From 9677a370e96fbfa9c80edd536a639fe378b96223 Mon Sep 17 00:00:00 2001 From: MDW Date: Thu, 17 Oct 2024 01:44:54 +0200 Subject: [PATCH] Qual: Nullable mysoc hint (#31393) * Qual: Nullable mysoc hint # Qual: Nullable mysoc hint $mysoc can be nullable resulting in issues (#31387) so it is best to detect these cases with static analysis * Prevent null assignment --- dev/tools/phan/config.php | 2 +- .../doc/doc_generic_asset_odt.modules.php | 4 ++++ .../asset/doc/pdf_standard_asset.modules.php | 15 ++++++++++----- .../core/modules/bank/doc/pdf_ban.modules.php | 16 ++++++++++------ .../bank/doc/pdf_sepamandate.modules.php | 16 ++++++++++------ .../bom/doc/doc_generic_bom_odt.modules.php | 4 ++++ .../modules/cheque/doc/pdf_blochet.class.php | 16 ++++++++++------ .../doc/doc_generic_order_odt.modules.php | 5 +++++ .../commande/doc/pdf_einstein.modules.php | 17 +++++++++++------ .../commande/doc/pdf_eratosthene.modules.php | 5 +++++ .../doc/doc_generic_contract_odt.modules.php | 5 +++++ .../contract/doc/pdf_strato.modules.php | 11 ++++++++--- .../delivery/doc/pdf_storm.modules.php | 5 +++++ .../delivery/doc/pdf_typhon.modules.php | 17 +++++++++++------ .../doc/doc_generic_shipment_odt.modules.php | 5 +++++ .../expedition/doc/pdf_espadon.modules.php | 5 +++++ .../expedition/doc/pdf_merou.modules.php | 5 +++++ .../expedition/doc/pdf_rouget.modules.php | 17 +++++++++++------ .../pdf_standard_expensereport.modules.php | 19 ++++++++++++------- .../doc/doc_generic_invoice_odt.modules.php | 7 ++++++- .../modules/facture/doc/pdf_crabe.modules.php | 17 +++++++++++------ .../facture/doc/pdf_octopus.modules.php | 17 +++++++++++------ .../facture/doc/pdf_sponge.modules.php | 5 +++++ .../fichinter/doc/pdf_soleil.modules.php | 11 ++++++++--- .../doc/pdf_standard_evaluation.modules.php | 11 ++++++++--- .../doc/doc_generic_member_odt.class.php | 7 ++++++- .../pdf_standard_movementstock.modules.php | 17 +++++++++++------ .../mrp/doc/doc_generic_mo_odt.modules.php | 5 +++++ .../modules/mrp/doc/pdf_vinci.modules.php | 11 ++++++++--- .../doc/doc_generic_product_odt.modules.php | 5 +++++ .../product/doc/pdf_standard.modules.php | 8 ++++++++ .../doc/doc_generic_project_odt.modules.php | 5 +++++ .../project/doc/pdf_baleine.modules.php | 17 +++++++++++------ .../project/doc/pdf_beluga.modules.php | 17 +++++++++++------ .../project/doc/pdf_timespent.modules.php | 17 +++++++++++------ .../task/doc/doc_generic_task_odt.modules.php | 5 +++++ .../doc/doc_generic_proposal_odt.modules.php | 5 +++++ .../modules/propale/doc/pdf_azur.modules.php | 17 +++++++++++------ .../modules/propale/doc/pdf_cyan.modules.php | 17 +++++++++++------ .../doc/doc_generic_reception_odt.modules.php | 5 +++++ .../reception/doc/pdf_squille.modules.php | 17 +++++++++++------ .../societe/doc/doc_generic_odt.modules.php | 7 ++++++- .../doc/doc_generic_stock_odt.modules.php | 5 +++++ .../stock/doc/pdf_standard_stock.modules.php | 17 +++++++++++------ .../stocktransfer/doc/pdf_eagle.modules.php | 17 +++++++++++------ .../doc/pdf_eagle_proforma.modules.php | 17 +++++++++++------ ...c_generic_supplier_invoice_odt.modules.php | 7 ++++++- ...doc_generic_supplier_order_odt.modules.php | 9 +++++++-- .../supplier_order/doc/pdf_cornas.modules.php | 17 +++++++++++------ .../doc/pdf_muscadet.modules.php | 17 +++++++++++------ .../pdf_standard_supplierpayment.modules.php | 5 +++++ ..._generic_supplier_proposal_odt.modules.php | 7 ++++++- .../doc/pdf_aurore.modules.php | 17 +++++++++++------ .../doc/pdf_zenith.modules.php | 17 +++++++++++------ .../doc/doc_generic_ticket_odt.modules.php | 5 +++++ .../user/doc/doc_generic_user_odt.modules.php | 5 +++++ .../doc/doc_generic_usergroup_odt.modules.php | 5 +++++ .../doc/doc_generic_myobject_odt.modules.php | 5 +++++ .../doc/pdf_standard_myobject.modules.php | 18 +++++++++++------- ...ric_recruitmentjobposition_odt.modules.php | 5 +++++ ...tandard_recruitmentjobposition.modules.php | 17 +++++++++++------ 61 files changed, 474 insertions(+), 177 deletions(-) diff --git a/dev/tools/phan/config.php b/dev/tools/phan/config.php index 4d4e78b6bef..618dc52befa 100644 --- a/dev/tools/phan/config.php +++ b/dev/tools/phan/config.php @@ -266,7 +266,7 @@ return [ 'linkedObjectBlock' => '\CommonObject[]', // See htdocs/core/class/html.form.class.php 'mainmenu' => 'string', 'menumanager' => '\MenuManager', - 'mysoc' => '\Societe', + 'mysoc' => '?\Societe', 'nblines' => '\int', 'objectoffield' => '\CommonObject', 'objsoc' => '\Societe', diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index 38b336269c9..60ad4222a7f 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -83,6 +83,10 @@ class doc_generic_asset_odt extends ModelePDFAsset $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php index e98ee2642a9..6876e5de43d 100644 --- a/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php +++ b/htdocs/core/modules/asset/doc/pdf_standard_asset.modules.php @@ -115,11 +115,6 @@ class pdf_standard_asset extends ModelePDFAsset $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } // Define position of columns $this->posxdesc = $this->marge_gauche + 1; // used for notes and other stuff @@ -135,6 +130,16 @@ class pdf_standard_asset extends ModelePDFAsset $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; $this->situationinvoice = false; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index 3606b28ca31..cf9664fe761 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -83,18 +83,22 @@ class pdf_ban extends ModeleBankAccountDoc $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - // Retrieves transmitter - $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define column position $this->posxref = $this->marge_gauche + 1; $this->posxlabel = $this->marge_gauche + 25; $this->posxworkload = $this->marge_gauche + 100; $this->posxdatestart = $this->marge_gauche + 150; $this->posxdateend = $this->marge_gauche + 170; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Retrieves issuer + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index 9f1852ccacc..53cbce641f2 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -94,12 +94,6 @@ class pdf_sepamandate extends ModeleBankAccountDoc $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - // Retrieves transmitter - $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define column position $this->posxref = $this->marge_gauche; @@ -112,6 +106,16 @@ class pdf_sepamandate extends ModeleBankAccountDoc $this->heightforfreetext = (getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') > 0 ? getDolGlobalInt('MAIN_PDF_FREETEXT_HEIGHT') : 5); $this->heightforfooter = $this->marge_basse + 8; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Retrieves issuer + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 884ced2b01b..bfa428bb13b 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -78,6 +78,10 @@ class doc_generic_bom_odt extends ModelePDFBom $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 8e6660856a7..f77851f4e74 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -89,16 +89,20 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); - // Retrieves transmitter - $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define column position $this->line_height = 5; $this->line_per_page = 40; $this->tab_height = 200; //$this->line_height * $this->line_per_page; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Retrieves issuer + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 4e174e69e28..41ff51ed49d 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -85,6 +85,11 @@ class doc_generic_order_odt extends ModelePDFCommandes $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index f00d76ee07e..e1c7e967b49 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -120,12 +120,6 @@ class pdf_einstein extends ModelePDFCommandes $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; if (getDolGlobalInt('PRODUCT_USE_UNITS')) { @@ -161,6 +155,17 @@ class pdf_einstein extends ModelePDFCommandes $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index ac999c10042..ca459a281ad 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -125,6 +125,11 @@ class pdf_eratosthene extends ModelePDFCommandes $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) { diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 53d3f3e4d1b..124b0889085 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -82,6 +82,11 @@ class doc_generic_contract_odt extends ModelePDFContract $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index ca43aa31e92..36ceddedab1 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -117,14 +117,19 @@ class pdf_strato extends ModelePDFContract $this->option_multilang = 0; // Available in several languages $this->option_draft_watermark = 1; // Support add of a watermark on drafts + // Define position of columns + $this->posxdesc = $this->marge_gauche + 1; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined } - - // Define position of columns - $this->posxdesc = $this->marge_gauche + 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php index e61453a8fc2..586a1c4f48c 100644 --- a/htdocs/core/modules/delivery/doc/pdf_storm.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_storm.modules.php @@ -105,6 +105,11 @@ class pdf_storm extends ModelePDFDeliveryOrder $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) { diff --git a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php index 5f9173e7581..67de9034188 100644 --- a/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/delivery/doc/pdf_typhon.modules.php @@ -108,12 +108,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; $this->posxcomm = 112; // customer comment @@ -131,6 +125,17 @@ class pdf_typhon extends ModelePDFDeliveryOrder //$this->posxdiscount-=20; //$this->postotalht-=20; } + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index 8b3178e980b..5cbba7e69f0 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -85,6 +85,11 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php index 61406d87272..d0e7a9c81ff 100644 --- a/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_espadon.modules.php @@ -113,6 +113,11 @@ class pdf_espadon extends ModelePdfExpedition $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) { diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index fccb96c7e60..e2361d79373 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -102,6 +102,11 @@ class pdf_merou extends ModelePdfExpedition $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 5cf08c6ad01..5dc3ce3799e 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -112,12 +112,6 @@ class pdf_rouget extends ModelePdfExpedition $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; - // Get source company - $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; $this->posxweightvol = $this->page_largeur - $this->marge_droite - 82; @@ -152,6 +146,17 @@ class pdf_rouget extends ModelePdfExpedition $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); $this->posxqtyordered = $this->posxqtytoship; } + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php index 88e18d4d23f..773ac744898 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard_expensereport.modules.php @@ -131,13 +131,6 @@ class pdf_standard_expensereport extends ModeleExpenseReport $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - // Get source company - $this->emetteur = $mysoc; - - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxpiece = $this->marge_gauche + 1; $this->posxcomment = $this->marge_gauche + 10; @@ -171,6 +164,18 @@ class pdf_standard_expensereport extends ModeleExpenseReport $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index d66f6158741..f4435c982ed 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -84,7 +84,12 @@ class doc_generic_invoice_odt extends ModelePDFFactures $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts - // Recupere emetteur + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Retrieves issuer $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // Par default, si n'etait pas defini diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 60660b9aa30..949207182d1 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -134,12 +134,6 @@ class pdf_crabe extends ModelePDFFactures $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; if (getDolGlobalInt('PRODUCT_USE_UNITS')) { @@ -179,6 +173,17 @@ class pdf_crabe extends ModelePDFFactures $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; $this->situationinvoice = false; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } diff --git a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php index 2a8a8dd7c2d..33971fc1244 100644 --- a/htdocs/core/modules/facture/doc/pdf_octopus.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_octopus.modules.php @@ -225,12 +225,6 @@ class pdf_octopus extends ModelePDFFactures $this->watermark = ''; $this->franchise = !$mysoc->tva_assuj; // not used ? - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; // used for notes and other stuff @@ -251,6 +245,17 @@ class pdf_octopus extends ModelePDFFactures } else { dol_syslog("object is empty, do not call getDataSituation..."); } + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 0bd6c80857f..695cae7dd81 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -159,6 +159,11 @@ class pdf_sponge extends ModelePDFFactures $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) { diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 6bcde30e3ec..ee153262b43 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -107,14 +107,19 @@ class pdf_soleil extends ModelePDFFicheinter $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; + // Define position of columns + $this->posxdesc = $this->marge_gauche + 1; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if not defined } - - // Define position of columns - $this->posxdesc = $this->marge_gauche + 1; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php b/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php index 9560d1d7e0f..d0b9a996023 100644 --- a/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php +++ b/htdocs/core/modules/hrm/doc/pdf_standard_evaluation.modules.php @@ -111,9 +111,6 @@ class pdf_standard_evaluation extends ModelePDFEvaluation $this->option_logo = 1; // Display logo $this->option_draft_watermark = 1; // Support add of a watermark on drafts - // Get source company - $this->emetteur = $mysoc; - // Define position of columns $this->posxnotes = $this->marge_gauche + 1; @@ -128,6 +125,14 @@ class pdf_standard_evaluation extends ModelePDFEvaluation $this->posxrequiredrank -= 20; $this->posxresult -= 20; } + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index c3a6196f80f..b50619460fe 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -81,7 +81,12 @@ class doc_generic_member_odt extends ModelePDFMember $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts - // Recupere emetteur + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Retrieves issuer $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined diff --git a/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php b/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php index 41925a7935a..59e49c4d0a0 100644 --- a/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php +++ b/htdocs/core/modules/movement/doc/pdf_standard_movementstock.modules.php @@ -89,12 +89,6 @@ class pdf_standard_movementstock extends ModelePDFMovement $this->option_multilang = 1; // Available in several languages $this->option_freetext = 0; // Support add of a personalised text - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define position of columns $this->wref = 15; $this->posxidref = $this->marge_gauche; @@ -121,6 +115,17 @@ class pdf_standard_movementstock extends ModelePDFMovement $this->posxdiscount -= 20; $this->postotalht -= 20; } + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 4995b133435..ff22719c4ab 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -84,6 +84,11 @@ class doc_generic_mo_odt extends ModelePDFMo $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php index a08a7bb8de3..9d7442f9826 100644 --- a/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php +++ b/htdocs/core/modules/mrp/doc/pdf_vinci.modules.php @@ -112,14 +112,19 @@ class pdf_vinci extends ModelePDFMo $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts + // Define position of columns + $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support during PDF transition: TODO remove this at the end + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (empty($this->emetteur->country_code)) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined } - - // Define position of columns - $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support during PDF transition: TODO remove this at the end } diff --git a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php index be3d8a94726..e6f0d524747 100644 --- a/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php +++ b/htdocs/core/modules/product/doc/doc_generic_product_odt.modules.php @@ -82,6 +82,11 @@ class doc_generic_product_odt extends ModelePDFProduct $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index db632a4b14b..e1fff4b2dcd 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -98,6 +98,14 @@ class pdf_standard extends ModelePDFProduct $this->option_multilang = 1; // Available in several languages $this->option_freetext = 0; // Support add of a personalised text + // Define position of columns + $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support during PDF transition: TODO remove this at the end + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 83f47b4554d..43b5df77027 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -122,6 +122,11 @@ class doc_generic_project_odt extends ModelePDFProjects $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index aaa54b1aacf..5f6b1cb6f13 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -114,12 +114,6 @@ class pdf_baleine extends ModelePDFProjects $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - // Get source company - $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define position of columns $this->posxref = $this->marge_gauche + 1; $this->posxlabel = $this->marge_gauche + 25; @@ -135,6 +129,17 @@ class pdf_baleine extends ModelePDFProjects $this->posxdatestart -= 20; $this->posxdateend -= 20; } + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index d4eb38ff6fb..1aa57b85bb8 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -134,12 +134,6 @@ class pdf_beluga extends ModelePDFProjects $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - // Get source company - $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define position of columns if ($this->orientation == 'L' || $this->orientation == 'Landscape') { $this->posxref = $this->marge_gauche + 1; @@ -164,6 +158,17 @@ class pdf_beluga extends ModelePDFProjects $this->posxamountttc -= 20; $this->posxstatut -= 20; } + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 1e6644c686e..9e6cc033f42 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -108,12 +108,6 @@ class pdf_timespent extends ModelePDFProjects $this->option_logo = 1; // Display logo FAC_PDF_LOGO $this->option_tva = 1; // Manage the vat option FACTURE_TVAOPTION - // Get source company - $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define position of columns $this->posxref = $this->marge_gauche + 1; $this->posxlabel = $this->marge_gauche + 25; @@ -130,6 +124,17 @@ class pdf_timespent extends ModelePDFProjects $this->posxuser -= 20; //$this->posxdateend -= 20; } + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index e693a4b2a7f..d1679fee4a5 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -121,6 +121,11 @@ class doc_generic_task_odt extends ModelePDFTask $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 3530fe696b4..86266b76b16 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -84,6 +84,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index 9f0e59f019f..3a6b6e4807b 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -121,12 +121,6 @@ class pdf_azur extends ModelePDFPropales $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; if (getDolGlobalInt('PRODUCT_USE_UNITS')) { @@ -162,6 +156,17 @@ class pdf_azur extends ModelePDFPropales $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 4fea94802b7..3ab9d3a6dd4 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -119,12 +119,6 @@ class pdf_cyan extends ModelePDFPropales $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; // used for notes and other stuff @@ -139,6 +133,17 @@ class pdf_cyan extends ModelePDFPropales $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 1c6f75d2a65..bf7247fdde8 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -79,6 +79,11 @@ class doc_generic_reception_odt extends ModelePdfReception $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 55dcc8cd0be..87b28d915b6 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -88,12 +88,6 @@ class pdf_squille extends ModelePdfReception $this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->watermark = ''; - // Get source company - $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; $this->posxweightvol = $this->page_largeur - $this->marge_droite - 78; @@ -124,6 +118,17 @@ class pdf_squille extends ModelePdfReception $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); $this->posxqtyordered = $this->posxqtytoship; } + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php index 52b528b414d..b95f709c55a 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -74,7 +74,12 @@ class doc_generic_odt extends ModeleThirdPartyDoc $this->option_freetext = 0; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts - // Retrieves transmitter + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Retrieves issuer $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index cd633933f02..fbb1bc64280 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -81,6 +81,11 @@ class doc_generic_stock_odt extends ModelePDFStock $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php b/htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php index 1afd23e99ec..b30d54d86b4 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard_stock.modules.php @@ -85,12 +85,6 @@ class pdf_standard_stock extends ModelePDFStock $this->option_multilang = 1; // Available in several languages $this->option_freetext = 0; // Support add of a personalised text - // Get source company - $this->emetteur = $mysoc; - if (!$this->emetteur->country_code) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define position of columns $this->wref = 35; $this->posxdesc = $this->marge_gauche + 1; @@ -117,6 +111,17 @@ class pdf_standard_stock extends ModelePDFStock } $this->tabTitleHeight = 11; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (!$this->emetteur->country_code) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined + } } diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php index 1b4440e35b9..e7bfb6592dc 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle.modules.php @@ -119,12 +119,6 @@ class pdf_eagle extends ModelePDFStockTransfer $this->corner_radius = getDolGlobalInt('MAIN_PDF_FRAME_CORNER_RADIUS', 0); $this->option_logo = 1; // Display logo - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; $this->posxlot = $this->page_largeur - $this->marge_droite - 135; @@ -162,6 +156,17 @@ class pdf_eagle extends ModelePDFStockTransfer $this->posxpicture += ($this->posxwarehousedestination - $this->posxwarehousesource); $this->posxwarehousesource = $this->posxwarehousedestination; }*/ + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php index 06ef936d358..18a7b792db0 100644 --- a/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php +++ b/htdocs/core/modules/stocktransfer/doc/pdf_eagle_proforma.modules.php @@ -115,12 +115,6 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); - } // By default, if was not defined - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; @@ -132,6 +126,17 @@ class pdf_eagle_proforma extends ModelePDFStockTransfer $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); + } // By default, if was not defined } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php index 4fee8dee6cb..cd4fbe8617b 100644 --- a/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php +++ b/htdocs/core/modules/supplier_invoice/doc/doc_generic_supplier_invoice_odt.modules.php @@ -6,7 +6,7 @@ * Copyright (C) 2018-2019 Philippe Grand * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2019 Tim Otte - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW * * 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 @@ -90,6 +90,11 @@ class doc_generic_supplier_invoice_odt extends ModelePDFSuppliersInvoices $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Recupere issuer $this->issuer = $mysoc; if (!$this->issuer->country_code) { diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index 6451408bd10..f6407073b83 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -6,7 +6,7 @@ * Copyright (C) 2018-2019 Philippe Grand * Copyright (C) 2018-2024 Frédéric France * Copyright (C) 2019 Tim Otte - * Copyright (C) 2024 MDW + * Copyright (C) 2024 MDW * * 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 @@ -90,7 +90,12 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts - // Recupere issuer + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Record issuer $this->issuer = $mysoc; if (!$this->issuer->country_code) { $this->issuer->country_code = substr($langs->defaultlang, -2); // By default if not defined diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index b3ec2bad687..22ff0e57489 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -114,12 +114,6 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support during PDF transition: TODO remove this at the end @@ -131,6 +125,17 @@ class pdf_cornas extends ModelePDFSuppliersOrders $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } diff --git a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php index 1082d2382bf..81c6eee23e6 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php @@ -113,12 +113,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; $this->posxdiscount = 162; @@ -156,6 +150,17 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php index 14c3954741d..cdbf0b9f13f 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard_supplierpayment.modules.php @@ -138,6 +138,11 @@ class pdf_standard_supplierpayment extends ModelePDFSuppliersPayments $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index 61cb85ee31b..a17f724a5fa 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -83,7 +83,12 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts - // Recupere emetteur + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Retrieves issuer $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php index 728a9856da1..674a56a0cba 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -112,12 +112,6 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->option_draft_watermark = 1; //Support add of a watermark on drafts $this->watermark = ''; - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; @@ -151,6 +145,17 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps diff --git a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php index 0713297269d..797194deb47 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_zenith.modules.php @@ -113,12 +113,6 @@ class pdf_zenith extends ModelePDFSupplierProposal $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; // For module retrocompatibility support during PDF transition: TODO remove this at the end @@ -130,6 +124,17 @@ class pdf_zenith extends ModelePDFSupplierProposal $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index d19704a0fd9..1cbb3c916af 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -77,6 +77,11 @@ class doc_generic_ticket_odt extends ModelePDFTicket $this->option_freetext = 0; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index 14e2ee3438e..306ab8a146a 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -81,6 +81,11 @@ class doc_generic_user_odt extends ModelePDFUser $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php index 3e72d52ce71..da30d9a0b21 100644 --- a/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php +++ b/htdocs/core/modules/usergroup/doc/doc_generic_usergroup_odt.modules.php @@ -83,6 +83,11 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index 2d2b4a4319c..a421972e610 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -97,6 +97,11 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index 27a87ac62c3..c24804b89ce 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -127,16 +127,9 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10); $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10); - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; // used for notes and other stuff - $this->tabTitleHeight = 5; // default height // Use new system for position of columns, view $this->defineColumnField() @@ -147,6 +140,17 @@ class pdf_standard_myobject extends ModelePDFMyObject $this->localtax2 = array(); $this->atleastoneratenotnull = 0; $this->atleastonediscount = 0; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } } diff --git a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php index 5933b81b1a8..e8462bd4ef4 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/doc_generic_recruitmentjobposition_odt.modules.php @@ -97,6 +97,11 @@ class doc_generic_recruitmentjobposition_odt extends ModelePDFRecruitmentJobPosi $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 52d7aef25ca..eaa4e0720ad 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -151,12 +151,6 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; // Support add of a watermark on drafts - // Get source company - $this->emetteur = $mysoc; - if (empty($this->emetteur->country_code)) { - $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined - } - // Define position of columns $this->posxdesc = $this->marge_gauche + 1; // used for notes and other stuff @@ -171,6 +165,17 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio // $this->atleastoneratenotnull = 0; // $this->atleastonediscount = 0; $this->situationinvoice = false; + + if ($mysoc === null) { + dol_syslog(get_class($this).'::__construct() Global $mysoc should not be null.'. getCallerInfoString(), LOG_ERR); + return; + } + + // Get source company + $this->emetteur = $mysoc; + if (empty($this->emetteur->country_code)) { + $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined + } }