clean deprecated modelpdf to model_pdf

This commit is contained in:
Frédéric FRANCE 2021-02-08 18:30:09 +01:00
parent 2440c11eec
commit 815f3602e3
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
11 changed files with 31 additions and 25 deletions

View File

@ -3271,7 +3271,7 @@ class Commande extends CommonOrder
$sql .= " fk_input_reason=".($this->demand_reason_id > 0 ? $this->demand_reason_id : "null").",";
$sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";
$sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").",";
$sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").",";
$sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").",";
$sql .= " import_key=".(isset($this->import_key) ? "'".$this->db->escape($this->import_key)."'" : "null")."";
$sql .= " WHERE rowid=".$this->id;
@ -3921,7 +3921,7 @@ class Commande extends CommonOrder
if (!empty($this->model_pdf)) {
$modele = $this->model_pdf;
} elseif (!empty($this->modelpdf)) { // dperecated
} elseif (!empty($this->modelpdf)) { // deprecated
$modele = $this->modelpdf;
} elseif (!empty($conf->global->COMMANDE_ADDON_PDF)) {
$modele = $conf->global->COMMANDE_ADDON_PDF;

View File

@ -14,7 +14,7 @@
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2014-2019 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2015-2016 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2018-2019 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@ -280,7 +280,7 @@ class FactureRec extends CommonInvoice
$sql .= ", ".(!empty($facsrc->remise) ? $this->remise : '0');
$sql .= ", ".(!empty($this->note_private) ? ("'".$this->db->escape($this->note_private)."'") : "NULL");
$sql .= ", ".(!empty($this->note_public) ? ("'".$this->db->escape($this->note_public)."'") : "NULL");
$sql .= ", ".(!empty($this->modelpdf) ? ("'".$this->db->escape($this->modelpdf)."'") : "NULL");
$sql .= ", ".(!empty($this->model_pdf) ? ("'".$this->db->escape($this->model_pdf)."'") : "NULL");
$sql .= ", '".$this->db->escape($user->id)."'";
$sql .= ", ".(!empty($facsrc->fk_project) ? "'".$this->db->escape($facsrc->fk_project)."'" : "null");
$sql .= ", ".(!empty($facsrc->fk_account) ? "'".$this->db->escape($facsrc->fk_account)."'" : "null");
@ -347,7 +347,7 @@ class FactureRec extends CommonInvoice
{
// Extrafields
if (method_exists($facsrc->lines[$i], 'fetch_optionals')) {
$facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->rowid);
$facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->id);
$objectline->array_options = $facsrc->lines[$i]->array_options;
}
@ -562,7 +562,7 @@ class FactureRec extends CommonInvoice
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->user_author = $obj->fk_user_author;
$this->modelpdf = $obj->model_pdf; // deprecatd
$this->modelpdf = $obj->model_pdf; // deprecated
$this->model_pdf = $obj->model_pdf;
$this->rang = $obj->rang;
$this->special_code = $obj->special_code;
@ -1280,9 +1280,8 @@ class FactureRec extends CommonInvoice
{
// We refresh the object in order to have all necessary data (like date_lim_reglement)
$facture->fetch($facture->id);
$result = $facture->generateDocument($facturerec->modelpdf, $langs);
if ($result <= 0)
{
$result = $facture->generateDocument($facturerec->model_pdf, $langs);
if ($result <= 0) {
$this->errors = $facture->errors;
$this->error = $facture->error;
$error++;
@ -1873,7 +1872,7 @@ class FactureRec extends CommonInvoice
dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG);
if ($this->db->query($sql))
{
$this->modelpdf = $model;
$this->model_pdf = $model;
return 1;
} else {
dol_print_error($this->db);

View File

@ -498,7 +498,7 @@ class Facture extends CommonInvoice
$this->fk_project = GETPOST('projectid', 'int') > 0 ? ((int) GETPOST('projectid', 'int')) : $_facrec->fk_project;
$this->note_public = GETPOST('note_public', 'none') ? GETPOST('note_public', 'restricthtml') : $_facrec->note_public;
$this->note_private = GETPOST('note_private', 'none') ? GETPOST('note_private', 'restricthtml') : $_facrec->note_private;
$this->modelpdf = GETPOST('model', 'alpha') ? GETPOST('model', 'alpha') : $_facrec->modelpdf;
$this->model_pdf = GETPOST('model', 'alpha') ? GETPOST('model', 'alpha') : $_facrec->model_pdf;
$this->cond_reglement_id = GETPOST('cond_reglement_id', 'int') > 0 ? ((int) GETPOST('cond_reglement_id', 'int')) : $_facrec->cond_reglement_id;
$this->mode_reglement_id = GETPOST('mode_reglement_id', 'int') > 0 ? ((int) GETPOST('mode_reglement_id', 'int')) : $_facrec->mode_reglement_id;
$this->fk_account = GETPOST('fk_account') > 0 ? ((int) GETPOST('fk_account')) : $_facrec->fk_account;
@ -1062,8 +1062,8 @@ class Facture extends CommonInvoice
$facture->note_public = $this->note_public;
$facture->note_private = $this->note_private;
$facture->ref_client = $this->ref_client;
$facture->modelpdf = $this->modelpdf; // deprecated
$facture->model_pdf = $this->modelpdf;
$facture->modelpdf = $this->model_pdf; // deprecated
$facture->model_pdf = $this->model_pdf;
$facture->fk_project = $this->fk_project;
$facture->cond_reglement_id = $this->cond_reglement_id;
$facture->mode_reglement_id = $this->mode_reglement_id;
@ -3370,8 +3370,8 @@ class Facture extends CommonInvoice
}
$this->line->id = $rowid;
$this->line->rowid = $rowid;
$this->line->label = $label;
$this->line->rowid = $rowid;
$this->line->label = $label;
$this->line->desc = $desc;
$this->line->ref_ext = $ref_ext;
$this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative
@ -3732,7 +3732,7 @@ class Facture extends CommonInvoice
}
if (!empty($addon)) {
dol_syslog("Call getNextNumRef with ".$addonConstName." = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->nom.", type=".$soc->typent_code, LOG_DEBUG);
dol_syslog("Call getNextNumRef with ".$addonConstName." = ".$conf->global->FACTURE_ADDON.", thirdparty=".$soc->name.", type=".$soc->typent_code, LOG_DEBUG);
$mybool = false;

View File

@ -119,7 +119,7 @@ if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->facture
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
}
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
$fac->generateDocument($fac->modelpdf, $outputlangs);
$fac->generateDocument($fac->model_pdf, $outputlangs);
}
}

View File

@ -425,7 +425,7 @@ class Paiement extends CommonObject
$outputlangs->setDefaultLang($newlang);
}
$ret = $invoice->fetch($facid); // Reload to get new records
$result = $invoice->generateDocument($invoice->modelpdf, $outputlangs);
$result = $invoice->generateDocument($invoice->model_pdf, $outputlangs);
if ($result < 0) {
setEventMessages($invoice->error, $invoice->errors, 'errors');
$error++;

View File

@ -304,7 +304,7 @@ if (!$error && $massaction == 'confirm_presend')
if ($_POST['addmaindocfile'])
{
// TODO Use future field $objectobj->fullpathdoc to know where is stored default file
// TODO If not defined, use $objectobj->modelpdf (or defaut invoice config) to know what is template to use to regenerate doc.
// TODO If not defined, use $objectobj->model_pdf (or defaut invoice config) to know what is template to use to regenerate doc.
$filename = dol_sanitizeFileName($objectobj->ref).'.pdf';
$subdir = '';
// TODO Set subdir to be compatible with multi levels dir trees
@ -1281,7 +1281,7 @@ if (!$error && $massaction == 'generate_doc' && $permissiontoread)
if (empty($hideref)) $hideref = 0;
if (empty($moreparams)) $moreparams = null;
$result = $objecttmp->generateDocument($objecttmp->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
$result = $objecttmp->generateDocument($objecttmp->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
if ($result <= 0)
{

View File

@ -355,6 +355,13 @@ abstract class CommonObject
*/
public $model_pdf;
/**
* @var string
* @deprecated
* @see model_pdf
*/
public $modelpdf;
/**
* @var string
* Contains relative path of last generated main file

View File

@ -175,7 +175,7 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte
if ($regenerate || !dol_is_file($filename))
{
if ($usestdout) print "Build PDF for invoice ".$obj->ref." - Lang = ".$outputlangs->defaultlang."\n";
$result = $fac->generateDocument($regenerate ? $regenerate : $fac->modelpdf, $outputlangs);
$result = $fac->generateDocument($regenerate ? $regenerate : $fac->model_pdf, $outputlangs);
} else {
if ($usestdout) print "PDF for invoice ".$obj->ref." already exists\n";
}

View File

@ -581,7 +581,7 @@ class Expedition extends CommonObject
$this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed
$this->fk_delivery_address = $obj->fk_address;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; // deprecated
$this->shipping_method_id = $obj->fk_shipping_method;
$this->shipping_method = $obj->shipping_method;
$this->tracking_number = $obj->tracking_number;
@ -1116,7 +1116,7 @@ class Expedition extends CommonObject
$sql .= " weight=".(($this->trueWeight != '') ? $this->trueWeight : "null").",";
$sql .= " note_private=".(isset($this->note_private) ? "'".$this->db->escape($this->note_private)."'" : "null").",";
$sql .= " note_public=".(isset($this->note_public) ? "'".$this->db->escape($this->note_public)."'" : "null").",";
$sql .= " model_pdf=".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null").",";
$sql .= " model_pdf=".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null").",";
$sql .= " entity=".$conf->entity;
$sql .= " WHERE rowid=".$this->id;

View File

@ -1699,13 +1699,13 @@ class SupplierProposal extends CommonObject
$resql = $this->db->query($sql);
if ($resql)
{
$modelpdf = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED : (empty($this->modelpdf) ? '' : $this->modelpdf);
$modelpdf = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED : (empty($this->model_pdf) ? '' : $this->model_pdf);
$triggerName = 'PROPOSAL_SUPPLIER_CLOSE_REFUSED';
if ($status == 2)
{
$triggerName = 'PROPOSAL_SUPPLIER_CLOSE_SIGNED';
$modelpdf = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL : (empty($this->modelpdf) ? '' : $this->modelpdf);
$modelpdf = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL ? $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL : (empty($this->model_pdf) ? '' : $this->model_pdf);
if (!empty($conf->global->SUPPLIER_PROPOSAL_UPDATE_PRICE_ON_SUPPlIER_PROPOSAL)) // TODO This option was not tested correctly. Error if product ref does not exists
{