diff --git a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php index 3293403644d..6c971cec66e 100644 --- a/htdocs/compta/stats/supplier_turnover_by_thirdparty.php +++ b/htdocs/compta/stats/supplier_turnover_by_thirdparty.php @@ -3,6 +3,7 @@ * Copyright (C) 2023 Ferran Marcet * Copyright (C) 2024 MDW * Copyright (C) 2024 Frédéric France + * Copyright (C) 2025 Alexandre Spangaro * * 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 @@ -66,11 +67,25 @@ $socid = GETPOSTINT('socid'); // Category $selected_cat = GETPOSTINT('search_categ'); +if ($selected_cat == -1) { + $selected_cat = 0; +} $subcat = false; if (GETPOST('subcat', 'alpha') === 'yes') { $subcat = true; } +// Security check +if ($user->socid > 0) { + $socid = $user->socid; +} +if (isModEnabled('comptabilite')) { + $result = restrictedArea($user, 'compta', '', '', 'resultat'); +} +if (isModEnabled('accounting')) { + $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); +} + // Hook $hookmanager->initHooks(array('supplierturnoverbythirdpartylist')); @@ -158,12 +173,24 @@ $commonparams['sortorder'] = $sortorder; $commonparams['sortfield'] = $sortfield; $headerparams = array(); -$headerparams['date_startyear'] = $date_startyear; -$headerparams['date_startmonth'] = $date_startmonth; -$headerparams['date_startday'] = $date_startday; -$headerparams['date_endyear'] = $date_endyear; -$headerparams['date_endmonth'] = $date_endmonth; -$headerparams['date_endday'] = $date_endday; +if (!empty($date_startyear)) { + $headerparams['date_startyear'] = $date_startyear; +} +if (!empty($date_startmonth)) { + $headerparams['date_startmonth'] = $date_startmonth; +} +if (!empty($date_startday)) { + $headerparams['date_startday'] = $date_startday; +} +if (!empty($date_endyear)) { + $headerparams['date_endyear'] = $date_endyear; +} +if (!empty($date_endmonth)) { + $headerparams['date_endmonth'] = $date_endmonth; +} +if (!empty($date_endday)) { + $headerparams['date_endday'] = $date_endday; +} $tableparams = array(); $tableparams['search_categ'] = $selected_cat; @@ -183,16 +210,7 @@ foreach ($allparams as $key => $value) { $paramslink .= '&'.$key.'='.$value; } -// Security check -if ($user->socid > 0) { - $socid = $user->socid; -} -if (isModEnabled('comptabilite')) { - $result = restrictedArea($user, 'compta', '', '', 'resultat'); -} -if (isModEnabled('accounting')) { - $result = restrictedArea($user, 'accounting', '', '', 'comptarapport'); -} + /* @@ -216,6 +234,8 @@ if ($modecompta == "BOOKKEEPINGCOLLECTED") { $calcmode = ''; $name = ''; +$namelink = ''; +$builddate = dol_now(); // Show report header if ($modecompta == "CREANCES-DETTES") { @@ -237,7 +257,6 @@ if ($modecompta == "CREANCES-DETTES") { // TODO } -$builddate = dol_now(); $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); $period .= ' - '; $period .= $form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzserver'); @@ -249,7 +268,7 @@ if ($date_end == dol_time_plus_duree($date_start, 1, 'y') - 1) { $exportlink = ''; -report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode); +report_header($name, $namelink, $period, $periodlink, $description, $builddate, $exportlink, $tableparams, $calcmode); if (isModEnabled('accounting')) { if ($modecompta != 'BOOKKEEPING') { diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 3b8c769b14a..c4375ae138e 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -1895,7 +1895,7 @@ class pdf_eratosthene extends ModelePDFCommandes $this->cols['position'] = array( 'rank' => $rank, 'width' => 10, - 'status' => getDolGlobalInt('PDF_ERATOSHTENE_ADD_POSITION') ? true : ((bool) getDolGlobalInt('PDF_ADD_POSITION')), + 'status' => (getDolGlobalInt('PDF_ERATOSTHENE_ADD_POSITION') || getDolGlobalInt('PDF_ERATOSHTENE_ADD_POSITION')) ? true : (getDolGlobalInt('PDF_ADD_POSITION') ? true : false), 'title' => array( 'textkey' => '#', // use lang key is useful in somme case with module 'align' => 'C', diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index d7949762329..f1469969582 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -275,13 +275,14 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf = pdf_getInstance($this->format); $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance - $heightforinfotot = 50; // Height reserved to output the info and total part + $pdf->SetAutoPageBreak(1, 0); + + $heightforinfotot = 40; // Height reserved to output the info and total part $heightforfreetext = getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT', 5); // Height reserved to output the free text on last page $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) { $heightforfooter += 6; } - $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) { $pdf->setPrintHeader(false); @@ -334,6 +335,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext; + $nexY = $tab_top - 1; + // Incoterm $height_incoterms = 0; if (isModEnabled('incoterm')) { @@ -343,7 +346,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pdf->SetFont('', '', $default_font_size - 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1, dol_htmlentitiesbr($desc_incoterms), 0, 1); - $nexY = $pdf->GetY(); + $nexY = max($pdf->GetY(), $nexY); $height_incoterms = $nexY - $tab_top; // Rect takes a length in 3rd parameter @@ -366,6 +369,8 @@ class pdf_cornas extends ModelePDFSuppliersOrders $pagenb = $pdf->getPage(); if (!empty($notetoshow)) { + $tab_top -= 2; + $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite; $pageposbeforenote = $pagenb; @@ -374,8 +379,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); - $tab_top -= 2; - $pdf->startTransaction(); $pdf->SetFont('', '', $default_font_size - 1); @@ -491,21 +494,11 @@ class pdf_cornas extends ModelePDFSuppliersOrders // Use new auto column system $this->prepareArrayColumnField($object, $outputlangs, $hidedetails, $hidedesc, $hideref); + $nexY = $tab_top + $this->tabTitleHeight; $pageposbeforeprintlines = $pdf->getPage(); $pagenb = $pageposbeforeprintlines; - // Show square - if ($pagenb == $pageposbeforeprintlines) { - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); - $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } else { - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); - $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } - - $nexY = $tab_top + $this->tabTitleHeight; - // Loop on each lines for ($i = 0; $i < $nblines; $i++) { $curY = $nexY; @@ -554,20 +547,20 @@ class pdf_cornas extends ModelePDFSuppliersOrders } // Description of product line - $curX = $this->posxdesc - 1; $showpricebeforepagebreak = 1; if ($this->getColumnStatus('desc')) { $pdf->startTransaction(); $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1); - $pageposafter = $pdf->getPage(); + if ($pageposafter > $pageposbefore) { // There is a pagebreak $pdf->rollbackTransaction(true); + $pageposafter = $pageposbefore; + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1); - $pageposafter = $pdf->getPage(); $posyafter = $pdf->GetY(); if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text @@ -594,8 +587,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders $posYAfterDescription = $pdf->GetY(); } - $nexY = $pdf->GetY(); + $nexY = max($pdf->GetY(), $posYAfterImage); + $pageposafter = $pdf->getPage(); + $pdf->setPage($pageposbefore); $pdf->setTopMargin($this->marge_haute); $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. @@ -797,6 +792,14 @@ class pdf_cornas extends ModelePDFSuppliersOrders } } + // Show square + if ($pagenb == $pageposbeforeprintlines) { + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code, $outputlangsbis); + } else { + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code, $outputlangsbis); + } + $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; + // Affiche zone infos $posy = $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);