* fix cti odt asset

* comment unused code in template

* phpdoc

* fix unreachable code

* fix unreachable code

* fix not falsy
This commit is contained in:
Frédéric FRANCE 2024-06-05 14:55:07 +02:00 committed by GitHub
parent 62593e2842
commit 74806473ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 82 additions and 78 deletions

View File

@ -2,6 +2,7 @@
<?php
/* Copyright (C) 2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2016 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2024 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
@ -124,7 +125,7 @@ while ($fields=fgetcsv($fhandle, $linelength, $delimiter, $enclosure, $escape))
$nboflines++;
$object = new User($db);
$object->statut = 1;
$object->status = 1;
$tmp=explode(' ', $fields[3], 2);
$object->firstname = trim($tmp[0]);

View File

@ -255,7 +255,7 @@ abstract class CommonDocGenerator
global $conf, $extrafields;
if ($member->photo) {
$logotouse = $conf->adherent->dir_output.'/'.get_exdir(0, 0, 0, 1, $member, 'user').'/photos/'.$member->photo;
$logotouse = $conf->member->dir_output.'/'.get_exdir(0, 0, 0, 1, $member, 'user').'/photos/'.$member->photo;
} else {
$logotouse = DOL_DOCUMENT_ROOT.'/public/theme/common/nophoto.png';
}
@ -386,7 +386,7 @@ abstract class CommonDocGenerator
'company_vatnumber' => $object->tva_intra,
'company_customercode' => $object->code_client,
'company_suppliercode' => $object->code_fournisseur,
'company_customeraccountancycode' => $object->code_compta,
'company_customeraccountancycode' => $object->code_compta_client,
'company_supplieraccountancycode' => $object->code_compta_fournisseur,
'company_juridicalstatus' => $object->forme_juridique,
'company_outstanding_limit' => $object->outstanding_limit,
@ -903,7 +903,7 @@ abstract class CommonDocGenerator
}
// Add info from $object->xxx where xxx has been loaded by fetch_origin() of shipment
if (!empty($object->commande) && is_object($object->commande)) {
if (is_object($object->commande) && !empty($object->commande->ref)) {
$array_shipment['order_ref'] = $object->commande->ref;
$array_shipment['order_ref_customer'] = $object->commande->ref_customer;
}

View File

@ -3,6 +3,7 @@
* Copyright (C) 2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2008-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 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
@ -34,8 +35,19 @@ class MenuManager
*/
public $db;
public $type_user; // Put 0 for internal users, 1 for external users
public $atarget = ""; // To store default target to use onto links
/**
* @var int Put 0 for internal users, 1 for external users
*/
public $type_user;
/**
* @var string To store default target to use onto links
*/
public $atarget = "";
/**
* @var string Menu name
*/
public $name = "auguria";
/**

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 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
@ -33,8 +34,19 @@ class MenuManager
*/
public $db;
public $type_user; // Put 0 for internal users, 1 for external users
public $atarget = ""; // To store default target to use onto links
/**
* @var int Put 0 for internal users, 1 for external users
*/
public $type_user;
/**
* @var string To store default target to use onto links
*/
public $atarget = "";
/**
* @var string Menu name
*/
public $name = "eldy";
/**
@ -118,9 +130,6 @@ class MenuManager
$menuArbo = new Menubase($this->db, 'eldy');
$menuArbo->menuLoad($mainmenu, $leftmenu, $this->type_user, 'eldy', $tabMenu);
$this->tabMenu = $tabMenu;
//var_dump($tabMenu);
//if ($forcemainmenu == 'all') { var_dump($this->tabMenu); exit; }
}
@ -136,8 +145,6 @@ class MenuManager
{
global $conf, $langs, $user;
//var_dump($this->tabMenu);
require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php';
if ($this->type_user == 1) {

View File

@ -332,10 +332,10 @@ class doc_generic_asset_odt extends ModelePDFAsset
$odfHandler = new Odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->asset->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
'PATH_TO_TMP' => $conf->asset->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
} catch (Exception $e) {
@ -346,9 +346,6 @@ class doc_generic_asset_odt extends ModelePDFAsset
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
//print html_entity_decode($odfHandler->__toString());
//print exit;
// Make substitutions into odt of freetext
try {
@ -403,9 +400,6 @@ class doc_generic_asset_odt extends ModelePDFAsset
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
} catch (OdfException $e) {
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
}
if ($foundtagforlines) {
$linenumber = 0;
@ -419,8 +413,6 @@ class doc_generic_asset_odt extends ModelePDFAsset
foreach ($tmparray as $key => $val) {
try {
$listlines->setVars($key, $val, true, 'UTF-8');
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
} catch (SegmentException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}

View File

@ -347,9 +347,6 @@ class doc_generic_bom_odt extends ModelePDFBom
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
//print html_entity_decode($odfHandler->__toString());
//print exit;
// Make substitutions into odt of freetext
try {
@ -402,9 +399,6 @@ class doc_generic_bom_odt extends ModelePDFBom
// We may arrive here if tags for lines not present into template
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
} catch (OdfException $e) {
$foundtagforlines = 0;
dol_syslog($e->getMessage(), LOG_INFO);
}
if ($foundtagforlines) {
$linenumber = 0;
@ -429,8 +423,6 @@ class doc_generic_bom_odt extends ModelePDFBom
foreach ($tmparray as $key => $val) {
try {
$listlines->setVars($key, $val, true, 'UTF-8');
} catch (OdfException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
} catch (SegmentException $e) {
dol_syslog($e->getMessage(), LOG_INFO);
}

View File

@ -8,7 +8,7 @@
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* This program is free software; you can redistribute it and/or modify
@ -523,10 +523,10 @@ class pdf_standard_myobject extends ModelePDFMyObject
$pdf->SetTextColor(0, 0, 0);
// Define size of image if we need it
$imglinesize = array();
if (!empty($realpatharray[$i])) {
$imglinesize = pdf_getSizeForImage($realpatharray[$i]);
}
// $imglinesize = array();
// if (!empty($realpatharray[$i])) {
// $imglinesize = pdf_getSizeForImage($realpatharray[$i]);
// }
$pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
@ -536,31 +536,31 @@ class pdf_standard_myobject extends ModelePDFMyObject
$posYAfterImage = 0;
$posYAfterDescription = 0;
if ($this->getColumnStatus('photo')) {
// We start with Photo of product line
if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
$pdf->AddPage('', '', true);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
$pdf->setPage($pageposbefore + 1);
// if ($this->getColumnStatus('photo')) {
// // We start with Photo of product line
// if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // If photo too high, we moved completely on new page
// $pdf->AddPage('', '', true);
// if (!empty($tplidx)) {
// $pdf->useTemplate($tplidx);
// }
// $pdf->setPage($pageposbefore + 1);
$curY = $tab_top_newpage;
// $curY = $tab_top_newpage;
// Allows data in the first page if description is long enough to break in multiples pages
if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
$showpricebeforepagebreak = 1;
} else {
$showpricebeforepagebreak = 0;
}
}
// // Allows data in the first page if description is long enough to break in multiples pages
// if (getDolGlobalInt('MAIN_PDF_DATA_ON_FIRST_PAGE')) {
// $showpricebeforepagebreak = 1;
// } else {
// $showpricebeforepagebreak = 0;
// }
// }
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// $pdf->Image does not increase value return by getY, so we save it manually
$posYAfterImage = $curY + $imglinesize['height'];
}
}
// if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height'])) {
// $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY + 1, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
// // $pdf->Image does not increase value return by getY, so we save it manually
// $posYAfterImage = $curY + $imglinesize['height'];
// }
// }
// Description of product line
if ($this->getColumnStatus('desc')) {
@ -578,7 +578,7 @@ class pdf_standard_myobject extends ModelePDFMyObject
$pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
$pdf->AddPage('', '', true);
@ -1241,24 +1241,24 @@ class pdf_standard_myobject extends ModelePDFMyObject
);
// PHOTO
$rank = $rank + 10;
$this->cols['photo'] = array(
'rank' => $rank,
'width' => (!getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')), // in mm
'status' => false,
'title' => array(
'textkey' => 'Photo',
'label' => ' '
),
'content' => array(
'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'border-left' => false, // remove left line separator
);
// $rank = $rank + 10;
// $this->cols['photo'] = array(
// 'rank' => $rank,
// 'width' => (!getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH') ? 20 : getDolGlobalInt('MAIN_DOCUMENTS_WITH_PICTURE_WIDTH')), // in mm
// 'status' => false,
// 'title' => array(
// 'textkey' => 'Photo',
// 'label' => ' '
// ),
// 'content' => array(
// 'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
// ),
// 'border-left' => false, // remove left line separator
// );
if (getDolGlobalInt('MAIN_GENERATE_INVOICES_WITH_PICTURE') && !empty($this->atleastonephoto)) {
$this->cols['photo']['status'] = true;
}
// if (getDolGlobalInt('MAIN_GENERATE_INVOICES_WITH_PICTURE') && !empty($this->atleastonephoto)) {
// $this->cols['photo']['status'] = true;
// }
$rank = $rank + 10;