forked from Wavyzz/dolibarr
fix members cards (#35639)
* fix members cards * fix * fix members cards
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,22 +26,22 @@
|
||||
* \brief Page to output members business cards
|
||||
*/
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*
|
||||
* @var array<string,array{name:string,paper-size:string|array{0:float,1:float},orientation:string,metric:string,marginLeft:float,marginTop:float,NX:int,NY:int,SpaceX:float,SpaceY:float,width:float,height:float,font-size:int,custom_x:float,custom_y:float}> $_Avery_Labels
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php';
|
||||
/** @var array<string,array{name:string,paper-size:string|array{0:float,1:float},orientation:string,metric:string,marginLeft:float,marginTop:float,NX:int,NY:int,SpaceX:float,SpaceY:float,width:float,height:float,font-size:int,custom_x:float,custom_y:float}> $_Avery_Labels */
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/member/modules_cards.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/printsheet/modules_labels.php';
|
||||
|
||||
$langs->loadLangs(array("members", "errors"));
|
||||
|
||||
// Choice of printing year or current year.
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
/* Copyright (C) 2003 Steve Dillon
|
||||
* Copyright (C) 2003 Laurent Passebecq
|
||||
* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2015 Francis Appels <francis.appels@yahoo.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
/* Copyright (C) 2003 Steve Dillon
|
||||
* Copyright (C) 2003 Laurent Passebecq
|
||||
* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2015 Francis Appels <francis.appels@yahoo.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -112,7 +113,7 @@ abstract class CommonStickerGenerator extends CommonDocGenerator
|
||||
public $Tformat;
|
||||
|
||||
/**
|
||||
* @var array<string,array{name:string,paper-size:'custom'|array{0:float,1:float},orientation:string,metric:string,marginLeft:float,marginTop:float,NX:int,NY:int,SpaceX:float,SpaceY:float,width:float,height:float,font-size:int,custom_x:float,custom_y:float}>
|
||||
* @var ?array<string,array{name:string,paper-size:'custom'|array{0:float,1:float},orientation:string,metric:string,marginLeft:float,marginTop:float,NX:int,NY:int,SpaceX:float,SpaceY:float,width:float,height:float,font-size:int,custom_x:float,custom_y:float}>
|
||||
*/
|
||||
public $_Avery_Labels;
|
||||
// phpcs:enable
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Copyright (C) 2002-2003 Jean-Louis Bergamo <jlb@j1b.org>
|
||||
* Copyright (C) 2006-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2015 Francis Appels <francis.appels@yahoo.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -49,7 +49,7 @@ class pdf_standard_member extends CommonStickerGenerator
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
global $langs;
|
||||
global $langs, $_Avery_Labels;
|
||||
|
||||
// Translations
|
||||
$langs->loadLangs(array("main", "admin"));
|
||||
@@ -58,6 +58,7 @@ class pdf_standard_member extends CommonStickerGenerator
|
||||
$this->name = "standard";
|
||||
$this->description = $langs->trans('TemplateforBusinessCards');
|
||||
//$this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
|
||||
$this->_Avery_Labels = $_Avery_Labels;
|
||||
|
||||
$this->type = 'pdf-various-sizes';
|
||||
}
|
||||
@@ -165,7 +166,6 @@ class pdf_standard_member extends CommonStickerGenerator
|
||||
$pdf->Cell($this->_Width - 2 * $xleft, $this->_Line_Height, $outputlangs->convToOutputCharset($header), 0, 1, 'C');
|
||||
}
|
||||
|
||||
|
||||
$ytop += (empty($header) ? 0 : (1 + $this->_Line_Height));
|
||||
|
||||
// Define widthtouse and heighttouse
|
||||
@@ -275,7 +275,7 @@ class pdf_standard_member extends CommonStickerGenerator
|
||||
public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = '', $filename = 'tmp_cards')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user, $conf, $langs, $mysoc, $_Avery_Labels;
|
||||
global $user, $conf, $langs, $mysoc;
|
||||
|
||||
$this->code = $srctemplatepath;
|
||||
|
||||
@@ -356,7 +356,7 @@ class pdf_standard_member extends CommonStickerGenerator
|
||||
$textfooter = make_substitutions(getDolGlobalString("ADHERENT_CARD_FOOTER_TEXT"), $substitutionarray);
|
||||
$textright = make_substitutions(getDolGlobalString("ADHERENT_CARD_TEXT_RIGHT"), $substitutionarray);
|
||||
|
||||
$nb = $_Avery_Labels[$this->code]['NX'] * $_Avery_Labels[$this->code]['NY'];
|
||||
$nb = $this->_Avery_Labels[$this->code]['NX'] * $this->_Avery_Labels[$this->code]['NY'];
|
||||
if ($nb <= 0) {
|
||||
$nb = 1; // Protection to avoid empty page
|
||||
}
|
||||
@@ -380,7 +380,7 @@ class pdf_standard_member extends CommonStickerGenerator
|
||||
$arrayofrecords = $object;
|
||||
}
|
||||
|
||||
$this->Tformat = $_Avery_Labels[$this->code];
|
||||
$this->Tformat = $this->_Avery_Labels[$this->code];
|
||||
if (empty($this->Tformat)) {
|
||||
dol_print_error(null, 'ErrorBadTypeForCard'.$this->code);
|
||||
exit;
|
||||
@@ -426,8 +426,6 @@ class pdf_standard_member extends CommonStickerGenerator
|
||||
$file = $dir.'/'.$filename;
|
||||
}
|
||||
|
||||
//var_dump($file);exit;
|
||||
|
||||
if (!file_exists($dir)) {
|
||||
if (dol_mkdir($dir) < 0) {
|
||||
$this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
|
||||
|
||||
Reference in New Issue
Block a user