forked from Wavyzz/dolibarr
Fix: Creation PDF commande si model par defaut n'existe plus
This commit is contained in:
@@ -301,20 +301,20 @@ if ($_GET['action'] == 'modif' && $user->rights->commande->creer)
|
||||
$commande->reopen($user->id);
|
||||
}
|
||||
|
||||
if ($_POST['action'] == 'builddoc')
|
||||
if ($_REQUEST['action'] == 'builddoc') // En get ou en post
|
||||
{
|
||||
/*
|
||||
* Generation de la commande
|
||||
* d<>finit dans /includes/modules/commande/modules_commande.php
|
||||
*/
|
||||
commande_pdf_create($db, $_GET['id'],$_POST['model']);
|
||||
|
||||
}
|
||||
if($_GET['action'] == 'builddoc')
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$commande->fetch($_GET['id']);
|
||||
commande_pdf_create($db, $_GET['id'],$commande->modelpdf);
|
||||
$outputlangs = new Translate(DOL_DOCUMENT_ROOT ."/langs");
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
$result=commande_pdf_create($db, $_REQUEST['id'],$_REQUEST['model'],$outputlangs);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dolibarr_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -54,6 +54,7 @@ class ModelePDFCommandes extends FPDF
|
||||
|
||||
/**
|
||||
* \brief Renvoi la liste des mod<6F>les actifs
|
||||
* \return array Tableau des modeles (cle=id, valeur=libelle)
|
||||
*/
|
||||
function liste_modeles($db)
|
||||
{
|
||||
@@ -150,24 +151,33 @@ function commande_pdf_create($db, $id, $modele='', $outputlangs='')
|
||||
$langs->load("orders");
|
||||
|
||||
$dir = DOL_DOCUMENT_ROOT."/includes/modules/commande/";
|
||||
$modelisok=0;
|
||||
$liste=array();
|
||||
|
||||
// Positionne modele sur le nom du modele de commande <20> utiliser
|
||||
if (! strlen($modele))
|
||||
$file = "pdf_".$modele.".modules.php";
|
||||
if ($modele && file_exists($dir.$file)) $modelisok=1;
|
||||
|
||||
// Si model pas encore bon
|
||||
if (! $modelisok)
|
||||
{
|
||||
if ($conf->global->COMMANDE_ADDON_PDF)
|
||||
{
|
||||
$modele = $conf->global->COMMANDE_ADDON_PDF;
|
||||
if ($conf->global->COMMANDE_ADDON_PDF) $modele = $conf->global->COMMANDE_ADDON_PDF;
|
||||
$file = "pdf_".$modele.".modules.php";
|
||||
if (file_exists($dir.$file)) $modelisok=1;
|
||||
}
|
||||
else
|
||||
|
||||
// Si model pas encore bon
|
||||
if (! $modelisok)
|
||||
{
|
||||
print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_ADDON_PDF_NotDefined");
|
||||
return 0;
|
||||
}
|
||||
$model=new ModelePDFCommandes();
|
||||
$liste=$model->liste_modeles($db);
|
||||
$modele=key($liste); // Renvoie premiere valeur de cl<63> trouv<75> dans le tableau
|
||||
$file = "pdf_".$modele.".modules.php";
|
||||
if (file_exists($dir.$file)) $modelisok=1;
|
||||
}
|
||||
|
||||
// Charge le modele
|
||||
$file = "pdf_".$modele.".modules.php";
|
||||
if (file_exists($dir.$file))
|
||||
if ($modelisok)
|
||||
{
|
||||
$classname = "pdf_".$modele;
|
||||
require_once($dir.$file);
|
||||
@@ -188,8 +198,15 @@ function commande_pdf_create($db, $id, $modele='', $outputlangs='')
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $conf->global->COMMANDE_ADDON_PDF)
|
||||
{
|
||||
print $langs->trans("Error")." ".$langs->trans("Error_COMMANDE_ADDON_PDF_NotDefined");
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans("Error")." ".$langs->trans("ErrorFileDoesNotExists",$dir.$file);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user