FIX pdf supplier payment work
This commit is contained in:
parent
4230b075c2
commit
977c18513d
@ -130,8 +130,8 @@ else if ($action == 'specimen')
|
|||||||
{
|
{
|
||||||
$modele=GETPOST('module','alpha');
|
$modele=GETPOST('module','alpha');
|
||||||
|
|
||||||
$facture = new Facture($db);
|
$paiementFourn = new PaiementFourn($db);
|
||||||
$facture->initAsSpecimen();
|
$paiementFourn->initAsSpecimen();
|
||||||
|
|
||||||
// Search template files
|
// Search template files
|
||||||
$file=''; $classname=''; $filefound=0;
|
$file=''; $classname=''; $filefound=0;
|
||||||
@ -153,7 +153,7 @@ else if ($action == 'specimen')
|
|||||||
|
|
||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
if ($module->write_file($facture,$langs) > 0)
|
if ($module->write_file($paiementFourn,$langs) > 0)
|
||||||
{
|
{
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=supplier_payment&file=SPECIMEN.pdf");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -345,6 +345,9 @@ class Conf
|
|||||||
$this->fournisseur->facture=new stdClass();
|
$this->fournisseur->facture=new stdClass();
|
||||||
$this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture";
|
$this->fournisseur->facture->dir_output =$rootfordata."/fournisseur/facture";
|
||||||
$this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp";
|
$this->fournisseur->facture->dir_temp =$rootfordata."/fournisseur/facture/temp";
|
||||||
|
$this->fournisseur->payment=new stdClass();
|
||||||
|
$this->fournisseur->payment->dir_output =$rootfordata."/fournisseur/payment";
|
||||||
|
$this->fournisseur->payment->dir_temp =$rootfordata."/fournisseur/payment/temp";
|
||||||
|
|
||||||
// To prepare split of module fournisseur into fournisseur + supplier_order + supplier_invoice
|
// To prepare split of module fournisseur into fournisseur + supplier_order + supplier_invoice
|
||||||
if (! empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // By default, if module supplier is on, we set new properties
|
if (! empty($this->fournisseur->enabled) && empty($this->global->MAIN_USE_NEW_SUPPLIERMOD)) // By default, if module supplier is on, we set new properties
|
||||||
|
|||||||
@ -1874,6 +1874,16 @@ function dol_check_secure_access_document($modulepart,$original_file,$entity,$fu
|
|||||||
$original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file;
|
$original_file=$conf->fournisseur->facture->dir_output.'/'.$original_file;
|
||||||
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE facnumber='".$db->escape($refname)."' AND entity=".$conf->entity;
|
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."facture_fourn WHERE facnumber='".$db->escape($refname)."' AND entity=".$conf->entity;
|
||||||
}
|
}
|
||||||
|
// Wrapping pour les rapport de paiements
|
||||||
|
else if ($modulepart == 'supplier_payment')
|
||||||
|
{
|
||||||
|
if ($fuser->rights->fournisseur->facture->lire || preg_match('/^specimen/i',$original_file))
|
||||||
|
{
|
||||||
|
$accessallowed=1;
|
||||||
|
}
|
||||||
|
$original_file=$conf->fournisseur->payment->dir_output.'/'.$original_file;
|
||||||
|
$sqlprotectagainstexternals = "SELECT fk_soc as fk_soc FROM ".MAIN_DB_PREFIX."paiementfournisseur WHERE ref='".$db->escape($refname)."' AND entity=".$conf->entity;
|
||||||
|
}
|
||||||
|
|
||||||
// Wrapping pour les rapport de paiements
|
// Wrapping pour les rapport de paiements
|
||||||
else if ($modulepart == 'facture_paiement')
|
else if ($modulepart == 'facture_paiement')
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
* \brief Class file to generate the supplier invoices with the canelle model
|
* \brief Class file to generate the supplier invoices with the canelle model
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_invoice/modules_facturefournisseur.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||||
@ -157,13 +157,11 @@ class pdf_cow extends ModelePDFSuppliersPayments
|
|||||||
$outputlangs->load("bills");
|
$outputlangs->load("bills");
|
||||||
$outputlangs->load("products");
|
$outputlangs->load("products");
|
||||||
|
|
||||||
if ($conf->fournisseur->dir_output.'/facture')
|
if ($conf->fournisseur->payment->dir_output)
|
||||||
{
|
{
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
$deja_regle = $object->getSommePaiement();
|
$total = $object->montant;
|
||||||
//$amount_credit_notes_included = $object->getSumCreditNotesUsed();
|
|
||||||
//$amount_deposits_included = $object->getSumDepositsUsed();
|
|
||||||
|
|
||||||
// Definition of $dir and $file
|
// Definition of $dir and $file
|
||||||
if ($object->specimen)
|
if ($object->specimen)
|
||||||
@ -175,7 +173,7 @@ class pdf_cow extends ModelePDFSuppliersPayments
|
|||||||
{
|
{
|
||||||
$objectref = dol_sanitizeFileName($object->ref);
|
$objectref = dol_sanitizeFileName($object->ref);
|
||||||
$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
|
$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
|
||||||
$dir = $conf->fournisseur->payment->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'supplier_payment').$objectref;
|
$dir = $conf->fournisseur->payment->dir_output.'/'.$objectref;
|
||||||
$file = $dir . "/" . $objectref . ".pdf";
|
$file = $dir . "/" . $objectref . ".pdf";
|
||||||
if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
|
if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -660,6 +660,49 @@ class PaiementFourn extends Paiement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a document onto disk according to template model.
|
||||||
|
*
|
||||||
|
* @param string $modele Force template to use ('' to not force)
|
||||||
|
* @param Translate $outputlangs Object lang a utiliser pour traduction
|
||||||
|
* @param int $hidedetails Hide details of lines
|
||||||
|
* @param int $hidedesc Hide description
|
||||||
|
* @param int $hideref Hide ref
|
||||||
|
* @return int <0 if KO, 0 if nothing done, >0 if OK
|
||||||
|
*/
|
||||||
|
public function generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
|
||||||
|
{
|
||||||
|
global $conf, $user, $langs;
|
||||||
|
|
||||||
|
$langs->load("suppliers");
|
||||||
|
|
||||||
|
// Set the model on the model name to use
|
||||||
|
if (empty($modele))
|
||||||
|
{
|
||||||
|
if (! empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF))
|
||||||
|
{
|
||||||
|
$modele = $conf->global->SUPPLIER_PAYMENT_ADDON_PDF;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$modele = ''; // No default value. For supplier invoice, we allow to disable all PDF generation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($modele))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$modelpath = "core/modules/supplier_payment/pdf/";
|
||||||
|
|
||||||
|
return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the right way of payment
|
* get the right way of payment
|
||||||
*
|
*
|
||||||
|
|||||||
@ -43,6 +43,11 @@ $confirm = GETPOST('confirm','alpha');
|
|||||||
|
|
||||||
$object = new PaiementFourn($db);
|
$object = new PaiementFourn($db);
|
||||||
|
|
||||||
|
// PDF
|
||||||
|
$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
|
||||||
|
$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
|
||||||
|
$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
@ -134,6 +139,32 @@ if ($action == 'setdatep' && ! empty($_POST['datepday']))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build document
|
||||||
|
if ($action == 'builddoc')
|
||||||
|
{
|
||||||
|
// Save modele used
|
||||||
|
$object->fetch($id);
|
||||||
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
|
// Save last template used to generate document
|
||||||
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||||
|
|
||||||
|
$outputlangs = $langs;
|
||||||
|
$newlang=GETPOST('lang_id','alpha');
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
|
||||||
|
if (! empty($newlang))
|
||||||
|
{
|
||||||
|
$outputlangs = new Translate("",$conf);
|
||||||
|
$outputlangs->setDefaultLang($newlang);
|
||||||
|
}
|
||||||
|
$result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
$action='';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
@ -353,14 +384,13 @@ if ($result > 0)
|
|||||||
* Documents generes
|
* Documents generes
|
||||||
*/
|
*/
|
||||||
$ref=dol_sanitizeFileName($object->ref);
|
$ref=dol_sanitizeFileName($object->ref);
|
||||||
$subdir = get_exdir($object->id,2,0,0,$object,'supplier_payment').$ref;
|
$filedir = $conf->fournisseur->payment->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||||
$filedir = $conf->fournisseur->paiement->dir_output.'/'.get_exdir($object->id,2,0,0,$object,'supplier_payment').$ref;
|
|
||||||
$urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id;
|
$urlsource=$_SERVER['PHP_SELF'].'?id='.$object->id;
|
||||||
$genallowed=$user->rights->fournisseur->facture->creer;
|
$genallowed=$user->rights->fournisseur->facture->creer;
|
||||||
$delallowed=$user->rights->fournisseur->facture->supprimer;
|
$delallowed=$user->rights->fournisseur->facture->supprimer;
|
||||||
$modelpdf=(! empty($object->modelpdf)?$object->modelpdf:(empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF)?'':$conf->global->SUPPLIER_PAYMENT_ADDON_PDF));
|
$modelpdf=(! empty($object->modelpdf)?$object->modelpdf:(empty($conf->global->SUPPLIER_PAYMENT_ADDON_PDF)?'':$conf->global->SUPPLIER_PAYMENT_ADDON_PDF));
|
||||||
|
|
||||||
print $formfile->showdocuments('supplier_payment',$subdir,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,40,0,'','','',$societe->default_lang);
|
print $formfile->showdocuments('supplier_payment',$ref,$filedir,$urlsource,$genallowed,$delallowed,$modelpdf,1,0,0,40,0,'','','',$societe->default_lang);
|
||||||
$somethingshown=$formfile->numoffiles;
|
$somethingshown=$formfile->numoffiles;
|
||||||
|
|
||||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||||
|
|||||||
@ -98,3 +98,5 @@ CREATE TABLE llx_product_attribute_combination
|
|||||||
entity INT DEFAULT 1 NOT NULL
|
entity INT DEFAULT 1 NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ALTER TABLE llx_paiementfourn ADD COLUMN model_pdf varchar(255);
|
||||||
|
|
||||||
|
|||||||
@ -32,5 +32,6 @@ create table llx_paiementfourn
|
|||||||
num_paiement varchar(50), -- numero de paiement (cheque)
|
num_paiement varchar(50), -- numero de paiement (cheque)
|
||||||
note text,
|
note text,
|
||||||
fk_bank integer NOT NULL,
|
fk_bank integer NOT NULL,
|
||||||
statut smallint NOT NULL DEFAULT 0
|
statut smallint NOT NULL DEFAULT 0,
|
||||||
|
model_pdf varchar(255)
|
||||||
)ENGINE=innodb;
|
)ENGINE=innodb;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user