Debug v15
This commit is contained in:
parent
b0230ad42b
commit
a81d6ef405
@ -2012,7 +2012,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
|
||||
|
||||
// Generated documents
|
||||
$filename = dol_sanitizeFileName($object->ref);
|
||||
//$filename = 'tmp_cards.php';
|
||||
$filedir = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $object, 'member');
|
||||
$urlsource = $_SERVER['PHP_SELF'].'?id='.$object->id;
|
||||
$genallowed = $user->rights->adherent->lire;
|
||||
|
||||
@ -39,6 +39,7 @@ $day = dol_print_date($now, '%d');
|
||||
$foruserid = GETPOST('foruserid', 'alphanohtml');
|
||||
$foruserlogin = GETPOST('foruserlogin', 'alphanohtml');
|
||||
$mode = GETPOST('mode', 'aZ09');
|
||||
$modelcard = GETPOST("modelcard", 'aZ09'); // Doc template to use for business cards
|
||||
$model = GETPOST("model", 'aZ09'); // Doc template to use for business cards
|
||||
$modellabel = GETPOST("modellabel", 'aZ09'); // Doc template to use for address sheet
|
||||
$mesg = '';
|
||||
@ -84,10 +85,10 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
||||
$sql .= " WHERE d.fk_adherent_type = t.rowid AND d.statut = 1";
|
||||
$sql .= " AND d.entity IN (".getEntity('adherent').")";
|
||||
if (is_numeric($foruserid)) {
|
||||
$sql .= " AND d.rowid=".(int) $foruserid;
|
||||
$sql .= " AND d.rowid = ".(int) $foruserid;
|
||||
}
|
||||
if ($foruserlogin) {
|
||||
$sql .= " AND d.login='".$db->escape($foruserlogin)."'";
|
||||
$sql .= " AND d.login = '".$db->escape($foruserlogin)."'";
|
||||
}
|
||||
$sql .= " ORDER BY d.rowid ASC";
|
||||
|
||||
@ -143,7 +144,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
||||
'__MONTH__'=>$month,
|
||||
'__DAY__'=>$day,
|
||||
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
|
||||
'__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/"
|
||||
'__SERVER__'=>"https://".$_SERVER["SERVER_NAME"]."/"
|
||||
);
|
||||
complete_substitutions_array($substitutionarray, $langs, $adherentstatic);
|
||||
|
||||
@ -155,7 +156,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
||||
$textright = make_substitutions($conf->global->ADHERENT_CARD_TEXT_RIGHT, $substitutionarray);
|
||||
|
||||
if (is_numeric($foruserid) || $foruserlogin) {
|
||||
$nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY'];
|
||||
$nb = $_Avery_Labels[$model]['NX'] * $_Avery_Labels[$model]['NY']; // $_Avery_Labels is defined into an include
|
||||
if ($nb <= 0) {
|
||||
$nb = 1; // Protection to avoid empty page
|
||||
}
|
||||
@ -209,7 +210,19 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
||||
}
|
||||
|
||||
// Build and output PDF
|
||||
if (empty($mode) || $mode == 'card' || $mode == 'cardlogin') {
|
||||
$outputlangs = $langs;
|
||||
|
||||
if (empty($mode) || $mode == 'card') {
|
||||
if (!count($arrayofmembers)) {
|
||||
$mesg = $langs->trans("ErrorRecordNotFound");
|
||||
}
|
||||
if (empty($modelcard) || $modelcard == '-1') {
|
||||
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE"));
|
||||
}
|
||||
if (!$mesg) {
|
||||
$result = members_card_pdf_create($db, $arrayofmembers, $modelcard, $outputlangs, '', 'standard', 'tmp_cards');
|
||||
}
|
||||
} elseif ($mode == 'cardlogin') {
|
||||
if (!count($arrayofmembers)) {
|
||||
$mesg = $langs->trans("ErrorRecordNotFound");
|
||||
}
|
||||
@ -217,7 +230,7 @@ if ((!empty($foruserid) || !empty($foruserlogin) || !empty($mode)) && !$mesg) {
|
||||
$mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("DescADHERENT_CARD_TYPE"));
|
||||
}
|
||||
if (!$mesg) {
|
||||
$result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs);
|
||||
$result = members_card_pdf_create($db, $arrayofmembers, $model, $outputlangs, '', 'standard', 'tmp_cards_login');
|
||||
}
|
||||
} elseif ($mode == 'label') {
|
||||
if (!count($arrayofmembers)) {
|
||||
@ -275,7 +288,7 @@ foreach (array_keys($_Avery_Labels) as $codecards) {
|
||||
$arrayoflabels[$codecards] = $_Avery_Labels[$codecards]['name'];
|
||||
}
|
||||
asort($arrayoflabels);
|
||||
print $form->selectarray('model', $arrayoflabels, (GETPOST('model') ? GETPOST('model') : (empty($conf->global->ADHERENT_CARD_TYPE) ? '' : $conf->global->ADHERENT_CARD_TYPE)), 1, 0, 0, '', 0, 0, 0, '', '', 1);
|
||||
print $form->selectarray('modelcard', $arrayoflabels, (GETPOST('modelcard') ? GETPOST('modelcard') : (empty($conf->global->ADHERENT_CARD_TYPE) ? '' : $conf->global->ADHERENT_CARD_TYPE)), 1, 0, 0, '', 0, 0, 0, '', '', 1);
|
||||
print '<br><input type="submit" class="button" value="'.$langs->trans("BuildDoc").'">';
|
||||
print '</form>';
|
||||
|
||||
|
||||
@ -195,9 +195,10 @@ class doc_generic_member_odt extends ModelePDFMember
|
||||
* @param string $srctemplatepath Full path of source filename for generator using a template file
|
||||
* @param string $mode Tell if doc module is called for 'member', ...
|
||||
* @param int $nooutput 1=Generate only file on disk and do not return it on response
|
||||
* @param string $filename Name of output file (without extension)
|
||||
* @return int 1 if OK, <=0 if KO
|
||||
*/
|
||||
public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0)
|
||||
public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0, $filename = 'tmp_cards')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user, $langs, $conf, $mysoc, $hookmanager;
|
||||
|
||||
@ -243,9 +243,10 @@ class pdf_standard extends CommonStickerGenerator
|
||||
* @param string $srctemplatepath Full path of source filename for generator using a template file. Example: '5161', 'AVERYC32010', 'CARD', ...
|
||||
* @param string $mode Tell if doc module is called for 'member', ...
|
||||
* @param int $nooutput 1=Generate only file on disk and do not return it on response
|
||||
* @param string $filename Name of output file (without extension)
|
||||
* @return int 1=OK, 0=KO
|
||||
*/
|
||||
public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0)
|
||||
public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0, $filename = 'tmp_cards')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $user, $conf, $langs, $mysoc, $_Avery_Labels;
|
||||
@ -282,7 +283,7 @@ class pdf_standard extends CommonStickerGenerator
|
||||
'__MONTH__'=>$month,
|
||||
'__DAY__'=>$day,
|
||||
'__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT,
|
||||
'__SERVER__'=>"http://".$_SERVER["SERVER_NAME"]."/"
|
||||
'__SERVER__'=>"https://".$_SERVER["SERVER_NAME"]."/"
|
||||
);
|
||||
complete_substitutions_array($substitutionarray, $langs);
|
||||
|
||||
@ -320,7 +321,10 @@ class pdf_standard extends CommonStickerGenerator
|
||||
dol_print_error('', 'ErrorBadTypeForCard'.$this->code);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->type = 'pdf';
|
||||
$filename .= '.pdf';
|
||||
|
||||
// standard format or custom
|
||||
if ($this->Tformat['paper-size'] != 'custom') {
|
||||
$this->format = $this->Tformat['paper-size'];
|
||||
@ -349,7 +353,7 @@ class pdf_standard extends CommonStickerGenerator
|
||||
return -1;
|
||||
}
|
||||
|
||||
$filename = 'tmp_cards.pdf';
|
||||
|
||||
if (is_object($object)) {
|
||||
$outputdir = $conf->adherent->dir_output;
|
||||
$dir = $outputdir."/".get_exdir(0, 0, 0, 0, $object, 'member');
|
||||
|
||||
@ -74,9 +74,10 @@ class ModelePDFCards
|
||||
* @param Translate $outputlangs Object langs to use for translation
|
||||
* @param string $outputdir Output directory
|
||||
* @param string $template pdf generenate document class to use default 'standard'
|
||||
* @param string $filename Name of output file (without extension)
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir = '', $template = 'standard')
|
||||
function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $outputdir = '', $template = 'standard', $filename = 'tmp_cards')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
@ -125,7 +126,7 @@ function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $o
|
||||
foreach (array('doc', 'pdf') as $prefix) {
|
||||
$file = $prefix."_".$template.".class.php";
|
||||
|
||||
// On verifie l'emplacement du modele
|
||||
// We check that file of doc generaotr exists
|
||||
$file = dol_buildpath($reldir."core/modules/member/doc/".$file, 0);
|
||||
if (file_exists($file)) {
|
||||
$filefound = 1;
|
||||
@ -148,7 +149,7 @@ function members_card_pdf_create($db, $arrayofmembers, $modele, $outputlangs, $o
|
||||
// We save charset_output to restore it because write_file can change it if needed for
|
||||
// output format that does not support UTF8.
|
||||
$sav_charset_output = $outputlangs->charset_output;
|
||||
if ($obj->write_file($arrayofmembers, $outputlangs, $srctemplatepath) > 0) {
|
||||
if ($obj->write_file($arrayofmembers, $outputlangs, $srctemplatepath, 'member', 0, $filename) > 0) {
|
||||
$outputlangs->charset_output = $sav_charset_output;
|
||||
return 1;
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user