Add & Update pdf_stdmouvement.modules.php

Fix Bug Generate pdf
This commit is contained in:
wdammak 2019-01-28 17:13:24 +01:00 committed by GitHub
parent 837821ebb6
commit 2ba7bb9d4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,12 +17,12 @@
*/ */
/** /**
* \file htdocs/core/modules/stock/doc/pdf_standard.modules.php * \file htdocs/core/modules/stock/doc/pdf_stdmouvement.modules.php
* \ingroup societe * \ingroup societe
* \brief File of class to build PDF documents for stocks/services * \brief File of class to build PDF documents for stocks movements
*/ */
require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_stock.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_movement.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
/** /**
* Class to build documents using ODF templates generator * Class to build documents using ODF templates generator
*/ */
class pdf_stdmouvement extends ModelePDFMouvement class pdf_stdmouvement extends ModelePDFMovement
{ {
/** /**
* @var DoliDb Database handler * @var DoliDb Database handler
@ -59,9 +59,9 @@ class pdf_stdmouvement extends ModelePDFMouvement
/** /**
* @var array() Minimum version of PHP required by module. * @var array() Minimum version of PHP required by module.
* e.g.: PHP ≥ 5.3 = array(5, 3) * e.g.: PHP ≥ 5.4 = array(5, 4)
*/ */
public $phpmin = array(5, 2); public $phpmin = array(5, 4);
/** /**
* Dolibarr version of the loaded document * Dolibarr version of the loaded document
@ -69,15 +69,46 @@ class pdf_stdmouvement extends ModelePDFMouvement
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
/**
* @var int page_largeur
*/
public $page_largeur; public $page_largeur;
/**
* @var int page_hauteur
*/
public $page_hauteur; public $page_hauteur;
/**
* @var array format
*/
public $format; public $format;
/**
* @var int marge_gauche
*/
public $marge_gauche; public $marge_gauche;
/**
* @var int marge_droite
*/
public $marge_droite; public $marge_droite;
/**
* @var int marge_haute
*/
public $marge_haute; public $marge_haute;
/**
* @var int marge_basse
*/
public $marge_basse; public $marge_basse;
public $emetteur; // Objet societe qui emet /**
* Issuer
* @var Societe
*/
public $emetteur;
/** /**
@ -89,8 +120,8 @@ class pdf_stdmouvement extends ModelePDFMouvement
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
$langs->load("main"); // Load traductions files requiredby by page
$langs->load("companies"); $langs->loadLangs(array("main", "companies"));
$this->db = $db; $this->db = $db;
$this->name = "stdmouvement"; $this->name = "stdmouvement";
@ -119,7 +150,7 @@ class pdf_stdmouvement extends ModelePDFMouvement
// Define position of columns // Define position of columns
$this->wref = 15; $this->wref = 15;
$this->posxidref = $this->marge_gauche; $this->posxidref = $this->marge_gauche;
$this->posxdatemouv = $this->marge_gauche+8;; $this->posxdatemouv = $this->marge_gauche+8;
$this->posxdesc=37; $this->posxdesc=37;
$this->posxlabel=50; $this->posxlabel=50;
$this->posxtva=80; $this->posxtva=80;
@ -149,6 +180,7 @@ class pdf_stdmouvement extends ModelePDFMouvement
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/** /**
* Function to build a document on disk using the generic odt module. * Function to build a document on disk using the generic odt module.
* *
@ -160,21 +192,17 @@ class pdf_stdmouvement extends ModelePDFMouvement
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @return int 1 if OK, <=0 if KO * @return int 1 if OK, <=0 if KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidedesc=0,$hideref=0) function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{ {
// phpcs:enable
global $user,$langs,$conf,$mysoc,$db,$hookmanager; global $user,$langs,$conf,$mysoc,$db,$hookmanager;
if (! is_object($outputlangs)) $outputlangs=$langs; if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
$outputlangs->load("main"); // Load traductions files requiredby by page
$outputlangs->load("dict"); $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
$outputlangs->load("companies");
$outputlangs->load("bills");
$outputlangs->load("stocks");
$outputlangs->load("orders");
$outputlangs->load("deliveries");
/** /**
* TODO: get from object * TODO: get from object
@ -219,7 +247,7 @@ class pdf_stdmouvement extends ModelePDFMouvement
// fetch optionals attributes and labels // fetch optionals attributes and labels
$extralabels = $extrafields->fetch_name_optionals_label('movement'); $extralabels = $extrafields->fetch_name_optionals_label('movement');
$search_array_options=$extrafields->getOptionalsFromPost($extralabels,'','search_'); $search_array_options=$extrafields->getOptionalsFromPost('movement','','search_');
$productlot=new ProductLot($db); $productlot=new ProductLot($db);
$productstatic=new Product($db); $productstatic=new Product($db);
@ -259,7 +287,7 @@ class pdf_stdmouvement extends ModelePDFMouvement
else else
$sql.= " AND date_format(m.datem, '%m') = '$month'"; $sql.= " AND date_format(m.datem, '%m') = '$month'";
} }
else if ($year > 0) elseif ($year > 0)
{ {
$sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
} }
@ -344,7 +372,7 @@ class pdf_stdmouvement extends ModelePDFMouvement
// Definition of $dir and $file // Definition of $dir and $file
if ($object->specimen) if ($object->specimen)
{ {
$dir = $conf->stock->dir_output . "/mouvement"; $dir = $conf->stock->dir_output . "/movement";
$file = $dir . "/SPECIMEN.pdf"; $file = $dir . "/SPECIMEN.pdf";
} }
else else
@ -352,7 +380,7 @@ class pdf_stdmouvement extends ModelePDFMouvement
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode; if(!empty($search_inventorycode)) $objectref.="_".$id."_".$search_inventorycode;
if($search_type_mouvement) $objectref.="_".$search_type_mouvement; if($search_type_mouvement) $objectref.="_".$search_type_mouvement;
$dir = $conf->stock->dir_output . "/mouvement/" . $objectref; $dir = $conf->stock->dir_output . "/movement/" . $objectref;
$file = $dir . "/" . $objectref . ".pdf"; $file = $dir . "/" . $objectref . ".pdf";
} }
@ -446,6 +474,7 @@ class pdf_stdmouvement extends ModelePDFMouvement
$totalunit=0; $totalunit=0;
$totalvalue=$totalvaluesell=0; $totalvalue=$totalvaluesell=0;
$arrayofuniqueproduct = array();
//dol_syslog('List products', LOG_DEBUG); //dol_syslog('List products', LOG_DEBUG);
$resql = $db->query($sql); $resql = $db->query($sql);
@ -684,7 +713,6 @@ class pdf_stdmouvement extends ModelePDFMouvement
// Total Qty // Total Qty
$pdf->SetXY($this->postotalht, $curY); $pdf->SetXY($this->postotalht, $curY);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $totalunit, 0, 'R', 0);
} }
else else
{ {
@ -790,7 +818,7 @@ class pdf_stdmouvement extends ModelePDFMouvement
* @param string $currency Currency code * @param string $currency Currency code
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
{ {
global $conf; global $conf;
@ -904,7 +932,6 @@ class pdf_stdmouvement extends ModelePDFMouvement
$pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26))); $pdf->SetLineStyle(array('dash'=>'0','color'=>array(220,26,26)));
$pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11); $pdf->line($this->marge_gauche, $tab_top+11, $this->page_largeur-$this->marge_droite, $tab_top+11);
$pdf->SetLineStyle(array('dash'=>0)); $pdf->SetLineStyle(array('dash'=>0));
} }
/** /**
@ -917,16 +944,13 @@ class pdf_stdmouvement extends ModelePDFMouvement
* @param string $titlekey Translation key to show as title of document * @param string $titlekey Translation key to show as title of document
* @return void * @return void
*/ */
function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="") function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "")
{ {
global $conf,$langs,$db,$hookmanager; global $conf,$langs,$db,$hookmanager;
$outputlangs->load("main"); // Load traductions files requiredby by page
$outputlangs->load("bills"); $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
$outputlangs->load("propal");
$outputlangs->load("companies");
$outputlangs->load("orders");
$outputlangs->load("stocks");
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
if ($object->type == 1) $titlekey='ServiceSheet'; if ($object->type == 1) $titlekey='ServiceSheet';
@ -1148,12 +1172,10 @@ class pdf_stdmouvement extends ModelePDFMouvement
* @param int $hidefreetext 1=Hide free text * @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text * @return int Return height of bottom margin including footer text
*/ */
function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0) function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
{ {
global $conf; global $conf;
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); return pdf_pagefoot($pdf,$outputlangs,'PRODUCT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
} }
} }