Standardize code. Use model_pdf.

This commit is contained in:
Laurent Destailleur 2020-08-18 14:48:38 +02:00
parent 6ce9d573e2
commit 964c4ef0d2
20 changed files with 55 additions and 49 deletions

View File

@ -1494,6 +1494,7 @@ class Propal extends CommonObject
$this->fk_project = $obj->fk_project; $this->fk_project = $obj->fk_project;
$this->project = null; // Clear if another value was already set by fetch_projet $this->project = null; // Clear if another value was already set by fetch_projet
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->last_main_doc = $obj->last_main_doc; $this->last_main_doc = $obj->last_main_doc;
$this->note = $obj->note_private; // TODO deprecated $this->note = $obj->note_private; // TODO deprecated

View File

@ -1824,6 +1824,7 @@ class Commande extends CommonOrder
$this->note = $obj->note_private; // deprecated $this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->last_main_doc = $obj->last_main_doc; $this->last_main_doc = $obj->last_main_doc;
$this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_id = $obj->fk_mode_reglement;

View File

@ -1581,6 +1581,7 @@ class Facture extends CommonInvoice
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->user_author = $obj->fk_user_author; $this->user_author = $obj->fk_user_author;
$this->user_valid = $obj->fk_user_valid; $this->user_valid = $obj->fk_user_valid;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->last_main_doc = $obj->last_main_doc; $this->last_main_doc = $obj->last_main_doc;
$this->situation_cycle_ref = $obj->situation_cycle_ref; $this->situation_cycle_ref = $obj->situation_cycle_ref;

View File

@ -726,6 +726,7 @@ class Contrat extends CommonObject
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->fk_projet = $obj->fk_project; // deprecated $this->fk_projet = $obj->fk_project; // deprecated

View File

@ -314,7 +314,7 @@ abstract class CommonObject
* @var string * @var string
* @see SetDocModel() * @see SetDocModel()
*/ */
public $modelpdf; public $model_pdf;
/** /**
* @var string * @var string
@ -2375,7 +2375,8 @@ abstract class CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$this->modelpdf = $modelpdf; $this->model_pdf = $modelpdf;
$this->modelpdf = $modelpdf; // For bakward compatibility
return 1; return 1;
} else { } else {
dol_print_error($this->db); dol_print_error($this->db);
@ -4538,7 +4539,7 @@ abstract class CommonObject
* Common function for all objects extending CommonObject for generating documents * Common function for all objects extending CommonObject for generating documents
* *
* @param string $modelspath Relative folder where generators are placed * @param string $modelspath Relative folder where generators are placed
* @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf','alpha') for example. * @param string $modele Generator to use. Caller must set it to obj->model_pdf or GETPOST('model_pdf','alpha') for example.
* @param Translate $outputlangs Output language to use * @param Translate $outputlangs Output language to use
* @param int $hidedetails 1 to hide details. 0 by default * @param int $hidedetails 1 to hide details. 0 by default
* @param int $hidedesc 1 to hide product description. 0 by default * @param int $hidedesc 1 to hide product description. 0 by default

View File

@ -50,8 +50,7 @@ class doc_generic_stock_odt extends ModelePDFStock
public $phpmin = array(5, 6); public $phpmin = array(5, 6);
/** /**
* Dolibarr version of the loaded document * @var string Dolibarr version of the loaded document
* @var string
*/ */
public $version = 'dolibarr'; public $version = 'dolibarr';
@ -116,16 +115,10 @@ class doc_generic_stock_odt extends ModelePDFStock
$form = new Form($this->db); $form = new Form($this->db);
$texte = $this->description.".<br>\n"; $texte = $this->description.".<br>\n";
$texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'; $texte .= '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">';
$texte .= '<input type="hidden" name="token" value="'.newToken().'">'; $texte .= '<input type="hidden" name="token" value="'.newToken().'">';
$texte .= '<input type="hidden" name="action" value="setModuleOptions">'; $texte .= '<input type="hidden" name="action" value="setModuleOptions">';
$texte .= '<input type="hidden" name="param1" value="STOCK_ADDON_PDF_ODT_PATH">'; $texte .= '<input type="hidden" name="param1" value="STOCK_ADDON_PDF_ODT_PATH">';
if ($conf->global->MAIN_PROPAL_CHOOSE_ODT_DOCUMENT > 0)
{
$texte .= '<input type="hidden" name="param2" value="STOCK_ADDON_PDF_ODT_DEFAULT">';
$texte .= '<input type="hidden" name="param3" value="STOCK_ADDON_PDF_ODT_TOBILL">';
$texte .= '<input type="hidden" name="param4" value="STOCK_ADDON_PDF_ODT_CLOSED">';
}
$texte .= '<table class="nobordernopadding" width="100%">'; $texte .= '<table class="nobordernopadding" width="100%">';
// List of directories area // List of directories area
@ -161,36 +154,31 @@ class doc_generic_stock_odt extends ModelePDFStock
$texte .= '<br></div></div>'; $texte .= '<br></div></div>';
// Scan directories // Scan directories
if (count($listofdir)) $nbofiles = count($listoffiles);
if (!empty($conf->global->STOCK_ADDON_PDF_ODT_PATH))
{ {
$texte .= $langs->trans("NumberOfModelFilesFound").': <b>'.count($listoffiles).'</b>'; $texte .= $langs->trans("NumberOfModelFilesFound").': <b>';
//$texte.=$nbofiles?'<a id="a_'.get_class($this).'" href="#">':'';
/*if ($conf->global->MAIN_STOCK_CHOOSE_ODT_DOCUMENT > 0) $texte .= count($listoffiles);
{ //$texte.=$nbofiles?'</a>':'';
// Model for creation $texte .= '</b>';
$liste=ModelePDFStock::liste_modeles($this->db);
$texte.= '<table width="50%;">';
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalCreate").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value2',$liste,$conf->global->STOCK_ADDON_PDF_ODT_DEFAULT);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalToBill").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value3',$liste,$conf->global->STOCK_ADDON_PDF_ODT_TOBILL);
$texte.= "</td></tr>";
$texte.= '<tr>';
$texte.= '<td width="60%;">'.$langs->trans("DefaultModelPropalClosed").'</td>';
$texte.= '<td colspan="">';
$texte.= $form->selectarray('value4',$liste,$conf->global->STOCK_ADDON_PDF_ODT_CLOSED);
$texte.= "</td></tr>";
$texte.= '</table>';
}*/
} }
if ($nbofiles)
{
$texte .= '<div id="div_'.get_class($this).'" class="hidden">';
foreach ($listoffiles as $file)
{
$texte .= $file['name'].'<br>';
}
$texte .= '</div>';
}
// Add input to upload a new template file.
$texte .= '<div>'.$langs->trans("UploadNewTemplate").' <input type="file" name="uploadfile">';
$texte .= '<input type="hidden" value="STOCK_ADDON_PDF_ODT_PATH" name="keyforuploaddir">';
$texte .= '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Upload")).'" name="upload">';
$texte .= '</div>';
$texte .= '</td>'; $texte .= '</td>';
$texte .= '<td rowspan="2" class="tdtop hideonsmartphone">'; $texte .= '<td rowspan="2" class="tdtop hideonsmartphone">';

View File

@ -510,7 +510,7 @@ class pdf_standard extends ModelePDFStock
$nexY += 2; $nexY += 2;
$curY = $nexY; $curY = $nexY;
if (! $object->specimen) { if ($nblines > 0) {
$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(200, 200, 200))); $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(200, 200, 200)));
$pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1); $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
$pdf->SetLineStyle(array('dash'=>0)); $pdf->SetLineStyle(array('dash'=>0));

View File

@ -686,6 +686,7 @@ class Don extends CommonObject
$this->amount = $obj->amount; $this->amount = $obj->amount;
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
// Retreive all extrafield // Retreive all extrafield

View File

@ -570,6 +570,7 @@ class Expedition extends CommonObject
$this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real $this->date_shipping = $this->db->jdate($obj->date_expedition); // Date real
$this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed
$this->fk_delivery_address = $obj->fk_address; $this->fk_delivery_address = $obj->fk_address;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->shipping_method_id = $obj->fk_shipping_method; $this->shipping_method_id = $obj->fk_shipping_method;
$this->shipping_method = $obj->shipping_method; $this->shipping_method = $obj->shipping_method;

View File

@ -448,7 +448,8 @@ class Fichinter extends CommonObject
$this->fk_project = $obj->fk_project; $this->fk_project = $obj->fk_project;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->modelpdf = $obj->model_pdf; $this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf;
$this->fk_contrat = $obj->fk_contrat; $this->fk_contrat = $obj->fk_contrat;
$this->user_creation = $obj->fk_user_author; $this->user_creation = $obj->fk_user_author;

View File

@ -280,6 +280,7 @@ class FichinterRec extends Fichinter
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->user_author = $obj->fk_user_author; $this->user_author = $obj->fk_user_author;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->rang = $obj->rang; $this->rang = $obj->rang;
$this->special_code = $obj->special_code; $this->special_code = $obj->special_code;

View File

@ -392,6 +392,7 @@ class CommandeFournisseur extends CommonOrder
$this->note = $obj->note_private; // deprecated $this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
//Incoterms //Incoterms

View File

@ -710,7 +710,7 @@ class FactureFournisseur extends CommonInvoice
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->model_pdf = $obj->model_pdf; $this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->import_key = $obj->import_key; $this->import_key = $obj->import_key;
//Incoterms //Incoterms

View File

@ -314,6 +314,7 @@ class Livraison extends CommonObject
$this->note = $obj->note_private; //TODO deprecated $this->note = $obj->note_private; //TODO deprecated
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->origin = $obj->origin; // May be 'shipping' $this->origin = $obj->origin; // May be 'shipping'
$this->origin_id = $obj->origin_id; // May be id of shipping $this->origin_id = $obj->origin_id; // May be id of shipping

View File

@ -790,20 +790,20 @@ $modulepart = 'stock';
if ($action != 'create' && $action != 'edit' && $action != 'delete') if ($action != 'create' && $action != 'edit' && $action != 'delete')
{ {
print '<br/>'; print '<br>';
print '<div class="fichecenter"><div class="fichehalfleft">'; print '<div class="fichecenter"><div class="fichehalfleft">';
print '<a name="builddoc"></a>'; // ancre print '<a name="builddoc"></a>'; // ancre
// Documents // Documents
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);
$relativepath = $comref.'/'.$objectref.'.pdf'; $relativepath = $object->ref.'/'.$objectref.'.pdf';
$filedir = $conf->stock->dir_output.'/'.$objectref; $filedir = $conf->stock->dir_output.'/'.$objectref;
$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id; $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
$genallowed = $usercanread; $genallowed = $usercanread;
$delallowed = $usercancreate; $delallowed = $usercancreate;
$modulepart = 'stock'; $modulepart = 'stock';
print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf, 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object);
$somethingshown = $formfile->numoffiles; $somethingshown = $formfile->numoffiles;
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@ -451,8 +451,8 @@ class Entrepot extends CommonObject
return -1; return -1;
} }
$sql = "SELECT rowid, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id, phone, fax"; $sql = "SELECT rowid, entity, fk_parent, ref as label, description, statut, lieu, address, zip, town, fk_pays as country_id, phone, fax,";
$sql .= ", entity"; $sql .= " model_pdf, import_key";
$sql .= " FROM ".MAIN_DB_PREFIX."entrepot"; $sql .= " FROM ".MAIN_DB_PREFIX."entrepot";
if ($id) if ($id)
{ {
@ -482,8 +482,11 @@ class Entrepot extends CommonObject
$this->zip = $obj->zip; $this->zip = $obj->zip;
$this->town = $obj->town; $this->town = $obj->town;
$this->country_id = $obj->country_id; $this->country_id = $obj->country_id;
$this->phone = $obj->phone; $this->phone = $obj->phone;
$this->fax = $obj->fax; $this->fax = $obj->fax;
$this->model_pdf = $obj->model_pdf;
$this->import_key = $obj->import_key;
// Retreive all extrafield // Retreive all extrafield
// fetch optionals attributes and labels // fetch optionals attributes and labels

View File

@ -521,6 +521,7 @@ class Project extends CommonObject
$this->opp_amount = $obj->opp_amount; $this->opp_amount = $obj->opp_amount;
$this->opp_percent = $obj->opp_percent; $this->opp_percent = $obj->opp_percent;
$this->budget_amount = $obj->budget_amount; $this->budget_amount = $obj->budget_amount;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->usage_opportunity = (int) $obj->usage_opportunity; $this->usage_opportunity = (int) $obj->usage_opportunity;
$this->usage_task = (int) $obj->usage_task; $this->usage_task = (int) $obj->usage_task;

View File

@ -400,6 +400,7 @@ class Reception extends CommonObject
$this->date_reception = $this->db->jdate($obj->date_reception); // Date real $this->date_reception = $this->db->jdate($obj->date_reception); // Date real
$this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed
$this->fk_delivery_address = $obj->fk_address; $this->fk_delivery_address = $obj->fk_address;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->shipping_method_id = $obj->fk_shipping_method; $this->shipping_method_id = $obj->fk_shipping_method;
$this->tracking_number = $obj->tracking_number; $this->tracking_number = $obj->tracking_number;

View File

@ -1636,6 +1636,7 @@ class Societe extends CommonObject
$this->note = $obj->note_private; // TODO Deprecated for backward comtability $this->note = $obj->note_private; // TODO Deprecated for backward comtability
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;
$this->note_public = $obj->note_public; $this->note_public = $obj->note_public;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->default_lang = $obj->default_lang; $this->default_lang = $obj->default_lang;
$this->logo = $obj->logo; $this->logo = $obj->logo;

View File

@ -1244,6 +1244,7 @@ class SupplierProposal extends CommonObject
$this->total_ttc = $obj->total; $this->total_ttc = $obj->total;
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->fk_project = $obj->fk_project; $this->fk_project = $obj->fk_project;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; $this->modelpdf = $obj->model_pdf;
$this->note = $obj->note_private; // TODO deprecated $this->note = $obj->note_private; // TODO deprecated
$this->note_private = $obj->note_private; $this->note_private = $obj->note_private;