Fix generation of doc for supplier payment
This commit is contained in:
parent
e152e81d18
commit
e56d74f5c4
@ -1134,4 +1134,29 @@ class Paiement extends CommonObject
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the third party of object, from id into this->thirdparty
|
||||||
|
*
|
||||||
|
* @param int $force_thirdparty_id Force thirdparty id
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function fetch_thirdparty($force_thirdparty_id=0)
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php';
|
||||||
|
|
||||||
|
if (empty($force_thirdparty_id))
|
||||||
|
{
|
||||||
|
$billsarray = $this->getBillsArray(); // From payment, the fk_soc isn't available, we should load the first supplier invoice to get him
|
||||||
|
if (!empty($billsarray))
|
||||||
|
{
|
||||||
|
$supplier_invoice = new FactureFournisseur($this->db);
|
||||||
|
if ($supplier_invoice->fetch($billsarray[0]) > 0)
|
||||||
|
{
|
||||||
|
$force_thirdparty_id = $supplier_invoice->fk_soc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::fetch_thirdparty($force_thirdparty_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,9 +19,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
|
* \file htdocs/core/modules/supplier_invoice/doc/pdf_standard.modules.php
|
||||||
* \ingroup fournisseur
|
* \ingroup fournisseur
|
||||||
* \brief Class file to generate the supplier invoices with the canelle model
|
* \brief Class file to generate the supplier invoice payment file with the standard model
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php';
|
||||||
@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php';
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class to generate the supplier invoices with the canelle model
|
* Class to generate the supplier invoices payment file with the standard model
|
||||||
*/
|
*/
|
||||||
class pdf_standard extends ModelePDFSuppliersPayments
|
class pdf_standard extends ModelePDFSuppliersPayments
|
||||||
{
|
{
|
||||||
@ -114,6 +114,10 @@ class pdf_standard extends ModelePDFSuppliersPayments
|
|||||||
$this->localtax2=array();
|
$this->localtax2=array();
|
||||||
$this->atleastoneratenotnull=0;
|
$this->atleastoneratenotnull=0;
|
||||||
$this->atleastonediscount=0;
|
$this->atleastonediscount=0;
|
||||||
|
|
||||||
|
// Recupere emetteur
|
||||||
|
$this->emetteur=$mysoc;
|
||||||
|
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -132,12 +136,6 @@ class pdf_standard extends ModelePDFSuppliersPayments
|
|||||||
{
|
{
|
||||||
global $user,$langs,$conf,$mysoc,$hookmanager;
|
global $user,$langs,$conf,$mysoc,$hookmanager;
|
||||||
|
|
||||||
// Get source company
|
|
||||||
if (! is_object($object->thirdparty)) $object->fetch_thirdparty();
|
|
||||||
if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc; // If fetch_thirdparty fails, object has no socid (specimen)
|
|
||||||
$this->emetteur=$object->thirdparty;
|
|
||||||
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
|
|
||||||
|
|
||||||
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';
|
||||||
@ -682,17 +680,17 @@ class pdf_standard extends ModelePDFSuppliersPayments
|
|||||||
// Sender properties
|
// Sender properties
|
||||||
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
|
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
|
||||||
|
|
||||||
// Show sender
|
// Show payer
|
||||||
$posy=42;
|
$posy=42;
|
||||||
$posx=$this->marge_gauche;
|
$posx=$this->marge_gauche;
|
||||||
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
|
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
|
||||||
$hautcadre=40;
|
$hautcadre=40;
|
||||||
/*
|
|
||||||
// Show sender frame
|
// Show sender frame
|
||||||
$pdf->SetTextColor(0,0,0);
|
$pdf->SetTextColor(0,0,0);
|
||||||
$pdf->SetFont('','', $default_font_size - 2);
|
$pdf->SetFont('','', $default_font_size - 2);
|
||||||
$pdf->SetXY($posx,$posy-5);
|
$pdf->SetXY($posx,$posy-5);
|
||||||
$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L');
|
$pdf->MultiCell(66,5, $outputlangs->transnoentities("PayedBy").":", 0, 'L');
|
||||||
$pdf->SetXY($posx,$posy);
|
$pdf->SetXY($posx,$posy);
|
||||||
$pdf->SetFillColor(230,230,230);
|
$pdf->SetFillColor(230,230,230);
|
||||||
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
|
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
|
||||||
@ -709,24 +707,8 @@ class pdf_standard extends ModelePDFSuppliersPayments
|
|||||||
$pdf->SetFont('','', $default_font_size - 1);
|
$pdf->SetFont('','', $default_font_size - 1);
|
||||||
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
|
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
|
||||||
|
|
||||||
*/
|
// Payed
|
||||||
|
$thirdparty = $object->thirdparty;
|
||||||
// If BILLING contact defined on invoice, we use it
|
|
||||||
$usecontact=false;
|
|
||||||
$arrayidcontact=$object->getIdContact('internal','BILLING');
|
|
||||||
if (count($arrayidcontact) > 0)
|
|
||||||
{
|
|
||||||
$usecontact=true;
|
|
||||||
$result=$object->fetch_contact($arrayidcontact[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Recipient name
|
|
||||||
// On peut utiliser le nom de la societe du contact
|
|
||||||
if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
|
|
||||||
$thirdparty = $object->contact;
|
|
||||||
} else {
|
|
||||||
$thirdparty = $mysoc;
|
|
||||||
}
|
|
||||||
|
|
||||||
$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs);
|
||||||
|
|
||||||
@ -743,7 +725,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
|
|||||||
$pdf->SetTextColor(0,0,0);
|
$pdf->SetTextColor(0,0,0);
|
||||||
$pdf->SetFont('','', $default_font_size - 2);
|
$pdf->SetFont('','', $default_font_size - 2);
|
||||||
$pdf->SetXY($posx+2,$posy-5);
|
$pdf->SetXY($posx+2,$posy-5);
|
||||||
$pdf->MultiCell($widthrecbox, 5, "",0,'L');
|
$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("PayedTo").":",0,'L');
|
||||||
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
|
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
|
||||||
|
|
||||||
// Show recipient name
|
// Show recipient name
|
||||||
|
|||||||
@ -738,4 +738,32 @@ class PaiementFourn extends Paiement
|
|||||||
|
|
||||||
return $way;
|
return $way;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the third party of object, from id into this->thirdparty
|
||||||
|
*
|
||||||
|
* @param int $force_thirdparty_id Force thirdparty id
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
function fetch_thirdparty($force_thirdparty_id=0)
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php';
|
||||||
|
|
||||||
|
if (empty($force_thirdparty_id))
|
||||||
|
{
|
||||||
|
$billsarray = $this->getBillsArray(); // From payment, the fk_soc isn't available, we should load the first supplier invoice to get him
|
||||||
|
if (!empty($billsarray))
|
||||||
|
{
|
||||||
|
$supplier_invoice = new FactureFournisseur($this->db);
|
||||||
|
if ($supplier_invoice->fetch($billsarray[0]) > 0)
|
||||||
|
{
|
||||||
|
$force_thirdparty_id = $supplier_invoice->fk_soc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::fetch_thirdparty($force_thirdparty_id);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -370,32 +370,36 @@ if ($result > 0)
|
|||||||
}
|
}
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
/*
|
|
||||||
print '<div class="fichecenter"><div class="fichehalfleft">';
|
print '<div class="fichecenter"><div class="fichehalfleft">';
|
||||||
|
|
||||||
// Documents generes
|
// Documents generes
|
||||||
$ref=dol_sanitizeFileName($object->ref);
|
|
||||||
$filedir = $conf->fournisseur->payment->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
|
||||||
$urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id;
|
|
||||||
$genallowed=$user->rights->fournisseur->facture->lire;
|
|
||||||
$delallowed=$user->rights->fournisseur->facture->creer;
|
|
||||||
$modelpdf=(! empty($object->modelpdf)?$object->modelpdf:(empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF)?'':$conf->global->SUPPLIER_PAYMENT_ADDON_PDF));
|
|
||||||
|
|
||||||
print $formfile->showdocuments('supplier_payment',$ref,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,40,0,'','','',$societe->default_lang);
|
include_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php';
|
||||||
$somethingshown=$formfile->numoffiles;
|
$modellist=ModelePDFSuppliersPayments::liste_modeles($db);
|
||||||
|
if (is_array($modellist))
|
||||||
|
{
|
||||||
|
$ref=dol_sanitizeFileName($object->ref);
|
||||||
|
$filedir = $conf->fournisseur->payment->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||||
|
$urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id;
|
||||||
|
$genallowed=$user->rights->fournisseur->facture->lire;
|
||||||
|
$delallowed=$user->rights->fournisseur->facture->creer;
|
||||||
|
$modelpdf=(! empty($object->modelpdf)?$object->modelpdf:(empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF)?'':$conf->global->SUPPLIER_PAYMENT_ADDON_PDF));
|
||||||
|
|
||||||
|
print $formfile->showdocuments('supplier_payment',$ref,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,40,0,'','','',$societe->default_lang);
|
||||||
|
$somethingshown=$formfile->numoffiles;
|
||||||
|
}
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
//print '</td><td valign="top" width="50%">';
|
|
||||||
//print '<br>';
|
//print '<br>';
|
||||||
|
|
||||||
// List of actions on element
|
// List of actions on element
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
/*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
|
||||||
$formactions=new FormActions($db);
|
$formactions=new FormActions($db);
|
||||||
$somethingshown = $formactions->showactions($object,'supplier_payment',$socid,1,'listaction'.($genallowed?'largetitle':''));
|
$somethingshown = $formactions->showactions($object,'supplier_payment',$socid,1,'listaction'.($genallowed?'largetitle':''));
|
||||||
|
*/
|
||||||
|
|
||||||
print '</div></div></div>';
|
print '</div></div></div>';
|
||||||
//print '</td></tr></table>';
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -912,3 +912,5 @@ CommentPage=Comments space
|
|||||||
CommentAdded=Comment added
|
CommentAdded=Comment added
|
||||||
CommentDeleted=Comment deleted
|
CommentDeleted=Comment deleted
|
||||||
Everybody=Everybody
|
Everybody=Everybody
|
||||||
|
PayedBy=Payed by
|
||||||
|
PayedTo=Payed to
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user