Fix warning

This commit is contained in:
Laurent Destailleur 2020-12-13 13:34:21 +01:00
parent 427fb16256
commit 3d33d3aa3a
10 changed files with 76 additions and 52 deletions

View File

@ -18,16 +18,6 @@
* See https://medium.com/@lhartikk/a-blockchain-in-200-lines-of-code-963cc1cc0e54
*/
/*ini_set('unserialize_callback_func', 'mycallback');
function mycallback($classname)
{
//var_dump($classname);
include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
}*/
/**
* Class to manage Blocked Log
@ -454,7 +444,9 @@ class BlockedLog
'ref', 'multicurrency_code', 'multicurrency_total_ht', 'multicurrency_total_tva', 'multicurrency_total_ttc', 'qty', 'product_type', 'vat_src_code', 'tva_tx', 'info_bits', 'localtax1_tx', 'localtax2_tx', 'total_ht', 'total_tva', 'total_ttc', 'total_localtax1', 'total_localtax2'
))) continue; // Discard if not into a dedicated list
if (!is_object($this->object_data->invoiceline[$lineid])) $this->object_data->invoiceline[$lineid] = new stdClass();
if (empty($this->object_data->invoiceline[$lineid]) || !is_object($this->object_data->invoiceline[$lineid])) { // To avoid warning
$this->object_data->invoiceline[$lineid] = new stdClass();
}
$this->object_data->invoiceline[$lineid]->{$keyline} = $valueline;
}
@ -465,7 +457,7 @@ class BlockedLog
if (!empty($object->newref)) $this->object_data->ref = $object->newref;
} elseif ($this->element == 'invoice_supplier')
{
foreach ($object as $key=>$value)
foreach ($object as $key => $value)
{
if (in_array($key, $arrayoffieldstoexclude)) continue; // Discard some properties
if (!in_array($key, array(

View File

@ -962,8 +962,8 @@ class Commande extends CommonOrder
$sql .= ", ".($this->demand_reason_id > 0 ? $this->demand_reason_id : "null");
$sql .= ", ".($delivery_date ? "'".$this->db->idate($delivery_date)."'" : "null");
$sql .= ", ".($this->fk_delivery_address > 0 ? $this->fk_delivery_address : 'NULL');
$sql .= ", ".($this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL');
$sql .= ", ".($this->warehouse_id > 0 ? $this->warehouse_id : 'NULL');
$sql .= ", ".(!empty($this->shipping_method_id) && $this->shipping_method_id > 0 ? $this->shipping_method_id : 'NULL');
$sql .= ", ".(!empty($this->warehouse_id) && $this->warehouse_id > 0 ? $this->warehouse_id : 'NULL');
$sql .= ", ".($this->remise_absolue > 0 ? $this->db->escape($this->remise_absolue) : 'NULL');
$sql .= ", ".($this->remise_percent > 0 ? $this->db->escape($this->remise_percent) : 0);
$sql .= ", ".(int) $this->fk_incoterms;
@ -1605,8 +1605,8 @@ class Commande extends CommonOrder
$this->line->tva_tx = $txtva;
$this->line->localtax1_tx = ($total_localtax1 ? $localtaxes_type[1] : 0);
$this->line->localtax2_tx = ($total_localtax2 ? $localtaxes_type[3] : 0);
$this->line->localtax1_type = $localtaxes_type[0];
$this->line->localtax2_type = $localtaxes_type[2];
$this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
$this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
$this->line->fk_product = $fk_product;
$this->line->product_type = $product_type;
$this->line->fk_remise_except = $fk_remise_except;
@ -3924,7 +3924,9 @@ class Commande extends CommonOrder
if (!dol_strlen($modele)) {
$modele = 'einstein';
if (!empty($this->modelpdf)) {
if (!empty($this->model_pdf)) {
$modele = $this->model_pdf;
} elseif (!empty($this->modelpdf)) { // dperecated
$modele = $this->modelpdf;
} elseif (!empty($conf->global->COMMANDE_ADDON_PDF)) {
$modele = $conf->global->COMMANDE_ADDON_PDF;

View File

@ -186,6 +186,8 @@ class Facture extends CommonInvoice
public $fac_rec;
public $date_pointoftax;
// Multicurrency
/**
* @var int ID
@ -645,7 +647,7 @@ class Facture extends CommonInvoice
$sql .= ", ".$this->cond_reglement_id;
$sql .= ", ".$this->mode_reglement_id;
$sql .= ", '".$this->db->idate($this->date_lim_reglement)."'";
$sql .= ", ".(isset($this->modelpdf) ? "'".$this->db->escape($this->modelpdf)."'" : "null");
$sql .= ", ".(isset($this->model_pdf) ? "'".$this->db->escape($this->model_pdf)."'" : "null");
$sql .= ", ".($this->situation_cycle_ref ? "'".$this->db->escape($this->situation_cycle_ref)."'" : "null");
$sql .= ", ".($this->situation_counter ? "'".$this->db->escape($this->situation_counter)."'" : "null");
$sql .= ", ".($this->situation_final ? $this->situation_final : 0);
@ -1080,6 +1082,8 @@ class Facture extends CommonInvoice
$facture->retained_warranty_fk_cond_reglement = $this->retained_warranty_fk_cond_reglement;
$facture->retained_warranty_date_limit = $this->retained_warranty_date_limit;
$facture->fk_user_author = $user->id;
// Loop on each line of new invoice
foreach ($facture->lines as $i => $tmpline)
@ -1164,8 +1168,10 @@ class Facture extends CommonInvoice
// Clear fields
$object->date = (empty($this->date) ? dol_now() : $this->date);
$object->user_author = $user->id;
$object->user_valid = '';
$object->user_author = $user->id; // deprecated
$object->user_valid = null; // deprecated
$object->fk_user_author = $user->id;
$object->fk_user_valid = null;
$object->fk_facture_source = 0;
$object->date_creation = '';
$object->date_modification = '';
@ -1317,8 +1323,9 @@ class Facture extends CommonInvoice
// get extrafields from original line
$object->lines[$i]->fetch_optionals();
foreach ($object->lines[$i]->array_options as $options_key => $value)
foreach ($object->lines[$i]->array_options as $options_key => $value) {
$line->array_options[$options_key] = $value;
}
$this->lines[$i] = $line;
}
@ -1348,6 +1355,8 @@ class Facture extends CommonInvoice
$this->origin = $object->element;
$this->origin_id = $object->id;
$this->fk_user_author = $user->id;
// get extrafields from original line
$object->fetch_optionals();
foreach ($object->array_options as $options_key => $value)
@ -1362,8 +1371,7 @@ class Facture extends CommonInvoice
$ret = $this->create($user);
if ($ret > 0)
{
if ($ret > 0) {
// Actions hooked (by external module)
$hookmanager->initHooks(array('invoicedao'));
@ -1600,8 +1608,10 @@ class Facture extends CommonInvoice
$this->note = $obj->note_private; // deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
$this->user_author = $obj->fk_user_author;
$this->user_valid = $obj->fk_user_valid;
$this->user_author = $obj->fk_user_author; // deprecated
$this->user_valid = $obj->fk_user_valid; // deprecated
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_valid = $obj->fk_user_valid;
$this->model_pdf = $obj->model_pdf;
$this->modelpdf = $obj->model_pdf; // deprecated
$this->last_main_doc = $obj->last_main_doc;
@ -1890,7 +1900,7 @@ class Facture extends CommonInvoice
$sql .= " date_lim_reglement=".(strval($this->date_lim_reglement) != '' ? "'".$this->db->idate($this->date_lim_reglement)."'" : '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 .= " situation_cycle_ref=".(empty($this->situation_cycle_ref) ? "null" : $this->db->escape($this->situation_cycle_ref)).",";
$sql .= " situation_counter=".(empty($this->situation_counter) ? "null" : $this->db->escape($this->situation_counter)).",";
@ -2113,7 +2123,7 @@ class Facture extends CommonInvoice
$rowid = $this->id;
dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".$this->thirdparty->name, LOG_DEBUG);
dol_syslog(get_class($this)."::delete rowid=".$rowid.", ref=".$this->ref.", thirdparty=".(empty($this->thirdparty) ? '' : $this->thirdparty->name), LOG_DEBUG);
// Test to avoid invoice deletion (allowed if draft)
$result = $this->is_erasable();
@ -4118,7 +4128,7 @@ class Facture extends CommonInvoice
*/
public function initAsSpecimen($option = '')
{
global $conf, $langs;
global $conf, $langs, $user;
$now = dol_now();
$arraynow = dol_getdate($now);
@ -4167,6 +4177,8 @@ class Facture extends CommonInvoice
$this->note_private = 'This is a comment (private)';
$this->note = 'This is a comment (private)';
$this->fk_user_author = $user->id;
$this->multicurrency_tx = 1;
$this->multicurrency_code = $conf->currency;
@ -4326,8 +4338,8 @@ class Facture extends CommonInvoice
/**
* Create a document onto disk according to template module.
*
* @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf','alpha') for example.
* @param Translate $outputlangs objet lang a utiliser pour traduction
* @param string $modele Generator to use. Caller must set it to obj->model_pdf or GETPOST('model','alpha') for example.
* @param Translate $outputlangs Object lang to use for translation
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
@ -4345,7 +4357,9 @@ class Facture extends CommonInvoice
$modele = 'crabe';
$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$this->type;
if (!empty($this->modelpdf)) {
if (!empty($this->model_pdf)) {
$modele = $this->model_pdf;
} elseif (!empty($this->modelpdf)) { // deprecated
$modele = $this->modelpdf;
} elseif (!empty($conf->global->$thisTypeConfName)) {
$modele = $conf->global->$thisTypeConfName;

View File

@ -2417,7 +2417,9 @@ class Contrat extends CommonObject
if (!dol_strlen($modele)) {
$modele = 'strato';
if (!empty($this->modelpdf)) {
if (!empty($this->model_pdf)) {
$modele = $this->model_pdf;
} elseif (!empty($this->modelpdf)) { // deprecated
$modele = $this->modelpdf;
} elseif (!empty($conf->global->CONTRACT_ADDON_PDF)) {
$modele = $conf->global->CONTRACT_ADDON_PDF;

View File

@ -195,6 +195,11 @@ abstract class CommonObject
*/
public $ref;
/**
* @var string An external reference for the object
*/
public $ref_ext;
/**
* @var string The object's previous reference
*/
@ -205,11 +210,6 @@ abstract class CommonObject
*/
public $ref_next;
/**
* @var string An external reference for the object
*/
public $ref_ext;
/**
* @var int The object's status
* @see setStatut()
@ -469,6 +469,12 @@ abstract class CommonObject
*/
public $specimen = 0;
/**
* @var int Id of contact to send object (used by the trigger of module Agenda)
*/
public $sendtoid;
/**
* @var array List of child tables. To test if we can delete object.
*/

View File

@ -2483,15 +2483,16 @@ class Expedition extends CommonObject
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
{
global $conf, $langs;
global $conf;
$langs->load("sendings");
$outputlangs->load("products");
if (!dol_strlen($modele)) {
$modele = 'rouget';
if (!empty($this->modelpdf)) {
if (!empty($this->model_pdf)) {
$modele = $this->model_pdf;
} elseif (!empty($this->modelpdf)) { // deprecated
$modele = $this->modelpdf;
} elseif (!empty($conf->global->EXPEDITION_ADDON_PDF)) {
$modele = $conf->global->EXPEDITION_ADDON_PDF;

View File

@ -2274,12 +2274,14 @@ class ExpenseReport extends CommonObject
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
{
global $conf, $langs;
global $conf;
$langs->load("trips");
$outputlangs->load("trips");
if (!dol_strlen($modele)) {
if (!empty($this->modelpdf)) {
if (!empty($this->model_pdf)) {
$modele = $this->model_pdf;
} elseif (!empty($this->modelpdf)) { // deprecated
$modele = $this->modelpdf;
} elseif (!empty($conf->global->EXPENSEREPORT_ADDON_PDF)) {
$modele = $conf->global->EXPENSEREPORT_ADDON_PDF;

View File

@ -696,14 +696,16 @@ class Fichinter extends CommonObject
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
{
global $conf, $langs;
global $conf;
$langs->load("interventions");
$outputlangs->load("interventions");
if (!dol_strlen($modele)) {
$modele = 'soleil';
if (!empty($this->modelpdf)) {
if (!empty($this->model_pdf)) {
$modele = $this->model_pdf;
} elseif (!empty($this->modelpdf)) { // deprecated
$modele = $this->modelpdf;
} elseif (!empty($conf->global->FICHEINTER_ADDON_PDF)) {
$modele = $conf->global->FICHEINTER_ADDON_PDF;

View File

@ -1896,14 +1896,16 @@ class Task extends CommonObject
*/
public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
{
global $conf, $langs;
global $conf;
$langs->load("projects");
$outputlangs->load("projects");
if (!dol_strlen($modele)) {
$modele = 'nodefault';
if (!empty($this->modelpdf)) {
if (!empty($this->model_pdf)) {
$modele = $this->model_pdf;
} elseif (!empty($this->modelpdf)) { // deprecated
$modele = $this->modelpdf;
} elseif (!empty($conf->global->PROJECT_TASK_ADDON_PDF)) {
$modele = $conf->global->PROJECT_TASK_ADDON_PDF;

View File

@ -239,9 +239,10 @@ class FactureTest extends PHPUnit\Framework\TestCase
array(
'newref','oldref','id','lines','client','thirdparty','brouillon','user_author','date_creation','date_validation','datem','date_modification',
'ref','statut','paye','specimen','ref','actiontypecode','actionmsg2','actionmsg','mode_reglement','cond_reglement',
'cond_reglement_doc','situation_cycle_ref','situation_counter','situation_final','multicurrency_total_ht','multicurrency_total_tva',
'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx',
'retained_warranty' ,'retained_warranty_date_limit', 'retained_warranty_fk_cond_reglement', 'specimen', 'trackid'
'cond_reglement_doc', 'modelpdf',
'multicurrency_total_ht','multicurrency_total_tva', 'multicurrency_total_ttc','fk_multicurrency','multicurrency_code','multicurrency_tx',
'retained_warranty' ,'retained_warranty_date_limit', 'retained_warranty_fk_cond_reglement', 'specimen', 'situation_cycle_ref', 'situation_counter', 'situation_final',
'trackid','user_creat','user_valid'
)
);
$this->assertEquals($arraywithdiff, array()); // Actual, Expected