diff --git a/dev/setup/codesniffer/ruleset.xml b/dev/setup/codesniffer/ruleset.xml index 296c6cb9b6f..1a18710b0d1 100644 --- a/dev/setup/codesniffer/ruleset.xml +++ b/dev/setup/codesniffer/ruleset.xml @@ -201,7 +201,7 @@ 0 - + diff --git a/dev/translation/autotranslator.class.php b/dev/translation/autotranslator.class.php index 4da15890045..789bd8173c4 100644 --- a/dev/translation/autotranslator.class.php +++ b/dev/translation/autotranslator.class.php @@ -50,7 +50,7 @@ class autoTranslator * @param string $_apikey Api key * @return void */ - function __construct($_destlang, $_refLang, $_langDir, $_limittofile, $_apikey) + public function __construct($_destlang, $_refLang, $_langDir, $_limittofile, $_apikey) { // Set enviorment variables @@ -346,5 +346,5 @@ class autoTranslator //print "OK ".join('',$src_texts).' => '.$rep."\n"; return $rep; - } + } } diff --git a/htdocs/accountancy/class/accountancycategory.class.php b/htdocs/accountancy/class/accountancycategory.class.php index 010f452755d..73cccdfd721 100644 --- a/htdocs/accountancy/class/accountancycategory.class.php +++ b/htdocs/accountancy/class/accountancycategory.class.php @@ -129,7 +129,7 @@ class AccountancyCategory // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -142,7 +142,7 @@ class AccountancyCategory // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -239,7 +239,7 @@ class AccountancyCategory // extends CommonObject * @param string $label Label * @return int <0 if KO, >0 if OK */ - function fetch($id, $code = '', $label = '') + public function fetch($id, $code = '', $label = '') { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -299,7 +299,7 @@ class AccountancyCategory // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -379,7 +379,7 @@ class AccountancyCategory // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -460,7 +460,7 @@ class AccountancyCategory // extends CommonObject return - 1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -509,7 +509,7 @@ class AccountancyCategory // extends CommonObject return - 1; } - } + } /** * Function to select accounting category of an accounting account present in chart of accounts @@ -552,7 +552,7 @@ class AccountancyCategory // extends CommonObject return - 1; } - } + } /** * Function to add an accounting account in an accounting category @@ -617,7 +617,7 @@ class AccountancyCategory // extends CommonObject return 1; } - } + } /** * Function to delete an accounting account from an accounting category @@ -643,7 +643,7 @@ class AccountancyCategory // extends CommonObject } // Commit or rollback - if ($error) { + if ($error) { foreach ($this->errors as $errmsg) { dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR); $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); @@ -651,12 +651,12 @@ class AccountancyCategory // extends CommonObject $this->db->rollback(); return - 1 * $error; - } else { + } else { $this->db->commit(); - return 1; - } - } + return 1; + } + } /** * Function to know all category from accounting account diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 775974edb6c..01f02a8a80a 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2016-2018 Alexandre Spangaro * Copyright (C) 2013-2017 Olivier Geffroy * Copyright (C) 2017 Elarifr. Ari Elbaz - * Copyright (C) 2017 Frédéric France + * Copyright (C) 2017-2019 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -98,18 +98,18 @@ class AccountancyExport global $langs; return array ( - //self::$EXPORT_TYPE_NORMAL => $langs->trans('Modelcsv_normal'), - self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans('Modelcsv_configurable'), - self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'), - self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), - self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), - self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), - self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'), - self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), - self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), - self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), - self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), - ); + //self::$EXPORT_TYPE_NORMAL => $langs->trans('Modelcsv_normal'), + self::$EXPORT_TYPE_CONFIGURABLE => $langs->trans('Modelcsv_configurable'), + self::$EXPORT_TYPE_CEGID => $langs->trans('Modelcsv_CEGID'), + self::$EXPORT_TYPE_COALA => $langs->trans('Modelcsv_COALA'), + self::$EXPORT_TYPE_BOB50 => $langs->trans('Modelcsv_bob50'), + self::$EXPORT_TYPE_CIEL => $langs->trans('Modelcsv_ciel'), + self::$EXPORT_TYPE_QUADRATUS => $langs->trans('Modelcsv_quadratus'), + self::$EXPORT_TYPE_EBP => $langs->trans('Modelcsv_ebp'), + self::$EXPORT_TYPE_COGILOG => $langs->trans('Modelcsv_cogilog'), + self::$EXPORT_TYPE_AGIRIS => $langs->trans('Modelcsv_agiris'), + self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'), + ); } /** diff --git a/htdocs/accountancy/class/accountancysystem.class.php b/htdocs/accountancy/class/accountancysystem.class.php index 65852258867..53e824219c5 100644 --- a/htdocs/accountancy/class/accountancysystem.class.php +++ b/htdocs/accountancy/class/accountancysystem.class.php @@ -64,10 +64,10 @@ class AccountancySystem * * @param DoliDB $db handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; - } + } /** @@ -77,7 +77,7 @@ class AccountancySystem * @param string $ref ref * @return int <0 if KO, Id of record if OK and found */ - function fetch($rowid = 0, $ref = '') + public function fetch($rowid = 0, $ref = '') { global $conf; @@ -124,7 +124,7 @@ class AccountancySystem * @param User $user making insert * @return int if KO, Id of line if OK */ - function create($user) + public function create($user) { $now = dol_now(); @@ -151,6 +151,6 @@ class AccountancySystem dol_syslog($this->error, LOG_ERR); } - return $result; - } + return $result; + } } diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index d889ef37195..f184d30699f 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -138,13 +138,13 @@ class AccountingAccount extends CommonObject * * @param DoliDB $db Database handle */ - function __construct($db) + public function __construct($db) { global $conf; $this->db = $db; $this->next_prev_filter='fk_pcg_version IN (SELECT pcg_version FROM ' . MAIN_DB_PREFIX . 'accounting_system WHERE rowid=' . $conf->global->CHARTOFACCOUNTS . ')'; // Used to add a filter in Form::showrefnav method - } + } /** * Load record in memory @@ -154,7 +154,7 @@ class AccountingAccount extends CommonObject * @param int $limittocurrentchart 1=Do not load record if it is into another accounting system * @return int <0 if KO, 0 if not found, Id of record if OK and found */ - function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) + public function fetch($rowid = null, $account_number = null, $limittocurrentchart = 0) { global $conf; @@ -216,7 +216,7 @@ class AccountingAccount extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf; $error = 0; @@ -317,7 +317,7 @@ class AccountingAccount extends CommonObject $this->db->commit(); return $this->id; } - } + } /** * Update record @@ -325,7 +325,7 @@ class AccountingAccount extends CommonObject * @param User $user Use making update * @return int <0 if KO, >0 if OK */ - function update($user) + public function update($user) { // Check parameters if (empty($this->pcg_type) || $this->pcg_type == '-1') @@ -368,7 +368,7 @@ class AccountingAccount extends CommonObject * * @return int <0 if KO, >0 if OK */ - function checkUsage() + public function checkUsage() { global $langs; @@ -402,7 +402,7 @@ class AccountingAccount extends CommonObject * @param int $notrigger 0=triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { $error = 0; @@ -453,9 +453,9 @@ class AccountingAccount extends CommonObject } else { return - 1; } - } + } - /** + /** * Return clicable name (with picto eventually) * * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto @@ -466,8 +466,8 @@ class AccountingAccount extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) - { + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) + { global $langs, $conf, $user; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; @@ -522,7 +522,7 @@ class AccountingAccount extends CommonObject if ($withpicto && $withpicto != 2) $result .= ' '; if ($withpicto != 2) $result.=$linkstart . $label_link . $linkend; return $result; - } + } /** * Information on record @@ -530,7 +530,7 @@ class AccountingAccount extends CommonObject * @param int $id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT a.rowid, a.datec, a.fk_user_author, a.fk_user_modif, a.tms'; $sql .= ' FROM ' . MAIN_DB_PREFIX . 'accounting_account as a'; @@ -562,14 +562,14 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Account deactivated * * @param int $id Id * @return int <0 if KO, >0 if OK */ - function account_desactivate($id) + public function account_desactivate($id) { // phpcs:enable $result = $this->checkUsage(); @@ -597,14 +597,14 @@ class AccountingAccount extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Account activated * * @param int $id Id * @return int <0 if KO, >0 if OK */ - function account_activate($id) + public function account_activate($id) { // phpcs:enable $this->db->begin(); @@ -615,15 +615,15 @@ class AccountingAccount extends CommonObject dol_syslog(get_class($this) . "::activate sql=" . $sql, LOG_DEBUG); $result = $this->db->query($sql); - if ($result) { + if ($result) { $this->db->commit(); return 1; - } else { + } else { $this->error = $this->db->lasterror(); $this->db->rollback(); return - 1; - } - } + } + } /** @@ -632,12 +632,12 @@ class AccountingAccount extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -645,7 +645,7 @@ class AccountingAccount extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -655,32 +655,32 @@ class AccountingAccount extends CommonObject { $prefix=''; if ($statut == 1) return $langs->trans('Enabled'); - if ($statut == 0) return $langs->trans('Disabled'); + elseif ($statut == 0) return $langs->trans('Disabled'); } elseif ($mode == 1) { if ($statut == 1) return $langs->trans('Enabled'); - if ($statut == 0) return $langs->trans('Disabled'); + elseif ($statut == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - if ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($mode == 4) { if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - if ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } } diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index b4ef9781aa2..eb99badd5f3 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -74,10 +74,10 @@ class AccountingJournal extends CommonObject * * @param DoliDB $db Database handle */ - function __construct($db) + public function __construct($db) { - $this->db = $db; - } + $this->db = $db; + } /** * Load an object from database @@ -86,7 +86,7 @@ class AccountingJournal extends CommonObject * @param string $journal_code Journal code * @return int <0 if KO, Id of record if OK and found */ - function fetch($rowid = null, $journal_code = null) + public function fetch($rowid = null, $journal_code = null) { global $conf; @@ -146,7 +146,7 @@ class AccountingJournal extends CommonObject * * @return int <0 if KO, >0 if OK */ - function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { $sql = "SELECT rowid, code, label, nature, active"; $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t'; @@ -213,7 +213,7 @@ class AccountingJournal extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0) + public function getNomUrl($withpicto = 0, $withlabel = 0, $nourl = 0, $moretitle = '', $notooltip = 0) { global $langs, $conf, $user; @@ -270,12 +270,12 @@ class AccountingJournal extends CommonObject * @param int $mode 0=libelle long, 1=libelle court * @return string Label of type */ - function getLibType($mode = 0) + public function getLibType($mode = 0) { return $this->LibType($this->nature, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return type of an accounting journal * @@ -283,7 +283,7 @@ class AccountingJournal extends CommonObject * @param int $mode 0=libelle long, 1=libelle court * @return string Label of type */ - function LibType($nature, $mode = 0) + public function LibType($nature, $mode = 0) { // phpcs:enable global $langs; @@ -294,20 +294,20 @@ class AccountingJournal extends CommonObject { $prefix=''; if ($nature == 9) return $langs->trans('AccountingJournalType9'); - if ($nature == 5) return $langs->trans('AccountingJournalType5'); - if ($nature == 4) return $langs->trans('AccountingJournalType4'); - if ($nature == 3) return $langs->trans('AccountingJournalType3'); - if ($nature == 2) return $langs->trans('AccountingJournalType2'); - if ($nature == 1) return $langs->trans('AccountingJournalType1'); + elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); + elseif ($nature == 4) return $langs->trans('AccountingJournalType4'); + elseif ($nature == 3) return $langs->trans('AccountingJournalType3'); + elseif ($nature == 2) return $langs->trans('AccountingJournalType2'); + elseif ($nature == 1) return $langs->trans('AccountingJournalType1'); } - if ($mode == 1) + elseif ($mode == 1) { if ($nature == 9) return $langs->trans('AccountingJournalType9'); - if ($nature == 5) return $langs->trans('AccountingJournalType5'); - if ($nature == 4) return $langs->trans('AccountingJournalType4'); - if ($nature == 3) return $langs->trans('AccountingJournalType3'); - if ($nature == 2) return $langs->trans('AccountingJournalType2'); - if ($nature == 1) return $langs->trans('AccountingJournalType1'); + elseif ($nature == 5) return $langs->trans('AccountingJournalType5'); + elseif ($nature == 4) return $langs->trans('AccountingJournalType4'); + elseif ($nature == 3) return $langs->trans('AccountingJournalType3'); + elseif ($nature == 2) return $langs->trans('AccountingJournalType2'); + elseif ($nature == 1) return $langs->trans('AccountingJournalType1'); } } } diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index bf3594e967d..5856c9a418e 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -411,7 +411,7 @@ class BookKeeping extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -1308,7 +1308,7 @@ class BookKeeping extends CommonObject * @param string $importkey Import key * @return int Result */ - function deleteByImportkey($importkey) + public function deleteByImportkey($importkey) { $this->db->begin(); @@ -1338,7 +1338,7 @@ class BookKeeping extends CommonObject * @param string $mode Mode * @return int <0 if KO, >0 if OK */ - function deleteByYearAndJournal($delyear = '', $journal = '', $mode = '') + public function deleteByYearAndJournal($delyear = '', $journal = '', $mode = '') { global $conf; @@ -1378,7 +1378,7 @@ class BookKeeping extends CommonObject * @param int $piecenum Piecenum to delete * @return int Result */ - function deleteMvtNum($piecenum) + public function deleteMvtNum($piecenum) { global $conf; @@ -1565,7 +1565,7 @@ class BookKeeping extends CommonObject * @param string $mode Mode * @return int <0 if KO, >0 if OK */ - function fetchAllPerMvt($piecenum, $mode = '') + public function fetchAllPerMvt($piecenum, $mode = '') { global $conf; @@ -1618,14 +1618,14 @@ class BookKeeping extends CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Export bookkeping * * @param string $model Model * @return int Result */ - function export_bookkeping($model = 'ebp') + public function export_bookkeping($model = 'ebp') { // phpcs:enable global $conf; @@ -1771,7 +1771,7 @@ class BookKeeping extends CommonObject */ } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of accounts with label by chart of accounts * @@ -1784,7 +1784,7 @@ class BookKeeping extends CommonObject * @param int $aabase Set accounting_account base class to display empty=all or from 1 to 8 will display only account beginning by this number * @return string String with HTML select */ - function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') + public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $aabase = '') { // phpcs:enable global $conf; @@ -1843,14 +1843,14 @@ class BookKeeping extends CommonObject return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Description of a root accounting account * * @param string $account Accounting account * @return string Root account */ - function get_compte_racine($account = null) + public function get_compte_racine($account = null) { // phpcs:enable global $conf; @@ -1884,15 +1884,15 @@ class BookKeeping extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Description of accounting account * * @param string $account Accounting account * @return string Account desc */ - function get_compte_desc($account = null) - { + public function get_compte_desc($account = null) + { // phpcs:enable global $conf; diff --git a/htdocs/adherents/canvas/actions_adherentcard_common.class.php b/htdocs/adherents/canvas/actions_adherentcard_common.class.php index d646a7cfb9b..31f957fcf21 100644 --- a/htdocs/adherents/canvas/actions_adherentcard_common.class.php +++ b/htdocs/adherents/canvas/actions_adherentcard_common.class.php @@ -32,15 +32,15 @@ abstract class ActionsAdherentCardCommon */ public $db; - var $dirmodule; - var $targetmodule; - var $canvas; - var $card; + public $dirmodule; + public $targetmodule; + public $canvas; + public $card; //! Template container - var $tpl = array(); + public $tpl = array(); //! Object container - var $object; + public $object; /** * @var string Error code (or message) @@ -59,7 +59,7 @@ abstract class ActionsAdherentCardCommon * @param int $id Object id * @return object Object loaded */ - function getObject($id) + public function getObject($id) { //$ret = $this->getInstanceDao(); @@ -75,7 +75,7 @@ abstract class ActionsAdherentCardCommon //} } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set content of ->tpl array, to use into template * @@ -83,7 +83,7 @@ abstract class ActionsAdherentCardCommon * @param int $id Id * @return string HTML output */ - function assign_values(&$action, $id) + public function assign_values(&$action, $id) { // phpcs:enable global $conf, $langs, $user, $canvas; @@ -245,23 +245,23 @@ abstract class ActionsAdherentCardCommon // phpcs:enable global $langs, $mysoc; - $this->object->old_name = $_POST["old_name"]; - $this->object->old_firstname = $_POST["old_firstname"]; + $this->object->old_name = $_POST["old_name"]; + $this->object->old_firstname = $_POST["old_firstname"]; - $this->object->fk_soc = $_POST["fk_soc"]; - $this->object->lastname = $_POST["lastname"]; - $this->object->firstname = $_POST["firstname"]; - $this->object->civility_id = $_POST["civility_id"]; - $this->object->address = $_POST["address"]; - $this->object->zip = $_POST["zipcode"]; - $this->object->town = $_POST["town"]; - $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; - $this->object->state_id = $_POST["state_id"]; - $this->object->phone_perso = $_POST["phone_perso"]; - $this->object->phone_mobile = $_POST["phone_mobile"]; - $this->object->email = $_POST["email"]; - $this->object->note = $_POST["note"]; - $this->object->canvas = $_POST["canvas"]; + $this->object->fk_soc = $_POST["fk_soc"]; + $this->object->lastname = $_POST["lastname"]; + $this->object->firstname = $_POST["firstname"]; + $this->object->civility_id = $_POST["civility_id"]; + $this->object->address = $_POST["address"]; + $this->object->zip = $_POST["zipcode"]; + $this->object->town = $_POST["town"]; + $this->object->country_id = $_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id; + $this->object->state_id = $_POST["state_id"]; + $this->object->phone_perso = $_POST["phone_perso"]; + $this->object->phone_mobile = $_POST["phone_mobile"]; + $this->object->email = $_POST["email"]; + $this->object->note = $_POST["note"]; + $this->object->canvas = $_POST["canvas"]; // We set country_id, and country_code label of the chosen country if ($this->object->country_id) @@ -272,8 +272,8 @@ abstract class ActionsAdherentCardCommon { $obj = $this->db->fetch_object($resql); - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle; } else { diff --git a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php index 67c1e33dbec..40424540312 100644 --- a/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php +++ b/htdocs/adherents/canvas/default/actions_adherentcard_default.class.php @@ -39,7 +39,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon * @param string $canvas Name of canvas * @param string $card Name of tab (sub-canvas) */ - function __construct($db, $dirmodule, $targetmodule, $canvas, $card) + public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) { $this->db = $db; $this->dirmodule = $dirmodule; @@ -67,7 +67,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -75,7 +75,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon * @param int $id Id * @return void */ - function assign_values(&$action, $id) + public function assign_values(&$action, $id) { // phpcs:enable global $limit, $offset, $sortfield, $sortorder; @@ -122,7 +122,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -132,7 +132,7 @@ class ActionsAdherentCardDefault extends ActionsAdherentCardCommon * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - function LoadListDatas($limit, $offset, $sortfield, $sortorder) + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) { // phpcs:enable global $conf, $langs; diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 66ee5ee16f2..1d7fb503ea2 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -223,7 +223,7 @@ class Adherent extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->statut = -1; @@ -234,7 +234,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function sending an email to the current member with the text supplied in parameter. * @@ -251,7 +251,7 @@ class Adherent extends CommonObject * @param string $moreinheader Add more html headers * @return int <0 if KO, >0 if OK */ - function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') + public function send_an_email($text, $subject, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = -1, $errors_to = '', $moreinheader = '') { // phpcs:enable global $conf,$langs; @@ -296,7 +296,7 @@ class Adherent extends CommonObject * @param string $text Text to make substitution to * @return string Value of input text string with substitutions done */ - function makeSubstitution($text) + public function makeSubstitution($text) { global $conf,$langs; @@ -363,7 +363,7 @@ class Adherent extends CommonObject * @param string $morphy Nature of the adherent (physical or moral) * @return string Label */ - function getmorphylib($morphy = '') + public function getmorphylib($morphy = '') { global $langs; if (! $morphy) { $morphy=$this->morphy; } @@ -379,7 +379,7 @@ class Adherent extends CommonObject * @param int $notrigger 1 ne declenche pas les triggers, 0 sinon * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$langs; @@ -505,7 +505,7 @@ class Adherent extends CommonObject * @param string $action Current action for hookmanager * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action = 'update') + public function update($user, $notrigger = 0, $nosyncuser = 0, $nosyncuserpass = 0, $nosyncthirdparty = 0, $action = 'update') { global $conf, $langs, $hookmanager; @@ -760,7 +760,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update denormalized last subscription date. * This function is called when we delete a subscription for example. @@ -768,7 +768,7 @@ class Adherent extends CommonObject * @param User $user User making change * @return int <0 if KO, >0 if OK */ - function update_end_date($user) + public function update_end_date($user) { // phpcs:enable $this->db->begin(); @@ -825,7 +825,7 @@ class Adherent extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, 0=nothing to do, >0 if OK */ - function delete($rowid, $user, $notrigger = 0) + public function delete($rowid, $user, $notrigger = 0) { global $conf, $langs; @@ -935,7 +935,7 @@ class Adherent extends CommonObject * @param int $nosyncuser Do not synchronize linked user * @return string If OK return clear password, 0 if no change, < 0 if error */ - function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) + public function setPassword($user, $password = '', $isencrypted = 0, $notrigger = 0, $nosyncuser = 0) { global $conf, $langs; @@ -1046,7 +1046,7 @@ class Adherent extends CommonObject * @param int $userid Id of user to link to * @return int 1=OK, -1=KO */ - function setUserId($userid) + public function setUserId($userid) { global $conf, $langs; @@ -1080,7 +1080,7 @@ class Adherent extends CommonObject * @param int $thirdpartyid Id of user to link to * @return int 1=OK, -1=KO */ - function setThirdPartyId($thirdpartyid) + public function setThirdPartyId($thirdpartyid) { global $conf, $langs; @@ -1116,14 +1116,14 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Method to load member from its login * * @param string $login login of member * @return void */ - function fetch_login($login) + public function fetch_login($login) { // phpcs:enable global $conf; @@ -1147,7 +1147,7 @@ class Adherent extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Method to load member from its name * @@ -1155,7 +1155,7 @@ class Adherent extends CommonObject * @param string $lastname Lastname * @return void */ - function fetch_name($firstname, $lastname) + public function fetch_name($firstname, $lastname) { // phpcs:enable global $conf; @@ -1191,7 +1191,7 @@ class Adherent extends CommonObject * @param bool $fetch_subscriptions To load member subscriptions * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($rowid, $ref = '', $fk_soc = '', $ref_ext = '', $fetch_optionals = true, $fetch_subscriptions = true) + public function fetch($rowid, $ref = '', $fk_soc = '', $ref_ext = '', $fetch_optionals = true, $fetch_subscriptions = true) { global $langs; @@ -1325,7 +1325,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to get member subscriptions data * first_subscription_date, first_subscription_date_start, first_subscription_date_end, first_subscription_amount @@ -1333,7 +1333,7 @@ class Adherent extends CommonObject * * @return int <0 si KO, >0 si OK */ - function fetch_subscriptions() + public function fetch_subscriptions() { // phpcs:enable global $langs; @@ -1409,7 +1409,7 @@ class Adherent extends CommonObject * @param int $datesubend Date end subscription * @return int rowid of record added, <0 if KO */ - function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0) + public function subscription($date, $amount, $accountid = 0, $operation = '', $label = '', $num_chq = '', $emetteur_nom = '', $emetteur_banque = '', $datesubend = 0) { global $conf,$langs,$user; @@ -1495,7 +1495,7 @@ class Adherent extends CommonObject * @param string $autocreatethirdparty Auto create new thirdparty if member not yet linked to a thirdparty and we request an option that generate invoice. * @return int <0 if KO, >0 if OK */ - function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom = '', $emetteur_banque = '', $autocreatethirdparty = 0) + public function subscriptionComplementaryActions($subscriptionid, $option, $accountid, $datesubscription, $paymentdate, $operation, $label, $amount, $num_chq, $emetteur_nom = '', $emetteur_banque = '', $autocreatethirdparty = 0) { global $conf, $langs, $user, $mysoc; @@ -1788,7 +1788,7 @@ class Adherent extends CommonObject * @param User $user user adherent qui valide * @return int <0 if KO, 0 if nothing done, >0 if OK */ - function validate($user) + public function validate($user) { global $langs,$conf; @@ -1841,7 +1841,7 @@ class Adherent extends CommonObject * @param User $user User making change * @return int <0 if KO, >0 if OK */ - function resiliate($user) + public function resiliate($user) { global $langs,$conf; @@ -1883,13 +1883,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to add member into external tools mailing-list, spip, etc. * * @return int <0 if KO, >0 if OK */ - function add_to_abo() + public function add_to_abo() { // phpcs:enable global $conf,$langs; @@ -1942,13 +1942,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to delete a member from external tools like mailing-list, spip, etc. * * @return int <0 if KO, >0 if OK */ - function del_to_abo() + public function del_to_abo() { // phpcs:enable global $conf,$langs; @@ -2006,7 +2006,7 @@ class Adherent extends CommonObject * * @return string Translated name of civility (translated with transnoentitiesnoconv) */ - function getCivilityLabel() + public function getCivilityLabel() { global $langs; $langs->load("dict"); @@ -2027,7 +2027,7 @@ class Adherent extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpictoimg = 0, $maxlen = 0, $option = 'card', $mode = '', $morecss = '', $save_lastsearch_value = -1) { global $conf, $langs; @@ -2118,12 +2118,12 @@ class Adherent extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $this->need_subscription, $this->datefin, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -2133,7 +2133,7 @@ class Adherent extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - function LibStatut($statut, $need_subscription, $date_end_subscription, $mode = 0) + public function LibStatut($statut, $need_subscription, $date_end_subscription, $mode = 0) { // phpcs:enable global $langs; @@ -2211,13 +2211,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -2247,14 +2247,14 @@ class Adherent extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Objet user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -2346,7 +2346,7 @@ class Adherent extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; @@ -2400,7 +2400,7 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -2410,7 +2410,7 @@ class Adherent extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -2422,13 +2422,13 @@ class Adherent extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialise tableau info (tableau des attributs LDAP) * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -2536,7 +2536,7 @@ class Adherent extends CommonObject * @param int $id Id of member to load * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT a.rowid, a.datec as datec,'; $sql.= ' a.datevalid as datev,'; @@ -2592,7 +2592,7 @@ class Adherent extends CommonObject * * @return int Number of EMailings */ - function getNbOfEMailings() + public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 9fd7a9b9d38..65085caf42a 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -89,7 +89,7 @@ class AdherentType extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->statut = 1; @@ -103,7 +103,7 @@ class AdherentType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf; @@ -170,7 +170,7 @@ class AdherentType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $hookmanager; @@ -238,7 +238,7 @@ class AdherentType extends CommonObject * * @return int > 0 if OK, 0 if not found, < 0 if KO */ - function delete() + public function delete() { global $user; @@ -272,7 +272,7 @@ class AdherentType extends CommonObject * @param int $rowid Id of member type to load * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = "SELECT d.rowid, d.libelle as label, d.statut, d.subscription, d.mail_valid, d.note, d.vote"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d"; @@ -306,13 +306,13 @@ class AdherentType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of members' type * * @return array List of types of members */ - function liste_array() + public function liste_array() { // phpcs:enable global $conf,$langs; @@ -356,7 +356,7 @@ class AdherentType extends CommonObject * 2=Return array of members id only * @return mixed Array of members or -1 on error */ - function listMembersForMemberType($excludefilter = '', $mode = 0) + public function listMembersForMemberType($excludefilter = '', $mode = 0) { global $conf, $user; @@ -404,14 +404,14 @@ class AdherentType extends CommonObject } /** - * Return clicable name (with picto eventually) + * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen length max label - * @param int $notooltip 1=Disable tooltip - * @return string String with URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen length max label + * @param int $notooltip 1=Disable tooltip + * @return string String with URL */ - function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) { global $langs; @@ -434,12 +434,12 @@ class AdherentType extends CommonObject * * @return string Return status of a type of member */ - function getLibStatut() - { - return ''; - } + public function getLibStatut() + { + return ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -449,7 +449,7 @@ class AdherentType extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -461,13 +461,13 @@ class AdherentType extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialize the info array (array of LDAP values) that will be used to call LDAP functions * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -502,7 +502,7 @@ class AdherentType extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $conf, $user, $langs; @@ -530,7 +530,7 @@ class AdherentType extends CommonObject * * @return string Return mail content of type or empty */ - function getMailOnValid() + public function getMailOnValid() { global $conf; @@ -547,7 +547,7 @@ class AdherentType extends CommonObject * * @return string Return mail content of type or empty */ - function getMailOnSubscription() + public function getMailOnSubscription() { global $conf; @@ -565,16 +565,16 @@ class AdherentType extends CommonObject * * @return string Return mail model content of type or empty */ - function getMailOnResiliate() - { - global $conf; + public function getMailOnResiliate() + { + global $conf; - // NOTE mail_resiliate not defined so never used - if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined - { - return $this->mail_resiliate; - } + // NOTE mail_resiliate not defined so never used + if (! empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) // Property not yet defined + { + return $this->mail_resiliate; + } - return ''; - } + return ''; + } } diff --git a/htdocs/adherents/class/adherentstats.class.php b/htdocs/adherents/class/adherentstats.class.php index 7468ddb92a9..b9085b1f6b4 100644 --- a/htdocs/adherents/class/adherentstats.class.php +++ b/htdocs/adherents/class/adherentstats.class.php @@ -37,12 +37,12 @@ class AdherentStats extends Stats */ public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -52,7 +52,7 @@ class AdherentStats extends Stats * @param int $socid Id third party * @param int $userid Id user for filter */ - function __construct($db, $socid = 0, $userid = 0) + public function __construct($db, $socid = 0, $userid = 0) { global $user, $conf; @@ -85,7 +85,7 @@ class AdherentStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of nb each month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -105,7 +105,7 @@ class AdherentStats extends Stats * * @return array Array of nb each year */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -126,7 +126,7 @@ class AdherentStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of amount each month */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { global $user; @@ -147,7 +147,7 @@ class AdherentStats extends Stats * @param int $year Year * @return array Array of average each month */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; @@ -168,7 +168,7 @@ class AdherentStats extends Stats * * @return array Array with nb, total amount, average for each year */ - function getAllByYear() + public function getAllByYear() { global $user; diff --git a/htdocs/adherents/class/api_members.class.php b/htdocs/adherents/class/api_members.class.php index 7e43e17fd6f..6025f2a2985 100644 --- a/htdocs/adherents/class/api_members.class.php +++ b/htdocs/adherents/class/api_members.class.php @@ -41,7 +41,7 @@ class Members extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -57,7 +57,7 @@ class Members extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); @@ -91,7 +91,7 @@ class Members extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $typeid = '', $sqlfilters = '') { global $db, $conf; @@ -162,7 +162,7 @@ class Members extends DolibarrApi * @param array $request_data Request data * @return int ID of member */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); @@ -187,7 +187,7 @@ class Members extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); @@ -242,7 +242,7 @@ class Members extends DolibarrApi * @param int $id member ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->adherent->supprimer) { throw new RestException(401); @@ -277,7 +277,7 @@ class Members extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $member = array(); foreach (Members::$FIELDS as $field) { @@ -294,7 +294,7 @@ class Members extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -328,7 +328,7 @@ class Members extends DolibarrApi * * @url GET {id}/subscriptions */ - function getSubscriptions($id) + public function getSubscriptions($id) { $obj_ret = array(); @@ -361,7 +361,7 @@ class Members extends DolibarrApi * * @url POST {id}/subscriptions */ - function createSubscription($id, $start_date, $end_date, $amount, $label = '') + public function createSubscription($id, $start_date, $end_date, $amount, $label = '') { if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { throw new RestException(401); @@ -389,7 +389,7 @@ class Members extends DolibarrApi * * @url GET {id}/categories */ - function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); diff --git a/htdocs/adherents/class/api_memberstypes.class.php b/htdocs/adherents/class/api_memberstypes.class.php index e6ce4ace151..43fd2635fb4 100644 --- a/htdocs/adherents/class/api_memberstypes.class.php +++ b/htdocs/adherents/class/api_memberstypes.class.php @@ -37,7 +37,7 @@ class MembersTypes extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -53,7 +53,7 @@ class MembersTypes extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->adherent->lire) { throw new RestException(401); @@ -86,7 +86,7 @@ class MembersTypes extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -154,7 +154,7 @@ class MembersTypes extends DolibarrApi * @param array $request_data Request data * @return int ID of member type */ - function post($request_data = null) + public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->adherent->configurer) { throw new RestException(401); @@ -179,7 +179,7 @@ class MembersTypes extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->adherent->configurer) { throw new RestException(401); @@ -220,7 +220,7 @@ class MembersTypes extends DolibarrApi * @param int $id member type ID * @return array */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->adherent->configurer) { throw new RestException(401); @@ -255,7 +255,7 @@ class MembersTypes extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $membertype = array(); foreach (MembersTypes::$FIELDS as $field) { @@ -272,7 +272,7 @@ class MembersTypes extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); diff --git a/htdocs/adherents/class/api_subscriptions.class.php b/htdocs/adherents/class/api_subscriptions.class.php index 3089f2cfd98..e5173005460 100644 --- a/htdocs/adherents/class/api_subscriptions.class.php +++ b/htdocs/adherents/class/api_subscriptions.class.php @@ -40,7 +40,7 @@ class Subscriptions extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -56,7 +56,7 @@ class Subscriptions extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->adherent->cotisation->lire) { throw new RestException(401); @@ -85,7 +85,7 @@ class Subscriptions extends DolibarrApi * * @throws RestException */ - function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "dateadh", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -151,7 +151,7 @@ class Subscriptions extends DolibarrApi * @param array $request_data Request data * @return int ID of subscription */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { throw new RestException(401); @@ -176,7 +176,7 @@ class Subscriptions extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->adherent->creer) { throw new RestException(401); @@ -209,7 +209,7 @@ class Subscriptions extends DolibarrApi * @param int $id ID of subscription to delete * @return array */ - function delete($id) + public function delete($id) { // The right to delete a subscription comes with the right to create one. if(! DolibarrApiAccess::$user->rights->adherent->cotisation->creer) { @@ -241,7 +241,7 @@ class Subscriptions extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $subscription = array(); foreach (Subscriptions::$FIELDS as $field) { diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 0d43b9d3f09..52cb8e05bbd 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -32,78 +32,78 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; */ class Subscription extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element='subscription'; - - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='subscription'; + /** + * @var string ID to identify managed object + */ + public $element='subscription'; /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto='payment'; + * @var string Name of table without prefix where object is stored + */ + public $table_element='subscription'; - public $datec; // Date creation - public $datem; // Date modification - public $dateh; // Subscription start date (date subscription) - public $datef; // Subscription end date + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto='payment'; - /** + public $datec; // Date creation + public $datem; // Date modification + public $dateh; // Subscription start date (date subscription) + public $datef; // Subscription end date + + /** * @var int ID */ - public $fk_type; - public $fk_adherent; + public $fk_type; + public $fk_adherent; - public $amount; + public $amount; - /** + /** * @var int ID */ - public $fk_bank; + public $fk_bank; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Function who permitted cretaion of the subscription - * - * @param User $user User that create - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id subscription created if OK - */ - function create($user, $notrigger = false) - { - global $langs; + /** + * Function who permitted cretaion of the subscription + * + * @param User $user User that create + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id subscription created if OK + */ + public function create($user, $notrigger = false) + { + global $langs; - $error = 0; + $error = 0; - $now=dol_now(); + $now=dol_now(); - // Check parameters - if ($this->datef <= $this->dateh) - { - $this->error=$langs->trans("ErrorBadValueForDate"); - return -1; - } - if (empty($this->datec)) $this->datec = $now; + // Check parameters + if ($this->datef <= $this->dateh) + { + $this->error=$langs->trans("ErrorBadValueForDate"); + return -1; + } + if (empty($this->datec)) $this->datec = $now; - $this->db->begin(); + $this->db->begin(); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."subscription (fk_adherent, fk_type, datec, dateadh, datef, subscription, note)"; if ($this->fk_type == null) { require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php'; @@ -113,338 +113,338 @@ class Subscription extends CommonObject } else { $type=$this->fk_type; } - $sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; - $sql.= " '".$this->db->idate($this->dateh)."',"; - $sql.= " '".$this->db->idate($this->datef)."',"; - $sql.= " ".$this->amount.","; - $sql.= " '".$this->db->escape($this->note_public?$this->note_public:$this->note)."')"; + $sql.= " VALUES (".$this->fk_adherent.", '".$type."', '".$this->db->idate($now)."',"; + $sql.= " '".$this->db->idate($this->dateh)."',"; + $sql.= " '".$this->db->idate($this->datef)."',"; + $sql.= " ".$this->amount.","; + $sql.= " '".$this->db->escape($this->note_public?$this->note_public:$this->note)."')"; - $resql = $this->db->query($sql); - if (! $resql) { - $error++; - $this->errors[] = $this->db->lasterror(); - } + $resql = $this->db->query($sql); + if (! $resql) { + $error++; + $this->errors[] = $this->db->lasterror(); + } - if (! $error) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); - } + if (! $error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); + } - if (! $error && ! $notrigger) - { - // Call triggers - $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); - if ($result < 0) { $error++; } - // End call triggers - } + if (! $error && ! $notrigger) + { + // Call triggers + $result=$this->call_trigger('MEMBER_SUBSCRIPTION_CREATE', $user); + if ($result < 0) { $error++; } + // End call triggers + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Method to load a subscription - * - * @param int $rowid Id subscription - * @return int <0 if KO, =0 if not found, >0 if OK - */ - function fetch($rowid) - { + /** + * Method to load a subscription + * + * @param int $rowid Id subscription + * @return int <0 if KO, =0 if not found, >0 if OK + */ + public function fetch($rowid) + { $sql ="SELECT rowid, fk_type, fk_adherent, datec,"; - $sql.=" tms,"; - $sql.=" dateadh as dateh,"; - $sql.=" datef,"; - $sql.=" subscription, note, fk_bank"; - $sql.=" FROM ".MAIN_DB_PREFIX."subscription"; - $sql.=" WHERE rowid=".$rowid; + $sql.=" tms,"; + $sql.=" dateadh as dateh,"; + $sql.=" datef,"; + $sql.=" subscription, note, fk_bank"; + $sql.=" FROM ".MAIN_DB_PREFIX."subscription"; + $sql.=" WHERE rowid=".$rowid; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; - $this->fk_type = $obj->fk_type; - $this->fk_adherent = $obj->fk_adherent; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->tms); - $this->dateh = $this->db->jdate($obj->dateh); - $this->datef = $this->db->jdate($obj->datef); - $this->amount = $obj->subscription; - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - return 1; - } - else - { - return 0; - } - } - else - { - $this->error=$this->db->lasterror(); - return -1; - } - } + $this->fk_type = $obj->fk_type; + $this->fk_adherent = $obj->fk_adherent; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->tms); + $this->dateh = $this->db->jdate($obj->dateh); + $this->datef = $this->db->jdate($obj->datef); + $this->amount = $obj->subscription; + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + return 1; + } + else + { + return 0; + } + } + else + { + $this->error=$this->db->lasterror(); + return -1; + } + } - /** - * Update subscription - * - * @param User $user User who updated - * @param int $notrigger 0=Disable triggers - * @return int <0 if KO, >0 if OK - */ - function update($user, $notrigger = 0) - { - $error = 0; + /** + * Update subscription + * + * @param User $user User who updated + * @param int $notrigger 0=Disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user, $notrigger = 0) + { + $error = 0; - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; - $sql .= " fk_type = ".$this->fk_type.","; - $sql .= " fk_adherent = ".$this->fk_adherent.","; - $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; - $sql .= " subscription = '".price2num($this->amount)."',"; - $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; - $sql .= " datef='".$this->db->idate($this->datef)."',"; - $sql .= " datec='".$this->db->idate($this->datec)."',"; - $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); - $sql .= " WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."subscription SET "; + $sql .= " fk_type = ".$this->fk_type.","; + $sql .= " fk_adherent = ".$this->fk_adherent.","; + $sql .= " note=".($this->note ? "'".$this->db->escape($this->note)."'" : 'null').","; + $sql .= " subscription = '".price2num($this->amount)."',"; + $sql .= " dateadh='".$this->db->idate($this->dateh)."',"; + $sql .= " datef='".$this->db->idate($this->datef)."',"; + $sql .= " datec='".$this->db->idate($this->datec)."',"; + $sql .= " fk_bank = ".($this->fk_bank ? $this->fk_bank : 'null'); + $sql .= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) - { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); - $result=$member->update_end_date($user); + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member=new Adherent($this->db); + $result=$member->fetch($this->fk_adherent); + $result=$member->update_end_date($user); - if (! $error && ! $notrigger) { - // Call triggers - $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); - if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } - else - { - $error++; - $this->error=$this->db->lasterror(); - } + if (! $error && ! $notrigger) { + // Call triggers + $result=$this->call_trigger('MEMBER_SUBSCRIPTION_MODIFY', $user); + if ($result < 0) { $error++; } //Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } + else + { + $error++; + $this->error=$this->db->lasterror(); + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return $this->id; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return $this->id; + } + } - /** - * Delete a subscription - * - * @param User $user User that delete - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, 0 if not found, >0 if OK - */ - function delete($user, $notrigger = false) - { - $error = 0; + /** + * Delete a subscription + * + * @param User $user User that delete + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function delete($user, $notrigger = false) + { + $error = 0; - // It subscription is linked to a bank transaction, we get it - if ($this->fk_bank > 0) - { - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $accountline=new AccountLine($this->db); - $result=$accountline->fetch($this->fk_bank); - } + // It subscription is linked to a bank transaction, we get it + if ($this->fk_bank > 0) + { + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + $accountline=new AccountLine($this->db); + $result=$accountline->fetch($this->fk_bank); + } - $this->db->begin(); + $this->db->begin(); - if (! $error) { - if (! $notrigger) { - // Call triggers - $result=$this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); - if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail - // End call triggers - } - } + if (! $error) { + if (! $notrigger) { + // Call triggers + $result=$this->call_trigger('MEMBER_SUBSCRIPTION_DELETE', $user); + if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail + // End call triggers + } + } - if (! $error) - { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $num=$this->db->affected_rows($resql); - if ($num) - { - require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - $member=new Adherent($this->db); - $result=$member->fetch($this->fk_adherent); - $result=$member->update_end_date($user); + if (! $error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."subscription WHERE rowid = ".$this->id; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num=$this->db->affected_rows($resql); + if ($num) + { + require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; + $member=new Adherent($this->db); + $result=$member->fetch($this->fk_adherent); + $result=$member->update_end_date($user); - if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) - { - $result=$accountline->delete($user); // Return false if refused because line is conciliated - if ($result > 0) - { - $this->db->commit(); - return 1; - } - else - { - $this->error=$accountline->error; - $this->db->rollback(); - return -1; - } - } - else - { - $this->db->commit(); - return 1; - } - } - else - { - $this->db->commit(); - return 0; - } - } - else - { - $error++; - $this->error=$this->db->lasterror(); - } - } + if ($this->fk_bank > 0 && is_object($accountline) && $accountline->id > 0) // If we found bank account line (this means this->fk_bank defined) + { + $result=$accountline->delete($user); // Return false if refused because line is conciliated + if ($result > 0) + { + $this->db->commit(); + return 1; + } + else + { + $this->error=$accountline->error; + $this->db->rollback(); + return -1; + } + } + else + { + $this->db->commit(); + return 1; + } + } + else + { + $this->db->commit(); + return 0; + } + } + else + { + $error++; + $this->error=$this->db->lasterror(); + } + } - // Commit or rollback - if ($error) { - $this->db->rollback(); - return -1; - } else { - $this->db->commit(); - return 1; - } - } + // Commit or rollback + if ($error) { + $this->db->rollback(); + return -1; + } else { + $this->db->commit(); + return 1; + } + } - /** - * Return clicable name (with picto eventually) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @param int $notooltip 1=Disable tooltip - * @param string $option Page for link ('', 'nolink', ...) - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string Chaine avec URL - */ - function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) - { - global $langs; + * @param string $option Page for link ('', 'nolink', ...) + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string Chaine avec URL + */ + public function getNomUrl($withpicto = 0, $notooltip = 0, $option = '', $morecss = '', $save_lastsearch_value = -1) + { + global $langs; - $result=''; + $result=''; - $langs->load("members"); + $langs->load("members"); $label=$langs->trans("ShowSubscription").': '.$this->ref; $url = DOL_URL_ROOT.'/adherents/subscription/card.php?rowid='.$this->id; if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkstart = ''; - $linkend = ''; + $linkend = ''; - $picto='payment'; + $picto='payment'; - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; - return $result; - } + return $result; + } - /** - * Retourne le libelle du statut d'une adhesion - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label - */ - function getLibStatut($mode = 0) - { - return ''; - } + /** + * Retourne le libelle du statut d'une adhesion + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label + */ + public function getLibStatut($mode = 0) + { + return ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $statut Id statut - * @return string Label - */ - function LibStatut($statut) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id statut + * @return string Label + */ + public function LibStatut($statut) + { // phpcs:enable - global $langs; - $langs->load("members"); - return ''; - } + global $langs; + $langs->load("members"); + return ''; + } /** * Load information of the subscription object - * + * * @param int $id Id subscription * @return void */ - function info($id) - { - $sql = 'SELECT c.rowid, c.datec,'; - $sql.= ' c.tms as datem'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; - $sql.= ' WHERE c.rowid = '.$id; + public function info($id) + { + $sql = 'SELECT c.rowid, c.datec,'; + $sql.= ' c.tms as datem'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'subscription as c'; + $sql.= ' WHERE c.rowid = '.$id; - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + } - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } } diff --git a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php index 9c691c88e88..f4ed611ac03 100644 --- a/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php +++ b/htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php @@ -69,7 +69,7 @@ class PrestaShopWebservice * @param string $key Authentification key * @param mixed $debug Debug mode Activated (true) or deactivated (false) */ - function __construct($url, $key, $debug = true) + public function __construct($url, $key, $debug = true) { if (!extension_loaded('curl')) throw new PrestaShopWebserviceException('Please activate the PHP extension \'curl\' to allow use of PrestaShop webservice library'); @@ -77,7 +77,7 @@ class PrestaShopWebservice $this->key = $key; $this->debug = $debug; $this->version = 'unknown'; - } + } /** * Take the status code and throw an exception if the server didn't return 200 or 201 code diff --git a/htdocs/admin/dolistore/class/dolistore.class.php b/htdocs/admin/dolistore/class/dolistore.class.php index b3a9f037e95..8a27072fad1 100644 --- a/htdocs/admin/dolistore/class/dolistore.class.php +++ b/htdocs/admin/dolistore/class/dolistore.class.php @@ -54,7 +54,7 @@ class Dolistore * * @param boolean $debug Enable debug of request on screen */ - function __construct($debug = false) + public function __construct($debug = false) { global $conf, $langs; @@ -77,7 +77,7 @@ class Dolistore * @param array $options Options * @return void */ - function getRemoteData($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) + public function getRemoteData($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0)) { global $conf, $langs; @@ -163,14 +163,14 @@ class Dolistore } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return tree of Dolistore categories. $this->categories must have been loaded before. * * @param int $parent Id of parent category * @return string */ - function get_categories($parent = 0) + public function get_categories($parent = 0) { // phpcs:enable if (!isset($this->categories)) die('not possible'); @@ -212,13 +212,13 @@ class Dolistore } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of product formated for output * * @return string HTML output */ - function get_products() + public function get_products() { // phpcs:enable global $langs, $conf; @@ -291,44 +291,44 @@ class Dolistore '.$download_link.' '; - } - return $html; - } + } + return $html; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * get previous link * * @param string $text symbol previous * @return string html previous link */ - function get_previous_link($text = '<<') + public function get_previous_link($text = '<<') { // phpcs:enable return ''.$text.''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * get next link * * @param string $text symbol next * @return string html next link */ - function get_next_link($text = '>>') + public function get_next_link($text = '>>') { // phpcs:enable return ''.$text.''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * get previous url * * @return string previous url */ - function get_previous_url() - { + public function get_previous_url() + { // phpcs:enable $param_array = array(); if ($this->start < $this->per_page) { @@ -343,15 +343,15 @@ class Dolistore } $param = http_build_query($param_array); return $this->url."&".$param; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * get next url * * @return string next url */ - function get_next_url() + public function get_next_url() { // phpcs:enable $param_array = array(); @@ -369,7 +369,7 @@ class Dolistore return $this->url."&".$param; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * version compare * @@ -377,7 +377,7 @@ class Dolistore * @param string $v2 version 2 * @return int result of compare */ - function version_compare($v1, $v2) + public function version_compare($v1, $v2) { // phpcs:enable $v1 = explode('.', $v1); diff --git a/htdocs/admin/receiptprinter.php b/htdocs/admin/receiptprinter.php index 5bbd6746573..f532db76ce4 100644 --- a/htdocs/admin/receiptprinter.php +++ b/htdocs/admin/receiptprinter.php @@ -81,7 +81,7 @@ if ($action == 'addprinter' && $user->admin) { } if (! $error) { - $result= $printer->AddPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter); + $result= $printer->addPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter); if ($result > 0) $error++; if (! $error) @@ -107,7 +107,7 @@ if ($action == 'deleteprinter' && $user->admin) { } if (! $error) { - $result= $printer->DeletePrinter($printerid); + $result= $printer->deletePrinter($printerid); if ($result > 0) $error++; if (! $error) @@ -133,7 +133,7 @@ if ($action == 'updateprinter' && $user->admin) { } if (! $error) { - $result= $printer->UpdatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid); + $result= $printer->updatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid); if ($result > 0) $error++; if (! $error) { @@ -156,7 +156,7 @@ if ($action == 'testprinter' && $user->admin) { if (! $error) { // test - $ret = $printer->SendTestToPrinter($printerid); + $ret = $printer->sendTestToPrinter($printerid); if ($ret == 0) { setEventMessages($langs->trans("TestSentToPrinter", $printername), null); } else { @@ -176,7 +176,7 @@ if ($action == 'updatetemplate' && $user->admin) { } if (! $error) { - $result= $printer->UpdateTemplate($templatename, $template, $templateid); + $result= $printer->updateTemplate($templatename, $template, $templateid); if ($result > 0) $error++; if (! $error) { diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php index 5595f94a950..6c9074226dc 100644 --- a/htdocs/api/class/api.class.php +++ b/htdocs/api/class/api.class.php @@ -37,7 +37,7 @@ class DolibarrApi /** * @var Restler $r Restler object */ - var $r; + public $r; /** * Constructor @@ -46,7 +46,7 @@ class DolibarrApi * @param string $cachedir Cache dir * @param boolean $refreshCache Update cache */ - function __construct($db, $cachedir = '', $refreshCache = false) + public function __construct($db, $cachedir = '', $refreshCache = false) { global $conf, $dolibarr_main_url_root; @@ -87,16 +87,16 @@ class DolibarrApi ); }*/ - + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Clean sensible object datas * * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + protected function _cleanObjectDatas($object) { - + // phpcs:enable // Remove $db object property for object unset($object->db); unset($object->isextrafieldmanaged); @@ -208,6 +208,7 @@ class DolibarrApi return $object; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Check user access to a resource * @@ -222,9 +223,9 @@ class DolibarrApi * @return bool * @throws RestException */ - static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') + protected static function _checkAccessToResource($resource, $resource_id = 0, $dbtablename = '', $feature2 = '', $dbt_keyfield = 'fk_soc', $dbt_select = 'rowid') { - + // phpcs:enable // Features/modules to check $featuresarray = array($resource); if (preg_match('/&/', $resource)) { @@ -240,16 +241,18 @@ class DolibarrApi } return checkUserAccessToObject(DolibarrApiAccess::$user, $featuresarray, $resource_id, $dbtablename, $feature2, $dbt_keyfield, $dbt_select); - } + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Return if a $sqlfilters parameter is valid * * @param string $sqlfilters sqlfilter string * @return boolean True if valid, False if not valid */ - function _checkFilters($sqlfilters) + protected function _checkFilters($sqlfilters) { + // phpcs:enable //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); $tmp=$sqlfilters; @@ -271,14 +274,15 @@ class DolibarrApi return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Function to forge a SQL criteria * * @param array $matches Array of found string by regex search * @return string Forged criteria. Example: "t.field like 'abc%'" */ - static function _forge_criteria_callback($matches) + protected static function _forge_criteria_callback($matches) { // phpcs:enable global $db; diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php index 9c748fb5f03..010bb854f25 100644 --- a/htdocs/api/class/api_access.class.php +++ b/htdocs/api/class/api_access.class.php @@ -173,20 +173,20 @@ class DolibarrApiAccess implements iAuthenticate * @example Digest * @example OAuth */ - public function __getWWWAuthenticateString() + public function __getWWWAuthenticateString() { // phpcs:enable return ''; } - /** - * Verify access - * - * @param array $m Properties of method - * - * @access private - * @return bool - */ + /** + * Verify access + * + * @param array $m Properties of method + * + * @access private + * @return bool + */ public static function verifyAccess(array $m) { $requires = isset($m['class']['DolibarrApiAccess']['properties']['requires']) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 7473bc5db5e..19bd61c641b 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -43,7 +43,7 @@ class Documents extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db; $this->db = $db; @@ -67,7 +67,7 @@ class Documents extends DolibarrApi * * @url GET /download */ - public function index($module_part, $original_file='') + public function index($module_part, $original_file = '') { global $conf, $langs; @@ -82,12 +82,11 @@ class Documents extends DolibarrApi $entity=$conf->entity; $check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', 'read'); - $accessallowed = $check_access['accessallowed']; + $accessallowed = $check_access['accessallowed']; $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; - $original_file = $check_access['original_file']; + $original_file = $check_access['original_file']; - if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) - { + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { throw new RestException(401); } if (!$accessallowed) { @@ -127,7 +126,7 @@ class Documents extends DolibarrApi * * @url PUT /builddoc */ - public function builddoc($module_part, $original_file='', $doctemplate='', $langcode='') + public function builddoc($module_part, $original_file = '', $doctemplate = '', $langcode = '') { global $conf, $langs; @@ -153,7 +152,7 @@ class Documents extends DolibarrApi $sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals']; $original_file = $check_access['original_file']; - if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) { + if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { throw new RestException(401); } if (!$accessallowed) { @@ -245,7 +244,7 @@ class Documents extends DolibarrApi * * @url GET / */ - function getDocumentsListByElement($modulepart, $id=0, $ref='', $sortfield='', $sortorder='') + public function getDocumentsListByElement($modulepart, $id = 0, $ref = '', $sortfield = '', $sortorder = '') { global $conf; @@ -392,7 +391,7 @@ class Documents extends DolibarrApi throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $filearray=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC), 1); if (empty($filearray)) { throw new RestException(404, 'Search for modulepart '.$modulepart.' with Id '.$object->id.(! empty($object->Ref)?' or Ref '.$object->ref:'').' does not return any document.'); } @@ -428,6 +427,7 @@ class Documents extends DolibarrApi * @param string $filecontent File content (string with file content. An empty file will be created if this parameter is not provided) * @param string $fileencoding File encoding (''=no encoding, 'base64'=Base 64) {@example '' or 'base64'} * @param int $overwriteifexists Overwrite file if exists (1 by default) + * @return string * * @throws 200 * @throws 400 @@ -437,7 +437,7 @@ class Documents extends DolibarrApi * * @url POST /upload */ - public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0) + public function post($filename, $modulepart, $ref = '', $subdir = '', $filecontent = '', $fileencoding = '', $overwriteifexists = 0) { global $db, $conf; @@ -517,7 +517,7 @@ class Documents extends DolibarrApi if($result == 0) { throw new RestException(404, "Object with ref '".$ref."' was not found."); - } + } elseif ($result < 0) { throw new RestException(500, 'Error while fetching object.'); @@ -592,6 +592,7 @@ class Documents extends DolibarrApi return dol_basename($destfile); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName /** * Validate fields before create or update object * @@ -599,7 +600,8 @@ class Documents extends DolibarrApi * @return array * @throws RestException */ - function _validate_file($data) { + private function _validate_file($data) { + // phpcs:enable $result = array(); foreach (Documents::$DOCUMENT_FIELDS as $field) { if (!isset($data[$field])) diff --git a/htdocs/api/class/api_login.class.php b/htdocs/api/class/api_login.class.php index 43a0aeb9bbb..2bf464f7296 100644 --- a/htdocs/api/class/api_login.class.php +++ b/htdocs/api/class/api_login.class.php @@ -29,11 +29,11 @@ class Login /** * Constructor of the class */ - function __construct() + public function __construct() { - global $db; - $this->db = $db; - } + global $db; + $this->db = $db; + } /** * Login @@ -136,5 +136,5 @@ class Login 'message' => 'Welcome ' . $login.($reset?' - Token is new':' - This is your token (generated by a previous call). You can use it to make any REST API call, or enter it into the DOLAPIKEY field to use the Dolibarr API explorer.') ) ); - } + } } diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 00a84a00555..766cf79f7be 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -38,7 +38,7 @@ class Setup extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db; $this->db = $db; @@ -61,7 +61,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getPaymentTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -76,7 +76,7 @@ class Setup extends DolibarrApi { throw new RestException(400, 'error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -128,7 +128,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') + public function getListOfCountries($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $filter = '', $lang = '', $sqlfilters = '') { $list = array(); @@ -195,7 +195,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getCountryByID($id, $lang = '') + public function getCountryByID($id, $lang = '') { $country = new Ccountry($this->db); @@ -228,7 +228,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getAvailability($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -279,7 +279,7 @@ class Setup extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -334,7 +334,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfEventTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '') + public function getListOfEventTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $module = '', $active = 1, $sqlfilters = '') { $list = array(); @@ -397,7 +397,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '') + public function getListOfCivilities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $module = '', $active = 1, $sqlfilters = '') { $list = array(); @@ -442,7 +442,7 @@ class Setup extends DolibarrApi return $list; } - + /** * Get the list of currencies. * @@ -458,10 +458,10 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfCurrencies($sortfield = "code_iso", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getListOfCurrencies($sortfield = "code_iso", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); - //TODO link with multicurrency module + //TODO link with multicurrency module $sql = "SELECT t.code_iso, t.label, t.unicode"; $sql.= " FROM ".MAIN_DB_PREFIX."c_currencies as t"; $sql.= " WHERE t.active = ".$active; @@ -516,7 +516,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') + public function getListOfExtrafields($sortfield = "t.pos", $sortorder = 'ASC', $type = '', $sqlfilters = '') { $list = array(); @@ -595,7 +595,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $active = 1, $sqlfilters = '') + public function getListOfTowns($sortfield = "zip,town", $sortorder = 'ASC', $limit = 100, $page = 0, $zipcode = '', $town = '', $active = 1, $sqlfilters = '') { $list = array(); @@ -659,7 +659,7 @@ class Setup extends DolibarrApi * @throws 400 RestException * @throws 200 OK */ - function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getPaymentTerms($sortfield = "sortorder", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -720,7 +720,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsCategories($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); @@ -780,13 +780,13 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsSeverities($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); $sql = "SELECT rowid, code, pos, label, use_default, color, description"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_severity as t"; - $sql.= " WHERE t.active = ".$active; + $sql.= " WHERE t.active = ".$active; // Add sql filters if ($sqlfilters) { @@ -840,13 +840,13 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') + public function getTicketsTypes($sortfield = "code", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { $list = array(); $sql = "SELECT rowid, code, pos, label, use_default, description"; $sql.= " FROM ".MAIN_DB_PREFIX."c_ticket_type as t"; - $sql.= " WHERE t.active = ".$active; + $sql.= " WHERE t.active = ".$active; if ($type) $sql.=" AND t.type LIKE '%" . $this->db->escape($type) . "%'"; if ($module) $sql.=" AND t.module LIKE '%" . $this->db->escape($module) . "%'"; // Add sql filters @@ -898,7 +898,7 @@ class Setup extends DolibarrApi * * @throws RestException */ - function getCheckIntegrity($target) + public function getCheckIntegrity($target) { global $langs, $conf; diff --git a/htdocs/api/class/api_status.class.php b/htdocs/api/class/api_status.class.php index 3ade4ea51b8..3e61b2e6d0a 100644 --- a/htdocs/api/class/api_status.class.php +++ b/htdocs/api/class/api_status.class.php @@ -31,7 +31,7 @@ class Status * * @return array */ - function index() + public function index() { global $conf; diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index aca175b59d2..8e9e31e68b2 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -23,8 +23,6 @@ */ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class for Asset @@ -312,7 +310,7 @@ class Asset extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -369,12 +367,12 @@ class Asset extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -382,7 +380,7 @@ class Asset extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - static function LibStatut($status, $mode = 0) + public static function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -425,7 +423,7 @@ class Asset extends CommonObject * @param int $id Id of order * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql.= ' fk_user_creat, fk_user_modif'; diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php index 58baf280036..9cc96ae6c44 100644 --- a/htdocs/asset/class/asset_type.class.php +++ b/htdocs/asset/class/asset_type.class.php @@ -76,7 +76,7 @@ class AssetType extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -89,8 +89,8 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function create($user, $notrigger = 0) - { + public function create($user, $notrigger = 0) + { global $conf; $error=0; @@ -157,7 +157,7 @@ class AssetType extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Met a jour en base donnees du type @@ -166,7 +166,7 @@ class AssetType extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int >0 if OK, < 0 if KO */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $hookmanager; @@ -233,7 +233,7 @@ class AssetType extends CommonObject * * @return int >0 if OK, 0 if not found, < 0 if KO */ - function delete() + public function delete() { global $user; @@ -267,7 +267,7 @@ class AssetType extends CommonObject * @param int $rowid Id of member type to load * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note"; $sql .= " FROM ".MAIN_DB_PREFIX."asset_type as d"; @@ -282,13 +282,13 @@ class AssetType extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->label = $obj->label; - $this->accountancy_code_asset = $obj->accountancy_code_asset; - $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; - $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; - $this->note = $obj->note; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->label = $obj->label; + $this->accountancy_code_asset = $obj->accountancy_code_asset; + $this->accountancy_code_depreciation_asset = $obj->accountancy_code_depreciation_asset; + $this->accountancy_code_depreciation_expense = $obj->accountancy_code_depreciation_expense; + $this->note = $obj->note; } return 1; @@ -300,13 +300,13 @@ class AssetType extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of asset's type * * @return array List of types of members */ - function liste_array() + public function liste_array() { // phpcs:enable global $conf,$langs; @@ -350,7 +350,7 @@ class AssetType extends CommonObject * 2=Return array of asset id only * @return mixed Array of asset or -1 on error */ - function listAssetForAssetType($excludefilter = '', $mode = 0) + public function listAssetForAssetType($excludefilter = '', $mode = 0) { global $conf, $user; @@ -405,7 +405,7 @@ class AssetType extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0) { global $langs; @@ -430,8 +430,8 @@ class AssetType extends CommonObject * * @return void */ - function initAsSpecimen() - { + public function initAsSpecimen() + { global $conf, $user, $langs; // Initialize parameters @@ -446,15 +446,15 @@ class AssetType extends CommonObject $this->asset=array( $user->id => $user ); - } + } - /** - * getLibStatut - * - * @return string Return status of a type of asset - */ - function getLibStatut() - { - return ''; - } + /** + * getLibStatut + * + * @return string Return status of a type of asset + */ + public function getLibStatut() + { + return ''; + } } diff --git a/htdocs/blockedlog/class/authority.class.php b/htdocs/blockedlog/class/authority.class.php index 6db5edf4646..376a1d3986a 100644 --- a/htdocs/blockedlog/class/authority.class.php +++ b/htdocs/blockedlog/class/authority.class.php @@ -53,7 +53,7 @@ class BlockedLogAuthority public function __construct($db) { $this->db = $db; - } + } /** * Get the blockchain @@ -76,7 +76,7 @@ class BlockedLogAuthority } return $this->blockchain; - } + } /** * Get hash of the block chain to check @@ -87,7 +87,7 @@ class BlockedLogAuthority { return md5($this->signature.$this->blockchain); - } + } /** * Get hash of the block chain to check @@ -99,7 +99,7 @@ class BlockedLogAuthority { return ($hash === $this->getBlockchainHash() ); - } + } /** * Add a new block to the chain @@ -111,7 +111,7 @@ class BlockedLogAuthority { $this->blockchain.=$block; - } + } /** * hash already exist into chain ? @@ -132,7 +132,7 @@ class BlockedLogAuthority else{ return false; } - } + } /** @@ -191,7 +191,7 @@ class BlockedLogAuthority $this->error=$this->db->error(); return -1; } - } + } /** * Create authority in database. @@ -245,7 +245,7 @@ class BlockedLogAuthority $this->db->rollback(); return -1; } - } + } /** * Create authority in database. @@ -283,7 +283,7 @@ class BlockedLogAuthority $this->db->rollback(); return -1; } - } + } /** * For cron to sync to authority. @@ -326,6 +326,6 @@ class BlockedLogAuthority } } - return 1; - } + return 1; + } } diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 9c7baa0634a..ae64665bbfd 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -291,8 +291,7 @@ class BlockedLog } elseif ($this->action == 'MODULE_RESET') { - if ($this->signature == '0000000000') - { + if ($this->signature == '0000000000') { return 'System to track events into unalterable logs were disabled after some recording were done. We saved a special Fingerprint to track the chain as broken.'; } else @@ -387,14 +386,15 @@ class BlockedLog $arrayoffieldstoexclude = array( 'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf','last_main_doc','civility_id','contact','contact_id', 'table_element_line','ismultientitymanaged','isextrafieldmanaged', - 'linkedObjectsIds','linkedObjects','fk_delivery_address', + 'linkedObjectsIds', + 'linkedObjects', + 'fk_delivery_address', 'context', 'projet' // There is already ->fk_project ); // Add more fields to exclude depending on object type - if ($this->element == 'cashcontrol') - { - $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array( + if ($this->element == 'cashcontrol') { + $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array( 'name','lastname','firstname','region','region_id','region_code','state','state_id','state_code','country','country_id','country_code', 'total_ht','total_tva','total_ttc','total_localtax1','total_localtax2', 'barcode_type','barcode_type_code','barcode_type_label','barcode_type_coder','mode_reglement_id','cond_reglement_id','mode_reglement','cond_reglement','shipping_method_id', @@ -727,15 +727,12 @@ class BlockedLog */ public function dolDecodeBlockedData($data, $mode = 0) { - try - { + try { //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; //include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; $aaa = unserialize($data); //$aaa = unserialize($data); - } - catch(Exception $e) - { + } catch(Exception $e) { //print $e->getErrs); } return $aaa; @@ -1064,14 +1061,14 @@ class BlockedLog } - /** - * Check if module was already used or not for at least one recording. - * - * @param int $ignoresystem Ignore system events for the test - * @return bool - */ - function alreadyUsed($ignoresystem = 0) - { + /** + * Check if module was already used or not for at least one recording. + * + * @param int $ignoresystem Ignore system events for the test + * @return bool + */ + public function alreadyUsed($ignoresystem = 0) + { global $conf; $result = false; @@ -1092,5 +1089,5 @@ class BlockedLog dol_syslog("Module Blockedlog alreadyUsed with ignoresystem=".$ignoresystem." is ".$result); return $result; - } + } } diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index ea5ba91c715..9d45b8e86f8 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -88,7 +88,7 @@ $search_all=trim(GETPOST("search_all", 'alpha')); $search=array(); foreach($object->fields as $key => $val) { - if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); + if (GETPOST('search_'.$key, 'alpha')) $search[$key]=GETPOST('search_'.$key, 'alpha'); } if (empty($action) && empty($id) && empty($ref)) $action='view'; @@ -115,15 +115,15 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { - $error=0; + $error=0; - $permissiontoadd = $user->rights->bom->write; - $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); + $permissiontoadd = $user->rights->bom->write; + $permissiontodelete = $user->rights->bom->delete || ($permissiontoadd && $object->status == 0); $backurlforlist = dol_buildpath('/bom/bom_list.php', 1); - if (empty($backtopage)) { - if (empty($id)) $backtopage = $backurlforlist; - else $backtopage = dol_buildpath('/bom/bom_card.php', 1).($id > 0 ? $id : '__ID__'); - } + if (empty($backtopage)) { + if (empty($id)) $backtopage = $backurlforlist; + else $backtopage = dol_buildpath('/bom/bom_card.php', 1).($id > 0 ? $id : '__ID__'); + } $triggermodname = 'BILLOFMATERIALS_BILLOFMATERIALS_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, delete or clone diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 4785d0c4598..3ec9695a7e0 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -478,19 +478,19 @@ while ($i < min($num, $limit)) if (isset($obj->$key)) $object->$key = $obj->$key; } - // Show here line of result - print ''; - foreach($object->fields as $key => $val) - { + // Show here line of result + print ''; + foreach($object->fields as $key => $val) + { $cssforfield=''; if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield.=($cssforfield?' ':'').'center'; elseif ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center'; - if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; - elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; + if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap'; + elseif ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowrap'; - if (! empty($arrayfields['t.'.$key]['checked'])) - { + if (! empty($arrayfields['t.'.$key]['checked'])) + { print 'rights->bom->create) { throw new RestException(401); @@ -222,7 +222,7 @@ class BillOfMaterialsApi extends DolibarrApi * * @url PUT boms/{id} */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->bom->create) { throw new RestException(401); @@ -255,7 +255,7 @@ class BillOfMaterialsApi extends DolibarrApi * * @url DELETE bom/{id} */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->bom->delete) { throw new RestException(401); @@ -289,7 +289,7 @@ class BillOfMaterialsApi extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -311,7 +311,7 @@ class BillOfMaterialsApi extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $bom = array(); foreach (BillOfMaterialsApi::$FIELDS as $field) { diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 2221da19567..fd44199a1a7 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -398,7 +398,7 @@ class BillOfMaterials extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -979,11 +979,11 @@ class BillOfMaterialsLine extends CommonObject * @param int $notooltip 1=Disable tooltip * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs, $hookmanager; + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; @@ -1043,7 +1043,7 @@ class BillOfMaterialsLine extends CommonObject else $result .= $hookmanager->resPrint; return $result; - } + } /** * Return label of the status @@ -1179,7 +1179,7 @@ class BillOfMaterialsLine extends CommonObject * Action executed by scheduler * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters' * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ //public function doScheduledJob($param1, $param2, ...) public function doScheduledJob() diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index f66ef8e4d80..eb1342ad119 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -82,7 +82,7 @@ class Bookmark extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -93,7 +93,7 @@ class Bookmark extends CommonObject * @param int $id Bookmark Id Loader * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $conf; @@ -135,7 +135,7 @@ class Bookmark extends CommonObject * * @return int <0 si ko, rowid du bookmark cree si ok */ - function create() + public function create() { global $conf; @@ -192,7 +192,7 @@ class Bookmark extends CommonObject * * @return int <0 if KO, > if OK */ - function update() + public function update() { // Clean parameters $this->url=trim($this->url); @@ -227,7 +227,7 @@ class Bookmark extends CommonObject * @param int $id Id removed bookmark * @return int <0 si ko, >0 si ok */ - function remove($id) + public function remove($id) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark"; $sql .= " WHERE rowid = ".$id; @@ -268,7 +268,7 @@ class Bookmark extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of contact status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return ''; } diff --git a/htdocs/cashdesk/class/Auth.class.php b/htdocs/cashdesk/class/Auth.class.php index 26c1bee3d3c..d33081f8e74 100644 --- a/htdocs/cashdesk/class/Auth.class.php +++ b/htdocs/cashdesk/class/Auth.class.php @@ -60,7 +60,7 @@ class Auth * @param string $aPasswd Password * @return void */ - function passwd($aPasswd) + public function passwd($aPasswd) { $this->passwd = $aPasswd; } diff --git a/htdocs/categories/class/api_categories.class.php b/htdocs/categories/class/api_categories.class.php index 2b670ae5286..434b7ba1d24 100644 --- a/htdocs/categories/class/api_categories.class.php +++ b/htdocs/categories/class/api_categories.class.php @@ -53,7 +53,7 @@ class Categories extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -70,7 +70,7 @@ class Categories extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); @@ -103,7 +103,7 @@ class Categories extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $type = '', $sqlfilters = '') { global $db, $conf; @@ -173,7 +173,7 @@ class Categories extends DolibarrApi * @param array $request_data Request data * @return int ID of category */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); @@ -198,7 +198,7 @@ class Categories extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->categorie->creer) { throw new RestException(401); @@ -234,7 +234,7 @@ class Categories extends DolibarrApi * @param int $id Category ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->categorie->supprimer) { throw new RestException(401); @@ -267,7 +267,7 @@ class Categories extends DolibarrApi * @param Categorie $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -324,7 +324,7 @@ class Categories extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $category = array(); foreach (Categories::$FIELDS as $field) { diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 99433a9b8f0..2c3a3c9032c 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -10,7 +10,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * * 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 @@ -107,7 +107,7 @@ class Categorie extends CommonObject 'account' => 'account', // old for bank_account 'bank_account' => 'account', 'project' => 'project', - ); + ); /** * @var array Category tables mapping from type string @@ -221,7 +221,7 @@ class Categorie extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -234,7 +234,7 @@ class Categorie extends CommonObject * @param string $type Type of category ('product', '...') or (0, 1, ...) * @return int <0 if KO, >0 if OK */ - function fetch($id, $label = '', $type = null) + public function fetch($id, $label = '', $type = null) { global $conf; @@ -297,15 +297,15 @@ class Categorie extends CommonObject } /** - * Add category into database + * Add category into database * - * @param User $user Object user - * @return int -1 : SQL error + * @param User $user Object user + * @return int -1 : SQL error * -2 : new ID unknown * -3 : Invalid category * -4 : category already exists */ - function create($user) + public function create($user) { global $conf,$langs,$hookmanager; $langs->load('categories'); @@ -426,7 +426,7 @@ class Categorie extends CommonObject * -1 : SQL error * -2 : invalid category */ - function update(User $user) + public function update(User $user) { global $conf, $langs,$hookmanager; @@ -501,7 +501,7 @@ class Categorie extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 KO >0 OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf,$langs; @@ -580,7 +580,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link an object to the category * @@ -588,7 +588,7 @@ class Categorie extends CommonObject * @param string $type Type of category ('product', ...) * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ - function add_type($obj, $type) + public function add_type($obj, $type) { // phpcs:enable global $user,$langs,$conf; @@ -682,7 +682,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete object from category * @@ -691,7 +691,7 @@ class Categorie extends CommonObject * * @return int 1 if OK, -1 if KO */ - function del_type($obj, $type) + public function del_type($obj, $type) { // phpcs:enable global $user,$langs,$conf; @@ -749,7 +749,7 @@ class Categorie extends CommonObject * @return array|int -1 if KO, array of instance of object if OK * @see containsObject */ - function getObjectsInCateg($type, $onlyids = 0) + public function getObjectsInCateg($type, $onlyids = 0) { $objs = array(); @@ -796,7 +796,7 @@ class Categorie extends CommonObject * @return int Number of occurrences * @see getObjectsInCateg */ - function containsObject($type, $object_id) + public function containsObject($type, $object_id) { $sql = "SELECT COUNT(*) as nb FROM " . MAIN_DB_PREFIX . "categorie_" . $this->MAP_CAT_TABLE[$type]; $sql .= " WHERE fk_categorie = " . $this->id . " AND fk_" . $this->MAP_CAT_FK[$type] . " = " . $object_id; @@ -821,7 +821,7 @@ class Categorie extends CommonObject * @param int $page Page number * @return array|int Array of categories, 0 if no cat, -1 on error */ - function getListForItem($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + public function getListForItem($id, $type = 'customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { global $conf; @@ -907,13 +907,13 @@ class Categorie extends CommonObject return $categories; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return childs of a category * * @return array|int <0 KO, array ok */ - function get_filles() + public function get_filles() { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; @@ -974,7 +974,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Rebuilding the category tree as an array * Return an array of table('id','id_mere',...) trie selon arbre et avec: @@ -990,7 +990,7 @@ class Categorie extends CommonObject * * @return array|int Array of categories. this->cats and this->motherof are set, -1 on error */ - function get_full_arbo($type, $markafterid = 0) + public function get_full_arbo($type, $markafterid = 0) { // phpcs:enable global $conf, $langs; @@ -1068,7 +1068,7 @@ class Categorie extends CommonObject return $this->cats; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For category id_categ and its childs available in this->cats, define property fullpath and fulllabel * @@ -1076,10 +1076,10 @@ class Categorie extends CommonObject * @param int $protection Deep counter to avoid infinite loop * @return void */ - function build_path_from_id_categ($id_categ, $protection = 1000) - { + public function build_path_from_id_categ($id_categ, $protection = 1000) + { // phpcs:enable - dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); + dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG); if (! empty($this->cats[$id_categ]['fullpath'])) { @@ -1109,16 +1109,16 @@ class Categorie extends CommonObject // We count number of _ to have level $this->cats[$id_categ]['level']=dol_strlen(preg_replace('/[^_]/i', '', $this->cats[$id_categ]['fullpath'])); - return; - } + return; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display content of $this->cats * * @return void */ - function debug_cats() + public function debug_cats() { // phpcs:enable // Display $this->cats @@ -1135,7 +1135,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns all categories * @@ -1143,7 +1143,7 @@ class Categorie extends CommonObject * @param boolean $parent Just parent categories if true * @return array|int Table of Object Category, -1 on error */ - function get_all_categories($type = null, $parent = false) + public function get_all_categories($type = null, $parent = false) { // phpcs:enable if (! is_numeric($type)) $type = $this->MAP_ID[$type]; @@ -1174,13 +1174,13 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if no category with same label already exists for this cat's parent or root and for this cat's type * * @return integer 1 if already exist, 0 otherwise, -1 if error */ - function already_exists() + public function already_exists() { // phpcs:enable $type=$this->type; @@ -1225,20 +1225,20 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the top level categories (which are not girls) * * @param int $type Type of category (0, 1, ...) * @return array */ - function get_main_categories($type = null) + public function get_main_categories($type = null) { // phpcs:enable return $this->get_all_categories($type, true); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the path of the category, with the names of the categories * separated by $sep (" >> " by default) @@ -1248,7 +1248,7 @@ class Categorie extends CommonObject * @param int $nocolor 0 * @return array */ - function print_all_ways($sep = " >> ", $url = '', $nocolor = 0) + public function print_all_ways($sep = " >> ", $url = '', $nocolor = 0) { // phpcs:enable $ways = array(); @@ -1297,13 +1297,13 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array containing the list of parent categories * * @return int|array <0 KO, array OK */ - function get_meres() + public function get_meres() { // phpcs:enable $parents = array(); @@ -1333,14 +1333,14 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns in a table all possible paths to get to the category * starting with the major categories represented by Tables of categories * * @return array */ - function get_all_ways() + public function get_all_ways() { // phpcs:enable $ways = array(); @@ -1376,7 +1376,7 @@ class Categorie extends CommonObject * labels, 'id'= Get array of category IDs * @return array|int Array of category objects or < 0 if KO */ - function containing($id, $type, $mode = 'object') + public function containing($id, $type, $mode = 'object') { $cats = array(); @@ -1458,7 +1458,7 @@ class Categorie extends CommonObject * @param boolean $case Case sensitive (true/false) * @return array|int Array of category id, -1 if error */ - function rechercher($id, $nom, $type, $exact = false, $case = false) + public function rechercher($id, $nom, $type, $exact = false, $case = false) { // Deprecation warning if (is_numeric($type)) { @@ -1467,15 +1467,15 @@ class Categorie extends CommonObject $cats = array(); - // For backward compatibility - if (is_numeric($type)) { - // We want to reverse lookup - $map_type = array_flip($this->MAP_ID); - $type = $map_type[$type]; + // For backward compatibility + if (is_numeric($type)) { + // We want to reverse lookup + $map_type = array_flip($this->MAP_ID); + $type = $map_type[$type]; dol_syslog(get_class($this) . "::rechercher(): numeric types are deprecated, please use string instead", LOG_WARNING); - } + } - // Generation requete recherche + // Generation requete recherche $sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "categorie"; $sql .= " WHERE type = " . $this->MAP_ID[$type]; $sql .= " AND entity IN (" . getEntity('category') . ")"; @@ -1521,7 +1521,7 @@ class Categorie extends CommonObject * @param int $maxlength Max length of text * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $maxlength = 0) + public function getNomUrl($withpicto = 0, $option = '', $maxlength = 0) { global $langs; @@ -1548,7 +1548,7 @@ class Categorie extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Deplace fichier uploade sous le nom $files dans le repertoire sdir * @@ -1556,7 +1556,7 @@ class Categorie extends CommonObject * @param string $file Nom du fichier uploade * @return void */ - function add_photo($sdir, $file) + public function add_photo($sdir, $file) { // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1599,7 +1599,7 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return tableau de toutes les photos de la categorie * @@ -1607,7 +1607,7 @@ class Categorie extends CommonObject * @param int $nbmax Nombre maximum de photos (0=pas de max) * @return array Tableau de photos */ - function liste_photos($dir, $nbmax = 0) + public function liste_photos($dir, $nbmax = 0) { // phpcs:enable include_once DOL_DOCUMENT_ROOT .'/core/lib/files.lib.php'; @@ -1656,14 +1656,14 @@ class Categorie extends CommonObject return $tabobj; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Efface la photo de la categorie et sa vignette * * @param string $file Path to file * @return void */ - function delete_photo($file) + public function delete_photo($file) { // phpcs:enable require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1686,14 +1686,14 @@ class Categorie extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load size of image file * * @param string $file Path to file * @return void */ - function get_image_size($file) + public function get_image_size($file) { // phpcs:enable $infoImg = getimagesize($file); // Recuperation des infos de l'image @@ -1708,7 +1708,7 @@ class Categorie extends CommonObject * * @return int <0 if KO, >0 if OK */ - function setMultiLangs($user) + public function setMultiLangs($user) { global $langs; @@ -1789,7 +1789,7 @@ class Categorie extends CommonObject * * @return int <0 if KO, >0 if OK */ - function getMultiLangs() + public function getMultiLangs() { global $langs; @@ -1828,7 +1828,7 @@ class Categorie extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of contact status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return ''; } @@ -1841,7 +1841,7 @@ class Categorie extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { dol_syslog(get_class($this)."::initAsSpecimen"); @@ -1855,20 +1855,20 @@ class Categorie extends CommonObject $this->type = self::TYPE_PRODUCT; } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'categorie_societe' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'categorie_societe' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables, 1); + } } diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 4ac6579592e..fba891a848a 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -480,13 +480,13 @@ class ActionComm extends CommonObject } /** - * Load an object from its id and create a new one in database + * Load an object from its id and create a new one in database * - * @param user $fuser Object user making action - * @param int $socid Id of thirdparty - * @return int New id of clone + * @param user $fuser Object user making action + * @param int $socid Id of thirdparty + * @return int New id of clone */ - function createFromClone($fuser, $socid) + public function createFromClone($fuser, $socid) { global $db, $user, $langs, $conf, $hookmanager; @@ -502,7 +502,7 @@ class ActionComm extends CommonObject // fetch optionals attributes and labels $this->fetch_optionals(); -// $this->fetch_userassigned(); + //$this->fetch_userassigned(); $this->fetchResources(); $this->id=0; @@ -559,14 +559,14 @@ class ActionComm extends CommonObject } /** - * Load object from database + * Load object from database * - * @param int $id Id of action to get - * @param string $ref Ref of action to get - * @param string $ref_ext Ref ext to get - * @return int <0 if KO, >0 if OK + * @param int $id Id of action to get + * @param string $ref Ref of action to get + * @param string $ref_ext Ref ext to get + * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '', $ref_ext = '') + public function fetch($id, $ref = '', $ref_ext = '') { global $langs; @@ -637,11 +637,11 @@ class ActionComm extends CommonObject $this->usermodid = $obj->fk_user_mod; if (!is_object($this->author)) $this->author = new stdClass(); // To avoid warning - $this->author->id = $obj->fk_user_author; // deprecated - $this->author->firstname = $obj->firstname; // deprecated - $this->author->lastname = $obj->lastname; // deprecated + $this->author->id = $obj->fk_user_author; // deprecated + $this->author->firstname = $obj->firstname; // deprecated + $this->author->lastname = $obj->lastname; // deprecated if (!is_object($this->usermod)) $this->usermod = new stdClass(); // To avoid warning - $this->usermod->id = $obj->fk_user_mod; // deprecated + $this->usermod->id = $obj->fk_user_mod; // deprecated $this->userownerid = $obj->fk_user_action; $this->userdoneid = $obj->fk_user_done; @@ -675,13 +675,13 @@ class ActionComm extends CommonObject return $num; } - /** + /** * Initialize $this->userassigned & this->socpeopleassigned array with list of id of user and contact assigned to event * - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ - function fetchResources() - { + public function fetchResources() + { $sql ='SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency'; $sql.=' FROM '.MAIN_DB_PREFIX.'actioncomm_resources'; $sql.=' WHERE fk_actioncomm = '.$this->id; @@ -720,13 +720,13 @@ class ActionComm extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialize this->userassigned array with list of id of user assigned to event * * @return int <0 if KO, >0 if OK */ - function fetch_userassigned() + public function fetch_userassigned() { // phpcs:enable $sql ="SELECT fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; @@ -761,7 +761,7 @@ class ActionComm extends CommonObject * @param int $notrigger 1 = disable triggers, 0 = enable triggers * @return int <0 if KO, >0 if OK */ - function delete($notrigger = 0) + public function delete($notrigger = 0) { global $user,$langs,$conf; @@ -780,15 +780,15 @@ class ActionComm extends CommonObject } if (! $error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; - $sql.= " WHERE fk_actioncomm=".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_resources"; + $sql.= " WHERE fk_actioncomm=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $res=$this->db->query($sql); - if ($res < 0) { - $this->error=$this->db->lasterror(); - $error++; - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $res=$this->db->query($sql); + if ($res < 0) { + $this->error=$this->db->lasterror(); + $error++; + } } // Removed extrafields @@ -838,7 +838,7 @@ class ActionComm extends CommonObject * @param int $notrigger 1 = disable triggers, 0 = enable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs,$conf,$hookmanager; @@ -986,20 +986,20 @@ class ActionComm extends CommonObject } /** - * Load all objects with filters. - * WARNING: This make a fetch on all records instead of making one request with a join. + * Load all objects with filters. + * WARNING: This make a fetch on all records instead of making one request with a join. * - * @param DoliDb $db Database handler - * @param int $socid Filter by thirdparty - * @param int $fk_element Id of element action is linked to - * @param string $elementtype Type of element action is linked to - * @param string $filter Other filter - * @param string $sortfield Sort on this field - * @param string $sortorder ASC or DESC - * @param string $limit Limit number of answers - * @return array or string Error string if KO, array with actions if OK + * @param DoliDb $db Database handler + * @param int $socid Filter by thirdparty + * @param int $fk_element Id of element action is linked to + * @param string $elementtype Type of element action is linked to + * @param string $filter Other filter + * @param string $sortfield Sort on this field + * @param string $sortorder ASC or DESC + * @param string $limit Limit number of answers + * @return array or string Error string if KO, array with actions if OK */ - static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) + public static function getActions($db, $socid = 0, $fk_element = 0, $elementtype = '', $filter = '', $sortfield = 'a.datep', $sortorder = 'DESC', $limit = 0) { global $conf, $langs; @@ -1043,7 +1043,7 @@ class ActionComm extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1051,7 +1051,7 @@ class ActionComm extends CommonObject * @param int $load_state_board Charge indicateurs this->nb de tableau de bord * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user, $load_state_board = 0) + public function load_board($user, $load_state_board = 0) { // phpcs:enable global $conf, $langs; @@ -1107,12 +1107,12 @@ class ActionComm extends CommonObject /** - * Charge les informations d'ordre info dans l'objet facture + * Charge les informations d'ordre info dans l'objet facture * - * @param int $id Id de la facture a charger - * @return void + * @param int $id Id de la facture a charger + * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT '; $sql.= ' a.id,'; @@ -1157,38 +1157,38 @@ class ActionComm extends CommonObject /** - * Return label of status + * Return label of status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @param int $hidenastatus 1=Show nothing if status is "Not applicable" - * @return string String with status + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $hidenastatus 1=Show nothing if status is "Not applicable" + * @return string String with status */ - function getLibStatut($mode, $hidenastatus = 0) + public function getLibStatut($mode, $hidenastatus = 0) { return $this->LibStatut($this->percentage, $mode, $hidenastatus, $this->datep); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return label of action status + * Return label of action status * - * @param int $percent Percent - * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto - * @param int $hidenastatus 1=Show nothing if status is "Not applicable" - * @param int $datestart Date start of event - * @return string Label + * @param int $percent Percent + * @param int $mode 0=Long label, 1=Short label, 2=Picto+Short label, 3=Picto, 4=Picto+Short label, 5=Short label+Picto, 6=Picto+Long label, 7=Very short label+Picto + * @param int $hidenastatus 1=Show nothing if status is "Not applicable" + * @param int $datestart Date start of event + * @return string Label */ - function LibStatut($percent, $mode, $hidenastatus = 0, $datestart = '') + public function LibStatut($percent, $mode, $hidenastatus = 0, $datestart = '') { // phpcs:enable global $langs; if ($mode == 0) { - if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); - elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; - elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; - elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; + if ($percent==-1 && ! $hidenastatus) return $langs->trans('StatusNotApplicable'); + elseif ($percent==0) return $langs->trans('StatusActionToDo').' (0%)'; + elseif ($percent > 0 && $percent < 100) return $langs->trans('StatusActionInProcess').' ('.$percent.'%)'; + elseif ($percent >= 100) return $langs->trans('StatusActionDone').' (100%)'; } elseif ($mode == 1) { @@ -1244,28 +1244,28 @@ class ActionComm extends CommonObject } /** - * Return URL of event - * Use $this->id, $this->type_code, $this->label and $this->type_label + * Return URL of event + * Use $this->id, $this->type_code, $this->label and $this->type_label * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. - * @param string $classname Force style class on a link - * @param string $option ''=Link to action, 'birthday'=Link to contact - * @param int $overwritepicto 1=Overwrite picto - * @param int $notooltip 1=Disable tooltip - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlength Max number of charaters into label. If negative, use the ref as label. + * @param string $classname Force style class on a link + * @param string $option ''=Link to action, 'birthday'=Link to contact + * @param int $overwritepicto 1=Overwrite picto + * @param int $notooltip 1=Disable tooltip + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlength = 0, $classname = '', $option = '', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $maxlength = 0, $classname = '', $option = '', $overwritepicto = 0, $notooltip = 0, $save_lastsearch_value = -1) { - global $conf, $langs, $user, $hookmanager, $action; + global $conf, $langs, $user, $hookmanager, $action; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - if ((!$user->rights->agenda->allactions->read && $this->author->id != $user->id) || (!$user->rights->agenda->myactions->read && $this->author->id == $user->id)) - $option = 'nolink'; + if ((!$user->rights->agenda->allactions->read && $this->author->id != $user->id) || (!$user->rights->agenda->myactions->read && $this->author->id == $user->id)) + $option = 'nolink'; - $label = $this->label; + $label = $this->label; if (empty($label)) $label=$this->libelle; // For backward compatibility $result=''; @@ -1379,7 +1379,7 @@ class ActionComm extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Export events from database into a cal file. * @@ -1390,7 +1390,7 @@ class ActionComm extends CommonObject * @param array $filters Array of filters. Exemple array('notolderthan'=>99, 'year'=>..., 'idfrom'=>..., 'notactiontype'=>'systemauto', 'project'=>123, ...) * @return int <0 if error, nb of events in new file if ok */ - function build_exportfile($format, $type, $cachedelay, $filename, $filters) + public function build_exportfile($format, $type, $cachedelay, $filename, $filters) { // phpcs:enable global $conf,$langs,$dolibarr_main_url_root,$mysoc; @@ -1614,11 +1614,11 @@ class ActionComm extends CommonObject /** * Initialise an instance with random values. * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. + * id must be 0 if object instance is a specimen. * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user; @@ -1651,12 +1651,12 @@ class ActionComm extends CommonObject } /** - * Function used to replace a thirdparty id with another one. + * Function used to replace a thirdparty id with another one. * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool */ public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) { @@ -1668,9 +1668,9 @@ class ActionComm extends CommonObject } /** - * Is the action delayed? + * Is the action delayed? * - * @return bool + * @return bool */ public function hasDelay() { @@ -1683,10 +1683,10 @@ class ActionComm extends CommonObject /** - * Send reminders by emails - * CAN BE A CRON TASK + * Send reminders by emails + * CAN BE A CRON TASK * - * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) + * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK) */ public function sendEmailsReminder() { @@ -1715,14 +1715,14 @@ class ActionComm extends CommonObject $this->db->begin(); - // TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done + // TODO Scan events of type 'email' into table llx_actioncomm_reminder with status todo, send email, then set status to done - // Delete also very old past events (we do not keep more than 1 month record in past) - $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; - $this->db->query($sql); + // Delete also very old past events (we do not keep more than 1 month record in past) + $sql = "DELETE FROM ".MAIN_DB_PREFIX."actioncomm_reminder WHERE dateremind < '".$this->db->jdate($now - (3600 * 24 * 32))."'"; + $this->db->query($sql); - $this->db->commit(); + $this->db->commit(); - return $error; + return $error; } } diff --git a/htdocs/comm/action/class/actioncommreminder.class.php b/htdocs/comm/action/class/actioncommreminder.class.php index f157c90f95d..b01e0e6a544 100644 --- a/htdocs/comm/action/class/actioncommreminder.class.php +++ b/htdocs/comm/action/class/actioncommreminder.class.php @@ -178,20 +178,20 @@ class ActionCommReminder extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ - static function LibStatut($status, $mode = 0) + public static function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/comm/action/class/api_agendaevents.class.php b/htdocs/comm/action/class/api_agendaevents.class.php index 6b14bb6e884..b6df9ec7d96 100644 --- a/htdocs/comm/action/class/api_agendaevents.class.php +++ b/htdocs/comm/action/class/api_agendaevents.class.php @@ -44,7 +44,7 @@ class AgendaEvents extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -61,7 +61,7 @@ class AgendaEvents extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->read) { throw new RestException(401, "Insuffisant rights to read an event"); @@ -76,11 +76,11 @@ class AgendaEvents extends DolibarrApi throw new RestException(401, "Insuffisant rights to read event for owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); } - if ( ! DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('agenda', $this->actioncomm->id, 'actioncomm', '', 'fk_soc', 'id')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->actioncomm->fetch_optionals(); + $result = $this->actioncomm->fetch_optionals(); $this->actioncomm->fetchObjectLinked(); return $this->_cleanObjectDatas($this->actioncomm); @@ -99,7 +99,7 @@ class AgendaEvents extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.label:like:'%dol%') and (t.datec:<:'20160101')" * @return array Array of Agenda Events objects */ - function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + public function index($sortfield = "t.id", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; @@ -120,13 +120,13 @@ class AgendaEvents extends DolibarrApi $sql = "SELECT t.id as rowid"; if (! empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) $sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as t"; if (! empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale $sql.= ' WHERE t.entity IN ('.getEntity('agenda').')'; if (! empty($conf->societe->enabled)) - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socid) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($user_ids) $sql.=" AND t.fk_user_action IN (".$user_ids.")"; if ($socid > 0) $sql.= " AND t.fk_soc = ".$socid; // Insert sale filter @@ -141,7 +141,7 @@ class AgendaEvents extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -188,7 +188,7 @@ class AgendaEvents extends DolibarrApi * @param array $request_data Request data * @return int ID of Agenda Event */ - function post($request_data = null) + public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); @@ -227,7 +227,7 @@ class AgendaEvents extends DolibarrApi * @return int */ /* - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->agenda->myactions->create) { throw new RestException(401, "Insuffisant rights to create your Agenda Event"); @@ -263,25 +263,25 @@ class AgendaEvents extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->agenda->myactions->delete) { throw new RestException(401, "Insuffisant rights to delete your Agenda Event"); } - $result = $this->actioncomm->fetch($id); + $result = $this->actioncomm->fetch($id); if(! DolibarrApiAccess::$user->rights->agenda->allactions->delete && DolibarrApiAccess::$user->id != $this->actioncomm->userownerid) { throw new RestException(401, "Insuffisant rights to delete an Agenda Event of owner id ".$request_data['userownerid'].' Your id is '.DolibarrApiAccess::$user->id); - } + } - if( ! $result ) { + if( ! $result ) { throw new RestException(404, 'Agenda Event not found'); } - if( ! DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('actioncomm', $this->actioncomm->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->actioncomm->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Agenda Event : '.$this->actioncomm->error); @@ -302,7 +302,7 @@ class AgendaEvents extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $event = array(); foreach (AgendaEvents::$FIELDS as $field) { @@ -319,51 +319,51 @@ class AgendaEvents extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - unset($object->usermod); - unset($object->libelle); - unset($object->context); - unset($object->canvas); - unset($object->contact); - unset($object->contact_id); - unset($object->thirdparty); - unset($object->user); - unset($object->origin); - unset($object->origin_id); - unset($object->ref_ext); - unset($object->statut); - unset($object->country); - unset($object->country_id); - unset($object->country_code); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); - unset($object->mode_reglement_id); - unset($object->cond_reglement_id); - unset($object->cond_reglement); - unset($object->fk_delivery_address); - unset($object->shipping_method_id); - unset($object->fk_account); - unset($object->total_ht); - unset($object->total_tva); - unset($object->total_localtax1); - unset($object->total_localtax2); - unset($object->total_ttc); - unset($object->fk_incoterms); - unset($object->libelle_incoterms); - unset($object->location_incoterms); - unset($object->name); - unset($object->lastname); - unset($object->firstname); - unset($object->civility_id); - unset($object->contact); - unset($object->societe); + unset($object->usermod); + unset($object->libelle); + unset($object->context); + unset($object->canvas); + unset($object->contact); + unset($object->contact_id); + unset($object->thirdparty); + unset($object->user); + unset($object->origin); + unset($object->origin_id); + unset($object->ref_ext); + unset($object->statut); + unset($object->country); + unset($object->country_id); + unset($object->country_code); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); + unset($object->mode_reglement_id); + unset($object->cond_reglement_id); + unset($object->cond_reglement); + unset($object->fk_delivery_address); + unset($object->shipping_method_id); + unset($object->fk_account); + unset($object->total_ht); + unset($object->total_tva); + unset($object->total_localtax1); + unset($object->total_localtax2); + unset($object->total_ttc); + unset($object->fk_incoterms); + unset($object->libelle_incoterms); + unset($object->location_incoterms); + unset($object->name); + unset($object->lastname); + unset($object->firstname); + unset($object->civility_id); + unset($object->contact); + unset($object->societe); - return $object; + return $object; } } diff --git a/htdocs/comm/action/class/cactioncomm.class.php b/htdocs/comm/action/class/cactioncomm.class.php index f69030e806c..eb7fb885d8d 100644 --- a/htdocs/comm/action/class/cactioncomm.class.php +++ b/htdocs/comm/action/class/cactioncomm.class.php @@ -68,7 +68,7 @@ class CActionComm * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -76,10 +76,10 @@ class CActionComm /** * Load action type from database * - * @param int $id id or code of action type to read - * @return int 1=ok, 0=not found, -1=error + * @param int $id id or code of action type to read + * @return int 1=ok, 0=not found, -1=error */ - function fetch($id) + public function fetch($id) { $sql = "SELECT id, code, type, libelle as label, color, active, picto"; $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm"; @@ -118,19 +118,19 @@ class CActionComm } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of event types: array(id=>label) or array(code=>label) * - * @param string|int $active 1 or 0 to filter on event state active or not ('' by default = no filter) - * @param string $idorcode 'id' or 'code' - * @param string $excludetype Type to exclude ('system' or 'systemauto') - * @param int $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual" + * @param string|int $active 1 or 0 to filter on event state active or not ('' by default = no filter) + * @param string $idorcode 'id' or 'code' + * @param string $excludetype Type to exclude ('system' or 'systemauto') + * @param int $onlyautoornot 1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual" * @param string $morefilter Add more SQL filter - * @param int $shortlabel 1=Get short label instead of long label - * @return mixed Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode. + * @param int $shortlabel 1=Get short label instead of long label + * @return mixed Array of all event types if OK, <0 if KO. Key of array is id or code depending on parameter $idorcode. */ - function liste_array($active = '', $idorcode = 'id', $excludetype = '', $onlyautoornot = 0, $morefilter = '', $shortlabel = 0) + public function liste_array($active = '', $idorcode = 'id', $excludetype = '', $onlyautoornot = 0, $morefilter = '', $shortlabel = 0) { // phpcs:enable global $langs,$conf; @@ -176,7 +176,7 @@ class CActionComm if ($qualified) { - $keyfortrans=''; + $keyfortrans=''; $transcode=''; $code=$obj->code; if ($onlyautoornot > 0 && $code == 'AC_OTH') $code='AC_MANUAL'; @@ -223,7 +223,7 @@ class CActionComm * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only * @return string Label of action type */ - function getNomUrl($withpicto = 0) + public function getNomUrl($withpicto = 0) { global $langs; diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 00efd44a1a7..41fe3c42e90 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -32,12 +32,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/xcal.lib.php'; */ class ICal { - var $file_text; // Text in file - var $cal; // Array to save iCalendar parse data - var $event_count; // Number of Events - var $todo_count; // Number of Todos - var $freebusy_count; // Number of Freebusy - var $last_key; //Help variable save last key (multiline string) + // Text in file + public $file_text; + public $cal; // Array to save iCalendar parse data + public $event_count; // Number of Events + public $todo_count; // Number of Todos + public $freebusy_count; // Number of Freebusy + public $last_key; //Help variable save last key (multiline string) /** @@ -47,14 +48,14 @@ class ICal { } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Read text file, icalender text file + * Read text file, icalender text file * - * @param string $file File - * @return string + * @param string $file File + * @return string */ - function read_file($file) + public function read_file($file) { // phpcs:enable $this->file = $file; @@ -63,31 +64,31 @@ class ICal $tmparray=file($file); if (is_array($tmparray)) { - $file_text = join("", $tmparray); //load file - $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); + $file_text = join("", $tmparray); //load file + $file_text = preg_replace("/[\r\n]{1,} /", "", $file_text); } return $file_text; // return all text } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the number of calendar events * * @return int */ - function get_event_count() + public function get_event_count() { // phpcs:enable return $this->event_count; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the number of to do * * @return int */ - function get_todo_count() + public function get_todo_count() { // phpcs:enable return $this->todo_count; @@ -99,7 +100,7 @@ class ICal * @param string $uri Url * @return array|string */ - function parse($uri) + public function parse($uri) { $this->cal = array(); // new empty array @@ -122,7 +123,7 @@ class ICal { // get Key and Value VCALENDAR:Begin -> Key = VCALENDAR, Value = begin list($key, $value) = $this->retun_key_value($text); - //var_dump($text.' -> '.$key.' - '.$value); + //var_dump($text.' -> '.$key.' - '.$value); switch ($text) // search special string { @@ -201,7 +202,7 @@ class ICal return $this->cal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add to $this->ical array one value and key. * @@ -210,7 +211,7 @@ class ICal * @param string $value Value * @return void */ - function add_to_array($type, $key, $value) + public function add_to_array($type, $key, $value) { // phpcs:enable @@ -263,14 +264,14 @@ class ICal $this->last_key = $key; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Parse text "XXXX:value text some with : " and return array($key = "XXXX", $value="value"); * * @param string $text Text * @return array */ - function retun_key_value($text) + public function retun_key_value($text) { // phpcs:enable /* @@ -288,14 +289,14 @@ class ICal return explode(':', $text, 2); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Parse RRULE return array * * @param string $value string * @return array */ - function ical_rrule($value) + public function ical_rrule($value) { // phpcs:enable $result = array(); @@ -308,14 +309,14 @@ class ICal return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return Unix time from ical date time fomrat (YYYYMMDD[T]HHMMSS[Z] or YYYYMMDD[T]HHMMSS) * * @param string $ical_date String date * @return int */ - function ical_date_to_unix($ical_date) + public function ical_date_to_unix($ical_date) { // phpcs:enable $ical_date = str_replace('T', '', $ical_date); @@ -331,7 +332,7 @@ class ICal return $ntime; // ntime is a GTM time } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return unix date from iCal date format * @@ -339,7 +340,7 @@ class ICal * @param string $value Value * @return array */ - function ical_dt_date($key, $value) + public function ical_dt_date($key, $value) { // phpcs:enable $return_value = array(); @@ -362,13 +363,13 @@ class ICal return array($key,$return_value); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return sorted eventlist as array or false if calendar is empty * * @return array|false */ - function get_sort_event_list() + public function get_sort_event_list() { // phpcs:enable $temp = $this->get_event_list(); @@ -383,7 +384,7 @@ class ICal } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Compare two unix timestamp * @@ -391,67 +392,67 @@ class ICal * @param array $b Operand b * @return integer */ - function ical_dtstart_compare($a, $b) + public function ical_dtstart_compare($a, $b) { // phpcs:enable return strnatcasecmp($a['DTSTART']['unixtime'], $b['DTSTART']['unixtime']); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return eventlist array (not sorted eventlist array) * * @return array */ - function get_event_list() + public function get_event_list() { // phpcs:enable return (! empty($this->cal['VEVENT'])?$this->cal['VEVENT']:''); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return eventlist array (not sort eventlist array) * * @return array */ - function get_freebusy_list() + public function get_freebusy_list() { // phpcs:enable return $this->cal['VFREEBUSY']; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return to do array (not sorted todo array) * * @return array */ - function get_todo_list() + public function get_todo_list() { // phpcs:enable return $this->cal['VTODO']; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return base calendar data * * @return array */ - function get_calender_data() + public function get_calender_data() { // phpcs:enable return $this->cal['VCALENDAR']; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array with all data * * @return array */ - function get_all_data() + public function get_all_data() { // phpcs:enable return $this->cal; diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 567f968e3d2..b450f5a0872 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -58,20 +58,20 @@ class AdvanceTargetingMailing extends CommonObject */ public $id; - var $name; - var $entity; - var $fk_element; - var $type_element; - var $filtervalue; - var $fk_user_author; - var $datec=''; - var $fk_user_mod; - var $tms=''; + public $name; + public $entity; + public $fk_element; + public $type_element; + public $filtervalue; + public $fk_user_author; + public $datec=''; + public $fk_user_mod; + public $tms=''; - var $select_target_type = array(); - var $type_statuscommprospect=array(); - var $thirdparty_lines; - var $contact_lines; + public $select_target_type = array(); + public $type_statuscommprospect=array(); + public $thirdparty_lines; + public $contact_lines; /** @@ -79,7 +79,7 @@ class AdvanceTargetingMailing extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs; $langs->load('customers'); @@ -108,7 +108,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -202,7 +202,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -253,14 +253,14 @@ class AdvanceTargetingMailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch_by_mailing($id = 0) + public function fetch_by_mailing($id = 0) { // phpcs:enable global $langs; @@ -319,7 +319,7 @@ class AdvanceTargetingMailing extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * @@ -327,7 +327,7 @@ class AdvanceTargetingMailing extends CommonObject * @param string $type_element Type target * @return int <0 if KO, >0 if OK */ - function fetch_by_element($id = 0, $type_element = 'mailing') + public function fetch_by_element($id = 0, $type_element = 'mailing') { // phpcs:enable global $langs; @@ -390,7 +390,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -469,7 +469,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -528,7 +528,7 @@ class AdvanceTargetingMailing extends CommonObject * @param array $arrayquery All element to Query * @return int <0 if KO, >0 if OK */ - function savequery($user, $arrayquery) + public function savequery($user, $arrayquery) { global $langs,$conf; @@ -548,14 +548,14 @@ class AdvanceTargetingMailing extends CommonObject - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from database * * @param array $arrayquery All element to Query * @return int <0 if KO, >0 if OK */ - function query_thirdparty($arrayquery) + public function query_thirdparty($arrayquery) { // phpcs:enable global $langs,$conf; @@ -699,7 +699,7 @@ class AdvanceTargetingMailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from database * @@ -707,7 +707,7 @@ class AdvanceTargetingMailing extends CommonObject * @param int $withThirdpartyFilter add contact with tridparty filter * @return int <0 if KO, >0 if OK */ - function query_contact($arrayquery, $withThirdpartyFilter = 0) + public function query_contact($arrayquery, $withThirdpartyFilter = 0) { // phpcs:enable global $langs,$conf; diff --git a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php index 66303647dbc..9048d5a46e2 100644 --- a/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php +++ b/htdocs/comm/mailing/class/html.formadvtargetemailing.class.php @@ -42,7 +42,7 @@ class FormAdvTargetEmailing extends Form * * @param DoliDB $db handler */ - function __construct($db) + public function __construct($db) { global $langs; @@ -56,7 +56,7 @@ class FormAdvTargetEmailing extends Form * @param string $htmlname select field * @return string select field */ - function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') + public function multiselectProspectionStatus($selected_array = array(), $htmlname = 'cust_prospect_status') { global $conf, $langs; $options_array = array(); @@ -93,7 +93,7 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array or Code or Label of preselected country * @return string HTML string with select */ - function multiselectCountry($htmlname = 'country_id', $selected_array = array()) + public function multiselectCountry($htmlname = 'country_id', $selected_array = array()) { global $conf, $langs; @@ -154,7 +154,7 @@ class FormAdvTargetEmailing extends Form * @param User $user User action * @return string combo list code */ - function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) + public function multiselectselectSalesRepresentatives($htmlname, $selected_array, $user) { global $conf; @@ -195,7 +195,7 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array selected array * @return string combo list code */ - function multiselectselectLanguage($htmlname = '', $selected_array = array()) + public function multiselectselectLanguage($htmlname = '', $selected_array = array()) { global $conf,$langs; @@ -222,7 +222,7 @@ class FormAdvTargetEmailing extends Form * * @return string HTML combo */ - function advMultiselectarraySelllist($htmlname, $sqlqueryparam = array(), $selected_array = array()) + public function advMultiselectarraySelllist($htmlname, $sqlqueryparam = array(), $selected_array = array()) { $options_array=array(); @@ -291,7 +291,7 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array Array * @return string HTML combo */ - function multiselectCivility($htmlname = 'civilite_id', $selected_array = array()) + public function multiselectCivility($htmlname = 'civilite_id', $selected_array = array()) { global $conf,$langs,$user; $langs->load("dict"); @@ -341,7 +341,7 @@ class FormAdvTargetEmailing extends Form * @param int $showempty show empty * @return string HTML combo */ - function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) + public function advMultiselectarray($htmlname, $options_array = array(), $selected_array = array(), $showempty = 0) { global $conf, $langs; @@ -357,7 +357,7 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array value selected * @return string HTML combo */ - function multiselectCustomerCategories($htmlname = 'cust_cat', $selected_array = array()) + public function multiselectCustomerCategories($htmlname = 'cust_cat', $selected_array = array()) { return $this->multiselectCategories($htmlname, $selected_array, 2); } @@ -369,7 +369,7 @@ class FormAdvTargetEmailing extends Form * @param array $selected_array value selected * @return string HTML combo */ - function multiselectContactCategories($htmlname = 'contact_cat', $selected_array = array()) + public function multiselectContactCategories($htmlname = 'contact_cat', $selected_array = array()) { return $this->multiselectCategories($htmlname, $selected_array, 4); } diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index 580a36425c8..c94c516d27d 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -80,9 +80,9 @@ class Mailing extends CommonObject * Constructor * * @param DoliDb $db Database handler - */ - function __construct($db) - { + */ + public function __construct($db) + { $this->db = $db; // List of language codes for status @@ -96,7 +96,7 @@ class Mailing extends CommonObject $this->statut_dest[1] = 'MailingStatusSent'; $this->statut_dest[2] = 'MailingStatusRead'; $this->statut_dest[3] = 'MailingStatusReadAndUnsubscribe'; // Read but ask to not be contacted anymore - } + } /** * Create an EMailing @@ -104,7 +104,7 @@ class Mailing extends CommonObject * @param User $user Object of user making creation * @return int -1 if error, Id of created object if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -163,7 +163,7 @@ class Mailing extends CommonObject * @param User $user Object of user making change * @return int < 0 if KO, > 0 if OK */ - function update($user) + public function update($user) { $sql = "UPDATE ".MAIN_DB_PREFIX."mailing "; $sql .= " SET titre = '".$this->db->escape($this->titre)."'"; @@ -195,7 +195,7 @@ class Mailing extends CommonObject * @param int $rowid Id of emailing * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { global $conf; @@ -218,34 +218,34 @@ class Mailing extends CommonObject { $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->statut = $obj->statut; - $this->nbemail = $obj->nbemail; - $this->titre = $obj->titre; + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->statut = $obj->statut; + $this->nbemail = $obj->nbemail; + $this->titre = $obj->titre; - $this->sujet = $obj->sujet; + $this->sujet = $obj->sujet; if (!empty($conf->global->FCKEDITOR_ENABLE_MAILING) && dol_textishtml(dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401))) { - $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401); + $this->body = dol_html_entity_decode($obj->body, ENT_COMPAT | ENT_HTML401); }else { - $this->body = $obj->body; + $this->body = $obj->body; } - $this->bgcolor = $obj->bgcolor; - $this->bgimage = $obj->bgimage; + $this->bgcolor = $obj->bgcolor; + $this->bgimage = $obj->bgimage; - $this->email_from = $obj->email_from; - $this->email_replyto = $obj->email_replyto; - $this->email_errorsto = $obj->email_errorsto; + $this->email_from = $obj->email_from; + $this->email_replyto = $obj->email_replyto; + $this->email_errorsto = $obj->email_errorsto; - $this->user_creat = $obj->fk_user_creat; - $this->user_valid = $obj->fk_user_valid; + $this->user_creat = $obj->fk_user_creat; + $this->user_valid = $obj->fk_user_valid; - $this->date_creat = $this->db->jdate($obj->date_creat); - $this->date_valid = $this->db->jdate($obj->date_valid); - $this->date_envoi = $this->db->jdate($obj->date_envoi); + $this->date_creat = $this->db->jdate($obj->date_creat); + $this->date_valid = $this->db->jdate($obj->date_valid); + $this->date_envoi = $this->db->jdate($obj->date_envoi); - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); return 1; } @@ -271,7 +271,7 @@ class Mailing extends CommonObject * @param int $option2 Not used * @return int New id of clone */ - function createFromClone($fromid, $option1, $option2) + public function createFromClone($fromid, $option1, $option2) { global $user,$langs; @@ -394,7 +394,7 @@ class Mailing extends CommonObject * @param User $user Objet user qui valide * @return int <0 if KO, >0 if OK */ - function valid($user) + public function valid($user) { $now=dol_now(); @@ -421,7 +421,7 @@ class Mailing extends CommonObject * @param int $rowid id du mailing a supprimer * @return int 1 en cas de succes */ - function delete($rowid) + public function delete($rowid) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing"; $sql.= " WHERE rowid = ".$rowid; @@ -439,13 +439,13 @@ class Mailing extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete targets emailing * * @return int 1 if OK, 0 if error */ - function delete_targets() + public function delete_targets() { // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; @@ -465,14 +465,14 @@ class Mailing extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Change status of each recipient * * @param User $user Objet user qui valide * @return int <0 if KO, >0 if OK */ - function reset_targets_status($user) + public function reset_targets_status($user) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; @@ -499,7 +499,7 @@ class Mailing extends CommonObject * @param string $mode Mode ('alreadysent' = Sent success or error, 'alreadysentok' = Sent success, 'alreadysentko' = Sent error) * @return int Nb of target with status */ - function countNbOfTargets($mode) + public function countNbOfTargets($mode) { $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."mailing_cibles"; $sql.= " WHERE fk_mailing = ".$this->id; @@ -537,7 +537,7 @@ class Mailing extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -608,12 +608,12 @@ class Mailing extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -621,7 +621,7 @@ class Mailing extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -634,30 +634,30 @@ class Mailing extends CommonObject elseif ($mode == 2) { if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); } elseif ($mode == 3) { if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - if ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); + elseif ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1'); + elseif ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3'); + elseif ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); } elseif ($mode == 4) { if ($statut == 0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); - if ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 1) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 2) return img_picto($langs->trans($this->statuts[$statut]), 'statut3').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut == 3) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); } elseif ($mode == 5) { if ($statut == 0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - if ($statut == 1) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - if ($statut == 2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); - if ($statut == 3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); + elseif ($statut == 1) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut1'); + elseif ($statut == 2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut3'); + elseif ($statut == 3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); } } @@ -687,37 +687,37 @@ class Mailing extends CommonObject elseif ($mode == 2) { if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); + elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); + elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); } elseif ($mode == 3) { if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); + elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); + elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); } elseif ($mode == 4) { if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); + elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); + elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); } elseif ($mode == 5) { if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); + elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); + elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); } elseif ($mode == 6) { if ($statut==-1) return $langs->trans("MailingStatusError").' '.img_error($desc); - if ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); - if ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); - if ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); + elseif ($statut==1) return $langs->trans("MailingStatusSent").' '.img_picto($langs->trans("MailingStatusSent"), 'statut6'); + elseif ($statut==2) return $langs->trans("MailingStatusRead").' '.img_picto($langs->trans("MailingStatusRead"), 'statut4'); + elseif ($statut==3) return $langs->trans("MailingStatusNotContact").' '.img_picto($langs->trans("MailingStatusNotContact"), 'statut3'); } } } diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index c72c54294ae..33122986187 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -29,8 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; */ class Proposals extends DolibarrApi { - - /** + /** * @var array $FIELDS Mandatory fields, checked when create and update object */ static $FIELDS = array( @@ -45,7 +44,7 @@ class Proposals extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -63,7 +62,7 @@ class Proposals extends DolibarrApi * * @throws RestException */ - function get($id, $contact_list = 1) + public function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); @@ -97,7 +96,7 @@ class Proposals extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" * @return array Array of order objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -182,8 +181,8 @@ class Proposals extends DolibarrApi * @param array $request_data Request data * @return int ID of proposal */ - function post($request_data = null) - { + public function post($request_data = null) + { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401, "Insuffisant rights"); } @@ -205,7 +204,7 @@ class Proposals extends DolibarrApi } return $this->propal->id; - } + } /** * Get lines of a commercial proposal @@ -216,7 +215,7 @@ class Proposals extends DolibarrApi * * @return int */ - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); @@ -248,9 +247,9 @@ class Proposals extends DolibarrApi * * @return int */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } @@ -259,12 +258,11 @@ class Proposals extends DolibarrApi throw new RestException(404, 'Commercial Proposal not found'); } - if (! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) - { + if (! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object) $request_data; + $request_data = (object) $request_data; $updateRes = $this->propal->addline( $request_data->desc, @@ -313,7 +311,7 @@ class Proposals extends DolibarrApi * * @return object */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -336,30 +334,30 @@ class Proposals extends DolibarrApi throw new RestException(404, 'Proposal line not found'); } - $updateRes = $this->propal->updateline( - $lineid, - isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, - isset($request_data->qty)?$request_data->qty:$propalline->qty, - isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, - isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, - isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, - isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, - isset($request_data->desc)?$request_data->desc:$propalline->desc, - 'HT', - isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, - isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, - isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, - 0, - isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, - isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, - isset($request_data->label)?$request_data->label:$propalline->label, - isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, - isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, - isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, - isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, - isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, - isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice - ); + $updateRes = $this->propal->updateline( + $lineid, + isset($request_data->subprice)?$request_data->subprice:$propalline->subprice, + isset($request_data->qty)?$request_data->qty:$propalline->qty, + isset($request_data->remise_percent)?$request_data->remise_percent:$propalline->remise_percent, + isset($request_data->tva_tx)?$request_data->tva_tx:$propalline->tva_tx, + isset($request_data->localtax1_tx)?$request_data->localtax1_tx:$propalline->localtax1_tx, + isset($request_data->localtax2_tx)?$request_data->localtax2_tx:$propalline->localtax2_tx, + isset($request_data->desc)?$request_data->desc:$propalline->desc, + 'HT', + isset($request_data->info_bits)?$request_data->info_bits:$propalline->info_bits, + isset($request_data->special_code)?$request_data->special_code:$propalline->special_code, + isset($request_data->fk_parent_line)?$request_data->fk_parent_line:$propalline->fk_parent_line, + 0, + isset($request_data->fk_fournprice)?$request_data->fk_fournprice:$propalline->fk_fournprice, + isset($request_data->pa_ht)?$request_data->pa_ht:$propalline->pa_ht, + isset($request_data->label)?$request_data->label:$propalline->label, + isset($request_data->product_type)?$request_data->product_type:$propalline->product_type, + isset($request_data->date_start)?$request_data->date_start:$propalline->date_start, + isset($request_data->date_end)?$request_data->date_end:$propalline->date_end, + isset($request_data->array_options)?$request_data->array_options:$propalline->array_options, + isset($request_data->fk_unit)?$request_data->fk_unit:$propalline->fk_unit, + isset($request_data->multicurrency_subprice)?$request_data->multicurrency_subprice:$propalline->subprice + ); if ($updateRes > 0) { $result = $this->get($id); @@ -382,7 +380,7 @@ class Proposals extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -422,7 +420,7 @@ class Proposals extends DolibarrApi * @throws 401 * @throws 404 */ - function postContact($id, $contactid, $type) + public function postContact($id, $contactid, $type) { if(!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -464,7 +462,7 @@ class Proposals extends DolibarrApi * @throws 404 * @throws 500 */ - function deleteContact($id, $rowid) + public function deleteContact($id, $rowid) { if(!DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -497,21 +495,21 @@ class Proposals extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->propal->creer) { + if (! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } $result = $this->propal->fetch($id); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'Proposal not found'); } - if( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + if ( ! DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->propal->$field = $value; } @@ -546,7 +544,7 @@ class Proposals extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->propal->supprimer) { throw new RestException(401); @@ -581,7 +579,7 @@ class Proposals extends DolibarrApi * * @return array */ - function settodraft($id) + public function settodraft($id) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -637,9 +635,9 @@ class Proposals extends DolibarrApi * @throws 500 * * @return array - */ - function validate($id, $notrigger = 0) - { + */ + public function validate($id, $notrigger = 0) + { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); } @@ -672,7 +670,7 @@ class Proposals extends DolibarrApi $this->propal->fetchObjectLinked(); return $this->_cleanObjectDatas($this->propal); - } + } /** * Close (Accept or refuse) a quote / commercial proposal @@ -686,7 +684,7 @@ class Proposals extends DolibarrApi * * @return array */ - function close($id, $status, $note_private = '', $notrigger = 0) + public function close($id, $status, $note_private = '', $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -731,7 +729,7 @@ class Proposals extends DolibarrApi * * @return array */ - function setinvoiced($id) + public function setinvoiced($id) { if (! DolibarrApiAccess::$user->rights->propal->creer) { throw new RestException(401); @@ -772,7 +770,7 @@ class Proposals extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $propal = array(); foreach (Proposals::$FIELDS as $field) { @@ -790,7 +788,7 @@ class Proposals extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 37f6b2bd3f5..304eccf9bb7 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -239,7 +239,7 @@ class Propal extends CommonObject * @param int $socid Id third party * @param int $propalid Id proposal */ - function __construct($db, $socid = "", $propalid = 0) + public function __construct($db, $socid = "", $propalid = 0) { global $conf,$langs; @@ -254,7 +254,7 @@ class Propal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add line into array products * $this->thirdparty should be loaded @@ -267,7 +267,7 @@ class Propal extends CommonObject * TODO Replace calls to this function by generation objet Ligne * inserted into table $this->products */ - function add_product($idproduct, $qty, $remise_percent = 0) + public function add_product($idproduct, $qty, $remise_percent = 0) { // phpcs:enable global $conf, $mysoc; @@ -316,14 +316,14 @@ class Propal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adding line of fixed discount in the proposal in DB * * @param int $idremise Id of fixed discount * @return int >0 if OK, <0 if KO */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -434,7 +434,7 @@ class Propal extends CommonObject * @return int >0 if OK, <0 if KO * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $fk_remise_except = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $fk_product = 0, $remise_percent = 0.0, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0, $fk_remise_except = 0) { global $mysoc, $conf, $langs; @@ -663,11 +663,11 @@ class Propal extends CommonObject * @param int $notrigger disable line update trigger * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { global $mysoc; -dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, + dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise_percent=$remise_percent, txtva=$txtva, desc=$desc, price_base_type=$price_base_type, info_bits=$info_bits, special_code=$special_code, fk_parent_line=$fk_parent_line, pa_ht=$pa_ht, type=$type, date_start=$date_start, date_end=$date_end"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -827,7 +827,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - function deleteline($lineid) + public function deleteline($lineid) { global $user; @@ -869,7 +869,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$hookmanager; $error=0; @@ -1193,7 +1193,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert into DB a proposal object completely defined by its data members (ex, results from copy). * @@ -1201,7 +1201,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @return int Id of the new object if ok, <0 if ko * @see create */ - function create_from($user) + public function create_from($user) { // phpcs:enable // i love this function because $this->products is not used in create function... @@ -1216,7 +1216,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$conf,$hookmanager; @@ -1345,7 +1345,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param string $ref Ref of proposal * @return int >0 if OK, <0 if KO */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { $sql = "SELECT p.rowid, p.ref, p.entity, p.remise, p.remise_percent, p.remise_absolue, p.fk_soc"; @@ -1509,7 +1509,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf; @@ -1597,14 +1597,14 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines * * @param int $only_product Return only physical products * @return int <0 if KO, >0 if OK */ - function fetch_lines($only_product = 0) + public function fetch_lines($only_product = 0) { // phpcs:enable $this->lines=array(); @@ -1723,7 +1723,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @return int <0 if KO, 0=Nothing done, >=0 if OK */ - function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1838,7 +1838,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define proposal date * @@ -1847,7 +1847,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_date($user, $date, $notrigger = 0) + public function set_date($user, $date, $notrigger = 0) { // phpcs:enable if (empty($date)) @@ -1907,7 +1907,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define end validity date * @@ -1916,7 +1916,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_echeance($user, $date_fin_validite, $notrigger = 0) + public function set_echeance($user, $date_fin_validite, $notrigger = 0) { // phpcs:enable if (! empty($user->rights->propal->creer)) @@ -1969,7 +1969,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set delivery date * @@ -1978,7 +1978,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function set_date_livraison($user, $date_livraison, $notrigger = 0) + public function set_date_livraison($user, $date_livraison, $notrigger = 0) { // phpcs:enable if (! empty($user->rights->propal->creer)) @@ -2031,7 +2031,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set delivery * @@ -2040,7 +2040,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_availability($user, $id, $notrigger = 0) + public function set_availability($user, $id, $notrigger = 0) { // phpcs:enable if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT) @@ -2102,7 +2102,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set source of demand * @@ -2111,7 +2111,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_demand_reason($user, $id, $notrigger = 0) + public function set_demand_reason($user, $id, $notrigger = 0) { // phpcs:enable if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT) @@ -2175,7 +2175,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set customer reference number * @@ -2184,7 +2184,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function set_ref_client($user, $ref_client, $notrigger = 0) + public function set_ref_client($user, $ref_client, $notrigger = 0) { // phpcs:enable if (! empty($user->rights->propal->creer)) @@ -2240,7 +2240,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an overall discount on the proposal * @@ -2249,7 +2249,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function set_remise_percent($user, $remise, $notrigger = 0) + public function set_remise_percent($user, $remise, $notrigger = 0) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -2307,7 +2307,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an absolute overall discount on the proposal * @@ -2316,7 +2316,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function set_remise_absolue($user, $remise, $notrigger = 0) + public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -2385,7 +2385,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function reopen($user, $statut, $note = '', $notrigger = 0) + public function reopen($user, $statut, $note = '', $notrigger = 0) { $this->statut = $statut; @@ -2446,7 +2446,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function cloture($user, $statut, $note = "", $notrigger = 0) + public function cloture($user, $statut, $note = "", $notrigger = 0) { global $langs,$conf; @@ -2549,7 +2549,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - function classifyBilled(User $user, $notrigger = 0) + public function classifyBilled(User $user, $notrigger = 0) { $error=0; @@ -2597,7 +2597,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -2605,7 +2605,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_draft($user, $notrigger = 0) + public function set_draft($user, $notrigger = 0) { // phpcs:enable $error=0; @@ -2656,7 +2656,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of proposal (eventually filtered on user) into an array * @@ -2670,7 +2670,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datep', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datep', $sortorder = 'DESC') { // phpcs:enable global $user; @@ -2739,19 +2739,19 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * * @return array Array of invoices */ - function getInvoiceArrayList() + public function getInvoiceArrayList() { return $this->InvoiceArrayList($this->id); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array with id and ref of related invoices * * @param int $id Id propal * @return array Array of invoices id */ - function InvoiceArrayList($id) + public function InvoiceArrayList($id) { // phpcs:enable $ga = array(); @@ -2838,7 +2838,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int 1 if ok, otherwise if error */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2962,7 +2962,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @return int >0 if OK, <0 if KO * @deprecated use set_availability */ - function availability($availability_id, $notrigger = 0) + public function availability($availability_id, $notrigger = 0) { global $user; @@ -3024,7 +3024,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Change source demand * @@ -3033,7 +3033,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @return int >0 si ok, <0 si ko * @deprecated use set_demand_reason */ - function demand_reason($demand_reason_id, $notrigger = 0) + public function demand_reason($demand_reason_id, $notrigger = 0) { // phpcs:enable global $user; @@ -3103,7 +3103,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $id Proposal id * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, "; $sql.= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; @@ -3158,12 +3158,12 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status (draft, validated, ...) * @@ -3171,7 +3171,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - function LibStatut($statut, $mode = 1) + public function LibStatut($statut, $mode = 1) { // phpcs:enable global $conf; @@ -3210,7 +3210,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -3218,7 +3218,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $mode "opened" for proposal to close, "signed" for proposal to invoice * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user, $mode) + public function load_board($user, $mode) { // phpcs:enable global $conf, $langs; @@ -3300,7 +3300,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $langs; @@ -3386,13 +3386,13 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 if ko, >0 if ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -3438,7 +3438,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param Societe $soc Object thirdparty * @return string Reference libre pour la propale */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf,$langs; $langs->load("propal"); @@ -3500,7 +3500,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1) { global $langs, $conf, $user; @@ -3574,7 +3574,7 @@ dol_syslog(get_class($this)."::updateLine rowid=$rowid, pu=$pu, qty=$qty, remise * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -3754,7 +3754,7 @@ class PropaleLigne extends CommonObjectLine * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db= $db; } @@ -3765,7 +3765,7 @@ class PropaleLigne extends CommonObjectLine * @param int $rowid Propal line id * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.vat_src_code, pd.tva_tx,'; $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; @@ -3859,7 +3859,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0) + public function insert($notrigger = 0) { global $conf,$user; @@ -4002,7 +4002,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function delete(User $user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { global $conf; @@ -4056,7 +4056,7 @@ class PropaleLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function update($notrigger = 0) + public function update($notrigger = 0) { global $conf,$user; @@ -4178,14 +4178,14 @@ class PropaleLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); diff --git a/htdocs/comm/propal/class/propalestats.class.php b/htdocs/comm/propal/class/propalestats.class.php index 6fd9d36f54b..808411100f9 100644 --- a/htdocs/comm/propal/class/propalestats.class.php +++ b/htdocs/comm/propal/class/propalestats.class.php @@ -40,12 +40,12 @@ class PropaleStats extends Stats */ public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -56,7 +56,7 @@ class PropaleStats extends Stats * @param int $userid Id user for filter (creation user) * @param string $mode Option ('customer', 'supplier') */ - function __construct($db, $socid = 0, $userid = 0, $mode = 'customer') + public function __construct($db, $socid = 0, $userid = 0, $mode = 'customer') { global $user, $conf; @@ -106,7 +106,7 @@ class PropaleStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -128,7 +128,7 @@ class PropaleStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -149,7 +149,7 @@ class PropaleStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with amount by month */ - function getAmountByMonth($year, $format) + public function getAmountByMonth($year, $format) { global $user; @@ -171,7 +171,7 @@ class PropaleStats extends Stats * @param int $year year for stats * @return array array with number by month */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; @@ -191,7 +191,7 @@ class PropaleStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { global $user; @@ -213,7 +213,7 @@ class PropaleStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAllByProduct($year) + public function getAllByProduct($year) { global $user; diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 95fe3f55d0d..2bd942a3c34 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -44,10 +44,10 @@ class Orders extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->commande = new Commande($this->db); } @@ -62,7 +62,7 @@ class Orders extends DolibarrApi * * @throws RestException */ - function get($id, $contact_list = 1) + public function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); @@ -100,7 +100,7 @@ class Orders extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -185,11 +185,11 @@ class Orders extends DolibarrApi * @param array $request_data Request data * @return int ID of order */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401, "Insuffisant rights"); - } + } // Check mandatory fields $result = $this->_validate($request_data); @@ -220,7 +220,7 @@ class Orders extends DolibarrApi * * @return int */ - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); @@ -252,7 +252,7 @@ class Orders extends DolibarrApi * * @return int */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -299,7 +299,7 @@ class Orders extends DolibarrApi if ($updateRes > 0) { return $updateRes; } else { - throw new RestException(400, $this->commande->error); + throw new RestException(400, $this->commande->error); } } @@ -314,7 +314,7 @@ class Orders extends DolibarrApi * * @return object */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -375,7 +375,7 @@ class Orders extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -399,7 +399,7 @@ class Orders extends DolibarrApi throw new RestException(405, $this->commande->error); } } - + /** * Add a contact type of given order * @@ -413,7 +413,7 @@ class Orders extends DolibarrApi * @throws 401 * @throws 404 */ - function postContact($id, $contactid, $type) + public function postContact($id, $contactid, $type) { if(!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -455,7 +455,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 500 */ - function deleteContact($id, $rowid) + public function deleteContact($id, $rowid) { if(!DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -488,7 +488,7 @@ class Orders extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -529,7 +529,7 @@ class Orders extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->commande->supprimer) { throw new RestException(401); @@ -577,7 +577,7 @@ class Orders extends DolibarrApi * * @return array */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -629,7 +629,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 405 */ - function reopen($id) + public function reopen($id) { if(! DolibarrApiAccess::$user->rights->commande->creer) { @@ -667,7 +667,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 405 */ - function setinvoiced($id) + public function setinvoiced($id) { if(! DolibarrApiAccess::$user->rights->commande->creer) { @@ -710,7 +710,7 @@ class Orders extends DolibarrApi * * @return int */ - function close($id, $notrigger = 0) + public function close($id, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -756,7 +756,7 @@ class Orders extends DolibarrApi * * @return array */ - function settodraft($id, $idwarehouse = -1) + public function settodraft($id, $idwarehouse = -1) { if(! DolibarrApiAccess::$user->rights->commande->creer) { throw new RestException(401); @@ -807,7 +807,7 @@ class Orders extends DolibarrApi * @throws 404 * @throws 405 */ - function createOrderFromProposal($proposalid) + public function createOrderFromProposal($proposalid) { require_once DOL_DOCUMENT_ROOT . '/comm/propal/class/propal.class.php'; @@ -844,7 +844,7 @@ class Orders extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -866,7 +866,7 @@ class Orders extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $commande = array(); foreach (Orders::$FIELDS as $field) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 26151fd8b72..9b55957b0f0 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -203,12 +203,12 @@ class Commande extends CommonOrder public $multicurrency_total_ttc; public $oldcopy; - + //! key of module source when order generated from a dedicated module ('cashdesk', 'takepos', ...) public $module_source; //! key of pos source ('0', '1', ...) public $pos_source; - + /** * ERR Not enough stock */ @@ -243,7 +243,7 @@ class Commande extends CommonOrder * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -260,7 +260,7 @@ class Commande extends CommonOrder * @param Societe $soc Object thirdparty * @return string Order free reference */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $langs, $conf; $langs->load("order"); @@ -318,7 +318,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <=0 if OK, 0=Nothing done, >0 if KO */ - function valid($user, $idwarehouse = 0, $notrigger = 0) + public function valid($user, $idwarehouse = 0, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -471,7 +471,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -479,8 +479,8 @@ class Commande extends CommonOrder * @param int $idwarehouse Warehouse ID to use for stock change (Used only if option STOCK_CALCULATE_ON_VALIDATE_ORDER is on) * @return int <0 if KO, >0 if OK */ - function set_draft($user, $idwarehouse = -1) - { + public function set_draft($user, $idwarehouse = -1) + { //phpcs:enable global $conf,$langs; @@ -551,10 +551,10 @@ class Commande extends CommonOrder $this->db->rollback(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag the order as validated (opened) * Function used when order is reopend after being closed. @@ -562,7 +562,7 @@ class Commande extends CommonOrder * @param User $user Object user that change status * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - function set_reopen($user) + public function set_reopen($user) { // phpcs:enable $error=0; @@ -622,7 +622,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function cloture($user, $notrigger = 0) + public function cloture($user, $notrigger = 0) { global $conf; @@ -682,7 +682,7 @@ class Commande extends CommonOrder * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function cancel($idwarehouse = -1) + public function cancel($idwarehouse = -1) { global $conf,$user,$langs; @@ -763,7 +763,7 @@ class Commande extends CommonOrder * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$langs; $error=0; @@ -892,7 +892,7 @@ class Commande extends CommonOrder $vatrate = $line->tva_tx; if ($line->vat_src_code && ! preg_match('/\(.*\)/', $vatrate)) $vatrate.=' ('.$line->vat_src_code.')'; - $result = $this->addline( + $result = $this->addline( $line->desc, $line->subprice, $line->qty, @@ -1067,7 +1067,7 @@ class Commande extends CommonOrder * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$hookmanager; @@ -1152,7 +1152,7 @@ class Commande extends CommonOrder * @param User $user User making creation * @return int <0 if KO, 0 if nothing done, 1 if OK */ - function createFromProposal($object, User $user) + public function createFromProposal($object, User $user) { global $conf, $hookmanager; @@ -1309,7 +1309,7 @@ class Commande extends CommonOrder * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $info_bits = 0, $fk_remise_except = 0, $price_base_type = 'HT', $pu_ttc = 0, $date_start = '', $date_end = '', $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $fk_unit = null, $origin = '', $origin_id = 0, $pu_ht_devise = 0) { global $mysoc, $conf, $langs, $user; @@ -1523,22 +1523,22 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add line into array * $this->client must be loaded * - * @param int $idproduct Product Id - * @param float $qty Quantity - * @param float $remise_percent Product discount relative - * @param int $date_start Start date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - * @param int $date_end End date of the line - Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) - * @return void + * @param int $idproduct Product Id + * @param float $qty Quantity + * @param float $remise_percent Product discount relative + * @param int $date_start Start date of the line + * @param int $date_end End date of the line + * @return void * * TODO Remplacer les appels a cette fonction par generation objet Ligne * insere dans tableau $this->products */ - function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') + public function add_product($idproduct, $qty, $remise_percent = 0.0, $date_start = '', $date_end = '') { // phpcs:enable global $conf, $mysoc; @@ -1583,7 +1583,6 @@ class Commande extends CommonOrder $line->product_desc=$prod->description; $line->fk_unit=$prod->fk_unit; - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) // Save the start and end date of the line in the object if ($date_start) { $line->date_start = $date_start; } if ($date_end) { $line->date_end = $date_end; } @@ -1623,7 +1622,7 @@ class Commande extends CommonOrder * @param string $ref_int Internal reference of other object * @return int >0 if OK, <0 if KO, 0 if not found */ - function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') { // Check parameters @@ -1719,7 +1718,7 @@ class Commande extends CommonOrder $this->fk_delivery_address = $obj->fk_delivery_address; $this->module_source = $obj->module_source; $this->pos_source = $obj->pos_source; - + //Incoterms $this->fk_incoterms = $obj->fk_incoterms; $this->location_incoterms = $obj->location_incoterms; @@ -1769,14 +1768,14 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adding line of fixed discount in the order in DB * * @param int $idremise Id de la remise fixe * @return int >0 si ok, <0 si ko */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -1848,14 +1847,14 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines * * @param int $only_product Return only physical products * @return int <0 if KO, >0 if OK */ - function fetch_lines($only_product = 0) + public function fetch_lines($only_product = 0) { // phpcs:enable $this->lines=array(); @@ -1971,7 +1970,7 @@ class Commande extends CommonOrder * * @return int <0 if KO, Nbr of product lines if OK */ - function getNbOfProductsLines() + public function getNbOfProductsLines() { $nb=0; foreach($this->lines as $line) @@ -1986,7 +1985,7 @@ class Commande extends CommonOrder * * @return int <0 if KO, Nbr of service lines if OK */ - function getNbOfServicesLines() + public function getNbOfServicesLines() { $nb=0; foreach($this->lines as $line) @@ -1997,11 +1996,11 @@ class Commande extends CommonOrder } /** - * Count numbe rof shipments for this order + * Count number of shipments for this order * * @return int <0 if KO, Nb of shipment found if OK */ - function getNbOfShipments() + public function getNbOfShipments() { $nb = 0; @@ -2037,7 +2036,7 @@ class Commande extends CommonOrder * @param int $filtre_statut Filter on shipment status * @return int <0 if KO, Nb of lines found if OK */ - function loadExpeditions($filtre_statut = -1) + public function loadExpeditions($filtre_statut = -1) { $this->expeditions = array(); @@ -2077,7 +2076,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns a array with expeditions lines number * @@ -2085,7 +2084,7 @@ class Commande extends CommonOrder * * TODO deprecate, move to Shipping class */ - function nb_expedition() + public function nb_expedition() { // phpcs:enable $sql = 'SELECT count(*)'; @@ -2104,7 +2103,7 @@ class Commande extends CommonOrder else dol_print_error($this->db); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a array with the pending stock by product * @@ -2113,7 +2112,7 @@ class Commande extends CommonOrder * * TODO FONCTION NON FINIE A FINIR */ - function stock_array($filtre_statut = self::STATUS_CANCELED) + public function stock_array($filtre_statut = self::STATUS_CANCELED) { // phpcs:enable $this->stocks = array(); @@ -2153,7 +2152,7 @@ class Commande extends CommonOrder * @param int $lineid Id of line to delete * @return int >0 if OK, 0 if nothing to do, <0 if KO */ - function deleteline($user = null, $lineid = 0) + public function deleteline($user = null, $lineid = 0) { if ($this->statut == self::STATUS_DRAFT) { @@ -2222,7 +2221,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Applique une remise relative * @@ -2231,7 +2230,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_remise($user, $remise, $notrigger = 0) + public function set_remise($user, $remise, $notrigger = 0) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -2290,7 +2289,7 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Applique une remise absolue * @@ -2299,7 +2298,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_remise_absolue($user, $remise, $notrigger = 0) + public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -2358,7 +2357,7 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the order date * @@ -2367,7 +2366,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_date($user, $date, $notrigger = 0) + public function set_date($user, $date, $notrigger = 0) { // phpcs:enable if ($user->rights->commande->creer) @@ -2424,7 +2423,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the planned delivery date * @@ -2433,7 +2432,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - function set_date_livraison($user, $date_livraison, $notrigger = 0) + public function set_date_livraison($user, $date_livraison, $notrigger = 0) { // phpcs:enable if ($user->rights->commande->creer) @@ -2490,7 +2489,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of orders (eventuelly filtered on a user) into an array * @@ -2504,7 +2503,7 @@ class Commande extends CommonOrder * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') { // phpcs:enable global $user; @@ -2572,7 +2571,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int >0 if OK, <0 if KO */ - function availability($availability_id, $notrigger = 0) + public function availability($availability_id, $notrigger = 0) { global $user; @@ -2635,7 +2634,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update order demand_reason * @@ -2643,7 +2642,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int >0 if ok, <0 if ko */ - function demand_reason($demand_reason_id, $notrigger = 0) + public function demand_reason($demand_reason_id, $notrigger = 0) { // phpcs:enable global $user; @@ -2707,7 +2706,7 @@ class Commande extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set customer ref * @@ -2716,7 +2715,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_ref_client($user, $ref_client, $notrigger = 0) + public function set_ref_client($user, $ref_client, $notrigger = 0) { // phpcs:enable if ($user->rights->commande->creer) @@ -2779,7 +2778,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function classifyBilled(User $user, $notrigger = 0) + public function classifyBilled(User $user, $notrigger = 0) { $error = 0; @@ -2835,7 +2834,7 @@ class Commande extends CommonOrder * * @return int <0 if ko, >0 if ok */ - function classifyUnBilled() + public function classifyUnBilled() { global $conf, $user, $langs; $error = 0; @@ -2914,7 +2913,7 @@ class Commande extends CommonOrder * @param int $notrigger disable line update trigger * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0.0, $txlocaltax2 = 0.0, $price_base_type = 'HT', $info_bits = 0, $date_start = '', $date_end = '', $type = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { global $conf, $mysoc, $langs, $user; @@ -3104,7 +3103,7 @@ class Commande extends CommonOrder * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf; @@ -3199,7 +3198,7 @@ class Commande extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <=0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -3321,14 +3320,14 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Object user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -3387,7 +3386,7 @@ class Commande extends CommonOrder * * @return string Label */ - function getLabelSource() + public function getLabelSource() { global $langs; @@ -3403,12 +3402,12 @@ class Commande extends CommonOrder * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $this->billed, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of status * @@ -3418,7 +3417,7 @@ class Commande extends CommonOrder * @param int $donotshowbilled Do not show billed status after order status * @return string Label of status */ - function LibStatut($statut, $billed, $mode, $donotshowbilled = 0) + public function LibStatut($statut, $billed, $mode, $donotshowbilled = 0) { // phpcs:enable global $langs, $conf; @@ -3430,72 +3429,72 @@ class Commande extends CommonOrder if ($mode == 0) { if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled'); - if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft'); - if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft'); + elseif ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); } elseif ($mode == 1) { if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort'); - if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort'); - if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort'); + elseif ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return $langs->trans('StatusOrderSentShort').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderDelivered'); } elseif ($mode == 2) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5').' '.$langs->trans('StatusOrderCanceledShort'); - if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraftShort'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'), 'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'), 'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBillShort'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDeliveredShort'); + elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraftShort'); + elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'), 'statut1').' '.$langs->trans('StatusOrderValidatedShort').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSent'), 'statut3').' '.$langs->trans('StatusOrderSentShort').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBillShort'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDeliveredShort'); } elseif ($mode == 3) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3'); - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0'); + elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3'); + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); } elseif ($mode == 4) { if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'), 'statut5').' '.$langs->trans('StatusOrderCanceled'); - if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraft'); - if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext; - if ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3').' '.$langs->trans('StatusOrderSent').$billedtext; - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBill'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDelivered'); + elseif ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'), 'statut0').' '.$langs->trans('StatusOrderDraft'); + elseif ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1').' '.$langs->trans('StatusOrderValidated').$billedtext; + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return img_picto($langs->trans('StatusOrderSentShort').$billedtext, 'statut3').' '.$langs->trans('StatusOrderSent').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'), 'statut4').' '.$langs->trans('StatusOrderToBill'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessedShort').$billedtext, 'statut6').' '.$langs->trans('StatusOrderProcessed').$billedtext; + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderDelivered'), 'statut6').' '.$langs->trans('StatusOrderDelivered'); } elseif ($mode == 5) { if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); + elseif ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSentShort').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDeliveredShort').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); } elseif ($mode == 6) { if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceled').' '.img_picto($langs->trans('StatusOrderCanceled'), 'statut5'); - if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); - if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); - if ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); - if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); - if ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); - if ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); + elseif ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraft').' '.img_picto($langs->trans('StatusOrderDraft'), 'statut0'); + elseif ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidated').$billedtext.' '.img_picto($langs->trans('StatusOrderValidated').$billedtext, 'statut1'); + elseif ($statut==self::STATUS_SHIPMENTONPROCESS) return ''.$langs->trans('StatusOrderSent').$billedtext.' '.img_picto($langs->trans('StatusOrderSent').$billedtext, 'statut3'); + elseif ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBill').' '.img_picto($langs->trans('StatusOrderToBill'), 'statut4'); + elseif ($statut==self::STATUS_CLOSED && ($billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessed').$billedtext.' '.img_picto($langs->trans('StatusOrderProcessed').$billedtext, 'statut6'); + elseif ($statut==self::STATUS_CLOSED && (! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderDelivered').' '.img_picto($langs->trans('StatusOrderDelivered'), 'statut6'); } } @@ -3511,7 +3510,7 @@ class Commande extends CommonOrder * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user; @@ -3588,7 +3587,7 @@ class Commande extends CommonOrder * @param int $id Id of order * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, date_creation as datec, tms as datem,'; $sql.= ' date_valid as datev,'; @@ -3646,7 +3645,7 @@ class Commande extends CommonOrder * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $langs; @@ -3728,13 +3727,13 @@ class Commande extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 si ko, >0 si ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -3776,7 +3775,7 @@ class Commande extends CommonOrder * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -3880,7 +3879,7 @@ class OrderLine extends CommonOrderLine public $table_element='commandedet'; - var $oldline; + public $oldline; /** * Id of parent order @@ -3897,38 +3896,37 @@ class OrderLine extends CommonOrderLine public $commande_id; // From llx_commandedet - var $fk_parent_line; - var $fk_facture; + public $fk_parent_line; + public $fk_facture; /** * @var string Order lines label */ public $label; - var $fk_remise_except; - var $rang = 0; - var $fk_fournprice; + public $fk_remise_except; + public $rang = 0; + public $fk_fournprice; /** * Buy price without taxes * @var float */ - var $pa_ht; - var $marge_tx; - var $marque_tx; + public $pa_ht; + public $marge_tx; + public $marque_tx; /** * @deprecated * @see remise_percent, fk_remise_except */ - var $remise; + public $remise; - // Added by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-dates-in-order-lines.html) // Start and end date of the line - var $date_start; - var $date_end; + public $date_start; + public $date_end; - var $skip_update_total; // Skip update price total for special lines + public $skip_update_total; // Skip update price total for special lines /** @@ -3936,10 +3934,10 @@ class OrderLine extends CommonOrderLine * * @param DoliDB $db handler d'acces base de donnee */ - function __construct($db) - { - $this->db= $db; - } + public function __construct($db) + { + $this->db= $db; + } /** * Load line order @@ -3947,7 +3945,7 @@ class OrderLine extends CommonOrderLine * @param int $rowid Id line order * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_parent_line, cd.fk_product, cd.product_type, cd.label as custom_label, cd.description, cd.price, cd.qty, cd.tva_tx, cd.localtax1_tx, cd.localtax2_tx,'; $sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,'; @@ -4032,7 +4030,7 @@ class OrderLine extends CommonOrderLine * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 si ko, >0 si ok */ - function delete(User $user, $notrigger = 0) + public function delete(User $user, $notrigger = 0) { global $conf, $langs; @@ -4093,7 +4091,7 @@ class OrderLine extends CommonOrderLine * @param int $notrigger 1 = disable triggers * @return int <0 if KO, >0 if OK */ - function insert($user = null, $notrigger = 0) + public function insert($user = null, $notrigger = 0) { global $langs, $conf; @@ -4238,7 +4236,7 @@ class OrderLine extends CommonOrderLine * @param int $notrigger 1 = disable triggers * @return int <0 si ko, >0 si ok */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf,$langs; @@ -4365,14 +4363,14 @@ class OrderLine extends CommonOrderLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); diff --git a/htdocs/commande/class/commandestats.class.php b/htdocs/commande/class/commandestats.class.php index 7c1dd201d23..15f0c628ce7 100644 --- a/htdocs/commande/class/commandestats.class.php +++ b/htdocs/commande/class/commandestats.class.php @@ -34,17 +34,17 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class CommandeStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -55,7 +55,7 @@ class CommandeStats extends Stats * @param string $mode Option ('customer', 'supplier') * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -74,7 +74,7 @@ class CommandeStats extends Stats $this->field_line='total_ht'; $this->where.= " c.fk_statut > 0"; // Not draft and not cancelled } - if ($mode == 'supplier') + elseif ($mode == 'supplier') { $object=new CommandeFournisseur($this->db); $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; @@ -101,7 +101,7 @@ class CommandeStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -123,7 +123,7 @@ class CommandeStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -144,7 +144,7 @@ class CommandeStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with amount by month */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { global $user; @@ -166,7 +166,7 @@ class CommandeStats extends Stats * @param int $year year for stats * @return array array with number by month */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; @@ -186,7 +186,7 @@ class CommandeStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { global $user; @@ -206,7 +206,7 @@ class CommandeStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAllByProduct($year) + public function getAllByProduct($year) { global $user; diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index 1c7a0c977a8..bd0e43b8461 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -235,7 +235,7 @@ class Account extends CommonObject * * @param DoliDB $db Database handler */ - function __construct(DoliDB $db) + public function __construct(DoliDB $db) { global $langs; @@ -290,7 +290,7 @@ class Account extends CommonObject * * @return int 1 if need to be concialiated, < 0 otherwise. */ - function canBeConciliated() + public function canBeConciliated() { global $conf; @@ -301,7 +301,7 @@ class Account extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a link between bank line record and its source * @@ -312,7 +312,7 @@ class Account extends CommonObject * @param string $type Type of link ('payment', 'company', 'member', ...) * @return int <0 if KO, id line if OK */ - function add_url_line($line_id, $url_id, $url, $label, $type) + public function add_url_line($line_id, $url_id, $url, $label, $type) { // phpcs:enable $sql = "INSERT INTO ".MAIN_DB_PREFIX."bank_url ("; @@ -342,7 +342,7 @@ class Account extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * TODO Move this into AccountLine * Return array with links from llx_bank_url @@ -352,7 +352,7 @@ class Account extends CommonObject * @param string $type To search using type * @return array|int Array of links array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> ) or -1 on error */ - function get_url($fk_bank = '', $url_id = '', $type = '') + public function get_url($fk_bank = '', $url_id = '', $type = '') { // phpcs:enable $lines = array(); @@ -417,7 +417,7 @@ class Account extends CommonObject * @param int $datev Date value * @return int Rowid of added entry, <0 if KO */ - function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null) + public function addline($date, $oper, $label, $amount, $num_chq, $categorie, User $user, $emetteur = '', $banque = '', $accountancycode = '', $datev = null) { // Deprecation warning if (is_numeric($oper)) { @@ -525,7 +525,7 @@ class Account extends CommonObject * @param int $notrigger 1=Disable triggers * @return int < 0 if KO, > 0 if OK */ - function create(User $user, $notrigger = 0) + public function create(User $user, $notrigger = 0) { global $langs,$conf, $hookmanager; @@ -690,7 +690,7 @@ class Account extends CommonObject * @param int $notrigger 1=Disable triggers * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $langs,$conf, $hookmanager; @@ -793,14 +793,14 @@ class Account extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update BBAN (RIB) account fields * * @param User $user Object user making update * @return int <0 if KO, >0 if OK */ - function update_bban(User $user = null) + public function update_bban(User $user = null) { // phpcs:enable global $conf,$langs; @@ -860,7 +860,7 @@ class Account extends CommonObject * @param string $ref Ref of bank account to get * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $conf; @@ -1008,7 +1008,7 @@ class Account extends CommonObject * @param User $user User deleting * @return int <0 if KO, >0 if OK */ - function delete(User $user = null) + public function delete(User $user = null) { global $conf; @@ -1076,12 +1076,12 @@ class Account extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->clos, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of given object status * @@ -1089,7 +1089,7 @@ class Account extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -1120,13 +1120,13 @@ class Account extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi si un compte peut etre supprimer ou non (sans mouvements) * * @return boolean vrai si peut etre supprime, faux sinon */ - function can_be_deleted() + public function can_be_deleted() { // phpcs:enable $can_be_deleted=false; @@ -1152,7 +1152,7 @@ class Account extends CommonObject * * @return string Error string */ - function error() + public function error() { return $this->error; } @@ -1163,7 +1163,7 @@ class Account extends CommonObject * @param int $option 1=Exclude future operation date (this is to exclude input made in advance and have real account sold) * @return int Current sold (value date <= today) */ - function solde($option = 0) + public function solde($option = 0) { $solde=0; @@ -1189,7 +1189,7 @@ class Account extends CommonObject return price2num($solde, 'MU'); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -1197,7 +1197,7 @@ class Account extends CommonObject * @param int $filteraccountid To get info for a particular account id * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board(User $user, $filteraccountid = 0) + public function load_board(User $user, $filteraccountid = 0) { // phpcs:enable global $conf, $langs; @@ -1246,13 +1246,13 @@ class Account extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * @param int $filteraccountid To get info for a particular account id * @return int <0 if ko, >0 if ok */ - function load_state_board($filteraccountid = 0) + public function load_state_board($filteraccountid = 0) { // phpcs:enable global $user; @@ -1329,7 +1329,7 @@ class Account extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $mode = '', $option = '', $save_lastsearch_value = -1, $notooltip = 0) { global $conf, $langs, $user; @@ -1396,7 +1396,7 @@ class Account extends CommonObject * * @return int 1 if correct, <=0 if wrong */ - function verif() + public function verif() { require_once DOL_DOCUMENT_ROOT . '/core/lib/bank.lib.php'; @@ -1430,7 +1430,7 @@ class Account extends CommonObject * * @return string country code */ - function getCountryCode() + public function getCountryCode() { global $mysoc; @@ -1467,7 +1467,7 @@ class Account extends CommonObject * 1=Need 2 fields for bank code: Bank, Desk (France, Spain, ...) + Account number and key * 2=Need 1 field for bank code: Bank only (Sort code for Great Britain, BSB for Australia) + Account number */ - function useDetailedBBAN() + public function useDetailedBBAN() { $country_code=$this->getCountryCode(); @@ -1481,7 +1481,7 @@ class Account extends CommonObject * * @return int 1 = mandatory / 0 = Not mandatory */ - function needIBAN() + public function needIBAN() { $country_code=$this->getCountryCode(); @@ -1531,7 +1531,7 @@ class Account extends CommonObject * @param int $id Id of object to load * @return void */ - function info($id) + public function info($id) { } @@ -1631,7 +1631,7 @@ class Account extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->specimen = 1; $this->ref = 'MBA'; @@ -1752,7 +1752,7 @@ class AccountLine extends CommonObject * * @param DoliDB $db Database handler */ - function __construct(DoliDB $db) + public function __construct(DoliDB $db) { $this->db = $db; } @@ -1765,7 +1765,7 @@ class AccountLine extends CommonObject * @param string $num External num to load (ex: num of transaction for paypal fee) * @return int <0 if KO, 0 if OK but not found, >0 if OK and found */ - function fetch($rowid, $ref = '', $num = '') + public function fetch($rowid, $ref = '', $num = '') { global $conf; @@ -1887,7 +1887,7 @@ class AccountLine extends CommonObject * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - function delete(User $user = null) + public function delete(User $user = null) { $nbko=0; @@ -1930,14 +1930,14 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete bank line records * * @param User $user User object that delete * @return int <0 if KO, >0 if OK */ - function delete_urls(User $user = null) + public function delete_urls(User $user = null) { // phpcs:enable $nbko=0; @@ -1976,7 +1976,7 @@ class AccountLine extends CommonObject * @param int $notrigger 0=Disable all triggers * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { $this->db->begin(); @@ -2002,7 +2002,7 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update conciliation field * @@ -2011,7 +2011,7 @@ class AccountLine extends CommonObject * @param int $conciliated 1=Set transaction to conciliated, 0=Keep transaction non conciliated * @return int <0 if KO, >0 if OK */ - function update_conciliation(User $user, $cat, $conciliated = 1) + public function update_conciliation(User $user, $cat, $conciliated = 1) { // phpcs:enable global $conf,$langs; @@ -2067,7 +2067,7 @@ class AccountLine extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase/decrease value date of a rowid * @@ -2075,7 +2075,7 @@ class AccountLine extends CommonObject * @param int $sign 1 or -1 * @return int >0 if OK, 0 if KO */ - function datev_change($rowid, $sign = 1) + public function datev_change($rowid, $sign = 1) { // phpcs:enable $sql = "SELECT datev FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; @@ -2107,34 +2107,34 @@ class AccountLine extends CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase value date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - function datev_next($id) + public function datev_next($id) { // phpcs:enable return $this->datev_change($id, 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Decrease value date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - function datev_previous($id) + public function datev_previous($id) { // phpcs:enable return $this->datev_change($id, -1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase/decrease operation date of a rowid * @@ -2142,7 +2142,7 @@ class AccountLine extends CommonObject * @param int $sign 1 or -1 * @return int >0 if OK, 0 if KO */ - function dateo_change($rowid, $sign = 1) + public function dateo_change($rowid, $sign = 1) { // phpcs:enable $sql = "SELECT dateo FROM ".MAIN_DB_PREFIX."bank WHERE rowid = ".$rowid; @@ -2174,27 +2174,27 @@ class AccountLine extends CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Increase operation date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - function dateo_next($id) + public function dateo_next($id) { // phpcs:enable return $this->dateo_change($id, 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Decrease operation date of a rowid * * @param int $id Id of line to change * @return int >0 if OK, 0 if KO */ - function dateo_previous($id) + public function dateo_previous($id) { // phpcs:enable return $this->dateo_change($id, -1); @@ -2207,7 +2207,7 @@ class AccountLine extends CommonObject * @param int $id Id of object to load * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT b.rowid, b.datec, b.tms as datem,'; $sql.= ' b.fk_user_author, b.fk_user_rappro'; @@ -2257,7 +2257,7 @@ class AccountLine extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0, $option = '', $notooltip = 0) { global $langs; @@ -2298,12 +2298,12 @@ class AccountLine extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -2311,7 +2311,7 @@ class AccountLine extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/compta/bank/class/api_bankaccounts.class.php b/htdocs/compta/bank/class/api_bankaccounts.class.php index feaaccaa50f..04692fb4e44 100644 --- a/htdocs/compta/bank/class/api_bankaccounts.class.php +++ b/htdocs/compta/bank/class/api_bankaccounts.class.php @@ -43,7 +43,7 @@ class BankAccounts extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db; $this->db = $db; @@ -61,11 +61,11 @@ class BankAccounts extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { $list = array(); - if(! DolibarrApiAccess::$user->rights->banque->lire) { + if (! DolibarrApiAccess::$user->rights->banque->lire) { throw new RestException(401); } @@ -121,7 +121,7 @@ class BankAccounts extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if (! DolibarrApiAccess::$user->rights->banque->lire) { throw new RestException(401); @@ -142,7 +142,7 @@ class BankAccounts extends DolibarrApi * @param array $request_data Request data * @return int ID of account */ - function post($request_data = null) + public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); @@ -173,7 +173,7 @@ class BankAccounts extends DolibarrApi * @param array $request_data data * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); @@ -196,7 +196,7 @@ class BankAccounts extends DolibarrApi } else { - throw new RestException(500, $account->error); + throw new RestException(500, $account->error); } } @@ -206,7 +206,7 @@ class BankAccounts extends DolibarrApi * @param int $id ID of account * @return array */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->banque->configurer) { throw new RestException(401); @@ -237,7 +237,7 @@ class BankAccounts extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $account = array(); foreach (BankAccounts::$FIELDS as $field) { @@ -254,7 +254,7 @@ class BankAccounts extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -273,7 +273,7 @@ class BankAccounts extends DolibarrApi * * @url GET {id}/lines */ - function getLines($id) + public function getLines($id) { $list = array(); @@ -325,7 +325,7 @@ class BankAccounts extends DolibarrApi * * @url POST {id}/lines */ - function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '') + public function addLine($id, $date, $type, $label, $amount, $category = 0, $cheque_number = '', $cheque_writer = '', $cheque_bank = '') { if (! DolibarrApiAccess::$user->rights->banque->modifier) { throw new RestException(401); @@ -337,8 +337,16 @@ class BankAccounts extends DolibarrApi throw new RestException(404, 'account not found'); } - $result = $account->addline($date, $type, $label, $amount, $cheque_number, $category, - DolibarrApiAccess::$user, $cheque_writer, $cheque_bank); + $result = $account->addline( + $date, + $type, + $label, + $amount, + $cheque_number, + $category, + DolibarrApiAccess::$user, + $cheque_writer, $cheque_bank + ); if ($result < 0) { throw new RestException(503, 'Error when adding line to account: ' . $account->error); } @@ -358,7 +366,7 @@ class BankAccounts extends DolibarrApi * * @url POST {id}/lines/{line_id}/links */ - function addLink($id, $line_id, $url_id, $url, $label, $type) + public function addLink($id, $line_id, $url_id, $url, $label, $type) { if (! DolibarrApiAccess::$user->rights->banque->modifier) { throw new RestException(401); diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 06de0a00bc1..5a7ac205fe5 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -99,7 +99,7 @@ class PaymentVarious extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->element = 'payment_various'; @@ -113,7 +113,7 @@ class PaymentVarious extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -184,7 +184,7 @@ class PaymentVarious extends CommonObject * @param User $user User that load * @return int <0 if KO, >0 if OK */ - function fetch($id, $user = null) + public function fetch($id, $user = null) { global $langs; $sql = "SELECT"; @@ -258,7 +258,7 @@ class PaymentVarious extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { global $conf, $langs; @@ -292,7 +292,7 @@ class PaymentVarious extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -316,7 +316,7 @@ class PaymentVarious extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf,$langs; @@ -482,14 +482,14 @@ class PaymentVarious extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between payment various and line generate into llx_bank * * @param int $id_bank Id bank account * @return int <0 if KO, >0 if OK */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_various SET fk_bank = '.$id_bank; @@ -513,12 +513,12 @@ class PaymentVarious extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -526,7 +526,7 @@ class PaymentVarious extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -575,7 +575,7 @@ class PaymentVarious extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $save_lastsearch_value = -1, $notooltip = 0) { global $db, $conf, $langs, $hookmanager; global $langs; @@ -644,8 +644,8 @@ class PaymentVarious extends CommonObject * @param int $id Id of record * @return void */ - function info($id) - { + public function info($id) + { $sql = 'SELECT v.rowid, v.datec, v.fk_user_author'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_various as v'; $sql.= ' WHERE v.rowid = '.$id; diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index 594639e74cd..ae1360ff633 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -83,7 +83,7 @@ class Deplacement extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -98,7 +98,7 @@ class Deplacement extends CommonObject * @param User $user User that creates * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf; @@ -183,7 +183,7 @@ class Deplacement extends CommonObject * @param User $user User making update * @return int <0 if KO, >0 if OK */ - function update($user) + public function update($user) { global $langs; @@ -245,7 +245,7 @@ class Deplacement extends CommonObject * @param string $ref Ref of record * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { $sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet as fk_project, extraparams"; $sql.= " FROM ".MAIN_DB_PREFIX."deplacement"; @@ -288,7 +288,7 @@ class Deplacement extends CommonObject * @param int $id Id of record to delete * @return int <0 if KO, >0 if OK */ - function delete($id) + public function delete($id) { $this->db->begin(); @@ -316,12 +316,12 @@ class Deplacement extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -329,7 +329,7 @@ class Deplacement extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Libelle */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -345,26 +345,26 @@ class Deplacement extends CommonObject elseif ($mode == 2) { if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts_short[$statut]); - if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]); - if ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); + elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts_short[$statut]); + elseif ($statut==2) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts_short[$statut]); } elseif ($mode == 3) { if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); + elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); } elseif ($mode == 4) { if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - if ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); } elseif ($mode == 5) { if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut0'); - if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); - if ($statut==2 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); + elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut4'); + elseif ($statut==2 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]), 'statut6'); } } @@ -374,7 +374,7 @@ class Deplacement extends CommonObject * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0) + public function getNomUrl($withpicto = 0) { global $langs; @@ -400,7 +400,7 @@ class Deplacement extends CommonObject * @param int $active Active or not * @return array */ - function listOfTypes($active = 1) + public function listOfTypes($active = 1) { global $langs; @@ -437,7 +437,7 @@ class Deplacement extends CommonObject * @param int $id Id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, c.datec, c.fk_user_author, c.fk_user_modif,'; $sql.= ' c.tms'; diff --git a/htdocs/compta/deplacement/class/deplacementstats.class.php b/htdocs/compta/deplacement/class/deplacementstats.class.php index 2580e264ee8..e6f3fb7828d 100644 --- a/htdocs/compta/deplacement/class/deplacementstats.class.php +++ b/htdocs/compta/deplacement/class/deplacementstats.class.php @@ -35,12 +35,12 @@ class DeplacementStats extends Stats */ public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** * Constructor @@ -50,7 +50,7 @@ class DeplacementStats extends Stats * @param mixed $userid Id user for filter or array of user ids * @return void */ - function __construct($db, $socid = 0, $userid = 0) + public function __construct($db, $socid = 0, $userid = 0) { global $conf; @@ -78,7 +78,7 @@ class DeplacementStats extends Stats * * @return array Array of values */ - function getNbByYear() + public function getNbByYear() { $sql = "SELECT YEAR(dated) as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -96,7 +96,7 @@ class DeplacementStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { $sql = "SELECT MONTH(dated) as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -118,7 +118,7 @@ class DeplacementStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { $sql = "SELECT date_format(dated,'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -138,7 +138,7 @@ class DeplacementStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { $sql = "SELECT date_format(dated,'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -155,14 +155,14 @@ class DeplacementStats extends Stats * * @return array Array of values */ - function getAllByYear() - { - $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + public function getAllByYear() + { + $sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 7da45f33920..6c4c94fc2ce 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -43,10 +43,10 @@ class Invoices extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->invoice = new Facture($this->db); } @@ -61,7 +61,7 @@ class Invoices extends DolibarrApi * * @throws RestException */ - function get($id, $contact_list = 1) + public function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); @@ -105,7 +105,7 @@ class Invoices extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') { global $db, $conf; @@ -204,7 +204,7 @@ class Invoices extends DolibarrApi * @param array $request_data Request datas * @return int ID of invoice */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401, "Insuffisant rights"); @@ -247,29 +247,29 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function createInvoiceFromOrder($orderid) + public function createInvoiceFromOrder($orderid) { require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; - if(! DolibarrApiAccess::$user->rights->commande->lire) { + if (! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); } - if(! DolibarrApiAccess::$user->rights->facture->creer) { + if (! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); } - if(empty($orderid)) { + if (empty($orderid)) { throw new RestException(400, 'Order ID is mandatory'); } $order = new Commande($this->db); $result = $order->fetch($orderid); - if( ! $result ) { + if ( ! $result ) { throw new RestException(404, 'Order not found'); } $result = $this->invoice->createFromOrder($order, DolibarrApiAccess::$user); - if( $result < 0) { + if ( $result < 0) { throw new RestException(405, $this->invoice->error); } $this->invoice->fetchObjectLinked(); @@ -285,7 +285,7 @@ class Invoices extends DolibarrApi * * @return int */ - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); @@ -323,7 +323,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -386,7 +386,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - function postContact($id, $contactid, $type) + public function postContact($id, $contactid, $type) { if(!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -428,7 +428,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function deleteContact($id, $rowid) + public function deleteContact($id, $rowid) { if(!DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -468,7 +468,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->facture->creer) { @@ -506,7 +506,7 @@ class Invoices extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -547,7 +547,7 @@ class Invoices extends DolibarrApi * @param int $id Invoice ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->facture->supprimer) { throw new RestException(401); @@ -597,7 +597,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 400 */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -681,23 +681,23 @@ class Invoices extends DolibarrApi * @throws 500 * */ - function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) + public function addContact($id, $fk_socpeople, $type_contact, $source, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); + throw new RestException(401); } $result = $this->invoice->fetch($id); if( ! $result ) { - throw new RestException(404, 'Invoice not found'); + throw new RestException(404, 'Invoice not found'); } if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->add_contact($fk_socpeople, $type_contact, $source, $notrigger); if ($result < 0) { - throw new RestException(500, 'Error : '.$this->invoice->error); + throw new RestException(500, 'Error : '.$this->invoice->error); } $result = $this->invoice->fetch($id); @@ -731,7 +731,7 @@ class Invoices extends DolibarrApi * @throws 500 * */ - function settodraft($id, $idwarehouse = -1) + public function settodraft($id, $idwarehouse = -1) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -783,7 +783,7 @@ class Invoices extends DolibarrApi * * @return array */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -834,7 +834,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function settopaid($id, $close_code = '', $close_note = '') + public function settopaid($id, $close_code = '', $close_note = '') { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -885,7 +885,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function settounpaid($id) + public function settounpaid($id) { if(! DolibarrApiAccess::$user->rights->facture->creer) { throw new RestException(401); @@ -934,24 +934,24 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 500 */ - function markAsCreditAvailable($id) + public function markAsCreditAvailable($id) { if(! DolibarrApiAccess::$user->rights->facture->creer) { - throw new RestException(401); + throw new RestException(401); } $result = $this->invoice->fetch($id); if( ! $result ) { - throw new RestException(404, 'Invoice not found'); + throw new RestException(404, 'Invoice not found'); } if( ! DolibarrApi::_checkAccessToResource('facture', $this->invoice->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $result = $this->invoice->fetch_thirdparty(); if( ! $result ) { - throw new RestException(404, 'Thirdparty not found'); + throw new RestException(404, 'Thirdparty not found'); } if (! $this->invoice->paye) // protection against multiple submit @@ -1053,7 +1053,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function useDiscount($id, $discountid) + public function useDiscount($id, $discountid) { if(! DolibarrApiAccess::$user->rights->facture->creer) { @@ -1099,7 +1099,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function useCreditNote($id, $discountid) + public function useCreditNote($id, $discountid) { require_once DOL_DOCUMENT_ROOT . '/core/class/discount.class.php'; @@ -1144,7 +1144,7 @@ class Invoices extends DolibarrApi * @throws 404 * @throws 405 */ - function getPayments($id) + public function getPayments($id) { if(! DolibarrApiAccess::$user->rights->facture->lire) { @@ -1192,7 +1192,7 @@ class Invoices extends DolibarrApi * @throws 401 * @throws 404 */ - function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPayment($id, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; @@ -1257,10 +1257,10 @@ class Invoices extends DolibarrApi $paiement->datepaye = $datepaye; $paiement->amounts = $amounts; // Array with all payments dispatching with invoice id $paiement->multicurrency_amounts = $multicurrency_amounts; // Array with all payments dispatching - $paiement->paiementid = $paiementid; + $paiement->paiementid = $paiementid; $paiement->paiementcode = dol_getIdFromCode($this->db, $paiementid, 'c_paiement', 'id', 'code', 1); $paiement->num_paiement = $num_paiement; - $paiement->note = $comment; + $paiement->note = $comment; $paiement_id = $paiement->create(DolibarrApiAccess::$user, ($closepaidinvoices=='yes'?1:0)); // This include closing invoices if ($paiement_id < 0) @@ -1312,7 +1312,7 @@ class Invoices extends DolibarrApi * @throws 403 * @throws 404 */ - function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') + public function addPaymentDistributed($arrayofamounts, $datepaye, $paiementid, $closepaidinvoices, $accountid, $num_paiement = '', $comment = '', $chqemetteur = '', $chqbank = '') { global $conf; @@ -1423,7 +1423,7 @@ class Invoices extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -1446,7 +1446,7 @@ class Invoices extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $invoice = array(); foreach (Invoices::$FIELDS as $field) { diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 2e0d346e62f..3dffd5b396d 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -103,7 +103,7 @@ class FactureRec extends CommonInvoice * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -115,7 +115,7 @@ class FactureRec extends CommonInvoice * @param int $facid Id of source invoice * @return int <0 if KO, id of invoice created if OK */ - function create($user, $facid) + public function create($user, $facid) { global $conf; @@ -225,7 +225,7 @@ class FactureRec extends CommonInvoice $tva_tx = $facsrc->lines[$i]->tva_tx; if (! empty($facsrc->lines[$i]->vat_src_code) && ! preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')'; - $result_insert = $this->addline( + $result_insert = $this->addline( $facsrc->lines[$i]->desc, $facsrc->lines[$i]->subprice, $facsrc->lines[$i]->qty, @@ -319,7 +319,7 @@ class FactureRec extends CommonInvoice * @param int $notrigger No trigger * @return int <0 if KO, Id of line if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf; @@ -372,7 +372,7 @@ class FactureRec extends CommonInvoice * @param int $ref_int Internal reference of other object * @return int >0 if OK, <0 if KO, 0 if not found */ - function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') { $sql = 'SELECT f.rowid, f.entity, f.titre, f.suspended, f.fk_soc, f.amount, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; $sql.= ', f.remise_percent, f.remise_absolue, f.remise'; @@ -500,19 +500,19 @@ class FactureRec extends CommonInvoice * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Recupere les lignes de factures predefinies dans this->lines * * @return int 1 if OK, < 0 if KO */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->lines=array(); @@ -624,7 +624,7 @@ class FactureRec extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function delete(User $user, $notrigger = 0, $idwarehouse = -1) + public function delete(User $user, $notrigger = 0, $idwarehouse = -1) { $rowid=$this->id; @@ -695,7 +695,7 @@ class FactureRec extends CommonInvoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0) { global $mysoc; @@ -877,7 +877,7 @@ class FactureRec extends CommonInvoice * @param int $date_end_fill 1=Flag to fill end date when generating invoice * @return int <0 if KO, Id of line if OK */ - function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0) + public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0) { global $mysoc; @@ -1013,7 +1013,7 @@ class FactureRec extends CommonInvoice * * @return int|false false if KO, timestamp if OK */ - function getNextDate() + public function getNextDate() { if (empty($this->date_when)) return false; return dol_time_plus_duree($this->date_when, $this->frequency, $this->unit_frequency); @@ -1024,7 +1024,7 @@ class FactureRec extends CommonInvoice * * @return boolean False by default, True if maximum number of generation is reached */ - function isMaxNbGenReached() + public function isMaxNbGenReached() { $ret = false; if ($this->nb_gen_max > 0 && ($this->nb_gen_done >= $this->nb_gen_max)) $ret = true; @@ -1037,7 +1037,7 @@ class FactureRec extends CommonInvoice * @param string $ret Default value to output * @return boolean False by default, True if maximum number of generation is reached */ - function strikeIfMaxNbGenReached($ret) + public function strikeIfMaxNbGenReached($ret) { // Special case to strike the date return ($this->isMaxNbGenReached()?'':'').$ret.($this->isMaxNbGenReached()?'':''); @@ -1053,7 +1053,7 @@ class FactureRec extends CommonInvoice * @param int $forcevalidation 1=Force validation of invoice whatever is template auto_validate flag. * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidation = 0) + public function createRecurringInvoices($restrictioninvoiceid = 0, $forcevalidation = 0) { global $conf, $langs, $db, $user, $hookmanager; @@ -1210,7 +1210,7 @@ class FactureRec extends CommonInvoice * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1) { global $langs; @@ -1261,13 +1261,13 @@ class FactureRec extends CommonInvoice * @param integer $alreadypaid Not used on recurring invoices * @return string Label of status */ - function getLibStatut($mode = 0, $alreadypaid = -1) + public function getLibStatut($mode = 0, $alreadypaid = -1) { return $this->LibStatut($this->frequency?1:0, $this->suspended, $mode, $alreadypaid, empty($this->type)?0:$this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1278,7 +1278,7 @@ class FactureRec extends CommonInvoice * @param int $type Type invoice * @return string Label of status */ - function LibStatut($recur, $status, $mode = 0, $alreadypaid = -1, $type = 0) + public function LibStatut($recur, $status, $mode = 0, $alreadypaid = -1, $type = 0) { // phpcs:enable global $langs; @@ -1379,7 +1379,7 @@ class FactureRec extends CommonInvoice * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') + public function initAsSpecimen($option = '') { global $user,$langs,$conf; @@ -1528,36 +1528,32 @@ class FactureRec extends CommonInvoice * Update frequency and unit * * @param int $frequency value of frequency - * @param string $unit unit of frequency (d, m, y) + * @param string $unit unit of frequency (d, m, y) * @return int <0 if KO, >0 if OK */ - function setFrequencyAndUnit($frequency, $unit) + public function setFrequencyAndUnit($frequency, $unit) { - if (! $this->table_element) - { + if (! $this->table_element) { dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR); return -1; } - if (!empty($frequency) && empty($unit)) - { + if (!empty($frequency) && empty($unit)) { dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined", LOG_ERR); return -2; } $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= ' SET frequency = '.($frequency?$this->db->escape($frequency):'null'); - if (!empty($unit)) - { + if (!empty($unit)) { $sql.= ', unit_frequency = \''.$this->db->escape($unit).'\''; } $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG); - if ($this->db->query($sql)) - { + if ($this->db->query($sql)) { $this->frequency = $frequency; - if (!empty($unit)) $this->unit_frequency = $unit; + if (!empty($unit)) $this->unit_frequency = $unit; return 1; } else @@ -1574,7 +1570,7 @@ class FactureRec extends CommonInvoice * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done * @return int <0 if KO, >0 if OK */ - function setNextDate($date, $increment_nb_gen_done = 0) + public function setNextDate($date, $increment_nb_gen_done = 0) { if (! $this->table_element) { @@ -1606,7 +1602,7 @@ class FactureRec extends CommonInvoice * @param int $nb number of maximum period * @return int <0 if KO, >0 if OK */ - function setMaxPeriod($nb) + public function setMaxPeriod($nb) { if (! $this->table_element) { @@ -1639,7 +1635,7 @@ class FactureRec extends CommonInvoice * @param int $validate 0 to create in draft, 1 to create and validate invoice * @return int <0 if KO, >0 if OK */ - function setAutoValidate($validate) + public function setAutoValidate($validate) { if (! $this->table_element) { @@ -1670,7 +1666,7 @@ class FactureRec extends CommonInvoice * @param int $validate 0 no document, 1 to generate document * @return int <0 if KO, >0 if OK */ - function setGeneratePdf($validate) + public function setGeneratePdf($validate) { if (! $this->table_element) { @@ -1696,12 +1692,12 @@ class FactureRec extends CommonInvoice } /** - * Update the model for documents + * Update the model for documents * - * @param string $model model of document generator - * @return int <0 if KO, >0 if OK + * @param string $model model of document generator + * @return int <0 if KO, >0 if OK */ - function setModelPdf($model) + public function setModelPdf($model) { if (! $this->table_element) { @@ -1745,8 +1741,8 @@ class FactureLigneRec extends CommonInvoiceLine */ public $table_element='facturedet_rec'; - var $date_start_fill; - var $date_end_fill; + public $date_start_fill; + public $date_end_fill; /** @@ -1756,7 +1752,7 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function delete(User $user, $notrigger = false) + public function delete(User $user, $notrigger = false) { $error=0; @@ -1799,7 +1795,7 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $rowid Id of invoice * @return int 1 if OK, < 0 if KO */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,'; $sql.= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,'; @@ -1874,7 +1870,7 @@ class FactureLigneRec extends CommonInvoiceLine * @param int $notrigger No trigger * @return int <0 if KO, Id of line if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf; @@ -1899,8 +1895,7 @@ class FactureLigneRec extends CommonInvoiceLine $sql.= ", info_bits='".price2num($this->info_bits)."'"; $sql.= ", date_start_fill=".(int) $this->date_start_fill; $sql.= ", date_end_fill=".(int) $this->date_end_fill; - if (empty($this->skip_update_total)) - { + if (empty($this->skip_update_total)) { $sql.= ", total_ht=".price2num($this->total_ht); $sql.= ", total_tva=".price2num($this->total_tva); $sql.= ", total_localtax1=".price2num($this->total_localtax1); @@ -1915,8 +1910,8 @@ class FactureLigneRec extends CommonInvoiceLine dol_syslog(get_class($this)."::updateline", LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { + if ($resql) + { if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { $result=$this->insertExtraFields(); @@ -1937,14 +1932,14 @@ class FactureLigneRec extends CommonInvoiceLine } // End call triggers } - $this->db->commit(); - return 1; - } - else - { - $this->error=$this->db->lasterror(); - $this->db->rollback(); - return -2; - } + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -2; + } } } diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 08f75f1e28e..5e2db021f83 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -274,7 +274,7 @@ class Facture extends CommonInvoice * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -289,7 +289,7 @@ class Facture extends CommonInvoice * @param int $forceduedate 1=Do not recalculate due date from payment condition but force it with value * @return int <0 if KO, >0 if OK */ - function create(User $user, $notrigger = 0, $forceduedate = 0) + public function create(User $user, $notrigger = 0, $forceduedate = 0) { global $langs,$conf,$mysoc,$hookmanager; $error=0; @@ -854,7 +854,7 @@ class Facture extends CommonInvoice * @param int $invertdetail Reverse sign of amounts for lines * @return int <0 if KO, >0 if OK */ - function createFromCurrent(User $user, $invertdetail = 0) + public function createFromCurrent(User $user, $invertdetail = 0) { global $conf; @@ -945,7 +945,7 @@ class Facture extends CommonInvoice * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$hookmanager, $conf; @@ -1054,7 +1054,7 @@ class Facture extends CommonInvoice * @param User $user Object user * @return int <0 if KO, 0 if nothing done, 1 if OK */ - function createFromOrder($object, User $user) + public function createFromOrder($object, User $user) { global $hookmanager; @@ -1172,7 +1172,7 @@ class Facture extends CommonInvoice * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $addlinktonotes = 0, $save_lastsearch_value = -1) { global $langs, $conf, $user, $form; @@ -1280,7 +1280,7 @@ class Facture extends CommonInvoice * @param bool $fetch_situation Fetch the previous and next situation in $tab_previous_situation_invoice and $tab_next_situation_invoice * @return int >0 if OK, <0 if KO, 0 if not found */ - function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_situation = false) + public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '', $fetch_situation = false) { global $conf; @@ -1431,13 +1431,13 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load all detailed lines into this->lines * * @return int 1 if OK, < 0 if KO */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->lines=array(); @@ -1547,7 +1547,7 @@ class Facture extends CommonInvoice * * @return void */ - function fetchPreviousNextSituationInvoice() + public function fetchPreviousNextSituationInvoice() { global $conf; @@ -1587,7 +1587,7 @@ class Facture extends CommonInvoice * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf; @@ -1692,14 +1692,14 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount) * * @param int $idremise Id of absolute discount * @return int >0 if OK, <0 if KO */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -1794,7 +1794,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set customer ref * @@ -1802,7 +1802,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_ref_client($ref_client, $notrigger = 0) + public function set_ref_client($ref_client, $notrigger = 0) { // phpcs:enable global $user; @@ -1867,7 +1867,7 @@ class Facture extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, 0=Refused, >0 if OK */ - function delete($user, $notrigger = 0, $idwarehouse = -1) + public function delete($user, $notrigger = 0, $idwarehouse = -1) { global $langs,$conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2031,7 +2031,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag la facture comme paye completement (si close_code non renseigne) => this->fk_statut=2, this->paye=1 * ou partiellement (si close_code renseigne) + appel trigger BILL_PAYED => this->fk_statut=2, this->paye stay 0 @@ -2041,7 +2041,7 @@ class Facture extends CommonInvoice * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet (cas escompte par exemple) * @return int <0 if KO, >0 if OK */ - function set_paid($user, $close_code = '', $close_note = '') + public function set_paid($user, $close_code = '', $close_note = '') { // phpcs:enable $error=0; @@ -2091,7 +2091,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag la facture comme non payee completement + appel trigger BILL_UNPAYED * Fonction utilisee quand un paiement prelevement est refuse, @@ -2100,7 +2100,7 @@ class Facture extends CommonInvoice * @param User $user Object user that change status * @return int <0 if KO, >0 if OK */ - function set_unpaid($user) + public function set_unpaid($user) { // phpcs:enable $error=0; @@ -2140,7 +2140,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag invoice as canceled, with no payment on it (example for replacement invoice or payment never received) + call trigger BILL_CANCEL * Warning, if option to decrease stock on invoice was set, this function does not change stock (it might be a cancel because @@ -2151,7 +2151,7 @@ class Facture extends CommonInvoice * @param string $close_note Comment * @return int <0 if KO, >0 if OK */ - function set_canceled($user, $close_code = '', $close_note = '') + public function set_canceled($user, $close_code = '', $close_note = '') { // phpcs:enable @@ -2214,7 +2214,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK */ - function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) + public function validate($user, $force_number = '', $idwarehouse = 0, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2471,7 +2471,7 @@ class Facture extends CommonInvoice * @param Translate $langs Translate object * @return bool false if KO, true if OK */ - function updatePriceNextInvoice(&$langs) + public function updatePriceNextInvoice(&$langs) { foreach ($this->tab_next_situation_invoice as $next_invoice) { @@ -2504,7 +2504,7 @@ class Facture extends CommonInvoice return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -2512,7 +2512,7 @@ class Facture extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function set_draft($user, $idwarehouse = -1) + public function set_draft($user, $idwarehouse = -1) { // phpcs:enable global $conf,$langs; @@ -2632,7 +2632,7 @@ class Facture extends CommonInvoice * @param double $pu_ht_devise Unit price in currency * @return int <0 if KO, Id of line if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $date_start = '', $date_end = '', $ventil = 0, $info_bits = 0, $fk_remise_except = '', $price_base_type = 'HT', $pu_ttc = 0, $type = self::TYPE_STANDARD, $rang = -1, $special_code = 0, $origin = '', $origin_id = 0, $fk_parent_line = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $array_options = 0, $situation_percent = 100, $fk_prev_id = 0, $fk_unit = null, $pu_ht_devise = 0) { // Deprecation warning if ($label) { @@ -2862,7 +2862,7 @@ class Facture extends CommonInvoice * @param int $notrigger disable line update trigger * @return int < 0 if KO, > 0 if OK */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = self::TYPE_STANDARD, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 100, $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0) { global $conf,$user; // Deprecation warning @@ -3053,7 +3053,7 @@ class Facture extends CommonInvoice * @param float $situation_percent progress percentage need to be test * @return false if KO, true if OK */ - function checkProgressLine($idline, $situation_percent) + public function checkProgressLine($idline, $situation_percent) { $sql = 'SELECT fd.situation_percent FROM '.MAIN_DB_PREFIX.'facturedet fd INNER JOIN '.MAIN_DB_PREFIX.'facture f ON (fd.fk_facture = f.rowid) @@ -3073,7 +3073,7 @@ class Facture extends CommonInvoice else return $situation_percent < $obj->situation_percent; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update invoice line with percentage * @@ -3081,7 +3081,7 @@ class Facture extends CommonInvoice * @param int $percent Percentage * @return void */ - function update_percent($line, $percent) + public function update_percent($line, $percent) { // phpcs:enable global $mysoc,$user; @@ -3111,7 +3111,7 @@ class Facture extends CommonInvoice * @param int $rowid Id of line to delete * @return int <0 if KO, >0 if OK */ - function deleteline($rowid) + public function deleteline($rowid) { global $user; @@ -3171,7 +3171,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set percent discount * @@ -3180,7 +3180,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function set_remise($user, $remise, $notrigger = 0) + public function set_remise($user, $remise, $notrigger = 0) { // phpcs:enable // Clean parameters @@ -3237,7 +3237,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set absolute discount * @@ -3246,7 +3246,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_remise_absolue($user, $remise, $notrigger = 0) + public function set_remise_absolue($user, $remise, $notrigger = 0) { // phpcs:enable if (empty($remise)) $remise=0; @@ -3313,7 +3313,7 @@ class Facture extends CommonInvoice * @param string $mode 'next' for next value or 'last' for last value * @return string free ref or last ref */ - function getNextNumRef($soc, $mode = 'next') + public function getNextNumRef($soc, $mode = 'next') { global $conf, $langs; $langs->load("bills"); @@ -3402,7 +3402,7 @@ class Facture extends CommonInvoice * @param int $id Id of object to load * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, datec, date_valid as datev, tms as datem,'; $sql.= ' fk_user_author, fk_user_valid'; @@ -3441,7 +3441,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of invoices (eventually filtered on a user) into an array * @@ -3455,7 +3455,7 @@ class Facture extends CommonInvoice * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'f.datef,f.rowid', $sortorder = 'DESC') { // phpcs:enable global $conf,$user; @@ -3517,7 +3517,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of invoices qualified to be replaced by another invoice. * Invoices matching the following rules are returned: @@ -3526,7 +3526,7 @@ class Facture extends CommonInvoice * @param int $socid Id thirdparty * @return array Array of invoices ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) */ - function list_replacable_invoices($socid = 0) + public function list_replacable_invoices($socid = 0) { // phpcs:enable global $conf; @@ -3567,7 +3567,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of invoices qualified to be corrected by a credit note. * Invoices matching the following rules are returned: @@ -3576,7 +3576,7 @@ class Facture extends CommonInvoice * @param int $socid Id thirdparty * @return array Array of invoices ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) */ - function list_qualified_avoir_invoices($socid = 0) + public function list_qualified_avoir_invoices($socid = 0) { // phpcs:enable global $conf; @@ -3642,7 +3642,7 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a withdrawal request for a standing order. * Use the remain to pay excluding all existing open direct debit requests. @@ -3651,7 +3651,7 @@ class Facture extends CommonInvoice * @param float $amount Amount we request direct debit for * @return int <0 if KO, >0 if OK */ - function demande_prelevement($fuser, $amount = 0) + public function demande_prelevement($fuser, $amount = 0) { // phpcs:enable @@ -3754,7 +3754,7 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Supprime une demande de prelevement * @@ -3762,7 +3762,7 @@ class Facture extends CommonInvoice * @param int $did id de la demande a supprimer * @return int <0 if OK, >0 if KO */ - function demande_prelevement_delete($fuser, $did) + public function demande_prelevement_delete($fuser, $did) { // phpcs:enable $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'prelevement_facture_demande'; @@ -3781,14 +3781,14 @@ class Facture extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Object user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -3853,7 +3853,7 @@ class Facture extends CommonInvoice * * @return array Liste des id contacts facturation */ - function getIdBillingContact() + public function getIdBillingContact() { return $this->getIdContact('external', 'BILLING'); } @@ -3863,7 +3863,7 @@ class Facture extends CommonInvoice * * @return array Liste des id contacts livraison */ - function getIdShippingContact() + public function getIdShippingContact() { return $this->getIdContact('external', 'SHIPPING'); } @@ -3877,7 +3877,7 @@ class Facture extends CommonInvoice * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') + public function initAsSpecimen($option = '') { global $langs; @@ -4028,13 +4028,13 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -4077,7 +4077,7 @@ class Facture extends CommonInvoice * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -4123,7 +4123,7 @@ class Facture extends CommonInvoice * * @return int >= 1 if OK, -1 if error */ - function newCycle() + public function newCycle() { $sql = 'SELECT max(situation_cycle_ref) FROM ' . MAIN_DB_PREFIX . 'facture as f'; $sql.= " WHERE f.entity in (".getEntity('invoice', 0).")"; @@ -4146,25 +4146,25 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Checks if the invoice is the first of a cycle * * @return boolean */ - function is_first() + public function is_first() { // phpcs:enable return ($this->situation_counter == 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array containing the previous situations as Facture objects * * @return mixed -1 if error, array of previous situations */ - function get_prev_sits() + public function get_prev_sits() { // phpcs:enable global $conf; @@ -4198,7 +4198,7 @@ class Facture extends CommonInvoice * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function setFinal(User $user, $notrigger = 0) + public function setFinal(User $user, $notrigger = 0) { $error=0; @@ -4239,14 +4239,14 @@ class Facture extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Checks if the invoice is the last in its cycle * * @return bool Last of the cycle status * */ - function is_last_in_cycle() + public function is_last_in_cycle() { // phpcs:enable global $conf; @@ -4403,7 +4403,7 @@ class FactureLigne extends CommonInvoiceLine * @param int $rowid id of invoice line to get * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT fd.rowid, fd.fk_facture, fd.fk_parent_line, fd.fk_product, fd.product_type, fd.label as custom_label, fd.description, fd.price, fd.qty, fd.vat_src_code, fd.tva_tx,'; $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; @@ -4495,7 +4495,7 @@ class FactureLigne extends CommonInvoiceLine * @param int $noerrorifdiscountalreadylinked 1=Do not make error if lines is linked to a discount and discount already linked to another * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) + public function insert($notrigger = 0, $noerrorifdiscountalreadylinked = 0) { global $langs,$user,$conf; @@ -4712,7 +4712,7 @@ class FactureLigne extends CommonInvoiceLine * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = '', $notrigger = 0) + public function update($user = '', $notrigger = 0) { global $user,$conf; @@ -4846,7 +4846,7 @@ class FactureLigne extends CommonInvoiceLine * * @return int <0 if KO, >0 if OK */ - function delete() + public function delete() { global $user; @@ -4877,14 +4877,14 @@ class FactureLigne extends CommonInvoiceLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); @@ -4919,7 +4919,7 @@ class FactureLigne extends CommonInvoiceLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns situation_percent of the previous line. * Warning: If invoice is a replacement invoice, this->fk_prev_id is id of the replaced line. @@ -4928,7 +4928,7 @@ class FactureLigne extends CommonInvoiceLine * @param bool $include_credit_note Include credit note or not * @return int >= 0 */ - function get_prev_progress($invoiceid, $include_credit_note = true) + public function get_prev_progress($invoiceid, $include_credit_note = true) { // phpcs:enable if (is_null($this->fk_prev_id) || empty($this->fk_prev_id) || $this->fk_prev_id == "") { diff --git a/htdocs/compta/facture/class/facturestats.class.php b/htdocs/compta/facture/class/facturestats.class.php index 65a8808bac7..91d3e4476ff 100644 --- a/htdocs/compta/facture/class/facturestats.class.php +++ b/htdocs/compta/facture/class/facturestats.class.php @@ -32,17 +32,17 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class FactureStats extends Stats { - var $socid; - var $userid; + public $socid; + public $userid; /** * @var string Name of table without prefix where object is stored */ public $table_element; - - var $from; - var $field; - var $where; + + public $from; + public $field; + public $where; /** @@ -53,7 +53,7 @@ class FactureStats extends Stats * @param string $mode Option ('customer', 'supplier') * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -100,7 +100,7 @@ class FactureStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -123,7 +123,7 @@ class FactureStats extends Stats * * @return array Array with number by year */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -145,7 +145,7 @@ class FactureStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with amount by month */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { global $user; @@ -168,7 +168,7 @@ class FactureStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { global $user; @@ -188,7 +188,7 @@ class FactureStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { global $user; @@ -208,7 +208,7 @@ class FactureStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAllByProduct($year) + public function getAllByProduct($year) { global $user; diff --git a/htdocs/compta/facture/class/paymentterm.class.php b/htdocs/compta/facture/class/paymentterm.class.php index 3d4f0881de2..707b6586b83 100644 --- a/htdocs/compta/facture/class/paymentterm.class.php +++ b/htdocs/compta/facture/class/paymentterm.class.php @@ -69,7 +69,7 @@ class PaymentTerm // extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -82,7 +82,7 @@ class PaymentTerm // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -173,7 +173,7 @@ class PaymentTerm // extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -229,7 +229,7 @@ class PaymentTerm // extends CommonObject * * @return int <0 if KO, >0 if OK */ - function getDefaultId() + public function getDefaultId() { global $langs; @@ -262,13 +262,13 @@ class PaymentTerm // extends CommonObject /** - * Update database + * Update database * - * @param User $user User that modify - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, >0 if OK + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -345,7 +345,7 @@ class PaymentTerm // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -391,12 +391,12 @@ class PaymentTerm // extends CommonObject /** - * Load an object from its id and create a new one in database + * Load an object from its id and create a new one in database * - * @param int $fromid Id of object to clone - * @return int New id of clone + * @param int $fromid Id of object to clone + * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -425,10 +425,6 @@ class PaymentTerm // extends CommonObject $error++; } - //if (! $error) - //{ - //} - unset($object->context['createfromclone']); // End @@ -445,15 +441,15 @@ class PaymentTerm // extends CommonObject } - /** + /** * Initialise an instance with random values. * Used to build previews or test instances. * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() - { + */ + public function initAsSpecimen() + { $this->id=0; $this->code=''; diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 686e72c46a7..b0178bd09e1 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -75,7 +75,7 @@ class Localtax extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -87,7 +87,7 @@ class Localtax extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -163,7 +163,7 @@ class Localtax extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf, $langs; @@ -228,7 +228,7 @@ class Localtax extends CommonObject * @param int $id Object id * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -292,7 +292,7 @@ class Localtax extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { // Call trigger $result=$this->call_trigger('LOCALTAX_DELETE', $user); @@ -322,7 +322,7 @@ class Localtax extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -345,7 +345,7 @@ class Localtax extends CommonObject * @param int $year Year * @return int ??? */ - function solde($year = 0) + public function solde($year = 0) { $reglee = $this->localtax_sum_reglee($year); @@ -358,14 +358,14 @@ class Localtax extends CommonObject return $solde; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Total de la localtax des factures emises par la societe. * * @param int $year Year * @return int ??? */ - function localtax_sum_collectee($year = 0) + public function localtax_sum_collectee($year = 0) { // phpcs:enable $sql = "SELECT sum(f.localtax) as amount"; @@ -398,14 +398,14 @@ class Localtax extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * localtax payed * * @param int $year Year * @return int ??? */ - function localtax_sum_payee($year = 0) + public function localtax_sum_payee($year = 0) { // phpcs:enable @@ -440,7 +440,7 @@ class Localtax extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * localtax payed * Total de la localtax payed @@ -448,7 +448,7 @@ class Localtax extends CommonObject * @param int $year Year * @return int ??? */ - function localtax_sum_reglee($year = 0) + public function localtax_sum_reglee($year = 0) { // phpcs:enable @@ -489,7 +489,7 @@ class Localtax extends CommonObject * @param User $user Object user that insert * @return int <0 if KO, rowid in localtax table if OK */ - function addPayment($user) + public function addPayment($user) { global $conf,$langs; @@ -596,21 +596,20 @@ class Localtax extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update the link betwen localtax payment and the line into llx_bank * * @param int $id Id bank account * @return int <0 if KO, >0 if OK */ - function update_fk_bank($id) + public function update_fk_bank($id) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'localtax SET fk_bank = '.$id; $sql.= ' WHERE rowid = '.$this->id; $result = $this->db->query($sql); - if ($result) - { + if ($result) { return 1; } else @@ -628,7 +627,7 @@ class Localtax extends CommonObject * @param string $option Sur quoi pointe le lien * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '') + public function getNomUrl($withpicto = 0, $option = '') { global $langs; @@ -652,12 +651,12 @@ class Localtax extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -665,7 +664,7 @@ class Localtax extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index 2c4180c3858..15b006d2cc6 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -70,12 +70,12 @@ class RemiseCheque extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { $this->db = $db; $this->next_id = 0; $this->previous_id = 0; - } + } /** * Load record @@ -84,8 +84,8 @@ class RemiseCheque extends CommonObject * @param string $ref Ref record * @return int <0 if KO, > 0 if OK */ - function fetch($id, $ref = '') - { + public function fetch($id, $ref = '') + { global $conf; $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.ref, bc.statut, bc.nbcheque, bc.ref_ext"; @@ -131,7 +131,7 @@ class RemiseCheque extends CommonObject $this->error=$this->db->lasterror(); return -1; } - } + } /** * Create a receipt to send cheques @@ -142,8 +142,8 @@ class RemiseCheque extends CommonObject * @param array $toRemise array with cheques to remise * @return int <0 if KO, >0 if OK */ - function create($user, $account_id, $limit, $toRemise) - { + public function create($user, $account_id, $limit, $toRemise) + { global $conf; $this->errno = 0; @@ -299,8 +299,8 @@ class RemiseCheque extends CommonObject * @param User $user Utilisateur qui effectue l'operation * @return int */ - function delete($user = '') - { + public function delete($user = '') + { global $conf; $this->errno = 0; @@ -353,8 +353,8 @@ class RemiseCheque extends CommonObject * @param User $user User * @return int <0 if KO, >0 if OK */ - function validate($user) - { + public function validate($user) + { global $langs,$conf; $this->errno = 0; @@ -416,8 +416,8 @@ class RemiseCheque extends CommonObject * @param string $mode 'next' for next value or 'last' for last value * @return string free ref or last ref */ - function getNextNumRef($mode = 'next') - { + public function getNextNumRef($mode = 'next') + { global $conf, $db, $langs, $mysoc; $langs->load("bills"); @@ -492,18 +492,18 @@ class RemiseCheque extends CommonObject print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); return ""; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Objet user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) - { + public function load_board($user) + { // phpcs:enable global $conf, $langs; @@ -547,17 +547,17 @@ class RemiseCheque extends CommonObject $this->error=$this->db->error(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 if ko, >0 if ok */ - function load_state_board() - { + public function load_state_board() + { // phpcs:enable global $user; @@ -588,7 +588,7 @@ class RemiseCheque extends CommonObject $this->error=$this->db->error(); return -1; } - } + } /** @@ -598,8 +598,8 @@ class RemiseCheque extends CommonObject * @param Translate $outputlangs Object langs * @return int <0 if KO, >0 if OK */ - function generatePdf($model, $outputlangs) - { + public function generatePdf($model, $outputlangs) + { global $langs,$conf; if (empty($model)) $model='blochet'; @@ -675,15 +675,15 @@ class RemiseCheque extends CommonObject $this->error=$langs->trans("ErrorFileDoesNotExists", $dir.$file); return -1; } - } + } /** * Mets a jour le montant total * * @return int 0 en cas de succes */ - function updateAmount() - { + public function updateAmount() + { global $conf; $this->errno = 0; @@ -735,7 +735,7 @@ class RemiseCheque extends CommonObject } return $this->errno; - } + } /** * Insere la remise en base @@ -743,8 +743,8 @@ class RemiseCheque extends CommonObject * @param int $account_id Compte bancaire concerne * @return int */ - function removeCheck($account_id) - { + public function removeCheck($account_id) + { $this->errno = 0; if ($this->id > 0) @@ -766,7 +766,7 @@ class RemiseCheque extends CommonObject } } return 0; - } + } /** * Check return management @@ -776,8 +776,8 @@ class RemiseCheque extends CommonObject * @param date $rejection_date Date to use on the negative payment * @return int Id of negative payment line created */ - function rejectCheck($bank_id, $rejection_date) - { + public function rejectCheck($bank_id, $rejection_date) + { global $db, $user; $payment = new Paiement($db); @@ -866,14 +866,14 @@ class RemiseCheque extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge les proprietes ref_previous et ref_next * * @return int <0 if KO, 0 if OK */ - function load_previous_next_id() - { + public function load_previous_next_id() + { // phpcs:enable global $conf; @@ -909,7 +909,7 @@ class RemiseCheque extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the creation date * @@ -917,7 +917,7 @@ class RemiseCheque extends CommonObject * @param int $date Date creation * @return int <0 if KO, >0 if OK */ - function set_date($user, $date) + public function set_date($user, $date) { // phpcs:enable if ($user->rights->banque->cheque) @@ -945,7 +945,7 @@ class RemiseCheque extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the ref of bordereau * @@ -953,8 +953,8 @@ class RemiseCheque extends CommonObject * @param int $ref ref of bordereau * @return int <0 if KO, >0 if OK */ - function set_number($user, $ref) - { + public function set_number($user, $ref) + { // phpcs:enable if ($user->rights->banque->cheque) { @@ -988,8 +988,8 @@ class RemiseCheque extends CommonObject * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') - { + public function initAsSpecimen($option = '') + { global $user,$langs,$conf; $now=dol_now(); @@ -1001,7 +1001,7 @@ class RemiseCheque extends CommonObject $this->ref = 'SPECIMEN'; $this->specimen=1; $this->date_bordereau = $nownotime; - } + } /** * Return clicable name (with picto eventually) @@ -1013,8 +1013,8 @@ class RemiseCheque extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { global $conf, $langs; $result=''; @@ -1056,7 +1056,7 @@ class RemiseCheque extends CommonObject $result .= $linkend; return $result; - } + } /** * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) @@ -1064,12 +1064,12 @@ class RemiseCheque extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - function getLibStatut($mode = 0) - { - return $this->LibStatut($this->statut, $mode); - } + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->statut, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1077,46 +1077,46 @@ class RemiseCheque extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @return string Libelle du statut */ - function LibStatut($status, $mode = 0) - { + public function LibStatut($status, $mode = 0) + { // phpcs:enable global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage $langs->load('compta'); if ($mode == 0) { if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); + elseif ($status == 1) return $langs->trans('Validated'); } elseif ($mode == 1) { if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); + elseif ($status == 1) return $langs->trans('Validated'); } elseif ($mode == 2) { if ($status == 0) return img_picto($langs->trans('ToValidate'), 'statut0').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'), 'statut4').' '.$langs->trans('Validated'); + elseif ($status == 1) return img_picto($langs->trans('Validated'), 'statut4').' '.$langs->trans('Validated'); } elseif ($mode == 3) { if ($status == 0) return img_picto($langs->trans('ToValidate'), 'statut0'); - if ($status == 1) return img_picto($langs->trans('Validated'), 'statut4'); + elseif ($status == 1) return img_picto($langs->trans('Validated'), 'statut4'); } elseif ($mode == 4) { if ($status == 0) return img_picto($langs->trans('ToValidate'), 'statut0').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'), 'statut4').' '.$langs->trans('Validated'); + elseif ($status == 1) return img_picto($langs->trans('Validated'), 'statut4').' '.$langs->trans('Validated'); } elseif ($mode == 5) { if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'), 'statut0'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'), 'statut4'); + elseif ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'), 'statut4'); } elseif ($mode == 6) { if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'), 'statut0'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'), 'statut4'); + elseif ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'), 'statut4'); } return $langs->trans('Unknown'); - } + } } diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index 7307b3e1601..13b04854b9c 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -225,7 +225,7 @@ class Paiement extends CommonObject * @param Societe $thirdparty Thirdparty * @return int id of created payment, < 0 if error */ - function create($user, $closepaidinvoices = 0, $thirdparty = null) + public function create($user, $closepaidinvoices = 0, $thirdparty = null) { global $conf, $langs; @@ -497,7 +497,7 @@ class Paiement extends CommonObject * @param int $notrigger No trigger * @return int <0 si ko, >0 si ok */ - function delete($notrigger = 0) + public function delete($notrigger = 0) { global $conf, $user, $langs; @@ -607,7 +607,7 @@ class Paiement extends CommonObject * @param int $notrigger No trigger * @return int <0 if KO, bank_line_id if OK */ - function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0) { global $conf,$langs,$user; @@ -730,9 +730,8 @@ class Paiement extends CommonObject } // Add link 'WithdrawalPayment' in bank_url - if (! $error && $label == '(WithdrawalPayment)') - { - $result=$acc->add_url_line( + if (! $error && $label == '(WithdrawalPayment)') { + $result=$acc->add_url_line( $bank_line_id, $this->id_prelevement, DOL_URL_ROOT.'/compta/prelevement/card.php?id=', @@ -776,14 +775,14 @@ class Paiement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour du lien entre le paiement et la ligne generee dans llx_bank * * @param int $id_bank Id compte bancaire * @return int <0 if KO, >0 if OK */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' set fk_bank = '.$id_bank; @@ -801,16 +800,16 @@ class Paiement extends CommonObject dol_syslog(get_class($this).'::update_fk_bank '.$this->error); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Updates the payment date * * @param int $date New date * @return int <0 if KO, 0 if OK */ - function update_date($date) + public function update_date($date) { // phpcs:enable $error=0; @@ -868,18 +867,17 @@ class Paiement extends CommonObject return -1; //no date given or already validated } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Updates the payment number * * @param string $num New num * @return int <0 if KO, 0 if OK */ - function update_num($num) + public function update_num($num) { // phpcs:enable - if(!empty($num) && $this->statut!=1) - { + if(!empty($num) && $this->statut!=1) { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql.= " SET num_paiement = '".$this->db->escape($num)."'"; $sql.= " WHERE rowid = ".$this->id; @@ -906,8 +904,8 @@ class Paiement extends CommonObject * @param User $user User making validation * @return int <0 if KO, >0 if OK */ - function valide(User $user = null) - { + public function valide(User $user = null) + { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 1 WHERE rowid = '.$this->id; dol_syslog(get_class($this).'::valide', LOG_DEBUG); @@ -922,7 +920,7 @@ class Paiement extends CommonObject dol_syslog(get_class($this).'::valide '.$this->error); return -1; } - } + } /** * Reject payment @@ -930,8 +928,8 @@ class Paiement extends CommonObject * @param User $user User making reject * @return int <0 if KO, >0 if OK */ - function reject(User $user = null) - { + public function reject(User $user = null) + { $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element.' SET statut = 2 WHERE rowid = '.$this->id; dol_syslog(get_class($this).'::reject', LOG_DEBUG); @@ -946,7 +944,7 @@ class Paiement extends CommonObject dol_syslog(get_class($this).'::reject '.$this->error); return -1; } - } + } /** * Information sur l'objet @@ -954,8 +952,8 @@ class Paiement extends CommonObject * @param int $id id du paiement dont il faut afficher les infos * @return void */ - function info($id) - { + public function info($id) + { $sql = 'SELECT p.rowid, p.datec, p.fk_user_creat, p.fk_user_modif, p.tms'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement as p'; $sql.= ' WHERE p.rowid = '.$id; @@ -990,7 +988,7 @@ class Paiement extends CommonObject { dol_print_error($this->db); } - } + } /** * Retourne la liste des factures sur lesquels porte le paiement @@ -998,8 +996,8 @@ class Paiement extends CommonObject * @param string $filter Critere de filtre * @return array Tableau des id de factures */ - function getBillsArray($filter = '') - { + public function getBillsArray($filter = '') + { $sql = 'SELECT fk_facture'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiement_facture as pf, '.MAIN_DB_PREFIX.'facture as f'; $sql.= ' WHERE pf.fk_facture = f.rowid AND fk_paiement = '.$this->id; @@ -1026,7 +1024,7 @@ class Paiement extends CommonObject dol_syslog(get_class($this).'::getBillsArray Error '.$this->error.' -', LOG_DEBUG); return -1; } - } + } /** * Return next reference of customer invoice not already used (or last reference) @@ -1036,7 +1034,7 @@ class Paiement extends CommonObject * @param string $mode 'next' for next value or 'last' for last value * @return string free ref or last ref */ - function getNextNumRef($soc, $mode = 'next') + public function getNextNumRef($soc, $mode = 'next') { global $conf, $db, $langs; $langs->load("bills"); @@ -1119,7 +1117,7 @@ class Paiement extends CommonObject * * @return string 'dolibarr' if standard comportment or paid in main currency, 'customer' if payment received from multicurrency inputs */ - function getWay() + public function getWay() { global $conf; @@ -1147,7 +1145,7 @@ class Paiement extends CommonObject * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') + public function initAsSpecimen($option = '') { global $user,$langs,$conf; @@ -1173,7 +1171,7 @@ class Paiement extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0) { global $conf, $langs; @@ -1231,12 +1229,12 @@ class Paiement extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1244,7 +1242,7 @@ class Paiement extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage @@ -1288,14 +1286,14 @@ class Paiement extends CommonObject return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the third party of object, from id into this->thirdparty * * @param int $force_thirdparty_id Force thirdparty id * @return int <0 if KO, >0 if OK */ - function fetch_thirdparty($force_thirdparty_id = 0) + public function fetch_thirdparty($force_thirdparty_id = 0) { // phpcs:enable include_once DOL_DOCUMENT_ROOT . '/compta/facture/class/facture.class.php'; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 16c7c2f3f52..142dd1b0e1e 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -81,7 +81,7 @@ class BonPrelevement extends CommonObject * @param DoliDB $db Database handler * @param string $filename Filename of withdraw receipt */ - function __construct($db, $filename = '') + public function __construct($db, $filename = '') { global $conf,$langs; @@ -112,7 +112,7 @@ class BonPrelevement extends CommonObject $this->fetched = 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add invoice to withdrawal * @@ -126,7 +126,7 @@ class BonPrelevement extends CommonObject * @param string $number_key number key of account number * @return int >0 if OK, <0 if KO */ - function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) + public function AddFacture($facture_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) { // phpcs:enable $result = 0; @@ -184,7 +184,7 @@ class BonPrelevement extends CommonObject * @param string $number_key number key of account number * @return int >0 if OK, <0 if KO */ - function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) + public function addline(&$line_id, $client_id, $client_nom, $amount, $code_banque, $code_guichet, $number, $number_key) { $result = -1; $concat = 0; @@ -258,7 +258,7 @@ class BonPrelevement extends CommonObject * @param int $error Id of error * @return string Error string */ - function getErrorString($error) + public function getErrorString($error) { global $langs; @@ -276,7 +276,7 @@ class BonPrelevement extends CommonObject * @param string $ref Ref of direct debit * @return int >0 if OK, <0 if KO */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { global $conf; @@ -300,20 +300,20 @@ class BonPrelevement extends CommonObject { $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - $this->ref = $obj->ref; - $this->amount = $obj->amount; - $this->note = $obj->note; - $this->datec = $this->db->jdate($obj->dc); + $this->id = $obj->rowid; + $this->ref = $obj->ref; + $this->amount = $obj->amount; + $this->note = $obj->note; + $this->datec = $this->db->jdate($obj->dc); - $this->date_trans = $this->db->jdate($obj->date_trans); - $this->method_trans = $obj->method_trans; - $this->user_trans = $obj->fk_user_trans; + $this->date_trans = $this->db->jdate($obj->date_trans); + $this->method_trans = $obj->method_trans; + $this->user_trans = $obj->fk_user_trans; - $this->date_credit = $this->db->jdate($obj->date_credit); - $this->user_credit = $obj->fk_user_credit; + $this->date_credit = $this->db->jdate($obj->date_credit); + $this->user_credit = $obj->fk_user_credit; - $this->statut = $obj->statut; + $this->statut = $obj->statut; $this->fetched = 1; @@ -331,13 +331,13 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set credite and set status of linked invoices. Still used ?? * * @return int <0 if KO, >=0 if OK */ - function set_credite() + public function set_credite() { // phpcs:enable global $user,$conf; @@ -410,7 +410,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set direct debit order to "credited" status. * @@ -418,7 +418,7 @@ class BonPrelevement extends CommonObject * @param int $date date of action * @return int >0 if OK, <0 if KO */ - function set_infocredit($user, $date) + public function set_infocredit($user, $date) { // phpcs:enable global $conf,$langs; @@ -557,7 +557,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set withdrawal to transmited status * @@ -566,7 +566,7 @@ class BonPrelevement extends CommonObject * @param string $method method of transmision to bank * @return int >0 if OK, <0 if KO */ - function set_infotrans($user, $date, $method) + public function set_infotrans($user, $date, $method) { // phpcs:enable global $conf,$langs; @@ -683,13 +683,13 @@ class BonPrelevement extends CommonObject return $arr; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns amount of withdrawal * * @return double Total amount */ - function SommeAPrelever() + public function SommeAPrelever() { // phpcs:enable global $conf; @@ -722,7 +722,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get number of invoices to withdrawal * TODO delete params banque and agence when not necesary @@ -731,7 +731,7 @@ class BonPrelevement extends CommonObject * @param int $agence dolibarr mysoc agence * @return int 0 if OK, <0 if KO */ - function delete($user = null) + public function delete($user = null) { $this->db->begin(); @@ -1178,7 +1178,7 @@ class BonPrelevement extends CommonObject * @param string $option link target * @return string URL of target */ - function getNomUrl($withpicto = 0, $option = '') + public function getNomUrl($withpicto = 0, $option = '') { global $langs; @@ -1200,14 +1200,14 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a notification def by id * * @param int $rowid id of notification * @return int 0 if OK, <0 if KO */ - function DeleteNotificationById($rowid) + public function DeleteNotificationById($rowid) { // phpcs:enable $result = 0; @@ -1225,7 +1225,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a notification * @@ -1233,7 +1233,7 @@ class BonPrelevement extends CommonObject * @param string $action notification action * @return int >0 if OK, <0 if KO */ - function DeleteNotification($user, $action) + public function DeleteNotification($user, $action) { // phpcs:enable $result = 0; @@ -1251,7 +1251,7 @@ class BonPrelevement extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a notification * @@ -1260,7 +1260,7 @@ class BonPrelevement extends CommonObject * @param string $action notification action * @return int 0 if OK, <0 if KO */ - function AddNotification($db, $user, $action) + public function AddNotification($db, $user, $action) { // phpcs:enable $result = 0; @@ -1299,7 +1299,7 @@ class BonPrelevement extends CommonObject * @param string $executiondate Date to execute transfer * @return int 0 if OK, <0 if KO */ - function generate($format = 'ALL', $executiondate = '') + public function generate($format = 'ALL', $executiondate = '') { global $conf,$langs,$mysoc; @@ -1478,7 +1478,7 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write recipient of request (customer) * @@ -1493,7 +1493,7 @@ class BonPrelevement extends CommonObject * @param string $rib_dom rib domiciliation * @return void */ - function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom = '') + public function EnregDestinataire($rowid, $client_nom, $rib_banque, $rib_guichet, $rib_number, $amount, $ref, $facid, $rib_dom = '') { // phpcs:enable fputs($this->file, "06"); @@ -1559,14 +1559,14 @@ class BonPrelevement extends CommonObject * @param string $row_drum Id of customer bank account (rib.rowid) * @return string RUM number */ - static function buildRumNumber($row_code_client, $row_datec, $row_drum) + public static function buildRumNumber($row_code_client, $row_datec, $row_drum) { global $langs; $pre = $langs->trans('RUM').'-'; return $pre.$row_code_client.'-'.$row_drum.'-'.date('U', $row_datec); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write recipient of request (customer) * @@ -1588,7 +1588,7 @@ class BonPrelevement extends CommonObject * @param string $row_drum rib.rowid used to generate rum * @return string Return string with SEPA part DrctDbtTxInf */ - function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum) + public function EnregDestinataireSEPA($row_code_client, $row_nom, $row_address, $row_zip, $row_town, $row_country_code, $row_cb, $row_cg, $row_cc, $row_somme, $row_ref, $row_idfac, $row_iban, $row_bic, $row_datec, $row_drum) { // phpcs:enable global $conf; @@ -1646,13 +1646,13 @@ class BonPrelevement extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write sender of request (me) * * @return void */ - function EnregEmetteur() + public function EnregEmetteur() { // phpcs:enable fputs($this->file, "03"); @@ -1713,7 +1713,7 @@ class BonPrelevement extends CommonObject fputs($this->file, "\n"); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write sender of request (me). * Note: The tag PmtInf is opened here but closed into caller @@ -1726,7 +1726,7 @@ class BonPrelevement extends CommonObject * @param string $format FRST or RCUR or ALL * @return string String with SEPA Sender */ - function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST') + public function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf = '\n', $format = 'FRST') { // phpcs:enable // SEPA INITIALISATION @@ -1836,14 +1836,14 @@ class BonPrelevement extends CommonObject return $XML_SEPA_INFO; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write end * * @param int $total total amount * @return void */ - function EnregTotal($total) + public function EnregTotal($total) { // phpcs:enable fputs($this->file, "08"); @@ -1905,12 +1905,12 @@ class BonPrelevement extends CommonObject * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return status label for a status * @@ -1918,7 +1918,7 @@ class BonPrelevement extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable if (empty($this->labelstatut)) @@ -1937,32 +1937,32 @@ class BonPrelevement extends CommonObject elseif ($mode == 2) { if ($statut==0) return img_picto($this->labelstatut[$statut], 'statut1').' '.$this->labelstatut[$statut]; - if ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3').' '.$this->labelstatut[$statut]; - if ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut]; + elseif ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3').' '.$this->labelstatut[$statut]; + elseif ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut]; } elseif ($mode == 3) { if ($statut==0) return img_picto($this->labelstatut[$statut], 'statut1'); - if ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3'); - if ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6'); + elseif ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3'); + elseif ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6'); } elseif ($mode == 4) { if ($statut==0) return img_picto($this->labelstatut[$statut], 'statut1').' '.$this->labelstatut[$statut]; - if ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3').' '.$this->labelstatut[$statut]; - if ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut]; + elseif ($statut==1) return img_picto($this->labelstatut[$statut], 'statut3').' '.$this->labelstatut[$statut]; + elseif ($statut==2) return img_picto($this->labelstatut[$statut], 'statut6').' '.$this->labelstatut[$statut]; } elseif ($mode == 5) { if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut1'); - if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut3'); - if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6'); + elseif ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut3'); + elseif ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6'); } elseif ($mode == 6) { if ($statut==0) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut1'); - if ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut3'); - if ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6'); + elseif ($statut==1) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut3'); + elseif ($statut==2) return $this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], 'statut6'); } } } diff --git a/htdocs/compta/prelevement/class/ligneprelevement.class.php b/htdocs/compta/prelevement/class/ligneprelevement.class.php index 6f9d50ceb07..e76cc9d184d 100644 --- a/htdocs/compta/prelevement/class/ligneprelevement.class.php +++ b/htdocs/compta/prelevement/class/ligneprelevement.class.php @@ -41,7 +41,7 @@ class LignePrelevement */ public $db; - var $statuts = array(); + public $statuts = array(); /** @@ -50,7 +50,7 @@ class LignePrelevement * @param DoliDb $db Database handler * @param User $user Objet user */ - function __construct($db, $user) + public function __construct($db, $user) { global $conf,$langs; @@ -71,7 +71,7 @@ class LignePrelevement * @param int $rowid id de la facture a recuperer * @return integer */ - function fetch($rowid) + public function fetch($rowid) { global $conf; @@ -117,18 +117,18 @@ class LignePrelevement return $result; } -/** + /** * Return status label of object * * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return status label for a status * @@ -136,7 +136,7 @@ class LignePrelevement * @param int $mode 0=Label, 1=Picto + label, 2=Picto, 3=Label + Picto * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -148,20 +148,20 @@ class LignePrelevement elseif ($mode == 1) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut1').' '.$langs->trans($this->statuts[$statut]); // Waiting - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); // Credited - if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); // Refused + elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6').' '.$langs->trans($this->statuts[$statut]); // Credited + elseif ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); // Refused } elseif ($mode == 2) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - if ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut6'); + elseif ($statut==3) return img_picto($langs->trans($this->statuts[$statut]), 'statut8'); } elseif ($mode == 3) { if ($statut==0) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut1'); - if ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); - if ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + elseif ($statut==2) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut6'); + elseif ($statut==3) return $langs->trans($this->statuts[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut8'); } } diff --git a/htdocs/compta/prelevement/class/rejetprelevement.class.php b/htdocs/compta/prelevement/class/rejetprelevement.class.php index f0df56fbec1..27dfe40a74f 100644 --- a/htdocs/compta/prelevement/class/rejetprelevement.class.php +++ b/htdocs/compta/prelevement/class/rejetprelevement.class.php @@ -47,7 +47,7 @@ class RejetPrelevement * @param DoliDb $db Database handler * @param User $user Objet user */ - function __construct($db, $user) + public function __construct($db, $user) { global $langs; @@ -82,7 +82,7 @@ class RejetPrelevement * @param int $facturation Facturation * @return void */ - function create($user, $id, $motif, $date_rejet, $bonid, $facturation = 0) + public function create($user, $id, $motif, $date_rejet, $bonid, $facturation = 0) { global $langs,$conf; @@ -198,14 +198,14 @@ class RejetPrelevement } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Send email to all users that has asked the withdraw request * * @param Facture $fac Invoice object * @return void */ - function _send_email($fac) + private function _send_email($fac) { // phpcs:enable global $langs; @@ -334,7 +334,7 @@ class RejetPrelevement * @param int $rowid id of invoice to retrieve * @return int */ - function fetch($rowid) + public function fetch($rowid) { $sql = "SELECT pr.date_rejet as dr, motif, afacturer"; diff --git a/htdocs/compta/salaries/class/paymentsalary.class.php b/htdocs/compta/salaries/class/paymentsalary.class.php index aad1d9d6e91..40cec40ecad 100644 --- a/htdocs/compta/salaries/class/paymentsalary.class.php +++ b/htdocs/compta/salaries/class/paymentsalary.class.php @@ -31,681 +31,681 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; */ class PaymentSalary extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element='payment_salary'; + /** + * @var string ID to identify managed object + */ + public $element='payment_salary'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='payment_salary'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element='payment_salary'; - /** - * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png - */ - public $picto='payment'; + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto='payment'; - public $tms; + public $tms; - /** - * @var int User ID - */ - public $fk_user; + /** + * @var int User ID + */ + public $fk_user; - public $datep; - public $datev; - public $amount; + public $datep; + public $datev; + public $amount; - /** + /** * @var int ID */ - public $fk_project; + public $fk_project; - public $type_payment; - public $num_payment; + public $type_payment; + public $num_payment; - /** + /** * @var string salary payments label */ public $label; - public $datesp; - public $dateep; + public $datesp; + public $dateep; - /** + /** * @var int ID */ - public $fk_bank; + public $fk_bank; - /** + /** * @var int ID */ - public $fk_user_author; + public $fk_user_author; - /** + /** * @var int ID */ - public $fk_user_modif; + public $fk_user_modif; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - $this->element = 'payment_salary'; - $this->table_element = 'payment_salary'; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + $this->element = 'payment_salary'; + $this->table_element = 'payment_salary'; + } - /** - * Update database - * - * @param User $user User that modify - * @param int $notrigger 0=no, 1=yes (no update trigger) - * @return int <0 if KO, >0 if OK - */ - function update($user = null, $notrigger = 0) - { - global $conf, $langs; + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=no, 1=yes (no update trigger) + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; - $error=0; + $error=0; - // Clean parameters - $this->fk_user=trim($this->fk_user); - $this->amount=trim($this->amount); - $this->label=trim($this->label); - $this->note=trim($this->note); - $this->fk_bank=trim($this->fk_bank); - $this->fk_user_author=trim($this->fk_user_author); - $this->fk_user_modif=trim($this->fk_user_modif); + // Clean parameters + $this->fk_user=trim($this->fk_user); + $this->amount=trim($this->amount); + $this->label=trim($this->label); + $this->note=trim($this->note); + $this->fk_bank=trim($this->fk_bank); + $this->fk_user_author=trim($this->fk_user_author); + $this->fk_user_modif=trim($this->fk_user_modif); - // Check parameters - if (empty($this->fk_user) || $this->fk_user < 0) - { - $this->error='ErrorBadParameter'; - return -1; - } + // Check parameters + if (empty($this->fk_user) || $this->fk_user < 0) + { + $this->error='ErrorBadParameter'; + return -1; + } - $this->db->begin(); + $this->db->begin(); - // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; - $sql.= " tms='".$this->db->idate($this->tms)."',"; - $sql.= " fk_user=".$this->fk_user.","; - $sql.= " datep='".$this->db->idate($this->datep)."',"; - $sql.= " datev='".$this->db->idate($this->datev)."',"; - $sql.= " amount=".price2num($this->amount).","; - $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; - $sql.= " fk_typepayment=".$this->fk_typepayment."',"; - $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; - $sql.= " label='".$this->db->escape($this->label)."',"; - $sql.= " datesp='".$this->db->idate($this->datesp)."',"; - $sql.= " dateep='".$this->db->idate($this->dateep)."',"; - $sql.= " note='".$this->db->escape($this->note)."',"; - $sql.= " fk_bank=".($this->fk_bank > 0 ? "'".$this->db->escape($this->fk_bank)."'":"null").","; - $sql.= " fk_user_author=".$this->fk_user_author.","; - $sql.= " fk_user_modif=".$this->fk_user_modif; + $sql.= " tms='".$this->db->idate($this->tms)."',"; + $sql.= " fk_user=".$this->fk_user.","; + $sql.= " datep='".$this->db->idate($this->datep)."',"; + $sql.= " datev='".$this->db->idate($this->datev)."',"; + $sql.= " amount=".price2num($this->amount).","; + $sql.= " fk_projet='".$this->db->escape($this->fk_project)."',"; + $sql.= " fk_typepayment=".$this->fk_typepayment."',"; + $sql.= " num_payment='".$this->db->escape($this->num_payment)."',"; + $sql.= " label='".$this->db->escape($this->label)."',"; + $sql.= " datesp='".$this->db->idate($this->datesp)."',"; + $sql.= " dateep='".$this->db->idate($this->dateep)."',"; + $sql.= " note='".$this->db->escape($this->note)."',"; + $sql.= " fk_bank=".($this->fk_bank > 0 ? "'".$this->db->escape($this->fk_bank)."'":"null").","; + $sql.= " fk_user_author=".$this->fk_user_author.","; + $sql.= " fk_user_modif=".$this->fk_user_modif; - $sql.= " WHERE rowid=".$this->id; + $sql.= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::update", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) - { - $this->error="Error ".$this->db->lasterror(); - return -1; - } + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } - if (! $notrigger) - { + if (! $notrigger) + { // Call trigger $result=$this->call_trigger('PAYMENT_SALARY_MODIFY', $user); if ($result < 0) $error++; // End call triggers - } + } - if (! $error) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - return -1; - } - } + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + $this->db->rollback(); + return -1; + } + } - /** - * Load object in memory from database - * - * @param int $id id object - * @param User $user User that load - * @return int <0 if KO, >0 if OK - */ - function fetch($id, $user = null) - { - global $langs; - $sql = "SELECT"; - $sql.= " s.rowid,"; + /** + * Load object in memory from database + * + * @param int $id id object + * @param User $user User that load + * @return int <0 if KO, >0 if OK + */ + public function fetch($id, $user = null) + { + global $langs; + $sql = "SELECT"; + $sql.= " s.rowid,"; - $sql.= " s.tms,"; - $sql.= " s.fk_user,"; - $sql.= " s.datep,"; - $sql.= " s.datev,"; - $sql.= " s.amount,"; - $sql.= " s.fk_projet as fk_project,"; - $sql.= " s.fk_typepayment,"; - $sql.= " s.num_payment,"; - $sql.= " s.label,"; - $sql.= " s.datesp,"; - $sql.= " s.dateep,"; - $sql.= " s.note,"; - $sql.= " s.fk_bank,"; - $sql.= " s.fk_user_author,"; - $sql.= " s.fk_user_modif,"; - $sql.= " b.fk_account,"; - $sql.= " b.fk_type,"; - $sql.= " b.rappro"; + $sql.= " s.tms,"; + $sql.= " s.fk_user,"; + $sql.= " s.datep,"; + $sql.= " s.datev,"; + $sql.= " s.amount,"; + $sql.= " s.fk_projet as fk_project,"; + $sql.= " s.fk_typepayment,"; + $sql.= " s.num_payment,"; + $sql.= " s.label,"; + $sql.= " s.datesp,"; + $sql.= " s.dateep,"; + $sql.= " s.note,"; + $sql.= " s.fk_bank,"; + $sql.= " s.fk_user_author,"; + $sql.= " s.fk_user_modif,"; + $sql.= " b.fk_account,"; + $sql.= " b.fk_type,"; + $sql.= " b.rappro"; - $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; - $sql.= " WHERE s.rowid = ".$id; + $sql.= " FROM ".MAIN_DB_PREFIX."payment_salary as s"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid"; + $sql.= " WHERE s.rowid = ".$id; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - if ($this->db->num_rows($resql)) - { - $obj = $this->db->fetch_object($resql); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->ref = $obj->rowid; - $this->tms = $this->db->jdate($obj->tms); - $this->fk_user = $obj->fk_user; - $this->datep = $this->db->jdate($obj->datep); - $this->datev = $this->db->jdate($obj->datev); - $this->amount = $obj->amount; - $this->fk_project = $obj->fk_project; - $this->type_payement = $obj->fk_typepayment; - $this->num_payment = $obj->num_payment; - $this->label = $obj->label; - $this->datesp = $this->db->jdate($obj->datesp); - $this->dateep = $this->db->jdate($obj->dateep); - $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; - $this->fk_user_author = $obj->fk_user_author; - $this->fk_user_modif = $obj->fk_user_modif; - $this->fk_account = $obj->fk_account; - $this->fk_type = $obj->fk_type; - $this->rappro = $obj->rappro; - } - $this->db->free($resql); + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + $this->tms = $this->db->jdate($obj->tms); + $this->fk_user = $obj->fk_user; + $this->datep = $this->db->jdate($obj->datep); + $this->datev = $this->db->jdate($obj->datev); + $this->amount = $obj->amount; + $this->fk_project = $obj->fk_project; + $this->type_payement = $obj->fk_typepayment; + $this->num_payment = $obj->num_payment; + $this->label = $obj->label; + $this->datesp = $this->db->jdate($obj->datesp); + $this->dateep = $this->db->jdate($obj->dateep); + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_modif = $obj->fk_user_modif; + $this->fk_account = $obj->fk_account; + $this->fk_type = $obj->fk_type; + $this->rappro = $obj->rappro; + } + $this->db->free($resql); - return 1; - } - else - { - $this->error="Error ".$this->db->lasterror(); - return -1; - } - } + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } - /** - * Delete object in database - * - * @param User $user User that delete - * @return int <0 if KO, >0 if OK - */ - function delete($user) - { - global $conf, $langs; + /** + * Delete object in database + * + * @param User $user User that delete + * @return int <0 if KO, >0 if OK + */ + public function delete($user) + { + global $conf, $langs; - $error=0; + $error=0; - // Call trigger - $result=$this->call_trigger('PAYMENT_SALARY_DELETE', $user); - if ($result < 0) return -1; - // End call triggers + // Call trigger + $result=$this->call_trigger('PAYMENT_SALARY_DELETE', $user); + if ($result < 0) return -1; + // End call triggers - $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; - $sql.= " WHERE rowid=".$this->id; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; + $sql.= " WHERE rowid=".$this->id; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) - { - $this->error="Error ".$this->db->lasterror(); - return -1; - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } - return 1; - } + return 1; + } - /** - * Initialise an instance with random values. - * Used to build previews or test instances. - * id must be 0 if object instance is a specimen. - * - * @return void - */ - function initAsSpecimen() - { - $this->id=0; + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + $this->id=0; - $this->tms=''; - $this->fk_user=''; - $this->datep=''; - $this->datev=''; - $this->amount=''; - $this->label=''; - $this->datesp=''; - $this->dateep=''; - $this->note=''; - $this->fk_bank=''; - $this->fk_user_author=''; - $this->fk_user_modif=''; - } + $this->tms=''; + $this->fk_user=''; + $this->datep=''; + $this->datev=''; + $this->amount=''; + $this->label=''; + $this->datesp=''; + $this->dateep=''; + $this->note=''; + $this->fk_bank=''; + $this->fk_user_author=''; + $this->fk_user_modif=''; + } - /** - * Create in database - * - * @param User $user User that create - * @return int <0 if KO, >0 if OK - */ - function create($user) - { - global $conf,$langs; + /** + * Create in database + * + * @param User $user User that create + * @return int <0 if KO, >0 if OK + */ + public function create($user) + { + global $conf,$langs; - $error=0; - $now=dol_now(); + $error=0; + $now=dol_now(); - // Clean parameters - $this->amount=price2num(trim($this->amount)); - $this->label=trim($this->label); - $this->note=trim($this->note); - $this->fk_bank=trim($this->fk_bank); - $this->fk_user_author=trim($this->fk_user_author); - $this->fk_user_modif=trim($this->fk_user_modif); + // Clean parameters + $this->amount=price2num(trim($this->amount)); + $this->label=trim($this->label); + $this->note=trim($this->note); + $this->fk_bank=trim($this->fk_bank); + $this->fk_user_author=trim($this->fk_user_author); + $this->fk_user_modif=trim($this->fk_user_modif); - // Check parameters - if (! $this->label) - { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); - return -3; - } - if ($this->fk_user < 0 || $this->fk_user == '') - { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); - return -4; - } - if ($this->amount < 0 || $this->amount == '') - { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); - return -5; - } - if (! empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) - { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); - return -6; - } - if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) - { - $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); - return -7; - } + // Check parameters + if (! $this->label) + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); + return -3; + } + if ($this->fk_user < 0 || $this->fk_user == '') + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); + return -4; + } + if ($this->amount < 0 || $this->amount == '') + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); + return -5; + } + if (! empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("Account")); + return -6; + } + if (! empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) + { + $this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")); + return -7; + } - $this->db->begin(); + $this->db->begin(); - // Insert into llx_payment_salary - $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; - $sql.= ", datep"; - $sql.= ", datev"; - $sql.= ", amount"; - $sql.= ", fk_projet"; - $sql.= ", salary"; - $sql.= ", fk_typepayment"; - $sql.= ", num_payment"; - if ($this->note) $sql.= ", note"; - $sql.= ", label"; - $sql.= ", datesp"; - $sql.= ", dateep"; - $sql.= ", fk_user_author"; - $sql.= ", datec"; - $sql.= ", fk_bank"; - $sql.= ", entity"; - $sql.= ") "; - $sql.= " VALUES ("; - $sql.= "'".$this->db->escape($this->fk_user)."'"; - $sql.= ", '".$this->db->idate($this->datep)."'"; - $sql.= ", '".$this->db->idate($this->datev)."'"; - $sql.= ", ".$this->amount; - $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0); - $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); - $sql.= ", ".$this->db->escape($this->type_payment); - $sql.= ", '".$this->db->escape($this->num_payment)."'"; - if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; - $sql.= ", '".$this->db->escape($this->label)."'"; - $sql.= ", '".$this->db->idate($this->datesp)."'"; - $sql.= ", '".$this->db->idate($this->dateep)."'"; - $sql.= ", '".$this->db->escape($user->id)."'"; - $sql.= ", '".$this->db->idate($now)."'"; - $sql.= ", NULL"; - $sql.= ", ".$conf->entity; - $sql.= ")"; + // Insert into llx_payment_salary + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_user"; + $sql.= ", datep"; + $sql.= ", datev"; + $sql.= ", amount"; + $sql.= ", fk_projet"; + $sql.= ", salary"; + $sql.= ", fk_typepayment"; + $sql.= ", num_payment"; + if ($this->note) $sql.= ", note"; + $sql.= ", label"; + $sql.= ", datesp"; + $sql.= ", dateep"; + $sql.= ", fk_user_author"; + $sql.= ", datec"; + $sql.= ", fk_bank"; + $sql.= ", entity"; + $sql.= ") "; + $sql.= " VALUES ("; + $sql.= "'".$this->db->escape($this->fk_user)."'"; + $sql.= ", '".$this->db->idate($this->datep)."'"; + $sql.= ", '".$this->db->idate($this->datev)."'"; + $sql.= ", ".$this->amount; + $sql.= ", ".($this->fk_project > 0? $this->fk_project : 0); + $sql.= ", ".($this->salary > 0 ? $this->salary : "null"); + $sql.= ", ".$this->db->escape($this->type_payment); + $sql.= ", '".$this->db->escape($this->num_payment)."'"; + if ($this->note) $sql.= ", '".$this->db->escape($this->note)."'"; + $sql.= ", '".$this->db->escape($this->label)."'"; + $sql.= ", '".$this->db->idate($this->datesp)."'"; + $sql.= ", '".$this->db->idate($this->dateep)."'"; + $sql.= ", '".$this->db->escape($user->id)."'"; + $sql.= ", '".$this->db->idate($now)."'"; + $sql.= ", NULL"; + $sql.= ", ".$conf->entity; + $sql.= ")"; - dol_syslog(get_class($this)."::create", LOG_DEBUG); - $result = $this->db->query($sql); - if ($result) - { + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); - if ($this->id > 0) - { - if (! empty($conf->banque->enabled) && ! empty($this->amount)) - { - // Insert into llx_bank - require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + if ($this->id > 0) + { + if (! empty($conf->banque->enabled) && ! empty($this->amount)) + { + // Insert into llx_bank + require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; - $acc = new Account($this->db); - $result=$acc->fetch($this->accountid); - if ($result <= 0) dol_print_error($this->db); + $acc = new Account($this->db); + $result=$acc->fetch($this->accountid); + if ($result <= 0) dol_print_error($this->db); - // Insert payment into llx_bank - // Add link 'payment_salary' in bank_url between payment and bank transaction - $bank_line_id = $acc->addline( - $this->datep, - $this->type_payment, - $this->label, - -abs($this->amount), - $this->num_payment, - '', - $user, - '', - '', - '', - $this->datev - ); + // Insert payment into llx_bank + // Add link 'payment_salary' in bank_url between payment and bank transaction + $bank_line_id = $acc->addline( + $this->datep, + $this->type_payment, + $this->label, + -abs($this->amount), + $this->num_payment, + '', + $user, + '', + '', + '', + $this->datev + ); - // Update fk_bank into llx_paiement. - // So we know the payment which has generate the banking ecriture - if ($bank_line_id > 0) - { - $this->update_fk_bank($bank_line_id); - } - else - { - $this->error=$acc->error; - $error++; - } + // Update fk_bank into llx_paiement. + // So we know the payment which has generate the banking ecriture + if ($bank_line_id > 0) + { + $this->update_fk_bank($bank_line_id); + } + else + { + $this->error=$acc->error; + $error++; + } - if (! $error) - { - // Add link 'payment_salary' in bank_url between payment and bank transaction - $url=DOL_URL_ROOT.'/compta/salaries/card.php?id='; + if (! $error) + { + // Add link 'payment_salary' in bank_url between payment and bank transaction + $url=DOL_URL_ROOT.'/compta/salaries/card.php?id='; - $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); - if ($result <= 0) - { - $this->error=$acc->error; - $error++; - } - } + $result=$acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary"); + if ($result <= 0) + { + $this->error=$acc->error; + $error++; + } + } - $fuser=new User($this->db); - $fuser->fetch($this->fk_user); + $fuser=new User($this->db); + $fuser->fetch($this->fk_user); - // Add link 'user' in bank_url between operation and bank transaction - $result=$acc->add_url_line( - $bank_line_id, - $this->fk_user, - DOL_URL_ROOT.'/user/card.php?id=', - $fuser->getFullName($langs), - // $langs->trans("SalaryPayment").' '.$fuser->getFullName($langs).' '.dol_print_date($this->datesp,'dayrfc').' '.dol_print_date($this->dateep,'dayrfc'), - 'user' - ); + // Add link 'user' in bank_url between operation and bank transaction + $result=$acc->add_url_line( + $bank_line_id, + $this->fk_user, + DOL_URL_ROOT.'/user/card.php?id=', + $fuser->getFullName($langs), + // $langs->trans("SalaryPayment").' '.$fuser->getFullName($langs).' '.dol_print_date($this->datesp,'dayrfc').' '.dol_print_date($this->dateep,'dayrfc'), + 'user' + ); - if ($result <= 0) - { - $this->error=$acc->error; - $error++; - } - } + if ($result <= 0) + { + $this->error=$acc->error; + $error++; + } + } - // Call trigger - $result=$this->call_trigger('PAYMENT_SALARY_CREATE', $user); - if ($result < 0) $error++; - // End call triggers - } - else $error++; + // Call trigger + $result=$this->call_trigger('PAYMENT_SALARY_CREATE', $user); + if ($result < 0) $error++; + // End call triggers + } + else $error++; - if (! $error) - { - $this->db->commit(); - return $this->id; - } - else - { - $this->db->rollback(); - return -2; - } - } - else - { - $this->error=$this->db->error(); - $this->db->rollback(); - return -1; - } - } + if (! $error) + { + $this->db->commit(); + return $this->id; + } + else + { + $this->db->rollback(); + return -2; + } + } + else + { + $this->error=$this->db->error(); + $this->db->rollback(); + return -1; + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Update link between payment salary and line generate into llx_bank - * - * @param int $id_bank Id bank account - * @return int <0 if KO, >0 if OK - */ - function update_fk_bank($id_bank) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Update link between payment salary and line generate into llx_bank + * + * @param int $id_bank Id bank account + * @return int <0 if KO, >0 if OK + */ + public function update_fk_bank($id_bank) + { // phpcs:enable - $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; - $sql.= ' WHERE rowid = '.$this->id; - $result = $this->db->query($sql); - if ($result) - { - return 1; - } - else - { - dol_print_error($this->db); - return -1; - } - } + $sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank; + $sql.= ' WHERE rowid = '.$this->id; + $result = $this->db->query($sql); + if ($result) + { + return 1; + } + else + { + dol_print_error($this->db); + return -1; + } + } - /** - * Send name clicable (with possibly the picto) - * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param string $option link option + /** + * Send name clicable (with possibly the picto) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param string $option link option * @param int $notooltip 1=Disable tooltip * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string Chaine with URL - */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs, $hookmanager; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + * @return string Chaine with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $result = ''; + $result = ''; - $label = '' . $langs->trans("ShowSalaryPayment") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; + $label = '' . $langs->trans("ShowSalaryPayment") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref; - $url = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/compta/salaries/card.php?id='.$this->id; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; - } + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } - $linkclose=''; - if (empty($notooltip)) - { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowMyObject"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - /* - $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ - } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + /* + $hookmanager->initHooks(array('myobjectdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $linkclose = $hookmanager->resPrint; + */ + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); - $linkstart = ''; - $linkend=''; + $linkstart = ''; + $linkend=''; - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; - $hookmanager->initHooks(array('salarypayment')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + global $action,$hookmanager; + $hookmanager->initHooks(array('salarypayment')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; - return $result; - } + return $result; + } - /** - * Information on record - * - * @param int $id Id of record - * @return void - */ - function info($id) - { - $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; - $sql.= ' WHERE ps.rowid = '.$id; + /** + * Information on record + * + * @param int $id Id of record + * @return void + */ + public function info($id) + { + $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_salary as ps'; + $sql.= ' WHERE ps.rowid = '.$id; - dol_syslog(get_class($this).'::info', LOG_DEBUG); - $result = $this->db->query($sql); + dol_syslog(get_class($this).'::info', LOG_DEBUG); + $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } - $this->date_creation = $this->db->jdate($obj->datec); - } - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + $this->date_creation = $this->db->jdate($obj->datec); + } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } - /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle - */ - function getLibStatut($mode = 0) - { - return $this->LibStatut($this->statut, $mode); - } + /** + * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->statut, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $status Statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut - */ - function LibStatut($status, $mode = 0) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle du statut + */ + public function LibStatut($status, $mode = 0) + { // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage - $langs->load('compta'); - /*if ($mode == 0) - { - if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); - } - if ($mode == 1) - { - if ($status == 0) return $langs->trans('ToValidate'); - if ($status == 1) return $langs->trans('Validated'); - } - if ($mode == 2) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); - } - if ($mode == 3) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); - } - if ($mode == 4) - { - if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); - if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); - } - if ($mode == 5) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); - } - if ($mode == 6) - { - if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); - if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); - }*/ - return ''; - } + $langs->load('compta'); + /*if ($mode == 0) + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 1) + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 2) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 3) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 4) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 5) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 6) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + }*/ + return ''; + } } diff --git a/htdocs/compta/salaries/class/salariesstats.class.php b/htdocs/compta/salaries/class/salariesstats.class.php index c1249abedac..0287f4978df 100644 --- a/htdocs/compta/salaries/class/salariesstats.class.php +++ b/htdocs/compta/salaries/class/salariesstats.class.php @@ -29,138 +29,137 @@ include_once DOL_DOCUMENT_ROOT . '/compta/salaries/class/paymentsalary.class.php */ class SalariesStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param int $socid Id third party - * @param mixed $userid Id user for filter or array of user ids - * @return void - */ - function __construct($db, $socid = 0, $userid = 0) - { - global $conf; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param int $socid Id third party + * @param mixed $userid Id user for filter or array of user ids + * @return void + */ + public function __construct($db, $socid = 0, $userid = 0) + { + global $conf; - $this->db = $db; - $this->socid = $socid; - $this->userid = $userid; + $this->db = $db; + $this->socid = $socid; + $this->userid = $userid; - $object=new PaymentSalary($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element; - $this->field='amount'; + $object=new PaymentSalary($this->db); + $this->from = MAIN_DB_PREFIX.$object->table_element; + $this->field='amount'; - $this->where.= " entity = ".$conf->entity; - if ($this->socid) - { - $this->where.=" AND fk_soc = ".$this->socid; - } - if (is_array($this->userid) && count($this->userid) > 0) $this->where.=' AND fk_user IN ('.join(',', $this->userid).')'; - elseif ($this->userid > 0) $this->where.=' AND fk_user = '.$this->userid; - } + $this->where.= " entity = ".$conf->entity; + if ($this->socid) { + $this->where.=" AND fk_soc = ".$this->socid; + } + if (is_array($this->userid) && count($this->userid) > 0) $this->where.=' AND fk_user IN ('.join(',', $this->userid).')'; + elseif ($this->userid > 0) $this->where.=' AND fk_user = '.$this->userid; + } - /** - * Return the number of salary by year - * - * @return array Array of values - */ - function getNbByYear() - { - $sql = "SELECT YEAR(datep) as dm, count(*)"; - $sql.= " FROM ".$this->from; - $sql.= " GROUP BY dm DESC"; - $sql.= " WHERE ".$this->where; + /** + * Return the number of salary by year + * + * @return array Array of values + */ + public function getNbByYear() + { + $sql = "SELECT YEAR(datep) as dm, count(*)"; + $sql.= " FROM ".$this->from; + $sql.= " GROUP BY dm DESC"; + $sql.= " WHERE ".$this->where; - return $this->_getNbByYear($sql); - } + return $this->_getNbByYear($sql); + } - /** - * Return the number of salary by month, for a given year - * - * @param string $year Year to scan - * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @return array Array of values - */ - function getNbByMonth($year, $format = 0) - { - $sql = "SELECT MONTH(datep) as dm, count(*)"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE YEAR(datep) = ".$year; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + /** + * Return the number of salary by month, for a given year + * + * @param string $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array of values + */ + public function getNbByMonth($year, $format = 0) + { + $sql = "SELECT MONTH(datep) as dm, count(*)"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE YEAR(datep) = ".$year; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; + $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); - //var_dump($res);print '
'; - return $res; - } + $res=$this->_getNbByMonth($year, $sql, $format); + //var_dump($res);print '
'; + return $res; + } - /** - * Return amount of salaries by month for a given year - * - * @param int $year Year to scan - * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @return array Array of values - */ - function getAmountByMonth($year, $format = 0) - { - $sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(datep,'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + /** + * Return amount of salaries by month for a given year + * + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array of values + */ + public function getAmountByMonth($year, $format = 0) + { + $sql = "SELECT date_format(datep,'%m') as dm, sum(".$this->field.")"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE date_format(datep,'%Y') = '".$year."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; + $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); - //var_dump($res);print '
'; - return $res; - } + $res=$this->_getAmountByMonth($year, $sql, $format); + //var_dump($res);print '
'; + return $res; + } - /** - * Return average amount - * - * @param int $year Year to scan - * @return array Array of values - */ - function getAverageByMonth($year) - { - $sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE date_format(datep,'%Y') = '".$year."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; - $sql.= $this->db->order('dm', 'DESC'); + /** + * Return average amount + * + * @param int $year Year to scan + * @return array Array of values + */ + public function getAverageByMonth($year) + { + $sql = "SELECT date_format(datep,'%m') as dm, avg(".$this->field.")"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE date_format(datep,'%Y') = '".$year."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; + $sql.= $this->db->order('dm', 'DESC'); - return $this->_getAverageByMonth($year, $sql); - } + return $this->_getAverageByMonth($year, $sql); + } - /** - * Return nb, total and average - * - * @return array Array of values - */ - function getAllByYear() - { - $sql = "SELECT date_format(datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; - $sql.= $this->db->order('year', 'DESC'); + /** + * Return nb, total and average + * + * @return array Array of values + */ + public function getAllByYear() + { + $sql = "SELECT date_format(datep,'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; + $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index 49cf2ec4560..1cb304fe519 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -404,7 +404,7 @@ class Cchargesociales * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $langs, $conf, $db; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -438,12 +438,12 @@ class Cchargesociales * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un status donne * @@ -451,7 +451,7 @@ class Cchargesociales * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 8600e21b2ea..41c9555ccfc 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -81,7 +81,7 @@ class ChargeSociales extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -93,7 +93,7 @@ class ChargeSociales extends CommonObject * @param string $ref Ref * @return int <0 KO >0 OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { $sql = "SELECT cs.rowid, cs.date_ech"; $sql.= ", cs.libelle as lib, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; @@ -152,7 +152,7 @@ class ChargeSociales extends CommonObject * * @return boolean True or false */ - function check() + public function check() { $newamount=price2num($this->amount, 'MT'); @@ -172,7 +172,7 @@ class ChargeSociales extends CommonObject * @param User $user User making creation * @return int <0 if KO, id if OK */ - function create($user) + public function create($user) { global $conf; $error=0; @@ -182,8 +182,7 @@ class ChargeSociales extends CommonObject // Nettoyage parametres $newamount=price2num($this->amount, 'MT'); - if (!$this->check()) - { + if (!$this->check()) { $this->error="ErrorBadParameter"; return -2; } @@ -206,8 +205,7 @@ class ChargeSociales extends CommonObject dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { + if ($resql) { $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."chargesociales"); //dol_syslog("ChargesSociales::create this->id=".$this->id); @@ -238,7 +236,7 @@ class ChargeSociales extends CommonObject * @param User $user Object user making delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { $error=0; @@ -309,7 +307,7 @@ class ChargeSociales extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { $error=0; $this->db->begin(); @@ -365,7 +363,7 @@ class ChargeSociales extends CommonObject * @param int $year Year * @return number */ - function solde($year = 0) + public function solde($year = 0) { global $conf; @@ -399,14 +397,14 @@ class ChargeSociales extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag social contribution as payed completely * * @param User $user Object user making change * @return int <0 if KO, >0 if OK */ - function set_paid($user) + public function set_paid($user) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; @@ -417,14 +415,14 @@ class ChargeSociales extends CommonObject else return -1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove tag payed on social contribution * * @param User $user Object user making change * @return int <0 if KO, >0 if OK */ - function set_unpaid($user) + public function set_unpaid($user) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."chargesociales SET"; @@ -442,12 +440,12 @@ class ChargeSociales extends CommonObject * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ - function getLibStatut($mode = 0, $alreadypaid = -1) + public function getLibStatut($mode = 0, $alreadypaid = -1) { return $this->LibStatut($this->paye, $mode, $alreadypaid); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -456,7 +454,7 @@ class ChargeSociales extends CommonObject * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ - function LibStatut($statut, $mode = 0, $alreadypaid = -1) + public function LibStatut($statut, $mode = 0, $alreadypaid = -1) { // phpcs:enable global $langs; @@ -467,37 +465,37 @@ class ChargeSociales extends CommonObject if ($mode == 0 || $mode == 1) { if ($statut == 0) return $langs->trans("Unpaid"); - if ($statut == 1) return $langs->trans("Paid"); + elseif ($statut == 1) return $langs->trans("Paid"); } elseif ($mode == 2) { if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); } elseif ($mode == 3) { if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1'); - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); + elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6'); } elseif ($mode == 4) { if ($statut == 0 && $alreadypaid <= 0) return img_picto($langs->trans("Unpaid"), 'statut1').' '.$langs->trans("Unpaid"); - if ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); - if ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); + elseif ($statut == 0 && $alreadypaid > 0) return img_picto($langs->trans("BillStatusStarted"), 'statut3').' '.$langs->trans("BillStatusStarted"); + elseif ($statut == 1) return img_picto($langs->trans("Paid"), 'statut6').' '.$langs->trans("Paid"); } elseif ($mode == 5) { if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + elseif ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } elseif ($mode == 6) { if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1'); - if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); - if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); + elseif ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); + elseif ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); } else return "Error, mode/status not found"; @@ -514,7 +512,7 @@ class ChargeSociales extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with link */ - function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $short = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $short = 0, $save_lastsearch_value = -1) { global $langs, $conf, $user, $form; @@ -574,7 +572,7 @@ class ChargeSociales extends CommonObject * * @return int Amount of payment already done, <0 if KO */ - function getSommePaiement() + public function getSommePaiement() { $table='paiementcharge'; $field='fk_charge'; @@ -585,8 +583,7 @@ class ChargeSociales extends CommonObject dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { + if ($resql) { $amount=0; $obj = $this->db->fetch_object($resql); @@ -607,7 +604,7 @@ class ChargeSociales extends CommonObject * @param int $id Id of social contribution * @return int <0 if KO, >0 if OK */ - function info($id) + public function info($id) { $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; $sql.= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; @@ -663,7 +660,7 @@ class ChargeSociales extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { // Initialize parameters $this->id=0; diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 4969b8f9b79..0fe747d0a86 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -91,7 +91,7 @@ class PaymentSocialContribution extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -104,7 +104,7 @@ class PaymentSocialContribution extends CommonObject * @param int $closepaidcontrib 1=Also close payed contributions to paid, 0=Do nothing more * @return int <0 if KO, id of payment if OK */ - function create($user, $closepaidcontrib = 0) + public function create($user, $closepaidcontrib = 0) { global $conf, $langs; @@ -221,7 +221,7 @@ class PaymentSocialContribution extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -292,7 +292,7 @@ class PaymentSocialContribution extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -379,7 +379,7 @@ class PaymentSocialContribution extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -409,10 +409,10 @@ class PaymentSocialContribution extends CommonObject if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -422,8 +422,8 @@ class PaymentSocialContribution extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback if ($error) @@ -451,7 +451,7 @@ class PaymentSocialContribution extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -510,7 +510,7 @@ class PaymentSocialContribution extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -540,7 +540,7 @@ class PaymentSocialContribution extends CommonObject * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ - function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $conf; @@ -624,14 +624,14 @@ class PaymentSocialContribution extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank generee * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."paiementcharge SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; @@ -656,12 +656,12 @@ class PaymentSocialContribution extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -669,7 +669,7 @@ class PaymentSocialContribution extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage @@ -720,7 +720,7 @@ class PaymentSocialContribution extends CommonObject * @param int $maxlen Longueur max libelle * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; @@ -729,16 +729,15 @@ class PaymentSocialContribution extends CommonObject if (empty($this->ref)) $this->ref=$this->lib; $label = $langs->trans("ShowPayment").': '.$this->ref; - if (!empty($this->id)) - { - $link = ''; - $linkend=''; + if (!empty($this->id)) { + $link = ''; + $linkend=''; if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); - if ($withpicto && $withpicto != 2) $result.=' '; - if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend; - } + if ($withpicto && $withpicto != 2) $result.=' '; + if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref, $maxlen):$this->ref).$linkend; + } - return $result; - } + return $result; + } } diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index c66e19ea5f2..b1f99275c93 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -81,7 +81,7 @@ class Tva extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -93,7 +93,7 @@ class Tva extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -173,7 +173,7 @@ class Tva extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; @@ -241,7 +241,7 @@ class Tva extends CommonObject * @param User $user User that load * @return int <0 if KO, >0 if OK */ - function fetch($id, $user = null) + public function fetch($id, $user = null) { global $langs; $sql = "SELECT"; @@ -309,7 +309,7 @@ class Tva extends CommonObject * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { global $conf, $langs; @@ -343,7 +343,7 @@ class Tva extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -365,7 +365,7 @@ class Tva extends CommonObject * @param int $year Year * @return double Amount */ - function solde($year = 0) + public function solde($year = 0) { $reglee = $this->tva_sum_reglee($year); @@ -378,14 +378,14 @@ class Tva extends CommonObject return $solde; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Total of the VAT from invoices emitted by the thirdparty. * * @param int $year Year * @return double Amount */ - function tva_sum_collectee($year = 0) + public function tva_sum_collectee($year = 0) { // phpcs:enable @@ -419,14 +419,14 @@ class Tva extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * VAT payed * * @param int $year Year * @return double Amount */ - function tva_sum_payee($year = 0) + public function tva_sum_payee($year = 0) { // phpcs:enable @@ -461,14 +461,14 @@ class Tva extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Total of the VAT payed * * @param int $year Year * @return double Amount */ - function tva_sum_reglee($year = 0) + public function tva_sum_reglee($year = 0) { // phpcs:enable @@ -510,7 +510,7 @@ class Tva extends CommonObject * @param User $user Object user that insert * @return int <0 if KO, rowid in tva table if OK */ - function addPayment($user) + public function addPayment($user) { global $conf,$langs; @@ -654,14 +654,14 @@ class Tva extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between payment tva and line generate into llx_bank * * @param int $id_bank Id bank account * @return int <0 if KO, >0 if OK */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.(int) $id_bank; @@ -687,7 +687,7 @@ class Tva extends CommonObject * @param string $morecss More CSS * @return string Chaine with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '') { global $langs, $conf; @@ -733,7 +733,7 @@ class Tva extends CommonObject * * @return int Amount of payment already done, <0 if KO */ - function getSommePaiement() + public function getSommePaiement() { $table='paiementcharge'; $field='fk_charge'; @@ -766,7 +766,7 @@ class Tva extends CommonObject * @param int $id Id of vat payment * @return int <0 if KO, >0 if OK */ - function info($id) + public function info($id) { $sql = "SELECT t.rowid, t.tms, t.fk_user_modif, t.datec, t.fk_user_creat"; $sql.= " FROM ".MAIN_DB_PREFIX."tva as t"; @@ -813,12 +813,12 @@ class Tva extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -826,7 +826,7 @@ class Tva extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index b78b279122b..9dafaa58f05 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -32,15 +32,15 @@ abstract class ActionsContactCardCommon */ public $db; - var $dirmodule; - var $targetmodule; - var $canvas; - var $card; + public $dirmodule; + public $targetmodule; + public $canvas; + public $card; //! Template container - var $tpl = array(); + public $tpl = array(); //! Object container - var $object; + public $object; /** * @var string Error code (or message) @@ -60,7 +60,7 @@ abstract class ActionsContactCardCommon * @param int $id Object id * @return object Object loaded */ - function getObject($id) + public function getObject($id) { /*$ret = $this->getInstanceDao(); @@ -76,7 +76,7 @@ abstract class ActionsContactCardCommon //} } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set content of ->tpl array, to use into template * @@ -84,7 +84,7 @@ abstract class ActionsContactCardCommon * @param int $id Id * @return string HTML output */ - function assign_values(&$action, $id) + public function assign_values(&$action, $id) { // phpcs:enable global $conf, $langs, $user, $canvas; @@ -315,9 +315,9 @@ abstract class ActionsContactCardCommon { dol_print_error($this->db); } - $this->object->country_id = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; - $this->object->country_code = $obj->code; - $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; + $this->object->country_id = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; + $this->object->country_code = $obj->code; + $this->object->country = $langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->label; } } } diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index eee24315dab..4bc23beb2d3 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -37,9 +37,9 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param string $targetmodule Name of directory of module where canvas is stored * @param string $canvas Name of canvas * @param string $card Name of tab (sub-canvas) - */ - function __construct($db, $dirmodule, $targetmodule, $canvas, $card) - { + */ + public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) + { $this->db = $db; $this->dirmodule = $dirmodule; $this->targetmodule = $targetmodule; @@ -66,7 +66,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas * @@ -74,7 +74,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param int $id Id * @return void */ - function assign_values(&$action, $id) + public function assign_values(&$action, $id) { // phpcs:enable global $limit, $offset, $sortfield, $sortorder; @@ -121,7 +121,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -131,13 +131,13 @@ class ActionsContactCardDefault extends ActionsContactCardCommon * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - function LoadListDatas($limit, $offset, $sortfield, $sortorder) - { + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) + { // phpcs:enable - global $conf, $langs; + global $conf, $langs; //$this->getFieldList(); $this->list_datas = array(); - } + } } diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 58204ae0c94..73f27f8ec1c 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -143,19 +143,19 @@ class Contact extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->statut = 1; // By default, status is enabled } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators into this->nb for board * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -200,7 +200,7 @@ class Contact extends CommonObject * @param User $user Object user that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -273,7 +273,7 @@ class Contact extends CommonObject } } - if (! $error) + if (! $error) { // Call trigger $result=$this->call_trigger('CONTACT_CREATE', $user); @@ -313,7 +313,7 @@ class Contact extends CommonObject * @param int $nosyncuser No sync linked user (external users and contacts are linked) * @return int <0 if KO, >0 if OK */ - function update($id, $user = null, $notrigger = 0, $action = 'update', $nosyncuser = 0) + public function update($id, $user = null, $notrigger = 0, $action = 'update', $nosyncuser = 0) { global $conf, $langs, $hookmanager; @@ -497,7 +497,7 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -507,7 +507,7 @@ class Contact extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -519,13 +519,13 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialise tableau info (tableau des attributs LDAP) * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf, $langs; @@ -594,7 +594,7 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update field alert birthday * @@ -603,7 +603,7 @@ class Contact extends CommonObject * @param int $notrigger 0=no, 1=yes * @return int <0 if KO, >=0 if OK */ - function update_perso($id, $user = null, $notrigger = 0) + public function update_perso($id, $user = null, $notrigger = 0) { // phpcs:enable $error=0; @@ -692,7 +692,7 @@ class Contact extends CommonObject * @param string $email Email * @return int -1 if KO, 0 if OK but not found, 1 if OK */ - function fetch($id, $user = null, $ref_ext = '', $email = '') + public function fetch($id, $user = null, $ref_ext = '', $email = '') { global $langs; @@ -876,7 +876,7 @@ class Contact extends CommonObject * * @return void */ - function setGenderFromCivility() + public function setGenderFromCivility() { unset($this->gender); if (in_array($this->civility_id, array('MR'))) { @@ -886,7 +886,7 @@ class Contact extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load number of elements the contact is used as a link for * ref_facturation @@ -896,7 +896,7 @@ class Contact extends CommonObject * * @return int <0 if KO, >=0 if OK */ - function load_ref_elements() + public function load_ref_elements() { // phpcs:enable // Compte les elements pour lesquels il est contact @@ -938,7 +938,7 @@ class Contact extends CommonObject * @param int $notrigger Disable all trigger * @return int <0 if KO, >0 if OK */ - function delete($notrigger = 0) + public function delete($notrigger = 0) { global $conf, $langs, $user; @@ -1052,7 +1052,7 @@ class Contact extends CommonObject * @param int $id Id du contact a charger * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, c.datec as datec, c.fk_user_creat,"; $sql.= " c.tms as tms, c.fk_user_modif"; @@ -1097,7 +1097,7 @@ class Contact extends CommonObject * * @return int Number of EMailings */ - function getNbOfEMailings() + public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc, ".MAIN_DB_PREFIX."mailing as m"; @@ -1132,7 +1132,7 @@ class Contact extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $moreparam = '', $save_lastsearch_value = -1, $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $maxlen = 0, $moreparam = '', $save_lastsearch_value = -1, $notooltip = 0) { global $conf, $langs, $hookmanager; @@ -1210,7 +1210,7 @@ class Contact extends CommonObject * * @return string Translated name of civility */ - function getCivilityLabel() + public function getCivilityLabel() { global $langs; $langs->load("dict"); @@ -1226,12 +1226,12 @@ class Contact extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of contact status */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1239,7 +1239,7 @@ class Contact extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -1277,14 +1277,14 @@ class Contact extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return translated label of Public or Private * * @param int $statut Type (0 = public, 1 = private) * @return string Label translated */ - function LibPubPriv($statut) + public function LibPubPriv($statut) { // phpcs:enable global $langs; @@ -1300,14 +1300,13 @@ class Contact extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { // Get first id of existing company and save it into $socid $socid = 0; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe ORDER BY rowid LIMIT 1"; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $obj = $this->db->fetch_object($resql); if ($obj) $socid=$obj->rowid; } @@ -1344,7 +1343,7 @@ class Contact extends CommonObject * @param int $statut Status to set * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - function setstatus($statut) + public function setstatus($statut) { global $conf,$langs,$user; diff --git a/htdocs/contrat/class/api_contracts.class.php b/htdocs/contrat/class/api_contracts.class.php index b93c9db55d5..6f4a2041670 100644 --- a/htdocs/contrat/class/api_contracts.class.php +++ b/htdocs/contrat/class/api_contracts.class.php @@ -35,9 +35,9 @@ class Contracts extends DolibarrApi */ static $FIELDS = array( 'socid', - 'date_contrat', - 'commercial_signature_id', - 'commercial_suivi_id' + 'date_contrat', + 'commercial_signature_id', + 'commercial_suivi_id' ); /** @@ -48,10 +48,10 @@ class Contracts extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->contract = new Contrat($this->db); } @@ -65,23 +65,23 @@ class Contracts extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->contrat->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->contrat->lire) { + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->contract->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->contract); + return $this->_cleanObjectDatas($this->contract); } @@ -99,9 +99,9 @@ class Contracts extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of contract objects * - * @throws RestException + * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -136,7 +136,7 @@ class Contracts extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -175,7 +175,7 @@ class Contracts extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No contract found'); } - return $obj_ret; + return $obj_ret; } /** @@ -184,7 +184,7 @@ class Contracts extends DolibarrApi * @param array $request_data Request data * @return int ID of contrat */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,7 +218,7 @@ class Contracts extends DolibarrApi * * @return array */ - function getLines($id) + public function getLines($id) { if (! DolibarrApiAccess::$user->rights->contrat->lire) { throw new RestException(401); @@ -229,8 +229,8 @@ class Contracts extends DolibarrApi throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } $this->contract->getLinesArray(); $result = array(); @@ -250,21 +250,21 @@ class Contracts extends DolibarrApi * * @return int|bool */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contract not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object) $request_data; + $request_data = (object) $request_data; $updateRes = $this->contract->addline( $request_data->desc, $request_data->subprice, @@ -274,16 +274,16 @@ class Contracts extends DolibarrApi $request_data->localtax2_tx, $request_data->fk_product, $request_data->remise_percent, - $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real - $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real + $request_data->date_start, // date_start = date planned start, date ouverture = date_start_real + $request_data->date_end, // date_end = date planned end, date_cloture = date_end_real $request_data->HT, - $request_data->subprice_excl_tax, - $request_data->info_bits, + $request_data->subprice_excl_tax, + $request_data->info_bits, $request_data->fk_fournprice, - $request_data->pa_ht, - $request_data->array_options, - $request_data->fk_unit, - $request_data->rang + $request_data->pa_ht, + $request_data->array_options, + $request_data->fk_unit, + $request_data->rang ); if ($updateRes > 0) { @@ -303,20 +303,20 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if( ! $result ) { throw new RestException(404, 'Contrat not found'); } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $request_data = (object) $request_data; @@ -328,12 +328,12 @@ class Contracts extends DolibarrApi $request_data->remise_percent, $request_data->date_ouveture_prevue, $request_data->date_fin_validite, - $request_data->tva_tx, + $request_data->tva_tx, $request_data->localtax1_tx, $request_data->localtax2_tx, $request_data->date_ouverture, $request_data->date_cloture, - 'HT', + 'HT', $request_data->info_bits, $request_data->fk_fourn_price, $request_data->pa_ht, @@ -363,30 +363,30 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) + public function activateLine($id, $lineid, $datestart, $dateend = null, $comment = null) { - if(! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contrat not found'); + } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment); + $updateRes = $this->contract->active_line(DolibarrApiAccess::$user, $lineid, $datestart, $dateend, $comment); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; + return false; } /** @@ -401,32 +401,32 @@ class Contracts extends DolibarrApi * * @return array|bool */ - function unactivateLine($id, $lineid, $datestart, $comment = null) + public function unactivateLine($id, $lineid, $datestart, $comment = null) { - if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + if (! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contrat not found'); - } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contrat not found'); + } - if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $request_data = (object) $request_data; + $request_data = (object) $request_data; - $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); + $updateRes = $this->contract->close_line(DolibarrApiAccess::$user, $lineid, $datestart, $comment); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } - return false; + return false; } /** @@ -442,19 +442,19 @@ class Contracts extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contrat not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } // TODO Check the lineid $lineid is a line of object @@ -465,7 +465,7 @@ class Contracts extends DolibarrApi } else { - throw new RestException(405, $this->contract->error); + throw new RestException(405, $this->contract->error); } } @@ -477,20 +477,20 @@ class Contracts extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contrat not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; $this->contract->$field = $value; @@ -502,7 +502,7 @@ class Contracts extends DolibarrApi } else { - throw new RestException(500, $this->contract->error); + throw new RestException(500, $this->contract->error); } } @@ -513,19 +513,19 @@ class Contracts extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->contrat->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contract not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if (! $this->contract->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete contract : '.$this->contract->error); @@ -555,27 +555,27 @@ class Contracts extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->contract->fetch($id); if (! $result) { throw new RestException(404, 'Contract not found'); } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); - } + $result = $this->contract->validate(DolibarrApiAccess::$user, '', $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Contract: '.$this->contract->error); + } return array( 'success' => array( @@ -601,34 +601,34 @@ class Contracts extends DolibarrApi * "notrigger": 0 * } */ - function close($id, $notrigger = 0) + public function close($id, $notrigger = 0) { - if (! DolibarrApiAccess::$user->rights->contrat->creer) { - throw new RestException(401); - } - $result = $this->contract->fetch($id); - if (! $result) { - throw new RestException(404, 'Contract not found'); - } + if (! DolibarrApiAccess::$user->rights->contrat->creer) { + throw new RestException(401); + } + $result = $this->contract->fetch($id); + if (! $result) { + throw new RestException(404, 'Contract not found'); + } - if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('contrat', $this->contract->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already close'); - } - if ($result < 0) { - throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); - } + $result = $this->contract->closeAll(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already close'); + } + if ($result < 0) { + throw new RestException(500, 'Error when closing Contract: '.$this->contract->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Contract closed (Ref='.$this->contract->ref.'). All services were closed.' + ) + ); } @@ -639,7 +639,7 @@ class Contracts extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -666,7 +666,7 @@ class Contracts extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $contrat = array(); foreach (Contracts::$FIELDS as $field) { diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index f657f7746fa..8c83c342ab4 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -188,7 +188,7 @@ class Contrat extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -199,7 +199,7 @@ class Contrat extends CommonObject * @param Societe $soc Thirdparty object * @return string free reference for contract */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $db, $langs, $conf; $langs->load("contracts"); @@ -250,7 +250,7 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -261,7 +261,7 @@ class Contrat extends CommonObject * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - function active_line($user, $line_id, $date, $date_end = '', $comment = '') + public function active_line($user, $line_id, $date, $date_end = '', $comment = '') { // phpcs:enable $result = $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment); @@ -274,7 +274,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * @@ -284,7 +284,7 @@ class Contrat extends CommonObject * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - function close_line($user, $line_id, $date_end, $comment = '') + public function close_line($user, $line_id, $date_end, $comment = '') { // phpcs:enable $result=$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment); @@ -307,7 +307,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @see closeAll */ - function activateAll($user, $date_start = '', $notrigger = 0, $comment = '') + public function activateAll($user, $date_start = '', $notrigger = 0, $comment = '') { if (empty($date_start)) $date_start = dol_now(); @@ -363,7 +363,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @see activateAll */ - function closeAll(User $user, $notrigger = 0, $comment = '') + public function closeAll(User $user, $notrigger = 0, $comment = '') { $this->db->begin(); @@ -419,7 +419,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function validate(User $user, $force_number = '', $notrigger = 0) + public function validate(User $user, $force_number = '', $notrigger = 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; global $langs, $conf; @@ -547,7 +547,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0=execute triggers * @return int <0 if KO, >0 if OK */ - function reopen($user, $notrigger = 0) + public function reopen($user, $notrigger = 0) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; global $langs, $conf; @@ -614,7 +614,7 @@ class Contrat extends CommonObject * @param string $ref_supplier Supplier ref * @return int <0 if KO, 0 if not found, Id of contract if OK */ - function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') + public function fetch($id, $ref = '', $ref_customer = '', $ref_supplier = '') { $sql = "SELECT rowid, statut, ref, fk_soc, mise_en_service as datemise,"; $sql.= " ref_supplier, ref_customer,"; @@ -665,7 +665,7 @@ class Contrat extends CommonObject $this->user_author_id = $obj->fk_user_author; - $this->commercial_signature_id = $obj->fk_commercial_signature; + $this->commercial_signature_id = $obj->fk_commercial_signature; $this->commercial_suivi_id = $obj->fk_commercial_suivi; $this->note_private = $obj->note_private; @@ -678,7 +678,7 @@ class Contrat extends CommonObject $this->socid = $obj->fk_soc; $this->fk_soc = $obj->fk_soc; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); $this->db->free($resql); @@ -711,14 +711,14 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines array into this->lines. * This set also nbofserviceswait, nbofservicesopened, nbofservicesexpired and nbofservicesclosed * * @return ContratLigne[] Return array of contract lines */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->nbofserviceswait=0; @@ -768,7 +768,7 @@ class Contrat extends CommonObject while ($i < $num) { - $objp = $this->db->fetch_object($result); + $objp = $this->db->fetch_object($result); $line = new ContratLigne($this->db); $line->id = $objp->rowid; @@ -829,7 +829,7 @@ class Contrat extends CommonObject // fetch optionals attributes and labels $line->fetch_optionals(); - $this->lines[$pos] = $line; + $this->lines[$pos] = $line; $this->lines_id_index_mapper[$line->id] = $pos; //dol_syslog("1 ".$line->desc); @@ -869,7 +869,7 @@ class Contrat extends CommonObject * @param User $user User that create * @return int <0 if KO, id of contract if OK */ - function create($user) + public function create($user) { global $conf,$langs,$mysoc; @@ -1088,7 +1088,7 @@ class Contrat extends CommonObject * @param User $user Utilisateur qui supprime * @return int < 0 si erreur, > 0 si ok */ - function delete($user) + public function delete($user) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -1242,7 +1242,7 @@ class Contrat extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -1360,7 +1360,7 @@ class Contrat extends CommonObject * @param string $rang Position * @return int <0 if KO, >0 if OK */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $date_start, $date_end, $price_base_type = 'HT', $pu_ttc = 0.0, $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null, $rang = 0) { global $user, $langs, $conf, $mysoc; $error=0; @@ -1570,7 +1570,7 @@ class Contrat extends CommonObject * @param string $fk_unit Code of the unit to use. Null to use the default one * @return int < 0 si erreur, > 0 si ok */ - function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_debut_reel = '', $date_fin_reel = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null) + public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_debut_reel = '', $date_fin_reel = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = 0, $fk_unit = null) { global $user, $conf, $langs, $mysoc; @@ -1647,21 +1647,21 @@ class Contrat extends CommonObject } $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".$this->db->escape($desc)."'"; - $sql.= ",price_ht='" . price2num($price)."'"; - $sql.= ",subprice='" . price2num($subprice)."'"; - $sql.= ",remise='" . price2num($remise)."'"; + $sql.= ",price_ht='".price2num($price)."'"; + $sql.= ",subprice='".price2num($subprice)."'"; + $sql.= ",remise='".price2num($remise)."'"; $sql.= ",remise_percent='".price2num($remise_percent)."'"; $sql.= ",qty='".$qty."'"; - $sql.= ",tva_tx='". price2num($tvatx)."'"; - $sql.= ",localtax1_tx='". price2num($localtax1tx)."'"; - $sql.= ",localtax2_tx='". price2num($localtax2tx)."'"; + $sql.= ",tva_tx='".price2num($tvatx)."'"; + $sql.= ",localtax1_tx='".price2num($localtax1tx)."'"; + $sql.= ",localtax2_tx='".price2num($localtax2tx)."'"; $sql.= ",localtax1_type='".$localtax1_type."'"; $sql.= ",localtax2_type='".$localtax2_type."'"; - $sql.= ", total_ht='". price2num($total_ht)."'"; - $sql.= ", total_tva='". price2num($total_tva)."'"; + $sql.= ", total_ht='".price2num($total_ht)."'"; + $sql.= ", total_tva='".price2num($total_tva)."'"; $sql.= ", total_localtax1='".price2num($total_localtax1)."'"; $sql.= ", total_localtax2='".price2num($total_localtax2)."'"; - $sql.= ", total_ttc='". price2num($total_ttc)."'"; + $sql.= ", total_ttc='".price2num($total_ttc)."'"; $sql.= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : "null"); $sql.= ", buy_price_ht='".price2num($pa_ht)."'"; if ($date_start > 0) { $sql.= ",date_ouverture_prevue='".$this->db->idate($date_start)."'"; } @@ -1733,7 +1733,7 @@ class Contrat extends CommonObject * @param User $user User that delete * @return int >0 if OK, <0 if KO */ - function deleteline($idline, User $user) + public function deleteline($idline, User $user) { global $conf, $langs; @@ -1792,7 +1792,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update statut of contract according to services * @@ -1800,7 +1800,7 @@ class Contrat extends CommonObject * @return int <0 if KO, >0 if OK * @deprecated This function will never be used. Status of a contract is status of its lines. */ - function update_statut($user) + public function update_statut($user) { // phpcs:enable dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); @@ -1811,11 +1811,11 @@ class Contrat extends CommonObject // Load $this->lines array // $this->fetch_lines(); -// $newstatut=1; -// foreach($this->lines as $key => $contractline) -// { -// // if ($contractline) // Loop on each service -// } + // $newstatut=1; + // foreach($this->lines as $key => $contractline) + // { + // // if ($contractline) // Loop on each service + // } return 1; } @@ -1827,12 +1827,12 @@ class Contrat extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length * @return string Label */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi label of a given contrat status * @@ -1840,7 +1840,7 @@ class Contrat extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Libelle court, 3=Picto, 4=Picto + Long label of all services, 5=Libelle court + Picto, 6=Picto of all services, 7=Same than 6 with fixed length * @return string Label */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -1872,8 +1872,7 @@ class Contrat extends CommonObject elseif ($mode == 4 || $mode == 6 || $mode == 7) { $text=''; - if ($mode == 4) - { + if ($mode == 4) { $text =''; $text.=($this->nbofserviceswait+$this->nbofservicesopened+$this->nbofservicesexpired+$this->nbofservicesclosed); $text.=' '.$langs->trans("Services"); @@ -1909,7 +1908,7 @@ class Contrat extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $maxlength = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $user; @@ -1973,7 +1972,7 @@ class Contrat extends CommonObject * @param int $id id du contrat a charger * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, c.ref, c.datec, c.date_cloture,"; $sql.= " c.tms as date_modification,"; @@ -2015,14 +2014,14 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of line rowid * * @param int $statut Status of lines to get * @return array Array of line's rowid */ - function array_detail($statut = -1) + public function array_detail($statut = -1) { // phpcs:enable $tab=array(); @@ -2059,7 +2058,7 @@ class Contrat extends CommonObject * @param string $option 'all' or 'others' * @return array Array of contracts id */ - function getListOfContracts($option = 'all') + public function getListOfContracts($option = 'all') { $tab=array(); @@ -2092,7 +2091,7 @@ class Contrat extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -2100,7 +2099,7 @@ class Contrat extends CommonObject * @param string $mode "inactive" pour services a activer, "expired" pour services expires * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user, $mode) + public function load_board($user, $mode) { // phpcs:enable global $conf, $langs; @@ -2172,13 +2171,13 @@ class Contrat extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 si ko, >0 si ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -2223,7 +2222,7 @@ class Contrat extends CommonObject * * @return array Liste des id contacts facturation */ - function getIdBillingContact() + public function getIdBillingContact() { return $this->getIdContact('external', 'BILLING'); } @@ -2233,7 +2232,7 @@ class Contrat extends CommonObject * * @return array Liste des id contacts prestation */ - function getIdServiceContact() + public function getIdServiceContact() { return $this->getIdContact('external', 'SERVICE'); } @@ -2245,9 +2244,9 @@ class Contrat extends CommonObject * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() - { + */ + public function initAsSpecimen() + { global $user,$langs,$conf; // Load array of products prodids @@ -2319,7 +2318,7 @@ class Contrat extends CommonObject * * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { return $this->fetch_lines(); } @@ -2382,7 +2381,7 @@ class Contrat extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int New id of clone */ - function createFromClone($socid = 0, $notrigger = 0) + public function createFromClone($socid = 0, $notrigger = 0) { global $db, $user, $langs, $conf, $hookmanager, $extrafields; @@ -2631,7 +2630,7 @@ class ContratLigne extends CommonObjectLine * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -2643,12 +2642,12 @@ class ContratLigne extends CommonObjectLine * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - function getLibStatut($mode) + public function getLibStatut($mode) { return $this->LibStatut($this->statut, $mode, ((! empty($this->date_fin_validite))?($this->date_fin_validite < dol_now()?1:0):-1)); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a contract line status * @@ -2658,7 +2657,7 @@ class ContratLigne extends CommonObjectLine * @param string $moreatt More attribute * @return string Libelle */ - static function LibStatut($statut, $mode, $expired = -1, $moreatt = '') + public static function LibStatut($statut, $mode, $expired = -1, $moreatt = '') { // phpcs:enable global $langs; @@ -2720,7 +2719,7 @@ class ContratLigne extends CommonObjectLine * @param int $maxlength Max length * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlength = 0) + public function getNomUrl($withpicto = 0, $maxlength = 0) { global $langs; @@ -2741,13 +2740,13 @@ class ContratLigne extends CommonObjectLine } /** - * Load object in memory from database + * Load object in memory from database * - * @param int $id Id object - * @param string $ref Ref of contract - * @return int <0 if KO, >0 if OK + * @param int $id Id object + * @param string $ref Ref of contract + * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { // Check parameters @@ -2879,7 +2878,7 @@ class ContratLigne extends CommonObjectLine * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs, $mysoc; @@ -3070,14 +3069,14 @@ class ContratLigne extends CommonObjectLine } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base des champs total_xxx de ligne * Used by migration process * * @return int <0 if KO, >0 if OK */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); @@ -3188,7 +3187,7 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate a contract line * @@ -3198,7 +3197,7 @@ class ContratLigne extends CommonObjectLine * @param string $comment A comment typed by user * @return int <0 if KO, >0 if OK */ - function active_line($user, $date, $date_end = '', $comment = '') + public function active_line($user, $date, $date_end = '', $comment = '') { // phpcs:enable global $langs, $conf; @@ -3247,7 +3246,7 @@ class ContratLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close a contract line * @@ -3257,7 +3256,7 @@ class ContratLigne extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers * @return int <0 if KO, >0 if OK */ - function close_line($user, $date_end, $comment = '', $notrigger = 0) + public function close_line($user, $date_end, $comment = '', $notrigger = 0) { // phpcs:enable global $langs, $conf; diff --git a/htdocs/core/boxes/box_actions.php b/htdocs/core/boxes/box_actions.php index c38be982756..994b604ae78 100644 --- a/htdocs/core/boxes/box_actions.php +++ b/htdocs/core/boxes/box_actions.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_actions extends ModeleBoxes { - var $boxcode="lastactions"; - var $boximg="object_action"; - var $boxlabel="BoxLastActions"; - var $depends = array("agenda"); + public $boxcode="lastactions"; + public $boximg="object_action"; + public $boxlabel="BoxLastActions"; + public $depends = array("agenda"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,7 +54,7 @@ class box_actions extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $user; @@ -69,7 +69,7 @@ class box_actions extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -188,7 +188,7 @@ class box_actions extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { global $langs, $conf; $out = parent::showBox($this->info_box_head, $this->info_box_contents); @@ -257,5 +257,5 @@ class box_actions extends ModeleBoxes else print $out; return ''; - } + } } diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 44ca6cbf9e3..300040639a8 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -30,21 +30,21 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_activity extends ModeleBoxes { - var $boxcode="activity"; - var $boximg="object_bill"; - var $boxlabel='BoxGlobalActivity'; - var $depends = array("facture"); + public $boxcode="activity"; + public $boximg="object_bill"; + public $boxlabel='BoxGlobalActivity'; + public $depends = array("facture"); /** * @var DoliDB Database handler. */ public $db; - var $param; - var $enabled = 1; + public $param; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_activity extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $conf, $user; @@ -74,7 +74,7 @@ class box_activity extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -450,16 +450,16 @@ class box_activity extends ModeleBoxes } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_bookmarks.php b/htdocs/core/boxes/box_bookmarks.php index 08d10e7c6d5..52f8c0f4a77 100644 --- a/htdocs/core/boxes/box_bookmarks.php +++ b/htdocs/core/boxes/box_bookmarks.php @@ -28,20 +28,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_bookmarks extends ModeleBoxes { - var $boxcode="bookmarks"; - var $boximg="object_bookmark"; - var $boxlabel="BoxMyLastBookmarks"; - var $depends = array("bookmark"); + public $boxcode="bookmarks"; + public $boximg="object_bookmark"; + public $boxlabel="BoxMyLastBookmarks"; + public $depends = array("bookmark"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -50,7 +50,7 @@ class box_bookmarks extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -65,7 +65,7 @@ class box_bookmarks extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); @@ -149,16 +149,16 @@ class box_bookmarks extends ModeleBoxes } } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 87378de74b3..ea2a7814f14 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_clients extends ModeleBoxes { - var $boxcode="lastcustomers"; - var $boximg="object_company"; - var $boxlabel="BoxLastCustomers"; - var $depends = array("societe"); + public $boxcode="lastcustomers"; + public $boximg="object_company"; + public $boxlabel="BoxLastCustomers"; + public $depends = array("societe"); /** * @var DoliDB Database handler. */ public $db; - var $enabled = 1; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,7 +54,7 @@ class box_clients extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf, $user; @@ -72,7 +72,7 @@ class box_clients extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); @@ -175,7 +175,7 @@ class box_clients extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index 3769a39faaf..8575e739946 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_commandes extends ModeleBoxes { - var $boxcode="lastcustomerorders"; - var $boximg="object_order"; - var $boxlabel="BoxLastCustomerOrders"; - var $depends = array("commande"); + public $boxcode="lastcustomerorders"; + public $boximg="object_order"; + public $boxlabel="BoxLastCustomerOrders"; + public $depends = array("commande"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,7 +54,7 @@ class box_commandes extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -69,7 +69,7 @@ class box_commandes extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -198,7 +198,7 @@ class box_commandes extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 7fafcb3bd10..525562d308d 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -33,21 +33,21 @@ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; */ class box_comptes extends ModeleBoxes { - var $boxcode="currentaccounts"; - var $boximg="object_bill"; - var $boxlabel="BoxCurrentAccounts"; - var $depends = array("banque"); // Box active if module banque active + public $boxcode="currentaccounts"; + public $boximg="object_bill"; + public $boxlabel="BoxCurrentAccounts"; + public $depends = array("banque"); // Box active if module banque active - /** + /** * @var DoliDB Database handler. */ public $db; - var $param; - var $enabled = 1; + public $param; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,7 +56,7 @@ class box_comptes extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf, $user; @@ -75,7 +75,7 @@ class box_comptes extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -176,16 +176,16 @@ class box_comptes extends ModeleBoxes } } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 8fdd5483975..45886e00be7 100644 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -34,20 +34,20 @@ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; */ class box_contacts extends ModeleBoxes { - var $boxcode="lastcontacts"; - var $boximg="object_contact"; - var $boxlabel="BoxLastContacts"; - var $depends = array("societe"); + public $boxcode="lastcontacts"; + public $boximg="object_contact"; + public $boxlabel="BoxLastContacts"; + public $depends = array("societe"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,7 +56,7 @@ class box_contacts extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -71,7 +71,7 @@ class box_contacts extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); @@ -185,7 +185,7 @@ class box_contacts extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php index a58081dffcf..57adf1c06cb 100644 --- a/htdocs/core/boxes/box_contracts.php +++ b/htdocs/core/boxes/box_contracts.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_contracts extends ModeleBoxes { - var $boxcode="lastcontracts"; - var $boximg="object_contract"; - var $boxlabel="BoxLastContracts"; - var $depends = array("contrat"); // conf->contrat->enabled + public $boxcode="lastcontracts"; + public $boximg="object_contract"; + public $boxlabel="BoxLastContracts"; + public $depends = array("contrat"); // conf->contrat->enabled /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_contracts extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -68,7 +68,7 @@ class box_contracts extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -189,7 +189,7 @@ class box_contracts extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_external_rss.php b/htdocs/core/boxes/box_external_rss.php index 38f865279e3..f879523e9e0 100644 --- a/htdocs/core/boxes/box_external_rss.php +++ b/htdocs/core/boxes/box_external_rss.php @@ -34,20 +34,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_external_rss extends ModeleBoxes { - var $boxcode="lastrssinfos"; - var $boximg="object_rss"; - var $boxlabel="BoxLastRssInfos"; - var $depends = array("externalrss"); + public $boxcode="lastrssinfos"; + public $boximg="object_rss"; + public $boxlabel="BoxLastRssInfos"; + public $depends = array("externalrss"); /** * @var DoliDB Database handler. */ public $db; - var $paramdef; // Params of box definition (not user params) + public $paramdef; // Params of box definition (not user params) - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,7 +56,7 @@ class box_external_rss extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { $this->db=$db; $this->paramdef=$param; @@ -69,7 +69,7 @@ class box_external_rss extends ModeleBoxes * @param int $cachedelay Delay we accept for cache file * @return void */ - function loadBox($max = 5, $cachedelay = 3600) + public function loadBox($max = 5, $cachedelay = 3600) { global $user, $langs, $conf; $langs->load("boxes"); @@ -195,7 +195,7 @@ class box_external_rss extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index c78837cc3ac..42c21f0708b 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures extends ModeleBoxes { - var $boxcode="lastcustomerbills"; - var $boximg="object_bill"; - var $boxlabel="BoxLastCustomerBills"; - var $depends = array("facture"); + public $boxcode="lastcustomerbills"; + public $boximg="object_bill"; + public $boxlabel="BoxLastCustomerBills"; + public $depends = array("facture"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,7 +52,7 @@ class box_factures extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -67,7 +67,7 @@ class box_factures extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -209,7 +209,7 @@ class box_factures extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_factures_fourn.php b/htdocs/core/boxes/box_factures_fourn.php index 1f3c0a4c7df..3dc8011fd7f 100644 --- a/htdocs/core/boxes/box_factures_fourn.php +++ b/htdocs/core/boxes/box_factures_fourn.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn extends ModeleBoxes { - var $boxcode="lastsupplierbills"; - var $boximg="object_bill"; - var $boxlabel="BoxLastSupplierBills"; - var $depends = array("facture","fournisseur"); + public $boxcode="lastsupplierbills"; + public $boximg="object_bill"; + public $boxlabel="BoxLastSupplierBills"; + public $depends = array("facture","fournisseur"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_factures_fourn extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -68,7 +68,7 @@ class box_factures_fourn extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -214,7 +214,7 @@ class box_factures_fourn extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index b6fea0f450a..3c1b486b50d 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_factures_fourn_imp extends ModeleBoxes { - var $boxcode = "oldestunpaidsupplierbills"; - var $boximg = "object_bill"; - var $boxlabel = "BoxOldestUnpaidSupplierBills"; - var $depends = array("facture","fournisseur"); + public $boxcode = "oldestunpaidsupplierbills"; + public $boximg = "object_bill"; + public $boxlabel = "BoxOldestUnpaidSupplierBills"; + public $depends = array("facture","fournisseur"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,7 +52,7 @@ class box_factures_fourn_imp extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -67,7 +67,7 @@ class box_factures_fourn_imp extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -201,7 +201,7 @@ class box_factures_fourn_imp extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index d76477dc356..fd85f136f96 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -33,20 +33,20 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; */ class box_factures_imp extends ModeleBoxes { - var $boxcode="oldestunpaidcustomerbills"; - var $boximg="object_bill"; - var $boxlabel="BoxOldestUnpaidCustomerBills"; - var $depends = array("facture"); + public $boxcode="oldestunpaidcustomerbills"; + public $boximg="object_bill"; + public $boxlabel="BoxOldestUnpaidCustomerBills"; + public $depends = array("facture"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,7 +55,7 @@ class box_factures_imp extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -70,7 +70,7 @@ class box_factures_imp extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -207,7 +207,7 @@ class box_factures_imp extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_ficheinter.php b/htdocs/core/boxes/box_ficheinter.php index 8dcd81c1aab..0debc76c507 100644 --- a/htdocs/core/boxes/box_ficheinter.php +++ b/htdocs/core/boxes/box_ficheinter.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_ficheinter extends ModeleBoxes { - var $boxcode="ficheinter"; - var $boximg="object_intervention"; - var $boxlabel="BoxFicheInter"; - var $depends = array("ficheinter"); // conf->contrat->enabled + public $boxcode="ficheinter"; + public $boximg="object_intervention"; + public $boxlabel="BoxFicheInter"; + public $depends = array("ficheinter"); // conf->contrat->enabled /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_ficheinter extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -68,7 +68,7 @@ class box_ficheinter extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 10) + public function loadBox($max = 10) { global $user, $langs, $db, $conf; @@ -176,7 +176,7 @@ class box_ficheinter extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php index 7cbefce2e32..01f62bc38c9 100644 --- a/htdocs/core/boxes/box_fournisseurs.php +++ b/htdocs/core/boxes/box_fournisseurs.php @@ -31,20 +31,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_fournisseurs extends ModeleBoxes { - var $boxcode="lastsuppliers"; - var $boximg="object_company"; - var $boxlabel="BoxLastSuppliers"; - var $depends = array("fournisseur"); + public $boxcode="lastsuppliers"; + public $boximg="object_company"; + public $boxlabel="BoxLastSuppliers"; + public $depends = array("fournisseur"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_fournisseurs extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -68,7 +68,7 @@ class box_fournisseurs extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; $langs->load("boxes"); @@ -160,7 +160,7 @@ class box_fournisseurs extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_goodcustomers.php b/htdocs/core/boxes/box_goodcustomers.php index 5d8b9f736f5..ea973caf773 100644 --- a/htdocs/core/boxes/box_goodcustomers.php +++ b/htdocs/core/boxes/box_goodcustomers.php @@ -33,20 +33,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_goodcustomers extends ModeleBoxes { - var $boxcode="goodcustomers"; - var $boximg="object_company"; - var $boxlabel="BoxGoodCustomers"; - var $depends = array("societe"); + public $boxcode="goodcustomers"; + public $boximg="object_company"; + public $boxlabel="BoxGoodCustomers"; + public $depends = array("societe"); /** * @var DoliDB Database handler. */ public $db; - var $enabled = 1; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,7 +55,7 @@ class box_goodcustomers extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf, $user; @@ -74,7 +74,7 @@ class box_goodcustomers extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); @@ -171,7 +171,7 @@ class box_goodcustomers extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index e663c408281..4323661370c 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_permonth extends ModeleBoxes { - var $boxcode="invoicespermonth"; - var $boximg="object_bill"; - var $boxlabel="BoxCustomersInvoicesPerMonth"; - var $depends = array("facture"); + public $boxcode="invoicespermonth"; + public $boximg="object_bill"; + public $boxlabel="BoxCustomersInvoicesPerMonth"; + public $depends = array("facture"); /** * @var DoliDB Database handler. */ public $db; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -48,7 +48,7 @@ class box_graph_invoices_permonth extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -63,7 +63,7 @@ class box_graph_invoices_permonth extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -76,14 +76,14 @@ class box_graph_invoices_permonth extends ModeleBoxes $text = $langs->trans("BoxCustomersInvoicesPerMonth", $max); $this->info_box_head = array( - 'text' => $text, - 'limit'=> dol_strlen($text), - 'graph'=> 1, - 'sublink'=>'', - 'subtext'=>$langs->trans("Filter"), - 'subpicto'=>'filter.png', - 'subclass'=>'linkobject boxfilter', - 'target'=>'none' // Set '' to get target="_blank" + 'text' => $text, + 'limit'=> dol_strlen($text), + 'graph'=> 1, + 'sublink'=>'', + 'subtext'=>$langs->trans("Filter"), + 'subpicto'=>'filter.png', + 'subclass'=>'linkobject boxfilter', + 'target'=>'none' // Set '' to get target="_blank" ); $dir=''; // We don't need a path because image file will not be saved into disk @@ -275,7 +275,7 @@ class box_graph_invoices_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index b8f020b4db7..bba5185c94a 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_invoices_supplier_permonth extends ModeleBoxes { - var $boxcode="invoicessupplierpermonth"; - var $boximg="object_bill"; - var $boxlabel="BoxSuppliersInvoicesPerMonth"; - var $depends = array("fournisseur"); + public $boxcode="invoicessupplierpermonth"; + public $boximg="object_bill"; + public $boxlabel="BoxSuppliersInvoicesPerMonth"; + public $depends = array("fournisseur"); /** * @var DoliDB Database handler. */ public $db; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -48,7 +48,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -63,7 +63,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -277,7 +277,7 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php index 98329df8379..b06558393aa 100644 --- a/htdocs/core/boxes/box_graph_orders_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_orders_permonth extends ModeleBoxes { - var $boxcode="orderspermonth"; - var $boximg="object_order"; - var $boxlabel="BoxCustomersOrdersPerMonth"; - var $depends = array("commande"); + public $boxcode="orderspermonth"; + public $boximg="object_order"; + public $boxlabel="BoxCustomersOrdersPerMonth"; + public $depends = array("commande"); /** * @var DoliDB Database handler. */ public $db; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -48,7 +48,7 @@ class box_graph_orders_permonth extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -63,7 +63,7 @@ class box_graph_orders_permonth extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -273,14 +273,14 @@ class box_graph_orders_permonth extends ModeleBoxes } /** - * Method to show box + * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return string + * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php index c3cdbcef412..9cb11aed7c1 100644 --- a/htdocs/core/boxes/box_graph_orders_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_orders_supplier_permonth.php @@ -48,7 +48,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -63,7 +63,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -279,7 +279,7 @@ class box_graph_orders_supplier_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_product_distribution.php b/htdocs/core/boxes/box_graph_product_distribution.php index e5ecb232ac1..d1c85cb2044 100644 --- a/htdocs/core/boxes/box_graph_product_distribution.php +++ b/htdocs/core/boxes/box_graph_product_distribution.php @@ -29,20 +29,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; */ class box_graph_product_distribution extends ModeleBoxes { - var $boxcode="productdistribution"; - var $boximg="object_product"; - var $boxlabel="BoxProductDistribution"; - var $depends = array("product|service","facture|propal|commande"); + public $boxcode="productdistribution"; + public $boximg="object_product"; + public $boxlabel="BoxProductDistribution"; + public $depends = array("product|service","facture|propal|commande"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -51,7 +51,7 @@ class box_graph_product_distribution extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user, $conf; @@ -70,7 +70,7 @@ class box_graph_product_distribution extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -416,7 +416,7 @@ class box_graph_product_distribution extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_graph_propales_permonth.php b/htdocs/core/boxes/box_graph_propales_permonth.php index b27229107e0..b21381473c2 100644 --- a/htdocs/core/boxes/box_graph_propales_permonth.php +++ b/htdocs/core/boxes/box_graph_propales_permonth.php @@ -28,18 +28,18 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_graph_propales_permonth extends ModeleBoxes { - var $boxcode="propalpermonth"; - var $boximg="object_propal"; - var $boxlabel="BoxProposalsPerMonth"; - var $depends = array("propal"); + public $boxcode="propalpermonth"; + public $boximg="object_propal"; + public $boxlabel="BoxProposalsPerMonth"; + public $depends = array("propal"); /** * @var DoliDB Database handler. */ public $db; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -48,7 +48,7 @@ class box_graph_propales_permonth extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -63,7 +63,7 @@ class box_graph_propales_permonth extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -283,7 +283,7 @@ class box_graph_propales_permonth extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_last_modified_ticket.php b/htdocs/core/boxes/box_last_modified_ticket.php index a0e0d55ebb1..e9f00049e04 100644 --- a/htdocs/core/boxes/box_last_modified_ticket.php +++ b/htdocs/core/boxes/box_last_modified_ticket.php @@ -195,7 +195,7 @@ class box_last_modified_ticket extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 45a4b5e8f02..352a10db682 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -192,7 +192,7 @@ class box_last_ticket extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_lastlogin.php b/htdocs/core/boxes/box_lastlogin.php index 0536a2c34a0..8a5b90ae9d5 100644 --- a/htdocs/core/boxes/box_lastlogin.php +++ b/htdocs/core/boxes/box_lastlogin.php @@ -30,21 +30,21 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_lastlogin extends ModeleBoxes { - var $boxcode="lastlogin"; - var $boximg="object_user"; - var $boxlabel='BoxLoginInformation'; - var $depends = array("user"); + public $boxcode="lastlogin"; + public $boximg="object_user"; + public $boxlabel='BoxLoginInformation'; + public $depends = array("user"); /** * @var DoliDB Database handler. */ public $db; - - var $param; - var $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $param; + public $enabled = 1; + + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -53,7 +53,7 @@ class box_lastlogin extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $conf; @@ -66,7 +66,7 @@ class box_lastlogin extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -75,7 +75,7 @@ class box_lastlogin extends ModeleBoxes 'text' => $textHead, 'limit'=> dol_strlen($textHead), ); - + $line=0; $this->info_box_contents[$line][0] = array( 'td' => '', @@ -86,7 +86,7 @@ class box_lastlogin extends ModeleBoxes 'text' => $user->getNomUrl(-1), 'asis' => 1 ); - + $line=1; $this->info_box_contents[$line][0] = array( 'td' => '', @@ -102,14 +102,14 @@ class box_lastlogin extends ModeleBoxes /** - * Method to show box + * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void + * @return void */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index e6ddca4ac1e..c0c82677d4e 100644 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -32,21 +32,21 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_members extends ModeleBoxes { - var $boxcode="lastmembers"; - var $boximg="object_user"; - var $boxlabel="BoxLastMembers"; - var $depends = array("adherent"); + public $boxcode="lastmembers"; + public $boximg="object_user"; + public $boxlabel="BoxLastMembers"; + public $depends = array("adherent"); /** * @var DoliDB Database handler. */ public $db; - var $param; - var $enabled = 1; + public $param; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,7 +55,7 @@ class box_members extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf, $user; @@ -74,7 +74,7 @@ class box_members extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; $langs->load("boxes"); @@ -178,7 +178,7 @@ class box_members extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_produits.php b/htdocs/core/boxes/box_produits.php index a44992832d9..38f9a73f57f 100644 --- a/htdocs/core/boxes/box_produits.php +++ b/htdocs/core/boxes/box_produits.php @@ -33,20 +33,20 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits extends ModeleBoxes { - var $boxcode="lastproducts"; - var $boximg="object_product"; - var $boxlabel="BoxLastProducts"; - var $depends = array("produit"); + public $boxcode="lastproducts"; + public $boximg="object_product"; + public $boxlabel="BoxLastProducts"; + public $depends = array("produit"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -55,7 +55,7 @@ class box_produits extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $conf, $user; @@ -73,7 +73,7 @@ class box_produits extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf, $hookmanager; @@ -218,16 +218,16 @@ class box_produits extends ModeleBoxes } } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_produits_alerte_stock.php b/htdocs/core/boxes/box_produits_alerte_stock.php index e041c0ab197..d1381870338 100644 --- a/htdocs/core/boxes/box_produits_alerte_stock.php +++ b/htdocs/core/boxes/box_produits_alerte_stock.php @@ -35,20 +35,20 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class box_produits_alerte_stock extends ModeleBoxes { - var $boxcode="productsalertstock"; - var $boximg="object_product"; - var $boxlabel="BoxProductsAlertStock"; - var $depends = array("produit"); + public $boxcode="productsalertstock"; + public $boximg="object_product"; + public $boxlabel="BoxProductsAlertStock"; + public $depends = array("produit"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -57,7 +57,7 @@ class box_produits_alerte_stock extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf,$user; @@ -75,7 +75,7 @@ class box_produits_alerte_stock extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf, $hookmanager; @@ -241,7 +241,7 @@ class box_produits_alerte_stock extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index f03915b7b2a..86e092de7c3 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT."/core/boxes/modules_boxes.php"; */ class box_project extends ModeleBoxes { - var $boxcode="project"; - var $boximg="object_projectpub"; - var $boxlabel; - //var $depends = array("projet"); + public $boxcode="project"; + public $boximg="object_projectpub"; + public $boxlabel; + //var $depends = array("projet"); - /** + /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** * Constructor @@ -51,7 +51,7 @@ class box_project extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $user, $langs; @@ -64,45 +64,45 @@ class box_project extends ModeleBoxes $this->hidden=! ($user->rights->projet->lire); } - /** - * Load data for box to show them later - * - * @param int $max Maximum number of records to load - * @return void - */ - function loadBox($max = 5) - { - global $conf, $user, $langs, $db; + /** + * Load data for box to show them later + * + * @param int $max Maximum number of records to load + * @return void + */ + public function loadBox($max = 5) + { + global $conf, $user, $langs, $db; - $this->max=$max; + $this->max=$max; - $totalMnt = 0; - $totalnb = 0; - $totalnbTask=0; + $totalMnt = 0; + $totalnb = 0; + $totalnbTask=0; - $textHead = $langs->trans("OpenedProjects"); - $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); + $textHead = $langs->trans("OpenedProjects"); + $this->info_box_head = array('text' => $textHead, 'limit'=> dol_strlen($textHead)); - // list the summary of the orders - if ($user->rights->projet->lire) { + // list the summary of the orders + if ($user->rights->projet->lire) { - include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - $projectstatic = new Project($this->db); + include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + $projectstatic = new Project($this->db); $socid=0; //if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement. // Get list of project id allowed to user (in a string list separated by coma) - $projectsListId=''; - if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); + $projectsListId=''; + if (! $user->rights->projet->all->lire) $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1, $socid); - $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; - $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut, p.public"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql.= " WHERE p.fk_statut = 1"; // Only open projects if (! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")"; // public and assigned to, or restricted to company for external users $sql.= " ORDER BY p.datec DESC"; - //$sql.= $db->plimit($max, 0); + //$sql.= $db->plimit($max, 0); $result = $db->query($sql); @@ -120,7 +120,7 @@ class box_project extends ModeleBoxes $this->info_box_contents[$i][] = array( 'td' => '', 'text' => $projectstatic->getNomUrl(1), - 'asis' => 1 + 'asis' => 1 ); $this->info_box_contents[$i][] = array( @@ -128,42 +128,42 @@ class box_project extends ModeleBoxes 'text' => $objp->title, ); - $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; - $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; - $sql.= " WHERE p.entity IN (".getEntity('project').')'; - $sql.=" AND p.rowid = ".$objp->rowid; - $resultTask = $db->query($sql); - if ($resultTask) { - $objTask = $db->fetch_object($resultTask); + $sql ="SELECT count(*) as nb, sum(progress) as totprogress"; + $sql.=" FROM ".MAIN_DB_PREFIX."projet as p LEFT JOIN ".MAIN_DB_PREFIX."projet_task as pt on pt.fk_projet = p.rowid"; + $sql.= " WHERE p.entity IN (".getEntity('project').')'; + $sql.=" AND p.rowid = ".$objp->rowid; + $resultTask = $db->query($sql); + if ($resultTask) { + $objTask = $db->fetch_object($resultTask); $this->info_box_contents[$i][] = array( 'td' => 'class="right"', 'text' => $objTask->nb." ".$langs->trans("Tasks"), ); - if ($objTask->nb > 0) + if ($objTask->nb > 0) $this->info_box_contents[$i][] = array( 'td' => 'class="right"', 'text' => round($objTask->totprogress/$objTask->nb, 0)."%", ); - else - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - $totalnbTask += $objTask->nb; - } else { - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); - $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); - } + else + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + $totalnbTask += $objTask->nb; + } else { + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => round(0)); + $this->info_box_contents[$i][] = array('td' => 'class="right"', 'text' => "N/A "); + } - $i++; - } - if ($max < $num) - { - $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); - $i++; - } - } - } + $i++; + } + if ($max < $num) + { + $this->info_box_contents[$i][] = array('td' => 'colspan="5"', 'text' => '...'); + $i++; + } + } + } - // Add the sum à the bottom of the boxes + // Add the sum à the bottom of the boxes $this->info_box_contents[$i][] = array( 'td' => '', 'text' => $langs->trans("Total")." ".$textHead, @@ -181,18 +181,18 @@ class box_project extends ModeleBoxes 'td' => '', 'text' => " ", ); - } + } - /** - * Method to show box - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + /** + * Method to show box + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index 9176cb9f013..6bf6a2c2166 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_propales extends ModeleBoxes { - var $boxcode="lastpropals"; - var $boximg="object_propal"; - var $boxlabel="BoxLastProposals"; - var $depends = array("propal"); // conf->propal->enabled + public $boxcode="lastpropals"; + public $boximg="object_propal"; + public $boxlabel="BoxLastProposals"; + public $depends = array("propal"); // conf->propal->enabled /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,7 +54,7 @@ class box_propales extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -69,7 +69,7 @@ class box_propales extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -181,14 +181,14 @@ class box_propales extends ModeleBoxes } /** - * Method to show box + * Method to show box * - * @param array $head Array with properties of box title + * @param array $head Array with properties of box title * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index ab82dc7a490..7f5cc566f42 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -34,20 +34,20 @@ include_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php'; */ class box_prospect extends ModeleBoxes { - var $boxcode="lastprospects"; - var $boximg="object_company"; - var $boxlabel="BoxLastProspects"; - var $depends = array("societe"); + public $boxcode="lastprospects"; + public $boximg="object_company"; + public $boxlabel="BoxLastProspects"; + public $depends = array("societe"); /** * @var DoliDB Database handler. */ public $db; - var $enabled = 1; + public $enabled = 1; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -56,7 +56,7 @@ class box_prospect extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $conf, $user; @@ -74,7 +74,7 @@ class box_prospect extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -177,7 +177,7 @@ class box_prospect extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_services_contracts.php b/htdocs/core/boxes/box_services_contracts.php index 00193fc427e..68959b15056 100644 --- a/htdocs/core/boxes/box_services_contracts.php +++ b/htdocs/core/boxes/box_services_contracts.php @@ -32,20 +32,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; */ class box_services_contracts extends ModeleBoxes { - var $boxcode="lastproductsincontract"; - var $boximg="object_product"; - var $boxlabel="BoxLastProductsInContract"; - var $depends = array("service","contrat"); + public $boxcode="lastproductsincontract"; + public $boximg="object_product"; + public $boxlabel="BoxLastProductsInContract"; + public $depends = array("service","contrat"); /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -54,7 +54,7 @@ class box_services_contracts extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -69,7 +69,7 @@ class box_services_contracts extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -249,8 +249,8 @@ class box_services_contracts extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { - return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); - } + return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); + } } diff --git a/htdocs/core/boxes/box_services_expired.php b/htdocs/core/boxes/box_services_expired.php index 0c5d1a01632..738d6af078f 100644 --- a/htdocs/core/boxes/box_services_expired.php +++ b/htdocs/core/boxes/box_services_expired.php @@ -30,20 +30,20 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_services_expired extends ModeleBoxes { - var $boxcode="expiredservices"; // id of box - var $boximg="object_contract"; - var $boxlabel="BoxOldestExpiredServices"; - var $depends = array("contrat"); // conf->propal->enabled + public $boxcode="expiredservices"; // id of box + public $boximg="object_contract"; + public $boxlabel="BoxOldestExpiredServices"; + public $depends = array("contrat"); // conf->propal->enabled /** * @var DoliDB Database handler. */ public $db; - var $param; + public $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,7 +52,7 @@ class box_services_expired extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -67,7 +67,7 @@ class box_services_expired extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $user, $langs, $db, $conf; @@ -189,14 +189,14 @@ class box_services_expired extends ModeleBoxes } /** - * Method to show box + * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return string + * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_supplier_orders.php b/htdocs/core/boxes/box_supplier_orders.php index f9a47fe8c83..34316cd1ad1 100644 --- a/htdocs/core/boxes/box_supplier_orders.php +++ b/htdocs/core/boxes/box_supplier_orders.php @@ -31,19 +31,19 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; class box_supplier_orders extends ModeleBoxes { - var $boxcode = "latestsupplierorders"; - var $boximg = "object_order"; - var $boxlabel="BoxLatestSupplierOrders"; - var $depends = array("fournisseur"); + public $boxcode = "latestsupplierorders"; + public $boximg = "object_order"; + public $boxlabel="BoxLatestSupplierOrders"; + public $depends = array("fournisseur"); /** * @var DoliDB Database handler. */ public $db; - var $param; - var $info_box_head = array(); - var $info_box_contents = array(); + public $param; + public $info_box_head = array(); + public $info_box_contents = array(); /** @@ -52,7 +52,7 @@ class box_supplier_orders extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param) + public function __construct($db, $param) { global $user; @@ -67,7 +67,7 @@ class box_supplier_orders extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; $langs->load("boxes"); @@ -177,14 +177,14 @@ class box_supplier_orders extends ModeleBoxes } /** - * Method to show box + * Method to show box * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines - * @param int $nooutput No print, only return string - * @return string - */ - function showBox($head = null, $contents = null, $nooutput = 0) + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines + * @param int $nooutput No print, only return string + * @return string + */ + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/box_task.php b/htdocs/core/boxes/box_task.php index 181de1f8696..d07792dc991 100644 --- a/htdocs/core/boxes/box_task.php +++ b/htdocs/core/boxes/box_task.php @@ -54,7 +54,7 @@ class box_task extends ModeleBoxes * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { global $user, $langs; @@ -73,7 +73,7 @@ class box_task extends ModeleBoxes * @param int $max Maximum number of records to load * @return void */ - function loadBox($max = 5) + public function loadBox($max = 5) { global $conf, $user, $langs, $db; @@ -150,7 +150,7 @@ class box_task extends ModeleBoxes * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput); } diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 4e715014992..79d4f17d8ee 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -115,7 +115,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * @param DoliDB $db Database handler * @param string $param More parameters */ - function __construct($db, $param = '') + public function __construct($db, $param = '') { $this->db=$db; } @@ -125,7 +125,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * * @return string Error message */ - function error() + public function error() { return $this->error; } @@ -138,7 +138,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { global $conf; @@ -182,7 +182,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * * @return string */ - function outputBox($head = null, $contents = null) + public function outputBox($head = null, $contents = null) { global $langs, $user, $conf; @@ -204,7 +204,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * @param int $nooutput No print, only return string * @return string */ - function showBox($head = null, $contents = null, $nooutput = 0) + public function showBox($head = null, $contents = null, $nooutput = 0) { global $langs, $user, $conf; @@ -385,7 +385,7 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box * @param array $forcedirwidget null=All default directories. This parameter is used by modulebuilder module only. * @return array Array list of widget */ - static function getWidgetsList($forcedirwidget = null) + public static function getWidgetsList($forcedirwidget = null) { global $conf, $langs, $db; diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index c64b408336c..585717fc4c7 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -40,53 +40,53 @@ class CMailFile public $sendmode; public $sendsetup; - var $subject; // Topic: Subject of email - var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). + public $subject; // Topic: Subject of email + public $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or ''). Note that with gmail smtps, value here is forced by google to account (but not the reply-to). // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain. // Return-Path: Email where to send bounds. - var $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) - var $errors_to; // Errors-To: Email where to send errors. - var $addr_to; - var $addr_cc; - var $addr_bcc; - var $trackid; + public $reply_to; // Reply-To: Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined) + public $errors_to; // Errors-To: Email where to send errors. + public $addr_to; + public $addr_cc; + public $addr_bcc; + public $trackid; - var $mixed_boundary; - var $related_boundary; - var $alternative_boundary; - var $deliveryreceipt; + public $mixed_boundary; + public $related_boundary; + public $alternative_boundary; + public $deliveryreceipt; - var $eol; - var $eol2; + public $eol; + public $eol2; /** * @var string Error code (or message) */ public $error=''; - var $smtps; // Contains SMTPs object (if this method is used) - var $phpmailer; // Contains PHPMailer object (if this method is used) + public $smtps; // Contains SMTPs object (if this method is used) + public $phpmailer; // Contains PHPMailer object (if this method is used) /** * @var string CSS */ public $css; //! Defined css style for body background - var $styleCSS; + public $styleCSS; //! Defined background directly in body tag - var $bodyCSS; + public $bodyCSS; - var $headers; - var $message; + public $headers; + public $message; // Image - var $html; - var $image_boundary; - var $atleastoneimage=0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). - var $html_images=array(); - var $images_encoded=array(); - var $image_types = array( + public $html; + public $image_boundary; + public $atleastoneimage=0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used). + public $html_images=array(); + public $images_encoded=array(); + public $image_types = array( 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', @@ -119,7 +119,7 @@ class CMailFile * @param string $sendcontext 'standard', 'emailing', ... (used to define with sending mode and parameters to use) * @param string $replyto Reply-to email (will be set to same value than From by default if not provided) */ - function __construct($subject, $to, $from, $msg, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = 0, $errors_to = '', $css = '', $trackid = '', $moreinheader = '', $sendcontext = 'standard', $replyto = '') + public function __construct($subject, $to, $from, $msg, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array(), $addr_cc = "", $addr_bcc = "", $deliveryreceipt = 0, $msgishtml = 0, $errors_to = '', $css = '', $trackid = '', $moreinheader = '', $sendcontext = 'standard', $replyto = '') { global $conf, $dolibarr_main_data_root; @@ -407,8 +407,8 @@ class CMailFile } } - // Set the To addresses with an associative array - if (! empty($to)) { + // Set the To addresses with an associative array + if (! empty($to)) { try { $result = $this->message->setTo($this->getArrayAddress($to)); } catch (Exception $e) { @@ -493,7 +493,7 @@ class CMailFile * * @return boolean True if mail sent, false otherwise */ - function sendfile() + public function sendfile() { global $conf,$db,$langs; @@ -752,9 +752,9 @@ class CMailFile } elseif ($this->sendmode == 'swiftmailer') { - // Use Swift Mailer library - // ------------------------------------------ - require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; + // Use Swift Mailer library + // ------------------------------------------ + require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php'; // Clean parameters if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver=ini_get('SMTP'); @@ -844,20 +844,20 @@ class CMailFile * @param string $stringtoencode String to encode * @return string string encoded */ - static function encodetorfc2822($stringtoencode) + public static function encodetorfc2822($stringtoencode) { global $conf; return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?='; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read a file on disk and return encoded content for emails (mode = 'mail') * * @param string $sourcefile Path to file to encode * @return int <0 if KO, encoded string if OK */ - function _encode_file($sourcefile) + private function _encode_file($sourcefile) { // phpcs:enable $newsourcefile=dol_osencode($sourcefile); @@ -877,7 +877,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write content of a SMTP request into a dump file (mode = all) * Used for debugging. @@ -885,7 +885,7 @@ class CMailFile * * @return void */ - function dump_mail() + public function dump_mail() { // phpcs:enable global $conf,$dolibarr_main_data_root; @@ -923,7 +923,7 @@ class CMailFile * @param string $msg String * @return string Completed string */ - function checkIfHTML($msg) + public function checkIfHTML($msg) { if (!preg_match('/^[\s\t]*css)) { @@ -972,13 +972,13 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create SMTP headers (mode = 'mail') * * @return string headers */ - function write_smtpheaders() + public function write_smtpheaders() { // phpcs:enable global $conf; @@ -1036,7 +1036,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create header MIME (mode = 'mail') * @@ -1044,7 +1044,7 @@ class CMailFile * @param array $mimefilename_list Array of mime types * @return string mime headers */ - function write_mimeheaders($filename_list, $mimefilename_list) + public function write_mimeheaders($filename_list, $mimefilename_list) { // phpcs:enable $mimedone=0; @@ -1067,14 +1067,14 @@ class CMailFile return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return email content (mode = 'mail') * * @param string $msgtext Message string * @return string String content */ - function write_body($msgtext) + public function write_body($msgtext) { // phpcs:enable global $conf; @@ -1169,7 +1169,7 @@ class CMailFile return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Attach file to email (mode = 'mail') * @@ -1178,7 +1178,7 @@ class CMailFile * @param array $mimefilename_list Tableau * @return string Chaine fichiers encodes */ - function write_files($filename_list, $mimetype_list, $mimefilename_list) + public function write_files($filename_list, $mimetype_list, $mimefilename_list) { // phpcs:enable $out = ''; @@ -1218,14 +1218,14 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Attach an image to email (mode = 'mail') * * @param array $images_list Array of array image * @return string Chaine images encodees */ - function write_images($images_list) + public function write_images($images_list) { // phpcs:enable $out = ''; @@ -1251,7 +1251,7 @@ class CMailFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Try to create a socket connection * @@ -1259,7 +1259,7 @@ class CMailFile * @param int $port Example: 25, 465 * @return int Socket id if ok, 0 if KO */ - function check_server_port($host, $port) + public function check_server_port($host, $port) { // phpcs:enable global $conf; @@ -1315,7 +1315,7 @@ class CMailFile return $_retVal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This function has been modified as provided by SirSir to allow multiline responses when * using SMTP Extensions. @@ -1324,7 +1324,7 @@ class CMailFile * @param string $response Response string * @return boolean true if success */ - function server_parse($socket, $response) + public function server_parse($socket, $response) { // phpcs:enable $_retVal = true; // Indicates if Object was created or not @@ -1354,7 +1354,7 @@ class CMailFile * @param string $images_dir Location of physical images files * @return int >0 if OK, <0 if KO */ - function findHtmlImages($images_dir) + public function findHtmlImages($images_dir) { // Build the list of image extensions $extensions = array_keys($this->image_types); @@ -1456,7 +1456,7 @@ class CMailFile * If format 3: '' or '"John Doe" ' or '"=?UTF-8?B?Sm9obiBEb2U=?=" ' * If format 4: 'John Doe' or 'john@doe.com' if no label exists */ - static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) + public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0) { global $conf; @@ -1523,7 +1523,7 @@ class CMailFile * @param string $address Example: 'John Doe , Alan Smith ' or 'john@doe.com, alan@smith.com' * @return array array of email => name */ - function getArrayAddress($address) + public function getArrayAddress($address) { global $conf; diff --git a/htdocs/core/class/CSMSFile.class.php b/htdocs/core/class/CSMSFile.class.php index 8bd70d8e063..cd5c9ae28b7 100644 --- a/htdocs/core/class/CSMSFile.class.php +++ b/htdocs/core/class/CSMSFile.class.php @@ -59,7 +59,7 @@ class CSMSFile * @param int $priority Priority * @param int $class Class */ - function __construct($to, $from, $msg, $deliveryreceipt = 0, $deferred = 0, $priority = 3, $class = 1) + public function __construct($to, $from, $msg, $deliveryreceipt = 0, $deferred = 0, $priority = 3, $class = 1) { global $conf; @@ -94,7 +94,7 @@ class CSMSFile * * @return boolean True if sms sent, false otherwise */ - function sendfile() + public function sendfile() { global $conf; @@ -195,17 +195,17 @@ class CSMSFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Write content of a SendSms request into a dump file (mode = all) - * Used for debugging. - * - * @return void - */ - function dump_sms() - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Write content of a SendSms request into a dump file (mode = all) + * Used for debugging. + * + * @return void + */ + public function dump_sms() + { // phpcs:enable - global $conf,$dolibarr_main_data_root; + global $conf,$dolibarr_main_data_root; if (@is_writeable($dolibarr_main_data_root)) // Avoid fatal error on fopen with open_basedir { @@ -226,7 +226,7 @@ class CSMSFile } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write content of a SendSms result into a dump file (mode = all) * Used for debugging. @@ -234,7 +234,7 @@ class CSMSFile * @param int $result Result of sms sending * @return void */ - function dump_sms_result($result) + public function dump_sms_result($result) { // phpcs:enable global $conf,$dolibarr_main_data_root; diff --git a/htdocs/core/class/antivir.class.php b/htdocs/core/class/antivir.class.php index dc0490285be..55bd3a8381d 100644 --- a/htdocs/core/class/antivir.class.php +++ b/htdocs/core/class/antivir.class.php @@ -55,12 +55,12 @@ class AntiVir * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Scan a file with antivirus. * This function runs the command defined in setup. This antivirus command must return 0 if OK. @@ -69,7 +69,7 @@ class AntiVir * @param string $file File to scan * @return int <0 if KO (-98 if error, -99 if virus), 0 if OK */ - function dol_avscan_file($file) + public function dol_avscan_file($file) { // phpcs:enable global $conf; @@ -153,7 +153,7 @@ class AntiVir * @param string $file File to scan * @return string Full command line to run */ - function getCliCommand($file) + public function getCliCommand($file) { global $conf; diff --git a/htdocs/core/class/canvas.class.php b/htdocs/core/class/canvas.class.php index 0250a138fb8..1351f0ea3c7 100644 --- a/htdocs/core/class/canvas.class.php +++ b/htdocs/core/class/canvas.class.php @@ -60,7 +60,7 @@ class Canvas * @param DoliDB $db Database handler * @param string $actiontype Action type ('create', 'view', 'edit', 'list') */ - function __construct($db, $actiontype = 'view') + public function __construct($db, $actiontype = 'view') { $this->db = $db; @@ -91,7 +91,7 @@ class Canvas * @param string $canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule) * @return void */ - function getCanvas($module, $card, $canvas) + public function getCanvas($module, $card, $canvas) { global $conf, $langs; @@ -133,7 +133,7 @@ class Canvas //print ' => template_dir='.$this->template_dir.'
'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Shared method for canvas to assign values for templates * @@ -142,7 +142,7 @@ class Canvas * @param string $ref Object ref (if id not provided) * @return void */ - function assign_values(&$action = 'view', $id = 0, $ref = '') + public function assign_values(&$action = 'view', $id = 0, $ref = '') { // phpcs:enable if (method_exists($this->control, 'assign_values')) $this->control->assign_values($action, $id, $ref); @@ -154,7 +154,7 @@ class Canvas * @param string $action Action code * @return int 0=Canvas template file does not exist, 1=Canvas template file exists */ - function displayCanvasExists($action) + public function displayCanvasExists($action) { if (empty($this->template_dir)) return 0; @@ -162,7 +162,7 @@ class Canvas else return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display a canvas page. This will include the template for output. * Variables used by templates may have been defined or loaded before into the assign_values function. @@ -170,7 +170,7 @@ class Canvas * @param string $action Action code * @return void */ - function display_canvas($action) + public function display_canvas($action) { // phpcs:enable global $db, $conf, $langs, $user, $canvas; @@ -188,7 +188,7 @@ class Canvas * * @return boolean Return if canvas contains actions (old feature. now actions should be inside hooks) */ - function hasActions() + public function hasActions() { return (is_object($this->control)); } @@ -204,7 +204,7 @@ class Canvas * @return mixed Return return code of doActions of canvas * @see http://wiki.dolibarr.org/index.php/Canvas_development */ - function doActions(&$action = 'view', $id = 0) + public function doActions(&$action = 'view', $id = 0) { if (method_exists($this->control, 'doActions')) { diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index e93af622a27..a97d992bf89 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -73,7 +73,7 @@ class Ccountry // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -86,7 +86,7 @@ class Ccountry // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -165,7 +165,7 @@ class Ccountry // extends CommonObject * @param string $code Code * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($id, $code = '') + public function fetch($id, $code = '') { global $langs; $sql = "SELECT"; @@ -214,7 +214,7 @@ class Ccountry // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -285,7 +285,7 @@ class Ccountry // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; diff --git a/htdocs/core/class/comment.class.php b/htdocs/core/class/comment.class.php index 6d00b4b8d8d..502ba924513 100644 --- a/htdocs/core/class/comment.class.php +++ b/htdocs/core/class/comment.class.php @@ -69,7 +69,7 @@ class Comment extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -82,7 +82,7 @@ class Comment extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -155,7 +155,7 @@ class Comment extends CommonObject * @param int $ref ref object * @return int <0 if KO, 0 if not found, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $langs; @@ -213,7 +213,7 @@ class Comment extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <=0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -278,7 +278,7 @@ class Comment extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index c1b483efe8c..d4a89c18e19 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -61,7 +61,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -69,7 +69,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_user($user, $outputlangs) + public function get_substitutionarray_user($user, $outputlangs) { // phpcs:enable global $conf; @@ -99,7 +99,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -107,7 +107,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_mysoc($mysoc, $outputlangs) + public function get_substitutionarray_mysoc($mysoc, $outputlangs) { // phpcs:enable global $conf; @@ -159,7 +159,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -167,7 +167,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_thirdparty($object, $outputlangs) + public function get_substitutionarray_thirdparty($object, $outputlangs) { // phpcs:enable global $conf; @@ -240,7 +240,7 @@ abstract class CommonDocGenerator return $array_thirdparty; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -249,7 +249,7 @@ abstract class CommonDocGenerator * @param array $array_key Name of the key for return array * @return array Array of substitution key->code */ - function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_contact($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -314,14 +314,14 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * * @param Translate $outputlangs Language object for output * @return array Array of substitution key->code */ - function get_substitutionarray_other($outputlangs) + public function get_substitutionarray_other($outputlangs) { // phpcs:enable global $conf; @@ -352,7 +352,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -361,7 +361,7 @@ abstract class CommonDocGenerator * @param string $array_key Name of the key for return array * @return array Array of substitution */ - function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -518,7 +518,7 @@ abstract class CommonDocGenerator return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -526,7 +526,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_lines($line, $outputlangs) + public function get_substitutionarray_lines($line, $outputlangs) { // phpcs:enable global $conf; @@ -599,7 +599,7 @@ abstract class CommonDocGenerator return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -608,7 +608,7 @@ abstract class CommonDocGenerator * @param array $array_key Name of the key for return array * @return array Array of substitution */ - function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_shipment($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -662,7 +662,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -670,7 +670,7 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Lang object to use for output * @return array Substitution array */ - function get_substitutionarray_shipment_lines($line, $outputlangs) + public function get_substitutionarray_shipment_lines($line, $outputlangs) { // phpcs:enable global $conf; @@ -683,7 +683,7 @@ abstract class CommonDocGenerator 'line_desc'=>$line->desc, 'line_vatrate'=>vatrate($line->tva_tx, true, $line->info_bits), 'line_up'=>price($line->subprice), - 'line_total_up'=>price($line->subprice * $line->qty), + 'line_total_up'=>price($line->subprice * $line->qty), 'line_qty'=>$line->qty, 'line_qty_shipped'=>$line->qty_shipped, 'line_qty_asked'=>$line->qty_asked, @@ -711,7 +711,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple subtitution key => subtitution value * @@ -720,7 +720,7 @@ abstract class CommonDocGenerator * @param boolean $recursive Want to fetch child array or child object * @return array Array of substitution key->code */ - function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) + public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) { // phpcs:enable $array_other = array(); @@ -740,7 +740,7 @@ abstract class CommonDocGenerator } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fill array with couple extrafield key => extrafield value * @@ -751,8 +751,8 @@ abstract class CommonDocGenerator * @param Translate $outputlangs Lang object to use for output * @return array Substitution array */ - function fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs) - { + public function fill_substitutionarray_with_extrafields($object, $array_to_fill, $extrafields, $array_key, $outputlangs) + { // phpcs:enable global $conf; foreach($extrafields->attribute_label as $key=>$label) @@ -838,7 +838,7 @@ abstract class CommonDocGenerator * @param int $hidebottom Hide bottom * @return void */ - function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) + public function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) { if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); $pdf->line($x+$l, $y, $x+$l, $y+$h); @@ -848,13 +848,13 @@ abstract class CommonDocGenerator /** - * uasort callback function to Sort colums fields + * uasort callback function to Sort colums fields * - * @param array $a PDF lines array fields configs - * @param array $b PDF lines array fields configs - * @return int Return compare result + * @param array $a PDF lines array fields configs + * @param array $b PDF lines array fields configs + * @return int Return compare result */ - function columnSort($a, $b) + public function columnSort($a, $b) { if(empty($a['rank'])){ $a['rank'] = 0; } if(empty($b['rank'])){ $b['rank'] = 0; } @@ -874,7 +874,7 @@ abstract class CommonDocGenerator * @param int $hideref Do not show ref * @return null */ - function prepareArrayColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function prepareArrayColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $conf; @@ -950,7 +950,7 @@ abstract class CommonDocGenerator * @param string $colKey the column key * @return float width in mm */ - function getColumnContentWidth($colKey) + public function getColumnContentWidth($colKey) { $colDef = $this->cols[$colKey]; return $colDef['width'] - $colDef['content']['padding'][3] - $colDef['content']['padding'][1]; @@ -958,12 +958,12 @@ abstract class CommonDocGenerator /** - * get column content X (abscissa) left position from column key + * get column content X (abscissa) left position from column key * - * @param string $colKey the column key - * @return float X position in mm + * @param string $colKey the column key + * @return float X position in mm */ - function getColumnContentXStart($colKey) + public function getColumnContentXStart($colKey) { $colDef = $this->cols[$colKey]; return $colDef['xStartPos'] + $colDef['content']['padding'][3]; @@ -975,22 +975,22 @@ abstract class CommonDocGenerator * @param string $colKey the column key * @return int rank on success and -1 on error */ - function getColumnRank($colKey) + public function getColumnRank($colKey) { if(!isset($this->cols[$colKey]['rank'])) return -1; return $this->cols[$colKey]['rank']; } /** - * get column position rank from column key + * get column position rank from column key * - * @param string $newColKey the new column key - * @param array $defArray a single column definition array - * @param string $targetCol target column used to place the new column beside - * @param bool $insertAfterTarget insert before or after target column ? - * @return int new rank on success and -1 on error + * @param string $newColKey the new column key + * @param array $defArray a single column definition array + * @param string $targetCol target column used to place the new column beside + * @param bool $insertAfterTarget insert before or after target column ? + * @return int new rank on success and -1 on error */ - function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) + public function insertNewColumnDef($newColKey, $defArray, $targetCol = false, $insertAfterTarget = false) { // prepare wanted rank $rank = -1; @@ -1033,7 +1033,7 @@ abstract class CommonDocGenerator * @param string $columnText column text * @return int new rank on success and -1 on error */ - function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') + public function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '') { global $hookmanager; @@ -1055,12 +1055,12 @@ abstract class CommonDocGenerator /** - * get column status from column key + * get column status from column key * - * @param string $colKey the column key - * @return float width in mm + * @param string $colKey the column key + * @return float width in mm */ - function getColumnStatus($colKey) + public function getColumnStatus($colKey) { if( !empty($this->cols[$colKey]['status'])){ return true; diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 7e8c9002042..5926f954a46 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -97,7 +97,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return double Remain of amount to pay */ - function getRemainToPay($multicurrency = 0) + public function getRemainToPay($multicurrency = 0) { $alreadypaid=0; $alreadypaid+=$this->getSommePaiement($multicurrency); @@ -112,7 +112,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int Amount of payment already done, <0 if KO */ - function getSommePaiement($multicurrency = 0) + public function getSommePaiement($multicurrency = 0) { $table='paiement_facture'; $field='fk_facture'; @@ -149,7 +149,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of deposits amount otherwise */ - function getSumDepositsUsed($multicurrency = 0) + public function getSumDepositsUsed($multicurrency = 0) { if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier') { @@ -178,7 +178,7 @@ abstract class CommonInvoice extends CommonObject * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumCreditNotesUsed($multicurrency = 0) + public function getSumCreditNotesUsed($multicurrency = 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; @@ -200,7 +200,7 @@ abstract class CommonInvoice extends CommonObject * * @return array Tableau d'id de factures avoirs */ - function getListIdAvoirFromInvoice() + public function getListIdAvoirFromInvoice() { $idarray=array(); @@ -233,7 +233,7 @@ abstract class CommonInvoice extends CommonObject * @param string $option filtre sur statut ('', 'validated', ...) * @return int <0 si KO, 0 si aucune facture ne remplace, id facture sinon */ - function getIdReplacingInvoice($option = '') + public function getIdReplacingInvoice($option = '') { $sql = 'SELECT rowid'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element; @@ -274,7 +274,7 @@ abstract class CommonInvoice extends CommonObject * @param string $filtertype 1 to filter on type of payment == 'PRE' * @return array Array with list of payments */ - function getListOfPayments($filtertype = '') + public function getListOfPayments($filtertype = '') { $retarray=array(); @@ -325,7 +325,7 @@ abstract class CommonInvoice extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if an invoice can be deleted * Rule is: @@ -339,8 +339,8 @@ abstract class CommonInvoice extends CommonObject * * @return int <=0 if no, >0 if yes */ - function is_erasable() - { + public function is_erasable() + { // phpcs:enable global $conf; @@ -428,7 +428,7 @@ abstract class CommonInvoice extends CommonObject * * @return string Label of type of invoice */ - function getLibType() + public function getLibType() { global $langs; if ($this->type == CommonInvoice::TYPE_STANDARD) return $langs->trans("InvoiceStandard"); @@ -447,12 +447,12 @@ abstract class CommonInvoice extends CommonObject * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label of status */ - function getLibStatut($mode = 0, $alreadypaid = -1) + public function getLibStatut($mode = 0, $alreadypaid = -1) { return $this->LibStatut($this->paye, $this->statut, $mode, $alreadypaid, $this->type); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -463,18 +463,16 @@ abstract class CommonInvoice extends CommonObject * @param int $type Type invoice * @return string Label of status */ - function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) + public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) { // phpcs:enable global $langs; $langs->load('bills'); //print "$paye,$status,$mode,$alreadypaid,$type"; - if ($mode == 0) - { + if ($mode == 0) { $prefix=''; - if (! $paye) - { + if (! $paye) { if ($status == 0) return $langs->trans('Bill'.$prefix.'StatusDraft'); elseif (($status == 3 || $status == 2) && $alreadypaid <= 0) return $langs->trans('Bill'.$prefix.'StatusClosedUnpaid'); elseif (($status == 3 || $status == 2) && $alreadypaid > 0) return $langs->trans('Bill'.$prefix.'StatusClosedPaidPartially'); @@ -585,7 +583,7 @@ abstract class CommonInvoice extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi une date limite de reglement de facture en fonction des * conditions de reglements de la facture et date de facturation. @@ -593,7 +591,7 @@ abstract class CommonInvoice extends CommonObject * @param integer $cond_reglement Condition of payment (code or id) to use. If 0, we use current condition. * @return date Date limite de reglement si ok, <0 si ko */ - function calculate_date_lim_reglement($cond_reglement = 0) + public function calculate_date_lim_reglement($cond_reglement = 0) { // phpcs:enable if (! $cond_reglement) $cond_reglement=$this->cond_reglement_code; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 98b9d93580a..e0b852f32d8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -423,7 +423,7 @@ abstract class CommonObject * @param string $ref_ext Ref ext of object to check * @return int <0 if KO, 0 if OK but not found, >0 if OK and exists */ - static function isExistingObject($element, $id, $ref = '', $ref_ext = '') + public static function isExistingObject($element, $id, $ref = '', $ref_ext = '') { global $db,$conf; @@ -457,7 +457,7 @@ abstract class CommonObject * * @return string String with errors */ - function errorsToString() + public function errorsToString() { return $this->error.(is_array($this->errors)?(($this->error!=''?', ':'').join(', ', $this->errors)):''); } @@ -468,7 +468,7 @@ abstract class CommonObject * @param string $objref Customer ref * @return string Customer ref formated */ - function getFormatedCustomerRef($objref) + public function getFormatedCustomerRef($objref) { global $hookmanager; @@ -488,7 +488,7 @@ abstract class CommonObject * @param string $objref Supplier ref * @return string Supplier ref formated */ - function getFormatedSupplierRef($objref) + public function getFormatedSupplierRef($objref) { global $hookmanager; @@ -511,7 +511,7 @@ abstract class CommonObject * @param int $maxlen Maximum length * @return string String with full name */ - function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0) + public function getFullName($langs, $option = 0, $nameorder = -1, $maxlen = 0) { //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."
\n"; $lastname=$this->lastname; @@ -538,7 +538,7 @@ abstract class CommonObject * @param int $withregion 1=Add region into address string * @return string Full address string */ - function getFullAddress($withcountry = 0, $sep = "\n", $withregion = 0) + public function getFullAddress($withcountry = 0, $sep = "\n", $withregion = 0) { if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country))) { @@ -569,7 +569,7 @@ abstract class CommonObject * @param Object $object Object (thirdparty, thirdparty of contact for contact, null for a member) * @return string Full address string */ - function getBannerAddress($htmlkey, $object) + public function getBannerAddress($htmlkey, $object) { global $conf, $langs; @@ -690,7 +690,7 @@ abstract class CommonObject * @param int $relativelink 0=Return full external link, 1=Return link relative to root of file * @return string Link or empty string if there is no download link */ - function getLastMainDocLink($modulepart, $initsharekey = 0, $relativelink = 0) + public function getLastMainDocLink($modulepart, $initsharekey = 0, $relativelink = 0) { global $user, $dolibarr_main_url_root; @@ -777,7 +777,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a link between element $this->element and a contact * @@ -787,7 +787,7 @@ abstract class CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) + public function add_contact($fk_socpeople, $type_contact, $source = 'external', $notrigger = 0) { // phpcs:enable global $user,$langs; @@ -901,7 +901,7 @@ abstract class CommonObject } else return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Copy contact from one element to current * @@ -909,7 +909,7 @@ abstract class CommonObject * @param string $source Nature of contact ('internal' or 'external') * @return int >0 if OK, <0 if KO */ - function copy_linked_contact($objFrom, $source = 'internal') + public function copy_linked_contact($objFrom, $source = 'internal') { // phpcs:enable $contacts = $objFrom->liste_contact(-1, $source); @@ -924,7 +924,7 @@ abstract class CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a link to contact line * @@ -934,7 +934,7 @@ abstract class CommonObject * @param int $fk_socpeople Id of soc_people to update (not modified if 0) * @return int <0 if KO, >= 0 if OK */ - function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0) + public function update_contact($rowid, $statut, $type_contact_id = 0, $fk_socpeople = 0) { // phpcs:enable // Insert into database @@ -955,7 +955,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a link to contact line * @@ -963,7 +963,7 @@ abstract class CommonObject * @param int $notrigger Disable all triggers * @return int >0 if OK, <0 if KO */ - function delete_contact($rowid, $notrigger = 0) + public function delete_contact($rowid, $notrigger = 0) { // phpcs:enable global $user; @@ -994,7 +994,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete all links between an object $this and all its contacts * @@ -1002,7 +1002,7 @@ abstract class CommonObject * @param string $code Type of contact (code or id) * @return int >0 if OK, <0 if KO */ - function delete_linked_contact($source = '', $code = '') + public function delete_linked_contact($source = '', $code = '') { // phpcs:enable $temp = array(); @@ -1031,7 +1031,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get array of all contacts for an object * @@ -1041,7 +1041,7 @@ abstract class CommonObject * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) * @return array|int Array of contacts, -1 if error */ - function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '') + public function liste_contact($statut = -1, $source = 'external', $list = 0, $code = '') { // phpcs:enable global $langs; @@ -1111,7 +1111,7 @@ abstract class CommonObject * @param int $rowid Id of link between object and contact * @return int <0 if KO, >=0 if OK */ - function swapContactStatus($rowid) + public function swapContactStatus($rowid) { $sql = "SELECT ec.datecreate, ec.statut, ec.fk_socpeople, ec.fk_c_type_contact,"; $sql.= " tc.code, tc.libelle"; @@ -1140,7 +1140,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array with list of possible values for type of contacts * @@ -1151,7 +1151,7 @@ abstract class CommonObject * @param string $code Type of contact (Example: 'CUSTOMER', 'SERVICE') * @return array Array list of type of contacts (id->label if option=0, code->label if option=1) */ - function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '') + public function liste_type_contact($source = 'internal', $order = 'position', $option = 0, $activeonly = 0, $code = '') { // phpcs:enable global $langs; @@ -1205,7 +1205,7 @@ abstract class CommonObject * @param int $status limited to a certain status * @return array List of id for such contacts */ - function getIdContact($source, $code, $status = 0) + public function getIdContact($source, $code, $status = 0) { global $conf; @@ -1258,14 +1258,14 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object contact with id=$this->contactid into $this->contact * * @param int $contactid Id du contact. Use this->contactid if empty. * @return int <0 if KO, >0 if OK */ - function fetch_contact($contactid = null) + public function fetch_contact($contactid = null) { // phpcs:enable if (empty($contactid)) $contactid=$this->contactid; @@ -1279,14 +1279,14 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the third party of object, from id $this->socid or $this->fk_soc, into this->thirdparty * * @param int $force_thirdparty_id Force thirdparty id * @return int <0 if KO, >0 if OK */ - function fetch_thirdparty($force_thirdparty_id = 0) + public function fetch_thirdparty($force_thirdparty_id = 0) { // phpcs:enable global $conf; @@ -1342,7 +1342,7 @@ abstract class CommonObject return $this->fetch($result->rowid); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load data for barcode into properties ->barcode_type* * Properties ->barcode_type that is id of barcode. Type is used to find other properties, but @@ -1350,7 +1350,7 @@ abstract class CommonObject * * @return int <0 if KO, 0 if can't guess type of barcode (ISBN, EAN13...), >0 if OK (all barcode properties loaded) */ - function fetch_barcode() + public function fetch_barcode() { // phpcs:enable global $conf; @@ -1393,13 +1393,13 @@ abstract class CommonObject return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the project with id $this->fk_project into this->project * * @return int <0 if KO, >=0 if OK */ - function fetch_projet() + public function fetch_projet() { // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; @@ -1415,13 +1415,13 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the product with id $this->fk_product into this->product * * @return int <0 if KO, >=0 if OK */ - function fetch_product() + public function fetch_product() { // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; @@ -1435,14 +1435,14 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the user with id $userid into this->user * * @param int $userid Id du contact * @return int <0 if KO, >0 if OK */ - function fetch_user($userid) + public function fetch_user($userid) { // phpcs:enable $user = new User($this->db); @@ -1451,13 +1451,13 @@ abstract class CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read linked origin object * * @return void */ - function fetch_origin() + public function fetch_origin() { // phpcs:enable if ($this->origin == 'shipping') $this->origin = 'expedition'; @@ -1480,7 +1480,7 @@ abstract class CommonObject * @param string $element Element name * @return int <0 if KO, >0 if OK */ - function fetchObjectFrom($table, $field, $key, $element = null) + public function fetchObjectFrom($table, $field, $key, $element = null) { global $conf; @@ -1516,7 +1516,7 @@ abstract class CommonObject * @param string $field Field selected * @return int <0 if KO, >0 if OK */ - function getValueFrom($table, $id, $field) + public function getValueFrom($table, $id, $field) { $result=false; if (!empty($id) && !empty($field) && !empty($table)) { @@ -1550,7 +1550,7 @@ abstract class CommonObject * @return int <0 if KO, >0 if OK * @see updateExtraField() */ - function setValueFrom($field, $value, $table = '', $id = null, $format = '', $id_field = '', $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif') + public function setValueFrom($field, $value, $table = '', $id = null, $format = '', $id_field = '', $fuser = null, $trigkey = '', $fk_user_field = 'fk_user_modif') { global $user,$langs,$conf; @@ -1620,7 +1620,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load properties id_previous and id_next by comparing $fieldid with $this->ref * @@ -1629,7 +1629,7 @@ abstract class CommonObject * @param int $nodbprefix Do not include DB prefix to forge table name * @return int <0 if KO, >0 if OK */ - function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) + public function load_previous_next_ref($filter, $fieldid, $nodbprefix = 0) { // phpcs:enable global $conf, $user; @@ -1753,7 +1753,7 @@ abstract class CommonObject * @return array Array of id of contacts (if source=external or internal) * Array of id of third parties with at least one contact on object (if source=thirdparty) */ - function getListContactId($source = 'external') + public function getListContactId($source = 'external') { $contactAlreadySelected = array(); $tab = $this->liste_contact(-1, $source); @@ -1775,7 +1775,7 @@ abstract class CommonObject * @param int $projectid Project id to link element to * @return int <0 if KO, >0 if OK */ - function setProject($projectid) + public function setProject($projectid) { if (! $this->table_element) { @@ -1816,7 +1816,7 @@ abstract class CommonObject * @param int $id Id of new payment method * @return int >0 if OK, <0 if KO */ - function setPaymentMethods($id) + public function setPaymentMethods($id) { dol_syslog(get_class($this).'::setPaymentMethods('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -1858,7 +1858,7 @@ abstract class CommonObject * @param string $code multicurrency code * @return int >0 if OK, <0 if KO */ - function setMulticurrencyCode($code) + public function setMulticurrencyCode($code) { dol_syslog(get_class($this).'::setMulticurrencyCode('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -1900,7 +1900,7 @@ abstract class CommonObject * @param int $mode mode 1 : amounts in company currency will be recalculated, mode 2 : amounts in foreign currency * @return int >0 if OK, <0 if KO */ - function setMulticurrencyRate($rate, $mode = 1) + public function setMulticurrencyRate($rate, $mode = 1) { dol_syslog(get_class($this).'::setMulticurrencyRate('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -2001,7 +2001,7 @@ abstract class CommonObject * @param int $id Id of new payment terms * @return int >0 if OK, <0 if KO */ - function setPaymentTerms($id) + public function setPaymentTerms($id) { dol_syslog(get_class($this).'::setPaymentTerms('.$id.')'); if ($this->statut >= 0 || $this->element == 'societe') @@ -2045,7 +2045,7 @@ abstract class CommonObject * @param int $id Address id * @return int <0 si ko, >0 si ok */ - function setDeliveryAddress($id) + public function setDeliveryAddress($id) { $fieldname = 'fk_delivery_address'; if ($this->element == 'delivery' || $this->element == 'shipping') $fieldname = 'fk_address'; @@ -2076,7 +2076,7 @@ abstract class CommonObject * * @return int 1 if OK, 0 if KO */ - function setShippingMethod($shipping_method_id, $notrigger = false, $userused = null) + public function setShippingMethod($shipping_method_id, $notrigger = false, $userused = null) { global $user; @@ -2130,7 +2130,7 @@ abstract class CommonObject * @param int $warehouse_id Id of warehouse * @return int 1 if OK, 0 if KO */ - function setWarehouse($warehouse_id) + public function setWarehouse($warehouse_id) { if (! $this->table_element) { dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined", LOG_ERR); @@ -2161,7 +2161,7 @@ abstract class CommonObject * @param string $modelpdf Modele name * @return int <0 if KO, >0 if OK */ - function setDocModel($user, $modelpdf) + public function setDocModel($user, $modelpdf) { if (! $this->table_element) { @@ -2200,7 +2200,7 @@ abstract class CommonObject * @param User $userused Object user * @return int 1 if OK, 0 if KO */ - function setBankAccount($fk_account, $notrigger = false, $userused = null) + public function setBankAccount($fk_account, $notrigger = false, $userused = null) { global $user; @@ -2255,7 +2255,7 @@ abstract class CommonObject // TODO: Move line related operations to CommonObjectLine? - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Save a new position (field rang) for details lines. * You can choose to set position for lines with already a position or lines without any position defined. @@ -2265,7 +2265,7 @@ abstract class CommonObject * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return int <0 if KO, >0 if OK */ - function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true) + public function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line = true) { // phpcs:enable if (! $this->table_element_line) @@ -2350,7 +2350,7 @@ abstract class CommonObject * @param int $id Id of parent line * @return array Array with list of children lines id */ - function getChildrenOfLine($id) + public function getChildrenOfLine($id) { $rows=array(); @@ -2376,7 +2376,7 @@ abstract class CommonObject return $rows; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a line to have a lower rank * @@ -2384,7 +2384,7 @@ abstract class CommonObject * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return void */ - function line_up($rowid, $fk_parent_line = true) + public function line_up($rowid, $fk_parent_line = true) { // phpcs:enable $this->line_order(false, 'ASC', $fk_parent_line); @@ -2396,7 +2396,7 @@ abstract class CommonObject $this->updateLineUp($rowid, $rang); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a line to have a higher rank * @@ -2404,7 +2404,7 @@ abstract class CommonObject * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return void */ - function line_down($rowid, $fk_parent_line = true) + public function line_down($rowid, $fk_parent_line = true) { // phpcs:enable $this->line_order(false, 'ASC', $fk_parent_line); @@ -2426,7 +2426,7 @@ abstract class CommonObject * @param int $rang Position * @return void */ - function updateRangOfLine($rowid, $rang) + public function updateRangOfLine($rowid, $rang) { $fieldposition = 'rang'; if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) $fieldposition = 'position'; @@ -2441,14 +2441,14 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update position of line with ajax (rang) * * @param array $rows Array of rows * @return void */ - function line_ajaxorder($rows) + public function line_ajaxorder($rows) { // phpcs:enable $num = count($rows); @@ -2465,7 +2465,7 @@ abstract class CommonObject * @param int $rang Position * @return void */ - function updateLineUp($rowid, $rang) + public function updateLineUp($rowid, $rang) { if ($rang > 1) { @@ -2499,7 +2499,7 @@ abstract class CommonObject * @param int $max Max * @return void */ - function updateLineDown($rowid, $rang, $max) + public function updateLineDown($rowid, $rang, $max) { if ($rang < $max) { @@ -2531,7 +2531,7 @@ abstract class CommonObject * @param int $rowid Id of line * @return int Value of rang in table of lines */ - function getRangOfLine($rowid) + public function getRangOfLine($rowid) { $sql = 'SELECT rang FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE rowid ='.$rowid; @@ -2551,7 +2551,7 @@ abstract class CommonObject * @param int $rang Rang value * @return int Rowid of the line */ - function getIdOfLine($rang) + public function getIdOfLine($rang) { $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; @@ -2564,14 +2564,14 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get max value used for position of line (rang) * * @param int $fk_parent_line Parent line id * @return int Max value of rang in table of lines */ - function line_max($fk_parent_line = 0) + public function line_max($fk_parent_line = 0) { // phpcs:enable // Search the last rang with fk_parent_line @@ -2612,14 +2612,14 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update external ref of element * * @param string $ref_ext Update field ref_ext * @return int <0 if KO, >0 if OK */ - function update_ref_ext($ref_ext) + public function update_ref_ext($ref_ext) { // phpcs:enable if (! $this->table_element) @@ -2645,7 +2645,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update note of element * @@ -2653,7 +2653,7 @@ abstract class CommonObject * @param string $suffix '', '_public' or '_private' * @return int <0 if KO, >0 if OK */ - function update_note($note, $suffix = '') + public function update_note($note, $suffix = '') { // phpcs:enable global $user; @@ -2698,7 +2698,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update public note (kept for backward compatibility) * @@ -2707,13 +2707,13 @@ abstract class CommonObject * @deprecated * @see update_note() */ - function update_note_public($note) + public function update_note_public($note) { // phpcs:enable return $this->update_note($note, '_public'); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total_ht, total_ttc, total_vat, total_localtax1, total_localtax2 for an object (sum of lines). * Must be called at end of methods addline or updateline. @@ -2724,7 +2724,7 @@ abstract class CommonObject * @param Societe $seller If roundingadjust is '0' or '1' or maybe 'auto', it means we recalculate total for lines before calculating total for object and for this, we need seller object. * @return int <0 if KO, >0 if OK */ - function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null) + public function update_price($exclspec = 0, $roundingadjust = 'none', $nodatabaseupdate = 0, $seller = null) { // phpcs:enable global $conf, $hookmanager, $action; @@ -2952,7 +2952,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add objects linked in llx_element_element. * @@ -2961,7 +2961,7 @@ abstract class CommonObject * @return int <=0 if KO, >0 if OK * @see fetchObjectLinked(), updateObjectLinked(), deleteObjectLinked() */ - function add_object_linked($origin = null, $origin_id = null) + public function add_object_linked($origin = null, $origin_id = null) { // phpcs:enable $origin = (! empty($origin) ? $origin : $this->origin); @@ -3022,7 +3022,7 @@ abstract class CommonObject * @return int <0 if KO, >0 if OK * @see add_object_linked(), updateObjectLinked(), deleteObjectLinked() */ - function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1) + public function fetchObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $clause = 'OR', $alsosametype = 1, $orderby = 'sourcetype', $loadalsoobjects = 1) { global $conf; @@ -3226,7 +3226,7 @@ abstract class CommonObject * @return int >0 if OK, <0 if KO * @see add_object_linked(), fetObjectLinked(), deleteObjectLinked() */ - function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '') + public function updateObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '') { $updatesource=false; $updatetarget=false; @@ -3273,7 +3273,7 @@ abstract class CommonObject * @return int >0 if OK, <0 if KO * @see add_object_linked, updateObjectLinked, fetchObjectLinked */ - function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '') + public function deleteObjectLinked($sourceid = null, $sourcetype = '', $targetid = null, $targettype = '', $rowid = '') { $deletesource=false; $deletetarget=false; @@ -3334,7 +3334,7 @@ abstract class CommonObject * @param string $trigkey Trigger key to use for trigger * @return int <0 if KO, >0 if OK */ - function setStatut($status, $elementId = null, $elementType = '', $trigkey = '') + public function setStatut($status, $elementId = null, $elementType = '', $trigkey = '') { global $user,$langs,$conf; @@ -3422,7 +3422,7 @@ abstract class CommonObject * @param string $ref Record ref * @return int <0 if KO, 0 if nothing done, >0 if OK */ - function getCanvas($id = 0, $ref = '') + public function getCanvas($id = 0, $ref = '') { global $conf; @@ -3463,7 +3463,7 @@ abstract class CommonObject * @param int $lineid Id of line * @return int Special code */ - function getSpecialCode($lineid) + public function getSpecialCode($lineid) { $sql = 'SELECT special_code FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE rowid = '.$lineid; @@ -3482,7 +3482,7 @@ abstract class CommonObject * @param int $id Force id of object * @return int <0 if KO, 0 if not used, >0 if already used */ - function isObjectUsed($id = 0) + public function isObjectUsed($id = 0) { global $langs; @@ -3551,7 +3551,7 @@ abstract class CommonObject * @param int $predefined -1=All, 0=Count free product/service only, 1=Count predefined product/service only, 2=Count predefined product, 3=Count predefined service * @return int <0 if KO, 0 if no predefined products, nb of lines with predefined products if found */ - function hasProductsOrServices($predefined = -1) + public function hasProductsOrServices($predefined = -1) { $nb=0; @@ -3574,7 +3574,7 @@ abstract class CommonObject * * @return float */ - function getTotalDiscount() + public function getTotalDiscount() { $total_discount=0.00; @@ -3614,7 +3614,7 @@ abstract class CommonObject * * @return array array('weight'=>...,'volume'=>...) */ - function getTotalWeightVolume() + public function getTotalWeightVolume() { $totalWeight = 0; $totalVolume = 0; @@ -3708,7 +3708,7 @@ abstract class CommonObject * * @return int <0 if KO, >0 if OK */ - function setExtraParameters() + public function setExtraParameters() { $this->db->begin(); @@ -3734,14 +3734,14 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return incoterms informations * TODO Use a cache for label get * * @return string incoterms info */ - function display_incoterms() + public function display_incoterms() { // phpcs:enable $out = ''; @@ -3767,7 +3767,7 @@ abstract class CommonObject * * @return string incoterms info */ - function getIncotermsForPDF() + public function getIncotermsForPDF() { $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_incoterms WHERE rowid = '.(int) $this->fk_incoterms; $resql = $this->db->query($sql); @@ -3798,7 +3798,7 @@ abstract class CommonObject * @param string $location location of incoterm * @return int <0 if KO, >0 if OK */ - function setIncoterms($id_incoterm, $location) + public function setIncoterms($id_incoterm, $location) { if ($this->id && $this->table_element) { @@ -3846,7 +3846,7 @@ abstract class CommonObject * @param Societe $buyer Object thirdparty who buy * @return void */ - function formAddObjectLine($dateSelector, $seller, $buyer) + public function formAddObjectLine($dateSelector, $seller, $buyer) { global $conf,$user,$langs,$object,$hookmanager; global $form,$bcnd,$var; @@ -3889,7 +3889,7 @@ abstract class CommonObject * @param int $dateSelector 1=Show also date range input fields * @return void */ - function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0) + public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0) { global $conf, $hookmanager, $langs, $user; // TODO We should not use global var for this ! @@ -4031,8 +4031,8 @@ abstract class CommonObject * Return HTML content of a detail line * TODO Move this into an output class file (htmlline.class.php) * - * @param string $action GET/POST action - * @param CommonObjectLine $line Selected object line to output + * @param string $action GET/POST action + * @param CommonObjectLine $line Selected object line to output * @param string $var Is it a an odd line (true) * @param int $num Number of line (0) * @param int $i I @@ -4043,7 +4043,7 @@ abstract class CommonObject * @param int $extrafieldsline Object of extrafield line attribute * @return void */ - function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0) + public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafieldsline = 0) { global $conf,$langs,$user,$object,$hookmanager; global $form,$bc,$bcdd; @@ -4161,7 +4161,7 @@ abstract class CommonObject * @param string $restrictlist ''=All lines, 'services'=Restrict to services only * @return void */ - function printOriginLinesList($restrictlist = '') + public function printOriginLinesList($restrictlist = '') { global $langs, $hookmanager, $conf; @@ -4215,7 +4215,7 @@ abstract class CommonObject * @param string $restrictlist ''=All lines, 'services'=Restrict to services only (strike line if not) * @return void */ - function printOriginLine($line, $var, $restrictlist = '') + public function printOriginLine($line, $var, $restrictlist = '') { global $langs, $conf; @@ -4350,7 +4350,7 @@ abstract class CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add resources to the current object : add entry into llx_element_resources * Need $this->element & $this->id @@ -4361,7 +4361,7 @@ abstract class CommonObject * @param int $mandatory Mandatory or not * @return int <=0 if KO, >0 if OK */ - function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0) + public function add_element_resource($resource_id, $resource_type, $busy = 0, $mandatory = 0) { // phpcs:enable $this->db->begin(); @@ -4396,7 +4396,7 @@ abstract class CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Delete a link to resource line * @@ -4405,7 +4405,7 @@ abstract class CommonObject * @param int $notrigger Disable all triggers * @return int >0 if OK, <0 if KO */ - function delete_resource($rowid, $element, $notrigger = 0) + public function delete_resource($rowid, $element, $notrigger = 0) { // phpcs:enable global $user; @@ -4442,7 +4442,7 @@ abstract class CommonObject * * @return void */ - function __clone() + public function __clone() { // Force a copy of this->lines, otherwise it will point to same object. if (isset($this->lines) && is_array($this->lines)) @@ -4619,9 +4619,15 @@ abstract class CommonObject if ($useonlinesignature) $setsharekey=true; if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; } - if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; - if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) $setsharekey=true; + if ($this->element == 'commande' && ! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } + if ($this->element == 'facture' && ! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } + if ($this->element == 'bank_account' && ! empty($conf->global->BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD)) { + $setsharekey=true; + } if ($setsharekey) { @@ -4719,7 +4725,7 @@ abstract class CommonObject * @param string $file Path file in UTF8 to original file to create thumbs from. * @return void */ - function addThumbs($file) + public function addThumbs($file) { global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; @@ -4755,7 +4761,7 @@ abstract class CommonObject * @param string $alternatevalue Alternate value to use * @return string|string[] Default value (can be an array if the GETPOST return an array) **/ - function getDefaultCreateValueFor($fieldname, $alternatevalue = null) + public function getDefaultCreateValueFor($fieldname, $alternatevalue = null) { global $conf, $_POST; @@ -4784,7 +4790,7 @@ abstract class CommonObject /* For triggers */ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Call trigger based on this instance. * Some context information may also be provided into array property this->context. @@ -4795,7 +4801,7 @@ abstract class CommonObject * @param User $user Object user * @return int Result of run_triggers */ - function call_trigger($trigger_name, $user) + public function call_trigger($trigger_name, $user) { // phpcs:enable global $langs,$conf; @@ -4822,7 +4828,7 @@ abstract class CommonObject /* Functions for extrafields */ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to get extra fields of an object into $this->array_options * This method is in most cases called by method fetch of objects but you can call it separately. @@ -4831,7 +4837,7 @@ abstract class CommonObject * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label(). Deprecated. Function must be called without parameters. * @return int <0 if error, 0 if no values of extrafield to find nor found, 1 if an attribute is found and value loaded */ - function fetch_optionals($rowid = null, $optionsArray = null) + public function fetch_optionals($rowid = null, $optionsArray = null) { // phpcs:enable if (empty($rowid)) $rowid=$this->id; @@ -4942,7 +4948,7 @@ abstract class CommonObject * * @return int <0 if KO, >0 if OK */ - function deleteExtraFields() + public function deleteExtraFields() { $this->db->begin(); @@ -4975,7 +4981,7 @@ abstract class CommonObject * @return int -1=error, O=did nothing, 1=OK * @see updateExtraField(), setValueFrom() */ - function insertExtraFields($trigger = '', $userused = null) + public function insertExtraFields($trigger = '', $userused = null) { global $conf,$langs,$user; @@ -5221,7 +5227,7 @@ abstract class CommonObject * @return int -1=error, O=did nothing, 1=OK * @see setValueFrom(), insertExtraFields() */ - function updateExtraField($key, $trigger = null, $userused = null) + public function updateExtraField($key, $trigger = null, $userused = null) { global $conf,$langs,$user; @@ -5355,7 +5361,7 @@ abstract class CommonObject * @param string|int $morecss Value for css to define style/length of field. May also be a numeric. * @return string */ - function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0) + public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = 0) { global $conf,$langs,$form; @@ -5965,7 +5971,7 @@ abstract class CommonObject * @param mixed $showsize Value for css to define size. May also be a numeric. * @return string */ - function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $showsize = 0) + public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $showsize = 0) { global $conf,$langs,$form; @@ -6336,7 +6342,7 @@ abstract class CommonObject * @param string $onetrtd All fields in same tr td * @return string */ - function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0) + public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0) { global $db, $conf, $langs, $action, $form; @@ -6644,7 +6650,7 @@ abstract class CommonObject return $buyPrice; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show photos of an object (nbmax maximum), into several columns * @@ -6662,7 +6668,7 @@ abstract class CommonObject * @param int $usesharelink Use the public shared link of image (if not available, the 'nophoto' image will be shown instead) * @return string Html code to show photo. Number of photos shown is saved in this->nbphoto */ - function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0) + public function show_photos($modulepart, $sdir, $size = 0, $nbmax = 0, $nbbyrow = 5, $showfilename = 0, $showaction = 0, $maxHeight = 120, $maxWidth = 160, $nolink = 0, $notitle = 0, $usesharelink = 0) { // phpcs:enable global $conf,$user,$langs; @@ -7476,15 +7482,15 @@ abstract class CommonObject return count($this->comments); } - /** - * Return nb comments already posted - * - * @return int - */ - public function getNbComments() - { - return count($this->comments); - } + /** + * Return nb comments already posted + * + * @return int + */ + public function getNbComments() + { + return count($this->comments); + } /** * Trim object parameters diff --git a/htdocs/core/class/commonstickergenerator.class.php b/htdocs/core/class/commonstickergenerator.class.php index 0055559c4dc..18bcfcee8d5 100644 --- a/htdocs/core/class/commonstickergenerator.class.php +++ b/htdocs/core/class/commonstickergenerator.class.php @@ -61,43 +61,57 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/format_cards.lib.php'; */ abstract class CommonStickerGenerator { - public $code; // Code of format + public $code; // Code of format - /** + /** * @var array format Array with informations */ public $format; - // protected - var $_Avery_Name = ''; // Nom du format de l'etiquette - var $_Margin_Left = 0; // Marge de gauche de l'etiquette - var $_Margin_Top = 0; // marge en haut de la page avant la premiere etiquette - var $_X_Space = 0; // Espace horizontal entre 2 bandes d'etiquettes - var $_Y_Space = 0; // Espace vertical entre 2 bandes d'etiquettes - var $_X_Number = 0; // NX Nombre d'etiquettes sur la largeur de la page - var $_Y_Number = 0; // NY Nombre d'etiquettes sur la hauteur de la page - var $_Width = 0; // Largeur de chaque etiquette - var $_Height = 0; // Hauteur de chaque etiquette - var $_Char_Size = 10; // Hauteur des caracteres - var $_Line_Height = 10; // Hauteur par defaut d'une ligne - var $_Metric = 'mm'; // Type of metric.. Will help to calculate good values - var $_Metric_Doc = 'mm'; // Type of metric for the doc.. - var $_COUNTX = 1; - var $_COUNTY = 1; - var $_First = 1; - var $Tformat; - + // phpcs:disable PEAR.NamingConventions.ValidVariableName.PublicUnderscore + // protected + // Nom du format de l'etiquette + protected $_Avery_Name = ''; + // Marge de gauche de l'etiquette + protected $_Margin_Left = 0; + // marge en haut de la page avant la premiere etiquette + protected $_Margin_Top = 0; + // Espace horizontal entre 2 bandes d'etiquettes + protected $_X_Space = 0; + // Espace vertical entre 2 bandes d'etiquettes + protected $_Y_Space = 0; + // NX Nombre d'etiquettes sur la largeur de la page + protected $_X_Number = 0; + // NY Nombre d'etiquettes sur la hauteur de la page + protected $_Y_Number = 0; + // Largeur de chaque etiquette + protected $_Width = 0; + // Hauteur de chaque etiquette + protected $_Height = 0; + // Hauteur des caracteres + protected $_Char_Size = 10; + // Hauteur par defaut d'une ligne + protected $_Line_Height = 10; + // Type of metric.. Will help to calculate good values + protected $_Metric = 'mm'; + // Type of metric for the doc.. + protected $_Metric_Doc = 'mm'; + protected $_COUNTX = 1; + protected $_COUNTY = 1; + protected $_First = 1; + public $Tformat; + // phpcs:enable /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP strem. * @@ -107,7 +121,7 @@ abstract class CommonStickerGenerator * @param string $outputdir Output directory for pdf file * @return int 1=OK, 0=KO */ - abstract function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = ''); + public abstract function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = ''); // phpcs:enable /** @@ -118,9 +132,9 @@ abstract class CommonStickerGenerator * @param array $param Associative array containing label content and optional parameters * @return void */ - abstract function addSticker(&$pdf, $outputlangs, $param); + public abstract function addSticker(&$pdf, $outputlangs, $param); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Methode qui permet de modifier la taille des caracteres * Cela modiera aussi l'espace entre chaque ligne @@ -129,7 +143,7 @@ abstract class CommonStickerGenerator * @param int $pt point * @return void */ - function Set_Char_Size(&$pdf, $pt) + public function Set_Char_Size(&$pdf, $pt) { // phpcs:enable if ($pt > 3) { @@ -139,7 +153,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * protected Print dot line * @@ -152,8 +167,8 @@ abstract class CommonStickerGenerator * @param int $nbPointilles Nb pointilles * @return void */ - function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) - { + protected function _Pointille(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $nbPointilles = 15) + { // phpcs:enable $pdf->SetLineWidth($epaisseur); $length=abs($x1-$x2); @@ -182,7 +197,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Function realisant une croix aux 4 coins des cartes * @@ -195,7 +211,7 @@ abstract class CommonStickerGenerator * @param int $taille Size * @return void */ - function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4) + protected function _Croix(&$pdf, $x1 = 0, $y1 = 0, $x2 = 210, $y2 = 297, $epaisseur = 1, $taille = 4) { // phpcs:enable $pdf->SetDrawColor(192, 192, 192); @@ -240,14 +256,15 @@ abstract class CommonStickerGenerator return $value; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Give the height for a char size given. * * @param int $pt Point * @return int Height chars */ - function _Get_Height_Chars($pt) + protected function _Get_Height_Chars($pt) { // phpcs:enable // Tableau de concordance entre la hauteur des caracteres et de l'espacement entre les lignes @@ -259,7 +276,8 @@ abstract class CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * protected Set format * @@ -267,7 +285,7 @@ abstract class CommonStickerGenerator * @param string $format Format * @return void */ - function _Set_Format(&$pdf, $format) + protected function _Set_Format(&$pdf, $format) { // phpcs:enable $this->_Metric = $format['metric']; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 5de1475a3f0..ecbecdeee2d 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -32,22 +32,22 @@ */ class Conf { - /** \public */ - //! To store properties found in conf file - var $file; + /** \public */ + //! To store properties found in conf file + public $file; - /** + /** * @var DoliDB Database handler. */ public $db; - //! To store properties found into database - var $global; - //! To store browser info - var $browser; + //! To store properties found into database + public $global; + //! To store browser info + public $browser; - //! To store if javascript/ajax is enabked - public $use_javascript_ajax; + //! To store if javascript/ajax is enabked + public $use_javascript_ajax; //! Used to store current currency (ISO code like 'USD', 'EUR', ...) public $currency; //! Used to store current css (from theme) @@ -55,19 +55,36 @@ class Conf public $css; // Contains full path of css page ("/theme/eldy/style.css.php", ...) //! Used to store current menu handler public $standard_menu; + // List of activated modules + public $modules = array(); + public $modules_parts = array( + 'css' => array(), + 'js' => array(), + 'tabs' => array(), + 'triggers' => array(), + 'login' => array(), + 'substitutions' => array(), + 'menus' => array(), + 'theme' => array(), + 'sms' => array(), + 'tpl' => array(), + 'barcode' => array(), + 'models' => array(), + 'societe' => array(), + 'hooks' => array(), + 'dir' => array(), + 'syslog' => array(), + ); - public $modules = array(); // List of activated modules - public $modules_parts = array('css'=>array(),'js'=>array(),'tabs'=>array(),'triggers'=>array(),'login'=>array(),'substitutions'=>array(),'menus'=>array(),'theme'=>array(),'sms'=>array(),'tpl'=>array(),'barcode'=>array(),'models'=>array(),'societe'=>array(),'hooks'=>array(),'dir'=>array(), 'syslog' =>array()); + public $logbuffer = array(); - var $logbuffer = array(); + /** + * @var LogHandlerInterface[] + */ + public $loghandlers = array(); - /** - * @var LogHandlerInterface[] - */ - var $loghandlers = array(); - - //! To store properties of multi-company - public $multicompany; + //! To store properties of multi-company + public $multicompany; //! Used to store running instance for multi-company (default 1) public $entity = 1; //! Used to store list of entities to use for each element @@ -83,7 +100,7 @@ class Conf /** * Constructor */ - function __construct() + public function __construct() { // Properly declare multi-modules objects. $this->file = new stdClass(); @@ -124,13 +141,13 @@ class Conf /** - * Load setup values into conf object (read llx_const) + * Load setup values into conf object (read llx_const) * Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called. * - * @param DoliDB $db Database handler - * @return int < 0 if KO, >= 0 if OK + * @param DoliDB $db Database handler + * @return int < 0 if KO, >= 0 if OK */ - function setValues($db) + public function setValues($db) { global $conf; @@ -201,8 +218,8 @@ class Conf $i++; } - $db->free($resql); - } + $db->free($resql); + } // Include other local consts.php files and fetch their values to the corresponding database constants. if (! empty($this->global->LOCAL_CONSTS_FILES)) { @@ -216,8 +233,8 @@ class Conf } } - //var_dump($this->modules); - //var_dump($this->modules_parts['theme']); + //var_dump($this->modules); + //var_dump($this->modules_parts['theme']); // If you can't set timezone of your PHP, set this constant. Better is to set it to UTC. // In future, this constant will be forced to 'UTC' so PHP server timezone will not have effect anymore. @@ -234,12 +251,10 @@ class Conf } // Object $mc - if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) - { + if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) { global $mc; $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); - if ($ret) - { + if ($ret) { $mc = new ActionsMulticompany($db); $this->mc = $mc; } @@ -575,7 +590,9 @@ class Conf $this->adherent->subscription = new stdClass(); $this->adherent->subscription->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60; } - if (isset($this->agenda)) $this->agenda->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60; + if (isset($this->agenda)) { + $this->agenda->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60; + } if (isset($this->projet)) { $this->projet->warning_delay=(isset($this->global->MAIN_DELAY_PROJECT_TO_CLOSE)?$this->global->MAIN_DELAY_PROJECT_TO_CLOSE:7)*24*60*60; @@ -615,9 +632,9 @@ class Conf $this->bank->cheque->warning_delay=(isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT)?$this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT:0)*24*60*60; } if (isset($this->expensereport)) { - $this->expensereport->approve = new stdClass(); + $this->expensereport->approve = new stdClass(); $this->expensereport->approve->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS)?$this->global->MAIN_DELAY_EXPENSEREPORTS:0)*24*60*60; - $this->expensereport->payment = new stdClass(); + $this->expensereport->payment = new stdClass(); $this->expensereport->payment->warning_delay=(isset($this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY)?$this->global->MAIN_DELAY_EXPENSEREPORTS_TO_PAY:0)*24*60*60; } diff --git a/htdocs/core/class/coreobject.class.php b/htdocs/core/class/coreobject.class.php index a3a8a0dd5ff..cb31a287656 100644 --- a/htdocs/core/class/coreobject.class.php +++ b/htdocs/core/class/coreobject.class.php @@ -27,55 +27,55 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; class CoreObject extends CommonObject { - public $withChild = true; - - /** - * @var Array $_fields Fields to synchronize with Database - */ - protected $fields=array(); + public $withChild = true; /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct(DoliDB &$db) + * @var Array $_fields Fields to synchronize with Database + */ + protected $fields=array(); + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct(DoliDB &$db) { $this->db = $db; - } + } /** * Function to init fields * * @return bool */ - protected function init() + protected function init() { - $this->id = 0; - $this->datec = 0; - $this->tms = 0; + $this->id = 0; + $this->datec = 0; + $this->tms = 0; - if (!empty($this->fields)) - { - foreach ($this->fields as $field=>$info) - { - if ($this->isDate($info)) $this->{$field} = time(); - elseif ($this->isArray($info)) $this->{$field} = array(); - elseif ($this->isInt($info)) $this->{$field} = (int) 0; - elseif ($this->isFloat($info)) $this->{$field} = (double) 0; - else $this->{$field} = ''; - } + if (!empty($this->fields)) + { + foreach ($this->fields as $field=>$info) + { + if ($this->isDate($info)) $this->{$field} = time(); + elseif ($this->isArray($info)) $this->{$field} = array(); + elseif ($this->isInt($info)) $this->{$field} = (int) 0; + elseif ($this->isFloat($info)) $this->{$field} = (double) 0; + else $this->{$field} = ''; + } $this->to_delete=false; $this->is_clone=false; - return true; - } - else + return true; + } + else { - return false; - } - } + return false; + } + } /** * Test type of field @@ -86,15 +86,15 @@ class CoreObject extends CommonObject */ private function checkFieldType($field, $type) { - if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) - { - return $this->{'is_'.$type}($this->fields[$field]); - } - else + if (isset($this->fields[$field]) && method_exists($this, 'is_'.$type)) + { + return $this->{'is_'.$type}($this->fields[$field]); + } + else { return false; } - } + } /** * Get object and children from database @@ -103,15 +103,15 @@ class CoreObject extends CommonObject * @param bool $loadChild used to load children from database * @return int >0 if OK, <0 if KO, 0 if not found */ - public function fetch($id, $loadChild = true) + public function fetch($id, $loadChild = true) { - $res = $this->fetchCommon($id); - if($res>0) { - if ($loadChild) $this->fetchChild(); - } + $res = $this->fetchCommon($id); + if($res>0) { + if ($loadChild) $this->fetchChild(); + } - return $res; - } + return $res; + } /** @@ -125,25 +125,25 @@ class CoreObject extends CommonObject */ public function addChild($tabName, $id = 0, $key = 'id', $try_to_load = false) { - if(!empty($id)) - { - foreach($this->{$tabName} as $k=>&$object) - { - if($object->{$key} === $id) return $k; - } - } + if(!empty($id)) + { + foreach($this->{$tabName} as $k=>&$object) + { + if($object->{$key} === $id) return $k; + } + } - $k = count($this->{$tabName}); + $k = count($this->{$tabName}); - $className = ucfirst($tabName); - $this->{$tabName}[$k] = new $className($this->db); - if($id>0 && $key==='id' && $try_to_load) - { - $this->{$tabName}[$k]->fetch($id); - } + $className = ucfirst($tabName); + $this->{$tabName}[$k] = new $className($this->db); + if($id>0 && $key==='id' && $try_to_load) + { + $this->{$tabName}[$k]->fetch($id); + } - return $k; - } + return $k; + } /** @@ -156,16 +156,16 @@ class CoreObject extends CommonObject */ public function removeChild($tabName, $id, $key = 'id') { - foreach ($this->{$tabName} as &$object) - { - if ($object->{$key} == $id) - { - $object->to_delete = true; - return true; - } - } - return false; - } + foreach ($this->{$tabName} as &$object) + { + if ($object->{$key} == $id) + { + $object->to_delete = true; + return true; + } + } + return false; + } /** @@ -175,10 +175,10 @@ class CoreObject extends CommonObject */ public function fetchChild() { - if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) - { - foreach($this->childtables as &$childTable) - { + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) + { + foreach($this->childtables as &$childTable) + { $className = ucfirst($childTable); $this->{$className}=array(); @@ -200,9 +200,9 @@ class CoreObject extends CommonObject { $this->errors[] = $this->db->lasterror(); } - } - } - } + } + } + } /** * Function to update children data @@ -210,26 +210,26 @@ class CoreObject extends CommonObject * @param User $user user object * @return void */ - public function saveChild(User &$user) + public function saveChild(User &$user) { - if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) - { - foreach($this->childtables as &$childTable) - { - $className = ucfirst($childTable); - if(!empty($this->{$className})) - { - foreach($this->{$className} as $i => &$object) - { - $object->{$this->fk_element} = $this->id; + if($this->withChild && !empty($this->childtables) && !empty($this->fk_element)) + { + foreach($this->childtables as &$childTable) + { + $className = ucfirst($childTable); + if(!empty($this->{$className})) + { + foreach($this->{$className} as $i => &$object) + { + $object->{$this->fk_element} = $this->id; - $object->update($user); - if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); - } - } - } - } - } + $object->update($user); + if($this->unsetChildDeleted && isset($object->to_delete) && $object->to_delete==true) unset($this->{$className}[$i]); + } + } + } + } + } /** @@ -240,7 +240,7 @@ class CoreObject extends CommonObject */ public function update(User &$user) { - if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed + if (empty($this->id)) return $this->create($user); // To test, with that, no need to test on high level object, the core decide it, update just needed elseif (isset($this->to_delete) && $this->to_delete==true) return $this->delete($user); $error = 0; @@ -270,7 +270,7 @@ class CoreObject extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Function to create object in database @@ -280,26 +280,26 @@ class CoreObject extends CommonObject */ public function create(User &$user) { - if($this->id > 0) return $this->update($user); + if($this->id > 0) return $this->update($user); $error = 0; $this->db->begin(); $res = $this->createCommon($user); - if($res) - { - $this->id = $this->db->last_insert_id($this->table_element); + if($res) + { + $this->id = $this->db->last_insert_id($this->table_element); - $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); + $result = $this->call_trigger(strtoupper($this->element). '_CREATE', $user); if ($result < 0) $error++; else $this->saveChild($user); - } - else + } + else { $error++; $this->error = $this->db->lasterror(); $this->errors[] = $this->error; - } + } if (empty($error)) { @@ -311,7 +311,7 @@ class CoreObject extends CommonObject $this->db->rollback(); return -1; } - } + } /** * Function to delete object in database @@ -319,9 +319,9 @@ class CoreObject extends CommonObject * @param User $user user object * @return < 0 if ko, > 0 if ok */ - public function delete(User &$user) + public function delete(User &$user) { - if ($this->id <= 0) return 0; + if ($this->id <= 0) return 0; $error = 0; $this->db->begin(); @@ -360,7 +360,7 @@ class CoreObject extends CommonObject $this->db->rollback(); return -1; } - } + } /** @@ -372,12 +372,12 @@ class CoreObject extends CommonObject */ public function getDate($field, $format = '') { - if(empty($this->{$field})) return ''; - else + if(empty($this->{$field})) return ''; + else { - return dol_print_date($this->{$field}, $format); - } - } + return dol_print_date($this->{$field}, $format); + } + } /** * Function to set date in field @@ -388,18 +388,18 @@ class CoreObject extends CommonObject */ public function setDate($field, $date) { - if (empty($date)) - { - $this->{$field} = 0; - } - else + if (empty($date)) + { + $this->{$field} = 0; + } + else { - require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; - $this->{$field} = dol_stringtotime($date); - } + require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + $this->{$field} = dol_stringtotime($date); + } - return $this->{$field}; - } + return $this->{$field}; + } /** @@ -410,29 +410,29 @@ class CoreObject extends CommonObject */ public function setValues(&$Tab) { - foreach ($Tab as $key => $value) - { - if($this->checkFieldType($key, 'date')) - { - $this->setDate($key, $value); - } - elseif( $this->checkFieldType($key, 'array')) - { - $this->{$key} = $value; - } - elseif( $this->checkFieldType($key, 'float') ) - { - $this->{$key} = (double) price2num($value); - } - elseif( $this->checkFieldType($key, 'int') ) { - $this->{$key} = (int) price2num($value); - } - else + foreach ($Tab as $key => $value) + { + if($this->checkFieldType($key, 'date')) { - $this->{$key} = $value; - } - } + $this->setDate($key, $value); + } + elseif( $this->checkFieldType($key, 'array')) + { + $this->{$key} = $value; + } + elseif( $this->checkFieldType($key, 'float') ) + { + $this->{$key} = (double) price2num($value); + } + elseif( $this->checkFieldType($key, 'int') ) { + $this->{$key} = (int) price2num($value); + } + else + { + $this->{$key} = $value; + } + } - return 1; - } + return 1; + } } diff --git a/htdocs/core/class/cstate.class.php b/htdocs/core/class/cstate.class.php index 6ad6523f199..97f5b9b016f 100644 --- a/htdocs/core/class/cstate.class.php +++ b/htdocs/core/class/cstate.class.php @@ -21,14 +21,8 @@ * \brief This file is a CRUD class file (Create/Read/Update/Delete) for c_departements dictionary */ -// Put here all includes required by your class file -//require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - - /** - * Class to manage dictionary States (used by imports) + * Class to manage dictionary States (used by imports) */ class Cstate // extends CommonObject { @@ -79,7 +73,7 @@ class Cstate // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -92,7 +86,7 @@ class Cstate // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -124,22 +118,20 @@ class Cstate // extends CommonObject $resql=$this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_departements"); - if (! $notrigger) - { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action call a trigger. + //if (! $notrigger) { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers - } + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + //} } // Commit or rollback @@ -168,7 +160,7 @@ class Cstate // extends CommonObject * @param string $code Code * @return int <0 if KO, >0 if OK */ - function fetch($id, $code = '') + public function fetch($id, $code = '') { global $langs; $sql = "SELECT"; @@ -212,7 +204,7 @@ class Cstate // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -239,10 +231,10 @@ class Cstate // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -252,11 +244,11 @@ class Cstate // extends CommonObject //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback - if ($error) + if ($error) { foreach($this->errors as $errmsg) { @@ -281,7 +273,7 @@ class Cstate // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -295,10 +287,10 @@ class Cstate // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -308,8 +300,8 @@ class Cstate // extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback if ($error) diff --git a/htdocs/core/class/ctypent.class.php b/htdocs/core/class/ctypent.class.php index ffaccbfe964..6c86c987d17 100644 --- a/htdocs/core/class/ctypent.class.php +++ b/htdocs/core/class/ctypent.class.php @@ -63,7 +63,7 @@ class Ctypent // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -76,7 +76,7 @@ class Ctypent // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -166,7 +166,7 @@ class Ctypent // extends CommonObject * @param string $label Label * @return int <0 if KO, >0 if OK */ - function fetch($id, $code = '', $label = '') + public function fetch($id, $code = '', $label = '') { global $langs; $sql = "SELECT"; @@ -214,7 +214,7 @@ class Ctypent // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -285,7 +285,7 @@ class Ctypent // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -299,10 +299,10 @@ class Ctypent // extends CommonObject $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -312,12 +312,12 @@ class Ctypent // extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback - if ($error) - { + if ($error) + { foreach($this->errors as $errmsg) { dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); @@ -325,11 +325,11 @@ class Ctypent // extends CommonObject } $this->db->rollback(); return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } - } + } + else + { + $this->db->commit(); + return 1; + } + } } diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 3970ff2df27..0e3987da516 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -66,7 +66,7 @@ class CUnits // extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -79,7 +79,7 @@ class CUnits // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -170,7 +170,7 @@ class CUnits // extends CommonObject * @param string $unit_type unit type * @return int <0 if KO, >0 if OK */ - function fetch($id, $code = '', $short_label = '', $unit_type = '') + public function fetch($id, $code = '', $short_label = '', $unit_type = '') { global $langs; @@ -310,7 +310,7 @@ class CUnits // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -383,7 +383,7 @@ class CUnits // extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; diff --git a/htdocs/core/class/discount.class.php b/htdocs/core/class/discount.class.php index 9615c040eb0..0a681b95b18 100644 --- a/htdocs/core/class/discount.class.php +++ b/htdocs/core/class/discount.class.php @@ -60,7 +60,8 @@ class DiscountAbsolute public $multicurrency_amount_ht; public $multicurrency_amount_tva; public $multicurrency_amount_ttc; - public $tva_tx; // Vat rate + // Vat rate + public $tva_tx; /** * @var int User ID Id utilisateur qui accorde la remise @@ -98,7 +99,7 @@ class DiscountAbsolute * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -112,7 +113,7 @@ class DiscountAbsolute * @param int $fk_invoice_supplier_source fk_invoice_supplier_source * @return int <0 if KO, =0 if not found, >0 if OK */ - function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) + public function fetch($rowid, $fk_facture_source = 0, $fk_invoice_supplier_source = 0) { global $conf; @@ -194,7 +195,7 @@ class DiscountAbsolute * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -253,10 +254,10 @@ class DiscountAbsolute /** * Delete object in database. If fk_facture_source is defined, we delete all familiy with same fk_facture_source. If not, only with id is removed * - * @param User $user Object of user asking to delete - * @return int <0 if KO, >0 if OK + * @param User $user Object of user asking to delete + * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { global $conf, $langs; @@ -291,8 +292,8 @@ class DiscountAbsolute // Check if we can remove the discount if ($this->fk_invoice_supplier_source) { - $sql="SELECT COUNT(rowid) as nb"; - $sql.=" FROM ".MAIN_DB_PREFIX."societe_remise_except"; + $sql="SELECT COUNT(rowid) as nb"; + $sql.=" FROM ".MAIN_DB_PREFIX."societe_remise_except"; $sql.=" WHERE (fk_invoice_supplier_line IS NOT NULL"; // Not used as absolute simple discount $sql.=" OR fk_invoice_supplier IS NOT NULL)"; // Not used as credit note and not used as deposit $sql.=" AND fk_invoice_supplier_source = ".$this->fk_invoice_supplier_source; @@ -389,7 +390,7 @@ class DiscountAbsolute - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link the discount to a particular invoice line or a particular invoice. * When discount is a global discount used as an invoice line, we link using rowidline. @@ -399,7 +400,7 @@ class DiscountAbsolute * @param int $rowidinvoice Invoice id (To use discount as a credit note to reduc payment of invoice) * @return int <0 if KO, >0 if OK */ - function link_to_invoice($rowidline, $rowidinvoice) + public function link_to_invoice($rowidline, $rowidinvoice) { // phpcs:enable // Check parameters @@ -445,20 +446,20 @@ class DiscountAbsolute } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link the discount to a particular invoice line or a particular invoice. * Do not call this if discount is linked to a reconcialiated invoice * * @return int <0 if KO, >0 if OK */ - function unlink_invoice() + public function unlink_invoice() { // phpcs:enable $sql ="UPDATE ".MAIN_DB_PREFIX."societe_remise_except"; - if(! empty($this->discount_type)) { - $sql.=" SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL"; - } else { + if (! empty($this->discount_type)) { + $sql.=" SET fk_invoice_supplier_line = NULL, fk_invoice_supplier = NULL"; + } else { $sql.=" SET fk_facture_line = NULL, fk_facture = NULL"; } $sql.=" WHERE rowid = ".$this->id; @@ -487,9 +488,9 @@ class DiscountAbsolute * @param int $discount_type 0 => customer discount, 1 => supplier discount * @return int <0 if KO, amount otherwise */ - function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0) + public function getAvailableDiscounts($company = '', $user = '', $filter = '', $maxvalue = 0, $discount_type = 0) { - global $conf; + global $conf; $sql = "SELECT SUM(rc.amount_ttc) as amount"; //$sql = "SELECT rc.amount_ttc as amount"; @@ -527,10 +528,10 @@ class DiscountAbsolute * Should always be empty, except if option FACTURE_DEPOSITS_ARE_JUST_PAYMENTS is on (not recommended). * * @param CommonInvoice $invoice Object invoice (customer of supplier) - * @param int $multicurrency Return multicurrency_amount instead of amount + * @param int $multicurrency Return multicurrency_amount instead of amount * @return int <0 if KO, Sum of credit notes and deposits amount otherwise */ - function getSumDepositsUsed($invoice, $multicurrency = 0) + public function getSumDepositsUsed($invoice, $multicurrency = 0) { dol_syslog(get_class($this)."::getSumDepositsUsed", LOG_DEBUG); @@ -572,11 +573,11 @@ class DiscountAbsolute /** * Return amount (with tax) of all credit notes invoices + excess received used by invoice as a payment * - * @param CommonInvoice $invoice Object invoice - * @param int $multicurrency Return multicurrency_amount instead of amount - * @return int <0 if KO, Sum of credit notes and excess received amount otherwise + * @param CommonInvoice $invoice Object invoice + * @param int $multicurrency Return multicurrency_amount instead of amount + * @return int <0 if KO, Sum of credit notes and excess received amount otherwise */ - function getSumCreditNotesUsed($invoice, $multicurrency = 0) + public function getSumCreditNotesUsed($invoice, $multicurrency = 0) { dol_syslog(get_class($this)."::getSumCreditNotesUsed", LOG_DEBUG); @@ -616,13 +617,13 @@ class DiscountAbsolute } /** - * Return clickable ref of object (with picto or not) + * Return clickable ref of object (with picto or not) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only - * @param string $option Where to link to ('invoice' or 'discount') - * @return string String with URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Picto only + * @param string $option Where to link to ('invoice' or 'discount') + * @return string String with URL */ - function getNomUrl($withpicto, $option = 'invoice') + public function getNomUrl($withpicto, $option = 'invoice') { global $langs; @@ -660,7 +661,7 @@ class DiscountAbsolute * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; diff --git a/htdocs/core/class/doleditor.class.php b/htdocs/core/class/doleditor.class.php index 4cbf20a8a75..110d850bfd0 100644 --- a/htdocs/core/class/doleditor.class.php +++ b/htdocs/core/class/doleditor.class.php @@ -28,43 +28,43 @@ */ class DolEditor { - var $tool; // Store the selected tool + public $tool; // Store the selected tool - // If using fckeditor - var $editor; + // If using fckeditor + public $editor; - // If not using fckeditor - var $content; - var $htmlname; - var $toolbarname; - var $toolbarstartexpanded; - var $rows; - var $cols; - var $height; - var $width; - var $readonly; + // If not using fckeditor + public $content; + public $htmlname; + public $toolbarname; + public $toolbarstartexpanded; + public $rows; + public $cols; + public $height; + public $width; + public $readonly; /** - * Create an object to build an HTML area to edit a large string content + * Create an object to build an HTML area to edit a large string content * - * @param string $htmlname HTML name of WYSIWIG field - * @param string $content Content of WYSIWIG field - * @param int $width Width in pixel of edit area (auto by default) - * @param int $height Height in pixel of edit area (200px by default) - * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). - * @param string $toolbarlocation Where bar is stored : - * 'In' each window has its own toolbar - * 'Out:name' share toolbar into the div called 'name' - * @param boolean $toolbarstartexpanded Bar is visible or not at start - * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. - * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. - * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". - * @param int $rows Size of rows for textarea tool - * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') - * @param int $readonly 0=Read/Edit, 1=Read only + * @param string $htmlname HTML name of WYSIWIG field + * @param string $content Content of WYSIWIG field + * @param int $width Width in pixel of edit area (auto by default) + * @param int $height Height in pixel of edit area (200px by default) + * @param string $toolbarname Name of bar set to use ('Full', 'dolibarr_notes[_encoded]', 'dolibarr_details[_encoded]'=the less featured, 'dolibarr_mailings[_encoded]', 'dolibarr_readonly'). + * @param string $toolbarlocation Where bar is stored : + * 'In' each window has its own toolbar + * 'Out:name' share toolbar into the div called 'name' + * @param boolean $toolbarstartexpanded Bar is visible or not at start + * @param int $uselocalbrowser Enabled to add links to local object with local browser. If false, only external images can be added in content. + * @param boolean|string $okforextendededitor True=Allow usage of extended editor tool if qualified (like ckeditor). If 'textarea', force use of simple textarea. If 'ace', force use of Ace. + * Warning: If you use 'ace', don't forget to also include ace.js in page header. Also, the button "save" must have class="buttonforacesave". + * @param int $rows Size of rows for textarea tool + * @param string $cols Size of cols for textarea tool (textarea number of cols '70' or percent 'x%') + * @param int $readonly 0=Read/Edit, 1=Read only */ - function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) + public function __construct($htmlname, $content, $width = '', $height = 200, $toolbarname = 'Basic', $toolbarlocation = 'In', $toolbarstartexpanded = false, $uselocalbrowser = true, $okforextendededitor = true, $rows = 0, $cols = 0, $readonly = 0) { global $conf,$langs; @@ -137,7 +137,7 @@ class DolEditor } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output edit area inside the HTML stream. * Output depends on this->tool (fckeditor, ckeditor, textarea, ...) @@ -149,7 +149,7 @@ class DolEditor * @param string $option For ACE editor, set the source language ('html', 'php', 'javascript', ...) * @return void|string */ - function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') + public function Create($noprint = 0, $morejs = '', $disallowAnyContent = true, $titlecontent = '', $option = '') { // phpcs:enable global $conf,$langs; diff --git a/htdocs/core/class/dolexception.class.php b/htdocs/core/class/dolexception.class.php index b61bc6e388c..be04c9fd741 100644 --- a/htdocs/core/class/dolexception.class.php +++ b/htdocs/core/class/dolexception.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010 Regis Houssin * * 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 @@ -16,21 +16,21 @@ */ /** - * \file htdocs/core/class/dolexception.class.php - * \ingroup core - * \brief File of class for exceptions + * \file htdocs/core/class/dolexception.class.php + * \ingroup core + * \brief File of class for exceptions */ /** - * Class to manage exceptions + * Class to manage exceptions */ class DolException extends Exception { /** * Constructor */ - function __construct() + public function __construct() { } } diff --git a/htdocs/core/class/dolgeoip.class.php b/htdocs/core/class/dolgeoip.class.php index 22ec32045a0..79515725aa1 100644 --- a/htdocs/core/class/dolgeoip.class.php +++ b/htdocs/core/class/dolgeoip.class.php @@ -33,7 +33,7 @@ */ class DolGeoIP { - var $gi; + public $gi; /** * Constructor @@ -41,7 +41,7 @@ class DolGeoIP * @param string $type 'country' or 'city' * @param string $datfile Data file */ - function __construct($type, $datfile) + public function __construct($type, $datfile) { if ($type == 'country') { @@ -88,7 +88,7 @@ class DolGeoIP * @param string $ip IP to scan * @return string Country code (two letters) */ - function getCountryCodeFromIP($ip) + public function getCountryCodeFromIP($ip) { if (empty($this->gi)) { @@ -112,7 +112,7 @@ class DolGeoIP * @param string $name FQN of host (example: myserver.xyz.com) * @return string Country code (two letters) */ - function getCountryCodeFromName($name) + public function getCountryCodeFromName($name) { if (empty($this->gi)) { @@ -121,27 +121,27 @@ class DolGeoIP return geoip_country_code_by_name($this->gi, $name); } - /** - * Return verion of data file - * - * @return string Version of datafile - */ - function getVersion() - { - if ($this->gi == 'NOGI') return geoip_database_info(); - return 'Not available (not using PHP internal geo functions)'; - } + /** + * Return verion of data file + * + * @return string Version of datafile + */ + public function getVersion() + { + if ($this->gi == 'NOGI') return geoip_database_info(); + return 'Not available (not using PHP internal geo functions)'; + } - /** - * Close geoip object - * - * @return void - */ - function close() - { - if (function_exists('geoip_close')) // With some geoip with PEAR, geoip_close function may not exists - { - geoip_close($this->gi); - } - } + /** + * Close geoip object + * + * @return void + */ + public function close() + { + if (function_exists('geoip_close')) { + // With some geoip with PEAR, geoip_close function may not exists + geoip_close($this->gi); + } + } } diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 7fd9258ddd7..386b378abdd 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -88,7 +88,7 @@ class DolGraph * * @param string $library 'jflot' (default) or 'artichow' (no more supported) */ - function __construct($library = 'jflot') + public function __construct($library = 'jflot') { global $conf; global $theme_bordercolor, $theme_datacolor, $theme_bgcolor, $theme_bgcoloronglet; @@ -128,130 +128,130 @@ class DolGraph } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set Y precision * * @param float $which_prec Precision * @return boolean */ - function SetPrecisionY($which_prec) + public function SetPrecisionY($which_prec) { // phpcs:enable $this->PrecisionY = $which_prec; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * * @param float $xi Xi * @return boolean True */ - function SetHorizTickIncrement($xi) + public function SetHorizTickIncrement($xi) { // phpcs:enable $this->horizTickIncrement = $xi; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Utiliser SetNumTicks ou SetHorizTickIncrement mais pas les 2 * * @param float $xt Xt * @return boolean True */ - function SetNumXTicks($xt) + public function SetNumXTicks($xt) { // phpcs:enable $this->SetNumXTicks = $xt; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set label interval to reduce number of labels * * @param float $x Label interval * @return boolean True */ - function SetLabelInterval($x) + public function SetLabelInterval($x) { // phpcs:enable $this->labelInterval = $x; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide X grid * * @param boolean $bool XGrid or not * @return boolean true */ - function SetHideXGrid($bool) + public function SetHideXGrid($bool) { // phpcs:enable $this->hideXGrid = $bool; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide Y grid * * @param boolean $bool YGrid or not * @return boolean true */ - function SetHideYGrid($bool) + public function SetHideYGrid($bool) { // phpcs:enable $this->hideYGrid = $bool; return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set y label * * @param string $label Y label * @return boolean|null True */ - function SetYLabel($label) + public function SetYLabel($label) { // phpcs:enable $this->YLabel = $label; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set width * * @param int $w Width * @return boolean|null True */ - function SetWidth($w) + public function SetWidth($w) { // phpcs:enable $this->width = $w; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set title * * @param string $title Title * @return void */ - function SetTitle($title) + public function SetTitle($title) { // phpcs:enable $this->title = $title; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set data * @@ -259,172 +259,172 @@ class DolGraph * @return void * @see draw_jflot for syntax of data array */ - function SetData($data) + public function SetData($data) { // phpcs:enable $this->data = $data; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set data * * @param array $datacolor Data color array(array(R,G,B),array(R,G,B)...) * @return void */ - function SetDataColor($datacolor) + public function SetDataColor($datacolor) { // phpcs:enable $this->datacolor = $datacolor; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set type * * @param array $type Array with type for each serie. Example: array('pie'), array('lines',...,'bars') * @return void */ - function SetType($type) + public function SetType($type) { // phpcs:enable $this->type = $type; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set legend * * @param array $legend Legend. Example: array('seriename1','seriname2',...) * @return void */ - function SetLegend($legend) + public function SetLegend($legend) { // phpcs:enable $this->Legend = $legend; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set min width * * @param int $legendwidthmin Min width * @return void */ - function SetLegendWidthMin($legendwidthmin) + public function SetLegendWidthMin($legendwidthmin) { // phpcs:enable $this->LegendWidthMin = $legendwidthmin; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set max value * * @param int $max Max value * @return void */ - function SetMaxValue($max) + public function SetMaxValue($max) { // phpcs:enable $this->MaxValue = $max; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get max value * * @return int Max value */ - function GetMaxValue() + public function GetMaxValue() { // phpcs:enable return $this->MaxValue; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set min value * * @param int $min Min value * @return void */ - function SetMinValue($min) + public function SetMinValue($min) { // phpcs:enable $this->MinValue = $min; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get min value * * @return int Max value */ - function GetMinValue() + public function GetMinValue() { // phpcs:enable return $this->MinValue; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set height * * @param int $h Height * @return void */ - function SetHeight($h) + public function SetHeight($h) { // phpcs:enable $this->height = $h; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set shading * * @param string $s Shading * @return void */ - function SetShading($s) + public function SetShading($s) { // phpcs:enable $this->SetShading = $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set shading * * @param string $s Shading * @return void */ - function SetCssPrefix($s) + public function SetCssPrefix($s) { // phpcs:enable $this->cssprefix = $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset bg color * * @return void */ - function ResetBgColor() + public function ResetBgColor() { // phpcs:enable unset($this->bgcolor); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset bgcolorgrid * * @return void */ - function ResetBgColorGrid() + public function ResetBgColorGrid() { // phpcs:enable unset($this->bgcolorgrid); @@ -435,7 +435,7 @@ class DolGraph * * @return string Error */ - function isGraphKo() + public function isGraphKo() { return $this->error; } @@ -446,7 +446,7 @@ class DolGraph * @param int $showlegend 1=Show legend (default), 0=Hide legend * @return void */ - function setShowLegend($showlegend) + public function setShowLegend($showlegend) { $this->showlegend=$showlegend; } @@ -457,7 +457,7 @@ class DolGraph * @param int $showpointvalue 1=Show value for each point, as tooltip or inline (default), 0=Hide value * @return void */ - function setShowPointValue($showpointvalue) + public function setShowPointValue($showpointvalue) { $this->showpointvalue=$showpointvalue; } @@ -468,21 +468,21 @@ class DolGraph * @param int $showpercent 1=Show percent for each point, as tooltip or inline, 0=Hide percent (default) * @return void */ - function setShowPercent($showpercent) + public function setShowPercent($showpercent) { $this->showpercent=$showpercent; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define background color of complete image * * @param array $bg_color array(R,G,B) ou 'onglet' ou 'default' * @return void */ - function SetBgColor($bg_color = array(255,255,255)) + public function SetBgColor($bg_color = array(255,255,255)) { // phpcs:enable global $theme_bgcolor,$theme_bgcoloronglet; @@ -505,14 +505,14 @@ class DolGraph } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define background color of grid * * @param array $bg_colorgrid array(R,G,B) ou 'onglet' ou 'default' * @return void */ - function SetBgColorGrid($bg_colorgrid = array(255,255,255)) + public function SetBgColorGrid($bg_colorgrid = array(255,255,255)) { // phpcs:enable global $theme_bgcolor,$theme_bgcoloronglet; @@ -535,25 +535,25 @@ class DolGraph } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reset data color * * @return void */ - function ResetDataColor() - { + public function ResetDataColor() + { // phpcs:enable - unset($this->datacolor); - } + unset($this->datacolor); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Get max value * * @return int Max value */ - function GetMaxValueInData() + public function GetMaxValueInData() { // phpcs:enable $k = 0; @@ -574,13 +574,13 @@ class DolGraph return $vals[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return min value of all data * * @return int Min value of all data */ - function GetMinValueInData() + public function GetMinValueInData() { // phpcs:enable $k = 0; @@ -601,13 +601,13 @@ class DolGraph return $vals[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return max value of all data * * @return int Max value of all data */ - function GetCeilMaxValue() + public function GetCeilMaxValue() { // phpcs:enable $max = $this->GetMaxValueInData(); @@ -626,13 +626,13 @@ class DolGraph return $res; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return min value of all data * * @return double Max value of all data */ - function GetFloorMinValue() + public function GetFloorMinValue() { // phpcs:enable $min = $this->GetMinValueInData(); @@ -658,7 +658,7 @@ class DolGraph * @param string $fileurl Url path to show image if saved onto disk * @return integer|null */ - function draw($file, $fileurl = '') + public function draw($file, $fileurl = '') { if (empty($file)) { @@ -1127,7 +1127,7 @@ class DolGraph * @param int $shownographyet Show graph to say there is not enough data * @return string HTML string to show graph */ - function show($shownographyet = 0) + public function show($shownographyet = 0) { global $langs; @@ -1149,7 +1149,7 @@ class DolGraph * @param string $defaultsize Value we want as default size * @return int Value of width or height to use by default */ - static function getDefaultGraphSizeForStats($direction, $defaultsize = '') + public static function getDefaultGraphSizeForStats($direction, $defaultsize = '') { global $conf; diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 19de8abb3f6..0a98925e46a 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -111,9 +111,9 @@ class dolReceiptPrinter extends Escpos */ public $db; - var $tags; - var $printer; - var $template; + public $tags; + public $printer; + public $template; /** * @var string Error code (or message) @@ -132,7 +132,7 @@ class dolReceiptPrinter extends Escpos * * @param DoliDB $db database */ - function __construct($db) + public function __construct($db) { $this->db=$db; $this->tags = array( @@ -211,7 +211,7 @@ class dolReceiptPrinter extends Escpos * * @return int 0 if OK; >0 if KO */ - function listPrinters() + public function listPrinters() { global $conf; $error = 0; @@ -279,7 +279,7 @@ class dolReceiptPrinter extends Escpos * * @return int 0 if OK; >0 if KO */ - function listPrintersTemplates() + public function listPrintersTemplates() { global $conf; $error = 0; @@ -311,7 +311,7 @@ class dolReceiptPrinter extends Escpos * @param string $htmlname select html name * @return int 0 if OK; >0 if KO */ - function selectTypePrinter($selected = '', $htmlname = 'printertypeid') + public function selectTypePrinter($selected = '', $htmlname = 'printertypeid') { global $langs; @@ -335,7 +335,7 @@ class dolReceiptPrinter extends Escpos * @param string $htmlname select html name * @return int 0 if OK; >0 if KO */ - function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') + public function selectProfilePrinter($selected = '', $htmlname = 'printerprofileid') { global $langs; @@ -352,7 +352,6 @@ class dolReceiptPrinter extends Escpos } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Add a printer in db * @@ -362,9 +361,8 @@ class dolReceiptPrinter extends Escpos * @param string $parameter Printer parameter * @return int 0 if OK; >0 if KO */ - function AddPrinter($name, $type, $profile, $parameter) + public function addPrinter($name, $type, $profile, $parameter) { - // phpcs:enable global $conf; $error = 0; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'printer_receipt'; @@ -378,7 +376,6 @@ class dolReceiptPrinter extends Escpos return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Update a printer in db * @@ -389,9 +386,8 @@ class dolReceiptPrinter extends Escpos * @param int $printerid Printer id * @return int 0 if OK; >0 if KO */ - function UpdatePrinter($name, $type, $profile, $parameter, $printerid) + public function updatePrinter($name, $type, $profile, $parameter, $printerid) { - // phpcs:enable global $conf; $error = 0; $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt'; @@ -408,16 +404,14 @@ class dolReceiptPrinter extends Escpos return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Delete a printer from db * * @param int $printerid Printer id * @return int 0 if OK; >0 if KO */ - function DeletePrinter($printerid) + public function deletePrinter($printerid) { - // phpcs:enable global $conf; $error = 0; $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt'; @@ -430,7 +424,6 @@ class dolReceiptPrinter extends Escpos return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Update a printer template in db * @@ -439,9 +432,8 @@ class dolReceiptPrinter extends Escpos * @param int $templateid Template id * @return int 0 if OK; >0 if KO */ - function UpdateTemplate($name, $template, $templateid) + public function updateTemplate($name, $template, $templateid) { - // phpcs:enable global $conf; $error = 0; $sql = 'UPDATE '.MAIN_DB_PREFIX.'printer_receipt_template'; @@ -457,20 +449,18 @@ class dolReceiptPrinter extends Escpos } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Send Test page to Printer * * @param int $printerid Printer id * @return int 0 if OK; >0 if KO */ - function SendTestToPrinter($printerid) + public function sendTestToPrinter($printerid) { - // phpcs:enable global $conf; $error = 0; $img = new EscposImage(DOL_DOCUMENT_ROOT .'/theme/common/dolibarr_logo_bw.png'); - $ret = $this->InitPrinter($printerid); + $ret = $this->initPrinter($printerid); if ($ret>0) { setEventMessages($this->error, $this->errors, 'errors'); } else { @@ -492,7 +482,6 @@ class dolReceiptPrinter extends Escpos return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Function to Print Receipt Ticket * @@ -501,9 +490,8 @@ class dolReceiptPrinter extends Escpos * @param int $printerid Printer id * @return int 0 if OK; >0 if KO */ - function SendToPrinter($object, $templateid, $printerid) + public function sendToPrinter($object, $templateid, $printerid) { - // phpcs:enable global $conf; $error = 0; $ret = $this->loadTemplate($templateid); @@ -542,15 +530,12 @@ class dolReceiptPrinter extends Escpos // print ticket $level = 0; $html = '
';
-        $ret = $this->InitPrinter($printerid);
+        $ret = $this->initPrinter($printerid);
         if ($ret>0) {
             setEventMessages($this->error, $this->errors, 'errors');
-        }
-        else
-        {
+        } else {
             $nboflines = count($vals);
-            for ($line=0; $line < $nboflines; $line++)
-            {
+            for ($line=0; $line < $nboflines; $line++) {
                 switch ($vals[$line]['tag']) {
                     case 'DOL_ALIGN_CENTER':
                         $this->printer->setJustification(Escpos::JUSTIFY_CENTER);
@@ -627,10 +612,10 @@ class dolReceiptPrinter extends Escpos
     /**
      *  Function to load Template
      *
-     *  @param   int       $templateid        Template id
-     *  @return  int                        0 if OK; >0 if KO
+     *  @param   int       $templateid          Template id
+     *  @return  int                            0 if OK; >0 if KO
      */
-    function loadTemplate($templateid)
+    public function loadTemplate($templateid)
     {
         global $conf;
         $error = 0;
@@ -656,16 +641,14 @@ class dolReceiptPrinter extends Escpos
     }
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
     /**
      *  Function Init Printer
      *
      *  @param   int       $printerid       Printer id
      *  @return  int                        0 if OK; >0 if KO
      */
-    function InitPrinter($printerid)
+    public function initPrinter($printerid)
     {
-        // phpcs:enable
         global $conf;
         $error=0;
         $sql = 'SELECT rowid, name, fk_type, fk_profile, parameter';
diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php
index 63172d17566..f9eeeabf4c6 100644
--- a/htdocs/core/class/emailsenderprofile.class.php
+++ b/htdocs/core/class/emailsenderprofile.class.php
@@ -277,7 +277,7 @@ class EmailSenderProfile extends CommonObject
 	 *	@param	int		$withpicto					Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto)
 	 *	@return	string								String with URL
 	 */
-	function getNomUrl($withpicto = 0)
+	public function getNomUrl($withpicto = 0)
 	{
 		global $db, $conf, $langs;
 		global $dolibarr_main_authentication, $dolibarr_main_demo;
@@ -286,16 +286,15 @@ class EmailSenderProfile extends CommonObject
 		$result = '';
 		$companylink = '';
 
-    $label=$this->label;
+        $label=$this->label;
 
-    $url='';
+        $url='';
 		//$url = dol_buildpath('/monmodule/emailsenderprofile_card.php',1).'?id='.$this->id;
 
 		$linkstart = '';
 		$linkend='';
 
-		if ($withpicto)
-		{
+		if ($withpicto) {
 			$result.=($linkstart.img_object($label, 'label', 'class="classfortooltip"').$linkend);
 			if ($withpicto != 2) $result.=' ';
 		}
@@ -309,12 +308,12 @@ class EmailSenderProfile extends CommonObject
 	 *  @param	int		$mode          0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
 	 *  @return	string 			       Label of status
 	 */
-	function getLibStatut($mode = 0)
+	public function getLibStatut($mode = 0)
 	{
 		return $this->LibStatut($this->status, $mode);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Return the status
 	 *
@@ -322,49 +321,49 @@ class EmailSenderProfile extends CommonObject
 	 *  @param  int		$mode          	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
 	 *  @return string 			       	Label of status
 	 */
-	static function LibStatut($status, $mode = 0)
+	public static function LibStatut($status, $mode = 0)
 	{
 		global $langs;
 
 		if ($mode == 0 || $mode == 1)
 		{
 			if ($status == 1) return $langs->trans('Enabled');
-			if ($status == 0) return $langs->trans('Disabled');
+			elseif ($status == 0) return $langs->trans('Disabled');
 		}
 		elseif ($mode == 2)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
-			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
 		}
 		elseif ($mode == 3)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
-			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
 		}
 		elseif ($mode == 4)
 		{
 			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
-			if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
 		}
 		elseif ($mode == 5)
 		{
 			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
 		}
 		elseif ($mode == 6)
 		{
 			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
-			if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
 		}
 	}
 
-	/**
-	 *	Charge les informations d'ordre info dans l'objet commande
+    /**
+     *  Charge les informations d'ordre info dans l'objet commande
 	 *
-	 *	@param  int		$id       Id of order
-	 *	@return	void
+	 *  @param  int     $id       Id of order
+	 *  @return	void
 	 */
-	function info($id)
+	public function info($id)
 	{
 		$sql = 'SELECT rowid, date_creation as datec, tms as datem,';
 		$sql.= ' fk_user_creat, fk_user_modif';
diff --git a/htdocs/core/class/events.class.php b/htdocs/core/class/events.class.php
index 50b948a85be..50fc116611a 100644
--- a/htdocs/core/class/events.class.php
+++ b/htdocs/core/class/events.class.php
@@ -119,7 +119,7 @@ class Events // extends CommonObject
 	 *
 	 *  @param		DoliDB		$db      Database handler
 	 */
-	function __construct($db)
+	public function __construct($db)
 	{
 		$this->db = $db;
 	}
@@ -129,9 +129,9 @@ class Events // extends CommonObject
 	 *   Create in database
 	 *
 	 *   @param      User	$user       User that create
-	 *   @return     int     		    <0 if KO, >0 if OK
+	 *   @return     int                <0 if KO, >0 if OK
 	 */
-	function create($user)
+	public function create($user)
 	{
 		global $conf, $langs;
 
@@ -183,7 +183,7 @@ class Events // extends CommonObject
 	 * @param   int		$notrigger	    0=no, 1=yes (no update trigger)
 	 * @return  int         			<0 if KO, >0 if OK
 	 */
-	function update($user = null, $notrigger = 0)
+    public function update($user = null, $notrigger = 0)
 	{
 		global $conf, $langs;
 
@@ -220,7 +220,7 @@ class Events // extends CommonObject
 	 *  @param  User	$user       User that load
 	 *  @return int         		<0 if KO, >0 if OK
 	 */
-	function fetch($id, $user = null)
+    public function fetch($id, $user = null)
 	{
 		global $langs;
 
@@ -271,7 +271,7 @@ class Events // extends CommonObject
 	 *	@param	User	$user       User that delete
 	 *	@return	int					<0 if KO, >0 if OK
 	 */
-	function delete($user)
+    public function delete($user)
 	{
 		global $conf, $langs;
 
@@ -296,8 +296,8 @@ class Events // extends CommonObject
      *	id must be 0 if object instance is a specimen.
      *
      *  @return	void
-	 */
-	function initAsSpecimen()
+     */
+    public function initAsSpecimen()
 	{
 		$this->id=0;
 
@@ -305,5 +305,5 @@ class Events // extends CommonObject
 		$this->type='';
 		$this->dateevent=time();
 		$this->description='This is a specimen event';
-	}
+    }
 }
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index c23f40a0283..ce8916c1871 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -182,7 +182,7 @@ class ExtraFields
 	 *
 	 *  @param		DoliDB		$db      Database handler
 	*/
-	function __construct($db)
+	public function __construct($db)
 	{
 		$this->db = $db;
 		$this->error = '';
@@ -226,7 +226,7 @@ class ExtraFields
 	 *  @param  string  		$enabled  		 	Condition to have the field enabled or not
 	 *  @return int      							<=0 if KO, >0 if OK
 	 */
-	function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1')
+	public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1')
 	{
 		if (empty($attrname)) return -1;
 		if (empty($label)) return -1;
@@ -469,7 +469,7 @@ class ExtraFields
 	 *  @param  string	$elementtype    Element type ('member', 'product', 'thirdparty', 'contact', ...)
 	 *  @return int              		< 0 if KO, 0 if nothing is done, 1 if OK
 	 */
-	function delete($attrname, $elementtype = 'member')
+	public function delete($attrname, $elementtype = 'member')
 	{
 		if ($elementtype == 'thirdparty') $elementtype='societe';
 		if ($elementtype == 'contact') $elementtype='socpeople';
@@ -586,7 +586,7 @@ class ExtraFields
      *  @param  int     $totalizable        Is extrafield totalizable on list
 	 * 	@return	int							>0 if OK, <=0 if KO
 	 */
-	function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0)
+	public function update($attrname, $label, $type, $length, $elementtype, $unique = 0, $required = 0, $pos = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0)
 	{
 		if ($elementtype == 'thirdparty') $elementtype='societe';
 		if ($elementtype == 'contact') $elementtype='socpeople';
@@ -819,7 +819,7 @@ class ExtraFields
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * 	Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ...
 	 *
@@ -827,7 +827,7 @@ class ExtraFields
 	 * 	@param	boolean		$forceload			Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED. Deprecated. Should not be required.
 	 * 	@return	array							Array of attributes keys+label for all extra fields.
 	 */
-	function fetch_name_optionals_label($elementtype, $forceload = false)
+	public function fetch_name_optionals_label($elementtype, $forceload = false)
 	{
         // phpcs:enable
 		global $conf;
@@ -950,7 +950,7 @@ class ExtraFields
 	 * @param  string  $extrafieldsobjectkey	If defined (for example $object->table_element), use the new method to get extrafields data
 	 * @return string
 	 */
-	function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '')
+	public function showInputField($key, $value, $moreparam = '', $keysuffix = '', $keyprefix = '', $morecss = '', $objectid = 0, $extrafieldsobjectkey = '')
 	{
 		global $conf,$langs,$form;
 
@@ -1565,7 +1565,7 @@ class ExtraFields
 	 * @param	string	$extrafieldsobjectkey	If defined (for example $object->table_element), use the new method to get extrafields data
 	 * @return	string							Formated value
 	 */
-	function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '')
+	public function showOutputField($key, $value, $moreparam = '', $extrafieldsobjectkey = '')
 	{
 		global $conf,$langs;
 
@@ -1877,7 +1877,7 @@ class ExtraFields
 	 * @param	string	$extrafieldsobjectkey	If defined, use the new method to get extrafields data
 	 * @return	string							Formated value
 	 */
-	function getAlignFlag($key, $extrafieldsobjectkey = '')
+	public function getAlignFlag($key, $extrafieldsobjectkey = '')
 	{
 		global $conf,$langs;
 
@@ -1929,7 +1929,7 @@ class ExtraFields
 	 * @param	string	$object			Object
 	 * @return 	string					HTML code with line for separator
 	 */
-	function showSeparator($key, $object)
+	public function showSeparator($key, $object)
 	{
 		global $langs;
 
@@ -1947,7 +1947,7 @@ class ExtraFields
 	 * @param	string	$onlykey		Only following key is filled. When we make update of only one extrafield ($action = 'update_extras'), calling page must must set this to avoid to have other extrafields being reset.
 	 * @return	int						1 if array_options set, 0 if no value, -1 if error (field required missing for example)
 	 */
-	function setOptionalsFromPost($extralabels, &$object, $onlykey = '')
+	public function setOptionalsFromPost($extralabels, &$object, $onlykey = '')
 	{
 		global $_POST, $langs;
 		$nofillrequired='';// For error when required field left blank
@@ -2046,7 +2046,7 @@ class ExtraFields
 	 * @param  string			$keysuffix      		Suffix string to add into name and id of field (can be used to avoid duplicate names)
 	 * @return array|int								array_options set or 0 if no value
 	 */
-	function getOptionalsFromPost($extrafieldsobjectkey, $keyprefix = '', $keysuffix = '')
+	public function getOptionalsFromPost($extrafieldsobjectkey, $keyprefix = '', $keysuffix = '')
 	{
 		global $_POST;
 
diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php
index d90707db4dd..bd36dba199b 100644
--- a/htdocs/core/class/fileupload.class.php
+++ b/htdocs/core/class/fileupload.class.php
@@ -41,7 +41,7 @@ class FileUpload
 	 * @param int		$fk_element		fk_element
 	 * @param string	$element		element
 	 */
-	function __construct($options = null, $fk_element = null, $element = null)
+	public function __construct($options = null, $fk_element = null, $element = null)
 	{
 		global $db, $conf;
 		global $object;
diff --git a/htdocs/core/class/fiscalyear.class.php b/htdocs/core/class/fiscalyear.class.php
index ddbe70303d2..014946434be 100644
--- a/htdocs/core/class/fiscalyear.class.php
+++ b/htdocs/core/class/fiscalyear.class.php
@@ -82,7 +82,7 @@ class Fiscalyear extends CommonObject
 	 *
 	 * @param	DoliDB		$db		Database handler
 	 */
-	function __construct(DoliDB $db)
+	public function __construct(DoliDB $db)
 	{
 		global $langs;
 
@@ -98,7 +98,7 @@ class Fiscalyear extends CommonObject
 	 *	@param		User	$user   User making creation
 	 *	@return 	int				<0 if KO, >0 if OK
 	 */
-	function create($user)
+	public function create($user)
 	{
 		global $conf;
 
@@ -159,7 +159,7 @@ class Fiscalyear extends CommonObject
 	 *	@param	User	$user		User making update
 	 *	@return	int					<0 if KO, >0 if OK
 	 */
-	function update($user)
+	public function update($user)
 	{
 		global $langs;
 
@@ -203,7 +203,7 @@ class Fiscalyear extends CommonObject
 	* @param	int		$id		Id of record to load
 	* @return	int				<0 if KO, >0 if OK
 	*/
-	function fetch($id)
+	public function fetch($id)
 	{
 		$sql = "SELECT rowid, label, date_start, date_end, statut";
 		$sql.= " FROM ".MAIN_DB_PREFIX."accounting_fiscalyear";
@@ -237,7 +237,7 @@ class Fiscalyear extends CommonObject
 	*	@param	int		$id		Id of record to delete
 	*	@return	int				<0 if KO, >0 if OK
 	*/
-	function delete($id)
+	public function delete($id)
 	{
 		$this->db->begin();
 
@@ -264,12 +264,12 @@ class Fiscalyear extends CommonObject
 	 * @param	int		$mode   	0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
 	 * @return  string   		   	Label
 	 */
-	function getLibStatut($mode = 0)
+	public function getLibStatut($mode = 0)
 	{
 		return $this->LibStatut($this->statut, $mode);
 	}
 
-	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Give a label from a status
 	 *
@@ -277,7 +277,7 @@ class Fiscalyear extends CommonObject
 	 *  @param  int		$mode       0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
 	 *  @return string      		Label
 	 */
-	function LibStatut($statut, $mode = 0)
+	public function LibStatut($statut, $mode = 0)
 	{
 		// phpcs:enable
 		global $langs;
@@ -318,7 +318,7 @@ class Fiscalyear extends CommonObject
 	 * @param	int		$id      Id of record
 	 * @return	void
 	 */
-	function info($id)
+	public function info($id)
 	{
 		$sql = 'SELECT fy.rowid, fy.datec, fy.fk_user_author, fy.fk_user_modif,';
 		$sql.= ' fy.tms';
@@ -364,7 +364,7 @@ class Fiscalyear extends CommonObject
 	 *	@param	int		$dateend	Date end to scan
 	 *	@return	string				Number of entries
 	 */
-	function getAccountancyEntriesByFiscalYear($datestart, $dateend)
+	public function getAccountancyEntriesByFiscalYear($datestart, $dateend)
 	{
 		global $conf;
 
@@ -386,11 +386,11 @@ class Fiscalyear extends CommonObject
 	/**
 	 *  Return the number of movements by fiscal year
 	 *
-	 *	@param	int		$datestart	Date start to scan
-	 *	@param	int		$dateend	Date end to scan
-	 *	@return	string				Number of movements
+	 *  @param	int		$datestart	Date start to scan
+	 *  @param	int		$dateend	Date end to scan
+	 *  @return	string				Number of movements
 	 */
-	function getAccountancyMovementsByFiscalYear($datestart, $dateend)
+	public function getAccountancyMovementsByFiscalYear($datestart, $dateend)
 	{
 		global $conf;
 
diff --git a/htdocs/core/class/genericobject.class.php b/htdocs/core/class/genericobject.class.php
index 993d884c88b..a8d837bbaba 100644
--- a/htdocs/core/class/genericobject.class.php
+++ b/htdocs/core/class/genericobject.class.php
@@ -34,7 +34,7 @@ class GenericObject extends CommonObject
      *
      * @param       DoliDB      $db     Database handler
      */
-    function __construct($db)
+    public function __construct($db)
     {
         $this->db=$db;
     }
diff --git a/htdocs/core/class/google.class.php b/htdocs/core/class/google.class.php
index 797f0a14af1..a472e6dcf22 100644
--- a/htdocs/core/class/google.class.php
+++ b/htdocs/core/class/google.class.php
@@ -26,63 +26,63 @@
  */
 class GoogleAPI
 {
-	/**
+    /**
      * @var DoliDB Database handler.
      */
     public $db;
 
-	/**
-	 * @var string Error code (or message)
-	 */
-	public $error='';
+    /**
+     * @var string Error code (or message)
+     */
+    public $error='';
 
-	public $key;
+    public $key;
 
-	/**
-	 * Constructor
-	 *
-	 * @param 	DoliDB		$db			Database handler
-	 * @param	string		$key		Google key
-	 */
-	function __construct($db, $key)
-	{
-		$this->db=$db;
-		$this->key=$key;
-	}
+    /**
+     * Constructor
+     *
+     * @param 	DoliDB		$db			Database handler
+     * @param	string		$key		Google key
+     */
+    public function __construct($db, $key)
+    {
+        $this->db=$db;
+        $this->key=$key;
+    }
 
 
-	/**
-	 *  Return geo coordinates of an address
-	 *
-	 *  @param	string	$address	Address
-	 * 								Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France
-	 *								Example: 188, rue de Fontenay,+94300,+Vincennes,+France
-	 *	@return	string				Coordinates
-	 */
-	function getGeoCoordinatesOfAddress($address)
-	{
-		global $conf;
+    /**
+     *  Return geo coordinates of an address
+     *
+     *  @param	string	$address	Address
+     * 								Example: 68 Grande rue Charles de Gaulle,+94130,+Nogent sur Marne,+France
+     *								Example: 188, rue de Fontenay,+94300,+Vincennes,+France
+     *	@return	string				Coordinates
+     */
+    public function getGeoCoordinatesOfAddress($address)
+    {
+        global $conf;
 
-		$i=0;
+        $i=0;
 
-		// Desired address
-		$urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key;
+        // Desired address
+        $urladdress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=xml&key=".$this->key;
 
-		// Retrieve the URL contents
-		$page = file_get_contents($urladdress);
+        // Retrieve the URL contents
+        $page = file_get_contents($urladdress);
 
-		$code = strstr($page, '');
-		$code = strstr($code, '>');
-		$val=strpos($code, "<");
-		$code = substr($code, 1, $val-1);
-		//print $code;
-		//print "
"; - $latitude = substr($code, 0, strpos($code, ",")); - $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); + $code = strstr($page, ''); + $code = strstr($code, '>'); + $val=strpos($code, "<"); + $code = substr($code, 1, $val-1); + //print $code; + //print "
"; + $latitude = substr($code, 0, strpos($code, ",")); + $longitude = substr($code, strpos($code, ",")+1, dol_strlen(strpos($code, ","))-3); - // Output the coordinates - //echo "Longitude: $longitude ',' Latitude: $latitude"; + // Output the coordinates + //echo "Longitude: $longitude ',' Latitude: $latitude"; - $i++; - } + $i++; + } } diff --git a/htdocs/core/class/hookmanager.class.php b/htdocs/core/class/hookmanager.class.php index 0db47d1ade0..f23aa1da5a3 100644 --- a/htdocs/core/class/hookmanager.class.php +++ b/htdocs/core/class/hookmanager.class.php @@ -45,24 +45,24 @@ class HookManager public $errors = array(); // Context hookmanager was created for ('thirdpartycard', 'thirdpartydao', ...) - var $contextarray=array(); + public $contextarray=array(); // Array with instantiated classes - var $hooks=array(); + public $hooks=array(); // Array result - var $resArray=array(); + public $resArray=array(); // Printable result - var $resPrint=''; + public $resPrint=''; // Nb of qualified hook ran - var $resNbOfHooks=0; + public $resNbOfHooks=0; /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -79,7 +79,7 @@ class HookManager * @param string[] $arraycontext Array list of searched hooks tab/features. For example: 'thirdpartycard' (for hook methods into page card thirdparty), 'thirdpartydao' (for hook methods into Societe), ... * @return int Always 1 */ - function initHooks($arraycontext) + public function initHooks($arraycontext) { global $conf; @@ -125,18 +125,18 @@ class HookManager } /** - * Execute hooks (if they were initialized) for the given method + * Execute hooks (if they were initialized) for the given method * - * @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...) - * @param array $parameters Array of parameters - * @param Object $object Object to use hooks on - * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) - * @return mixed For 'addreplace' hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. - * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. - * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. - * $this->error or this->errors are also defined by class called by this function if error. + * @param string $method Name of method hooked ('doActions', 'printSearchForm', 'showInputField', ...) + * @param array $parameters Array of parameters + * @param Object $object Object to use hooks on + * @param string $action Action code on calling page ('create', 'edit', 'view', 'add', 'update', 'delete'...) + * @return mixed For 'addreplace' hooks (doActions,formObjectOptions,pdf_xxx,...): Return 0 if we want to keep standard actions, >0 if we want to stop/replace standard actions, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. + * For 'output' hooks (printLeftBlock, formAddObjectLine, formBuilddocOptions, ...): Return 0, <0 if KO. Things to print are returned into ->resprints and set into ->resPrint. Things to return are returned into ->results by hook and set into ->resArray for caller. + * All types can also return some values into an array ->results that will be finaly merged into this->resArray for caller. + * $this->error or this->errors are also defined by class called by this function if error. */ - function executeHooks($method, $parameters = array(), &$object = '', &$action = '') + public function executeHooks($method, $parameters = array(), &$object = '', &$action = '') { if (! is_array($this->hooks) || empty($this->hooks)) return ''; @@ -145,7 +145,7 @@ class HookManager // Define type of hook ('output' or 'addreplace'. 'returnvalue' is deprecated because a 'addreplace' hook can also return resPrint and resArray). $hooktype='output'; -if (in_array( + if (in_array( $method, array( 'addCalendarChoice', @@ -204,10 +204,9 @@ if (in_array( ) )) $hooktype='addreplace'; - if ($method == 'insertExtraFields') - { - $hooktype='returnvalue'; // @deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available. - dol_syslog("Warning: The hook 'insertExtraFields' is deprecated and must not be used. Use instead trigger on CRUD event (ask it to dev team if not implemented)", LOG_WARNING); + if ($method == 'insertExtraFields') { + $hooktype='returnvalue'; // @deprecated. TODO Remove all code with "executeHooks('insertExtraFields'" as soon as there is a trigger available. + dol_syslog("Warning: The hook 'insertExtraFields' is deprecated and must not be used. Use instead trigger on CRUD event (ask it to dev team if not implemented)", LOG_WARNING); } // Init return properties diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ce5c27f3b8c..a83ff1083e6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -17,7 +17,7 @@ * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2014 Alexandre Spangaro * Copyright (C) 2018 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018 Christophe Battarel * Copyright (C) 2018 Josep Lluis Amador @@ -102,7 +102,7 @@ class Form * @param string $paramid Key of parameter for id ('id', 'socid') * @return string HTML edit field */ - function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id') + public function editfieldkey($text, $htmlname, $preselected, $object, $perm, $typeofdata = 'string', $moreparam = '', $fieldrequired = 0, $notabletag = 0, $paramid = 'id') { global $conf,$langs; @@ -164,7 +164,7 @@ class Form * @param string $paramid Key of parameter for id ('id', 'socid') * @return string HTML edit field */ - function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 0, $formatfunc = '', $paramid = 'id') + public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 0, $formatfunc = '', $paramid = 'id') { global $conf,$langs,$db; @@ -441,7 +441,7 @@ class Form * @see Use function textwithpicto if you can. * TODO Move this as static as soon as everybody use textwithpicto or @Form::textwithtooltip */ - function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0) + public function textwithtooltip($text, $htmltext, $tooltipon = 1, $direction = 0, $img = '', $extracss = '', $notabs = 2, $incbefore = '', $noencodehtmltext = 0, $tooltiptrigger = '', $forcenowrap = 0) { global $conf; @@ -526,7 +526,7 @@ class Form * @param int $forcenowrap Force no wrap between text and picto (works with notabs=2 only) * @return string HTML code of text, picto, tooltip */ - function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2, $tooltiptrigger = '', $forcenowrap = 0) + public function textwithpicto($text, $htmltext, $direction = 1, $type = 'help', $extracss = '', $noencodehtmltext = 0, $notabs = 2, $tooltiptrigger = '', $forcenowrap = 0) { global $conf, $langs; @@ -578,7 +578,7 @@ class Form * @param int $alwaysvisible 1=select button always visible * @return string Select list */ - function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0) + public function selectMassAction($selected, $arrayofaction, $alwaysvisible = 0) { global $conf,$langs,$hookmanager; @@ -663,7 +663,7 @@ class Form return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return combo list of activated countries, into language of user * @@ -678,7 +678,7 @@ class Form * @param int $addspecialentries 1=Add dedicated entries for group of countries (like 'European Economic Community', ...) * @return string HTML string with select */ - function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0) + public function select_country($selected = '', $htmlname = 'country_id', $htmloption = '', $maxlength = 0, $morecss = 'minwidth300', $usecodeaskey = '', $showempty = 1, $disablefavorites = 0, $addspecialentries = 0) { // phpcs:enable global $conf,$langs,$mysoc; @@ -778,7 +778,7 @@ class Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list of incoterms * @@ -791,7 +791,7 @@ class Form * @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return string HTML string with select and input */ - function select_incoterms($selected = '', $location_incoterms = '', $page = '', $htmlname = 'incoterm_id', $htmloption = '', $forcecombo = 1, $events = array()) + public function select_incoterms($selected = '', $location_incoterms = '', $page = '', $htmlname = 'incoterm_id', $htmloption = '', $forcecombo = 1, $events = array()) { // phpcs:enable global $conf,$langs; @@ -872,7 +872,7 @@ class Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of types of lines (product or service) * Example: 0=product, 1=service, 9=other (for external module) @@ -884,7 +884,7 @@ class Form * @param integer $forceall 1=Force to show products and services in combo list, whatever are activated modules, 0=No force, 2=Force to show only Products, 3=Force to show only services, -1=Force none (and set hidden field to 'service') * @return void */ - function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0) + public function select_type_of_lines($selected = '', $htmlname = 'type', $showempty = 0, $hidetext = 0, $forceall = 0) { // phpcs:enable global $db,$langs,$user,$conf; @@ -929,13 +929,13 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into cache cache_types_fees, array of types of fees * * @return int Nb of lines loaded, <0 if KO */ - function load_cache_types_fees() + public function load_cache_types_fees() { // phpcs:enable global $langs; @@ -978,7 +978,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of types of notes * @@ -987,7 +987,7 @@ class Form * @param int $showempty Add an empty field * @return void */ - function select_type_fees($selected = '', $htmlname = 'type', $showempty = 0) + public function select_type_fees($selected = '', $htmlname = 'type', $showempty = 0) { // phpcs:enable global $user, $langs; @@ -1018,7 +1018,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML code to select a company. * @@ -1031,13 +1031,13 @@ class Form * @return string Return select box for thirdparty. * @deprecated 3.8 Use select_company instead. For exemple $form->select_thirdparty(GETPOST('socid'),'socid','',0) => $form->select_company(GETPOST('socid'),'socid','',1,0,0,array(),0) */ - function select_thirdparty($selected = '', $htmlname = 'socid', $filter = '', $limit = 20, $ajaxoptions = array(), $forcecombo = 0) + public function select_thirdparty($selected = '', $htmlname = 'socid', $filter = '', $limit = 20, $ajaxoptions = array(), $forcecombo = 0) { // phpcs:enable return $this->select_thirdparty_list($selected, $htmlname, $filter, 1, 0, $forcecombo, array(), '', 0, $limit); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output html form to select a third party * @@ -1057,7 +1057,7 @@ class Form * @param bool $multiple add [] in the name of element and add 'multiple' attribut (not working with ajax_autocompleter) * @return string HTML string with select box for thirdparty. */ - function select_company($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss = 'minwidth100', $moreparam = '', $selected_input_value = '', $hidelabel = 1, $ajaxoptions = array(), $multiple = false) + public function select_company($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $limit = 0, $morecss = 'minwidth100', $moreparam = '', $selected_input_value = '', $hidelabel = 1, $ajaxoptions = array(), $multiple = false) { // phpcs:enable global $conf,$user,$langs; @@ -1101,7 +1101,7 @@ class Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output html form to select a third party. * Note, you must use the select_company to get the component to select a third party. This function must only be called by select_company. @@ -1121,7 +1121,7 @@ class Form * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return string HTML string with */ - function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false) + public function select_thirdparty_list($selected = '', $htmlname = 'socid', $filter = '', $showempty = '', $showtype = 0, $forcecombo = 0, $events = array(), $filterkey = '', $outputmode = 0, $limit = 0, $morecss = 'minwidth100', $moreparam = '', $multiple = false) { // phpcs:enable global $conf,$user,$langs; @@ -1284,18 +1284,18 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return HTML combo list of absolute discounts + * Return HTML combo list of absolute discounts * - * @param string $selected Id remise fixe pre-selectionnee - * @param string $htmlname Nom champ formulaire - * @param string $filter Criteres optionnels de filtre - * @param int $socid Id of thirdparty - * @param int $maxvalue Max value for lines that can be selected - * @return int Return number of qualifed lines in list + * @param string $selected Id remise fixe pre-selectionnee + * @param string $htmlname Nom champ formulaire + * @param string $filter Criteres optionnels de filtre + * @param int $socid Id of thirdparty + * @param int $maxvalue Max value for lines that can be selected + * @return int Return number of qualifed lines in list */ - function select_remises($selected, $htmlname, $filter, $socid, $maxvalue = 0) + public function select_remises($selected, $htmlname, $filter, $socid, $maxvalue = 0) { // phpcs:enable global $langs,$conf; @@ -1361,33 +1361,33 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return list of all contacts (for a third party or all) + * Return list of all contacts (for a third party or all) * - * @param int $socid Id ot third party or 0 for all - * @param string $selected Id contact pre-selectionne - * @param string $htmlname Name of HTML field ('none' for a not editable field) - * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list - * @param string $exclude List of contacts id to exclude - * @param string $limitto Disable answers that are not id in this array list - * @param integer $showfunction Add function into label - * @param string $moreclass Add more class to class style - * @param integer $showsoc Add company into label - * @param int $forcecombo Force to use combo box + * @param int $socid Id ot third party or 0 for all + * @param string $selected Id contact pre-selectionne + * @param string $htmlname Name of HTML field ('none' for a not editable field) + * @param int $showempty 0=no empty value, 1=add an empty value, 2=add line 'Internal' (used by user edit), 3=add an empty value only if more than one record into list + * @param string $exclude List of contacts id to exclude + * @param string $limitto Disable answers that are not id in this array list + * @param integer $showfunction Add function into label + * @param string $moreclass Add more class to class style + * @param integer $showsoc Add company into label + * @param int $forcecombo Force to use combo box * @param array $events Event options. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @param bool $options_only Return options only (for ajax treatment) * @param string $moreparam Add more parameters onto the select tag. For example 'style="width: 95%"' to avoid select2 component to go over parent container * @param string $htmlid Html id to use instead of htmlname - * @return int <0 if KO, Nb of contact in list if OK + * @return int <0 if KO, Nb of contact in list if OK * @deprected You can use selectcontacts directly (warning order of param was changed) */ - function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '') - { + public function select_contacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $showsoc = 0, $forcecombo = 0, $events = array(), $options_only = false, $moreparam = '', $htmlid = '') + { // phpcs:enable print $this->selectcontacts($socid, $selected, $htmlname, $showempty, $exclude, $limitto, $showfunction, $moreclass, $options_only, $showsoc, $forcecombo, $events, $moreparam, $htmlid); return $this->num; - } + } /** * Return HTML code of the SELECT of list of all contacts (for a third party or all). @@ -1412,8 +1412,8 @@ class Form * @param bool $multiple add [] in the name of element and add 'multiple' attribut * @return int <0 if KO, Nb of contact in list if OK */ - function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false) - { + public function selectcontacts($socid, $selected = '', $htmlname = 'contactid', $showempty = 0, $exclude = '', $limitto = '', $showfunction = 0, $moreclass = '', $options_only = false, $showsoc = 0, $forcecombo = 0, $events = array(), $moreparam = '', $htmlid = '', $multiple = false) + { global $conf,$langs,$hookmanager,$action; $langs->load('companies'); @@ -1543,7 +1543,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list of users * @@ -1559,13 +1559,13 @@ class Form * @deprecated Use select_dolusers instead * @see select_dolusers() */ - function select_users($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0') + public function select_users($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0') { // phpcs:enable print $this->select_dolusers($selected, $htmlname, $show_empty, $exclude, $disabled, $include, $enableonly, $force_entity); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list of users * @@ -1589,7 +1589,7 @@ class Form * @return string HTML select string * @see select_dolgroups */ - function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false) + public function select_dolusers($selected = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $show_every = 0, $enableonlytext = '', $morecss = '', $noactive = 0, $outputmode = 0, $multiple = false) { // phpcs:enable global $conf,$user,$langs; @@ -1774,7 +1774,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list of users. Selected users are stored into session. * List of users are provided into $_SESSION['assignedtouser']. @@ -1797,7 +1797,7 @@ class Form * @return string HTML select string * @see select_dolgroups */ - function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array()) + public function select_dolusers_forevent($action = '', $htmlname = 'userid', $show_empty = 0, $exclude = null, $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $maxlength = 0, $showstatus = 0, $morefilter = '', $showproperties = 0, $listofuserid = array(), $listofcontactid = array(), $listofotherid = array()) { // phpcs:enable global $conf, $user, $langs; @@ -1864,7 +1864,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of products for customer in Ajax if Ajax activated or go to select_produits_list * @@ -1890,7 +1890,7 @@ class Form * @param array $selected_combinations Selected combinations. Format: array([attrid] => attrval, [...]) * @return void */ - function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = array()) + public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = array()) { // phpcs:enable global $langs,$conf; @@ -2008,7 +2008,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of products for a customer * @@ -2032,7 +2032,7 @@ class Form * 'warehouseinternal' = select products from warehouses for internal correct/transfer only * @return array Array of keys for json */ - function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') + public function select_produits_list($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 20, $price_level = 0, $filterkey = '', $status = 1, $finished = 2, $outputmode = 0, $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '') { // phpcs:enable global $langs,$conf,$user,$db; @@ -2561,7 +2561,7 @@ class Form $optJson = array('key'=>$outkey, 'value'=>$outref, 'label'=>$outval, 'label2'=>$outlabel, 'desc'=>$outdesc, 'type'=>$outtype, 'price_ht'=>$outprice_ht, 'price_ttc'=>$outprice_ttc, 'pricebasetype'=>$outpricebasetype, 'tva_tx'=>$outtva_tx, 'qty'=>$outqty, 'discount'=>$outdiscount, 'duration_value'=>$outdurationvalue, 'duration_unit'=>$outdurationunit); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of products for customer (in Ajax if Ajax activated or go to select_produits_fournisseurs_list) * @@ -2576,7 +2576,7 @@ class Form * @param string $morecss More CSS * @return void */ - function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') + public function select_produits_fournisseurs($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $ajaxoptions = array(), $hidelabel = 0, $alsoproductwithnosupplierprice = 0, $morecss = '') { // phpcs:enable global $langs,$conf; @@ -2605,7 +2605,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of suppliers products * @@ -2622,7 +2622,7 @@ class Form * @param string $morecss Add more CSS * @return array Array of keys for json */ - function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') + public function select_produits_fournisseurs_list($socid, $selected = '', $htmlname = 'productid', $filtertype = '', $filtre = '', $filterkey = '', $statut = -1, $outputmode = 0, $limit = 100, $alsoproductwithnosupplierprice = 0, $morecss = '') { // phpcs:enable global $langs,$conf,$db; @@ -2837,7 +2837,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of suppliers prices for a product * @@ -2846,7 +2846,7 @@ class Form * @param int $selected_supplier Pre-selected supplier if more than 1 result * @return void */ - function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') + public function select_product_fourn_price($productid, $htmlname = 'productfournpriceid', $selected_supplier = '') { // phpcs:enable global $langs,$conf; @@ -2950,7 +2950,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of delivery address * @@ -2960,7 +2960,7 @@ class Form * @param int $showempty Add an empty field * @return integer|null */ - function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0) + public function select_address($selected, $socid, $htmlname = 'address_id', $showempty = 0) { // phpcs:enable // looking for users @@ -3004,13 +3004,13 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into cache list of payment terms * * @return int Nb of lines loaded, <0 if KO */ - function load_cache_conditions_paiements() + public function load_cache_conditions_paiements() { // phpcs:enable global $langs; @@ -3053,13 +3053,13 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge dans cache la liste des délais de livraison possibles * * @return int Nb of lines loaded, <0 if KO */ - function load_cache_availability() + public function load_cache_availability() { // phpcs:enable global $langs; @@ -3111,7 +3111,7 @@ class Form * @param int $addempty Add empty entry * @return void */ - function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0) + public function selectAvailabilityDelay($selected = '', $htmlname = 'availid', $filtertype = '', $addempty = 0) { global $langs,$user; @@ -3143,7 +3143,7 @@ class Form * * @return int Nb of lines loaded, <0 if KO */ - function loadCacheInputReason() + public function loadCacheInputReason() { global $langs; @@ -3197,7 +3197,7 @@ class Form * @param int $addempty Add an empty entry * @return void */ - function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) + public function selectInputReason($selected = '', $htmlname = 'demandreasonid', $exclude = '', $addempty = 0) { global $langs,$user; @@ -3225,13 +3225,13 @@ class Form if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge dans cache la liste des types de paiements possibles * * @return int Nb of lines loaded, <0 if KO */ - function load_cache_types_paiements() + public function load_cache_types_paiements() { // phpcs:enable global $langs; @@ -3279,7 +3279,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment modes. * Constant MAIN_DEFAULT_PAYMENT_TERM_ID can used to set default value but scope is all application, probably not what you want. @@ -3293,7 +3293,7 @@ class Form * @param string $morecss Add more CSS on select tag * @return void */ - function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') + public function select_conditions_paiements($selected = 0, $htmlname = 'condid', $filtertype = -1, $addempty = 0, $noinfoadmin = 0, $morecss = '') { // phpcs:enable global $langs, $user, $conf; @@ -3325,7 +3325,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of payment methods * @@ -3340,7 +3340,7 @@ class Form * @param string $morecss Add more CSS on select tag * @return void */ - function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') + public function select_types_paiements($selected = '', $htmlname = 'paiementtype', $filtertype = '', $format = 0, $empty = 1, $noadmininfo = 0, $maxlength = 0, $active = 1, $morecss = '') { // phpcs:enable global $langs,$user; @@ -3394,7 +3394,7 @@ class Form * @param string $htmlname Nom de la zone select * @return string Code of HTML select to chose tax or not */ - function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') + public function selectPriceBaseType($selected = '', $htmlname = 'price_base_type') { global $langs; @@ -3432,7 +3432,7 @@ class Form * @param string $moreattrib To add more attribute on select * @return void */ - function selectShippingMethod($selected = '', $htmlname = 'shipping_method_id', $filtre = '', $useempty = 0, $moreattrib = '') + public function selectShippingMethod($selected = '', $htmlname = 'shipping_method_id', $filtre = '', $useempty = 0, $moreattrib = '') { global $langs, $conf, $user; @@ -3485,7 +3485,7 @@ class Form * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ - function formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) + public function formSelectShippingMethod($page, $selected = '', $htmlname = 'shipping_method_id', $addempty = 0) { global $langs, $db; @@ -3516,7 +3516,7 @@ class Form * * @return string HTML select */ - function selectSituationInvoices($selected = '', $socid = 0) + public function selectSituationInvoices($selected = '', $socid = 0) { global $langs; @@ -3570,7 +3570,7 @@ class Form * @param int $showempty Add a nempty line * @return string HTML select */ - function selectUnits($selected = '', $htmlname = 'units', $showempty = 0) + public function selectUnits($selected = '', $htmlname = 'units', $showempty = 0) { global $langs; @@ -3608,7 +3608,7 @@ class Form return $return; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select list of bank accounts * @@ -3621,7 +3621,7 @@ class Form * @param int $showcurrency Show currency in label * @return int <0 if error, Num of bank account found if OK (0, 1, 2, ...) */ - function select_comptes($selected = '', $htmlname = 'accountid', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0) + public function select_comptes($selected = '', $htmlname = 'accountid', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '', $showcurrency = 0) { // phpcs:enable global $langs, $conf; @@ -3693,7 +3693,7 @@ class Form * @param string $moreattrib To add more attribute on select * @return int <0 if error, Num of establishment found if OK (0, 1, 2, ...) */ - function selectEstablishments($selected = '', $htmlname = 'entity', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '') + public function selectEstablishments($selected = '', $htmlname = 'entity', $statut = 0, $filtre = '', $useempty = 0, $moreattrib = '') { // phpcs:enable global $langs, $conf; @@ -3760,7 +3760,7 @@ class Form * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ - function formSelectAccount($page, $selected = '', $htmlname = 'fk_account', $addempty = 0) + public function formSelectAccount($page, $selected = '', $htmlname = 'fk_account', $addempty = 0) { global $langs; if ($htmlname != "none") { @@ -3785,7 +3785,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of categories having choosed type * @@ -3798,7 +3798,7 @@ class Form * @return string * @see select_categories */ - function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $excludeafterid = 0, $outputmode = 0) + public function select_all_categories($type, $selected = '', $htmlname = "parent", $maxlength = 64, $excludeafterid = 0, $outputmode = 0) { // phpcs:enable global $conf, $langs; @@ -3872,7 +3872,7 @@ class Form return $output; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a confirmation HTML form or AJAX popup * @@ -3889,7 +3889,7 @@ class Form * @deprecated * @see formconfirm() */ - function form_confirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = "", $useajax = 0, $height = 170, $width = 500) + public function form_confirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = "", $useajax = 0, $height = 170, $width = 500) { // phpcs:enable dol_syslog(__METHOD__ . ': using form_confirm is deprecated. Use formconfim instead.', LOG_WARNING); @@ -3920,7 +3920,7 @@ class Form * @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a
section. * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form */ - function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 210, $width = 500, $disableformtag = 0) + public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 210, $width = 500, $disableformtag = 0) { global $langs,$conf; global $useglobalvars; @@ -4186,7 +4186,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a form to select a project * @@ -4200,7 +4200,7 @@ class Form * @param int $nooutput No print is done. String is returned. * @return string Return html content */ - function form_project($page, $socid, $selected = '', $htmlname = 'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0) + public function form_project($page, $socid, $selected = '', $htmlname = 'projectid', $discard_closed = 0, $maxlength = 20, $forcefocus = 0, $nooutput = 0) { // phpcs:enable global $langs; @@ -4246,7 +4246,7 @@ class Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a form to select payment conditions * @@ -4256,7 +4256,7 @@ class Form * @param int $addempty Add empty entry * @return void */ - function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0) + public function form_conditions_reglement($page, $selected = '', $htmlname = 'cond_reglement_id', $addempty = 0) { // phpcs:enable global $langs; @@ -4281,7 +4281,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a form to select a delivery delay * @@ -4291,7 +4291,7 @@ class Form * @param int $addempty Ajoute entree vide * @return void */ - function form_availability($page, $selected = '', $htmlname = 'availability', $addempty = 0) + public function form_availability($page, $selected = '', $htmlname = 'availability', $addempty = 0) { // phpcs:enable global $langs; @@ -4317,17 +4317,17 @@ class Form } /** - * Output HTML form to select list of input reason (events that triggered an object creation, like after sending an emailing, making an advert, ...) + * Output HTML form to select list of input reason (events that triggered an object creation, like after sending an emailing, making an advert, ...) * List found into table c_input_reason loaded by loadCacheInputReason * * @param string $page Page * @param string $selected Id condition pre-selectionne * @param string $htmlname Name of select html field - * @param int $addempty Add empty entry + * @param int $addempty Add empty entry * @return void - */ - function formInputReason($page, $selected = '', $htmlname = 'demandreason', $addempty = 0) - { + */ + public function formInputReason($page, $selected = '', $htmlname = 'demandreason', $addempty = 0) + { global $langs; if ($htmlname != "none") { @@ -4357,7 +4357,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a form + html select a date * @@ -4370,7 +4370,7 @@ class Form * @return string * @see selectDate */ - function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0) + public function form_date($page, $selected, $htmlname, $displayhour = 0, $displaymin = 0, $nooutput = 0) { // phpcs:enable global $langs; @@ -4400,7 +4400,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a select form to choose a user * @@ -4411,7 +4411,7 @@ class Form * @param array $include List of users id to include * @return void */ - function form_users($page, $selected = '', $htmlname = 'userid', $exclude = '', $include = '') + public function form_users($page, $selected = '', $htmlname = 'userid', $exclude = '', $include = '') { // phpcs:enable global $langs; @@ -4440,7 +4440,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form with payment mode * @@ -4452,7 +4452,7 @@ class Form * @param int $addempty 1=Add empty entry * @return void */ - function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0) + public function form_modes_reglement($page, $selected = '', $htmlname = 'mode_reglement_id', $filtertype = '', $active = 1, $addempty = 0) { // phpcs:enable global $langs; @@ -4477,7 +4477,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form with multicurrency code * @@ -4486,7 +4486,7 @@ class Form * @param string $htmlname Name of select html field * @return void */ - function form_multicurrency_code($page, $selected = '', $htmlname = 'multicurrency_code') + public function form_multicurrency_code($page, $selected = '', $htmlname = 'multicurrency_code') { // phpcs:enable global $langs; @@ -4506,7 +4506,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form with multicurrency rate * @@ -4516,7 +4516,7 @@ class Form * @param string $currency Currency code to explain the rate * @return void */ - function form_multicurrency_rate($page, $rate = '', $htmlname = 'multicurrency_tx', $currency = '') + public function form_multicurrency_rate($page, $rate = '', $htmlname = 'multicurrency_tx', $currency = '') { // phpcs:enable global $langs, $mysoc, $conf; @@ -4549,7 +4549,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a select box with available absolute discounts * @@ -4565,7 +4565,7 @@ class Form * @param int $discount_type 0 => customer discount, 1 => supplier discount * @return void */ - function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter = '', $maxvalue = 0, $more = '', $hidelist = 0, $discount_type = 0) + public function form_remise_dispo($page, $selected, $htmlname, $socid, $amount, $filter = '', $maxvalue = 0, $more = '', $hidelist = 0, $discount_type = 0) { // phpcs:enable global $conf,$langs; @@ -4646,18 +4646,18 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Show forms to select a contact - * - * @param string $page Page - * @param Societe $societe Filter on third party - * @param int $selected Id contact pre-selectionne - * @param string $htmlname Name of HTML select. If 'none', we just show contact link. - * @return void - */ - function form_contacts($page, $societe, $selected = '', $htmlname = 'contactid') - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Show forms to select a contact + * + * @param string $page Page + * @param Societe $societe Filter on third party + * @param int $selected Id contact pre-selectionne + * @param string $htmlname Name of HTML select. If 'none', we just show contact link. + * @return void + */ + public function form_contacts($page, $societe, $selected = '', $htmlname = 'contactid') + { // phpcs:enable global $langs, $conf; @@ -4692,7 +4692,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output html select to select thirdparty * @@ -4707,7 +4707,7 @@ class Form * @param int $nooutput No print output. Return it only. * @return void */ - function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0) + public function form_thirdparty($page, $selected = '', $htmlname = 'socid', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $events = array(), $nooutput = 0) { // phpcs:enable global $langs; @@ -4741,7 +4741,7 @@ class Form else print $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste des devises, dans la langue de l'utilisateur * @@ -4750,7 +4750,7 @@ class Form * @deprecated * @return void */ - function select_currency($selected = '', $htmlname = 'currency_id') + public function select_currency($selected = '', $htmlname = 'currency_id') { // phpcs:enable print $this->selectCurrency($selected, $htmlname); @@ -4763,7 +4763,7 @@ class Form * @param string $htmlname name of HTML select list * @return string */ - function selectCurrency($selected = '', $htmlname = 'currency_id') + public function selectCurrency($selected = '', $htmlname = 'currency_id') { global $conf,$langs,$user; @@ -4806,7 +4806,7 @@ class Form * @param integer $useempty 1=Add empty line * @return string */ - function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0) + public function selectMultiCurrency($selected = '', $htmlname = 'multicurrency_code', $useempty = 0) { global $db,$conf,$langs,$user; @@ -4854,14 +4854,14 @@ class Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load into the cache vat rates of a country + * Load into the cache vat rates of a country * - * @param string $country_code Country code with quotes ("'CA'", or "'CA,IN,...'") - * @return int Nb of loaded lines, 0 if already loaded, <0 if KO + * @param string $country_code Country code with quotes ("'CA'", or "'CA,IN,...'") + * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ - function load_cache_vatrates($country_code) + public function load_cache_vatrates($country_code) { // phpcs:enable global $langs; @@ -4921,7 +4921,7 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output an HTML select vat rate. * The name of this function should be selectVat. We keep bad name for compatibility purpose. @@ -4943,7 +4943,7 @@ class Form * @param int $mode 0=Use vat rate as key in combo list, 1=Add VAT code after vat rate into key, -1=Use id of vat line as key * @return string */ - function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false, $mode = 0) + public function load_tva($htmlname = 'tauxtva', $selectedrate = '', $societe_vendeuse = '', $societe_acheteuse = '', $idprod = 0, $info_bits = 0, $type = '', $options_only = false, $mode = 0) { // phpcs:enable global $langs,$conf,$mysoc; @@ -5118,7 +5118,7 @@ class Form } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a HTML widget to input a date or combo list for day, month, years and optionaly hours and minutes. * Fields are preselected with : @@ -5143,7 +5143,7 @@ class Form * @deprecated * @see form_date, select_month, select_year, select_dayofweek */ - function select_date($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '') + public function select_date($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $nooutput = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '') { // phpcs:enable $retstring = $this->selectDate($set_time, $prefix, $h, $m, $empty, $form_name, $d, $addnowlink, $disabled, $fullday, $addplusone, $adddateof); @@ -5176,7 +5176,7 @@ class Form * @return string Html for selectDate * @see form_date, select_month, select_year, select_dayofweek */ - function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '') + public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '') { global $conf,$langs; @@ -5525,9 +5525,9 @@ class Form return $retstring; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Function to show a form to select a duration on a page + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Function to show a form to select a duration on a page * * @param string $prefix Prefix for input fields * @param int $iSecond Default preselected duration (number of seconds or '') @@ -5539,7 +5539,7 @@ class Form * @param int $nooutput Do not output html string but return it * @return string|void */ - function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0) + public function select_duration($prefix, $iSecond = '', $disabled = 0, $typehour = 'select', $minunderhours = 0, $nooutput = 0) { // phpcs:enable global $langs; @@ -5627,7 +5627,7 @@ class Form * @return string Return HTML string * @see selectForFormsList select_thirdparty */ - function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0) + public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0) { global $conf, $user; @@ -5697,7 +5697,7 @@ class Form * @return string Return HTML string * @see selectForForms */ - function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0) + public function selectForFormsList($objecttmp, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $outputmode = 0) { global $conf, $langs, $user; @@ -5834,7 +5834,7 @@ class Form * @return string HTML select string. * @see multiselectarray, selectArrayAjax, selectArrayFilter */ - static function selectarray($htmlname, $array, $id = '', $show_empty = 0, $key_in_label = 0, $value_as_key = 0, $moreparam = '', $translate = 0, $maxlen = 0, $disabled = 0, $sort = '', $morecss = '', $addjscombo = 0, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0) + public static function selectarray($htmlname, $array, $id = '', $show_empty = 0, $key_in_label = 0, $value_as_key = 0, $moreparam = '', $translate = 0, $maxlen = 0, $disabled = 0, $sort = '', $morecss = '', $addjscombo = 0, $moreparamonempty = '', $disablebademail = 0, $nohtmlescape = 0) { global $conf, $langs; @@ -5944,7 +5944,7 @@ class Form * @return string HTML select string * @see selectArrayFilter, ajax_combobox in ajax.lib.php */ - static function selectArrayAjax($htmlname, $url, $id = '', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0) + public static function selectArrayAjax($htmlname, $url, $id = '', $moreparam = '', $moreparamtourl = '', $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0) { global $conf, $langs; global $delayedhtmlcontent; @@ -6028,11 +6028,11 @@ class Form return $out; } - /** - * Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter. - * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. - * - * @param string $htmlname Name of html select area + /** + * Return a HTML select string, built from an array of key+value, but content returned into select is defined into $array parameter. + * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. + * + * @param string $htmlname Name of html select area * @param string $array Array (key=>array('text'=>'A text', 'url'=>'An url'), ...) * @param string $id Preselected key * @param string $moreparam Add more parameters onto the select tag @@ -6043,10 +6043,10 @@ class Form * @param int $callurlonselect If set to 1, some code is added so an url return by the ajax is called when value is selected. * @param string $placeholder String to use as placeholder * @param integer $acceptdelayedhtml 1 = caller is requesting to have html js content not returned but saved into global $delayedhtmlcontent (so caller can show it at end of page to avoid flash FOUC effect) - * @return string HTML select string + * @return string HTML select string * @see selectArrayAjax, ajax_combobox in ajax.lib.php */ - static function selectArrayFilter($htmlname, $array, $id = '', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0) + public static function selectArrayFilter($htmlname, $array, $id = '', $moreparam = '', $disableFiltering = 0, $disabled = 0, $minimumInputLength = 1, $morecss = '', $callurlonselect = 0, $placeholder = '', $acceptdelayedhtml = 0) { global $conf, $langs; global $delayedhtmlcontent; @@ -6164,7 +6164,7 @@ class Form * @return string HTML multiselect string * @see selectarray, selectArrayAjax, selectArrayFilter */ - static function multiselectarray($htmlname, $array, $selected = array(), $key_in_label = 0, $value_as_key = 0, $morecss = '', $translate = 0, $width = 0, $moreattrib = '', $elemtype = '', $placeholder = '', $addjscombo = -1) + public static function multiselectarray($htmlname, $array, $selected = array(), $key_in_label = 0, $value_as_key = 0, $morecss = '', $translate = 0, $width = 0, $moreattrib = '', $elemtype = '', $placeholder = '', $addjscombo = -1) { global $conf, $langs; @@ -6274,7 +6274,7 @@ class Form * @return string HTML multiselect string * @see selectarray */ - static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage) + public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage) { global $conf,$langs,$user; @@ -6362,7 +6362,7 @@ class Form * @param int $rendermode 0=Default, use multiselect. 1=Emulate multiselect (recommended) * @return string String with categories */ - function showCategories($id, $type, $rendermode = 0) + public function showCategories($id, $type, $rendermode = 0) { global $db; @@ -6407,7 +6407,7 @@ class Form * @param array $compatibleImportElementsList Array of compatibles elements object for "import from" action * @return int <0 if KO, >=0 if OK */ - function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false) + public function showLinkedObjectBlock($object, $morehtmlright = '', $compatibleImportElementsList = false) { global $conf,$langs,$hookmanager; global $bc; @@ -6555,7 +6555,7 @@ class Form * @param array $excludelinksto Do not show links of this type, for exemple array('order') or array('supplier_order'). null or array() if no exclusion. * @return string <0 if KO, >0 if OK */ - function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array()) + public function showLinkToObjectBlock($object, $restrictlinksto = array(), $excludelinksto = array()) { global $conf, $langs, $hookmanager; global $bc; @@ -6728,7 +6728,7 @@ class Form * @param int $useempty 1=Add empty line * @return string See option */ - function selectyesno($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0) + public function selectyesno($htmlname, $value = '', $option = 0, $disabled = false, $useempty = 0) { global $langs; @@ -6760,7 +6760,7 @@ class Form - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of export templates * @@ -6770,7 +6770,7 @@ class Form * @param int $useempty Affiche valeur vide dans liste * @return void */ - function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0) + public function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0) { // phpcs:enable $sql = "SELECT rowid, label"; @@ -6828,7 +6828,7 @@ class Form * @param string $morehtmlright More html code to show after ref. * @return string Portion HTML with ref + navigation buttons */ - function showrefnav($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $morehtmlright = '') + public function showrefnav($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $morehtmlright = '') { global $langs,$conf,$hookmanager; @@ -6978,7 +6978,7 @@ class Form * @param int $width Width of photo * @return string HTML code to output barcode */ - function showbarcode(&$object, $width = 100) + public function showbarcode(&$object, $width = 100) { global $conf; @@ -7015,7 +7015,7 @@ class Form * @param string $forcecapture Force parameter capture on HTML input file element to ask a smartphone to allow to open camera to take photo. Auto if empty. * @return string HTML code to output photo */ - static function showphoto($modulepart, $object, $width = 100, $height = 0, $caneditfield = 0, $cssclass = 'photowithmargin', $imagesize = '', $addlinktofullsize = 1, $cache = 0, $forcecapture = '') + public static function showphoto($modulepart, $object, $width = 100, $height = 0, $caneditfield = 0, $cssclass = 'photowithmargin', $imagesize = '', $addlinktofullsize = 1, $cache = 0, $forcecapture = '') { global $conf,$langs; @@ -7158,7 +7158,7 @@ class Form return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list of groups * @@ -7174,7 +7174,7 @@ class Form * @return string * @see select_dolusers */ - function select_dolgroups($selected = '', $htmlname = 'groupid', $show_empty = 0, $exclude = '', $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $multiple = false) + public function select_dolgroups($selected = '', $htmlname = 'groupid', $show_empty = 0, $exclude = '', $disabled = 0, $include = '', $enableonly = '', $force_entity = '0', $multiple = false) { // phpcs:enable global $conf,$user,$langs; @@ -7270,7 +7270,7 @@ class Form * * @return string */ - function showFilterButtons() + public function showFilterButtons() { global $conf, $langs; @@ -7289,7 +7289,7 @@ class Form * @param int $calljsfunction 0=default. 1=call function initCheckForSelect() after changing status of checkboxes * @return string */ - function showCheckAddButtons($cssclass = 'checkforaction', $calljsfunction = 0) + public function showCheckAddButtons($cssclass = 'checkforaction', $calljsfunction = 0) { global $conf, $langs; @@ -7328,7 +7328,7 @@ class Form * @param int $calljsfunction 0=default. 1=call function initCheckForSelect() after changing status of checkboxes * @return string */ - function showFilterAndCheckAddButtons($addcheckuncheckall = 0, $cssclass = 'checkforaction', $calljsfunction = 0) + public function showFilterAndCheckAddButtons($addcheckuncheckall = 0, $cssclass = 'checkforaction', $calljsfunction = 0) { $out.=$this->showFilterButtons(); if ($addcheckuncheckall) @@ -7350,7 +7350,7 @@ class Form * @param array $params param to give * @return string */ - function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array()) + public function selectExpenseCategories($selected = '', $htmlname = 'fk_c_exp_tax_cat', $useempty = 0, $excludeid = array(), $target = '', $default_selected = 0, $params = array()) { global $db, $conf, $langs, $user; @@ -7439,7 +7439,7 @@ class Form * @param integer $useempty 1=Add empty line * @return string */ - function selectExpenseRanges($selected = '', $htmlname = 'fk_range', $useempty = 0) + public function selectExpenseRanges($selected = '', $htmlname = 'fk_range', $useempty = 0) { global $db,$conf,$langs; @@ -7476,7 +7476,7 @@ class Form * @param integer $useid 0=use 'code' as key, 1=use 'id' as key * @return string */ - function selectExpense($selected = '', $htmlname = 'fk_c_type_fees', $useempty = 0, $allchoice = 1, $useid = 0) + public function selectExpense($selected = '', $htmlname = 'fk_c_type_fees', $useempty = 0, $allchoice = 1, $useid = 0) { global $db,$langs; @@ -7505,6 +7505,6 @@ class Form dol_print_error($db); } - return $out; - } + return $out; + } } diff --git a/htdocs/core/class/html.formaccounting.class.php b/htdocs/core/class/html.formaccounting.class.php index a5b0a574c35..fa44c8dbcc9 100644 --- a/htdocs/core/class/html.formaccounting.class.php +++ b/htdocs/core/class/html.formaccounting.class.php @@ -55,7 +55,7 @@ class FormAccounting extends Form $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of journals with label by nature * @@ -70,7 +70,7 @@ class FormAccounting extends Form * @param int $disabledajaxcombo Disable ajax combo box. * @return string String with HTML select */ - function select_journal($selectid, $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '', $disabledajaxcombo = 0) + public function select_journal($selectid, $htmlname = 'journal', $nature = 0, $showempty = 0, $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '', $disabledajaxcombo = 0) { // phpcs:enable global $conf,$langs; @@ -138,7 +138,7 @@ class FormAccounting extends Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of accounting category. * Use mysoc->country_id or mysoc->country_code so they must be defined. @@ -151,7 +151,7 @@ class FormAccounting extends Form * @param int $allcountries All countries * @return void */ - function select_accounting_category($selected = '', $htmlname = 'account_category', $useempty = 0, $maxlen = 0, $help = 1, $allcountries = 0) + public function select_accounting_category($selected = '', $htmlname = 'account_category', $useempty = 0, $maxlen = 0, $help = 1, $allcountries = 0) { // phpcs:enable global $db,$langs,$user,$mysoc; @@ -220,7 +220,7 @@ class FormAccounting extends Form print $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select filter with date of transaction * @@ -228,7 +228,7 @@ class FormAccounting extends Form * @param string $selectedkey Value * @return string HTML edit field */ - function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') + public function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') { // phpcs:enable $options = array(); @@ -253,7 +253,7 @@ class FormAccounting extends Form return Form::selectarray($htmlname, $options, $selectedkey); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of accounts with label by chart of accounts * @@ -267,7 +267,7 @@ class FormAccounting extends Form * @param string $usecache Key to use to store result into a cache. Next call with same key will reuse the cache. * @return string String with HTML select */ - function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '') + public function select_account($selectid, $htmlname = 'account', $showempty = 0, $event = array(), $select_in = 0, $select_out = 0, $morecss = 'maxwidth300 maxwidthonsmartphone', $usecache = '') { // phpcs:enable global $conf, $langs; @@ -346,7 +346,7 @@ class FormAccounting extends Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of auxilary thirdparty accounts * @@ -356,7 +356,7 @@ class FormAccounting extends Form * @param string $morecss More css * @return string String with HTML select */ - function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth200') + public function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $morecss = 'maxwidth200') { // phpcs:enable @@ -429,7 +429,7 @@ class FormAccounting extends Form return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML combo list of years existing into book keepping * @@ -439,7 +439,7 @@ class FormAccounting extends Form * @param string $output_format (html/opton (for option html only)/array (to return options arrays * @return string/array */ - function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html') + public function selectyear_accountancy_bookkepping($selected = '', $htmlname = 'yearid', $useempty = 0, $output_format = 'html') { // phpcs:enable global $conf; diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index f8733420abb..6afe7552187 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -43,15 +43,15 @@ class FormActions /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show list of action status * @@ -64,7 +64,7 @@ class FormActions * @param string $morecss More css on select field * @return void */ - function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100') + public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100') { // phpcs:enable global $langs,$conf; @@ -168,7 +168,7 @@ class FormActions * @param string $morehtmlright More html text on right of title line * @return int <0 if KO, >=0 if OK */ - function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlright = '') + public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlright = '') { global $langs,$conf,$user; global $bc; @@ -179,7 +179,7 @@ class FormActions $sortorder='DESC,DESC'; $listofactions=ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max?($max+1):0)); - if (! is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); + if (! is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions'); $num = count($listofactions); if ($num || $forceshowtitle) @@ -314,7 +314,7 @@ class FormActions } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output html select list of type of event * @@ -327,7 +327,7 @@ class FormActions * @param int $nooutput 1=No output * @return string */ - function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0) + public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0) { // phpcs:enable global $langs,$user,$form,$conf; diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index 04235da29ed..1758480af8f 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -29,37 +29,37 @@ */ class FormAdmin { - var $db; - var $error; + public $db; + public $error; /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Return html select list with available languages (key='en_US', value='United States' for example) - * - * @param string $selected Language pre-selected - * @param string $htmlname Name of HTML select - * @param int $showauto Show 'auto' choice - * @param array $filter Array of keys to exclude in list - * @param string $showempty '1'=Add empty value or string to show - * @param int $showwarning Show a warning if language is not complete - * @param int $disabled Disable edit of select - * @param string $morecss Add more css styles - * @param int $showcode 1=Add language code into label at begining, 2=Add language code into label at end - * @param int $forcecombo Force to use combo box (so no ajax beautify effect) - * @return string Return HTML select string with list of languages + * Constructor + * + * @param DoliDB $db Database handler */ - function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0, $forcecombo = 0) + public function __construct($db) + { + $this->db = $db; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return html select list with available languages (key='en_US', value='United States' for example) + * + * @param string $selected Language pre-selected + * @param string $htmlname Name of HTML select + * @param int $showauto Show 'auto' choice + * @param array $filter Array of keys to exclude in list + * @param string $showempty '1'=Add empty value or string to show + * @param int $showwarning Show a warning if language is not complete + * @param int $disabled Disable edit of select + * @param string $morecss Add more css styles + * @param int $showcode 1=Add language code into label at begining, 2=Add language code into label at end + * @param int $forcecombo Force to use combo box (so no ajax beautify effect) + * @return string Return HTML select string with list of languages + */ + public function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0, $forcecombo = 0) { // phpcs:enable global $langs; @@ -121,8 +121,8 @@ class FormAdmin return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Return list of available menus (eldy_backoffice, ...) * * @param string $selected Preselected menu value @@ -131,7 +131,7 @@ class FormAdmin * @param string $moreattrib More attributes on html select tag * @return integer|null */ - function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib = '') + public function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib = '') { // phpcs:enable global $langs,$conf; @@ -212,7 +212,7 @@ class FormAdmin print ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return combo list of available menu families * @@ -221,13 +221,13 @@ class FormAdmin * @param string[] $dirmenuarray Directories to scan * @return void */ - function select_menu_families($selected, $htmlname, $dirmenuarray) + public function select_menu_families($selected, $htmlname, $dirmenuarray) { - // phpcs:enable - global $langs,$conf; + // phpcs:enable + global $langs,$conf; //$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php'); // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set - $expdevmenu=array(); + $expdevmenu=array(); $menuarray=array(); @@ -285,7 +285,7 @@ class FormAdmin } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select list of timezones * @@ -293,15 +293,15 @@ class FormAdmin * @param string $htmlname Nom de la zone select * @return void */ - function select_timezone($selected, $htmlname) + public function select_timezone($selected, $htmlname) { - // phpcs:enable - global $langs,$conf; + // phpcs:enable + global $langs,$conf; print ''; - } + foreach ($arraytz as $lib => $gmt) { + print ''."\n"; + } + print ''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return html select list with available languages (key='en_US', value='United States' for example) * * @param string $selected Paper format pre-selected * @param string $htmlname Name of HTML select field - * @param string $filter Value to filter on code - * @param int $showempty Add empty value - * @return string Return HTML output + * @param string $filter Value to filter on code + * @param int $showempty Add empty value + * @return string Return HTML output */ - function select_paper_format($selected = '', $htmlname = 'paperformat_id', $filter = 0, $showempty = 0) + public function select_paper_format($selected = '', $htmlname = 'paperformat_id', $filter = 0, $showempty = 0) { // phpcs:enable global $langs; diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index f7a7199ab03..c41ba24f17f 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -45,7 +45,7 @@ class FormBarCode * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -60,7 +60,7 @@ class FormBarCode * @param int $idForm Id du formulaire * @return string HTML select string */ - function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm = 'formbarcode') + public function setBarcodeEncoder($selected, $barcodelist, $code_id, $idForm = 'formbarcode') { global $conf, $langs; @@ -86,7 +86,7 @@ class FormBarCode { $disable = 'disabled'; } - + if (!empty($conf->use_javascript_ajax)) { $select_encoder = ''; @@ -94,7 +94,7 @@ class FormBarCode $select_encoder.= ''; $select_encoder.= ''; } - + $selectname=(!empty($conf->use_javascript_ajax)?'coder':'coder'.$code_id); $select_encoder.= ''; - + if (!empty($conf->use_javascript_ajax)) { $select_encoder.= ''; @@ -113,7 +113,7 @@ class FormBarCode return $select_encoder; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Print form to select type of barcode * @@ -123,7 +123,7 @@ class FormBarCode * @return void * @deprecated */ - function select_barcode_type($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) + public function select_barcode_type($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) { // phpcs:enable print $this->selectBarcodeType($selected, $htmlname, $useempty); @@ -137,7 +137,7 @@ class FormBarCode * @param int $useempty Display empty value in select * @return string */ - function selectBarcodeType($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) + public function selectBarcodeType($selected = '', $htmlname = 'barcodetype_id', $useempty = 0) { global $langs, $conf; @@ -183,7 +183,7 @@ class FormBarCode return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form to select type of barcode * @@ -193,7 +193,7 @@ class FormBarCode * @return void * @deprecated */ - function form_barcode_type($page, $selected = '', $htmlname = 'barcodetype_id') + public function form_barcode_type($page, $selected = '', $htmlname = 'barcodetype_id') { // phpcs:enable print $this->formBarcodeType($page, $selected, $htmlname); @@ -207,7 +207,7 @@ class FormBarCode * @param string $htmlname Nom du formulaire select * @return string */ - function formBarcodeType($page, $selected = '', $htmlname = 'barcodetype_id') + public function formBarcodeType($page, $selected = '', $htmlname = 'barcodetype_id') { global $langs, $conf; $out = ''; diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index f92bee4519f..65f92c86948 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -46,13 +46,13 @@ class FormCompany * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of labels (translated) of third parties type * @@ -60,7 +60,7 @@ class FormCompany * @param string $filter Add a SQL filter to select * @return array Array of types */ - function typent_array($mode = 0, $filter = '') + public function typent_array($mode = 0, $filter = '') { // phpcs:enable global $langs,$mysoc; @@ -95,7 +95,7 @@ class FormCompany return $effs; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) * @@ -103,7 +103,7 @@ class FormCompany * @param string $filter Add a SQL filter to select * @return array Array of types d'effectifs */ - function effectif_array($mode = 0, $filter = '') + public function effectif_array($mode = 0, $filter = '') { // phpcs:enable $effs = array(); @@ -135,7 +135,7 @@ class FormCompany } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Affiche formulaire de selection des modes de reglement * @@ -145,7 +145,7 @@ class FormCompany * @param int $empty Add empty value in list * @return void */ - function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) + public function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0) { // phpcs:enable global $user, $langs; @@ -186,7 +186,7 @@ class FormCompany print ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. * In the case of an all-country list, the display breaks on the country. @@ -198,13 +198,13 @@ class FormCompany * @param string $htmlname Id of department * @return void */ - function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') + public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id') { // phpcs:enable print $this->select_state($selected, $country_codeid, $htmlname); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the drop-down list of departments/provinces/cantons for all countries or for a given country. * In the case of an all-country list, the display breaks on the country. @@ -217,7 +217,7 @@ class FormCompany * @return string String with HTML select * @see select_country */ - function select_state($selected = '', $country_codeid = 0, $htmlname = 'state_id') + public function select_state($selected = '', $country_codeid = 0, $htmlname = 'state_id') { // phpcs:enable global $conf,$langs,$user; @@ -319,7 +319,7 @@ class FormCompany } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste deroulante des regions actives dont le pays est actif * La cle de la liste est le code (il peut y avoir plusieurs entree pour @@ -330,7 +330,7 @@ class FormCompany * @param string $htmlname Name of HTML select field * @return void */ - function select_region($selected = '', $htmlname = 'region_id') + public function select_region($selected = '', $htmlname = 'region_id') { // phpcs:enable global $conf,$langs; @@ -387,7 +387,7 @@ class FormCompany } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return combo list with people title * @@ -396,7 +396,7 @@ class FormCompany * @param string $morecss Add more css on SELECT element * @return string String with HTML select */ - function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth100') + public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth100') { // phpcs:enable global $conf,$langs,$user; @@ -445,7 +445,7 @@ class FormCompany return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays. @@ -457,13 +457,13 @@ class FormCompany * @deprecated Use print xxx->select_juridicalstatus instead * @see select_juridicalstatus() */ - function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '') + public function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '') { // phpcs:enable print $this->select_juridicalstatus($selected, $country_codeid, $filter); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays @@ -474,7 +474,7 @@ class FormCompany * @param string $htmlname HTML name of select * @return string String with HTML select */ - function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code') + public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code') { // phpcs:enable global $conf,$langs,$user; @@ -579,7 +579,7 @@ class FormCompany * @param string $morecss More CSS on select component * @return int The selected third party ID */ - function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') + public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '') { global $conf, $langs; @@ -738,7 +738,7 @@ class FormCompany * @param string $morecss Add more css to select component * @return void */ - function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '') + public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '') { global $user, $langs; @@ -762,7 +762,7 @@ class FormCompany } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a select list with zip codes and their town * @@ -775,7 +775,7 @@ class FormCompany * @param string $morecss More css * @return string */ - function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '') + public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '') { // phpcs:enable global $conf; @@ -795,7 +795,7 @@ class FormCompany return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...) * @@ -806,7 +806,7 @@ class FormCompany * @param string $morecss More css * @return string HTML string with prof id */ - function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') + public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent') { // phpcs:enable global $conf,$langs; @@ -847,7 +847,7 @@ class FormCompany return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select with localtax values for thirdparties * @@ -856,7 +856,7 @@ class FormCompany * @param string $htmlname HTML select name * @return void */ - function select_localtax($local, $selected, $htmlname) + public function select_localtax($local, $selected, $htmlname) { // phpcs:enable $tax=get_localtax_by_third($local); @@ -900,7 +900,7 @@ class FormCompany * @param string $morecss More css * @return string HTML string */ - function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '') + public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '') { global $conf,$langs; diff --git a/htdocs/core/class/html.formcontract.class.php b/htdocs/core/class/html.formcontract.class.php index d7cf1cd62d9..195f09663b3 100644 --- a/htdocs/core/class/html.formcontract.class.php +++ b/htdocs/core/class/html.formcontract.class.php @@ -49,7 +49,7 @@ class FormContract } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a combo list with contracts qualified for a third party * @@ -60,8 +60,8 @@ class FormContract * @param int $showempty Show empty line * @return int Nbr of project if OK, <0 if KO */ - function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) - { + public function select_contract($socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) + { // phpcs:enable global $db,$user,$conf,$langs; @@ -164,21 +164,21 @@ class FormContract dol_print_error($db); return -1; } - } + } - /** - * Show a form to select a contract - * - * @param int $page Page - * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) - * @param int $selected Id contract preselected - * @param string $htmlname Nom de la zone html - * @param int $maxlength Maximum length of label - * @param int $showempty Show empty line - * @return int Nbr of project if OK, <0 if KO - */ - function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) - { + /** + * Show a form to select a contract + * + * @param int $page Page + * @param int $socid Id third party (-1=all, 0=only contracts not linked to a third party, id=contracts not linked or linked to third party id) + * @param int $selected Id contract preselected + * @param string $htmlname Nom de la zone html + * @param int $maxlength Maximum length of label + * @param int $showempty Show empty line + * @return int Nbr of project if OK, <0 if KO + */ + public function formSelectContract($page, $socid = -1, $selected = '', $htmlname = 'contrattid', $maxlength = 16, $showempty = 1) + { global $langs; print "\n"; diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php index 13cf88e9aa2..0611d553af1 100644 --- a/htdocs/core/class/html.formcron.class.php +++ b/htdocs/core/class/html.formcron.class.php @@ -18,7 +18,7 @@ */ /** - * \file core/class/html.formcron.class.php + * \file htdocs/core/class/html.formcron.class.php * \brief Fichier de la classe des fonctions predefinie de composants html cron */ @@ -28,75 +28,75 @@ */ class FormCron extends Form { - /** + /** * @var DoliDB Database handler. */ public $db; - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Display On Off selector - * - * @param string $htmlname Html control name - * @param integer $selected selected value - * @param integer $readonly Select is read only or not - * @return string HTML select field - */ - function select_typejob($htmlname, $selected = 0, $readonly = 0) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Display On Off selector + * + * @param string $htmlname Html control name + * @param integer $selected selected value + * @param integer $readonly Select is read only or not + * @return string HTML select field + */ + public function select_typejob($htmlname, $selected = 0, $readonly = 0) + { // phpcs:enable - global $langs; + global $langs; - $langs->load('cron@cron'); - if (!empty($readonly)) { - if ($selected=='command') { - $out= $langs->trans('CronType_command'); - $out.=''; - } elseif ($selected=='method') { - $out= $langs->trans('CronType_method'); - $out.=''; - } - }else { + $langs->load('cron@cron'); + if (!empty($readonly)) { + if ($selected=='command') { + $out= $langs->trans('CronType_command'); + $out.=''; + } elseif ($selected=='method') { + $out= $langs->trans('CronType_method'); + $out.=''; + } + } else { - $out=''; - if ($selected=='command') { - $selected_attr=' selected '; - } else { - $selected_attr=''; - } - $out.= ''; + if ($selected=='command') { + $selected_attr=' selected '; + } else { + $selected_attr=''; + } + $out.= ''; - if ($selected=='method') { - $selected_attr=' selected '; - } else { - $selected_attr=''; - } - $out.= ''; + if ($selected=='method') { + $selected_attr=' selected '; + } else { + $selected_attr=''; + } + $out.= ''; - $out.=''; - } + $out.=''; + } - return $out; - } + return $out; + } } diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 2243b4e06c1..65364e0a343 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -51,14 +51,14 @@ class FormFile * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numoffiles=0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show form to upload a new file. * @@ -70,7 +70,7 @@ class FormFile * @param int $size Length of input file area. Deprecated. * @param Object $object Object to use (when attachment is done on an element) * @param string $options Add an option column - * @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). + * @param integer $useajax Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option). * Deprecated 2 should never be used and if 1 is used, option should no be enabled. * @param string $savingdocmask Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__' * @param integer $linkfiles 1=Also add form to link files, 0=Do not show form to link files @@ -79,7 +79,7 @@ class FormFile * @param string $sectiondir If upload must be done inside a particular directory (is sectiondir defined, sectionid must not be) * @return int <0 if KO, >0 if OK */ - function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '') + public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '') { // phpcs:enable global $conf,$langs, $hookmanager; @@ -183,11 +183,11 @@ class FormFile else { $rename='checked'; } - + $out .= '
'; if (! empty($options)) $out .= ''; $out .= ''; $out .= ''; } @@ -247,7 +247,7 @@ class FormFile } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show the box with list of available documents for object * @@ -270,7 +270,7 @@ class FormFile * @return int <0 if KO, number of shown files if OK * @deprecated Use print xxx->showdocuments() instead. */ - function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '') + public function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '') { // phpcs:enable $this->numoffiles=0; @@ -303,7 +303,7 @@ class FormFile * @param int $hideifempty Hide section of generated files if there is no file * @return string Output string with HTML array of documents (might be empty string) */ - function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0) + public function showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '', $morepicto = '', $object = null, $hideifempty = 0) { // Deprecation warning if (! empty($iconPDF)) { @@ -902,7 +902,7 @@ class FormFile * @param string $filter Filter filenames on this regex string (Example: '\.pdf$') * @return string Output string with HTML link of documents (might be empty string). This also fill the array ->infofiles */ - function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '') + public function getDocumentsLink($modulepart, $modulesubdir, $filedir, $filter = '') { global $conf, $langs; @@ -1005,7 +1005,7 @@ class FormFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show list of documents in $filearray (may be they are all in same directory but may not) * This also sync database if $upload_dir is defined. @@ -1037,7 +1037,7 @@ class FormFile * @return int <0 if KO, nb of files shown if OK * @see list_of_autoecmfiles */ - function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0) + public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0) { // phpcs:enable global $user, $conf, $langs, $hookmanager; @@ -1406,7 +1406,7 @@ class FormFile } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show list of documents in a directory * @@ -1425,7 +1425,7 @@ class FormFile * @return int <0 if KO, nb of files shown if OK * @see list_of_documents */ - function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permtodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0) + public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permtodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0) { // phpcs:enable global $user, $conf, $langs, $form; @@ -1571,7 +1571,7 @@ class FormFile { preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref=(isset($reg[1])?$reg[1]:''); } - + if (! $id && ! $ref) continue; $found=0; if (! empty($this->cache_objects[$modulepart.'_'.$id.'_'.$ref])) diff --git a/htdocs/core/class/html.formintervention.class.php b/htdocs/core/class/html.formintervention.class.php index 3d0a84b074c..83405f9725b 100644 --- a/htdocs/core/class/html.formintervention.class.php +++ b/htdocs/core/class/html.formintervention.class.php @@ -49,7 +49,7 @@ class FormIntervention } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show a combo list with contracts qualified for a third party * @@ -60,7 +60,7 @@ class FormIntervention * @param int $showempty Show empty line * @return int Nbre of project if OK, <0 if KO */ - function select_interventions($socid = -1, $selected = '', $htmlname = 'interventionid', $maxlength = 16, $showempty = 1) + public function select_interventions($socid = -1, $selected = '', $htmlname = 'interventionid', $maxlength = 16, $showempty = 1) { // phpcs:enable global $db,$user,$conf,$langs; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 1159c74dc8d..b643f1dfcb9 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -121,7 +121,7 @@ class FormMail extends Form * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -151,13 +151,13 @@ class FormMail extends Form $this->withfckeditor=-1; // -1 = Auto } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Clear list of attached files in send mail form (also stored in session) * * @return void */ - function clear_attached_files() + public function clear_attached_files() { // phpcs:enable global $conf,$user; @@ -174,7 +174,7 @@ class FormMail extends Form unset($_SESSION["listofmimes".$keytoavoidconflict]); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a file into the list of attached files (stored in SECTION array) * @@ -183,7 +183,7 @@ class FormMail extends Form * @param string $type Mime type (can be dol_mimetype($file)) * @return void */ - function add_attached_files($path, $file = '', $type = '') + public function add_attached_files($path, $file = '', $type = '') { // phpcs:enable $listofpaths=array(); @@ -208,14 +208,14 @@ class FormMail extends Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a file from the list of attached files (stored in SECTION array) * * @param string $keytodelete Key in file array (0, 1, 2, ...) * @return void */ - function remove_attached_files($keytodelete) + public function remove_attached_files($keytodelete) { // phpcs:enable $listofpaths=array(); @@ -238,13 +238,13 @@ class FormMail extends Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of attached files (stored in SECTION array) * * @return array array('paths'=> ,'names'=>, 'mimes'=> ) */ - function get_attached_files() + public function get_attached_files() { // phpcs:enable $listofpaths=array(); @@ -258,7 +258,7 @@ class FormMail extends Form return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files @@ -268,13 +268,13 @@ class FormMail extends Form * @param string $removefileaction Name of action when removing file attachments * @return void */ - function show_form($addfileaction = 'addfile', $removefileaction = 'removefile') + public function show_form($addfileaction = 'addfile', $removefileaction = 'removefile') { // phpcs:enable print $this->get_form($addfileaction, $removefileaction); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get the form to input an email * this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files @@ -285,7 +285,7 @@ class FormMail extends Form * @param string $removefileaction Name of action when removing file attachments * @return string Form to show */ - function get_form($addfileaction = 'addfile', $removefileaction = 'removefile') + public function get_form($addfileaction = 'addfile', $removefileaction = 'removefile') { // phpcs:enable global $conf, $langs, $user, $hookmanager, $form; @@ -1130,24 +1130,23 @@ class FormMail extends Form } /** - * Return templates of email with type = $type_template or type = 'all'. - * This search into table c_email_templates. Used by the get_form function. + * Return templates of email with type = $type_template or type = 'all'. + * This search into table c_email_templates. Used by the get_form function. * - * @param DoliDB $db Database handler - * @param string $type_template Get message for model/type=$type_template, type='all' also included. - * @param string $user Get template public or limited to this user - * @param Translate $outputlangs Output lang object - * @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found) - * @param int $active 1=Only active template, 0=Only disabled, -1=All - * @param string $label Label of template - * @return ModelMail|integer One instance of ModelMail or -1 if error + * @param DoliDB $db Database handler + * @param string $type_template Get message for model/type=$type_template, type='all' also included. + * @param string $user Get template public or limited to this user + * @param Translate $outputlangs Output lang object + * @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found) + * @param int $active 1=Only active template, 0=Only disabled, -1=All + * @param string $label Label of template + * @return ModelMail|integer One instance of ModelMail or -1 if error */ public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '') { - $ret = new ModelMail(); + $ret = new ModelMail(); - if ($id == -2 && empty($label)) - { + if ($id == -2 && empty($label)) { $this->error = 'LabelIsMandatoryWhenIdIs-2'; return -1; } @@ -1320,7 +1319,7 @@ class FormMail extends Form * @return void * @see getCommonSubstitutionArray */ - function setSubstitFromObject($object, $outputlangs) + public function setSubstitFromObject($object, $outputlangs) { global $conf, $user; @@ -1377,7 +1376,7 @@ class FormMail extends Form * @param Object $object Object if applicable * @return array Array of substitution values for emails. */ - static function getAvailableSubstitKey($mode = 'formemail', $object = null) + public static function getAvailableSubstitKey($mode = 'formemail', $object = null) { global $conf, $langs; diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index 95c2c057b40..caf4bf8a504 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -27,33 +27,33 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; */ class FormMailing extends Form { - /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); - /** - * Output a select with destinaries status - * - * @param string $selectedid The selected id - * @param string $htmlname Name of controm - * @param integer $show_empty Show empty option - * @return string HTML select - */ + /** + * Output a select with destinaries status + * + * @param string $selectedid The selected id + * @param string $htmlname Name of controm + * @param integer $show_empty Show empty option + * @return string HTML select + */ public function selectDestinariesStatus($selectedid = '', $htmlname = 'dest_status', $show_empty = 0) { - global $langs; - $langs->load("mails"); + global $langs; + $langs->load("mails"); - require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; - $mailing = new Mailing($this->db); + require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; + $mailing = new Mailing($this->db); - $options = array(); + $options = array(); - if ($show_empty) { - $options[-2] = ''; // Note -1 is used for error - } + if ($show_empty) { + $options[-2] = ''; // Note -1 is used for error + } $options = $options + $mailing->statut_dest; diff --git a/htdocs/core/class/html.formmargin.class.php b/htdocs/core/class/html.formmargin.class.php index 5aecb6efc71..f022d2c3791 100644 --- a/htdocs/core/class/html.formmargin.class.php +++ b/htdocs/core/class/html.formmargin.class.php @@ -44,7 +44,7 @@ class FormMargin * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -59,7 +59,7 @@ class FormMargin * @param boolean $force_price True of not * @return array Array with info */ - function getMarginInfosArray($object, $force_price = false) + public function getMarginInfosArray($object, $force_price = false) { global $conf, $db; @@ -191,7 +191,7 @@ class FormMargin * @param boolean $force_price Force price * @return void */ - function displayMarginInfos($object, $force_price = false) + public function displayMarginInfos($object, $force_price = false) { global $langs, $conf, $user; diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index 9783d6f50a8..9c1d847f16e 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -31,13 +31,13 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; class FormOrder extends Form { - /** - * Return combo list of differents status of a orders + /** + * Return combo list of differents status of a orders * - * @param string $selected Preselected value - * @param int $short Use short labels - * @param string $hmlname Name of HTML select element - * @return void + * @param string $selected Preselected value + * @param int $short Use short labels + * @param string $hmlname Name of HTML select element + * @return void */ public function selectSupplierOrderStatus($selected = '', $short = 0, $hmlname = 'order_status') { diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 97beb2464ad..1bb59077bec 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -50,13 +50,13 @@ class FormOther * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return HTML select list of export models * @@ -67,7 +67,7 @@ class FormOther * @param int $fk_user Utilisateur créant le modèle * @return void */ - function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0, $fk_user = null) + public function select_export_model($selected = '', $htmlname = 'exportmodelid', $type = '', $useempty = 0, $fk_user = null) { // phpcs:enable $sql = "SELECT rowid, label"; @@ -109,7 +109,7 @@ class FormOther } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of export models * @@ -119,7 +119,7 @@ class FormOther * @param int $useempty Affiche valeur vide dans liste * @return void */ - function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0) + public function select_import_model($selected = '', $htmlname = 'importmodelid', $type = '', $useempty = 0) { // phpcs:enable $sql = "SELECT rowid, label"; @@ -160,7 +160,7 @@ class FormOther } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of ecotaxes with label * @@ -168,7 +168,7 @@ class FormOther * @param string $htmlname Name of combo list * @return integer */ - function select_ecotaxes($selected = '', $htmlname = 'ecotaxe_id') + public function select_ecotaxes($selected = '', $htmlname = 'ecotaxe_id') { // phpcs:enable global $langs; @@ -218,7 +218,7 @@ class FormOther } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of revenue stamp for country * @@ -227,7 +227,7 @@ class FormOther * @param string $country_code Country Code * @return string HTML select list */ - function select_revenue_stamp($selected = '', $htmlname = 'revenuestamp', $country_code = '') + public function select_revenue_stamp($selected = '', $htmlname = 'revenuestamp', $country_code = '') { // phpcs:enable global $langs; @@ -277,7 +277,7 @@ class FormOther } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a HTML select list to select a percent * @@ -290,7 +290,7 @@ class FormOther * @param int $showempty Add also an empty line * @return string HTML select string */ - function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0) + public function select_percent($selected = 0, $htmlname = 'percent', $disabled = 0, $increment = 5, $start = 0, $end = 100, $showempty = 0) { // phpcs:enable $return = '"; - } - else - { + } else { print $langs->trans("DictionaryEmpty"); } } diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php index 765f7d00d79..9ef1098901c 100644 --- a/htdocs/core/class/html.formprojet.class.php +++ b/htdocs/core/class/html.formprojet.class.php @@ -45,12 +45,12 @@ class FormProjets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a combo list with projects qualified for a third party / user * @@ -71,8 +71,8 @@ class FormProjets * @param int $htmlid Html id to use instead of htmlname * @return string Return html content */ - function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '') - { + public function select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '') + { // phpcs:enable global $langs,$conf,$form; @@ -90,13 +90,13 @@ class FormProjets $selected_input_value=$project->ref; } $urloption='socid='.$socid.'&htmlname='.$htmlname.'&discardclosed='.$discard_closed; -$out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array( -// 'update' => array( -// 'projectid' => 'id' -// ) - )); + $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projects.php', $urloption, $conf->global->PROJECT_USE_SEARCH_TO_SELECT, 0, array( + // 'update' => array( + // 'projectid' => 'id' + // ) + )); - $out.=''; + $out.=''; } else { @@ -119,7 +119,7 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec else return $out; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns an array with projects qualified for a third party * @@ -140,8 +140,8 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec * @param string $morecss More CSS * @return int Nb of project if OK, <0 if KO */ - function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500') - { + public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500') + { // phpcs:enable global $user,$conf,$langs; @@ -303,11 +303,11 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec } /** - * Output a combo list with tasks qualified for a third party + * Output a combo list with tasks qualified for a third party * - * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) - * @param int $selected Id task preselected - * @param string $htmlname Name of HTML select + * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) + * @param int $selected Id task preselected + * @param string $htmlname Name of HTML select * @param int $maxlength Maximum length of label * @param int $option_only Return only html options lines without the select tag * @param string $show_empty Add an empty line ('1' or string to show for empty line) @@ -320,7 +320,7 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec * @param User $usertofilter User object to use for filtering * @return int Nbr of project if OK, <0 if KO */ - function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) + public function selectTasks($socid = -1, $selected = '', $htmlname = 'taskid', $maxlength = 24, $option_only = 0, $show_empty = '1', $discard_closed = 0, $forcefocus = 0, $disabled = 0, $morecss = 'maxwidth500', $projectsListId = '', $showproject = 'all', $usertofilter = null) { global $user,$conf,$langs; @@ -477,7 +477,7 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build a HTML select list of element of same thirdparty to suggest to link them to project * @@ -488,7 +488,7 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec * @param string $projectkey Equivalent key to fk_projet for actual table_element * @return int|string The HTML select list of element or '' if nothing or -1 if KO */ - function select_element($table_element, $socid = 0, $morecss = '', $limitonstatus = -2, $projectkey = "fk_projet") + public function select_element($table_element, $socid = 0, $morecss = '', $limitonstatus = -2, $projectkey = "fk_projet") { // phpcs:enable global $conf, $langs; @@ -618,7 +618,7 @@ $out.=ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/projet/ajax/projec * @param string $morecss Add more css * @return int|string The HTML select list of element or '' if nothing or -1 if KO */ - function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '') + public function selectOpportunityStatus($htmlname, $preselected = '-1', $showempty = 1, $useshortlabel = 0, $showallnone = 0, $showpercent = 0, $morecss = '') { global $conf, $langs; diff --git a/htdocs/core/class/html.formpropal.class.php b/htdocs/core/class/html.formpropal.class.php index 1f4fad0829c..e9f78638742 100644 --- a/htdocs/core/class/html.formpropal.class.php +++ b/htdocs/core/class/html.formpropal.class.php @@ -27,26 +27,26 @@ */ class FormPropal { - /** + /** * @var DoliDB Database handler. */ public $db; - - /** - * @var string Error code (or message) - */ - public $error=''; + + /** + * @var string Error code (or message) + */ + public $error=''; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } /** * Return combo list of differents status of a proposal @@ -60,14 +60,13 @@ class FormPropal * @param string $htmlname Name of select field * @return void */ - function selectProposalStatus($selected = '', $short = 0, $excludedraft = 0, $showempty = 1, $mode = 'customer', $htmlname = 'propal_statut') + public function selectProposalStatus($selected = '', $short = 0, $excludedraft = 0, $showempty = 1, $mode = 'customer', $htmlname = 'propal_statut') { global $langs; $prefix=''; $listofstatus=array(); - if ($mode == 'supplier') - { + if ($mode == 'supplier') { $prefix='SupplierProposalStatus'; $langs->load("supplier_proposal"); @@ -78,9 +77,7 @@ class FormPropal 3=>array('id'=>3, 'code'=>'PR_NOTSIGNED'), 4=>array('id'=>4, 'code'=>'PR_CLOSED') ); - } - else - { + } else { $prefix="PropalStatus"; $sql = "SELECT id, code, label, active FROM ".MAIN_DB_PREFIX."c_propalst"; @@ -114,11 +111,11 @@ class FormPropal { if ($excludedraft) { - if ($obj['code'] == 'Draft' || $obj['code'] == 'PR_DRAFT') - { - $i++; - continue; - } + if ($obj['code'] == 'Draft' || $obj['code'] == 'PR_DRAFT') + { + $i++; + continue; + } } if ($selected != '' && $selected == $obj['id']) { @@ -134,7 +131,7 @@ class FormPropal print $langs->trans($prefix.$key.($short?'Short':'')); } else - { + { $conv_to_new_code=array('PR_DRAFT'=>'Draft','PR_OPEN'=>'Validated','PR_CLOSED'=>'Closed','PR_SIGNED'=>'Signed','PR_NOTSIGNED'=>'NotSigned','PR_FAC'=>'Billed'); if (! empty($conv_to_new_code[$obj['code']])) $key=$conv_to_new_code[$obj['code']]; diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index df6e09da59e..5269f4fdcad 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -76,7 +76,7 @@ class FormSms * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -92,7 +92,7 @@ class FormSms $this->withbodyreadonly=0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show the form to input an sms. * @@ -100,7 +100,7 @@ class FormSms * @param int $showform Show form tags and submit button (recommanded is to use with value 0) * @return void */ - function show_form($morecss = 'titlefield', $showform = 1) + public function show_form($morecss = 'titlefield', $showform = 1) { // phpcs:enable global $conf, $langs, $user, $form; diff --git a/htdocs/core/class/html.formsocialcontrib.class.php b/htdocs/core/class/html.formsocialcontrib.class.php index c797fb77dbb..74a511ebdd5 100644 --- a/htdocs/core/class/html.formsocialcontrib.class.php +++ b/htdocs/core/class/html.formsocialcontrib.class.php @@ -48,7 +48,7 @@ class FormSocialContrib $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of social contributions. * Use mysoc->country_id or mysoc->country_code so they must be defined. @@ -61,7 +61,7 @@ class FormSocialContrib * @param string $morecss Add more CSS on select * @return void */ - function select_type_socialcontrib($selected = '', $htmlname = 'actioncode', $useempty = 0, $maxlen = 40, $help = 1, $morecss = 'minwidth300') + public function select_type_socialcontrib($selected = '', $htmlname = 'actioncode', $useempty = 0, $maxlen = 40, $help = 1, $morecss = 'minwidth300') { // phpcs:enable global $conf,$db,$langs,$user,$mysoc; diff --git a/htdocs/core/class/html.formwebsite.class.php b/htdocs/core/class/html.formwebsite.class.php index 9ab430733e0..3cefeaef99c 100644 --- a/htdocs/core/class/html.formwebsite.class.php +++ b/htdocs/core/class/html.formwebsite.class.php @@ -40,7 +40,7 @@ class FormWebsite * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -54,9 +54,9 @@ class FormWebsite * @param int $useempty Show empty value or not * @return string Html component */ - function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0) + public function selectWebsite($selected = '', $htmlname = 'exportmodelid', $useempty = 0) { - $out=''; + $out=''; $sql = "SELECT rowid, ref"; $sql.= " FROM ".MAIN_DB_PREFIX."website"; @@ -107,16 +107,16 @@ class FormWebsite * @param string $moreattrib More attributes on HTML select tag * @return void */ - function selectTypeOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') + public function selectTypeOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') { - global $langs, $conf, $user; + global $langs, $conf, $user; - $langs->load("admin"); + $langs->load("admin"); - $sql = "SELECT rowid, code, label, entity"; - $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; - $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; - $sql.= " ORDER BY label"; + $sql = "SELECT rowid, code, label, entity"; + $sql.= " FROM ".MAIN_DB_PREFIX.'c_type_container'; + $sql.= " WHERE active = 1 AND entity IN (".getEntity('c_type_container').")"; + $sql.= " ORDER BY label"; dol_syslog(get_class($this)."::selectTypeOfContainer", LOG_DEBUG); $result = $this->db->query($sql); @@ -170,7 +170,7 @@ class FormWebsite * @param string $moreattrib More attributes on HTML select tag * @return void */ - function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') + public function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '') { global $langs, $conf, $user; diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index ddee9453e08..1138e3a69ad 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -27,15 +27,15 @@ */ class InfoBox { - /** - * Name of positions 0=Home, 1=... - * - * @return string[] Array with list of zones - */ - static function getListOfPagesForBoxes() - { - return array(0=>'Home'); - } + /** + * Name of positions 0=Home, 1=... + * + * @return string[] Array with list of zones + */ + public static function getListOfPagesForBoxes() + { + return array(0=>'Home'); + } /** * Return array of boxes qualified for area and user @@ -48,7 +48,7 @@ class InfoBox * @param int $includehidden Include also hidden boxes * @return array Array of boxes */ - static function listBoxes($db, $mode, $zone, $user = null, $excludelist = array(), $includehidden = 1) + public static function listBoxes($db, $mode, $zone, $user = null, $excludelist = array(), $includehidden = 1) { global $conf; @@ -68,10 +68,10 @@ class InfoBox $sql.= " ORDER BY b.box_order"; } else // available - { + { $sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."boxes_def as d"; - $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; + $sql.= " WHERE d.entity IN (0,".$conf->entity.")"; } dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')."", LOG_DEBUG); @@ -97,17 +97,17 @@ class InfoBox { $boxname=preg_replace('/\.php$/i', '', $obj->file); $relsourcefile = "/core/boxes/".$boxname.".php"; - } + } - //print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'
'; + //print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'
'; - // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then + // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then // the "enabled" condition for modules forbidden for external users and the depends condition can be done. // Goal is to avoid making a "new" done for each boxes returned by select. dol_include_once($relsourcefile); if (class_exists($boxname)) { - $box=new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. + $box=new $boxname($db, $obj->note); // Constructor may set properties like box->enabled. obj->note is note into box def, not user params. //$box=new stdClass(); // box properties @@ -117,9 +117,9 @@ class InfoBox $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); $box->sourcefile= $relsourcefile; - $box->class = $boxname; + $box->class = $boxname; - if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database + if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database { if (is_numeric($box->box_order)) { @@ -138,19 +138,19 @@ class InfoBox { foreach($box->depends as $moduleelem) { - $arrayelem=explode('|', $moduleelem); - $tmpenabled=0; // $tmpenabled is used for the '|' test (OR) - foreach($arrayelem as $module) - { - $tmpmodule=preg_replace('/@[^@]+/', '', $module); - if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; - //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'
'; - } - if (empty($tmpenabled)) // We found at least one module required that is disabled - { - $enabled=0; - break; - } + $arrayelem=explode('|', $moduleelem); + $tmpenabled=0; // $tmpenabled is used for the '|' test (OR) + foreach($arrayelem as $module) + { + $tmpmodule=preg_replace('/@[^@]+/', '', $module); + if (! empty($conf->$tmpmodule->enabled)) $tmpenabled=1; + //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'
'; + } + if (empty($tmpenabled)) // We found at least one module required that is disabled + { + $enabled=0; + break; + } } } //print '=>'.$boxname.'-enabled='.$enabled.'
'; @@ -160,16 +160,16 @@ class InfoBox else unset($box); } else - { - dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING); - } + { + dol_syslog("Failed to load box '".$boxname."' into file '".$relsourcefile."'", LOG_WARNING); + } } $j++; } } else - { - dol_syslog($db->lasterror(), LOG_ERR); + { + dol_syslog($db->lasterror(), LOG_ERR); return array('error'=>$db->lasterror()); } @@ -186,7 +186,7 @@ class InfoBox * @param int $userid Id of user * @return int <0 if KO, 0=Nothing done, > 0 if OK */ - static function saveboxorder($db, $zone, $boxorder, $userid = 0) + public static function saveboxorder($db, $zone, $boxorder, $userid = 0) { global $conf; diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 82b146489e9..ec0c2571ec8 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -36,24 +36,24 @@ class Interfaces */ public $db; - var $dir; // Directory with all core and external triggers files + public $dir; // Directory with all core and external triggers files /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + * @var string[] Error codes (or messages) + */ + public $errors = array(); /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function called when a Dolibarr business event occurs * This function call all qualified triggers. @@ -65,15 +65,15 @@ class Interfaces * @param Conf $conf Objet conf * @return int Nb of triggers ran if no error, -Nb of triggers with errors otherwise. */ - function run_triggers($action, $object, $user, $langs, $conf) + public function run_triggers($action, $object, $user, $langs, $conf) { // phpcs:enable // Check parameters if (! is_object($object) || ! is_object($conf)) // Error { - $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); + $this->error='function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); dol_syslog(get_class($this).'::run_triggers '.$this->error, LOG_ERR); - $this->errors[]=$this->error; + $this->errors[]=$this->error; return -1; } if (! is_object($langs)) // Warning @@ -93,10 +93,10 @@ class Interfaces $files = array(); $modules = array(); $orders = array(); - $i=0; + $i=0; - $dirtriggers=array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); + $dirtriggers=array_merge(array('/core/triggers'), $conf->modules_parts['triggers']); foreach($dirtriggers as $reldir) { $dir=dol_buildpath($reldir, 0); @@ -113,9 +113,9 @@ class Interfaces { if (is_readable($newdir."/".$file) && preg_match('/^interface_([0-9]+)_([^_]+)_(.+)\.class\.php$/i', $file, $reg)) { - $part1=$reg[1]; - $part2=$reg[2]; - $part3=$reg[3]; + $part1=$reg[1]; + $part2=$reg[2]; + $part3=$reg[3]; $nbfile++; @@ -177,22 +177,22 @@ class Interfaces $objMod = new $modName($this->db); if ($objMod) { - $result=0; + $result=0; - if (method_exists($objMod, 'runTrigger')) // New method to implement - { - //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); - $result=$objMod->runTrigger($action, $object, $user, $langs, $conf); - } - elseif (method_exists($objMod, 'run_trigger')) // Deprecated method - { - dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); - $result=$objMod->run_trigger($action, $object, $user, $langs, $conf); - } - else - { - dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); - } + if (method_exists($objMod, 'runTrigger')) // New method to implement + { + //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch runTrigger for file '".$files[$key]."'", LOG_DEBUG); + $result=$objMod->runTrigger($action, $object, $user, $langs, $conf); + } + elseif (method_exists($objMod, 'run_trigger')) // Deprecated method + { + dol_syslog(get_class($this)."::run_triggers action=".$action." Launch old method run_trigger (rename your trigger into runTrigger) for file '".$files[$key]."'", LOG_WARNING); + $result=$objMod->run_trigger($action, $object, $user, $langs, $conf); + } + else + { + dol_syslog(get_class($this)."::run_triggers action=".$action." A trigger was declared for class ".get_class($objMod)." but method runTrigger was not found", LOG_ERR); + } if ($result > 0) { @@ -217,7 +217,7 @@ class Interfaces } } else - { + { dol_syslog(get_class($this)."::run_triggers action=".$action." Failed to instantiate trigger for file '".$files[$key]."'", LOG_ERR); } } @@ -238,10 +238,10 @@ class Interfaces * Return list of triggers. Function used by admin page htdoc/admin/triggers. * List is sorted by trigger filename so by priority to run. * - * @param array $forcedirtriggers null=All default directories. This parameter is used by modulebuilder module only. + * @param array $forcedirtriggers null=All default directories. This parameter is used by modulebuilder module only. * @return array Array list of triggers */ - function getTriggersList($forcedirtriggers = null) + public function getTriggersList($forcedirtriggers = null) { global $conf, $langs, $db; @@ -256,7 +256,7 @@ class Interfaces $dirtriggers=array_merge(array('/core/triggers/'), $conf->modules_parts['triggers']); if (is_array($forcedirtriggers)) { - $dirtriggers=$forcedirtriggers; + $dirtriggers=$forcedirtriggers; } foreach($dirtriggers as $reldir) @@ -276,9 +276,9 @@ class Interfaces { if (preg_match('/\.back$/', $file)) continue; - $part1=$reg[1]; - $part2=$reg[2]; - $part3=$reg[3]; + $part1=$reg[1]; + $part2=$reg[2]; + $part3=$reg[3]; $modName = 'Interface'.ucfirst($reg[3]); //print "file=$file"; print "modName=$modName"; exit; @@ -319,8 +319,8 @@ class Interfaces if (! class_exists($modName)) { - print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."
\n"; - continue; + print 'Error: A trigger file was found but its class "'.$modName.'" was not found.'."
\n"; + continue; } $objMod = new $modName($db); @@ -342,7 +342,7 @@ class Interfaces $triggers[$j]['module']=strtolower($module); } - // We set info of modules + // We set info of modules $triggers[$j]['picto'] = $objMod->picto?img_object('', $objMod->picto):img_object('', 'generic'); $triggers[$j]['file'] = $files[$key]; $triggers[$j]['fullpath'] = $fullpath[$key]; diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 1e23d2a071c..c00f4003d5d 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -42,78 +42,78 @@ class Ldap /** * Tableau des serveurs (IP addresses ou nom d'hotes) */ - var $server=array(); + public $server=array(); /** * Base DN (e.g. "dc=foo,dc=com") */ - var $dn; + public $dn; /** * type de serveur, actuellement OpenLdap et Active Directory */ - var $serverType; + public $serverType; /** * Version du protocole ldap */ - var $domain; + public $domain; /** * User administrateur Ldap * Active Directory ne supporte pas les connexions anonymes */ - var $searchUser; + public $searchUser; /** * Mot de passe de l'administrateur * Active Directory ne supporte pas les connexions anonymes */ - var $searchPassword; + public $searchPassword; /** * DN des utilisateurs */ - var $people; + public $people; /** * DN des groupes */ - var $groups; + public $groups; /** * Code erreur retourne par le serveur Ldap */ - var $ldapErrorCode; + public $ldapErrorCode; /** * Message texte de l'erreur */ - var $ldapErrorText; + public $ldapErrorText; //Fetch user - var $name; - var $firstname; - var $login; - var $phone; - var $skype; - var $fax; - var $mail; - var $mobile; + public $name; + public $firstname; + public $login; + public $phone; + public $skype; + public $fax; + public $mail; + public $mobile; - var $uacf; - var $pwdlastset; + public $uacf; + public $pwdlastset; - var $ldapcharset='UTF-8'; // LDAP should be UTF-8 encoded + public $ldapcharset='UTF-8'; // LDAP should be UTF-8 encoded /** * The internal LDAP connection handle */ - var $connection; + public $connection; /** * Result of any connections etc. */ - var $result; + public $result; /** * Constructor */ - function __construct() + public function __construct() { global $conf; @@ -149,7 +149,7 @@ class Ldap // Connection handling methods ------------------------------------------- - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Connect and bind * Use this->server, this->serverPort, this->ldapProtocolVersion, this->serverType, this->searchUser, this->searchPassword @@ -157,7 +157,7 @@ class Ldap * * @return int <0 if KO, 1 if bind anonymous, 2 if bind auth */ - function connect_bind() + public function connect_bind() { // phpcs:enable global $langs, $conf; @@ -290,7 +290,7 @@ class Ldap * * @return boolean true or false */ - function close() + public function close() { if ($this->connection && ! @ldap_close($this->connection)) { @@ -308,7 +308,7 @@ class Ldap * * @return boolean true or false */ - function bind() + public function bind() { if (! $this->result=@ldap_bind($this->connection)) { @@ -333,7 +333,7 @@ class Ldap * @param string $pass Password * @return boolean true or false */ - function bindauth($bindDn, $pass) + public function bindauth($bindDn, $pass) { if (! $this->result = @ldap_bind($this->connection, $bindDn, $pass)) { @@ -353,7 +353,7 @@ class Ldap * * @return boolean true or false */ - function unbind() + public function unbind() { if (!$this->result=@ldap_unbind($this->connection)) { @@ -369,7 +369,7 @@ class Ldap * * @return string version */ - function getVersion() + public function getVersion() { $version = 0; $version = @ldap_get_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $version); @@ -379,9 +379,9 @@ class Ldap /** * Change ldap protocol version to use. * - * @return boolean version + * @return boolean version */ - function setVersion() + public function setVersion() { // LDAP_OPT_PROTOCOL_VERSION est une constante qui vaut 17 $ldapsetversion = ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, $this->ldapProtocolVersion); @@ -391,9 +391,9 @@ class Ldap /** * changement du referrals. * - * @return boolean referrals + * @return boolean referrals */ - function setReferrals() + public function setReferrals() { // LDAP_OPT_REFERRALS est une constante qui vaut ? $ldapreferrals = ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); @@ -410,7 +410,7 @@ class Ldap * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ - function add($dn, $info, $user) + public function add($dn, $info, $user) { global $conf; @@ -464,7 +464,7 @@ class Ldap * @param User $user Objet user that modify * @return int <0 if KO, >0 if OK */ - function modify($dn, $info, $user) + public function modify($dn, $info, $user) { global $conf; @@ -518,7 +518,7 @@ class Ldap * @param bool $deleteoldrdn If true the old RDN value(s) is removed, else the old RDN value(s) is retained as non-distinguished values of the entry. * @return int <0 if KO, >0 if OK */ - function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true) + public function rename($dn, $newrdn, $newparent, $user, $deleteoldrdn = true) { global $conf; @@ -559,7 +559,7 @@ class Ldap /** * Modify a LDAP entry (to use if dn != olddn) - * Ldap object connect and bind must have been done + * Ldap object connect and bind must have been done * * @param string $dn DN entry key * @param array $info Attributes array @@ -569,7 +569,7 @@ class Ldap * @param string $newparent New parent (ou=xxx,dc=aaa,dc=bbb) (for ldap_rename) * @return int <0 if KO, >0 if OK */ - function update($dn, $info, $user, $olddn, $newrdn = false, $newparent = false) + public function update($dn, $info, $user, $olddn, $newrdn = false, $newparent = false) { global $conf; @@ -629,7 +629,7 @@ class Ldap * @param string $dn DN entry key * @return int <0 if KO, >0 if OK */ - function delete($dn) + public function delete($dn) { global $conf; @@ -656,7 +656,7 @@ class Ldap return -1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build a LDAP message * @@ -664,7 +664,7 @@ class Ldap * @param array $info Attributes array * @return string Content of file */ - function dump_content($dn, $info) + public function dump_content($dn, $info) { // phpcs:enable $content=''; @@ -707,7 +707,7 @@ class Ldap * @param array $info Attributes array * @return int <0 if KO, >0 if OK */ - function dump($dn, $info) + public function dump($dn, $info) { global $conf; @@ -741,7 +741,7 @@ class Ldap * @param int $timeout Timeout in second (default 1s) * @return boolean true or false */ - function serverPing($host, $port = 389, $timeout = 1) + public function serverPing($host, $port = 389, $timeout = 1) { // Replace ldaps:// by ssl:// if (preg_match('/^ldaps:\/\/([^\/]+)\/?$/', $host, $regs)) { @@ -771,7 +771,7 @@ class Ldap * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ - function addAttribute($dn, $info, $user) + public function addAttribute($dn, $info, $user) { global $conf; @@ -823,7 +823,7 @@ class Ldap * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ - function updateAttribute($dn, $info, $user) + public function updateAttribute($dn, $info, $user) { global $conf; @@ -875,7 +875,7 @@ class Ldap * @param User $user Objet user that create * @return int <0 if KO, >0 if OK */ - function deleteAttribute($dn, $info, $user) + public function deleteAttribute($dn, $info, $user) { global $conf; @@ -925,7 +925,7 @@ class Ldap * @param string $filter Filter * @return int|array <0 or false if KO, array if OK */ - function getAttribute($dn, $filter) + public function getAttribute($dn, $filter) { // Check parameters if (! $this->connection) @@ -970,7 +970,7 @@ class Ldap * @param string $attribute Attributes * @return void */ - function getAttributeValues($filterrecord, $attribute) + public function getAttributeValues($filterrecord, $attribute) { $attributes=array(); $attributes[0] = $attribute; @@ -1015,7 +1015,7 @@ class Ldap * @param array $attributeAsArray Array of fields wanted as an array not a string * @return array Array of [id_record][ldap_field]=value */ - function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array()) + public function getRecords($search, $userDn, $useridentifier, $attributeArray, $activefilter = 0, $attributeAsArray = array()) { $fulllist=array(); @@ -1123,7 +1123,7 @@ class Ldap * @param string $hex Hex value * @return string Little endian */ - function littleEndian($hex) + public function littleEndian($hex) { for ($x=dol_strlen($hex)-2; $x >= 0; $x=$x-2) { $result .= substr($hex, $x, 2); @@ -1139,7 +1139,7 @@ class Ldap * @param string $ldapUser Login de l'utilisateur * @return string Sid */ - function getObjectSid($ldapUser) + public function getObjectSid($ldapUser) { $criteria = '('.$this->getUserIdentifier().'='.$ldapUser.')'; $justthese = array("objectsid"); @@ -1198,7 +1198,7 @@ class Ldap * @param string $binsid Binary SID * @return string Textual SID */ - function binSIDtoText($binsid) + public function binSIDtoText($binsid) { $hex_sid=bin2hex($binsid); $rev = hexdec(substr($hex_sid, 0, 2)); // Get revision-part of SID @@ -1224,7 +1224,7 @@ class Ldap * @param string $filter Search filter (ex: (sn=nom_personne) ) * @return array|int Array with answers (key lowercased - value) */ - function search($checkDn, $filter) + public function search($checkDn, $filter) { dol_syslog(get_class($this)."::search checkDn=".$checkDn." filter=".$filter); @@ -1260,7 +1260,7 @@ class Ldap * Examples: &(objectClass=inetOrgPerson) &(objectClass=user)(objectCategory=person) &(isMemberOf=cn=Sales,ou=Groups,dc=opencsi,dc=com) * @return int >0 if OK, <0 if KO */ - function fetch($user, $filter) + public function fetch($user, $filter) { // Perform the search and get the entry handles @@ -1353,7 +1353,7 @@ class Ldap * * @return string Login */ - function getUserIdentifier() + public function getUserIdentifier() { if ($this->serverType == "activedirectory") { return $this->attr_sambalogin; @@ -1368,7 +1368,7 @@ class Ldap * @param string $uacf UACF * @return void */ - function parseUACF($uacf) + public function parseUACF($uacf) { //All flags array $flags = array( @@ -1414,7 +1414,7 @@ class Ldap * @param string $samtype SamType * @return string Sam string */ - function parseSAT($samtype) + public function parseSAT($samtype) { $stypes = array( 805306368 => "NORMAL_ACCOUNT", @@ -1438,14 +1438,14 @@ class Ldap return($retval); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Convertit le temps ActiveDirectory en Unix timestamp * * @param string $value AD time to convert * @return integer Unix timestamp */ - function convert_time($value) + public function convert_time($value) { // phpcs:enable $dateLargeInt=$value; // nano secondes depuis 1601 !!!! @@ -1478,7 +1478,7 @@ class Ldap * @param string $pagecodeto Page code for result string * @return string Converted string */ - function convFromOutputCharset($str, $pagecodeto = 'UTF-8') + public function convFromOutputCharset($str, $pagecodeto = 'UTF-8') { global $conf; if ($pagecodeto == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') $str=utf8_decode($str); @@ -1493,7 +1493,7 @@ class Ldap * @param string $keygroup Key of group * @return int gid number */ - function getNextGroupGid($keygroup = 'LDAP_KEY_GROUPS') + public function getNextGroupGid($keygroup = 'LDAP_KEY_GROUPS') { global $conf; diff --git a/htdocs/core/class/link.class.php b/htdocs/core/class/link.class.php index d796891e632..283b296b3e3 100644 --- a/htdocs/core/class/link.class.php +++ b/htdocs/core/class/link.class.php @@ -150,11 +150,11 @@ class Link extends CommonObject } /** - * Update parameters of third party + * Update parameters of third party * - * @param User $user User executing update - * @param int $call_trigger 0=no, 1=yes - * @return int <0 if KO, >=0 if OK + * @param User $user User executing update + * @param int $call_trigger 0=no, 1=yes + * @return int <0 if KO, >=0 if OK */ public function update($user = '', $call_trigger = 1) { diff --git a/htdocs/core/class/menu.class.php b/htdocs/core/class/menu.class.php index 07fab4e74ea..204efbf0ae7 100644 --- a/htdocs/core/class/menu.class.php +++ b/htdocs/core/class/menu.class.php @@ -28,14 +28,14 @@ */ class Menu { - var $liste; + public $liste; /** - * Constructor + * Constructor */ - function __construct() + public function __construct() { - $this->liste = array(); + $this->liste = array(); } /** @@ -43,7 +43,7 @@ class Menu * * @return void */ - function clear() + public function clear() { $this->liste = array(); } @@ -65,15 +65,15 @@ class Menu * @param string $prefix Prefix to title (image or picto) * @return void */ - function add($url, $titre, $level = 0, $enabled = 1, $target = '', $mainmenu = '', $leftmenu = '', $position = 0, $id = '', $idsel = '', $classname = '', $prefix = '') + public function add($url, $titre, $level = 0, $enabled = 1, $target = '', $mainmenu = '', $leftmenu = '', $position = 0, $id = '', $idsel = '', $classname = '', $prefix = '') { - $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname, 'prefix'=>$prefix); + $this->liste[]=array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu, 'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname, 'prefix'=>$prefix); } /** * Insert a menu entry into this->liste * - * @param int $idafter Array key after which inserting new entry + * @param int $idafter Array key after which inserting new entry * @param string $url Url to follow on click * @param string $titre Label of menu to add * @param integer $level Level of menu to add @@ -88,7 +88,7 @@ class Menu * @param string $prefix Prefix to title (image or picto) * @return void */ - function insert($idafter, $url, $titre, $level = 0, $enabled = 1, $target = '', $mainmenu = '', $leftmenu = '', $position = 0, $id = '', $idsel = '', $classname = '', $prefix = '') + public function insert($idafter, $url, $titre, $level = 0, $enabled = 1, $target = '', $mainmenu = '', $leftmenu = '', $position = 0, $id = '', $idsel = '', $classname = '', $prefix = '') { $array_start = array_slice($this->liste, 0, ($idafter+1)); $array_new = array(0=>array('url'=>$url,'titre'=>$titre,'level'=>$level,'enabled'=>$enabled,'target'=>$target,'mainmenu'=>$mainmenu,'leftmenu'=>$leftmenu,'position'=>$position, 'id'=>$id, 'idsel'=>$idsel, 'classname'=>$classname, 'prefix'=>$prefix)); @@ -96,13 +96,13 @@ class Menu $this->liste=array_merge($array_start, $array_new, $array_end); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a menu entry from this->liste * * @return void */ - function remove_last() + public function remove_last() { // phpcs:enable if (count($this->liste) > 1) { @@ -115,7 +115,7 @@ class Menu * * @return int Number of visible (gray or not) menu entries */ - function getNbOfVisibleMenuEntries() + public function getNbOfVisibleMenuEntries() { $nb=0; foreach($this->liste as $val) diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index 16c1f54ee31..d1d7534af23 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -91,7 +91,7 @@ class Menubase * @param DoliDB $db Database handler * @param string $menu_handler Menu handler */ - function __construct($db, $menu_handler = '') + public function __construct($db, $menu_handler = '') { $this->db = $db; $this->menu_handler = $menu_handler; @@ -105,7 +105,7 @@ class Menubase * @param User $user User that create * @return int <0 if KO, Id of record if OK */ - function create($user = null) + public function create($user = null) { global $conf, $langs; @@ -245,7 +245,7 @@ class Menubase * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -310,7 +310,7 @@ class Menubase * @param User $user User that load * @return int <0 if KO, >0 if OK */ - function fetch($id, $user = null) + public function fetch($id, $user = null) { global $langs; @@ -384,7 +384,7 @@ class Menubase * @param User $user User that delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { global $conf, $langs; @@ -410,7 +410,7 @@ class Menubase * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -443,7 +443,7 @@ class Menubase * @param array $tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @return array Return array with menu entries for top menu */ - function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) + public function menuTopCharger($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) { global $langs, $user, $conf; // To export to dol_eval function global $mainmenu,$leftmenu; // To export to dol_eval function @@ -472,7 +472,7 @@ class Menubase * @param array $tabMenu Array with menu entries already loaded * @return Menu Menu array for particular mainmenu value or full tabArray */ - function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) + public function menuLeftCharger($newmenu, $mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) { global $langs, $user, $conf; // To export to dol_eval function global $mainmenu,$leftmenu; // To export to dol_eval function @@ -480,16 +480,16 @@ class Menubase $mainmenu=$mymainmenu; // To export to dol_eval function $leftmenu=$myleftmenu; // To export to dol_eval function - // Detect what is top mainmenu id + // Detect what is top mainmenu id $menutopid=''; foreach($tabMenu as $key => $val) { - // Define menutopid of mainmenu - if (empty($menutopid) && $val['type'] == 'top' && $val['mainmenu'] == $mainmenu) - { - $menutopid=$val['rowid']; - break; - } + // Define menutopid of mainmenu + if (empty($menutopid) && $val['type'] == 'top' && $val['mainmenu'] == $mainmenu) + { + $menutopid=$val['rowid']; + break; + } } // We initialize newmenu with first already found menu entries @@ -561,7 +561,7 @@ class Menubase * @param array $tabMenu Array to store new entries found (in most cases, it's empty, but may be alreay filled) * @return int >0 if OK, <0 if KO */ - function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) + public function menuLoad($mymainmenu, $myleftmenu, $type_user, $menu_handler, &$tabMenu) { global $langs, $user, $conf; // To export to dol_eval function global $mainmenu, $leftmenu; // To export to dol_eval function @@ -577,10 +577,10 @@ class Menubase if ($type_user == 0) $sql.= " AND m.usertype IN (0,2)"; if ($type_user == 1) $sql.= " AND m.usertype IN (1,2)"; $sql.= " ORDER BY m.position, m.rowid"; - //print $sql; + //print $sql; - //$tmp1=microtime(true); - //print '>>> 1 0
'; + //$tmp1=microtime(true); + //print '>>> 1 0
'; dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu)."", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) @@ -647,8 +647,8 @@ class Menubase $title = $langs->trans($menu['titre']); } } - //$tmp4=microtime(true); - //print '>>> 3 '.($tmp4 - $tmp3).'
'; + //$tmp4=microtime(true); + //print '>>> 3 '.($tmp4 - $tmp3).'
'; // We complete tabMenu $tabMenu[$b]['rowid'] = $menu['rowid']; diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 772b3db29e3..a599137109d 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -90,7 +90,7 @@ class Notify * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -105,7 +105,7 @@ class Notify * @param Object $object Object the notification is about * @return string Message */ - function confirmMessage($action, $socid, $object) + public function confirmMessage($action, $socid, $object) { global $langs; $langs->load("mails"); @@ -146,7 +146,7 @@ class Notify * @param array $scope Scope where to search * @return array|int <0 if KO, array of notifications to send if OK */ - function getNotificationsArray($notifcode, $socid = 0, $object = null, $userid = 0, $scope = array('thirdparty', 'user', 'global')) + public function getNotificationsArray($notifcode, $socid = 0, $object = null, $userid = 0, $scope = array('thirdparty', 'user', 'global')) { global $conf, $user; @@ -309,7 +309,7 @@ class Notify * @param array $mimefilename_list List of attached file name in message * @return int <0 if KO, or number of changes if OK */ - function send($notifcode, $object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array()) + public function send($notifcode, $object, $filename_list = array(), $mimetype_list = array(), $mimefilename_list = array()) { global $user,$conf,$langs,$mysoc; global $hookmanager; @@ -530,7 +530,7 @@ class Notify if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; } - $mailfile = new CMailFile( + $mailfile = new CMailFile( $subject, $sendto, $replyto, @@ -542,7 +542,7 @@ class Notify '', 0, -1 - ); + ); if ($mailfile->sendfile()) { @@ -758,7 +758,7 @@ class Notify if (! empty($hookmanager->resArray['subject'])) $subject.=$hookmanager->resArray['subject']; if (! empty($hookmanager->resArray['message'])) $message.=$hookmanager->resArray['message']; } - $mailfile = new CMailFile( + $mailfile = new CMailFile( $subject, $sendto, $replyto, diff --git a/htdocs/core/class/openid.class.php b/htdocs/core/class/openid.class.php index 32838f0deb2..2612aa5057b 100644 --- a/htdocs/core/class/openid.class.php +++ b/htdocs/core/class/openid.class.php @@ -26,18 +26,18 @@ */ class SimpleOpenID { - var $openid_url_identity; - var $URLs = array(); - var $error = array(); - var $fields = array( - 'required' => array(), - 'optional' => array(), + public $openid_url_identity; + public $URLs = array(); + public $error = array(); + public $fields = array( + 'required' => array(), + 'optional' => array(), ); /** * Constructor */ - function __construct() + public function __construct() { if (!function_exists('curl_exec')) { @@ -45,66 +45,66 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetOpenIDServer * * @param string $a Server * @return void */ - function SetOpenIDServer($a) + public function SetOpenIDServer($a) { // phpcs:enable $this->URLs['openid_server'] = $a; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetOpenIDServer * * @param string $a Server * @return void */ - function SetTrustRoot($a) + public function SetTrustRoot($a) { // phpcs:enable $this->URLs['trust_root'] = $a; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetOpenIDServer * * @param string $a Server * @return void */ - function SetCancelURL($a) + public function SetCancelURL($a) { // phpcs:enable $this->URLs['cancel'] = $a; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetApprovedURL * * @param string $a Server * @return void */ - function SetApprovedURL($a) + public function SetApprovedURL($a) { // phpcs:enable $this->URLs['approved'] = $a; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetRequiredFields * * @param string $a Server * @return void */ - function SetRequiredFields($a) + public function SetRequiredFields($a) { // phpcs:enable if (is_array($a)) { @@ -114,14 +114,14 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetOptionalFields * * @param string $a Server * @return void */ - function SetOptionalFields($a) + public function SetOptionalFields($a) { // phpcs:enable if (is_array($a)) { @@ -131,14 +131,14 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetIdentity * * @param string $a Server * @return void */ - function SetIdentity($a) + public function SetIdentity($a) { // phpcs:enable // Set Identity URL @@ -162,33 +162,33 @@ class SimpleOpenID $this->openid_url_identity = $a; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * GetIdentity * * @return string */ - function GetIdentity() + public function GetIdentity() { // phpcs:enable // Get Identity return $this->openid_url_identity; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * SetOpenIDServer * * @return void */ - function GetError() + public function GetError() { // phpcs:enable $e = $this->error; return array('code'=>$e[0],'description'=>$e[1]); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * ErrorStore * @@ -196,7 +196,7 @@ class SimpleOpenID * @param string $desc Description * @return void */ - function ErrorStore($code, $desc = null) + public function ErrorStore($code, $desc = null) { // phpcs:enable $errs['OPENID_NOSERVERSFOUND'] = 'Cannot find OpenID Server TAG on Identity page.'; @@ -206,13 +206,13 @@ class SimpleOpenID $this->error = array($code,$desc); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * IsError * * @return boolean */ - function IsError() + public function IsError() { // phpcs:enable if (count($this->error) > 0) @@ -231,7 +231,7 @@ class SimpleOpenID * @param string $response Server * @return void */ - function splitResponse($response) + public function splitResponse($response) { $r = array(); $response = explode("\n", $response); @@ -245,14 +245,14 @@ class SimpleOpenID return $r; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * OpenID_Standarize * * @param string $openid_identity Server * @return string */ - function OpenID_Standarize($openid_identity = null) + public function OpenID_Standarize($openid_identity = null) { // phpcs:enable if ($openid_identity === null) @@ -279,7 +279,7 @@ class SimpleOpenID * @param array $arr An array * @return false|string false if KO, string of url if OK */ - function array2url($arr) + public function array2url($arr) { // converts associated array to URL Query String if (!is_array($arr)){ @@ -292,7 +292,7 @@ class SimpleOpenID return $query; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * FSOCK_Request * @@ -301,7 +301,7 @@ class SimpleOpenID * @param string $params Params * @return boolean|unknown */ - function FSOCK_Request($url, $method = "GET", $params = "") + public function FSOCK_Request($url, $method = "GET", $params = "") { // phpcs:enable $fp = fsockopen("ssl://www.myopenid.com", 443, $errno, $errstr, 3); // Connection timeout is 3 seconds @@ -326,7 +326,7 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * CURL_Request * @@ -335,7 +335,7 @@ class SimpleOpenID * @param string $params Params * @return string */ - function CURL_Request($url, $method = "GET", $params = "") + public function CURL_Request($url, $method = "GET", $params = "") { // phpcs:enable // Remember, SSL MUST BE SUPPORTED @@ -359,14 +359,14 @@ class SimpleOpenID return $response; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * HTML2OpenIDServer * * @param string $content Content * @return array Array of servers */ - function HTML2OpenIDServer($content) + public function HTML2OpenIDServer($content) { // phpcs:enable $get = array(); @@ -387,20 +387,20 @@ class SimpleOpenID } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get openid server * * @param string $url Url to found endpoint * @return string Endpoint */ - function GetOpenIDServer($url = '') + public function GetOpenIDServer($url = '') { // phpcs:enable global $conf; - include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; $response = getURLContent($url); @@ -417,13 +417,13 @@ class SimpleOpenID return $servers[0]; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * GetRedirectURL * * @return string */ - function GetRedirectURL() + public function GetRedirectURL() { // phpcs:enable $params = array(); @@ -443,13 +443,13 @@ class SimpleOpenID return $this->URLs['openid_server'] . "?". $this->array2url($params); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Redirect * * @return void */ - function Redirect() + public function Redirect() { // phpcs:enable $redirect_to = $this->GetRedirectURL(); @@ -465,19 +465,19 @@ class SimpleOpenID } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * ValidateWithServer * * @return boolean */ - function ValidateWithServer() + public function ValidateWithServer() { // phpcs:enable $params = array( - 'openid.assoc_handle' => urlencode($_GET['openid_assoc_handle']), - 'openid.signed' => urlencode($_GET['openid_signed']), - 'openid.sig' => urlencode($_GET['openid_sig']) + 'openid.assoc_handle' => urlencode($_GET['openid_assoc_handle']), + 'openid.signed' => urlencode($_GET['openid_signed']), + 'openid.sig' => urlencode($_GET['openid_sig']) ); // Send only required parameters to confirm validity $arr_signed = explode(",", str_replace('sreg.', 'sreg_', $_GET['openid_signed'])); @@ -518,36 +518,36 @@ class SimpleOpenID * @param string $url Url of endpoint to request * @return string First endpoint OpenID server found. False if it failed to found. */ - function sendDiscoveryRequestToGetXRDS($url = '') + public function sendDiscoveryRequestToGetXRDS($url = '') { - global $conf; + global $conf; - include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; - if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; + include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; + if (empty($url)) $url=$conf->global->MAIN_AUTHENTICATION_OPENID_URL; - dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS'); + dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS get XRDS'); - $addheaders=array('Accept: application/xrds+xml'); + $addheaders=array('Accept: application/xrds+xml'); $response = getURLContent($url, 'GET', '', 1, $addheaders); - /* response should like this: - - - - - http://specs.openid.net/auth/2.0/server - http://openid.net/srv/ax/1.0 - ... - https://www.google.com/accounts/o8/ud - - - - */ - $content=$response['content']; + /* response should like this: + + + + + http://specs.openid.net/auth/2.0/server + http://openid.net/srv/ax/1.0 + ... + https://www.google.com/accounts/o8/ud + + + + */ + $content=$response['content']; $server=''; if (preg_match('/'.preg_quote('', '/').'(.*)'.preg_quote('', '/').'/is', $content, $reg)) { - $server=$reg[1]; + $server=$reg[1]; } if (empty($server)) @@ -557,9 +557,9 @@ class SimpleOpenID } else { - dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server); - $this->SetOpenIDServer($server); - return $server; - } + dol_syslog(get_class($this).'::sendDiscoveryRequestToGetXRDS found endpoint = '.$server); + $this->SetOpenIDServer($server); + return $server; + } } } diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 7683137767b..1dcd7ef64e5 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -32,9 +32,9 @@ class RssParser public $db; /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; private $_format=''; private $_urlRSS; @@ -61,7 +61,7 @@ class RssParser */ public function __construct($db) { - $this->db = $db; + $this->db = $db; } /** @@ -252,28 +252,28 @@ class RssParser if ($str !== false) { - // Convert $str into xml - if (! empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) - { - //print 'xx'.LIBXML_NOCDATA; - libxml_use_internal_errors(false); - $rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA); - } - else - { - $xmlparser=xml_parser_create(''); - if (!is_resource($xmlparser)) { - $this->error="ErrorFailedToCreateParser"; return -1; - } + // Convert $str into xml + if (! empty($conf->global->EXTERNALRSS_USE_SIMPLEXML)) + { + //print 'xx'.LIBXML_NOCDATA; + libxml_use_internal_errors(false); + $rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA); + } + else + { + $xmlparser=xml_parser_create(''); + if (!is_resource($xmlparser)) { + $this->error="ErrorFailedToCreateParser"; return -1; + } - xml_set_object($xmlparser, $this); - xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element'); - xml_set_character_data_handler($xmlparser, 'feed_cdata'); - $status = xml_parse($xmlparser, $str); - xml_parser_free($xmlparser); - $rss=$this; - //var_dump($rss->_format);exit; - } + xml_set_object($xmlparser, $this); + xml_set_element_handler($xmlparser, 'feed_start_element', 'feed_end_element'); + xml_set_character_data_handler($xmlparser, 'feed_cdata'); + $status = xml_parse($xmlparser, $str); + xml_parser_free($xmlparser); + $rss=$this; + //var_dump($rss->_format);exit; + } } // If $rss loaded @@ -287,16 +287,16 @@ class RssParser $fp = fopen($newpathofdestfile, 'w'); if ($fp) { - fwrite($fp, $str); - fclose($fp); - if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; - @chmod($newpathofdestfile, octdec($newmask)); + fwrite($fp, $str); + fclose($fp); + if (! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; + @chmod($newpathofdestfile, octdec($newmask)); - $this->_lastfetchdate=$nowgmt; + $this->_lastfetchdate=$nowgmt; } else { - print 'Error, failed to open file '.$newpathofdestfile.' for write'; + print 'Error, failed to open file '.$newpathofdestfile.' for write'; } } @@ -435,13 +435,13 @@ class RssParser // Add record to result array $this->_rssarray[$i] = array( - 'link'=>$itemLink, - 'title'=>$itemTitle, - 'description'=>$itemDescription, - 'pubDate'=>$itemPubDate, - 'category'=>$itemCategory, - 'id'=>$itemId, - 'author'=>$itemAuthor); + 'link'=>$itemLink, + 'title'=>$itemTitle, + 'description'=>$itemDescription, + 'pubDate'=>$itemPubDate, + 'category'=>$itemCategory, + 'id'=>$itemId, + 'author'=>$itemAuthor); //var_dump($this->_rssarray); $i++; @@ -461,7 +461,7 @@ class RssParser - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Triggered when opened tag is found * @@ -470,7 +470,7 @@ class RssParser * @param array $attrs Attributes of tags * @return void */ - function feed_start_element($p, $element, &$attrs) + public function feed_start_element($p, $element, &$attrs) { // phpcs:enable $el = $element = strtolower($element); @@ -581,7 +581,7 @@ class RssParser } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Triggered when CDATA is found * @@ -589,7 +589,7 @@ class RssParser * @param string $text Tag * @return void */ - function feed_cdata($p, $text) + public function feed_cdata($p, $text) { // phpcs:enable if ($this->_format == 'atom' and $this->incontent) @@ -603,7 +603,7 @@ class RssParser } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Triggered when closed tag is found * @@ -611,7 +611,7 @@ class RssParser * @param string $el Tag * @return void */ - function feed_end_element($p, $el) + public function feed_end_element($p, $el) { // phpcs:enable $el = strtolower($el); @@ -666,7 +666,7 @@ class RssParser * @param string $str2 Str2 * @return string String cancatenated */ - function concat(&$str1, $str2 = "") + public function concat(&$str1, $str2 = "") { if (!isset($str1) ) { $str1=""; @@ -674,14 +674,14 @@ class RssParser $str1 .= $str2; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Enter description here ... * * @param string $text Text * @return void */ - function append_content($text) + public function append_content($text) { // phpcs:enable if ( $this->initem ) { @@ -699,7 +699,7 @@ class RssParser * @param string $text Text * @return void */ - function append($el, $text) + public function append($el, $text) { if (!$el) { return; diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index 695464f536f..24e7b2acc59 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -45,109 +45,109 @@ */ class SMTPs { - /** - * Host Name or IP of SMTP Server to use - */ - var $_smtpsHost = 'localhost'; + /** + * Host Name or IP of SMTP Server to use + */ + private $_smtpsHost = 'localhost'; - /** - * SMTP Server Port definition. 25 is default value - * This can be defined via a INI file or via a setter method - */ - var $_smtpsPort = '25'; + /** + * SMTP Server Port definition. 25 is default value + * This can be defined via a INI file or via a setter method + */ + private $_smtpsPort = '25'; - /** - * Secure SMTP Server access ID - * This can be defined via a INI file or via a setter method - */ - var $_smtpsID = null; + /** + * Secure SMTP Server access ID + * This can be defined via a INI file or via a setter method + */ + private $_smtpsID = null; - /** - * Secure SMTP Server access Password - * This can be defined via a INI file or via a setter method - */ - var $_smtpsPW = null; + /** + * Secure SMTP Server access Password + * This can be defined via a INI file or via a setter method + */ + private $_smtpsPW = null; - /** - * Who sent the Message - * This can be defined via a INI file or via a setter method - */ - var $_msgFrom = null; + /** + * Who sent the Message + * This can be defined via a INI file or via a setter method + */ + private $_msgFrom = null; - /** - * Where are replies and errors to be sent to - * This can be defined via a INI file or via a setter method - */ - var $_msgReplyTo = null; + /** + * Where are replies and errors to be sent to + * This can be defined via a INI file or via a setter method + */ + private $_msgReplyTo = null; - /** - * Who will the Message be sent to; TO, CC, BCC - * Multi-diminsional array containg addresses the message will - * be sent TO, CC or BCC - */ - var $_msgRecipients = null; + /** + * Who will the Message be sent to; TO, CC, BCC + * Multi-diminsional array containg addresses the message will + * be sent TO, CC or BCC + */ + private $_msgRecipients = null; - /** - * Message Subject - */ - var $_msgSubject = null; + /** + * Message Subject + */ + private $_msgSubject = null; - /** - * Message Content - */ - var $_msgContent = null; + /** + * Message Content + */ + private $_msgContent = null; - /** - * Custom X-Headers - */ - var $_msgXheader = null; + /** + * Custom X-Headers + */ + private $_msgXheader = null; - /** - * Character set - * Defaulted to 'iso-8859-1' - */ - var $_smtpsCharSet = 'iso-8859-1'; + /** + * Character set + * Defaulted to 'iso-8859-1' + */ + private $_smtpsCharSet = 'iso-8859-1'; - /** - * Message Sensitivity - * Defaults to ZERO - None - */ - var $_msgSensitivity = 0; + /** + * Message Sensitivity + * Defaults to ZERO - None + */ + private $_msgSensitivity = 0; - /** - * Message Sensitivity - */ - var $_arySensitivity = array ( false, + /** + * Message Sensitivity + */ + private $_arySensitivity = array ( false, 'Personal', 'Private', 'Company Confidential' ); - /** - * Message Sensitivity - * Defaults to 3 - Normal - */ - var $_msgPriority = 3; + /** + * Message Sensitivity + * Defaults to 3 - Normal + */ + private $_msgPriority = 3; - /** - * Message Priority - */ - var $_aryPriority = array ( 'Bulk', + /** + * Message Priority + */ + private $_aryPriority = array ( 'Bulk', 'Highest', 'High', 'Normal', 'Low', 'Lowest' ); - /** - * Content-Transfer-Encoding - * Defaulted to 0 - 7bit - */ - var $_smtpsTransEncodeType = 0; + /** + * Content-Transfer-Encoding + * Defaulted to 0 - 7bit + */ + private $_smtpsTransEncodeType = 0; - /** - * Content-Transfer-Encoding - */ - var $_smtpsTransEncodeTypes = array( '7bit', // Simple 7-bit ASCII + /** + * Content-Transfer-Encoding + */ + private $_smtpsTransEncodeTypes = array( '7bit', // Simple 7-bit ASCII '8bit', // 8-bit coding with line termination characters 'base64', // 3 octets encoded into 4 sextets with offset 'binary', // Arbitrary binary stream @@ -155,78 +155,78 @@ class SMTPs 'quoted-printable', // Mostly 7-bit, with 8-bit characters encoded as "=HH" 'uuencode' ); // UUENCODE encoding - /** - * Content-Transfer-Encoding - * Defaulted to '7bit' - */ - var $_smtpsTransEncode = '7bit'; + /** + * Content-Transfer-Encoding + * Defaulted to '7bit' + */ + private $_smtpsTransEncode = '7bit'; - /** - * Boundary String for MIME seperation - */ - var $_smtpsBoundary = null; + /** + * Boundary String for MIME seperation + */ + private $_smtpsBoundary = null; - /** - * Related Boundary - */ - var $_smtpsRelatedBoundary = null; + /** + * Related Boundary + */ + private $_smtpsRelatedBoundary = null; - /** - * Alternative Boundary - */ - var $_smtpsAlternativeBoundary = null; + /** + * Alternative Boundary + */ + private $_smtpsAlternativeBoundary = null; - /** - * Determines the method inwhich the message are to be sent. - * - 'sockets' [0] - conect via network to SMTP server - default - * - 'pipe [1] - use UNIX path to EXE - * - 'phpmail [2] - use the PHP built-in mail function - * NOTE: Only 'sockets' is implemented - */ - var $_transportType = 0; + /** + * Determines the method inwhich the message are to be sent. + * - 'sockets' [0] - conect via network to SMTP server - default + * - 'pipe [1] - use UNIX path to EXE + * - 'phpmail [2] - use the PHP built-in mail function + * NOTE: Only 'sockets' is implemented + */ + private $_transportType = 0; - /** - * If '$_transportType' is set to '1', then this variable is used - * to define the UNIX file system path to the sendmail execuable - */ - var $_mailPath = '/usr/lib/sendmail'; + /** + * If '$_transportType' is set to '1', then this variable is used + * to define the UNIX file system path to the sendmail execuable + */ + private $_mailPath = '/usr/lib/sendmail'; - /** - * Sets the SMTP server timeout in seconds. - */ - var $_smtpTimeout = 10; + /** + * Sets the SMTP server timeout in seconds. + */ + private $_smtpTimeout = 10; - /** - * Determines whether to calculate message MD5 checksum. - */ - var $_smtpMD5 = false; + /** + * Determines whether to calculate message MD5 checksum. + */ + private $_smtpMD5 = false; - /** - * Class error codes and messages - */ - var $_smtpsErrors = null; + /** + * Class error codes and messages + */ + private $_smtpsErrors = null; - /** - * Defines log level - * 0 - no logging - * 1 - connectivity logging - * 2 - message generation logging - * 3 - detail logging - */ - var $_log_level = 0; + /** + * Defines log level + * 0 - no logging + * 1 - connectivity logging + * 2 - message generation logging + * 3 - detail logging + */ + private $_log_level = 0; - /** - * Place Class in" debug" mode - */ - var $_debug = false; + /** + * Place Class in" debug" mode + */ + private $_debug = false; - // @CHANGE LDR - var $log = ''; - var $_errorsTo = ''; - var $_deliveryReceipt = 0; - var $_trackId = ''; - var $_moreInHeader = ''; + // @CHANGE LDR + private $log = ''; + private $_errorsTo = ''; + private $_deliveryReceipt = 0; + private $_trackId = ''; + private $_moreInHeader = ''; /** @@ -235,20 +235,20 @@ class SMTPs * @param int $_val Value * @return void */ - function setDeliveryReceipt($_val = 0) - { - $this->_deliveryReceipt = $_val; - } + public function setDeliveryReceipt($_val = 0) + { + $this->_deliveryReceipt = $_val; + } /** * get delivery receipt * * @return int Delivery receipt */ - function getDeliveryReceipt() - { - return $this->_deliveryReceipt; - } + public function getDeliveryReceipt() + { + return $this->_deliveryReceipt; + } /** * Set trackid @@ -256,10 +256,10 @@ class SMTPs * @param string $_val Value * @return void */ - function setTrackId($_val = '') - { - $this->_trackId = $_val; - } + public function setTrackId($_val = '') + { + $this->_trackId = $_val; + } /** * Set moreInHeader @@ -267,30 +267,30 @@ class SMTPs * @param string $_val Value * @return void */ - function setMoreInHeader($_val = '') - { - $this->_moreinheader = $_val; - } + public function setMoreInHeader($_val = '') + { + $this->_moreinheader = $_val; + } - /** + /** * get trackid * * @return string Track id */ - function getTrackId() - { - return $this->_trackId; - } + public function getTrackId() + { + return $this->_trackId; + } - /** - * get moreInHeader - * - * @return string moreInHeader - */ - function getMoreInHeader() - { - return $this->_moreinheader; - } + /** + * get moreInHeader + * + * @return string moreInHeader + */ + public function getMoreInHeader() + { + return $this->_moreinheader; + } /** * Set errors to @@ -298,11 +298,11 @@ class SMTPs * @param string $_strErrorsTo Errors to * @return void */ - function setErrorsTo($_strErrorsTo) - { - if ( $_strErrorsTo ) - $this->_errorsTo = $this->_strip_email($_strErrorsTo); - } + public function setErrorsTo($_strErrorsTo) + { + if ( $_strErrorsTo ) + $this->_errorsTo = $this->_strip_email($_strErrorsTo); + } /** * Get errors to @@ -310,1524 +310,1524 @@ class SMTPs * @param boolean $_part Variant * @return string Errors to */ - function getErrorsTo($_part = true) - { - $_retValue = ''; + public function getErrorsTo($_part = true) + { + $_retValue = ''; - if ( $_part === true ) - $_retValue = $this->_errorsTo; - else - $_retValue = $this->_errorsTo[$_part]; + if ( $_part === true ) + $_retValue = $this->_errorsTo; + else + $_retValue = $this->_errorsTo[$_part]; - return $_retValue; - } + return $_retValue; + } - /** - * Set debug - * - * @param boolean $_vDebug Value for debug - * @return void - */ - function setDebug($_vDebug = false) - { - $this->_debug = $_vDebug; - } + /** + * Set debug + * + * @param boolean $_vDebug Value for debug + * @return void + */ + public function setDebug($_vDebug = false) + { + $this->_debug = $_vDebug; + } - /** - * build RECIPIENT List, all addresses who will recieve this message - * - * @return void - */ - function buildRCPTlist() - { - // Pull TO list - $_aryToList = $this->getTO(); - } + /** + * build RECIPIENT List, all addresses who will recieve this message + * + * @return void + */ + public function buildRCPTlist() + { + // Pull TO list + $_aryToList = $this->getTO(); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Attempt a connection to mail server - * - * @return mixed $_retVal Boolean indicating success or failure on connection - */ - function _server_connect() - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Attempt a connection to mail server + * + * @return mixed $_retVal Boolean indicating success or failure on connection + */ + private function _server_connect() + { // phpcs:enable - // Default return value - $_retVal = true; + // Default return value + $_retVal = true; - // We have to make sure the HOST given is valid - // This is done here because '@fsockopen' will not give me this - // information if it failes to connect because it can't find the HOST - $host=$this->getHost(); - $usetls = preg_match('@tls://@i', $host); + // We have to make sure the HOST given is valid + // This is done here because '@fsockopen' will not give me this + // information if it failes to connect because it can't find the HOST + $host=$this->getHost(); + $usetls = preg_match('@tls://@i', $host); - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix + $host=preg_replace('@tcp://@i', '', $host); // Remove prefix + $host=preg_replace('@ssl://@i', '', $host); // Remove prefix + $host=preg_replace('@tls://@i', '', $host); // Remove prefix - // @CHANGE LDR - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + // @CHANGE LDR + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - if ( (! is_ip($host)) && ((gethostbyname($host)) == $host)) - { - $this->_setErr(99, $host . ' is either offline or is an invalid host name.'); - $_retVal = false; - } - else - { - //See if we can connect to the SMTP server + if ( (! is_ip($host)) && ((gethostbyname($host)) == $host)) + { + $this->_setErr(99, $host . ' is either offline or is an invalid host name.'); + $_retVal = false; + } + else + { + //See if we can connect to the SMTP server if ($this->socket = @fsockopen( - preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain - $this->getPort(), // which Port number to use - $this->errno, // actual system level error - $this->errstr, // and any text that goes with the error - $this->_smtpTimeout // timeout for reading/writing data over the socket - )) { - // Fix from PHP SMTP class by 'Chris Ryan' - // Sometimes the SMTP server takes a little longer to respond - // so we will give it a longer timeout for the first read - // Windows still does not have support for this timeout function - if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0); + preg_replace('@tls://@i', '', $this->getHost()), // Host to 'hit', IP or domain + $this->getPort(), // which Port number to use + $this->errno, // actual system level error + $this->errstr, // and any text that goes with the error + $this->_smtpTimeout // timeout for reading/writing data over the socket + )) { + // Fix from PHP SMTP class by 'Chris Ryan' + // Sometimes the SMTP server takes a little longer to respond + // so we will give it a longer timeout for the first read + // Windows still does not have support for this timeout function + if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0); - // Check response from Server - if ( $_retVal = $this->server_parse($this->socket, "220") ) - $_retVal = $this->socket; - } - // This connection attempt failed. - else - { - // @CHANGE LDR - if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); - $this->_setErr($this->errno, $this->errstr); - $_retVal = false; - } - } + // Check response from Server + if ( $_retVal = $this->server_parse($this->socket, "220") ) + $_retVal = $this->socket; + } + // This connection attempt failed. + else + { + // @CHANGE LDR + if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); + $this->_setErr($this->errno, $this->errstr); + $_retVal = false; + } + } - return $_retVal; - } + return $_retVal; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Attempt mail server authentication for a secure connection - * - * @return boolean|null $_retVal Boolean indicating success or failure of authentication - */ - function _server_authenticate() - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Attempt mail server authentication for a secure connection + * + * @return boolean|null $_retVal Boolean indicating success or failure of authentication + */ + private function _server_authenticate() + { // phpcs:enable - global $conf; + global $conf; - // Send the RFC2554 specified EHLO. - // This improvment as provided by 'SirSir' to - // accomodate both SMTP AND ESMTP capable servers - $host=$this->getHost(); - $usetls = preg_match('@tls://@i', $host); + // Send the RFC2554 specified EHLO. + // This improvment as provided by 'SirSir' to + // accomodate both SMTP AND ESMTP capable servers + $host=$this->getHost(); + $usetls = preg_match('@tls://@i', $host); - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix + $host=preg_replace('@tcp://@i', '', $host); // Remove prefix + $host=preg_replace('@ssl://@i', '', $host); // Remove prefix + $host=preg_replace('@tls://@i', '', $host); // Remove prefix - if ($usetls) $host='tls://'.$host; + if ($usetls) $host='tls://'.$host; - $hosth = $host; + $hosth = $host; - if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) - { - // If the from to is 'aaa ', we will keep 'ccc.com' - $hosth = $this->getFrom('addr'); - $hosth = preg_replace('/^.*.*$/', '', $hosth); - $hosth = preg_replace('/.*@/', '', $hosth); - } + if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) + { + // If the from to is 'aaa ', we will keep 'ccc.com' + $hosth = $this->getFrom('addr'); + $hosth = preg_replace('/^.*.*$/', '', $hosth); + $hosth = preg_replace('/.*@/', '', $hosth); + } - if ( $_retVal = $this->socket_send_str('EHLO ' . $hosth, '250') ) - { - if ($usetls) - { - /* - The following dialog illustrates how a client and server can start a TLS STARTTLS session - S: - C: - S: 220 mail.imc.org SMTP service ready - C: EHLO mail.ietf.org - S: 250-mail.imc.org offers a warm hug of welcome - S: 250 STARTTLS - C: STARTTLS - S: 220 Go ahead - C: - C & S: - C & S: + if ( $_retVal = $this->socket_send_str('EHLO ' . $hosth, '250') ) + { + if ($usetls) + { + /* + The following dialog illustrates how a client and server can start a TLS STARTTLS session + S: + C: + S: 220 mail.imc.org SMTP service ready + C: EHLO mail.ietf.org + S: 250-mail.imc.org offers a warm hug of welcome + S: 250 STARTTLS + C: STARTTLS + S: 220 Go ahead + C: + C & S: + C & S: // Second pass EHLO C: EHLO client-domain.com S: 250-server-domain.com S: 250 AUTH LOGIN - C: socket_send_str('STARTTLS', 220)) - { - $this->_setErr(131, 'STARTTLS connection is not supported.'); - return $_retVal; - } + C: socket_send_str('STARTTLS', 220)) + { + $this->_setErr(131, 'STARTTLS connection is not supported.'); + return $_retVal; + } - // Before 5.6.7: - // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_SSLv2_CLIENT|STREAM_CRYPTO_METHOD_SSLv3_CLIENT - // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT - // PHP >= 5.6.7: - // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT - // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT + // Before 5.6.7: + // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_SSLv2_CLIENT|STREAM_CRYPTO_METHOD_SSLv3_CLIENT + // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT + // PHP >= 5.6.7: + // STREAM_CRYPTO_METHOD_SSLv23_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT + // STREAM_CRYPTO_METHOD_TLS_CLIENT = STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT - $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; - if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { - $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; - $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; - } + $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; + if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { + $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; + $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; + } - if (!stream_socket_enable_crypto($this->socket, true, $crypto_method)) - { - $this->_setErr(132, 'STARTTLS connection failed.'); - return $_retVal; - } - // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time - // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. - if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250')) - { - $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); - return $_retVal; - } - } - // Send Authentication to Server - // Check for errors along the way - $this->socket_send_str('AUTH LOGIN', '334'); + if (!stream_socket_enable_crypto($this->socket, true, $crypto_method)) + { + $this->_setErr(132, 'STARTTLS connection failed.'); + return $_retVal; + } + // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time + // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. + if (!$_retVal = $this->socket_send_str('EHLO '.$host, '250')) + { + $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); + return $_retVal; + } + } + // Send Authentication to Server + // Check for errors along the way + $this->socket_send_str('AUTH LOGIN', '334'); - // User name will not return any error, server will take anything we give it. - $this->socket_send_str(base64_encode($this->_smtpsID), '334'); + // User name will not return any error, server will take anything we give it. + $this->socket_send_str(base64_encode($this->_smtpsID), '334'); - // The error here just means the ID/password combo doesn't work. - // There is not a method to determine which is the problem, ID or password - if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) - $this->_setErr(130, 'Invalid Authentication Credentials.'); - } - else - { - $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); - } + // The error here just means the ID/password combo doesn't work. + // There is not a method to determine which is the problem, ID or password + if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) + $this->_setErr(130, 'Invalid Authentication Credentials.'); + } + else + { + $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); + } - return $_retVal; - } + return $_retVal; + } - /** - * Now send the message - * - * @param boolean $_bolTestMsg whether to run this method in 'Test' mode. - * @param boolean $_bolDebug whether to log all communication between this Class and the Mail Server. - * @return boolean|null void - * $_strMsg If this is run in 'Test' mode, the actual message structure will be returned - */ - function sendMsg($_bolTestMsg = false, $_bolDebug = false) - { - global $conf; + /** + * Now send the message + * + * @param boolean $_bolTestMsg whether to run this method in 'Test' mode. + * @param boolean $_bolDebug whether to log all communication between this Class and the Mail Server. + * @return boolean|null void + * $_strMsg If this is run in 'Test' mode, the actual message structure will be returned + */ + public function sendMsg($_bolTestMsg = false, $_bolDebug = false) + { + global $conf; - /** - * Default return value - */ - $_retVal = false; + /** + * Default return value + */ + $_retVal = false; - // Connect to Server - if ( $this->socket = $this->_server_connect() ) - { - // If a User ID *and* a password is given, assume Authentication is desired - if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) ) - { - // Send the RFC2554 specified EHLO. - $_retVal = $this->_server_authenticate(); - } + // Connect to Server + if ( $this->socket = $this->_server_connect() ) + { + // If a User ID *and* a password is given, assume Authentication is desired + if( !empty($this->_smtpsID) && !empty($this->_smtpsPW) ) + { + // Send the RFC2554 specified EHLO. + $_retVal = $this->_server_authenticate(); + } - // This is a "normal" SMTP Server "handshack" - else - { - // Send the RFC821 specified HELO. - $host=$this->getHost(); - $usetls = preg_match('@tls://@i', $host); + // This is a "normal" SMTP Server "handshack" + else + { + // Send the RFC821 specified HELO. + $host=$this->getHost(); + $usetls = preg_match('@tls://@i', $host); - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix + $host=preg_replace('@tcp://@i', '', $host); // Remove prefix + $host=preg_replace('@ssl://@i', '', $host); // Remove prefix + $host=preg_replace('@tls://@i', '', $host); // Remove prefix - $hosth = $host; + $hosth = $host; - if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) - { - // If the from to is 'aaa ', we will keep 'ccc.com' - $hosth = $this->getFrom('addr'); - $hosth = preg_replace('/^.*.*$/', '', $hosth); - $hosth = preg_replace('/.*@/', '', $hosth); - } + if (! empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) + { + // If the from to is 'aaa ', we will keep 'ccc.com' + $hosth = $this->getFrom('addr'); + $hosth = preg_replace('/^.*.*$/', '', $hosth); + $hosth = preg_replace('/.*@/', '', $hosth); + } - $_retVal = $this->socket_send_str('HELO ' . $hosth, '250'); - } + $_retVal = $this->socket_send_str('HELO ' . $hosth, '250'); + } - // Well, did we get to the server? - if ( $_retVal ) - { - // From this point onward most server response codes should be 250 - // Specify who the mail is from.... - // This has to be the raw email address, strip the "name" off - $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250'); + // Well, did we get to the server? + if ( $_retVal ) + { + // From this point onward most server response codes should be 250 + // Specify who the mail is from.... + // This has to be the raw email address, strip the "name" off + $this->socket_send_str('MAIL FROM: ' . $this->getFrom('addr'), '250'); - // 'RCPT TO:' must be given a single address, so this has to loop - // through the list of addresses, regardless of TO, CC or BCC - // and send it out "single file" - foreach ($this->get_RCPT_list() as $_address) - { - /* Note: - * BCC email addresses must be listed in the RCPT TO command list, + // 'RCPT TO:' must be given a single address, so this has to loop + // through the list of addresses, regardless of TO, CC or BCC + // and send it out "single file" + foreach ($this->get_RCPT_list() as $_address) + { + /* Note: + * BCC email addresses must be listed in the RCPT TO command list, * but the BCC header should not be printed under the DATA command. - * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server - */ + * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server + */ - /* - * TODO - * After each 'RCPT TO:' is sent, we need to make sure it was kosher, - * if not, the whole message will fail - * If any email address fails, we will need to RESET the connection, - * mark the last address as "bad" and start the address loop over again. - * If any address fails, the entire message fails. - */ - $this->socket_send_str('RCPT TO: <' . $_address . '>', '250'); - } + /* + * TODO + * After each 'RCPT TO:' is sent, we need to make sure it was kosher, + * if not, the whole message will fail + * If any email address fails, we will need to RESET the connection, + * mark the last address as "bad" and start the address loop over again. + * If any address fails, the entire message fails. + */ + $this->socket_send_str('RCPT TO: <' . $_address . '>', '250'); + } - // Tell the server we are ready to start sending data - // with any custom headers... - // This is the last response code we look for until the end of the message. - $this->socket_send_str('DATA', '354'); + // Tell the server we are ready to start sending data + // with any custom headers... + // This is the last response code we look for until the end of the message. + $this->socket_send_str('DATA', '354'); - // Now we are ready for the message... - // Ok, all the ingredients are mixed in let's cook this puppy... - $this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250'); + // Now we are ready for the message... + // Ok, all the ingredients are mixed in let's cook this puppy... + $this->socket_send_str($this->getHeader().$this->getBodyContent() . "\r\n" . '.', '250'); - // Now tell the server we are done and close the socket... - fputs($this->socket, 'QUIT'); - fclose($this->socket); - } - } + // Now tell the server we are done and close the socket... + fputs($this->socket, 'QUIT'); + fclose($this->socket); + } + } - return $_retVal; - } + return $_retVal; + } - // ============================================================= - // ** Setter & Getter methods + // ============================================================= + // ** Setter & Getter methods - // ** Basic System configuration + // ** Basic System configuration - /** - * setConfig() is used to populate select class properties from either - * a user defined INI file or the systems 'php.ini' file - * - * If a user defined INI is to be used, the files complete path is passed - * as the method single parameter. The INI can define any class and/or - * user properties. Only properties defined within this file will be setter - * and/or orverwritten - * - * If the systems 'php.ini' file is to be used, the method is called without - * parameters. In this case, only HOST, PORT and FROM properties will be set - * as they are the only properties that are defined within the 'php.ini'. - * - * If secure SMTP is to be used, the user ID and Password can be defined with - * the user INI file, but the properties are not defined with the systems - * 'php.ini'file, they must be defined via their setter methods - * - * This method can be called twice, if desired. Once without a parameter to - * load the properties as defined within the systems 'php.ini' file, and a - * second time, with a path to a user INI file for other properties to be - * defined. - * - * @param mixed $_strConfigPath path to config file or VOID - * @return boolean - */ - function setConfig($_strConfigPath = null) - { - /** - * Returns constructed SELECT Object string or boolean upon failure - * Default value is set at true - */ - $_retVal = true; + /** + * setConfig() is used to populate select class properties from either + * a user defined INI file or the systems 'php.ini' file + * + * If a user defined INI is to be used, the files complete path is passed + * as the method single parameter. The INI can define any class and/or + * user properties. Only properties defined within this file will be setter + * and/or orverwritten + * + * If the systems 'php.ini' file is to be used, the method is called without + * parameters. In this case, only HOST, PORT and FROM properties will be set + * as they are the only properties that are defined within the 'php.ini'. + * + * If secure SMTP is to be used, the user ID and Password can be defined with + * the user INI file, but the properties are not defined with the systems + * 'php.ini'file, they must be defined via their setter methods + * + * This method can be called twice, if desired. Once without a parameter to + * load the properties as defined within the systems 'php.ini' file, and a + * second time, with a path to a user INI file for other properties to be + * defined. + * + * @param mixed $_strConfigPath path to config file or VOID + * @return boolean + */ + public function setConfig($_strConfigPath = null) + { + /** + * Returns constructed SELECT Object string or boolean upon failure + * Default value is set at true + */ + $_retVal = true; - // if we have a path... - if ( ! empty($_strConfigPath) ) - { - // If the path is not valid, this will NOT generate an error, - // it will simply return false. - if ( ! @include $_strConfigPath) - { - $this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.'); - $_retVal = false; - } - } + // if we have a path... + if ( ! empty($_strConfigPath) ) + { + // If the path is not valid, this will NOT generate an error, + // it will simply return false. + if ( ! @include $_strConfigPath) + { + $this->_setErr(110, '"' . $_strConfigPath . '" is not a valid path.'); + $_retVal = false; + } + } - // Read the Systems php.ini file - else - { - // Set these properties ONLY if they are set in the php.ini file. - // Otherwise the default values will be used. - if ( $_host = ini_get('SMTPs') ) - $this->setHost($_host); + // Read the Systems php.ini file + else + { + // Set these properties ONLY if they are set in the php.ini file. + // Otherwise the default values will be used. + if ( $_host = ini_get('SMTPs') ) + $this->setHost($_host); - if ( $_port = ini_get('smtp_port') ) - $this->setPort($_port); + if ( $_port = ini_get('smtp_port') ) + $this->setPort($_port); - if ( $_from = ini_get('sendmail_from') ) - $this->setFrom($_from); - } + if ( $_from = ini_get('sendmail_from') ) + $this->setFrom($_from); + } - // Send back what we have - return $_retVal; - } + // Send back what we have + return $_retVal; + } - /** - * Determines the method inwhich the messages are to be sent. - * - 'sockets' [0] - conect via network to SMTP server - * - 'pipe [1] - use UNIX path to EXE - * - 'phpmail [2] - use the PHP built-in mail function - * - * @param int $_type Interger value representing Mail Transport Type - * @return void - */ - function setTransportType($_type = 0) - { - if ( ( is_numeric($_type) ) && - ( ( $_type >= 0 ) && ( $_type <= 3 ) ) ) - $this->_transportType = $_type; - } + /** + * Determines the method inwhich the messages are to be sent. + * - 'sockets' [0] - conect via network to SMTP server + * - 'pipe [1] - use UNIX path to EXE + * - 'phpmail [2] - use the PHP built-in mail function + * + * @param int $_type Interger value representing Mail Transport Type + * @return void + */ + public function setTransportType($_type = 0) + { + if ((is_numeric($_type)) && (($_type >= 0) && ($_type <= 3))) { + $this->_transportType = $_type; + } + } - /** - * Return the method inwhich the message is to be sent. - * - 'sockets' [0] - conect via network to SMTP server - * - 'pipe [1] - use UNIX path to EXE - * - 'phpmail [2] - use the PHP built-in mail function - * - * @return int $_strHost Host Name or IP of the Mail Server to use - */ - function getTransportType() - { - return $this->_transportType; - } + /** + * Return the method inwhich the message is to be sent. + * - 'sockets' [0] - conect via network to SMTP server + * - 'pipe [1] - use UNIX path to EXE + * - 'phpmail [2] - use the PHP built-in mail function + * + * @return int $_strHost Host Name or IP of the Mail Server to use + */ + public function getTransportType() + { + return $this->_transportType; + } - /** - * Path to the sendmail execuable - * - * @param string $_path Path to the sendmail execuable - * @return boolean - * - */ - function setMailPath($_path) - { - // This feature is not yet implemented - return true; + /** + * Path to the sendmail execuable + * + * @param string $_path Path to the sendmail execuable + * @return boolean + * + */ + public function setMailPath($_path) + { + // This feature is not yet implemented + return true; - //if ( $_path ) $this->_mailPath = $_path; - } + //if ( $_path ) $this->_mailPath = $_path; + } - /** - * Defines the Host Name or IP of the Mail Server to use. - * This is defaulted to 'localhost' - * This is used only with 'socket' based mail transmission - * - * @param string $_strHost Host Name or IP of the Mail Server to use - * @return void - */ - function setHost($_strHost) - { - if ( $_strHost ) - $this->_smtpsHost = $_strHost; - } + /** + * Defines the Host Name or IP of the Mail Server to use. + * This is defaulted to 'localhost' + * This is used only with 'socket' based mail transmission + * + * @param string $_strHost Host Name or IP of the Mail Server to use + * @return void + */ + public function setHost($_strHost) + { + if ( $_strHost ) + $this->_smtpsHost = $_strHost; + } - /** - * Retrieves the Host Name or IP of the Mail Server to use - * This is used only with 'socket' based mail transmission - * - * @return string $_strHost Host Name or IP of the Mail Server to use - */ - function getHost() - { - return $this->_smtpsHost; - } + /** + * Retrieves the Host Name or IP of the Mail Server to use + * This is used only with 'socket' based mail transmission + * + * @return string $_strHost Host Name or IP of the Mail Server to use + */ + public function getHost() + { + return $this->_smtpsHost; + } - /** - * Defines the Port Number of the Mail Server to use - * This is defaulted to '25' - * This is used only with 'socket' based mail transmission - * - * @param int $_intPort Port Number of the Mail Server to use - * @return void - */ - function setPort($_intPort) - { - if ( ( is_numeric($_intPort) ) && - ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) - $this->_smtpsPort = $_intPort; - } + /** + * Defines the Port Number of the Mail Server to use + * This is defaulted to '25' + * This is used only with 'socket' based mail transmission + * + * @param int $_intPort Port Number of the Mail Server to use + * @return void + */ + public function setPort($_intPort) + { + if ( ( is_numeric($_intPort) ) && + ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) + $this->_smtpsPort = $_intPort; + } - /** - * Retrieves the Port Number of the Mail Server to use - * This is used only with 'socket' based mail transmission - * - * @return string Port Number of the Mail Server to use - */ - function getPort() - { - return $this->_smtpsPort; - } + /** + * Retrieves the Port Number of the Mail Server to use + * This is used only with 'socket' based mail transmission + * + * @return string Port Number of the Mail Server to use + */ + public function getPort() + { + return $this->_smtpsPort; + } - /** - * User Name for authentication on Mail Server - * - * @param string $_strID User Name for authentication on Mail Server - * @return void - */ - function setID($_strID) - { - $this->_smtpsID = $_strID; - } + /** + * User Name for authentication on Mail Server + * + * @param string $_strID User Name for authentication on Mail Server + * @return void + */ + public function setID($_strID) + { + $this->_smtpsID = $_strID; + } - /** - * Retrieves the User Name for authentication on Mail Server - * - * @return string User Name for authentication on Mail Server - */ - function getID() - { - return $this->_smtpsID; - } + /** + * Retrieves the User Name for authentication on Mail Server + * + * @return string User Name for authentication on Mail Server + */ + public function getID() + { + return $this->_smtpsID; + } - /** - * User Password for authentication on Mail Server - * - * @param string $_strPW User Password for authentication on Mail Server - * @return void - */ - function setPW($_strPW) - { - $this->_smtpsPW = $_strPW; - } + /** + * User Password for authentication on Mail Server + * + * @param string $_strPW User Password for authentication on Mail Server + * @return void + */ + public function setPW($_strPW) + { + $this->_smtpsPW = $_strPW; + } - /** - * Retrieves the User Password for authentication on Mail Server - * - * @return string User Password for authentication on Mail Server - */ - function getPW() - { - return $this->_smtpsPW; - } + /** + * Retrieves the User Password for authentication on Mail Server + * + * @return string User Password for authentication on Mail Server + */ + public function getPW() + { + return $this->_smtpsPW; + } - /** - * Character set used for current message - * Character set is defaulted to 'iso-8859-1'; - * - * @param string $_strCharSet Character set used for current message - * @return void - */ - function setCharSet($_strCharSet) - { - if ( $_strCharSet ) - $this->_smtpsCharSet = $_strCharSet; - } + /** + * Character set used for current message + * Character set is defaulted to 'iso-8859-1'; + * + * @param string $_strCharSet Character set used for current message + * @return void + */ + public function setCharSet($_strCharSet) + { + if ( $_strCharSet ) + $this->_smtpsCharSet = $_strCharSet; + } - /** - * Retrieves the Character set used for current message - * - * @return string $_smtpsCharSet Character set used for current message - */ - function getCharSet() - { - return $this->_smtpsCharSet; - } + /** + * Retrieves the Character set used for current message + * + * @return string $_smtpsCharSet Character set used for current message + */ + public function getCharSet() + { + return $this->_smtpsCharSet; + } - /** - * Content-Transfer-Encoding, Defaulted to '7bit' - * This can be changed for 2byte characers sets - * Known Encode Types - * - 7bit Simple 7-bit ASCII - * - 8bit 8-bit coding with line termination characters - * - base64 3 octets encoded into 4 sextets with offset - * - binary Arbitrary binary stream - * - mac-binhex40 Macintosh binary to hex encoding - * - quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH" - * - uuencode UUENCODE encoding - * - * @param string $_strTransEncode Content-Transfer-Encoding - * @return void - */ - function setTransEncode($_strTransEncode) - { - if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) - $this->_smtpsTransEncode = $_strTransEncode; - } + /** + * Content-Transfer-Encoding, Defaulted to '7bit' + * This can be changed for 2byte characers sets + * Known Encode Types + * - 7bit Simple 7-bit ASCII + * - 8bit 8-bit coding with line termination characters + * - base64 3 octets encoded into 4 sextets with offset + * - binary Arbitrary binary stream + * - mac-binhex40 Macintosh binary to hex encoding + * - quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH" + * - uuencode UUENCODE encoding + * + * @param string $_strTransEncode Content-Transfer-Encoding + * @return void + */ + public function setTransEncode($_strTransEncode) + { + if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) + $this->_smtpsTransEncode = $_strTransEncode; + } - /** - * Retrieves the Content-Transfer-Encoding - * - * @return string $_smtpsTransEncode Content-Transfer-Encoding - */ - function getTransEncode() - { - return $this->_smtpsTransEncode; - } + /** + * Retrieves the Content-Transfer-Encoding + * + * @return string $_smtpsTransEncode Content-Transfer-Encoding + */ + public function getTransEncode() + { + return $this->_smtpsTransEncode; + } - /** - * Content-Transfer-Encoding, Defaulted to '0' [ZERO] - * This can be changed for 2byte characers sets - * Known Encode Types - * - [0] 7bit Simple 7-bit ASCII - * - [1] 8bit 8-bit coding with line termination characters - * - [2] base64 3 octets encoded into 4 sextets with offset - * - [3] binary Arbitrary binary stream - * - [4] mac-binhex40 Macintosh binary to hex encoding - * - [5] quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH" - * - [6] uuencode UUENCODE encoding - * - * @param string $_strTransEncodeType Content-Transfer-Encoding - * @return void - * - */ - function setTransEncodeType($_strTransEncodeType) - { - if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) - $this->_smtpsTransEncodeType = $_strTransEncodeType; - } + /** + * Content-Transfer-Encoding, Defaulted to '0' [ZERO] + * This can be changed for 2byte characers sets + * Known Encode Types + * - [0] 7bit Simple 7-bit ASCII + * - [1] 8bit 8-bit coding with line termination characters + * - [2] base64 3 octets encoded into 4 sextets with offset + * - [3] binary Arbitrary binary stream + * - [4] mac-binhex40 Macintosh binary to hex encoding + * - [5] quoted-printable Mostly 7-bit, with 8-bit characters encoded as "=HH" + * - [6] uuencode UUENCODE encoding + * + * @param string $_strTransEncodeType Content-Transfer-Encoding + * @return void + * + */ + public function setTransEncodeType($_strTransEncodeType) + { + if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) + $this->_smtpsTransEncodeType = $_strTransEncodeType; + } - /** - * Retrieves the Content-Transfer-Encoding - * - * @return string Content-Transfer-Encoding - */ - function getTransEncodeType() - { - return $this->_smtpsTransEncodeTypes[$this->_smtpsTransEncodeType]; - } + /** + * Retrieves the Content-Transfer-Encoding + * + * @return string Content-Transfer-Encoding + */ + public function getTransEncodeType() + { + return $this->_smtpsTransEncodeTypes[$this->_smtpsTransEncodeType]; + } - // ** Message Construction + // ** Message Construction - /** - * FROM Address from which mail will be sent - * - * @param string $_strFrom Address from which mail will be sent - * @return void - */ - function setFrom($_strFrom) - { - if ( $_strFrom ) - $this->_msgFrom = $this->_strip_email($_strFrom); - } + /** + * FROM Address from which mail will be sent + * + * @param string $_strFrom Address from which mail will be sent + * @return void + */ + public function setFrom($_strFrom) + { + if ( $_strFrom ) + $this->_msgFrom = $this->_strip_email($_strFrom); + } - /** - * Retrieves the Address from which mail will be sent - * - * @param boolean $_part To "strip" 'Real name' from address - * @return string Address from which mail will be sent - */ - function getFrom($_part = true) - { - $_retValue = ''; + /** + * Retrieves the Address from which mail will be sent + * + * @param boolean $_part To "strip" 'Real name' from address + * @return string Address from which mail will be sent + */ + public function getFrom($_part = true) + { + $_retValue = ''; - if ( $_part === true ) - $_retValue = $this->_msgFrom; - else - $_retValue = $this->_msgFrom[$_part]; + if ( $_part === true ) + $_retValue = $this->_msgFrom; + else + $_retValue = $this->_msgFrom[$_part]; - return $_retValue; - } + return $_retValue; + } - /** - * Reply-To Address from which mail will be the reply-to - * - * @param string $_strReplyTo Address from which mail will be the reply-to - * @return void - */ - function setReplyTo($_strReplyTo) - { - if ( $_strReplyTo ) - $this->_msgReplyTo = $this->_strip_email($_strReplyTo); - } + /** + * Reply-To Address from which mail will be the reply-to + * + * @param string $_strReplyTo Address from which mail will be the reply-to + * @return void + */ + public function setReplyTo($_strReplyTo) + { + if ( $_strReplyTo ) + $this->_msgReplyTo = $this->_strip_email($_strReplyTo); + } - /** - * Retrieves the Address from which mail will be the reply-to - * - * @param boolean $_part To "strip" 'Real name' from address - * @return string Address from which mail will be the reply-to - */ - function getReplyTo($_part = true) - { - $_retValue = ''; + /** + * Retrieves the Address from which mail will be the reply-to + * + * @param boolean $_part To "strip" 'Real name' from address + * @return string Address from which mail will be the reply-to + */ + public function getReplyTo($_part = true) + { + $_retValue = ''; - if ( $_part === true ) - $_retValue = $this->_msgReplyTo; - else - $_retValue = $this->_msgReplyTo[$_part]; + if ( $_part === true ) + $_retValue = $this->_msgReplyTo; + else + $_retValue = $this->_msgReplyTo[$_part]; - return $_retValue; - } + return $_retValue; + } - /** - * Inserts given addresses into structured format. - * This method takes a list of given addresses, via an array - * or a COMMA delimted string, and inserts them into a highly - * structured array. This array is designed to remove duplicate - * addresses and to sort them by Domain. - * - * @param string $_type TO, CC, or BCC lists to add addrresses into - * @param mixed $_addrList Array or COMMA delimited string of addresses - * @return void - * - */ - function _buildAddrList($_type, $_addrList) - { - // Pull existing list - $aryHost = $this->_msgRecipients; + /** + * Inserts given addresses into structured format. + * This method takes a list of given addresses, via an array + * or a COMMA delimted string, and inserts them into a highly + * structured array. This array is designed to remove duplicate + * addresses and to sort them by Domain. + * + * @param string $_type TO, CC, or BCC lists to add addrresses into + * @param mixed $_addrList Array or COMMA delimited string of addresses + * @return void + * + */ + private function _buildAddrList($_type, $_addrList) + { + // Pull existing list + $aryHost = $this->_msgRecipients; - // Only run this if we have something - if ( !empty($_addrList)) - { - // $_addrList can be a STRING or an array - if ( is_string($_addrList) ) - { - // This could be a COMMA delimited string - if ( strstr($_addrList, ',') ) - // "explode "list" into an array - $_addrList = explode(',', $_addrList); + // Only run this if we have something + if ( !empty($_addrList)) + { + // $_addrList can be a STRING or an array + if ( is_string($_addrList) ) + { + // This could be a COMMA delimited string + if ( strstr($_addrList, ',') ) + // "explode "list" into an array + $_addrList = explode(',', $_addrList); - // Stick it in an array - else - $_addrList = array($_addrList); - } + // Stick it in an array + else + $_addrList = array($_addrList); + } - // take the array of addresses and split them further - foreach ($_addrList as $_strAddr) - { - // Strip off the end '>' - $_strAddr = str_replace('>', '', $_strAddr); + // take the array of addresses and split them further + foreach ($_addrList as $_strAddr) + { + // Strip off the end '>' + $_strAddr = str_replace('>', '', $_strAddr); - // Seperate "Real Name" from eMail address - $_tmpaddr = null; - $_tmpaddr = explode('<', $_strAddr); + // Seperate "Real Name" from eMail address + $_tmpaddr = null; + $_tmpaddr = explode('<', $_strAddr); - // We have a "Real Name" and eMail address - if ( count($_tmpaddr) == 2 ) - { - $_tmpHost = explode('@', $_tmpaddr[1]); - $_tmpaddr[0] = trim($_tmpaddr[0], ' ">'); - $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = $_tmpaddr[0]; - } - // We only have an eMail address - else - { - // Strip off the beggining '<' - $_strAddr = str_replace('<', '', $_strAddr); + // We have a "Real Name" and eMail address + if ( count($_tmpaddr) == 2 ) + { + $_tmpHost = explode('@', $_tmpaddr[1]); + $_tmpaddr[0] = trim($_tmpaddr[0], ' ">'); + $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = $_tmpaddr[0]; + } + // We only have an eMail address + else + { + // Strip off the beggining '<' + $_strAddr = str_replace('<', '', $_strAddr); - $_tmpHost = explode('@', $_strAddr); - $_tmpHost[0] = trim($_tmpHost[0]); - $_tmpHost[1] = trim($_tmpHost[1]); + $_tmpHost = explode('@', $_strAddr); + $_tmpHost[0] = trim($_tmpHost[0]); + $_tmpHost[1] = trim($_tmpHost[1]); - $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = ''; - } - } - } - // replace list - $this->_msgRecipients = $aryHost; - } + $aryHost[$_tmpHost[1]][$_type][$_tmpHost[0]] = ''; + } + } + } + // replace list + $this->_msgRecipients = $aryHost; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Returns an array of the various parts of an email address - * This assumes a well formed address: - * - "Real name" - * - "Real Name" is optional - * - if "Real Name" does not exist, the angle brackets are optional - * This will split an email address into 4 or 5 parts. - * - $_aryEmail[org] = orignal string - * - $_aryEmail[real] = "real name" - if there is one - * - $_aryEmail[addr] = address part "username@domain.tld" - * - $_aryEmail[host] = "domain.tld" - * - $_aryEmail[user] = "userName" - * - * @param string $_strAddr Email address - * @return array An array of the various parts of an email address - */ - function _strip_email($_strAddr) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns an array of the various parts of an email address + * This assumes a well formed address: + * - "Real name" + * - "Real Name" is optional + * - if "Real Name" does not exist, the angle brackets are optional + * This will split an email address into 4 or 5 parts. + * - $_aryEmail[org] = orignal string + * - $_aryEmail[real] = "real name" - if there is one + * - $_aryEmail[addr] = address part "username@domain.tld" + * - $_aryEmail[host] = "domain.tld" + * - $_aryEmail[user] = "userName" + * + * @param string $_strAddr Email address + * @return array An array of the various parts of an email address + */ + private function _strip_email($_strAddr) + { // phpcs:enable - // Keep the orginal - $_aryEmail['org'] = $_strAddr; + // Keep the orginal + $_aryEmail['org'] = $_strAddr; - // Set entire string to Lower Case - $_strAddr = strtolower($_strAddr); + // Set entire string to Lower Case + $_strAddr = strtolower($_strAddr); - // Drop "stuff' off the end - $_strAddr = trim($_strAddr, ' ">'); + // Drop "stuff' off the end + $_strAddr = trim($_strAddr, ' ">'); - // Seperate "Real Name" from eMail address, if we have one - $_tmpAry = explode('<', $_strAddr); + // Seperate "Real Name" from eMail address, if we have one + $_tmpAry = explode('<', $_strAddr); - // Do we have a "Real name" - if ( count($_tmpAry) == 2 ) - { - // We may not really have a "Real Name" - if ( $_tmpAry[0]) - $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); + // Do we have a "Real name" + if ( count($_tmpAry) == 2 ) + { + // We may not really have a "Real Name" + if ( $_tmpAry[0]) + $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); - $_aryEmail['addr'] = $_tmpAry[1]; - } - else - $_aryEmail['addr'] = $_tmpAry[0]; + $_aryEmail['addr'] = $_tmpAry[1]; + } + else + $_aryEmail['addr'] = $_tmpAry[0]; - // Pull User Name and Host.tld apart - list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']); + // Pull User Name and Host.tld apart + list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']); - // Put the brackets back around the address - $_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>'; + // Put the brackets back around the address + $_aryEmail['addr'] = '<' . $_aryEmail['addr'] . '>'; - return $_aryEmail; - } + return $_aryEmail; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Returns an array of bares addresses for use with 'RCPT TO:' - * This is a "build as you go" method. Each time this method is called - * the underlaying array is destroyed and reconstructed. - * - * @return array Returns an array of bares addresses - */ - function get_RCPT_list() - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns an array of bares addresses for use with 'RCPT TO:' + * This is a "build as you go" method. Each time this method is called + * the underlaying array is destroyed and reconstructed. + * + * @return array Returns an array of bares addresses + */ + public function get_RCPT_list() + { // phpcs:enable - /** - * An array of bares addresses for use with 'RCPT TO:' - */ - $_RCPT_list=array(); + /** + * An array of bares addresses for use with 'RCPT TO:' + */ + $_RCPT_list=array(); - // walk down Recipients array and pull just email addresses - foreach ($this->_msgRecipients as $_host => $_list) - { - foreach ($_list as $_subList) - { - foreach ($_subList as $_name => $_addr) - { - // build RCPT list - $_RCPT_list[] = $_name . '@' . $_host; - } - } - } + // walk down Recipients array and pull just email addresses + foreach ($this->_msgRecipients as $_host => $_list) + { + foreach ($_list as $_subList) + { + foreach ($_subList as $_name => $_addr) + { + // build RCPT list + $_RCPT_list[] = $_name . '@' . $_host; + } + } + } - return $_RCPT_list; - } + return $_RCPT_list; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Returns an array of addresses for a specific type; TO, CC or BCC - * - * @param string $_which Which collection of addresses to return ('to', 'cc', 'bcc') - * @return string|false Array of emaill address - */ - function get_email_list($_which = null) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Returns an array of addresses for a specific type; TO, CC or BCC + * + * @param string $_which Which collection of addresses to return ('to', 'cc', 'bcc') + * @return string|false Array of emaill address + */ + public function get_email_list($_which = null) + { // phpcs:enable - // We need to know which address segment to pull - if ( $_which ) - { - // Make sure we have addresses to process - if ( $this->_msgRecipients ) - { - $_RCPT_list=array(); - // walk down Recipients array and pull just email addresses - foreach ($this->_msgRecipients as $_host => $_list) - { - if ( $this->_msgRecipients[$_host][$_which] ) - { - foreach ($this->_msgRecipients[$_host][$_which] as $_addr => $_realName) - { - if ( $_realName ) // @CHANGE LDR - { - $_realName = '"' . $_realName . '"'; - $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; - } - else - { - $_RCPT_list[] = $_addr . '@' . $_host; - } - } - } - } + // We need to know which address segment to pull + if ( $_which ) + { + // Make sure we have addresses to process + if ( $this->_msgRecipients ) + { + $_RCPT_list=array(); + // walk down Recipients array and pull just email addresses + foreach ($this->_msgRecipients as $_host => $_list) + { + if ( $this->_msgRecipients[$_host][$_which] ) + { + foreach ($this->_msgRecipients[$_host][$_which] as $_addr => $_realName) + { + if ( $_realName ) // @CHANGE LDR + { + $_realName = '"' . $_realName . '"'; + $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; + } + else + { + $_RCPT_list[] = $_addr . '@' . $_host; + } + } + } + } - return implode(', ', $_RCPT_list); - } - else - { - $this->_setErr(101, 'No eMail Address for message to be sent to.'); - return false; - } - } - else - { - $this->_setErr(102, 'eMail type not defined.'); - return false; - } - } + return implode(', ', $_RCPT_list); + } + else + { + $this->_setErr(101, 'No eMail Address for message to be sent to.'); + return false; + } + } + else + { + $this->_setErr(102, 'eMail type not defined.'); + return false; + } + } - /** - * TO Address[es] inwhich to send mail to - * - * @param string $_addrTo TO Address[es] inwhich to send mail to - * @return void - */ - function setTO($_addrTo) - { - if ( $_addrTo ) - $this->_buildAddrList('to', $_addrTo); - } + /** + * TO Address[es] inwhich to send mail to + * + * @param string $_addrTo TO Address[es] inwhich to send mail to + * @return void + */ + public function setTO($_addrTo) + { + if ( $_addrTo ) + $this->_buildAddrList('to', $_addrTo); + } - /** - * Retrieves the TO Address[es] inwhich to send mail to - * - * @return string TO Address[es] inwhich to send mail to - */ - function getTo() - { - return $this->get_email_list('to'); - } + /** + * Retrieves the TO Address[es] inwhich to send mail to + * + * @return string TO Address[es] inwhich to send mail to + */ + public function getTo() + { + return $this->get_email_list('to'); + } - /** - * CC Address[es] inwhich to send mail to - * - * @param string $_strCC CC Address[es] inwhich to send mail to - * @return void - */ - function setCC($_strCC) - { - if ( $_strCC ) - $this->_buildAddrList('cc', $_strCC); - } + /** + * CC Address[es] inwhich to send mail to + * + * @param string $_strCC CC Address[es] inwhich to send mail to + * @return void + */ + public function setCC($_strCC) + { + if ( $_strCC ) + $this->_buildAddrList('cc', $_strCC); + } - /** - * Retrieves the CC Address[es] inwhich to send mail to - * - * @return string CC Address[es] inwhich to send mail to - */ - function getCC() - { - return $this->get_email_list('cc'); - } + /** + * Retrieves the CC Address[es] inwhich to send mail to + * + * @return string CC Address[es] inwhich to send mail to + */ + public function getCC() + { + return $this->get_email_list('cc'); + } - /** - * BCC Address[es] inwhich to send mail to - * - * @param string $_strBCC Recipients BCC Address[es] inwhich to send mail to - * @return void - */ - function setBCC($_strBCC) - { - if ( $_strBCC ) - $this->_buildAddrList('bcc', $_strBCC); - } + /** + * BCC Address[es] inwhich to send mail to + * + * @param string $_strBCC Recipients BCC Address[es] inwhich to send mail to + * @return void + */ + public function setBCC($_strBCC) + { + if ( $_strBCC ) + $this->_buildAddrList('bcc', $_strBCC); + } - /** - * Retrieves the BCC Address[es] inwhich to send mail to - * - * @return string BCC Address[es] inwhich to send mail to - */ - function getBCC() - { - return $this->get_email_list('bcc'); - } + /** + * Retrieves the BCC Address[es] inwhich to send mail to + * + * @return string BCC Address[es] inwhich to send mail to + */ + public function getBCC() + { + return $this->get_email_list('bcc'); + } - /** - * Message Subject - * - * @param string $_strSubject Message Subject - * @return void - */ - function setSubject($_strSubject = '') - { - if ( $_strSubject ) - $this->_msgSubject = $_strSubject; - } + /** + * Message Subject + * + * @param string $_strSubject Message Subject + * @return void + */ + public function setSubject($_strSubject = '') + { + if ( $_strSubject ) + $this->_msgSubject = $_strSubject; + } - /** - * Retrieves the Message Subject - * - * @return string Message Subject - */ - function getSubject() - { - return $this->_msgSubject; - } + /** + * Retrieves the Message Subject + * + * @return string Message Subject + */ + public function getSubject() + { + return $this->_msgSubject; + } - /** - * Constructes and returns message header - * - * @return string Complete message header - */ - function getHeader() - { - global $conf; + /** + * Constructes and returns message header + * + * @return string Complete message header + */ + public function getHeader() + { + global $conf; - $_header = 'From: ' . $this->getFrom('org') . "\r\n" - . 'To: ' . $this->getTO() . "\r\n"; + $_header = 'From: ' . $this->getFrom('org') . "\r\n" + . 'To: ' . $this->getTO() . "\r\n"; - if ( $this->getCC() ) - $_header .= 'Cc: ' . $this->getCC() . "\r\n"; + if ( $this->getCC() ) + $_header .= 'Cc: ' . $this->getCC() . "\r\n"; - /* Note: - * BCC email addresses must be listed in the RCPT TO command list, - * but the BCC header should not be printed under the DATA command. - * So it is included into the function sendMsg() but not here. - * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server - */ - /* - if ( $this->getBCC() ) - $_header .= 'Bcc: ' . $this->getBCC() . "\r\n"; + /* Note: + * BCC email addresses must be listed in the RCPT TO command list, + * but the BCC header should not be printed under the DATA command. + * So it is included into the function sendMsg() but not here. + * http://stackoverflow.com/questions/2750211/sending-bcc-emails-using-a-smtp-server + */ + /* + if ( $this->getBCC() ) + $_header .= 'Bcc: ' . $this->getBCC() . "\r\n"; */ - $host=$this->getHost(); - $usetls = preg_match('@tls://@i', $host); - - $host=preg_replace('@tcp://@i', '', $host); // Remove prefix - $host=preg_replace('@ssl://@i', '', $host); // Remove prefix - $host=preg_replace('@tls://@i', '', $host); // Remove prefix - - $host=dol_getprefix('email'); - - //NOTE: Message-ID should probably contain the username of the user who sent the msg - $_header .= 'Subject: ' . $this->getSubject() . "\r\n"; - $_header .= 'Date: ' . date("r") . "\r\n"; - - $trackid = $this->getTrackId(); - if ($trackid) - { - // References is kept in response and Message-ID is returned into In-Reply-To: - $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; - $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; - $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host . "\r\n"; - } - else - { - $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n"; - } - if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n"; - if ( $this->getMoreInHeader() ) - $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; - - //$_header .= - // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" - // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; - - if ( $this->getSensitivity() ) - $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; - - if ( $this->_msgPriority != 3 ) - $_header .= $this->getPriority(); - - - // @CHANGE LDR - if ( $this->getDeliveryReceipt() ) - $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; - if ( $this->getErrorsTo() ) - $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; - if ( $this->getReplyTo() ) - $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; - - $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n"; - $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n"; - $_header .= 'Mime-Version: 1.0' . "\r\n"; - - - return $_header; - } - - /** - * Message Content - * - * @param string $strContent Message Content - * @param string $strType Type - * @return void - */ - function setBodyContent($strContent, $strType = 'plain') - { - //if ( $strContent ) - //{ - if ( $strType == 'html' ) - $strMimeType = 'text/html'; - else - $strMimeType = 'text/plain'; - - // Make RFC821 Compliant, replace bare linefeeds - $strContent = preg_replace("/(?]*>/", " ", $strContent); - $strContentAltText = html_entity_decode(strip_tags($strContentAltText)); - $strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n")); - } - - // Make RFC2045 Compliant - //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content - $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. - - $this->_msgContent[$strType] = array(); - - $this->_msgContent[$strType]['mimeType'] = $strMimeType; - $this->_msgContent[$strType]['data'] = $strContent; - $this->_msgContent[$strType]['dataText'] = $strContentAltText; - - if ( $this->getMD5flag() ) - $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); - //} - } - - /** - * Retrieves the Message Content - * - * @return string Message Content - */ - function getBodyContent() - { - global $conf; - - // Generate a new Boundary string - $this->_setBoundary(); - - // What type[s] of content do we have - $_types = array_keys($this->_msgContent); - - // How many content types do we have - $keyCount = count($_types); - - // If we have ZERO, we have a problem - if( $keyCount === 0 ) - die("Sorry, no content"); - - // If we have ONE, we can use the simple format - elseif( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) - { - $_msgData = $this->_msgContent; - $_msgData = $_msgData[$_types[0]]; - - $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n" - . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n" - . 'Content-Disposition: inline' . "\r\n" - . 'Content-Description: Message' . "\r\n"; - - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; - - $content .= "\r\n" - . $_msgData['data'] . "\r\n"; - } - - // If we have more than ONE, we use the multi-part format - elseif( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) - { - // Since this is an actual multi-part message - // We need to define a content message Boundary - // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this. - - //$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n"; - $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n"; - - // . "\r\n" - // . 'This is a multi-part message in MIME format.' . "\r\n"; - $content .= "Content-Transfer-Encoding: 8bit\r\n"; - $content .= "\r\n"; - - $content .= "--" . $this->_getBoundary('mixed') . "\r\n"; - - if (key_exists('image', $this->_msgContent)) // If inline image found - { - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; - $content .= "\r\n"; - $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; - } - - - // $this->_msgContent must be sorted with key 'text' or 'html' first then 'image' then 'attachment' - - - // Loop through message content array - foreach ($this->_msgContent as $type => $_content) - { - if ( $type == 'attachment' ) - { - // loop through all attachments - foreach ($_content as $_file => $_data) - { - $content .= "--" . $this->_getBoundary('mixed') . "\r\n" - . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n" - . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n" - . 'Content-Transfer-Encoding: base64' . "\r\n" - . 'Content-Description: ' . $_data['fileName'] ."\r\n"; - - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; - - $content .= "\r\n" . $_data['data'] . "\r\n\r\n"; - } - } - // @CHANGE LDR - elseif ( $type == 'image' ) - { - // loop through all images - foreach ($_content as $_image => $_data) - { - $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image - - $content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n" - . 'Content-Transfer-Encoding: base64' . "\r\n" - . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n" - . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n"; - - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; - - $content .= "\r\n" - . $_data['data'] . "\r\n"; - } - - // always end related and end alternative after inline images - $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; - $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; - $content.= "\r\n"; - } - else - { - if (key_exists('image', $this->_msgContent)) - { - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; - $content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; - $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; - $content.= "\r\n"; - $content.= "--" . $this->_getBoundary('related') . "\r\n"; - } - - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part - { - $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; - $content .= "\r\n"; - $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; - - $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; - $content.= "\r\n". $_content['dataText'] . "\r\n"; - $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; - } - - $content .= 'Content-Type: ' . $_content['mimeType'] . '; ' - // . 'charset="' . $this->getCharSet() . '"'; - . 'charset=' . $this->getCharSet() . ''; - - // $content .= ( $type == 'html') ? '; name="HTML Part"' : ''; - $content .= "\r\n"; - // $content .= 'Content-Transfer-Encoding: '; - // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType(); - // $content .= "\r\n" - // . 'Content-Disposition: inline' . "\r\n" - // . 'Content-Description: ' . $type . ' message' . "\r\n"; - - if ( $this->getMD5flag() ) - $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; - - $content .= "\r\n" . $_content['data'] . "\r\n"; - - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part - { - $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n"; - } - - $content .= "\r\n"; - } - } - - // Close message boundries - // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ; - $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ; - } - - return $content; - } - - /** - * File attachments are added to the content array as sub-arrays, - * allowing for multiple attachments for each outbound email - * - * @param string $strContent File data to attach to message - * @param string $strFileName File Name to give to attachment - * @param string $strMimeType File Mime Type of attachment - * @return void - */ - function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown') - { - if ( $strContent ) - { - $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047 - - $this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType; - $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName; - $this->_msgContent['attachment'][$strFileName]['data'] = $strContent; - - if ( $this->getMD5flag() ) - $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); - } - } - - - // @CHANGE LDR - - /** - * Image attachments are added to the content array as sub-arrays, - * allowing for multiple images for each outbound email - * - * @param string $strContent Image data to attach to message - * @param string $strImageName Image Name to give to attachment - * @param string $strMimeType Image Mime Type of attachment - * @param string $strImageCid CID - * @return void - */ - function setImageInline($strContent, $strImageName = 'unknown', $strMimeType = 'unknown', $strImageCid = 'unknown') - { - if ($strContent) - { - $this->_msgContent['image'][$strImageName]['mimeType'] = $strMimeType; - $this->_msgContent['image'][$strImageName]['imageName'] = $strImageName; - $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid; - $this->_msgContent['image'][$strImageName]['data'] = $strContent; - - if ( $this->getMD5flag() ) - $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); - } - } - // END @CHANGE LDR - - - /** - * Message Content Sensitivity - * Message Sensitivity values: - * - [0] None - default - * - [1] Personal - * - [2] Private - * - [3] Company Confidential - * - * @param integer $_value Message Sensitivity - * @return void - */ - function setSensitivity($_value = 0) - { - if ( ( is_numeric($_value) ) && - ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) - $this->_msgSensitivity = $_value; - } - - /** - * Returns Message Content Sensitivity string - * Message Sensitivity values: - * - [0] None - default - * - [1] Personal - * - [2] Private - * - [3] Company Confidential - * - * @return void - */ - function getSensitivity() - { - return $this->_arySensitivity[$this->_msgSensitivity]; - } - - /** - * Message Content Priority - * Message Priority values: - * - [0] 'Bulk' - * - [1] 'Highest' - * - [2] 'High' - * - [3] 'Normal' - default - * - [4] 'Low' - * - [5] 'Lowest' - * - * @param integer $_value Message Priority - * @return void - */ - function setPriority($_value = 3) - { - if ( ( is_numeric($_value) ) && - ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) - $this->_msgPriority = $_value; - } - - /** - * Message Content Priority - * Message Priority values: - * - [0] 'Bulk' - * - [1] 'Highest' - * - [2] 'High' - * - [3] 'Normal' - default - * - [4] 'Low' - * - [5] 'Lowest' - * - * @return string - */ - function getPriority() - { - return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" - . 'Priority: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" - . 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n"; - } - - /** - * Set flag which determines whether to calculate message MD5 checksum. - * - * @param string $_flag Message Priority - * @return void - */ - function setMD5flag($_flag = false) - { - $this->_smtpMD5 = $_flag; - } - - /** - * Gets flag which determines whether to calculate message MD5 checksum. - * - * @return boolean Message Priority - */ - function getMD5flag() - { - return $this->_smtpMD5; - } - - /** - * Message X-Header Content - * This is a simple "insert". Whatever is given will be placed - * "as is" into the Xheader array. - * - * @param string $strXdata Message X-Header Content - * @return void - */ - function setXheader($strXdata) - { - if ( $strXdata ) - $this->_msgXheader[] = $strXdata; - } - - /** - * Retrieves the Message X-Header Content - * - * @return string[] $_msgContent Message X-Header Content - */ - function getXheader() - { - return $this->_msgXheader; - } - - /** - * Generates Random string for MIME message Boundary - * - * @return void - */ - function _setBoundary() - { - $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; - $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); - $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); - } - - /** - * Retrieves the MIME message Boundary - * - * @param string $type Type of boundary - * @return string $_smtpsBoundary MIME message Boundary - */ - function _getBoundary($type = 'mixed') - { - if ($type == 'mixed') return $this->_smtpsBoundary; - elseif ($type == 'related') return $this->_smtpsRelatedBoundary; - elseif ($type == 'alternative') return $this->_smtpsAlternativeBoundary; - } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * This function has been modified as provided by SirSir to allow multiline responses when - * using SMTP Extensions - * - * @param Handler $socket Socket handler - * @param string $response Response. Example: "550 5.7.1 https://support.google.com/a/answer/6140680#invalidcred j21sm814390wre.3" - * @return boolean True or false - */ - function server_parse($socket, $response) - { + $host=$this->getHost(); + $usetls = preg_match('@tls://@i', $host); + + $host=preg_replace('@tcp://@i', '', $host); // Remove prefix + $host=preg_replace('@ssl://@i', '', $host); // Remove prefix + $host=preg_replace('@tls://@i', '', $host); // Remove prefix + + $host=dol_getprefix('email'); + + //NOTE: Message-ID should probably contain the username of the user who sent the msg + $_header .= 'Subject: ' . $this->getSubject() . "\r\n"; + $_header .= 'Date: ' . date("r") . "\r\n"; + + $trackid = $this->getTrackId(); + if ($trackid) + { + // References is kept in response and Message-ID is returned into In-Reply-To: + $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; + $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; + $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host . "\r\n"; + } + else + { + $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n"; + } + if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n"; + if ( $this->getMoreInHeader() ) + $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; + + //$_header .= + // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" + // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; + + if ( $this->getSensitivity() ) + $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; + + if ( $this->_msgPriority != 3 ) + $_header .= $this->getPriority(); + + + // @CHANGE LDR + if ( $this->getDeliveryReceipt() ) + $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; + if ( $this->getErrorsTo() ) + $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; + if ( $this->getReplyTo() ) + $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; + + $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n"; + $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n"; + $_header .= 'Mime-Version: 1.0' . "\r\n"; + + + return $_header; + } + + /** + * Message Content + * + * @param string $strContent Message Content + * @param string $strType Type + * @return void + */ + public function setBodyContent($strContent, $strType = 'plain') + { + //if ( $strContent ) + //{ + if ( $strType == 'html' ) + $strMimeType = 'text/html'; + else + $strMimeType = 'text/plain'; + + // Make RFC821 Compliant, replace bare linefeeds + $strContent = preg_replace("/(?]*>/", " ", $strContent); + $strContentAltText = html_entity_decode(strip_tags($strContentAltText)); + $strContentAltText = rtrim(wordwrap($strContentAltText, 75, "\r\n")); + } + + // Make RFC2045 Compliant + //$strContent = rtrim(chunk_split($strContent)); // Function chunck_split seems ko if not used on a base64 content + $strContent = rtrim(wordwrap($strContent, 75, "\r\n")); // TODO Using this method creates unexpected line break on text/plain content. + + $this->_msgContent[$strType] = array(); + + $this->_msgContent[$strType]['mimeType'] = $strMimeType; + $this->_msgContent[$strType]['data'] = $strContent; + $this->_msgContent[$strType]['dataText'] = $strContentAltText; + + if ( $this->getMD5flag() ) + $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); + //} + } + + /** + * Retrieves the Message Content + * + * @return string Message Content + */ + public function getBodyContent() + { + global $conf; + + // Generate a new Boundary string + $this->_setBoundary(); + + // What type[s] of content do we have + $_types = array_keys($this->_msgContent); + + // How many content types do we have + $keyCount = count($_types); + + // If we have ZERO, we have a problem + if( $keyCount === 0 ) + die("Sorry, no content"); + + // If we have ONE, we can use the simple format + elseif( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) + { + $_msgData = $this->_msgContent; + $_msgData = $_msgData[$_types[0]]; + + $content = 'Content-Type: ' . $_msgData['mimeType'] . '; charset="' . $this->getCharSet() . '"' . "\r\n" + . 'Content-Transfer-Encoding: ' . $this->getTransEncodeType() . "\r\n" + . 'Content-Disposition: inline' . "\r\n" + . 'Content-Description: Message' . "\r\n"; + + if ( $this->getMD5flag() ) + $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; + + $content .= "\r\n" + . $_msgData['data'] . "\r\n"; + } + + // If we have more than ONE, we use the multi-part format + elseif( $keyCount >= 1 || ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) + { + // Since this is an actual multi-part message + // We need to define a content message Boundary + // NOTE: This was 'multipart/alternative', but Windows based mail servers have issues with this. + + //$content = 'Content-Type: multipart/related; boundary="' . $this->_getBoundary() . '"' . "\r\n"; + $content = 'Content-Type: multipart/mixed; boundary="' . $this->_getBoundary('mixed') . '"' . "\r\n"; + + // . "\r\n" + // . 'This is a multi-part message in MIME format.' . "\r\n"; + $content .= "Content-Transfer-Encoding: 8bit\r\n"; + $content .= "\r\n"; + + $content .= "--" . $this->_getBoundary('mixed') . "\r\n"; + + if (key_exists('image', $this->_msgContent)) // If inline image found + { + $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; + $content .= "\r\n"; + $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; + } + + + // $this->_msgContent must be sorted with key 'text' or 'html' first then 'image' then 'attachment' + + + // Loop through message content array + foreach ($this->_msgContent as $type => $_content) + { + if ( $type == 'attachment' ) + { + // loop through all attachments + foreach ($_content as $_file => $_data) + { + $content .= "--" . $this->_getBoundary('mixed') . "\r\n" + . 'Content-Disposition: attachment; filename="' . $_data['fileName'] . '"' . "\r\n" + . 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['fileName'] . '"' . "\r\n" + . 'Content-Transfer-Encoding: base64' . "\r\n" + . 'Content-Description: ' . $_data['fileName'] ."\r\n"; + + if ( $this->getMD5flag() ) + $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; + + $content .= "\r\n" . $_data['data'] . "\r\n\r\n"; + } + } + // @CHANGE LDR + elseif ( $type == 'image' ) + { + // loop through all images + foreach ($_content as $_image => $_data) + { + $content .= "--" . $this->_getBoundary('related') . "\r\n"; // always related for an inline image + + $content .= 'Content-Type: ' . $_data['mimeType'] . '; name="' . $_data['imageName'] . '"' . "\r\n" + . 'Content-Transfer-Encoding: base64' . "\r\n" + . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n" + . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n"; + + if ( $this->getMD5flag() ) + $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; + + $content .= "\r\n" + . $_data['data'] . "\r\n"; + } + + // always end related and end alternative after inline images + $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; + $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; + $content.= "\r\n"; + } + else + { + if (key_exists('image', $this->_msgContent)) + { + $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; + $content.= "\r\n" . ($_content['dataText']?$_content['dataText']:strip_tags($_content['data'])) . "\r\n"; // Add plain text message + $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; + $content.= 'Content-Type: multipart/related; boundary="' . $this->_getBoundary('related') . '"' . "\r\n"; + $content.= "\r\n"; + $content.= "--" . $this->_getBoundary('related') . "\r\n"; + } + + if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part + { + $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; + $content .= "\r\n"; + $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; + + $content.= "Content-Type: text/plain; charset=" . $this->getCharSet() . "\r\n"; + $content.= "\r\n". $_content['dataText'] . "\r\n"; + $content.= "--" . $this->_getBoundary('alternative') . "\r\n"; + } + + $content .= 'Content-Type: ' . $_content['mimeType'] . '; ' + // . 'charset="' . $this->getCharSet() . '"'; + . 'charset=' . $this->getCharSet() . ''; + + // $content .= ( $type == 'html') ? '; name="HTML Part"' : ''; + $content .= "\r\n"; + // $content .= 'Content-Transfer-Encoding: '; + // $content .= ($type == 'html') ? 'quoted-printable' : $this->getTransEncodeType(); + // $content .= "\r\n" + // . 'Content-Disposition: inline' . "\r\n" + // . 'Content-Description: ' . $type . ' message' . "\r\n"; + + if ( $this->getMD5flag() ) + $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; + + $content .= "\r\n" . $_content['data'] . "\r\n"; + + if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part + { + $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n"; + } + + $content .= "\r\n"; + } + } + + // Close message boundries + // $content .= "\r\n--" . $this->_getBoundary() . '--' . "\r\n" ; + $content .= "--" . $this->_getBoundary('mixed') . '--' . "\r\n" ; + } + + return $content; + } + + /** + * File attachments are added to the content array as sub-arrays, + * allowing for multiple attachments for each outbound email + * + * @param string $strContent File data to attach to message + * @param string $strFileName File Name to give to attachment + * @param string $strMimeType File Mime Type of attachment + * @return void + */ + public function setAttachment($strContent, $strFileName = 'unknown', $strMimeType = 'unknown') + { + if ( $strContent ) + { + $strContent = rtrim(chunk_split(base64_encode($strContent), 76, "\r\n")); // 76 max is defined into http://tools.ietf.org/html/rfc2047 + + $this->_msgContent['attachment'][$strFileName]['mimeType'] = $strMimeType; + $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName; + $this->_msgContent['attachment'][$strFileName]['data'] = $strContent; + + if ( $this->getMD5flag() ) + $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); + } + } + + + // @CHANGE LDR + + /** + * Image attachments are added to the content array as sub-arrays, + * allowing for multiple images for each outbound email + * + * @param string $strContent Image data to attach to message + * @param string $strImageName Image Name to give to attachment + * @param string $strMimeType Image Mime Type of attachment + * @param string $strImageCid CID + * @return void + */ + public function setImageInline($strContent, $strImageName = 'unknown', $strMimeType = 'unknown', $strImageCid = 'unknown') + { + if ($strContent) + { + $this->_msgContent['image'][$strImageName]['mimeType'] = $strMimeType; + $this->_msgContent['image'][$strImageName]['imageName'] = $strImageName; + $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid; + $this->_msgContent['image'][$strImageName]['data'] = $strContent; + + if ( $this->getMD5flag() ) + $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); + } + } + // END @CHANGE LDR + + + /** + * Message Content Sensitivity + * Message Sensitivity values: + * - [0] None - default + * - [1] Personal + * - [2] Private + * - [3] Company Confidential + * + * @param integer $_value Message Sensitivity + * @return void + */ + public function setSensitivity($_value = 0) + { + if ( ( is_numeric($_value) ) && + ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) + $this->_msgSensitivity = $_value; + } + + /** + * Returns Message Content Sensitivity string + * Message Sensitivity values: + * - [0] None - default + * - [1] Personal + * - [2] Private + * - [3] Company Confidential + * + * @return void + */ + public function getSensitivity() + { + return $this->_arySensitivity[$this->_msgSensitivity]; + } + + /** + * Message Content Priority + * Message Priority values: + * - [0] 'Bulk' + * - [1] 'Highest' + * - [2] 'High' + * - [3] 'Normal' - default + * - [4] 'Low' + * - [5] 'Lowest' + * + * @param integer $_value Message Priority + * @return void + */ + public function setPriority($_value = 3) + { + if ( ( is_numeric($_value) ) && + ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) + $this->_msgPriority = $_value; + } + + /** + * Message Content Priority + * Message Priority values: + * - [0] 'Bulk' + * - [1] 'Highest' + * - [2] 'High' + * - [3] 'Normal' - default + * - [4] 'Low' + * - [5] 'Lowest' + * + * @return string + */ + public function getPriority() + { + return 'Importance: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" + . 'Priority: ' . $this->_aryPriority[$this->_msgPriority] . "\r\n" + . 'X-Priority: ' . $this->_msgPriority . ' (' . $this->_aryPriority[$this->_msgPriority] . ')' . "\r\n"; + } + + /** + * Set flag which determines whether to calculate message MD5 checksum. + * + * @param string $_flag Message Priority + * @return void + */ + public function setMD5flag($_flag = false) + { + $this->_smtpMD5 = $_flag; + } + + /** + * Gets flag which determines whether to calculate message MD5 checksum. + * + * @return boolean Message Priority + */ + public function getMD5flag() + { + return $this->_smtpMD5; + } + + /** + * Message X-Header Content + * This is a simple "insert". Whatever is given will be placed + * "as is" into the Xheader array. + * + * @param string $strXdata Message X-Header Content + * @return void + */ + public function setXheader($strXdata) + { + if ( $strXdata ) + $this->_msgXheader[] = $strXdata; + } + + /** + * Retrieves the Message X-Header Content + * + * @return string[] $_msgContent Message X-Header Content + */ + public function getXheader() + { + return $this->_msgXheader; + } + + /** + * Generates Random string for MIME message Boundary + * + * @return void + */ + private function _setBoundary() + { + $this->_smtpsBoundary = "multipart_x." . time() . ".x_boundary"; + $this->_smtpsRelatedBoundary = 'mul_'.dol_hash(uniqid("dolibarr2"), 3); + $this->_smtpsAlternativeBoundary = 'mul_'.dol_hash(uniqid("dolibarr3"), 3); + } + + /** + * Retrieves the MIME message Boundary + * + * @param string $type Type of boundary + * @return string $_smtpsBoundary MIME message Boundary + */ + private function _getBoundary($type = 'mixed') + { + if ($type == 'mixed') return $this->_smtpsBoundary; + elseif ($type == 'related') return $this->_smtpsRelatedBoundary; + elseif ($type == 'alternative') return $this->_smtpsAlternativeBoundary; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * This function has been modified as provided by SirSir to allow multiline responses when + * using SMTP Extensions + * + * @param Handler $socket Socket handler + * @param string $response Response. Example: "550 5.7.1 https://support.google.com/a/answer/6140680#invalidcred j21sm814390wre.3" + * @return boolean True or false + */ + public function server_parse($socket, $response) + { // phpcs:enable - /** - * Returns constructed SELECT Object string or boolean upon failure - * Default value is set at true - */ - $_retVal = true; + /** + * Returns constructed SELECT Object string or boolean upon failure + * Default value is set at true + */ + $_retVal = true; - $server_response = ''; + $server_response = ''; // avoid infinite loop $limit=0; - while (substr($server_response, 3, 1) != ' ' && $limit<100) - { - if (! ($server_response = fgets($socket, 256))) - { - $this->_setErr(121, "Couldn't get mail server response codes"); - $_retVal = false; - break; - } + while (substr($server_response, 3, 1) != ' ' && $limit<100) + { + if (! ($server_response = fgets($socket, 256))) + { + $this->_setErr(121, "Couldn't get mail server response codes"); + $_retVal = false; + break; + } $limit++; - } + } - if (! (substr($server_response, 0, 3) == $response)) - { - $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response"); - $_retVal = false; - } + if (! (substr($server_response, 0, 3) == $response)) + { + $this->_setErr(120, "Ran into problems sending Mail.\r\nResponse: $server_response"); + $_retVal = false; + } - return $_retVal; - } + return $_retVal; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Send str - * - * @param string $_strSend String to send - * @param string $_returnCode Return code - * @param string $CRLF CRLF - * @return boolean|null True or false - */ - function socket_send_str($_strSend, $_returnCode = null, $CRLF = "\r\n") - { - // phpcs:enable - if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log - fputs($this->socket, $_strSend . $CRLF); - if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF; - - if ( $_returnCode ) - return $this->server_parse($this->socket, $_returnCode); - } - - // ============================================================= - // ** Error handling methods - - /** - * Defines errors codes and messages for Class - * - * @param int $_errNum Error Code Number - * @param string $_errMsg Error Message - * @return void + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Send str + * + * @param string $_strSend String to send + * @param string $_returnCode Return code + * @param string $CRLF CRLF + * @return boolean|null True or false */ - function _setErr($_errNum, $_errMsg) + public function socket_send_str($_strSend, $_returnCode = null, $CRLF = "\r\n") + { + // phpcs:enable + if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log + fputs($this->socket, $_strSend . $CRLF); + if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF; + + if ( $_returnCode ) + return $this->server_parse($this->socket, $_returnCode); + } + + // ============================================================= + // ** Error handling methods + + /** + * Defines errors codes and messages for Class + * + * @param int $_errNum Error Code Number + * @param string $_errMsg Error Message + * @return void + */ + private function _setErr($_errNum, $_errMsg) { $this->_smtpsErrors[] = array( 'num' => $_errNum, @@ -1835,25 +1835,25 @@ class SMTPs ); } - /** - * Returns errors codes and messages for Class - * - * @return string $_errMsg Error Message - */ - function getErrors() - { - $_errMsg = array(); + /** + * Returns errors codes and messages for Class + * + * @return string $_errMsg Error Message + */ + public function getErrors() + { + $_errMsg = array(); - if (is_array($this->_smtpsErrors)) - { - foreach ($this->_smtpsErrors as $_err => $_info) - { - $_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg']; - } - } + if (is_array($this->_smtpsErrors)) + { + foreach ($this->_smtpsErrors as $_err => $_info) + { + $_errMsg[] = 'Error [' . $_info['num'] .']: '. $_info['msg']; + } + } - return implode("\n", $_errMsg); - } + return implode("\n", $_errMsg); + } } diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php index bbdebab81b0..b35e9947644 100644 --- a/htdocs/core/class/stats.class.php +++ b/htdocs/core/class/stats.class.php @@ -42,7 +42,7 @@ abstract class Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) + public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) { global $conf,$user,$langs; @@ -136,7 +136,7 @@ abstract class Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) + public function getAmountByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0, $format = 0) { global $conf,$user,$langs; @@ -228,8 +228,8 @@ abstract class Stats * @param int $startyear End year * @return array Array of values */ - function getAverageByMonthWithPrevYear($endyear, $startyear) - { + public function getAverageByMonthWithPrevYear($endyear, $startyear) + { if ($startyear > $endyear) return -1; $datay=array(); @@ -264,9 +264,9 @@ abstract class Stats * @param int $cachedelay Delay we accept for cache file (0=No read, no save of cache, -1=No read but save) * @return array Array of values */ - function getAllByProductEntry($year, $cachedelay = 0) - { - global $conf,$user,$langs; + public function getAllByProductEntry($year, $cachedelay = 0) + { + global $conf,$user,$langs; $datay=array(); @@ -333,14 +333,16 @@ abstract class Stats // Here we have low level of shared code called by XxxStats.class.php - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** * Return nb of elements by year * * @param string $sql SQL request * @return array */ - function _getNbByYear($sql) - { + protected function _getNbByYear($sql) + { + // phpcs:enable $result = array(); dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); @@ -363,14 +365,16 @@ abstract class Stats return $result; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Return nb of elements, total amount and avg amount each year * * @param string $sql SQL request * @return array Array with nb, total amount, average for each year */ - function _getAllByYear($sql) + protected function _getAllByYear($sql) { + // phpcs:enable $result = array(); dol_syslog(get_class($this).'::'.__FUNCTION__."", LOG_DEBUG); @@ -405,6 +409,7 @@ abstract class Stats return $result; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Renvoie le nombre de proposition par mois pour une annee donnee * @@ -412,9 +417,10 @@ abstract class Stats * @param string $sql SQL * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of nb each month - */ - function _getNbByMonth($year, $sql, $format = 0) - { + */ + protected function _getNbByMonth($year, $sql, $format = 0) + { + // phpcs:enable global $langs; $result=array(); @@ -462,6 +468,7 @@ abstract class Stats } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Renvoie le nombre d'element par mois pour une annee donnee * @@ -470,8 +477,9 @@ abstract class Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array */ - function _getAmountByMonth($year, $sql, $format = 0) - { + protected function _getAmountByMonth($year, $sql, $format = 0) + { + // phpcs:enable global $langs; $result=array(); @@ -514,18 +522,20 @@ abstract class Stats } return $data; - } + } - /** - * Renvoie le montant moyen par mois pour une annee donnee - * - * @param int $year Year - * @param string $sql SQL - * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @return array - */ - function _getAverageByMonth($year, $sql, $format = 0) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Renvoie le montant moyen par mois pour une annee donnee + * + * @param int $year Year + * @param string $sql SQL + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array + */ + protected function _getAverageByMonth($year, $sql, $format = 0) + { + // phpcs:enable global $langs; $result=array(); @@ -567,18 +577,20 @@ abstract class Stats } return $data; - } + } - /** - * Return number or total of product refs - * - * @param string $sql SQL - * @param int $limit Limit - * @return array - */ - function _getAllByProduct($sql, $limit = 10) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore + /** + * Return number or total of product refs + * + * @param string $sql SQL + * @param int $limit Limit + * @return array + */ + protected function _getAllByProduct($sql, $limit = 10) + { + // phpcs:enable global $langs; $result=array(); @@ -592,16 +604,16 @@ abstract class Stats $i = 0; $other=0; while ($i < $num) { - $row = $this->db->fetch_row($resql); + $row = $this->db->fetch_row($resql); if ($i < $limit || $num == $limit) $result[$i] = array($row[0],$row[1]); // Ref of product, nb else $other += $row[1]; $i++; - } + } if ($num > $limit) $result[$i] = array($langs->transnoentitiesnoconv("Other"),$other); $this->db->free($resql); } else dol_print_error($this->db); return $result; - } + } } diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index bc104bb2b79..e0865a640e4 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -48,7 +48,7 @@ class Translate * @param string $dir Force directory that contains /langs subdirectory (value is sometimes '..' like into install/* pages or support/* pages). Use '' by default. * @param Conf $conf Object with Dolibarr configuration */ - function __construct($dir, $conf) + public function __construct($dir, $conf) { if (! empty($conf->file->character_set_client)) $this->charset_output=$conf->file->character_set_client; // If charset output is forced if ($dir) $this->dir=array($dir); @@ -62,7 +62,7 @@ class Translate * @param string $srclang Language to use. If '' or 'auto', we use browser lang. * @return void */ - function setDefaultLang($srclang = 'en_US') + public function setDefaultLang($srclang = 'en_US') { global $conf; @@ -132,7 +132,7 @@ class Translate * @param int $mode 0=Long language code, 1=Short language code (en, fr, es, ...) * @return string Language code used (en_US, en_AU, fr_FR, ...) */ - function getDefaultLang($mode = 0) + public function getDefaultLang($mode = 0) { if (empty($mode)) return $this->defaultlang; else return substr($this->defaultlang, 0, 2); @@ -145,7 +145,7 @@ class Translate * @param array $domains Array of lang files to load * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK */ - function loadLangs($domains) + public function loadLangs($domains) { foreach($domains as $domain) { @@ -173,7 +173,7 @@ class Translate * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK * @see loadLangs */ - function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0) + public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0) { global $conf,$db; @@ -399,7 +399,7 @@ class Translate * @param Database $db Database handler * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK */ - function loadFromDatabase($db) + public function loadFromDatabase($db) { global $conf; @@ -537,8 +537,8 @@ class Translate * @param string $key Key to translate * @return string Translated string (translated with transnoentitiesnoconv) */ - private function getTradFromKey($key) - { + private function getTradFromKey($key) + { global $conf, $db; if (! is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly. @@ -577,7 +577,7 @@ class Translate }*/ return $newstr; - } + } /** @@ -593,9 +593,9 @@ class Translate * @param string $param4 chaine de param4 * @param int $maxsize Max length of text * @return string Translated string (encoded into HTML entities and UTF8) - */ - function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $maxsize = 0) - { + */ + public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $maxsize = 0) + { global $conf; if (! empty($this->tab_translate[$key])) // Translation is available @@ -638,7 +638,7 @@ class Translate //if ($key[0] == '$') { return dol_eval($key,1); } return $this->getTradFromKey($key); } - } + } /** @@ -655,7 +655,7 @@ class Translate * @param string $param5 chaine de param5 * @return string Translated string (encoded into UTF8) */ - function transnoentities($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $param5 = '') + public function transnoentities($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $param5 = '') { return $this->convToOutputCharset($this->transnoentitiesnoconv($key, $param1, $param2, $param3, $param4, $param5)); } @@ -676,7 +676,7 @@ class Translate * @param string $param5 chaine de param5 * @return string Translated string */ - function transnoentitiesnoconv($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $param5 = '') + public function transnoentitiesnoconv($key, $param1 = '', $param2 = '', $param3 = '', $param4 = '', $param5 = '') { global $conf; @@ -719,7 +719,7 @@ class Translate * @param string $countrycode country code (FR, ...) * @return string translated string */ - function transcountry($str, $countrycode) + public function transcountry($str, $countrycode) { if ($this->tab_translate["$str$countrycode"]) return $this->trans("$str$countrycode"); else return $this->trans($str); @@ -733,7 +733,7 @@ class Translate * @param string $countrycode country code (FR, ...) * @return string translated string */ - function transcountrynoentities($str, $countrycode) + public function transcountrynoentities($str, $countrycode) { if ($this->tab_translate["$str$countrycode"]) return $this->transnoentities("$str$countrycode"); else return $this->transnoentities($str); @@ -747,7 +747,7 @@ class Translate * @param string $pagecodefrom Page code of src string * @return string Converted string */ - function convToOutputCharset($str, $pagecodefrom = 'UTF-8') + public function convToOutputCharset($str, $pagecodefrom = 'UTF-8') { if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str=utf8_encode($str); if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str=utf8_decode(str_replace('€', chr(128), $str)); @@ -755,7 +755,7 @@ class Translate } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of all available languages * @@ -764,8 +764,8 @@ class Translate * @param int $usecode 1=Show code instead of country name for language variant, 2=Show only code * @return array List of languages */ - function get_available_languages($langdir = DOL_DOCUMENT_ROOT, $maxlength = 0, $usecode = 0) - { + public function get_available_languages($langdir = DOL_DOCUMENT_ROOT, $maxlength = 0, $usecode = 0) + { // phpcs:enable global $conf; @@ -793,10 +793,10 @@ class Translate } } return $langs_available; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if a filename $filename exists for current language (or alternate language) * @@ -804,8 +804,8 @@ class Translate * @param integer $searchalt Search also alernate language file * @return boolean true if exists and readable */ - function file_exists($filename, $searchalt = 0) - { + public function file_exists($filename, $searchalt = 0) + { // phpcs:enable // Test si fichier dans repertoire de la langue foreach($this->dir as $searchdir) @@ -822,7 +822,7 @@ class Translate } return false; - } + } /** @@ -836,8 +836,8 @@ class Translate * 10 if setDefaultLang was en_US => ten * 123 if setDefaultLang was fr_FR => cent vingt trois */ - function getLabelFromNumber($number, $isamount = 0) - { + public function getLabelFromNumber($number, $isamount = 0) + { global $conf; $newnumber=$number; @@ -861,7 +861,7 @@ class Translate } return $newnumber; - } + } /** @@ -879,8 +879,8 @@ class Translate * @return string Label in UTF8 (but without entities) * @see dol_getIdFromCode */ - function getLabelFromKey($db, $key, $tablename, $fieldkey, $fieldlabel, $keyforselect = '', $filteronentity = 0) - { + public function getLabelFromKey($db, $key, $tablename, $fieldkey, $fieldlabel, $keyforselect = '', $filteronentity = 0) + { // If key empty if ($key == '') return ''; @@ -919,7 +919,7 @@ class Translate $this->error=$db->lasterror(); return -1; } - } + } /** @@ -931,7 +931,7 @@ class Translate * @deprecated Use method price to output a price * @see price() */ - function getCurrencyAmount($currency_code, $amount) + public function getCurrencyAmount($currency_code, $amount) { $symbol=$this->getCurrencySymbol($currency_code); @@ -947,8 +947,8 @@ class Translate * @param integer $forceloadall 1=Force to load all currencies into cache. We know we need to use all of them. By default read and cache only required currency. * @return string Currency symbol encoded into UTF8 */ - function getCurrencySymbol($currency_code, $forceloadall = 0) - { + public function getCurrencySymbol($currency_code, $forceloadall = 0) + { $currency_sign = ''; // By default return iso code if (function_exists("mb_convert_encoding")) @@ -965,7 +965,7 @@ class Translate } return ($currency_sign?$currency_sign:$currency_code); - } + } /** * Load into the cache this->cache_currencies, all currencies @@ -1021,23 +1021,23 @@ class Translate } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return an array with content of all loaded translation keys (found into this->tab_translate) so * we get a substitution array we can use for substitutions (for mail or ODT generation for example) * * @return array Array of translation keys lang_key => string_translation_loaded */ - function get_translations_for_substitutions() - { + public function get_translations_for_substitutions() + { // phpcs:enable - $substitutionarray = array(); + $substitutionarray = array(); - foreach($this->tab_translate as $code => $label) { - $substitutionarray['lang_'.$code] = $label; - $substitutionarray['__('.$code.')__'] = $label; - } + foreach($this->tab_translate as $code => $label) { + $substitutionarray['lang_'.$code] = $label; + $substitutionarray['__('.$code.')__'] = $label; + } - return $substitutionarray; - } + return $substitutionarray; + } } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 6cacf353ca1..a5a3bd8aca9 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -32,15 +32,15 @@ class Utils */ public $db; - var $output; // Used by Cron method to return message - var $result; // Used by Cron method to return data + public $output; // Used by Cron method to return message + public $result; // Used by Cron method to return data /** * Constructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -53,7 +53,7 @@ class Utils * @param string $choice Choice of purge mode ('tempfiles', '' or 'tempfilesold' to purge temp older than 24h, 'allfiles', 'logfile') * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function purgeFiles($choice = 'tempfilesold') + public function purgeFiles($choice = 'tempfilesold') { global $conf, $langs, $dolibarr_main_data_root; @@ -182,7 +182,7 @@ class Utils * @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec', 2=Use the 'popen' method * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0) + public function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0) { global $db, $conf, $langs, $dolibarr_main_data_root; global $dolibarr_main_db_name, $dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_port, $dolibarr_main_db_pass; @@ -501,7 +501,7 @@ class Utils * @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec', 2=Use the 'popen' method * @return array array('result'=>...,'output'=>...,'error'=>...). result = 0 means OK. */ - function executeCLI($command, $outputfile, $execmethod = 0) + public function executeCLI($command, $outputfile, $execmethod = 0) { global $conf, $langs; @@ -570,7 +570,7 @@ class Utils * @param string $module Module name * @return int <0 if KO, >0 if OK */ - function generateDoc($module) + public function generateDoc($module) { global $conf, $langs; global $dirins; @@ -737,7 +737,7 @@ class Utils * * @return int 0 if OK, < 0 if KO */ - function compressSyslogs() + public function compressSyslogs() { global $conf; @@ -843,7 +843,7 @@ class Utils $this->output = 'Archive log files (keeping last SYSLOG_FILE_SAVES='.$nbSaves.' files) done.'; return 0; - } + } /** Backup the db OR just a table without mysqldump binary, with PHP only (does not require any exec permission) * Author: David Walsh (http://davidwalsh.name/backup-mysql-database-php) @@ -855,7 +855,7 @@ class Utils * @param string $tables Table name or '*' for all * @return int <0 if KO, >0 if OK */ - function backupTables($outputfile, $tables = '*') + public function backupTables($outputfile, $tables = '*') { global $db, $langs; global $errormsg; diff --git a/htdocs/core/class/vcard.class.php b/htdocs/core/class/vcard.class.php index cf19b43145d..fc240a88dcc 100644 --- a/htdocs/core/class/vcard.class.php +++ b/htdocs/core/class/vcard.class.php @@ -84,21 +84,21 @@ function dol_quoted_printable_encode($input, $line_max = 76) */ class vCard { - var $properties; - var $filename; + public $properties; + public $filename; //var $encoding="UTF-8"; - var $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; + public $encoding="ISO-8859-1;ENCODING=QUOTED-PRINTABLE"; /** - * mise en forme du numero de telephone + * mise en forme du numero de telephone * - * @param int $number numero de telephone - * @param string $type Type - * @return void + * @param int $number numero de telephone + * @param string $type Type + * @return void */ - function setPhoneNumber($number, $type = "") + public function setPhoneNumber($number, $type = "") { // type may be PREF | WORK | HOME | VOICE | FAX | MSG | CELL | PAGER | BBS | CAR | MODEM | ISDN | VIDEO or any senseful combination, e.g. "PREF;WORK;VOICE" $key = "TEL"; @@ -115,7 +115,7 @@ class vCard * @param string $photo Photo * @return void */ - function setPhoto($type, $photo) + public function setPhoto($type, $photo) { // $type = "GIF" | "JPEG" $this->properties["PHOTO;TYPE=$type;ENCODING=BASE64"] = base64_encode($photo); @@ -127,7 +127,7 @@ class vCard * @param string $name Name * @return void */ - function setFormattedName($name) + public function setFormattedName($name) { $this->properties["FN;CHARSET=".$this->encoding] = encode($name); } @@ -142,7 +142,7 @@ class vCard * @param string $suffix Suffix * @return void */ - function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "") + public function setName($family = "", $first = "", $additional = "", $prefix = "", $suffix = "") { $this->properties["N;CHARSET=".$this->encoding] = encode($family).";".encode($first).";".encode($additional).";".encode($prefix).";".encode($suffix); $this->filename = "$first%20$family.vcf"; @@ -155,7 +155,7 @@ class vCard * @param timestamp $date Date * @return void */ - function setBirthday($date) + public function setBirthday($date) { // $date format is YYYY-MM-DD - RFC 2425 and RFC 2426 $this->properties["BDAY"] = dol_print_date($date, 'dayrfc'); @@ -174,7 +174,7 @@ class vCard * @param string $type Type * @return void */ - function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") + public function setAddress($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") { // $type may be DOM | INTL | POSTAL | PARCEL | HOME | WORK or any combination of these: e.g. "WORK;PARCEL;POSTAL" $key = "ADR"; @@ -189,19 +189,19 @@ class vCard } /** - * mise en forme du label + * mise en forme du label * - * @param string $postoffice Postoffice - * @param string $extended Extended - * @param string $street Street - * @param string $city City - * @param string $region Region - * @param string $zip Zip - * @param string $country Country - * @param string $type Type - * @return void + * @param string $postoffice Postoffice + * @param string $extended Extended + * @param string $street Street + * @param string $city City + * @param string $region Region + * @param string $zip Zip + * @param string $country Country + * @param string $type Type + * @return void */ - function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") + public function setLabel($postoffice = "", $extended = "", $street = "", $city = "", $region = "", $zip = "", $country = "", $type = "HOME;POSTAL") { $label = ""; if ($postoffice!="") $label.= "$postoffice\r\n"; @@ -222,7 +222,7 @@ class vCard * @param string $type Vcard type * @return void */ - function setEmail($address, $type = "internet,pref") + public function setEmail($address, $type = "internet,pref") { $this->properties["EMAIL;TYPE=".$type] = $address; } @@ -233,7 +233,7 @@ class vCard * @param string $note Note * @return void */ - function setNote($note) + public function setNote($note) { $this->properties["NOTE;CHARSET=".$this->encoding] = encode($note); } @@ -244,19 +244,19 @@ class vCard * @param string $title Title * @return void */ - function setTitle($title) + public function setTitle($title) { $this->properties["TITLE;CHARSET=".$this->encoding] = encode($title); } /** - * mise en forme de la societe + * mise en forme de la societe * - * @param string $org Org - * @return void + * @param string $org Org + * @return void */ - function setOrg($org) + public function setOrg($org) { $this->properties["ORG;CHARSET=".$this->encoding] = encode($org); } @@ -268,7 +268,7 @@ class vCard * @param string $prodid Prodid * @return void */ - function setProdId($prodid) + public function setProdId($prodid) { $this->properties["PRODID;CHARSET=".$this->encoding] = encode($prodid); } @@ -280,7 +280,7 @@ class vCard * @param string $uid Uid * @return void */ - function setUID($uid) + public function setUID($uid) { $this->properties["UID;CHARSET=".$this->encoding] = encode($uid); } @@ -293,7 +293,7 @@ class vCard * @param string $type Type * @return void */ - function setURL($url, $type = "") + public function setURL($url, $type = "") { // $type may be WORK | HOME $key = "URL"; @@ -306,7 +306,7 @@ class vCard * * @return string */ - function getVCard() + public function getVCard() { $text = "BEGIN:VCARD\r\n"; $text.= "VERSION:3.0\r\n"; @@ -326,7 +326,7 @@ class vCard * * @return string Filename */ - function getFileName() + public function getFileName() { return $this->filename; } diff --git a/htdocs/core/db/Database.interface.php b/htdocs/core/db/Database.interface.php index e62692b233a..75a6fa14ec1 100644 --- a/htdocs/core/db/Database.interface.php +++ b/htdocs/core/db/Database.interface.php @@ -33,16 +33,16 @@ interface Database * @param string $resko resultat si test non egal * @return string SQL string */ - function ifsql($test, $resok, $resko); + public function ifsql($test, $resok, $resko); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return array Array */ - function fetch_row($resultset); + public function fetch_row($resultset); // phpcs:enable /** @@ -52,23 +52,23 @@ interface Database * @param int $param Date TMS to convert * @return string Date in a string YYYYMMDDHHMMSS */ - function idate($param); + public function idate($param); /** * Return last error code * * @return string lasterrno */ - function lasterrno(); + public function lasterrno(); /** * Start transaction * * @return int 1 if transaction successfuly opened or already opened, 0 if error */ - function begin(); + public function begin(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated @@ -80,7 +80,7 @@ interface Database * @param string $owner Username of database owner * @return resource resource defined if OK, null if KO */ - function DDLCreateDb($database, $charset = '', $collation = '', $owner = ''); + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = ''); // phpcs:enable /** @@ -88,7 +88,7 @@ interface Database * * @return array Version array */ - function getVersionArray(); + public function getVersionArray(); /** * Convert a SQL request in Mysql syntax to native syntax @@ -97,9 +97,9 @@ interface Database * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - static function convertSQLFromMysql($line, $type = 'ddl'); + public static function convertSQLFromMysql($line, $type = 'ddl'); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE * @@ -107,7 +107,7 @@ interface Database * @return int Nombre de lignes * @see num_rows */ - function affected_rows($resultset); + public function affected_rows($resultset); // phpcs:enable /** @@ -115,9 +115,9 @@ interface Database * * @return string Error text */ - function error(); + public function error(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List tables into a database * @@ -125,7 +125,7 @@ interface Database * @param string $table Nmae of table filter ('xxx%') * @return array List of tables in an array */ - function DDLListTables($database, $table = ''); + public function DDLListTables($database, $table = ''); // phpcs:enable /** @@ -133,7 +133,7 @@ interface Database * * @return string Last query */ - function lastquery(); + public function lastquery(); /** * Define sort criteria of request @@ -142,7 +142,7 @@ interface Database * @param string $sortorder Sort order * @return string String to provide syntax of a sort sql string */ - function order($sortfield = null, $sortorder = null); + public function order($sortfield = null, $sortorder = null); /** * Decrypt sensitive data in database @@ -150,16 +150,16 @@ interface Database * @param string $value Value to decrypt * @return string Decrypted value if used */ - function decrypt($value); + public function decrypt($value); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return array Array */ - function fetch_array($resultset); + public function fetch_array($resultset); // phpcs:enable /** @@ -167,7 +167,7 @@ interface Database * * @return string lasterror */ - function lasterror(); + public function lasterror(); /** * Escape a string to insert data @@ -175,9 +175,9 @@ interface Database * @param string $stringtoencode String to escape * @return string String escaped */ - function escape($stringtoencode); + public function escape($stringtoencode); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT * @@ -185,7 +185,7 @@ interface Database * @param string $fieldid Field name * @return int Id of row */ - function last_insert_id($tab, $fieldid = 'rowid'); + public function last_insert_id($tab, $fieldid = 'rowid'); // phpcs:enable /** @@ -193,7 +193,7 @@ interface Database * * @return string Full path of restore program */ - function getPathOfRestore(); + public function getPathOfRestore(); /** * Annulation d'une transaction et retour aux anciennes valeurs @@ -201,7 +201,7 @@ interface Database * @param string $log Add more log to default log line * @return int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur */ - function rollback($log = ''); + public function rollback($log = ''); /** * Execute a SQL request and return the resultset @@ -212,7 +212,7 @@ interface Database * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return resource Resultset of answer */ - function query($query, $usesavepoint = 0, $type = 'auto'); + public function query($query, $usesavepoint = 0, $type = 'auto'); /** * Connexion to server @@ -225,7 +225,7 @@ interface Database * @return resource Database access handler * @see close */ - function connect($host, $login, $passwd, $name, $port = 0); + public function connect($host, $login, $passwd, $name, $port = 0); /** * Define limits and offset of request @@ -234,7 +234,7 @@ interface Database * @param int $offset Numero of line from where starting fetch * @return string String with SQL syntax to add a limit and offset */ - function plimit($limit = 0, $offset = 0); + public function plimit($limit = 0, $offset = 0); /** * Return value of server parameters @@ -242,7 +242,7 @@ interface Database * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerParametersValues($filter = ''); + public function getServerParametersValues($filter = ''); /** * Return value of server status @@ -250,16 +250,16 @@ interface Database * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerStatusValues($filter = ''); + public function getServerStatusValues($filter = ''); /** * Return collation used in database * * @return string Collation value */ - function getDefaultCollationDatabase(); + public function getDefaultCollationDatabase(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -267,7 +267,7 @@ interface Database * @return int Nb of lines * @see affected_rows */ - function num_rows($resultset); + public function num_rows($resultset); // phpcs:enable /** @@ -275,23 +275,23 @@ interface Database * * @return string Full path of dump program */ - function getPathOfDump(); + public function getPathOfDump(); /** * Return version of database client driver * * @return string Version string */ - function getDriverInfo(); + public function getDriverInfo(); /** * Return generic error code of last operation. * * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ - function errno(); + public function errno(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a table into database * @@ -304,17 +304,17 @@ interface Database * @param array $keys Tableau des champs cles noms => valeur * @return int <0 if KO, >=0 if OK */ - function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null); + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null); // phpcs:enable - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a table into database * * @param string $table Name of table * @return int <0 if KO, >=0 if OK */ - function DDLDropTable($table); + public function DDLDropTable($table); // phpcs:enable /** @@ -322,9 +322,9 @@ interface Database * * @return array List of Charset */ - function getListOfCharacterSet(); + public function getListOfCharacterSet(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new field into table * @@ -334,10 +334,10 @@ interface Database * @param string $field_position Optionnel ex.: "after champtruc" * @return int <0 if KO, >0 if OK */ - function DDLAddField($table, $field_name, $field_desc, $field_position = ""); + public function DDLAddField($table, $field_name, $field_desc, $field_position = ""); // phpcs:enable - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a field from table * @@ -345,10 +345,10 @@ interface Database * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK */ - function DDLDropField($table, $field_name); + public function DDLDropField($table, $field_name); // phpcs:enable - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update format of a field into a table * @@ -357,7 +357,7 @@ interface Database * @param string $field_desc Array with description of field format * @return int <0 if KO, >0 if OK */ - function DDLUpdateField($table, $field_name, $field_desc); + public function DDLUpdateField($table, $field_name, $field_desc); // phpcs:enable /** @@ -365,9 +365,9 @@ interface Database * * @return array List of Collation */ - function getListOfCollation(); + public function getListOfCollation(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a pointer of line with description of a table or field * @@ -375,7 +375,7 @@ interface Database * @param string $field Optionnel : Name of field if we want description of field * @return resource Resource */ - function DDLDescTable($table, $field = ""); + public function DDLDescTable($table, $field = ""); // phpcs:enable /** @@ -383,16 +383,16 @@ interface Database * * @return string Version string */ - function getVersion(); + public function getVersion(); /** * Return charset used to store data in database * * @return string Charset */ - function getDefaultCharacterSetDatabase(); + public function getDefaultCharacterSetDatabase(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user and privileges to connect to database (even if database does not exists yet) * @@ -400,13 +400,13 @@ interface Database * @param string $dolibarr_main_db_user Nom user a creer * @param string $dolibarr_main_db_pass Mot de passe user a creer * @param string $dolibarr_main_db_name Database name where user must be granted - * @return int <0 if KO, >=0 if OK - */ - function DDLCreateUser( - $dolibarr_main_db_host, - $dolibarr_main_db_user, - $dolibarr_main_db_pass, - $dolibarr_main_db_name + * @return int <0 if KO, >=0 if OK + */ + public function DDLCreateUser( + $dolibarr_main_db_host, + $dolibarr_main_db_user, + $dolibarr_main_db_pass, + $dolibarr_main_db_name ); // phpcs:enable @@ -419,7 +419,7 @@ interface Database * @param bool $gm 1=Input informations are GMT values, otherwise local to server TZ * @return int|string Date TMS or '' */ - function jdate($string, $gm = false); + public function jdate($string, $gm = false); /** * Encrypt sensitive data in database @@ -429,7 +429,7 @@ interface Database * @param int $withQuotes Return string with quotes * @return string XXX(field) or XXX('value') or field or 'value' */ - function encrypt($fieldorvalue, $withQuotes = 0); + public function encrypt($fieldorvalue, $withQuotes = 0); /** * Validate a database transaction @@ -437,25 +437,25 @@ interface Database * @param string $log Add more log to default log line * @return int 1 if validation is OK or transaction level no started, 0 if ERROR */ - function commit($log = ''); + public function commit($log = ''); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. * * @param string $table Name of table - * @return array Array with inforation on table - */ - function DDLInfoTable($table); + * @return array Array with inforation on table + */ + public function DDLInfoTable($table); // phpcs:enable - /** + /** * Free last resultset used. * * @param resource $resultset Fre cursor * @return void */ - function free($resultset = null); + public function free($resultset = null); /** * Close database connexion @@ -463,41 +463,41 @@ interface Database * @return boolean True if disconnect successfull, false otherwise * @see connect */ - function close(); + public function close(); /** * Return last query in error * * @return string lastqueryerror */ - function lastqueryerror(); + public function lastqueryerror(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return connexion ID * * @return string Id connexion */ - function DDLGetConnectId(); + public function DDLGetConnectId(); // phpcs:enable - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * * @param resource $resultset Curseur de la requete voulue * @return Object Object result line or false if KO or end of cursor */ - function fetch_object($resultset); + public function fetch_object($resultset); // phpcs:enable - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database * * @param string $database Name of database * @return boolean true if OK, false if KO */ - function select_db($database); + public function select_db($database); // phpcs:enable } diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index ae61e35489d..575cf2256ef 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -75,7 +75,7 @@ abstract class DoliDB implements Database * @param string $resko resultat si test non egal * @return string SQL string */ - function ifsql($test, $resok, $resko) + public function ifsql($test, $resok, $resko) { return 'IF('.$test.','.$resok.','.$resko.')'; } @@ -87,7 +87,7 @@ abstract class DoliDB implements Database * @param int $param Date TMS to convert * @return string Date in a string YYYY-MM-DD HH:MM:SS */ - function idate($param) + public function idate($param) { // TODO GMT $param should be gmt, so we should add tzouptut to 'gmt' return dol_print_date($param, "%Y-%m-%d %H:%M:%S"); @@ -98,7 +98,7 @@ abstract class DoliDB implements Database * * @return string lasterrno */ - function lasterrno() + public function lasterrno() { return $this->lasterrno; } @@ -108,7 +108,7 @@ abstract class DoliDB implements Database * * @return int 1 if transaction successfuly opened or already opened, 0 if error */ - function begin() + public function begin() { if (! $this->transaction_opened) { @@ -135,7 +135,7 @@ abstract class DoliDB implements Database * @param string $log Add more log to default log line * @return int 1 if validation is OK or transaction level no started, 0 if ERROR */ - function commit($log = '') + public function commit($log = '') { dol_syslog('', 0, -1); if ($this->transaction_opened<=1) @@ -165,7 +165,7 @@ abstract class DoliDB implements Database * @param string $log Add more log to default log line * @return resource|int 1 si annulation ok ou transaction non ouverte, 0 en cas d'erreur */ - function rollback($log = '') + public function rollback($log = '') { dol_syslog('', 0, -1); if ($this->transaction_opened<=1) @@ -189,7 +189,7 @@ abstract class DoliDB implements Database * @param int $offset Numero of line from where starting fetch * @return string String with SQL syntax to add a limit and offset */ - function plimit($limit = 0, $offset = 0) + public function plimit($limit = 0, $offset = 0) { global $conf; if (empty($limit)) return ""; @@ -203,7 +203,7 @@ abstract class DoliDB implements Database * * @return array Version array */ - function getVersionArray() + public function getVersionArray() { return preg_split("/[\.,-]/", $this->getVersion()); } @@ -213,7 +213,7 @@ abstract class DoliDB implements Database * * @return string Last query */ - function lastquery() + public function lastquery() { return $this->lastquery; } @@ -225,7 +225,7 @@ abstract class DoliDB implements Database * @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC'; * @return string String to provide syntax of a sort sql string */ - function order($sortfield = null, $sortorder = null) + public function order($sortfield = null, $sortorder = null) { if (! empty($sortfield)) { @@ -264,7 +264,7 @@ abstract class DoliDB implements Database * * @return string Last error */ - function lasterror() + public function lasterror() { return $this->lasterror; } @@ -278,7 +278,7 @@ abstract class DoliDB implements Database * @param bool $gm 1=Input informations are GMT values, otherwise local to server TZ * @return int|string Date TMS or '' */ - function jdate($string, $gm = false) + public function jdate($string, $gm = false) { // TODO GMT must set param gm to true by default if ($string==0 || $string=="0000-00-00 00:00:00") return ''; @@ -293,7 +293,7 @@ abstract class DoliDB implements Database * * @return string lastqueryerror */ - function lastqueryerror() + public function lastqueryerror() { return $this->lastqueryerror; } diff --git a/htdocs/core/db/mssql.class.php b/htdocs/core/db/mssql.class.php index a49ef7f6294..4c95098813d 100644 --- a/htdocs/core/db/mssql.class.php +++ b/htdocs/core/db/mssql.class.php @@ -36,9 +36,9 @@ class DoliDBMssql extends DoliDB //! Database label const LABEL='MSSQL'; //! Charset used to force charset when creating database - var $forcecharset='latin1'; // Can't be static as it may be forced with a dynamic value + public $forcecharset='latin1'; // Can't be static as it may be forced with a dynamic value //! Collate used to force collate when creating database - var $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value + public $forcecollate='latin1_swedish_ci'; // Can't be static as it may be forced with a dynamic value //! Version min database const VERSIONMIN='2000'; /** @var resource Resultset of last query */ @@ -55,7 +55,7 @@ class DoliDBMssql extends DoliDB * @param string $name Nom de la database * @param int $port Port of database server */ - function __construct($type, $host, $user, $pass, $name = '', $port = 0) + public function __construct($type, $host, $user, $pass, $name = '', $port = 0) { global $langs; @@ -134,19 +134,19 @@ class DoliDBMssql extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - static function convertSQLFromMysql($line, $type = 'ddl') + public static function convertSQLFromMysql($line, $type = 'ddl') { return $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database * * @param string $database Name of database * @return boolean true if OK, false if KO */ - function select_db($database) + public function select_db($database) { // phpcs:enable return @mssql_select_db($database, $this->db); @@ -163,7 +163,7 @@ class DoliDBMssql extends DoliDB * @return false|resource|true Database access handler * @see close */ - function connect($host, $login, $passwd, $name, $port = 0) + public function connect($host, $login, $passwd, $name, $port = 0) { dol_syslog(get_class($this)."::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name"); $newhost=$host; @@ -191,7 +191,7 @@ class DoliDBMssql extends DoliDB * * @return string Version string */ - function getVersion() + public function getVersion() { $resql=$this->query("SELECT @@VERSION"); if ($resql) @@ -207,7 +207,7 @@ class DoliDBMssql extends DoliDB * * @return string Version string */ - function getDriverInfo() + public function getDriverInfo() { return 'php mssql driver'; } @@ -218,7 +218,7 @@ class DoliDBMssql extends DoliDB * @return bool True if disconnect successfull, false otherwise * @see connect */ - function close() + public function close() { if ($this->db) { @@ -235,7 +235,7 @@ class DoliDBMssql extends DoliDB * * @return bool true if transaction successfuly opened or already opened, false if error */ - function begin() + public function begin() { $res=mssql_query('select @@TRANCOUNT'); @@ -263,7 +263,7 @@ class DoliDBMssql extends DoliDB * @param string $log Add more log to default log line * @return bool true if validation is OK or transaction level no started, false if ERROR */ - function commit($log = '') + public function commit($log = '') { $res=mssql_query('select @@TRANCOUNT'); $this->transaction_opened=mssql_result($res, 0, 0); @@ -296,7 +296,7 @@ class DoliDBMssql extends DoliDB * @param string $log Add more log to default log line * @return bool true si annulation ok ou transaction non ouverte, false en cas d'erreur */ - function rollback($log = '') + public function rollback($log = '') { $res=mssql_query('select @@TRANCOUNT'); $this->transaction_opened=mssql_result($res, 0, 0); @@ -324,7 +324,7 @@ class DoliDBMssql extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return false|resource|true Resultset of answer */ - function query($query, $usesavepoint = 0, $type = 'auto') + public function query($query, $usesavepoint = 0, $type = 'auto') { $query = trim($query); @@ -368,11 +368,11 @@ class DoliDBMssql extends DoliDB } else { - if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+PRIMARY\h+KEY\h+(\w+?)\h*\((.+)\)/is', $query, $matches)) - { + if (preg_match('/ALTER TABLE\h+(\w+?)\h+ADD\h+PRIMARY\h+KEY\h+(\w+?)\h*\((.+)\)/is', $query, $matches)) + { $original_query=$query; $query="ALTER TABLE [".$matches[1]."] ADD CONSTRAINT [".$matches[2]."] PRIMARY KEY CLUSTERED (".$matches[3].")"; - } + } } } @@ -459,14 +459,14 @@ class DoliDBMssql extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * * @param resource $resultset Curseur de la requete voulue * @return object|false Object result line or false if KO or end of cursor */ - function fetch_object($resultset) + public function fetch_object($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -474,14 +474,14 @@ class DoliDBMssql extends DoliDB return mssql_fetch_object($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return array|false Array or false if KO or end of cursor */ - function fetch_array($resultset) + public function fetch_array($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -490,14 +490,14 @@ class DoliDBMssql extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return array|false Array or false if KO or end of cursor */ - function fetch_row($resultset) + public function fetch_row($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -505,7 +505,7 @@ class DoliDBMssql extends DoliDB return @mssql_fetch_row($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -513,7 +513,7 @@ class DoliDBMssql extends DoliDB * @return int Nb of lines * @see affected_rows */ - function num_rows($resultset) + public function num_rows($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -521,7 +521,7 @@ class DoliDBMssql extends DoliDB return mssql_num_rows($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE * @@ -529,7 +529,7 @@ class DoliDBMssql extends DoliDB * @return int Nombre de lignes * @see num_rows */ - function affected_rows($resultset) + public function affected_rows($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -548,7 +548,7 @@ class DoliDBMssql extends DoliDB * @param resource $resultset Curseur de la requete voulue * @return bool */ - function free($resultset = null) + public function free($resultset = null) { // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion if (! is_resource($resultset)) { $resultset=$this->_results; } @@ -562,7 +562,7 @@ class DoliDBMssql extends DoliDB * @param string $stringtoencode String to escape * @return string String escaped */ - function escape($stringtoencode) + public function escape($stringtoencode) { return addslashes($stringtoencode); } @@ -575,7 +575,7 @@ class DoliDBMssql extends DoliDB * @param string $param Date TMS to convert * @return string Date in a string YYYY-MM-DD HH:MM:SS */ - function idate($param) + public function idate($param) { return dol_print_date($param, "%Y-%m-%d %H:%M:%S"); } @@ -585,7 +585,7 @@ class DoliDBMssql extends DoliDB * * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ - function errno() + public function errno() { if (! $this->connected) { @@ -638,7 +638,7 @@ class DoliDBMssql extends DoliDB * * @return string Error text */ - function error() + public function error() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide pour mssql_get_last_message. @@ -649,7 +649,7 @@ class DoliDBMssql extends DoliDB } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT * @@ -657,7 +657,7 @@ class DoliDBMssql extends DoliDB * @param string $fieldid Field name * @return int Id of row or -1 on error */ - function last_insert_id($tab, $fieldid = 'rowid') + public function last_insert_id($tab, $fieldid = 'rowid') { // phpcs:enable $res = $this->query("SELECT @@IDENTITY as id"); @@ -679,7 +679,7 @@ class DoliDBMssql extends DoliDB * @param int $withQuotes Return string with quotes * @return string XXX(field) or XXX('value') or field or 'value' */ - function encrypt($fieldorvalue, $withQuotes = 0) + public function encrypt($fieldorvalue, $withQuotes = 0) { global $conf; @@ -699,7 +699,7 @@ class DoliDBMssql extends DoliDB * @param string $value Value to decrypt * @return string Decrypted value if used */ - function decrypt($value) + public function decrypt($value) { global $conf; @@ -714,13 +714,13 @@ class DoliDBMssql extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return connexion ID * * @return string Id connexion */ - function DDLGetConnectId() + public function DDLGetConnectId() { // phpcs:enable $resql=$this->query('SELECT CONNECTION_ID()'); @@ -732,7 +732,7 @@ class DoliDBMssql extends DoliDB else return '?'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated @@ -744,7 +744,7 @@ class DoliDBMssql extends DoliDB * @param string $owner Username of database owner * @return false|resource|true resource defined if OK, false if KO */ - function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') { // phpcs:enable /*if (empty($charset)) $charset=$this->forcecharset; @@ -770,7 +770,7 @@ class DoliDBMssql extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List tables into a database * @@ -778,21 +778,21 @@ class DoliDBMssql extends DoliDB * @param string $table Nmae of table filter ('xxx%') * @return array List of tables in an array */ - function DDLListTables($database, $table = '') + public function DDLListTables($database, $table = '') { // phpcs:enable $this->_results = mssql_list_tables($database, $this->db); return $this->_results; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. * * @param string $table Name of table * @return array Tableau des informations des champs de la table */ - function DDLInfoTable($table) + public function DDLInfoTable($table) { // phpcs:enable @@ -804,7 +804,7 @@ class DoliDBMssql extends DoliDB return $infotables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a table into database * @@ -817,7 +817,7 @@ class DoliDBMssql extends DoliDB * @param array $keys Tableau des champs cles noms => valeur * @return int <0 if KO, >=0 if OK */ - function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) { // phpcs:enable // FIXME: $fulltext_keys parameter is unused @@ -885,14 +885,14 @@ class DoliDBMssql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a table into database * * @param string $table Name of table * @return int <0 if KO, >=0 if OK */ - function DDLDropTable($table) + public function DDLDropTable($table) { // phpcs:enable $sql = "DROP TABLE ".$table; @@ -903,7 +903,7 @@ class DoliDBMssql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a pointer of line with description of a table or field * @@ -911,7 +911,7 @@ class DoliDBMssql extends DoliDB * @param string $field Optionnel : Name of field if we want description of field * @return false|resource|true Resource */ - function DDLDescTable($table, $field = "") + public function DDLDescTable($table, $field = "") { // phpcs:enable $sql="DESC ".$table." ".$field; @@ -921,7 +921,7 @@ class DoliDBMssql extends DoliDB return $this->_results; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new field into table * @@ -931,7 +931,7 @@ class DoliDBMssql extends DoliDB * @param string $field_position Optionnel ex.: "after champtruc" * @return int <0 if KO, >0 if OK */ - function DDLAddField($table, $field_name, $field_desc, $field_position = "") + public function DDLAddField($table, $field_name, $field_desc, $field_position = "") { // phpcs:enable // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra @@ -959,7 +959,7 @@ class DoliDBMssql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update format of a field into a table * @@ -968,7 +968,7 @@ class DoliDBMssql extends DoliDB * @param string $field_desc Array with description of field format * @return int <0 if KO, >0 if OK */ - function DDLUpdateField($table, $field_name, $field_desc) + public function DDLUpdateField($table, $field_name, $field_desc) { // phpcs:enable $sql = "ALTER TABLE ".$table; @@ -984,7 +984,7 @@ class DoliDBMssql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a field from table * @@ -992,7 +992,7 @@ class DoliDBMssql extends DoliDB * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK */ - function DDLDropField($table, $field_name) + public function DDLDropField($table, $field_name) { // phpcs:enable $sql= "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; @@ -1005,7 +1005,7 @@ class DoliDBMssql extends DoliDB else return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user and privileges to connect to database (even if database does not exists yet) * @@ -1015,7 +1015,7 @@ class DoliDBMssql extends DoliDB * @param string $dolibarr_main_db_name Database name where user must be granted * @return int <0 if KO, >=0 if OK */ - function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) + public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) { // phpcs:enable $sql = "CREATE LOGIN ".$this->EscapeFieldName($dolibarr_main_db_user)." WITH PASSWORD='$dolibarr_main_db_pass'"; @@ -1059,7 +1059,7 @@ class DoliDBMssql extends DoliDB * * @return string Charset */ - function getDefaultCharacterSetDatabase() + public function getDefaultCharacterSetDatabase() { // FIXME: Dummy method // TODO: Implement @@ -1072,7 +1072,7 @@ class DoliDBMssql extends DoliDB * * @return array List of Charset */ - function getListOfCharacterSet() + public function getListOfCharacterSet() { // FIXME: Dummy method // TODO: Implement @@ -1085,7 +1085,7 @@ class DoliDBMssql extends DoliDB * * @return string Collation value */ - function getDefaultCollationDatabase() + public function getDefaultCollationDatabase() { $resql=$this->query("SELECT SERVERPROPERTY('collation')"); if (!$resql) @@ -1101,7 +1101,7 @@ class DoliDBMssql extends DoliDB * * @return array Liste of Collation */ - function getListOfCollation() + public function getListOfCollation() { // FIXME: Dummy method // TODO: Implement @@ -1114,7 +1114,7 @@ class DoliDBMssql extends DoliDB * * @return string Full path of dump program */ - function getPathOfDump() + public function getPathOfDump() { // FIXME: Dummy method // TODO: Implement @@ -1127,7 +1127,7 @@ class DoliDBMssql extends DoliDB * * @return string Full path of restore program */ - function getPathOfRestore() + public function getPathOfRestore() { // FIXME: Dummy method // TODO: Implement @@ -1141,7 +1141,7 @@ class DoliDBMssql extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerParametersValues($filter = '') + public function getServerParametersValues($filter = '') { // FIXME: Dummy method // TODO: Implement @@ -1157,7 +1157,7 @@ class DoliDBMssql extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerStatusValues($filter = '') + public function getServerStatusValues($filter = '') { // FIXME: Dummy method // TODO: Implement @@ -1166,21 +1166,21 @@ class DoliDBMssql extends DoliDB return array(); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Escape a field name according to escape's syntax * * @param string $fieldname Field's name to escape * @return string field's name escaped */ - function EscapeFieldName($fieldname) + public function EscapeFieldName($fieldname) { // phpcs:enable return "[".$fieldname."]"; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get information on field * @@ -1188,7 +1188,7 @@ class DoliDBMssql extends DoliDB * @param mixed $fields String for one field or array of string for multiple field * @return false|object */ - function GetFieldInformation($table, $fields) + public function GetFieldInformation($table, $fields) { // phpcs:enable $sql="SELECT * from INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='".$this->escape($table)."' AND COLUMN_NAME"; diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 48a768bd365..6c3bfd2362f 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -54,7 +54,7 @@ class DoliDBMysqli extends DoliDB * @param string $name Nom de la database * @param int $port Port of database server */ - function __construct($type, $host, $user, $pass, $name = '', $port = 0) + public function __construct($type, $host, $user, $pass, $name = '', $port = 0) { global $conf,$langs; @@ -162,19 +162,19 @@ class DoliDBMysqli extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - static function convertSQLFromMysql($line, $type = 'ddl') + public static function convertSQLFromMysql($line, $type = 'ddl') { return $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database * * @param string $database Name of database * @return boolean true if OK, false if KO */ - function select_db($database) + public function select_db($database) { // phpcs:enable dol_syslog(get_class($this)."::select_db database=".$database, LOG_DEBUG); @@ -193,22 +193,22 @@ class DoliDBMysqli extends DoliDB * @return mysqli Database access object * @see close */ - function connect($host, $login, $passwd, $name, $port = 0) - { + public function connect($host, $login, $passwd, $name, $port = 0) + { dol_syslog(get_class($this) . "::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name", LOG_DEBUG); // Can also be // mysqli::init(); mysql::options(MYSQLI_INIT_COMMAND, 'SET AUTOCOMMIT = 0'); mysqli::options(MYSQLI_OPT_CONNECT_TIMEOUT, 5); // return mysqli::real_connect($host, $user, $pass, $db, $port); return new mysqli($host, $login, $passwd, $name, $port); - } + } /** * Return version of database server * * @return string Version string */ - function getVersion() + public function getVersion() { return $this->db->server_info; } @@ -218,10 +218,10 @@ class DoliDBMysqli extends DoliDB * * @return string Version string */ - function getDriverInfo() - { - return $this->db->client_info; - } + public function getDriverInfo() + { + return $this->db->client_info; + } /** @@ -230,7 +230,7 @@ class DoliDBMysqli extends DoliDB * @return bool True if disconnect successfull, false otherwise * @see connect */ - function close() + public function close() { if ($this->db) { @@ -250,7 +250,7 @@ class DoliDBMysqli extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return bool|mysqli_result Resultset of answer */ - function query($query, $usesavepoint = 0, $type = 'auto') + public function query($query, $usesavepoint = 0, $type = 'auto') { global $conf; @@ -287,14 +287,14 @@ class DoliDBMysqli extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * * @param mysqli_result $resultset Curseur de la requete voulue * @return object|null Object result line or null if KO or end of cursor */ - function fetch_object($resultset) + public function fetch_object($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -303,14 +303,14 @@ class DoliDBMysqli extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param mysqli_result $resultset Resultset of request * @return array|null Array or null if KO or end of cursor */ - function fetch_array($resultset) + public function fetch_array($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -318,14 +318,14 @@ class DoliDBMysqli extends DoliDB return $resultset->fetch_array(); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param mysqli_result $resultset Resultset of request * @return array|null|0 Array or null if KO or end of cursor or 0 if resultset is bool */ - function fetch_row($resultset) + public function fetch_row($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -341,7 +341,7 @@ class DoliDBMysqli extends DoliDB } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -349,7 +349,7 @@ class DoliDBMysqli extends DoliDB * @return int Nb of lines * @see affected_rows */ - function num_rows($resultset) + public function num_rows($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -357,7 +357,7 @@ class DoliDBMysqli extends DoliDB return $resultset->num_rows; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE * @@ -365,7 +365,7 @@ class DoliDBMysqli extends DoliDB * @return int Nombre de lignes * @see num_rows */ - function affected_rows($resultset) + public function affected_rows($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -382,7 +382,7 @@ class DoliDBMysqli extends DoliDB * @param mysqli_result $resultset Curseur de la requete voulue * @return void */ - function free($resultset = null) + public function free($resultset = null) { // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } @@ -396,7 +396,7 @@ class DoliDBMysqli extends DoliDB * @param string $stringtoencode String to escape * @return string String escaped */ - function escape($stringtoencode) + public function escape($stringtoencode) { return $this->db->real_escape_string($stringtoencode); } @@ -406,7 +406,7 @@ class DoliDBMysqli extends DoliDB * * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ - function errno() + public function errno() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide. @@ -457,7 +457,7 @@ class DoliDBMysqli extends DoliDB * * @return string Error text */ - function error() + public function error() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide pour mysqli_error. @@ -468,7 +468,7 @@ class DoliDBMysqli extends DoliDB } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT * @@ -476,7 +476,7 @@ class DoliDBMysqli extends DoliDB * @param string $fieldid Field name * @return int|string Id of row */ - function last_insert_id($tab, $fieldid = 'rowid') + public function last_insert_id($tab, $fieldid = 'rowid') { // phpcs:enable return $this->db->insert_id; @@ -491,7 +491,7 @@ class DoliDBMysqli extends DoliDB * @return string XXX(field) or XXX('value') or field or 'value' * */ - function encrypt($fieldorvalue, $withQuotes = 0) + public function encrypt($fieldorvalue, $withQuotes = 0) { global $conf; @@ -524,7 +524,7 @@ class DoliDBMysqli extends DoliDB * @param string $value Value to decrypt * @return string Decrypted value if used */ - function decrypt($value) + public function decrypt($value) { global $conf; @@ -552,13 +552,13 @@ class DoliDBMysqli extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return connexion ID * * @return string Id connexion */ - function DDLGetConnectId() + public function DDLGetConnectId() { // phpcs:enable $resql=$this->query('SELECT CONNECTION_ID()'); @@ -570,7 +570,7 @@ class DoliDBMysqli extends DoliDB else return '?'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated @@ -582,7 +582,7 @@ class DoliDBMysqli extends DoliDB * @param string $owner Username of database owner * @return bool|mysqli_result resource defined if OK, null if KO */ - function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') { // phpcs:enable if (empty($charset)) $charset=$this->forcecharset; @@ -604,7 +604,7 @@ class DoliDBMysqli extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List tables into a database * @@ -612,7 +612,7 @@ class DoliDBMysqli extends DoliDB * @param string $table Nmae of table filter ('xxx%') * @return array List of tables in an array */ - function DDLListTables($database, $table = '') + public function DDLListTables($database, $table = '') { // phpcs:enable $listtables=array(); @@ -632,14 +632,14 @@ class DoliDBMysqli extends DoliDB return $listtables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. * * @param string $table Name of table * @return array Tableau des informations des champs de la table */ - function DDLInfoTable($table) + public function DDLInfoTable($table) { // phpcs:enable $infotables=array(); @@ -658,7 +658,7 @@ class DoliDBMysqli extends DoliDB return $infotables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a table into database * @@ -671,7 +671,7 @@ class DoliDBMysqli extends DoliDB * @param array $keys Tableau des champs cles noms => valeur * @return int <0 if KO, >=0 if OK */ - function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) { // phpcs:enable // FIXME: $fulltext_keys parameter is unused @@ -742,14 +742,14 @@ class DoliDBMysqli extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a table into database * * @param string $table Name of table * @return int <0 if KO, >=0 if OK */ - function DDLDropTable($table) + public function DDLDropTable($table) { // phpcs:enable $sql = "DROP TABLE ".$table; @@ -760,7 +760,7 @@ class DoliDBMysqli extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a pointer of line with description of a table or field * @@ -768,7 +768,7 @@ class DoliDBMysqli extends DoliDB * @param string $field Optionnel : Name of field if we want description of field * @return bool|mysqli_result Resultset x (x->Field, x->Type, ...) */ - function DDLDescTable($table, $field = "") + public function DDLDescTable($table, $field = "") { // phpcs:enable $sql="DESC ".$table." ".$field; @@ -778,7 +778,7 @@ class DoliDBMysqli extends DoliDB return $this->_results; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new field into table * @@ -788,7 +788,7 @@ class DoliDBMysqli extends DoliDB * @param string $field_position Optionnel ex.: "after champtruc" * @return int <0 if KO, >0 if OK */ - function DDLAddField($table, $field_name, $field_desc, $field_position = "") + public function DDLAddField($table, $field_name, $field_desc, $field_position = "") { // phpcs:enable // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra @@ -830,7 +830,7 @@ class DoliDBMysqli extends DoliDB return -1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update format of a field into a table * @@ -839,7 +839,7 @@ class DoliDBMysqli extends DoliDB * @param string $field_desc Array with description of field format * @return int <0 if KO, >0 if OK */ - function DDLUpdateField($table, $field_name, $field_desc) + public function DDLUpdateField($table, $field_name, $field_desc) { // phpcs:enable $sql = "ALTER TABLE ".$table; @@ -877,7 +877,7 @@ class DoliDBMysqli extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a field from table * @@ -885,7 +885,7 @@ class DoliDBMysqli extends DoliDB * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK */ - function DDLDropField($table, $field_name) + public function DDLDropField($table, $field_name) { // phpcs:enable $sql= "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; @@ -898,7 +898,7 @@ class DoliDBMysqli extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user and privileges to connect to database (even if database does not exists yet) * @@ -908,7 +908,7 @@ class DoliDBMysqli extends DoliDB * @param string $dolibarr_main_db_name Database name where user must be granted * @return int <0 if KO, >=0 if OK */ - function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) + public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) { // phpcs:enable $sql = "CREATE USER '".$this->escape($dolibarr_main_db_user)."'"; @@ -953,7 +953,7 @@ class DoliDBMysqli extends DoliDB * @return string Charset * @see getDefaultCollationDatabase */ - function getDefaultCharacterSetDatabase() + public function getDefaultCharacterSetDatabase() { $resql=$this->query('SHOW VARIABLES LIKE \'character_set_database\''); if (!$resql) @@ -972,7 +972,7 @@ class DoliDBMysqli extends DoliDB * * @return array|null List of Charset */ - function getListOfCharacterSet() + public function getListOfCharacterSet() { $resql=$this->query('SHOW CHARSET'); $liste = array(); @@ -999,7 +999,7 @@ class DoliDBMysqli extends DoliDB * @return string Collation value * @see getDefaultCharacterSetDatabase */ - function getDefaultCollationDatabase() + public function getDefaultCollationDatabase() { $resql=$this->query('SHOW VARIABLES LIKE \'collation_database\''); if (!$resql) @@ -1018,7 +1018,7 @@ class DoliDBMysqli extends DoliDB * * @return array|null Liste of Collation */ - function getListOfCollation() + public function getListOfCollation() { $resql=$this->query('SHOW COLLATION'); $liste = array(); @@ -1043,7 +1043,7 @@ class DoliDBMysqli extends DoliDB * * @return string Full path of dump program */ - function getPathOfDump() + public function getPathOfDump() { $fullpathofdump='/pathtomysqldump/mysqldump'; @@ -1062,7 +1062,7 @@ class DoliDBMysqli extends DoliDB * * @return string Full path of restore program */ - function getPathOfRestore() + public function getPathOfRestore() { $fullpathofimport='/pathtomysql/mysql'; @@ -1082,7 +1082,7 @@ class DoliDBMysqli extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerParametersValues($filter = '') + public function getServerParametersValues($filter = '') { $result=array(); @@ -1103,7 +1103,7 @@ class DoliDBMysqli extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerStatusValues($filter = '') + public function getServerStatusValues($filter = '') { $result=array(); diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 1145be1849b..6e72d9c435a 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -40,9 +40,9 @@ class DoliDBPgsql extends DoliDB //! Database label const LABEL='PostgreSQL'; // Label of manager //! Charset - var $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value + public $forcecharset='UTF8'; // Can't be static as it may be forced with a dynamic value //! Collate used to force collate when creating database - var $forcecollate=''; // Can't be static as it may be forced with a dynamic value + public $forcecollate=''; // Can't be static as it may be forced with a dynamic value //! Version min database const VERSIONMIN='9.0.0'; // Version min database /** @var resource Resultset of last query */ @@ -62,7 +62,7 @@ class DoliDBPgsql extends DoliDB * @param string $name Nom de la database * @param int $port Port of database server */ - function __construct($type, $host, $user, $pass, $name = '', $port = 0) + public function __construct($type, $host, $user, $pass, $name = '', $port = 0) { global $conf,$langs; @@ -150,7 +150,7 @@ class DoliDBPgsql extends DoliDB * @param bool $unescapeslashquot Unescape slash quote with quote quote * @return string SQL request line converted */ - static function convertSQLFromMysql($line, $type = 'auto', $unescapeslashquot = false) + public static function convertSQLFromMysql($line, $type = 'auto', $unescapeslashquot = false) { global $conf; @@ -368,7 +368,7 @@ class DoliDBPgsql extends DoliDB return $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database * Ici postgresql n'a aucune fonction equivalente de mysql_select_db @@ -377,7 +377,7 @@ class DoliDBPgsql extends DoliDB * @param string $database Name of database * @return bool true if OK, false if KO */ - function select_db($database) + public function select_db($database) { // phpcs:enable if ($database == $this->database_name) { @@ -398,7 +398,7 @@ class DoliDBPgsql extends DoliDB * @return false|resource Database access handler * @see close */ - function connect($host, $login, $passwd, $name, $port = 0) + public function connect($host, $login, $passwd, $name, $port = 0) { // use pg_pconnect() instead of pg_connect() if you want to use persistent connection costing 1ms, instead of 30ms for non persistent @@ -446,7 +446,7 @@ class DoliDBPgsql extends DoliDB * * @return string Version string */ - function getVersion() + public function getVersion() { $resql=$this->query('SHOW server_version'); if ($resql) @@ -462,7 +462,7 @@ class DoliDBPgsql extends DoliDB * * @return string Version string */ - function getDriverInfo() + public function getDriverInfo() { return 'pgsql php driver'; } @@ -473,7 +473,7 @@ class DoliDBPgsql extends DoliDB * @return boolean True if disconnect successfull, false otherwise * @see connect */ - function close() + public function close() { if ($this->db) { @@ -492,7 +492,7 @@ class DoliDBPgsql extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return false|resource Resultset of answer */ - function query($query, $usesavepoint = 0, $type = 'auto') + public function query($query, $usesavepoint = 0, $type = 'auto') { global $conf; @@ -554,14 +554,14 @@ class DoliDBPgsql extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * * @param resource $resultset Curseur de la requete voulue * @return false|object Object result line or false if KO or end of cursor */ - function fetch_object($resultset) + public function fetch_object($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -569,14 +569,14 @@ class DoliDBPgsql extends DoliDB return pg_fetch_object($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return false|array Array */ - function fetch_array($resultset) + public function fetch_array($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -584,14 +584,14 @@ class DoliDBPgsql extends DoliDB return pg_fetch_array($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param resource $resultset Resultset of request * @return false|array Array */ - function fetch_row($resultset) + public function fetch_row($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -599,7 +599,7 @@ class DoliDBPgsql extends DoliDB return pg_fetch_row($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -607,7 +607,7 @@ class DoliDBPgsql extends DoliDB * @return int Nb of lines, -1 on error * @see affected_rows */ - function num_rows($resultset) + public function num_rows($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -615,7 +615,7 @@ class DoliDBPgsql extends DoliDB return pg_num_rows($resultset); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie le nombre de lignes dans le resultat d'une requete INSERT, DELETE ou UPDATE * @@ -623,7 +623,7 @@ class DoliDBPgsql extends DoliDB * @return int Nb of lines * @see num_rows */ - function affected_rows($resultset) + public function affected_rows($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -640,7 +640,7 @@ class DoliDBPgsql extends DoliDB * @param resource $resultset Result set of request * @return void */ - function free($resultset = null) + public function free($resultset = null) { // If resultset not provided, we take the last used by connexion if (! is_resource($resultset)) { $resultset=$this->_results; } @@ -656,7 +656,7 @@ class DoliDBPgsql extends DoliDB * @param int $offset Numero of line from where starting fetch * @return string String with SQL syntax to add a limit and offset */ - function plimit($limit = 0, $offset = 0) + public function plimit($limit = 0, $offset = 0) { global $conf; if (empty($limit)) return ""; @@ -672,7 +672,7 @@ class DoliDBPgsql extends DoliDB * @param string $stringtoencode String to escape * @return string String escaped */ - function escape($stringtoencode) + public function escape($stringtoencode) { return pg_escape_string($stringtoencode); } @@ -684,7 +684,7 @@ class DoliDBPgsql extends DoliDB * @param string $param Date TMS to convert * @return string Date in a string YYYY-MM-DD HH:MM:SS */ - function idate($param) + public function idate($param) { return dol_print_date($param, "%Y-%m-%d %H:%M:%S"); } @@ -697,7 +697,7 @@ class DoliDBPgsql extends DoliDB * @param string $resko resultat si test non egal * @return string chaine formate SQL */ - function ifsql($test, $resok, $resko) + public function ifsql($test, $resok, $resko) { return '(CASE WHEN '.$test.' THEN '.$resok.' ELSE '.$resko.' END)'; } @@ -707,7 +707,7 @@ class DoliDBPgsql extends DoliDB * * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ - function errno() + public function errno() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide. @@ -773,12 +773,12 @@ class DoliDBPgsql extends DoliDB * * @return string Error text */ - function error() + public function error() { return pg_last_error($this->db); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT * @@ -786,7 +786,7 @@ class DoliDBPgsql extends DoliDB * @param string $fieldid Field name * @return string Id of row */ - function last_insert_id($tab, $fieldid = 'rowid') + public function last_insert_id($tab, $fieldid = 'rowid') { // phpcs:enable //$result = pg_query($this->db,"SELECT MAX(".$fieldid.") FROM ".$tab); @@ -809,7 +809,7 @@ class DoliDBPgsql extends DoliDB * @param int $withQuotes Return string with quotes * @return string XXX(field) or XXX('value') or field or 'value' */ - function encrypt($fieldorvalue, $withQuotes = 0) + public function encrypt($fieldorvalue, $withQuotes = 0) { global $conf; @@ -830,7 +830,7 @@ class DoliDBPgsql extends DoliDB * @param int $value Value to decrypt * @return string Decrypted value if used */ - function decrypt($value) + public function decrypt($value) { global $conf; @@ -845,13 +845,13 @@ class DoliDBPgsql extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return connexion ID * * @return string Id connexion */ - function DDLGetConnectId() + public function DDLGetConnectId() { // phpcs:enable return '?'; @@ -859,7 +859,7 @@ class DoliDBPgsql extends DoliDB - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated @@ -871,7 +871,7 @@ class DoliDBPgsql extends DoliDB * @param string $owner Username of database owner * @return false|resource resource defined if OK, null if KO */ - function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') { // phpcs:enable if (empty($charset)) $charset=$this->forcecharset; @@ -886,7 +886,7 @@ class DoliDBPgsql extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List tables into a database * @@ -894,7 +894,7 @@ class DoliDBPgsql extends DoliDB * @param string $table Name of table filter ('xxx%') * @return array List of tables in an array */ - function DDLListTables($database, $table = '') + public function DDLListTables($database, $table = '') { // phpcs:enable $listtables=array(); @@ -912,7 +912,7 @@ class DoliDBPgsql extends DoliDB return $listtables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. * @@ -920,7 +920,7 @@ class DoliDBPgsql extends DoliDB * @return array Tableau des informations des champs de la table * */ - function DDLInfoTable($table) + public function DDLInfoTable($table) { // phpcs:enable $infotables=array(); @@ -954,7 +954,7 @@ class DoliDBPgsql extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a table into database * @@ -967,7 +967,7 @@ class DoliDBPgsql extends DoliDB * @param array $keys Tableau des champs cles noms => valeur * @return int <0 if KO, >=0 if OK */ - function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) { // phpcs:enable // FIXME: $fulltext_keys parameter is unused @@ -1035,14 +1035,14 @@ class DoliDBPgsql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a table into database * * @param string $table Name of table * @return int <0 if KO, >=0 if OK */ - function DDLDropTable($table) + public function DDLDropTable($table) { // phpcs:enable $sql = "DROP TABLE ".$table; @@ -1053,7 +1053,7 @@ class DoliDBPgsql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user to connect to database * @@ -1063,7 +1063,7 @@ class DoliDBPgsql extends DoliDB * @param string $dolibarr_main_db_name Database name where user must be granted * @return int <0 if KO, >=0 if OK */ - function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) + public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) { // phpcs:enable // Note: using ' on user does not works with pgsql @@ -1079,7 +1079,7 @@ class DoliDBPgsql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a pointer of line with description of a table or field * @@ -1087,7 +1087,7 @@ class DoliDBPgsql extends DoliDB * @param string $field Optionnel : Name of field if we want description of field * @return false|resource Resultset x (x->attname) */ - function DDLDescTable($table, $field = "") + public function DDLDescTable($table, $field = "") { // phpcs:enable $sql ="SELECT attname FROM pg_attribute, pg_type WHERE typname = '".$table."' AND attrelid = typrelid"; @@ -1099,7 +1099,7 @@ class DoliDBPgsql extends DoliDB return $this->_results; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new field into table * @@ -1109,7 +1109,7 @@ class DoliDBPgsql extends DoliDB * @param string $field_position Optionnel ex.: "after champtruc" * @return int <0 if KO, >0 if OK */ - function DDLAddField($table, $field_name, $field_desc, $field_position = "") + public function DDLAddField($table, $field_name, $field_desc, $field_position = "") { // phpcs:enable // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra @@ -1140,7 +1140,7 @@ class DoliDBPgsql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update format of a field into a table * @@ -1149,7 +1149,7 @@ class DoliDBPgsql extends DoliDB * @param string $field_desc Array with description of field format * @return int <0 if KO, >0 if OK */ - function DDLUpdateField($table, $field_name, $field_desc) + public function DDLUpdateField($table, $field_name, $field_desc) { // phpcs:enable $sql = "ALTER TABLE ".$table; @@ -1185,7 +1185,7 @@ class DoliDBPgsql extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a field from table * @@ -1193,7 +1193,7 @@ class DoliDBPgsql extends DoliDB * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK */ - function DDLDropField($table, $field_name) + public function DDLDropField($table, $field_name) { // phpcs:enable $sql= "ALTER TABLE ".$table." DROP COLUMN ".$field_name; @@ -1211,7 +1211,7 @@ class DoliDBPgsql extends DoliDB * * @return string Charset */ - function getDefaultCharacterSetDatabase() + public function getDefaultCharacterSetDatabase() { $resql=$this->query('SHOW SERVER_ENCODING'); if ($resql) @@ -1227,7 +1227,7 @@ class DoliDBPgsql extends DoliDB * * @return array List of Charset */ - function getListOfCharacterSet() + public function getListOfCharacterSet() { $resql=$this->query('SHOW SERVER_ENCODING'); $liste = array(); @@ -1252,7 +1252,7 @@ class DoliDBPgsql extends DoliDB * * @return string Collation value */ - function getDefaultCollationDatabase() + public function getDefaultCollationDatabase() { $resql=$this->query('SHOW LC_COLLATE'); if ($resql) @@ -1268,7 +1268,7 @@ class DoliDBPgsql extends DoliDB * * @return array Liste of Collation */ - function getListOfCollation() + public function getListOfCollation() { $resql=$this->query('SHOW LC_COLLATE'); $liste = array(); @@ -1292,7 +1292,7 @@ class DoliDBPgsql extends DoliDB * * @return string Full path of dump program */ - function getPathOfDump() + public function getPathOfDump() { $fullpathofdump='/pathtopgdump/pg_dump'; @@ -1320,7 +1320,7 @@ class DoliDBPgsql extends DoliDB * * @return string Full path of restore program */ - function getPathOfRestore() + public function getPathOfRestore() { //$tool='pg_restore'; $tool='psql'; @@ -1352,7 +1352,7 @@ class DoliDBPgsql extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerParametersValues($filter = '') + public function getServerParametersValues($filter = '') { $result=array(); @@ -1373,7 +1373,7 @@ class DoliDBPgsql extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerStatusValues($filter = '') + public function getServerStatusValues($filter = '') { /* This is to return current running requests. $sql='SELECT datname,procpid,current_query FROM pg_stat_activity ORDER BY procpid'; diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index 1ff024d6c6f..5ed0a05ee2a 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -38,8 +38,8 @@ class DoliDBSqlite3 extends DoliDB const LABEL='Sqlite3'; //! Version min database const VERSIONMIN='3.0.0'; - /** @var SQLite3Result Resultset of last query */ - private $_results; + /** @var SQLite3Result Resultset of last query */ + private $_results; const WEEK_MONDAY_FIRST=1; const WEEK_YEAR = 2; @@ -47,17 +47,17 @@ class DoliDBSqlite3 extends DoliDB /** - * Constructor. - * This create an opened connexion to a database server and eventually to a database + * Constructor. + * This create an opened connexion to a database server and eventually to a database * - * @param string $type Type of database (mysql, pgsql...) - * @param string $host Address of database server - * @param string $user Nom de l'utilisateur autorise - * @param string $pass Mot de passe - * @param string $name Nom de la database - * @param int $port Port of database server + * @param string $type Type of database (mysql, pgsql...) + * @param string $host Address of database server + * @param string $user Nom de l'utilisateur autorise + * @param string $pass Mot de passe + * @param string $name Nom de la database + * @param int $port Port of database server */ - function __construct($type, $host, $user, $pass, $name = '', $port = 0) + public function __construct($type, $host, $user, $pass, $name = '', $port = 0) { global $conf; @@ -134,7 +134,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return string SQL request line converted */ - static function convertSQLFromMysql($line, $type = 'ddl') + public static function convertSQLFromMysql($line, $type = 'ddl') { // Removed empty line if this is a comment line for SVN tagging if (preg_match('/^--\s\$Id/i', $line)) { @@ -295,14 +295,14 @@ class DoliDBSqlite3 extends DoliDB return $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Select a database * * @param string $database Name of database * @return boolean true if OK, false if KO */ - function select_db($database) + public function select_db($database) { // phpcs:enable dol_syslog(get_class($this)."::select_db database=".$database, LOG_DEBUG); @@ -323,7 +323,7 @@ class DoliDBSqlite3 extends DoliDB * @return SQLite3 Database access handler * @see close */ - function connect($host, $login, $passwd, $name, $port = 0) + public function connect($host, $login, $passwd, $name, $port = 0) { global $main_data_dir; @@ -356,7 +356,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Version string */ - function getVersion() + public function getVersion() { $tmp=$this->db->version(); return $tmp['versionString']; @@ -367,7 +367,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Version string */ - function getDriverInfo() + public function getDriverInfo() { return 'sqlite3 php driver'; } @@ -379,7 +379,7 @@ class DoliDBSqlite3 extends DoliDB * @return bool True if disconnect successfull, false otherwise * @see connect */ - function close() + public function close() { if ($this->db) { @@ -401,7 +401,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $type Type of SQL order ('ddl' for insert, update, select, delete or 'dml' for create, alter...) * @return SQLite3Result Resultset of answer */ - function query($query, $usesavepoint = 0, $type = 'auto') + public function query($query, $usesavepoint = 0, $type = 'auto') { $ret=null; $query = trim($query); @@ -490,14 +490,14 @@ class DoliDBSqlite3 extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la ligne courante (comme un objet) pour le curseur resultset * * @param SQLite3Result $resultset Curseur de la requete voulue * @return false|object Object result line or false if KO or end of cursor */ - function fetch_object($resultset) + public function fetch_object($resultset) { // phpcs:enable // Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion @@ -511,14 +511,14 @@ class DoliDBSqlite3 extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param SQLite3Result $resultset Resultset of request * @return false|array Array or false if KO or end of cursor */ - function fetch_array($resultset) + public function fetch_array($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -528,14 +528,14 @@ class DoliDBSqlite3 extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return datas as an array * * @param SQLite3Result $resultset Resultset of request * @return false|array Array or false if KO or end of cursor */ - function fetch_row($resultset) + public function fetch_row($resultset) { // phpcs:enable // If resultset not provided, we take the last used by connexion @@ -551,7 +551,7 @@ class DoliDBSqlite3 extends DoliDB } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -559,7 +559,7 @@ class DoliDBSqlite3 extends DoliDB * @return int Nb of lines * @see affected_rows */ - function num_rows($resultset) + public function num_rows($resultset) { // phpcs:enable // FIXME: SQLite3Result does not have a queryString member @@ -572,7 +572,7 @@ class DoliDBSqlite3 extends DoliDB return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return number of lines for result of a SELECT * @@ -580,7 +580,7 @@ class DoliDBSqlite3 extends DoliDB * @return int Nb of lines * @see affected_rows */ - function affected_rows($resultset) + public function affected_rows($resultset) { // phpcs:enable // FIXME: SQLite3Result does not have a queryString member @@ -602,7 +602,7 @@ class DoliDBSqlite3 extends DoliDB * @param SQLite3Result $resultset Curseur de la requete voulue * @return void */ - function free($resultset = null) + public function free($resultset = null) { // If resultset not provided, we take the last used by connexion if (! is_object($resultset)) { $resultset=$this->_results; } @@ -616,7 +616,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $stringtoencode String to escape * @return string String escaped */ - function escape($stringtoencode) + public function escape($stringtoencode) { return Sqlite3::escapeString($stringtoencode); } @@ -626,7 +626,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Error code (Exemples: DB_ERROR_TABLE_ALREADY_EXISTS, DB_ERROR_RECORD_ALREADY_EXISTS...) */ - function errno() + public function errno() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide. @@ -691,7 +691,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Error text */ - function error() + public function error() { if (! $this->connected) { // Si il y a eu echec de connexion, $this->db n'est pas valide pour sqlite_error. @@ -702,7 +702,7 @@ class DoliDBSqlite3 extends DoliDB } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get last ID after an insert INSERT * @@ -710,7 +710,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $fieldid Field name * @return int Id of row */ - function last_insert_id($tab, $fieldid = 'rowid') + public function last_insert_id($tab, $fieldid = 'rowid') { // phpcs:enable return $this->db->lastInsertRowId(); @@ -724,7 +724,7 @@ class DoliDBSqlite3 extends DoliDB * @param int $withQuotes Return string with quotes * @return string XXX(field) or XXX('value') or field or 'value' */ - function encrypt($fieldorvalue, $withQuotes = 0) + public function encrypt($fieldorvalue, $withQuotes = 0) { global $conf; @@ -757,7 +757,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $value Value to decrypt * @return string Decrypted value if used */ - function decrypt($value) + public function decrypt($value) { global $conf; @@ -785,20 +785,20 @@ class DoliDBSqlite3 extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return connexion ID * * @return string Id connexion */ - function DDLGetConnectId() + public function DDLGetConnectId() { // phpcs:enable return '?'; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new database * Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated @@ -810,7 +810,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $owner Username of database owner * @return SQLite3Result resource defined if OK, null if KO */ - function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') + public function DDLCreateDb($database, $charset = '', $collation = '', $owner = '') { // phpcs:enable if (empty($charset)) $charset=$this->forcecharset; @@ -832,7 +832,7 @@ class DoliDBSqlite3 extends DoliDB return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List tables into a database * @@ -840,7 +840,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $table Name of table filter ('xxx%') * @return array List of tables in an array */ - function DDLListTables($database, $table = '') + public function DDLListTables($database, $table = '') { // phpcs:enable $listtables=array(); @@ -860,7 +860,7 @@ class DoliDBSqlite3 extends DoliDB return $listtables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List information of columns into a table. * @@ -868,7 +868,7 @@ class DoliDBSqlite3 extends DoliDB * @return array Tableau des informations des champs de la table * TODO modify for sqlite */ - function DDLInfoTable($table) + public function DDLInfoTable($table) { // phpcs:enable $infotables=array(); @@ -887,7 +887,7 @@ class DoliDBSqlite3 extends DoliDB return $infotables; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a table into database * @@ -900,7 +900,7 @@ class DoliDBSqlite3 extends DoliDB * @param array $keys Tableau des champs cles noms => valeur * @return int <0 if KO, >=0 if OK */ - function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) + public function DDLCreateTable($table, $fields, $primary_key, $type, $unique_keys = null, $fulltext_keys = null, $keys = null) { // phpcs:enable // FIXME: $fulltext_keys parameter is unused @@ -967,14 +967,14 @@ class DoliDBSqlite3 extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a table into database * * @param string $table Name of table * @return int <0 if KO, >=0 if OK */ - function DDLDropTable($table) + public function DDLDropTable($table) { // phpcs:enable $sql = "DROP TABLE ".$table; @@ -985,7 +985,7 @@ class DoliDBSqlite3 extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a pointer of line with description of a table or field * @@ -993,7 +993,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $field Optionnel : Name of field if we want description of field * @return SQLite3Result Resource */ - function DDLDescTable($table, $field = "") + public function DDLDescTable($table, $field = "") { // phpcs:enable $sql="DESC ".$table." ".$field; @@ -1003,7 +1003,7 @@ class DoliDBSqlite3 extends DoliDB return $this->_results; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a new field into table * @@ -1013,7 +1013,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $field_position Optionnel ex.: "after champtruc" * @return int <0 if KO, >0 if OK */ - function DDLAddField($table, $field_name, $field_desc, $field_position = "") + public function DDLAddField($table, $field_name, $field_desc, $field_position = "") { // phpcs:enable // cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra @@ -1048,7 +1048,7 @@ class DoliDBSqlite3 extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update format of a field into a table * @@ -1057,7 +1057,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $field_desc Array with description of field format * @return int <0 if KO, >0 if OK */ - function DDLUpdateField($table, $field_name, $field_desc) + public function DDLUpdateField($table, $field_name, $field_desc) { // phpcs:enable $sql = "ALTER TABLE ".$table; @@ -1072,7 +1072,7 @@ class DoliDBSqlite3 extends DoliDB return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Drop a field from table * @@ -1080,7 +1080,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $field_name Name of field to drop * @return int <0 if KO, >0 if OK */ - function DDLDropField($table, $field_name) + public function DDLDropField($table, $field_name) { // phpcs:enable $sql= "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; @@ -1094,7 +1094,7 @@ class DoliDBSqlite3 extends DoliDB } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user and privileges to connect to database (even if database does not exists yet) * @@ -1104,7 +1104,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $dolibarr_main_db_name Database name where user must be granted * @return int <0 if KO, >=0 if OK */ - function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) + public function DDLCreateUser($dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_pass, $dolibarr_main_db_name) { // phpcs:enable $sql = "INSERT INTO user "; @@ -1147,7 +1147,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Charset */ - function getDefaultCharacterSetDatabase() + public function getDefaultCharacterSetDatabase() { return 'UTF-8'; } @@ -1157,7 +1157,7 @@ class DoliDBSqlite3 extends DoliDB * * @return array List of Charset */ - function getListOfCharacterSet() + public function getListOfCharacterSet() { $liste = array(); $i=0; @@ -1171,7 +1171,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Collation value */ - function getDefaultCollationDatabase() + public function getDefaultCollationDatabase() { return 'UTF-8'; } @@ -1181,7 +1181,7 @@ class DoliDBSqlite3 extends DoliDB * * @return array List of Collation */ - function getListOfCollation() + public function getListOfCollation() { $liste = array(); $i=0; @@ -1195,7 +1195,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Full path of dump program */ - function getPathOfDump() + public function getPathOfDump() { // FIXME: not for SQLite $fullpathofdump='/pathtomysqldump/mysqldump'; @@ -1215,7 +1215,7 @@ class DoliDBSqlite3 extends DoliDB * * @return string Full path of restore program */ - function getPathOfRestore() + public function getPathOfRestore() { // FIXME: not for SQLite $fullpathofimport='/pathtomysql/mysql'; @@ -1236,7 +1236,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerParametersValues($filter = '') + public function getServerParametersValues($filter = '') { $result=array(); static $pragmas; @@ -1247,7 +1247,7 @@ class DoliDBSqlite3 extends DoliDB $pragmas = array( 'application_id', 'auto_vacuum', 'automatic_index', 'busy_timeout', 'cache_size', 'cache_spill', 'case_sensitive_like', 'checkpoint_fullsync', 'collation_list', - 'compile_options', 'data_version', /*'database_list',*/ + 'compile_options', 'data_version', /*'database_list',*/ 'defer_foreign_keys', 'encoding', 'foreign_key_check', 'freelist_count', 'full_column_names', 'fullsync', 'ingore_check_constraints', 'integrity_check', 'journal_mode', 'journal_size_limit', 'legacy_file_format', 'locking_mode', @@ -1285,7 +1285,7 @@ class DoliDBSqlite3 extends DoliDB * @param string $filter Filter list on a particular value * @return array Array of key-values (key=>value) */ - function getServerStatusValues($filter = '') + public function getServerStatusValues($filter = '') { $result=array(); /* diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php index cfa05289f4b..fd13eb2fd26 100644 --- a/htdocs/core/js/lib_foot.js.php +++ b/htdocs/core/js/lib_foot.js.php @@ -21,13 +21,13 @@ * \brief File that include javascript functions (included if option use_javascript activated) */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); -if (! defined('NOLOGIN')) define('NOLOGIN',1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (! defined('NOLOGIN')) define('NOLOGIN', 1); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); @@ -159,4 +159,3 @@ print ' } }); });'."\n"; - diff --git a/htdocs/core/js/lib_gravatar.js.php b/htdocs/core/js/lib_gravatar.js.php index dad6482460a..e1e900b6d00 100644 --- a/htdocs/core/js/lib_gravatar.js.php +++ b/htdocs/core/js/lib_gravatar.js.php @@ -22,16 +22,16 @@ * JQuery (providing object $) library must be loaded before this file. */ -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); // Not disabled cause need to load personalized language -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); // Not disabled cause need to do translations -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); -if (! defined('NOLOGIN')) define('NOLOGIN',1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); // Not disabled cause need to load personalized language +//if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); // Not disabled cause need to do translations +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (! defined('NOLOGIN')) define('NOLOGIN', 1); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php index 5b909c6e148..07a47090792 100644 --- a/htdocs/core/js/lib_head.js.php +++ b/htdocs/core/js/lib_head.js.php @@ -24,13 +24,13 @@ * JQuery (providing object $) and JQuery-UI (providing $datepicker) libraries must be loaded before this file. */ -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK',1); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); -if (! defined('NOLOGIN')) define('NOLOGIN',1); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1); -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1); -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', 1); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); +if (! defined('NOLOGIN')) define('NOLOGIN', 1); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', 1); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', 1); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); session_cache_limiter('public'); diff --git a/htdocs/core/lib/json.lib.php b/htdocs/core/lib/json.lib.php index f58d1b44dbf..7eb0fbb1acc 100644 --- a/htdocs/core/lib/json.lib.php +++ b/htdocs/core/lib/json.lib.php @@ -214,7 +214,7 @@ if (! function_exists('json_decode')) * @param bool $assoc False return an object, true return an array * @return mixed Object or Array */ - function json_decode($json, $assoc=false) + function json_decode($json, $assoc = false) { return dol_json_decode($json, $assoc); } @@ -229,7 +229,7 @@ if (! function_exists('json_decode')) * @return mixed Object or Array or false on error * @see json_decode() */ -function dol_json_decode($json, $assoc=false) +function dol_json_decode($json, $assoc = false) { dol_syslog("For better performance, enable the native json in your PHP", LOG_WARNING); @@ -242,8 +242,8 @@ function dol_json_decode($json, $assoc=false) if (! $comment) { if (($json[$i] == '{') || ($json[$i] == '[')) $out.= 'array('; - else if (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; - else if ($json[$i] == ':') $out.= ' => '; + elseif (($json[$i] == '}') || ($json[$i] == ']')) $out.= ')'; + elseif ($json[$i] == ':') $out.= ' => '; else $out.=$json[$i]; } else $out.= $json[$i]; @@ -292,7 +292,7 @@ function _unval($val) // single, escaped unicode character $utf16 = chr(hexdec($reg[1])) . chr(hexdec($reg[2])); $utf8 = utf162utf8($utf16); - $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i',$utf8,$val); + $val=preg_replace('/\\\u'.$reg[1].$reg[2].'/i', $utf8, $val); } return $val; } diff --git a/htdocs/core/menus/standard/auguria_menu.php b/htdocs/core/menus/standard/auguria_menu.php index 6495aced16d..74ecba32db5 100644 --- a/htdocs/core/menus/standard/auguria_menu.php +++ b/htdocs/core/menus/standard/auguria_menu.php @@ -32,15 +32,15 @@ class MenuManager * @var DoliDB Database handler. */ public $db; - - var $type_user; // Put 0 for internal users, 1 for external users - var $atarget=""; // To store default target to use onto links - var $name="auguria"; - var $menu_array; - var $menu_array_after; + public $type_user; // Put 0 for internal users, 1 for external users + public $atarget=""; // To store default target to use onto links + public $name="auguria"; - var $tabMenu; + public $menu_array; + public $menu_array_after; + + public $tabMenu; /** @@ -49,7 +49,7 @@ class MenuManager * @param DoliDB $db Database handler * @param int $type_user Type of user */ - function __construct($db, $type_user) + public function __construct($db, $type_user) { $this->type_user=$type_user; $this->db=$db; @@ -63,7 +63,7 @@ class MenuManager * @param string $forceleftmenu To force leftmenu to load * @return void */ - function loadMenu($forcemainmenu = '', $forceleftmenu = '') + public function loadMenu($forcemainmenu = '', $forceleftmenu = '') { global $conf, $user, $langs; @@ -123,7 +123,7 @@ class MenuManager * @param array $moredata An array with more data to output * @return int 0 or nb of top menu entries if $mode = 'topnb' */ - function showmenu($mode, $moredata = null) + public function showmenu($mode, $moredata = null) { global $conf, $langs, $user; diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 61394df6126..2dea6a53c5d 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -32,14 +32,14 @@ class MenuManager */ public $db; - var $type_user; // Put 0 for internal users, 1 for external users - var $atarget=""; // To store default target to use onto links - var $name="eldy"; + public $type_user; // Put 0 for internal users, 1 for external users + public $atarget=""; // To store default target to use onto links + public $name="eldy"; - var $menu_array; - var $menu_array_after; + public $menu_array; + public $menu_array_after; - var $tabMenu; + public $tabMenu; /** @@ -48,7 +48,7 @@ class MenuManager * @param DoliDB $db Database handler * @param int $type_user Type of user */ - function __construct($db, $type_user) + public function __construct($db, $type_user) { $this->type_user=$type_user; $this->db=$db; @@ -62,7 +62,7 @@ class MenuManager * @param string $forceleftmenu To force leftmenu to load * @return void */ - function loadMenu($forcemainmenu = '', $forceleftmenu = '') + public function loadMenu($forcemainmenu = '', $forceleftmenu = '') { // On sauve en session le menu principal choisi if (isset($_GET["mainmenu"])) $_SESSION["mainmenu"]=$_GET["mainmenu"]; @@ -123,7 +123,7 @@ class MenuManager * @param array $moredata An array with more data to output * @return int 0 or nb of top menu entries if $mode = 'topnb' */ - function showmenu($mode, $moredata = null) + public function showmenu($mode, $moredata = null) { global $conf, $langs, $user; diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index 643de2ebd71..c0ddb924a31 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -30,11 +30,11 @@ class MenuManager */ public $db; - var $type_user=0; // Put 0 for internal users, 1 for external users - var $atarget=""; // To store default target to use onto links + public $type_user=0; // Put 0 for internal users, 1 for external users + public $atarget=""; // To store default target to use onto links - var $menu; - var $menu_array_after; + public $menu; + public $menu_array_after; /** @@ -43,7 +43,7 @@ class MenuManager * @param DoliDB $db Database handler * @param int $type_user Type of user */ - function __construct($db, $type_user) + public function __construct($db, $type_user) { $this->type_user=$type_user; $this->db=$db; @@ -55,7 +55,7 @@ class MenuManager * * @return void */ - function loadMenu() + public function loadMenu() { } @@ -67,7 +67,7 @@ class MenuManager * @param array $moredata An array with more data to output * @return int 0 or nb of top menu entries if $mode = 'topnb' */ - function showmenu($mode, $moredata = null) + public function showmenu($mode, $moredata = null) { global $user,$conf,$langs,$dolibarr_main_db_name; diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 76033d4c0cb..2e9af363d08 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -7,6 +7,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2014 Raphaël Doursenaud * Copyright (C) 2018 Josep Lluís Amador + * Copyright (C) 2019 Frédéric France * * 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 @@ -334,7 +335,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin; @@ -369,6 +370,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // We need constructor into function unActivateModule into admin.lib.php + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Enables a module. * Inserts all informations into database @@ -381,47 +383,57 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int 1 if OK, 0 if KO */ - function _init($array_sql, $options = '') + protected function _init($array_sql, $options = '') { + // phpcs:enable global $conf; $err=0; $this->db->begin(); // Insert activation module constant - if (! $err) { $err+=$this->_active(); + if (! $err) { + $err+=$this->_active(); } // Insert new pages for tabs (into llx_const) - if (! $err) { $err+=$this->insert_tabs(); + if (! $err) { + $err+=$this->insert_tabs(); } // Insert activation of module's parts - if (! $err) { $err+=$this->insert_module_parts(); + if (! $err) { + $err+=$this->insert_module_parts(); } // Insert constant defined by modules (into llx_const) - if (! $err && ! preg_match('/newboxdefonly/', $options)) { $err+=$this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade + if (! $err && ! preg_match('/newboxdefonly/', $options)) { + $err+=$this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade } // Insert boxes def into llx_boxes_def and boxes setup (into llx_boxes) - if (! $err && ! preg_match('/noboxes/', $options)) { $err+=$this->insert_boxes($options); + if (! $err && ! preg_match('/noboxes/', $options)) { + $err+=$this->insert_boxes($options); } // Insert cron job entries (entry in llx_cronjobs) - if (! $err) { $err+=$this->insert_cronjobs(); + if (! $err) { + $err+=$this->insert_cronjobs(); } // Insert permission definitions of module into llx_rights_def. If user is admin, grant this permission to user. - if (! $err) { $err+=$this->insert_permissions(1, null, 1); + if (! $err) { + $err+=$this->insert_permissions(1, null, 1); } // Insert specific menus entries into database - if (! $err) { $err+=$this->insert_menus(); + if (! $err) { + $err+=$this->insert_menus(); } // Create module's directories - if (! $err) { $err+=$this->create_dirs(); + if (! $err) { + $err+=$this->create_dirs(); } // Execute addons requests @@ -466,6 +478,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Disable function. Deletes the module constants and boxes from the database. * @@ -474,46 +487,56 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int 1 if OK, 0 if KO */ - function _remove($array_sql, $options = '') + protected function _remove($array_sql, $options = '') { + // phpcs:enable $err=0; $this->db->begin(); // Remove activation module line (constant MAIN_MODULE_MYMODULE in llx_const) - if (! $err) { $err+=$this->_unactive(); + if (! $err) { + $err+=$this->_unactive(); } // Remove activation of module's new tabs (MAIN_MODULE_MYMODULE_TABS_XXX in llx_const) - if (! $err) { $err+=$this->delete_tabs(); + if (! $err) { + $err+=$this->delete_tabs(); } // Remove activation of module's parts (MAIN_MODULE_MYMODULE_XXX in llx_const) - if (! $err) { $err+=$this->delete_module_parts(); + if (! $err) { + $err+=$this->delete_module_parts(); } // Remove constants defined by modules - if (! $err) { $err+=$this->delete_const(); + if (! $err) { + $err+=$this->delete_const(); } // Remove list of module's available boxes (entry in llx_boxes) - if (! $err && ! preg_match('/(newboxdefonly|noboxes)/', $options)) { $err+=$this->delete_boxes(); // We don't have to delete if option ask to keep boxes safe or ask to add new box def only + if (! $err && ! preg_match('/(newboxdefonly|noboxes)/', $options)) { + $err+=$this->delete_boxes(); // We don't have to delete if option ask to keep boxes safe or ask to add new box def only } // Remove list of module's cron job entries (entry in llx_cronjobs) - if (! $err) { $err+=$this->delete_cronjobs(); + if (! $err) { + $err+=$this->delete_cronjobs(); } // Remove module's permissions from list of available permissions (entries in llx_rights_def) - if (! $err) { $err+=$this->delete_permissions(); + if (! $err) { + $err+=$this->delete_permissions(); } // Remove module's menus (entries in llx_menu) - if (! $err) { $err+=$this->delete_menus(); + if (! $err) { + $err+=$this->delete_menus(); } // Remove module's directories - if (! $err) { $err+=$this->delete_dirs(); + if (! $err) { + $err+=$this->delete_dirs(); } // Run complementary sql requests @@ -549,7 +572,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated module name */ - function getName() + public function getName() { global $langs; $langs->load("admin"); @@ -585,7 +608,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated module description */ - function getDesc() + public function getDesc() { global $langs; $langs->load("admin"); @@ -621,7 +644,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Long description of a module from README.md of from property. */ - function getDescLong() + public function getDescLong() { global $langs; $langs->load("admin"); @@ -639,11 +662,12 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it @include_once DOL_DOCUMENT_ROOT.'/core/lib/parsemd.lib.php'; $content = dolMd2Html( - $content, 'parsedown', + $content, + 'parsedown', array( - 'doc/'=>dol_buildpath(strtolower($this->name).'/doc/', 1), - 'img/'=>dol_buildpath(strtolower($this->name).'/img/', 1), - 'images/'=>dol_buildpath(strtolower($this->name).'/imgages/', 1), + 'doc/' => dol_buildpath(strtolower($this->name).'/doc/', 1), + 'img/' => dol_buildpath(strtolower($this->name).'/img/', 1), + 'images/' => dol_buildpath(strtolower($this->name).'/imgages/', 1), ) ); } @@ -652,8 +676,9 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $content = nl2br($content); } } - else // Mostly for internal modules + else { + // Mostly for internal modules if (! empty($this->descriptionlong)) { if (is_array($this->langfiles)) { foreach($this->langfiles as $val) @@ -675,7 +700,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Path of file if a README file was found. */ - function getDescLongReadmeFound() + public function getDescLongReadmeFound() { global $langs; @@ -710,7 +735,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Content of ChangeLog */ - function getChangeLog() + public function getChangeLog() { global $langs; $langs->load("admin"); @@ -755,7 +780,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Publisher name */ - function getPublisher() + public function getPublisher() { return $this->editor_name; } @@ -765,7 +790,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Publisher url */ - function getPublisherUrl() + public function getPublisherUrl() { return $this->editor_url; } @@ -778,7 +803,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param int $translated 1=Special version keys are translated, 0=Special version keys are not translated * @return string Module version */ - function getVersion($translated = 1) + public function getVersion($translated = 1) { global $langs; $langs->load("admin"); @@ -786,14 +811,20 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $ret=''; $newversion=preg_replace('/_deprecated/', '', $this->version); - if ($newversion == 'experimental') { $ret=($translated?$langs->transnoentitiesnoconv("VersionExperimental"):$newversion); - } elseif ($newversion == 'development') { $ret=($translated?$langs->transnoentitiesnoconv("VersionDevelopment"):$newversion); - } elseif ($newversion == 'dolibarr') { $ret=DOL_VERSION; - } elseif ($newversion) { $ret=$newversion; - } else { $ret=($translated?$langs->transnoentitiesnoconv("VersionUnknown"):'unknown'); + if ($newversion == 'experimental') { + $ret=($translated?$langs->transnoentitiesnoconv("VersionExperimental"):$newversion); + } elseif ($newversion == 'development') { + $ret=($translated?$langs->transnoentitiesnoconv("VersionDevelopment"):$newversion); + } elseif ($newversion == 'dolibarr') { + $ret=DOL_VERSION; + } elseif ($newversion) { + $ret=$newversion; + } else { + $ret=($translated?$langs->transnoentitiesnoconv("VersionUnknown"):'unknown'); } - if (preg_match('/_deprecated/', $this->version)) { $ret.=($translated?' ('.$langs->transnoentitiesnoconv("Deprecated").')':$this->version); + if (preg_match('/_deprecated/', $this->version)) { + $ret.=($translated?' ('.$langs->transnoentitiesnoconv("Deprecated").')':$this->version); } return $ret; } @@ -804,15 +835,19 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string 'core', 'external' or 'unknown' */ - function isCoreOrExternalModule() + public function isCoreOrExternalModule() { - if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') { return 'core'; + if ($this->version == 'dolibarr' || $this->version == 'dolibarr_deprecated') { + return 'core'; } - if (! empty($this->version) && ! in_array($this->version, array('experimental','development'))) { return 'external'; + if (! empty($this->version) && ! in_array($this->version, array('experimental','development'))) { + return 'external'; } - if (! empty($this->editor_name) || ! empty($this->editor_url)) { return 'external'; + if (! empty($this->editor_name) || ! empty($this->editor_url)) { + return 'external'; } - if ($this->numero >= 100000) { return 'external'; + if ($this->numero >= 100000) { + return 'external'; } return 'unknown'; } @@ -823,7 +858,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string[] Language files list */ - function getLangFilesArray() + public function getLangFilesArray() { return $this->langfiles; } @@ -835,7 +870,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated databaset label */ - function getExportDatasetLabel($r) + public function getExportDatasetLabel($r) { global $langs; @@ -859,7 +894,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return string Translated dataset label */ - function getImportDatasetLabel($r) + public function getImportDatasetLabel($r) { global $langs; @@ -882,7 +917,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return timestamp Date of last activation */ - function getLastActivationDate() + public function getLastActivationDate() { global $conf; @@ -892,11 +927,12 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $err++; - } else - { + if (! $resql) { + $err++; + } else { $obj=$this->db->fetch_object($resql); - if ($obj) { return $this->db->jdate($obj->tms); + if ($obj) { + return $this->db->jdate($obj->tms); } } @@ -909,7 +945,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return array Array array('authorid'=>Id of last activation user, 'lastactivationdate'=>Date of last activation) */ - function getLastActivationInfo() + public function getLastActivationInfo() { global $conf; @@ -919,15 +955,16 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it dol_syslog(get_class($this)."::getLastActiveDate", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $err++; - } else - { + if (! $resql) { + $err++; + } else { $obj=$this->db->fetch_object($resql); $tmp=array(); if ($obj->note) { $tmp=json_decode($obj->note, true); } - if ($obj) { return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); + if ($obj) { + return array('authorid'=>$tmp['authorid'], 'ip'=>$tmp['ip'], 'lastactivationdate'=>$this->db->jdate($obj->tms)); } } @@ -940,7 +977,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function _active() + private function _active() { global $conf, $user; @@ -955,7 +992,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it dol_syslog(get_class($this)."::_active delete activation constant", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $err++; + if (! $resql) { + $err++; } $note=json_encode(array('authorid'=>(is_object($user)?$user->id:0), 'ip'=>(empty($_SERVER['REMOTE_ADDR'])?'':$_SERVER['REMOTE_ADDR']))); @@ -980,7 +1018,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function _unactive() + private function _unactive() { global $conf; @@ -1000,7 +1038,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create tables and keys required by module. * Files module.sql and module.key.sql with create table and create keys @@ -1010,7 +1048,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param string $reldir Relative directory where to scan files * @return int <=0 if KO, >0 if OK */ - function _load_tables($reldir) + private function _load_tables($reldir) { // phpcs:enable global $conf; @@ -1018,7 +1056,8 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $error=0; $dirfound=0; - if (empty($reldir)) { return 1; + if (empty($reldir)) { + return 1; } include_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php'; @@ -1119,7 +1158,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds boxes * @@ -1127,7 +1166,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function insert_boxes($option = '') + public function insert_boxes($option = '') { // phpcs:enable include_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; @@ -1219,13 +1258,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes boxes * * @return int Error count (0 if OK) */ - function delete_boxes() + public function delete_boxes() { // phpcs:enable global $conf; @@ -1292,13 +1331,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds cronjobs * * @return int Error count (0 if OK) */ - function insert_cronjobs() + public function insert_cronjobs() { // phpcs:enable include_once DOL_DOCUMENT_ROOT . '/core/class/infobox.class.php'; @@ -1332,13 +1371,17 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // Search if cron entry already present $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."cronjob"; $sql.= " WHERE module_name = '".$this->db->escape(empty($this->rights_class)?strtolower($this->name):$this->rights_class)."'"; - if ($class) { $sql.= " AND classesname = '".$this->db->escape($class)."'"; + if ($class) { + $sql.= " AND classesname = '".$this->db->escape($class)."'"; } - if ($objectname) { $sql.= " AND objectname = '".$this->db->escape($objectname)."'"; + if ($objectname) { + $sql.= " AND objectname = '".$this->db->escape($objectname)."'"; } - if ($method) { $sql.= " AND methodename = '".$this->db->escape($method)."'"; + if ($method) { + $sql.= " AND methodename = '".$this->db->escape($method)."'"; } - if ($command) { $sql.= " AND command = '".$this->db->escape($command)."'"; + if ($command) { + $sql.= " AND command = '".$this->db->escape($command)."'"; } $sql.= " AND entity = ".$entity; // Must be exact entity @@ -1410,13 +1453,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes boxes * * @return int Error count (0 if OK) */ - function delete_cronjobs() + public function delete_cronjobs() { // phpcs:enable global $conf; @@ -1441,13 +1484,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes tabs * * @return int Error count (0 if OK) */ - function delete_tabs() + public function delete_tabs() { // phpcs:enable global $conf; @@ -1467,13 +1510,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds tabs * * @return int Error count (0 if ok) */ - function insert_tabs() + public function insert_tabs() { // phpcs:enable global $conf; @@ -1533,13 +1576,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds constants * * @return int Error count (0 if OK) */ - function insert_const() + public function insert_const() { // phpcs:enable global $conf; @@ -1605,13 +1648,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes constants tagged 'deleteonunactive' * * @return int <0 if KO, 0 if OK */ - function delete_const() + public function delete_const() { // phpcs:enable global $conf; @@ -1641,7 +1684,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds access rights * @@ -1650,7 +1693,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int Error count (0 if OK) */ - function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0) + public function insert_permissions($reinitadminperms = 0, $force_entity = null, $notrigger = 0) { // phpcs:enable global $conf,$user; @@ -1680,7 +1723,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it $r_def = $this->rights[$key][3]; $r_perms = $this->rights[$key][4]; $r_subperms = isset($this->rights[$key][5])?$this->rights[$key][5]:''; - $r_modul = empty($this->rights_class)?strtolower($this->name):$this->rights_class; + $r_modul = empty($this->rights_class)?strtolower($this->name):$this->rights_class; if (empty($r_type)) { $r_type='w'; } @@ -1788,13 +1831,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes access rights * * @return int Error count (0 if OK) */ - function delete_permissions() + public function delete_permissions() { // phpcs:enable global $conf; @@ -1814,13 +1857,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds menu entries * * @return int Error count (0 if OK) */ - function insert_menus() + public function insert_menus() { // phpcs:enable global $user; @@ -1918,13 +1961,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes menu entries * * @return int Error count (0 if OK) */ - function delete_menus() + public function delete_menus() { // phpcs:enable global $conf; @@ -1948,13 +1991,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Creates directories * * @return int Error count (0 if OK) */ - function create_dirs() + public function create_dirs() { // phpcs:enable global $langs, $conf; @@ -2008,7 +2051,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds directories definitions * @@ -2017,7 +2060,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it * * @return int Error count (0 if OK) */ - function insert_dirs($name, $dir) + public function insert_dirs($name, $dir) { // phpcs:enable global $conf; @@ -2052,13 +2095,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes directories * * @return int Error count (0 if OK) */ - function delete_dirs() + public function delete_dirs() { // phpcs:enable global $conf; @@ -2078,13 +2121,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $err; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adds generic parts * * @return int Error count (0 if OK) */ - function insert_module_parts() + public function insert_module_parts() { // phpcs:enable global $conf; @@ -2155,13 +2198,13 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it return $error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Removes generic parts * * @return int Error count (0 if OK) */ - function delete_module_parts() + public function delete_module_parts() { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/action/modules_action.php b/htdocs/core/modules/action/modules_action.php index 4b090b9b56f..104e1e37ae9 100644 --- a/htdocs/core/modules/action/modules_action.php +++ b/htdocs/core/modules/action/modules_action.php @@ -33,7 +33,7 @@ abstract class ModeleAction extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -41,7 +41,7 @@ abstract class ModeleAction extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/action/rapport.pdf.php b/htdocs/core/modules/action/rapport.pdf.php index eaf71d9f8af..52b70caf47f 100644 --- a/htdocs/core/modules/action/rapport.pdf.php +++ b/htdocs/core/modules/action/rapport.pdf.php @@ -71,7 +71,7 @@ class CommActionRapport * @param int $month Month * @param int $year Year */ - function __construct($db, $month, $year) + public function __construct($db, $month, $year) { global $conf, $langs; @@ -99,16 +99,16 @@ class CommActionRapport $this->subject=$langs->transnoentitiesnoconv("ActionsReport").' '.$this->year."-".$this->month; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Write the object to document file to disk * * @param int $socid Thirdparty id * @param int $catid Cat id * @param Translate $outputlangs Lang object for output language * @return int 1=OK, 0=KO - */ - function write_file($socid = 0, $catid = 0, $outputlangs = '') + */ + public function write_file($socid = 0, $catid = 0, $outputlangs = '') { // phpcs:enable global $user,$conf,$langs,$hookmanager; @@ -210,7 +210,7 @@ class CommActionRapport * @param Translate $outputlangs Object langs * @return int 1 */ - function _pages(&$pdf, $outputlangs) + private function _pages(&$pdf, $outputlangs) { global $conf; @@ -335,7 +335,7 @@ class CommActionRapport * @param int $pagenb Page nb * @return integer */ - function _pagehead(&$pdf, $outputlangs, $pagenb) + private function _pagehead(&$pdf, $outputlangs, $pagenb) { global $conf,$langs; diff --git a/htdocs/core/modules/bank/doc/pdf_ban.modules.php b/htdocs/core/modules/bank/doc/pdf_ban.modules.php index 98f86e9a596..53a38eb70ed 100644 --- a/htdocs/core/modules/bank/doc/pdf_ban.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_ban.modules.php @@ -50,7 +50,7 @@ class pdf_ban extends ModeleBankAccountDoc * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -90,7 +90,7 @@ class pdf_ban extends ModeleBankAccountDoc } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant le projet sur le disque * @@ -98,7 +98,7 @@ class pdf_ban extends ModeleBankAccountDoc * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs) + public function write_file($object, $outputlangs) { // phpcs:enable global $conf, $hookmanager, $langs, $user; @@ -288,7 +288,7 @@ class pdf_ban extends ModeleBankAccountDoc * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -304,7 +304,7 @@ class pdf_ban extends ModeleBankAccountDoc * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -390,7 +390,7 @@ class pdf_ban extends ModeleBankAccountDoc * @param int $hidefreetext 1=Hide free text * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php index f61758abf92..bbd5858192c 100644 --- a/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php +++ b/htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php @@ -52,7 +52,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -92,7 +92,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant le projet sur le disque * @@ -105,7 +105,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param null|array $moreparams More parameters * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { // phpcs:enable global $conf, $hookmanager, $langs, $user, $mysoc; @@ -435,7 +435,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -443,7 +443,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -453,7 +453,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf, $mysoc; @@ -480,7 +480,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show area for the customer to sign * @@ -490,7 +490,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _signature_area(&$pdf, $object, $posy, $outputlangs) + private function _signature_area(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -531,7 +531,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -623,7 +623,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc * @param int $hidefreetext 1=Hide free text * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/bank/modules_bank.php b/htdocs/core/modules/bank/modules_bank.php index 8cdf2ba7ebe..f965e29ccce 100644 --- a/htdocs/core/modules/bank/modules_bank.php +++ b/htdocs/core/modules/bank/modules_bank.php @@ -37,7 +37,7 @@ abstract class ModeleBankAccountDoc extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -45,7 +45,7 @@ abstract class ModeleBankAccountDoc extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php index cfbe51b0579..19744177e40 100644 --- a/htdocs/core/modules/barcode/doc/phpbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/phpbarcode.modules.php @@ -49,7 +49,7 @@ class modPhpbarcode extends ModeleBarCode * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -60,7 +60,7 @@ class modPhpbarcode extends ModeleBarCode * * @return string Texte descripif */ - function info() + public function info() { global $langs; @@ -76,7 +76,7 @@ class modPhpbarcode extends ModeleBarCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs; @@ -90,7 +90,7 @@ class modPhpbarcode extends ModeleBarCode * @param string $encoding Encoding norm * @return int >0 if supported, 0 if not */ - function encodingIsSupported($encoding) + public function encodingIsSupported($encoding) { global $genbarcode_loc; //print 'genbarcode_loc='.$genbarcode_loc.' encoding='.$encoding;exit; @@ -100,8 +100,7 @@ class modPhpbarcode extends ModeleBarCode if ($encoding == 'ISBN') $supported=1; // Formats that hangs on Windows (when genbarcode.exe for Windows is called, so they are not // activated on Windows) - if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) - { + if (file_exists($genbarcode_loc) && empty($_SERVER["WINDIR"])) { if ($encoding == 'EAN8') $supported=1; if ($encoding == 'UPC') $supported=1; if ($encoding == 'C39') $supported=1; @@ -120,7 +119,7 @@ class modPhpbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error * @return int <0 if KO, >0 if OK */ - function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $_GET,$_SERVER; global $conf; @@ -161,7 +160,7 @@ class modPhpbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error * @return int <0 if KO, >0 if OK */ - function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $conf,$filebarcode; diff --git a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php index f6eff1e2c5d..17793a5dfd4 100644 --- a/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php +++ b/htdocs/core/modules/barcode/doc/tcpdfbarcode.modules.php @@ -49,7 +49,7 @@ class modTcpdfbarcode extends ModeleBarCode * * @return string Text with description */ - function info() + public function info() { global $langs; @@ -61,7 +61,7 @@ class modTcpdfbarcode extends ModeleBarCode * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -72,7 +72,7 @@ class modTcpdfbarcode extends ModeleBarCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs; @@ -85,7 +85,7 @@ class modTcpdfbarcode extends ModeleBarCode * @param string $encoding Encoding norm * @return int >0 if supported, 0 if not */ - function encodingIsSupported($encoding) + public function encodingIsSupported($encoding) { $tcpdfEncoding = $this->getTcpdfEncodingType($encoding); if (empty($tcpdfEncoding)) { @@ -105,7 +105,7 @@ class modTcpdfbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error (not used with this engine) * @return int <0 if KO, >0 if OK */ - function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function buildBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $_GET; @@ -152,7 +152,7 @@ class modTcpdfbarcode extends ModeleBarCode * @param integer $nooutputiferror No output if error (not used with this engine) * @return int <0 if KO, >0 if OK */ - function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) + public function writeBarCode($code, $encoding, $readable = 'Y', $scale = 1, $nooutputiferror = 0) { global $conf,$_GET; diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php index 239a1683fad..936e7b87be4 100644 --- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php +++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php @@ -61,7 +61,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 0; $this->code_modifiable = 1; @@ -77,7 +77,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Translate $langs Object langs * @return string Description of module */ - function info($langs) + public function info($langs) { global $conf, $mc; global $form; @@ -119,7 +119,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Product $objproduct Object product * @return string Return string example */ - function getExample($langs, $objproduct = 0) + public function getExample($langs, $objproduct = 0) { $examplebarcode = $this->getNextValue($objproduct, ''); if (! $examplebarcode) @@ -142,7 +142,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param string $type Type of barcode (EAN, ISBN, ...) * @return string Value if OK, '' if module not configured, <0 if KO */ - function getNextValue($objproduct = null, $type = '') + public function getNextValue($objproduct = null, $type = '') { global $db,$conf; @@ -184,7 +184,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $product, $thirdparty_type, $type) + public function verif($db, &$code, $product, $thirdparty_type, $type) { global $conf; @@ -235,7 +235,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if a code is used (by other element) * @@ -244,7 +244,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param Product $product Objet product * @return int 0 if available, <0 if KO */ - function verif_dispo($db, $code, $product) + public function verif_dispo($db, $code, $product) { // phpcs:enable $sql = "SELECT barcode FROM ".MAIN_DB_PREFIX."product"; @@ -269,7 +269,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return if a barcode value match syntax * @@ -277,7 +277,7 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode * @param string $typefortest Type of barcode (ISBN, EAN, ...) * @return int 0 if OK, <0 if KO */ - function verif_syntax($codefortest, $typefortest) + public function verif_syntax($codefortest, $typefortest) { // phpcs:enable global $conf; @@ -296,15 +296,15 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode $newcodefortest=$codefortest; - // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test - if (in_array($typefortest, array('EAN13','ISBN'))) // We remove the CRC char not included into mask - { - if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) - { - if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest, 0, 12); - dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); - } - } + // Special case, if mask is on 12 digits instead of 13, we remove last char into code to test + if (in_array($typefortest, array('EAN13','ISBN'))) // We remove the CRC char not included into mask + { + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i', $mask, $reg)) + { + if (strlen($reg[1]) == 12) $newcodefortest=substr($newcodefortest, 0, 12); + dol_syslog(get_class($this).'::verif_syntax newcodefortest='.$newcodefortest); + } + } $result=check_value($mask, $newcodefortest); if (is_string($result)) diff --git a/htdocs/core/modules/barcode/modules_barcode.class.php b/htdocs/core/modules/barcode/modules_barcode.class.php index 7e0eba53571..6a205b57d8c 100644 --- a/htdocs/core/modules/barcode/modules_barcode.class.php +++ b/htdocs/core/modules/barcode/modules_barcode.class.php @@ -29,21 +29,21 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php'; */ abstract class ModeleBarCode { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - /** - * Return if a model can be used or not - * - * @return boolean true if model can be used - */ - function isEnabled() - { - return true; - } + /** + * Return if a model can be used or not + * + * @return boolean true if model can be used + */ + public function isEnabled() + { + return true; + } } @@ -52,17 +52,17 @@ abstract class ModeleBarCode */ abstract class ModeleNumRefBarCode { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; /** Return default description of numbering model * * @param Translate $langs Object langs * @return string Descriptive text */ - function info($langs) + public function info($langs) { $langs->load("bills"); return $langs->trans("NoDescription"); @@ -73,7 +73,7 @@ abstract class ModeleNumRefBarCode * @param Translate $langs Object langs * @return string Model name */ - function getNom($langs) + public function getNom($langs) { return empty($this->name)?$this->nom:$this->name; } @@ -83,7 +83,7 @@ abstract class ModeleNumRefBarCode * @param Translate $langs Object langs * @return string Example */ - function getExample($langs) + public function getExample($langs) { $langs->load("bills"); return $langs->trans("NoExample"); @@ -96,17 +96,17 @@ abstract class ModeleNumRefBarCode * @param string $type Type of barcode (EAN, ISBN, ...) * @return string Value */ - function getNextValue($objproduct, $type = '') + public function getNextValue($objproduct, $type = '') { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); } - /** Return version of module + /** Return version of module * * @return string Version */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -126,7 +126,7 @@ abstract class ModeleNumRefBarCode * @param int $type -1=Nothing, 0=Product, 1=Service * @return string HTML translated description */ - function getToolTip($langs, $soc, $type) + public function getToolTip($langs, $soc, $type) { global $conf; diff --git a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php index 999494ea6c3..80876747d59 100644 --- a/htdocs/core/modules/cheque/doc/pdf_blochet.class.php +++ b/htdocs/core/modules/cheque/doc/pdf_blochet.class.php @@ -45,7 +45,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -78,7 +78,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts $this->tab_height = 200; //$this->line_height * $this->line_per_page; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction to generate document on disk * @@ -88,7 +88,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts * @param Translate $outputlangs Lang output object * @return int 1=ok, 0=ko */ - function write_file($object, $_dir, $number, $outputlangs) + public function write_file($object, $_dir, $number, $outputlangs) { // phpcs:enable global $user,$conf,$langs,$hookmanager; @@ -209,7 +209,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Generate Header * @@ -219,7 +219,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts * @param Translate $outputlangs Object language for output * @return void */ - function Header(&$pdf, $page, $pages, $outputlangs) + public function Header(&$pdf, $page, $pages, $outputlangs) { // phpcs:enable global $langs; @@ -317,7 +317,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output array * @@ -327,7 +327,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts * @param Translate $outputlangs Object lang * @return void */ - function Body(&$pdf, $pagenb, $pages, $outputlangs) + public function Body(&$pdf, $pagenb, $pages, $outputlangs) { // phpcs:enable // x=10 - Num @@ -378,15 +378,15 @@ class BordereauChequeBlochet extends ModeleChequeReceipts /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return void + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return void */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php index 0bdf6f0fc91..0183300c4ad 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_mint.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_mint.php @@ -25,7 +25,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/cheque/modules_chequereceipts.php'; /** - * Class to manage cheque receipts numbering rules Mint + * Class to manage cheque receipts numbering rules Mint */ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts { @@ -50,7 +50,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -62,7 +62,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -74,7 +74,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -109,7 +109,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -145,7 +145,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -153,7 +153,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts * @param string $objforref Object for number to search * @return string Next free value */ - function chequereceipt_get_num($objsoc, $objforref) + public function chequereceipt_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php index c978dbaa0f3..da1ec40620c 100644 --- a/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php +++ b/htdocs/core/modules/cheque/mod_chequereceipt_thyme.php @@ -49,7 +49,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -89,7 +89,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -112,7 +112,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -133,7 +133,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -141,7 +141,7 @@ class mod_chequereceipt_thyme extends ModeleNumRefChequeReceipts * @param string $objforref Object for number to search * @return string Next free value */ - function chequereceipt_get_num($objsoc, $objforref) + public function chequereceipt_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/cheque/modules_chequereceipts.php b/htdocs/core/modules/cheque/modules_chequereceipts.php index d13384805d5..29fd071200a 100644 --- a/htdocs/core/modules/cheque/modules_chequereceipts.php +++ b/htdocs/core/modules/cheque/modules_chequereceipts.php @@ -46,7 +46,7 @@ abstract class ModeleNumRefChequeReceipts * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -56,7 +56,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -68,7 +68,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -80,7 +80,7 @@ abstract class ModeleNumRefChequeReceipts * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -92,7 +92,7 @@ abstract class ModeleNumRefChequeReceipts * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -103,7 +103,7 @@ abstract class ModeleNumRefChequeReceipts * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -127,7 +127,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -135,7 +135,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -154,7 +154,7 @@ abstract class ModeleChequeReceipts extends CommonDocGenerator /** - * Cree un bordereau remise de cheque + * Cree un bordereau remise de cheque * * @param DoliDB $db Database handler * @param int $id Object invoice (or id of invoice) 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 14f3c1fc862..d2f2ba9af07 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 @@ -63,7 +63,7 @@ class doc_generic_order_odt extends ModelePDFCommandes * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -108,7 +108,7 @@ class doc_generic_order_odt extends ModelePDFCommandes * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -191,9 +191,9 @@ class doc_generic_order_odt extends ModelePDFCommandes return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build a document on disk using the generic odt module. + * Function to build a document on disk using the generic odt module. * * @param Commande $object Object source to build document * @param Translate $outputlangs Lang output object @@ -203,7 +203,7 @@ class doc_generic_order_odt extends ModelePDFCommandes * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -338,7 +338,7 @@ class doc_generic_order_odt extends ModelePDFCommandes // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->commande->dir_temp, diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index 5354e6bc2c7..ec8aa3978d9 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -68,7 +68,7 @@ class pdf_einstein extends ModelePDFCommandes public $type; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -203,7 +203,7 @@ class pdf_einstein extends ModelePDFCommandes $this->atleastonediscount=0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -215,7 +215,7 @@ class pdf_einstein extends ModelePDFCommandes * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes; @@ -652,7 +652,7 @@ class pdf_einstein extends ModelePDFCommandes } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * @@ -662,13 +662,13 @@ class pdf_einstein extends ModelePDFCommandes * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -678,7 +678,7 @@ class pdf_einstein extends ModelePDFCommandes * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -855,18 +855,18 @@ class pdf_einstein extends ModelePDFCommandes } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * - * @param TCPDF $pdf Object PDF + * @param TCPDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Montant deja regle * @param int $posy Position depart * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -1129,7 +1129,7 @@ class pdf_einstein extends ModelePDFCommandes * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1239,7 +1239,7 @@ class pdf_einstein extends ModelePDFCommandes * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle") + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "PdfOrderTitle") { global $conf,$langs,$hookmanager; @@ -1450,7 +1450,7 @@ class pdf_einstein extends ModelePDFCommandes * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php index 75db1887e4d..f7ce304b380 100644 --- a/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_eratosthene.modules.php @@ -643,7 +643,7 @@ class pdf_eratosthene extends ModelePDFCommandes if ($pagenb == $pageposafter) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); - } + } else { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); @@ -816,7 +816,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->MultiCell(80, 4, $dlp, 0, 'L'); $posy=$pdf->GetY()+1; - } + } elseif ($object->availability_code || $object->availability) // Show availability conditions { $pdf->SetFont('', 'B', $default_font_size - 2); @@ -831,7 +831,7 @@ class pdf_eratosthene extends ModelePDFCommandes $pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); $posy=$pdf->GetY()+1; - } + } // Show payment mode if ($object->mode_reglement_code @@ -889,8 +889,8 @@ class pdf_eratosthene extends ModelePDFCommandes $posy=$pdf->GetY()+2; } } - } - } + } + } // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') @@ -1672,5 +1672,5 @@ class pdf_eratosthene extends ModelePDFCommandes { $this->cols = $hookmanager->resArray; } - } + } } diff --git a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php index 66a5307cbfa..f10f858544f 100644 --- a/htdocs/core/modules/commande/doc/pdf_proforma.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_proforma.modules.php @@ -46,7 +46,7 @@ class pdf_proforma extends pdf_einstein * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -67,7 +67,7 @@ class pdf_proforma extends pdf_einstein * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "InvoiceProForma") + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "InvoiceProForma") { global $conf,$langs,$hookmanager; diff --git a/htdocs/core/modules/commande/mod_commande_marbre.php b/htdocs/core/modules/commande/mod_commande_marbre.php index e888905b3be..b0b462e96dc 100644 --- a/htdocs/core/modules/commande/mod_commande_marbre.php +++ b/htdocs/core/modules/commande/mod_commande_marbre.php @@ -60,7 +60,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,7 +72,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -155,7 +155,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -163,7 +163,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index bfe853996ce..373f1e01200 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -62,7 +62,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -102,7 +102,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -128,7 +128,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -151,7 +151,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -159,7 +159,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/commande/modules_commande.php b/htdocs/core/modules/commande/modules_commande.php index 6090ad35028..e0a0e454861 100644 --- a/htdocs/core/modules/commande/modules_commande.php +++ b/htdocs/core/modules/commande/modules_commande.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'; abstract class ModelePDFCommandes extends CommonDocGenerator { - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -48,7 +48,7 @@ abstract class ModelePDFCommandes extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -82,7 +82,7 @@ abstract class ModeleNumRefCommandes * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -92,7 +92,7 @@ abstract class ModeleNumRefCommandes * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("orders"); @@ -104,7 +104,7 @@ abstract class ModeleNumRefCommandes * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("orders"); @@ -116,7 +116,7 @@ abstract class ModeleNumRefCommandes * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ abstract class ModeleNumRefCommandes * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ abstract class ModeleNumRefCommandes * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); 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 1f77537ceb5..8319bff919b 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 @@ -58,11 +58,11 @@ class doc_generic_contract_odt extends ModelePDFContract /** - * Constructor + * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -107,7 +107,7 @@ class doc_generic_contract_odt extends ModelePDFContract * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -181,19 +181,19 @@ class doc_generic_contract_odt extends ModelePDFContract return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build a document on disk using the generic odt module. + * Function to build a document on disk using the generic odt module. * - * @param Contract $object Object source to build document - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param Contract $object Object source to build document + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref - * @return int 1 if OK, <=0 if KO + * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -291,10 +291,9 @@ class doc_generic_contract_odt extends ModelePDFContract // Recipient name $contactobject=null; - if (! empty($usecontact)) - { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + if (! empty($usecontact)) { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 84f363af74c..fd0f5cd38a0 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -61,7 +61,7 @@ class pdf_strato extends ModelePDFContract public $type; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -124,7 +124,7 @@ class pdf_strato extends ModelePDFContract * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -160,7 +160,7 @@ class pdf_strato extends ModelePDFContract $this->posxdesc=$this->marge_gauche+1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -171,9 +171,9 @@ class pdf_strato extends ModelePDFContract * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref * @return int 1=OK, 0=KO - */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + */ + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$hookmanager,$mysoc; @@ -513,7 +513,7 @@ class pdf_strato extends ModelePDFContract * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf; @@ -522,7 +522,7 @@ class pdf_strato extends ModelePDFContract if ($hidetop) $hidetop=-1; $default_font_size = pdf_getPDFFontSize($outputlangs); -/* + /* $pdf->SetXY($this->marge_gauche, $tab_top); $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8); @@ -546,7 +546,7 @@ class pdf_strato extends ModelePDFContract $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY); $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also. -*/ + */ // Output Rect $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+3); // Rect prend une longueur en 3eme param et 4eme param @@ -560,7 +560,7 @@ class pdf_strato extends ModelePDFContract * @param Translate $outputlangs Object language for output * @return void */ - private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs) + private function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs) { $pdf->SetDrawColor(128, 128, 128); $posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite)/2); @@ -577,19 +577,19 @@ class pdf_strato extends ModelePDFContract $pdf->SetXY($posmiddle + 5, $posy + 5); $pdf->MultiCell($this->page_largeur-$this->marge_droite - $posmiddle - 5, 20, '', 1); - } + } - /** - * Show top header of page. - * - * @param PDF $pdf Object PDF - * @param CommonObject $object Object to show - * @param int $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output - * @return void - */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) - { + /** + * Show top header of page. + * + * @param PDF $pdf Object PDF + * @param CommonObject $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return void + */ + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + { global $conf,$langs; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -767,7 +767,7 @@ class pdf_strato extends ModelePDFContract * @param int $hidefreetext 1=Hide free text * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index db7689d7855..3dfa0533cbe 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -59,7 +59,7 @@ class mod_contract_magre extends ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $conf,$langs; @@ -95,7 +95,7 @@ class mod_contract_magre extends ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -118,7 +118,7 @@ class mod_contract_magre extends ModelNumRefContracts * @param Object $contract contract object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $db,$conf; @@ -137,15 +137,15 @@ class mod_contract_magre extends ModelNumRefContracts return $numFinal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next value * - * @param Societe $objsoc third party object - * @param Object $objforref contract object - * @return string Value if OK, 0 if KO - */ - function contract_get_num($objsoc, $objforref) + * @param Societe $objsoc third party object + * @param Object $objforref contract object + * @return string Value if OK, 0 if KO + */ + public function contract_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/contract/mod_contract_olive.php b/htdocs/core/modules/contract/mod_contract_olive.php index 799bd297633..c1a395c4439 100644 --- a/htdocs/core/modules/contract/mod_contract_olive.php +++ b/htdocs/core/modules/contract/mod_contract_olive.php @@ -66,7 +66,7 @@ class mod_contract_olive extends ModelNumRefContracts * * @return string Description of module */ - function info() + public function info() { global $langs; @@ -81,7 +81,7 @@ class mod_contract_olive extends ModelNumRefContracts * @param Contrat $contract Object contract * @return string Return next value */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $langs; return ''; @@ -101,7 +101,7 @@ class mod_contract_olive extends ModelNumRefContracts * -3 ErrorProductCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $product, $type) + public function verif($db, &$code, $product, $type) { global $conf; diff --git a/htdocs/core/modules/contract/mod_contract_serpis.php b/htdocs/core/modules/contract/mod_contract_serpis.php index 2106463107e..2f644f2762f 100644 --- a/htdocs/core/modules/contract/mod_contract_serpis.php +++ b/htdocs/core/modules/contract/mod_contract_serpis.php @@ -61,7 +61,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -73,7 +73,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_contract_serpis extends ModelNumRefContracts * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_contract_serpis extends ModelNumRefContracts * @param Object $contract contract object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $db,$conf; @@ -153,7 +153,7 @@ class mod_contract_serpis extends ModelNumRefContracts } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next value * @@ -161,7 +161,7 @@ class mod_contract_serpis extends ModelNumRefContracts * @param Object $objforref contract object * @return string Value if OK, 0 if KO */ - function contract_get_num($objsoc, $objforref) + public function contract_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/contract/modules_contract.php b/htdocs/core/modules/contract/modules_contract.php index 0c126459436..9cbc2092979 100644 --- a/htdocs/core/modules/contract/modules_contract.php +++ b/htdocs/core/modules/contract/modules_contract.php @@ -43,7 +43,7 @@ abstract class ModelePDFContract extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -51,7 +51,7 @@ abstract class ModelePDFContract extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -82,7 +82,7 @@ class ModelNumRefContracts * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -92,7 +92,7 @@ class ModelNumRefContracts * * @return string text description */ - function info() + public function info() { global $langs; $langs->load("contracts"); @@ -104,7 +104,7 @@ class ModelNumRefContracts * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("contracts"); @@ -116,7 +116,7 @@ class ModelNumRefContracts * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ class ModelNumRefContracts * @param Object $contract contract object * @return string Value */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ class ModelNumRefContracts * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index cbb6f3807cc..6ef76d21b78 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -40,7 +40,7 @@ class html_cerfafr extends ModeleDon * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs; @@ -58,13 +58,13 @@ class html_cerfafr extends ModeleDon * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write the object to document file to disk * @@ -73,7 +73,7 @@ class html_cerfafr extends ModeleDon * @param string $currency Currency code * @return int >0 if OK, <0 if KO */ - function write_file($don, $outputlangs, $currency = '') + public function write_file($don, $outputlangs, $currency = '') { // phpcs:enable global $user,$conf,$langs,$mysoc; @@ -306,22 +306,22 @@ class html_cerfafr extends ModeleDon $dix[3]=intval($valeur_entiere%100000000/10000000); $cent[3]=intval($valeur_entiere%1000000000/100000000); $chif=array('', 'un', 'deux', 'trois', 'quatre', 'cinq', 'six', 'sept', 'huit', 'neuf', 'dix', 'onze', 'douze', 'treize', 'quatorze', 'quinze', 'seize', 'dix sept', 'dix huit', 'dix neuf'); - $secon_c=''; - $trio_c=''; - for($i=1; $i<=3; $i++){ + $secon_c=''; + $trio_c=''; + for($i=1; $i<=3; $i++) { $prim[$i]=''; $secon[$i]=''; $trio[$i]=''; - if($dix[$i]==0){ + if ($dix[$i]==0) { $secon[$i]=''; $prim[$i]=$chif[$unite[$i]]; } - elseif($dix[$i]==1){ + elseif ($dix[$i]==1) { $secon[$i]=''; $prim[$i]=$chif[($unite[$i]+10)]; } - elseif($dix[$i]==2){ - if($unite[$i]==1){ + elseif ($dix[$i]==2) { + if ($unite[$i]==1) { $secon[$i]='vingt et'; $prim[$i]=$chif[$unite[$i]]; } @@ -330,8 +330,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==3){ - if($unite[$i]==1){ + elseif ($dix[$i]==3) { + if ($unite[$i]==1) { $secon[$i]='trente et'; $prim[$i]=$chif[$unite[$i]]; } @@ -340,8 +340,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==4){ - if($unite[$i]==1){ + elseif ($dix[$i]==4) { + if ($unite[$i]==1) { $secon[$i]='quarante et'; $prim[$i]=$chif[$unite[$i]]; } @@ -350,8 +350,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==5){ - if($unite[$i]==1){ + elseif ($dix[$i]==5) { + if ($unite[$i]==1) { $secon[$i]='cinquante et'; $prim[$i]=$chif[$unite[$i]]; } @@ -360,8 +360,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==6){ - if($unite[$i]==1){ + elseif ($dix[$i]==6) { + if ($unite[$i]==1) { $secon[$i]='soixante et'; $prim[$i]=$chif[$unite[$i]]; } @@ -370,8 +370,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==7){ - if($unite[$i]==1){ + elseif ($dix[$i]==7) { + if ($unite[$i]==1) { $secon[$i]='soixante et'; $prim[$i]=$chif[$unite[$i]+10]; } @@ -380,8 +380,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]+10]; } } - elseif($dix[$i]==8){ - if($unite[$i]==1){ + elseif ($dix[$i]==8) { + if ($unite[$i]==1) { $secon[$i]='quatre-vingts et'; $prim[$i]=$chif[$unite[$i]]; } @@ -390,8 +390,8 @@ class html_cerfafr extends ModeleDon $prim[$i]=$chif[$unite[$i]]; } } - elseif($dix[$i]==9){ - if($unite[$i]==1){ + elseif ($dix[$i]==9) { + if ($unite[$i]==1) { $secon[$i]='quatre-vingts et'; $prim[$i]=$chif[$unite[$i]+10]; } @@ -407,19 +407,19 @@ class html_cerfafr extends ModeleDon $chif2=array('', 'dix', 'vingt', 'trente', 'quarante', 'cinquante', 'soixante', 'soixante-dix', 'quatre-vingts', 'quatre-vingts dix'); $secon_c=$chif2[$dix_c]; - if($cent_c==1) $trio_c='cent'; - elseif($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents'; + if ($cent_c==1) $trio_c='cent'; + elseif ($cent_c!=0 || $cent_c!='') $trio_c=$chif[$cent_c] .' cents'; - if(($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) + if (($cent[3]==0 || $cent[3]=='') && ($dix[3]==0 || $dix[3]=='') && ($unite[3]==1)) $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' million '; - elseif(($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) + elseif (($cent[3]!=0 && $cent[3]!='') || ($dix[3]!=0 && $dix[3]!='') || ($unite[3]!=0 && $unite[3]!='')) $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]. ' millions '; else $somme = $trio[3]. ' ' .$secon[3]. ' ' . $prim[3]; - if(($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) + if (($cent[2]==0 || $cent[2]=='') && ($dix[2]==0 || $dix[2]=='') && ($unite[2]==1)) $somme = $somme.' mille '; - elseif(($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) + elseif (($cent[2]!=0 && $cent[2]!='') || ($dix[2]!=0 && $dix[2]!='') || ($unite[2]!=0 && $unite[2]!='')) $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]. ' milles '; else $somme = $somme. $trio[2]. ' ' .$secon[2]. ' ' . $prim[2]; @@ -428,7 +428,7 @@ class html_cerfafr extends ModeleDon $somme = $somme. ' '. $dev1 .' ' ; - if(($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) + if (($cent_c=='0' || $cent_c=='') && ($dix_c=='0' || $dix_c=='')) return $somme. ' et zéro '. $dev2; else return $somme. $trio_c. ' ' .$secon_c. ' ' . $dev2; diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index adda4dce750..9957bf4f326 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -39,7 +39,7 @@ abstract class ModeleDon extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -47,7 +47,7 @@ abstract class ModeleDon extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -78,7 +78,7 @@ abstract class ModeleNumRefDons * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -88,7 +88,7 @@ abstract class ModeleNumRefDons * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -100,7 +100,7 @@ abstract class ModeleNumRefDons * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -113,7 +113,7 @@ abstract class ModeleNumRefDons * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -123,7 +123,7 @@ abstract class ModeleNumRefDons * * @return string Valeur */ - function getNextValue() + public function getNextValue() { global $langs; return $langs->trans("NotAvailable"); @@ -134,7 +134,7 @@ abstract class ModeleNumRefDons * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); 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 558ffe44e0a..53891a1c340 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 @@ -64,7 +64,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -109,7 +109,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -191,7 +191,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -203,7 +203,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -337,7 +337,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->expedition->dir_temp, diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php index 628d9102e96..649d20154e4 100644 --- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php @@ -58,7 +58,7 @@ class pdf_merou extends ModelePdfExpedition public $type; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -116,7 +116,7 @@ class pdf_merou extends ModelePdfExpedition * * @param DoliDB $db Database handler */ - function __construct($db = 0) + public function __construct($db = 0) { global $conf,$langs,$mysoc; @@ -142,7 +142,7 @@ class pdf_merou extends ModelePdfExpedition } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -154,7 +154,7 @@ class pdf_merou extends ModelePdfExpedition * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$conf,$langs,$mysoc,$hookmanager; @@ -460,7 +460,7 @@ class pdf_merou extends ModelePdfExpedition * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $langs; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -498,7 +498,7 @@ class pdf_merou extends ModelePdfExpedition * @param int $hidefreetext 1=Hide free text * @return void */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { $default_font_size = pdf_getPDFFontSize($outputlangs); $pdf->SetFont('', '', $default_font_size - 2); @@ -527,7 +527,7 @@ class pdf_merou extends ModelePdfExpedition * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs,$hookmanager; diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 116fae7c354..e0de76bb7b7 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -57,7 +57,7 @@ class pdf_rouget extends ModelePdfExpedition public $type; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -115,7 +115,7 @@ class pdf_rouget extends ModelePdfExpedition * * @param DoliDB $db Database handler */ - function __construct($db = 0) + public function __construct($db = 0) { global $conf,$langs,$mysoc; @@ -156,23 +156,22 @@ class pdf_rouget extends ModelePdfExpedition $this->posxpicture=$this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images - if ($this->page_largeur < 210) // To work with US executive format - { - $this->posxweightvol-=20; - $this->posxpicture-=20; - $this->posxqtyordered-=20; - $this->posxqtytoship-=20; - } + // To work with US executive format + if ($this->page_largeur < 210) { + $this->posxweightvol-=20; + $this->posxpicture-=20; + $this->posxqtyordered-=20; + $this->posxqtytoship-=20; + } - if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) - { + if (! empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) { $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered); $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered); $this->posxqtyordered = $this->posxqtytoship; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -184,7 +183,7 @@ class pdf_rouget extends ModelePdfExpedition * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$conf,$langs,$hookmanager; @@ -664,7 +663,7 @@ class pdf_rouget extends ModelePdfExpedition } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -675,7 +674,7 @@ class pdf_rouget extends ModelePdfExpedition * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -783,7 +782,7 @@ class pdf_rouget extends ModelePdfExpedition * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf; @@ -868,7 +867,7 @@ class pdf_rouget extends ModelePdfExpedition * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs,$mysoc; @@ -1108,15 +1107,15 @@ class pdf_rouget extends ModelePdfExpedition } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/expedition/mod_expedition_ribera.php b/htdocs/core/modules/expedition/mod_expedition_ribera.php index ac0c286d389..7b20d1df4d8 100644 --- a/htdocs/core/modules/expedition/mod_expedition_ribera.php +++ b/htdocs/core/modules/expedition/mod_expedition_ribera.php @@ -57,7 +57,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * * @return string text description */ - function info() + public function info() { global $conf, $langs; @@ -93,7 +93,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -119,7 +119,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * @param Object $shipment Shipment object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $shipment) { global $db,$conf; @@ -140,7 +140,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition return $numFinal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -148,7 +148,7 @@ class mod_expedition_ribera extends ModelNumRefExpedition * @param Object $objforref Shipment object * @return string Next free value */ - function expedition_get_num($objsoc, $objforref) + public function expedition_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/expedition/mod_expedition_safor.php b/htdocs/core/modules/expedition/mod_expedition_safor.php index 3bf655c6f23..40033df65f7 100644 --- a/htdocs/core/modules/expedition/mod_expedition_safor.php +++ b/htdocs/core/modules/expedition/mod_expedition_safor.php @@ -59,7 +59,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * * @return string text description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -71,7 +71,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -82,7 +82,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -117,7 +117,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * @param Object $shipment Shipment object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $shipment) { global $db,$conf; @@ -150,7 +150,7 @@ class mod_expedition_safor extends ModelNumRefExpedition return $this->prefix.$yymm."-".$num; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -158,7 +158,7 @@ class mod_expedition_safor extends ModelNumRefExpedition * @param Object $objforref Shipment object * @return string Next free value */ - function expedition_get_num($objsoc, $objforref) + public function expedition_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/expedition/modules_expedition.php b/htdocs/core/modules/expedition/modules_expedition.php index 7b88a83392e..3a2d7774e33 100644 --- a/htdocs/core/modules/expedition/modules_expedition.php +++ b/htdocs/core/modules/expedition/modules_expedition.php @@ -42,7 +42,7 @@ abstract class ModelePdfExpedition extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models * @@ -50,7 +50,7 @@ abstract class ModelePdfExpedition extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -80,7 +80,7 @@ abstract class ModelNumRefExpedition * * @return boolean true if model can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -90,7 +90,7 @@ abstract class ModelNumRefExpedition * * @return string text description */ - function info() + public function info() { global $langs; $langs->load("sendings"); @@ -102,7 +102,7 @@ abstract class ModelNumRefExpedition * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("sendings"); @@ -114,7 +114,7 @@ abstract class ModelNumRefExpedition * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -126,7 +126,7 @@ abstract class ModelNumRefExpedition * @param Object $shipment Shipment object * @return string Value */ - function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $shipment) { global $langs; return $langs->trans("NotAvailable"); @@ -137,7 +137,7 @@ abstract class ModelNumRefExpedition * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php index 03ebe71e88d..2563028ee93 100644 --- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php @@ -114,13 +114,13 @@ class pdf_standard extends ModeleExpenseReport public $emetteur; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { global $conf, $langs, $mysoc; // Translations @@ -192,7 +192,7 @@ class pdf_standard extends ModeleExpenseReport } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -204,7 +204,7 @@ class pdf_standard extends ModeleExpenseReport * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $db, $hookmanager; @@ -450,8 +450,7 @@ class pdf_standard extends ModeleExpenseReport } // Show square - if ($pagenb == 1) - { + if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } @@ -625,7 +624,7 @@ class pdf_standard extends ModeleExpenseReport * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs, $hookmanager; @@ -770,8 +769,7 @@ class pdf_standard extends ModeleExpenseReport $pdf->MultiCell(96, 4, $outputlangs->transnoentities("DateCreation")." : ".dol_print_date($object->date_create, "day", false, $outputlangs), 0, 'L'); } - if ($object->fk_statut==99) - { + if ($object->fk_statut==99) { if ($object->fk_user_refuse > 0) { $userfee=new User($this->db); $userfee->fetch($object->fk_user_refuse); $posy+=6; @@ -840,7 +838,7 @@ class pdf_standard extends ModeleExpenseReport * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1054,15 +1052,15 @@ class pdf_standard extends ModeleExpenseReport } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/expensereport/mod_expensereport_jade.php b/htdocs/core/modules/expensereport/mod_expensereport_jade.php index b4d1b7b2b6e..a878fb1325c 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_jade.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_jade.php @@ -59,10 +59,10 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * * @return string Text with description */ - function info() + public function info() { - global $langs; - return $langs->trans("SimpleNumRefModelDesc", $this->prefix); + global $langs; + return $langs->trans("SimpleNumRefModelDesc", $this->prefix); } @@ -71,7 +71,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -83,7 +83,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -117,7 +117,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($object) + public function getNextValue($object) { global $db,$conf; diff --git a/htdocs/core/modules/expensereport/mod_expensereport_sand.php b/htdocs/core/modules/expensereport/mod_expensereport_sand.php index e9c5eb06dd5..2311de4841a 100644 --- a/htdocs/core/modules/expensereport/mod_expensereport_sand.php +++ b/htdocs/core/modules/expensereport/mod_expensereport_sand.php @@ -59,7 +59,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport * * @return string Texte descripif */ - function info() + public function info() { global $db, $conf, $langs; @@ -99,7 +99,7 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport * * @return string Example */ - function getExample() + public function getExample() { global $db, $conf,$langs,$user; @@ -116,15 +116,15 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport return $numExample; } - /** - * Return next free value - * - * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO - */ - function getNextValue($object) + /** + * Return next free value + * + * @param Object $object Object we need next value for + * @return string Value if KO, <0 if KO + */ + public function getNextValue($object) { - global $db,$conf; + global $db,$conf; require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; @@ -154,5 +154,5 @@ class mod_expensereport_sand extends ModeleNumRefExpenseReport $numFinal=get_next_value($db, $mask, 'expensereport', 'ref', '', null, $date, 'next', true, $fuser); return $numFinal; - } + } } diff --git a/htdocs/core/modules/expensereport/modules_expensereport.php b/htdocs/core/modules/expensereport/modules_expensereport.php index a31a61f67e1..fde96e56af5 100644 --- a/htdocs/core/modules/expensereport/modules_expensereport.php +++ b/htdocs/core/modules/expensereport/modules_expensereport.php @@ -29,7 +29,7 @@ abstract class ModeleExpenseReport extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active models generation * @@ -37,7 +37,7 @@ abstract class ModeleExpenseReport extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -52,7 +52,6 @@ abstract class ModeleExpenseReport extends CommonDocGenerator } } -// phpcs:ignore PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * expensereport_pdf_create * @@ -68,8 +67,7 @@ abstract class ModeleExpenseReport extends CommonDocGenerator */ function expensereport_pdf_create(DoliDB $db, ExpenseReport $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - // phpcs:enable - return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } /** @@ -89,7 +87,7 @@ abstract class ModeleNumRefExpenseReport * * @return boolean true if model can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -99,7 +97,7 @@ abstract class ModeleNumRefExpenseReport * * @return string Descriptive text */ - function info() + public function info() { global $langs; $langs->load("orders"); @@ -111,7 +109,7 @@ abstract class ModeleNumRefExpenseReport * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("trips"); @@ -123,7 +121,7 @@ abstract class ModeleNumRefExpenseReport * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -134,26 +132,26 @@ abstract class ModeleNumRefExpenseReport * @param Object $object Object we need next value for * @return string Value */ - function getNextValue($object) + public function getNextValue($object) { global $langs; return $langs->trans("NotAvailable"); } - /** - * Returns the version of the numbering module - * - * @return string Value - */ - function getVersion() - { - global $langs; - $langs->load("admin"); + /** + * Returns the version of the numbering module + * + * @return string Value + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); - } + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); + } } diff --git a/htdocs/core/modules/export/export_csv.modules.php b/htdocs/core/modules/export/export_csv.modules.php index a90e550c3da..249d1563988 100644 --- a/htdocs/core/modules/export/export_csv.modules.php +++ b/htdocs/core/modules/export/export_csv.modules.php @@ -62,7 +62,7 @@ class ExportCsv extends ModeleExports * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $this->db = $db; @@ -89,7 +89,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverId() + public function getDriverId() { return $this->id; } @@ -99,7 +99,7 @@ class ExportCsv extends ModeleExports * * @return string Return driver label */ - function getDriverLabel() + public function getDriverLabel() { return $this->label; } @@ -109,7 +109,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverDesc() + public function getDriverDesc() { return $this->desc; } @@ -119,7 +119,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverExtension() + public function getDriverExtension() { return $this->extension; } @@ -129,7 +129,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getDriverVersion() + public function getDriverVersion() { return $this->version; } @@ -139,7 +139,7 @@ class ExportCsv extends ModeleExports * * @return string */ - function getLibLabel() + public function getLibLabel() { return $this->label_lib; } @@ -149,13 +149,13 @@ class ExportCsv extends ModeleExports * * @return string */ - function getLibVersion() + public function getLibVersion() { return $this->version_lib; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Open output file * @@ -163,7 +163,7 @@ class ExportCsv extends ModeleExports * @param Translate $outputlangs Output language object * @return int <0 if KO, >=0 if OK */ - function open_file($file, $outputlangs) + public function open_file($file, $outputlangs) { // phpcs:enable global $langs; @@ -184,21 +184,21 @@ class ExportCsv extends ModeleExports return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output header into file * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_header($outputlangs) + public function write_header($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line into file * @@ -208,7 +208,7 @@ class ExportCsv extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -234,7 +234,7 @@ class ExportCsv extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record line into file * @@ -244,7 +244,7 @@ class ExportCsv extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -288,26 +288,26 @@ class ExportCsv extends ModeleExports return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output footer into file * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_footer($outputlangs) + public function write_footer($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close file handle * * @return int <0 if KO, >0 if OK */ - function close_file() + public function close_file() { // phpcs:enable fclose($this->handle); diff --git a/htdocs/core/modules/export/export_excel.modules.php b/htdocs/core/modules/export/export_excel.modules.php index 7b12651cfa0..28357c0a09a 100644 --- a/htdocs/core/modules/export/export_excel.modules.php +++ b/htdocs/core/modules/export/export_excel.modules.php @@ -70,17 +70,17 @@ class ExportExcel extends ModeleExports * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $this->db = $db; $this->id='excel'; // Same value then xxx in file name export_xxx.modules.php - $this->label='Excel 95'; // Label of driver + $this->label='Excel 95'; // Label of driver $this->desc = $langs->trans('Excel95FormatDesc'); $this->extension='xls'; // Extension for generated file by this driver - $this->picto='mime/xls'; // Picto - $this->version='1.30'; // Driver version + $this->picto='mime/xls'; // Picto + $this->version='1.30'; // Driver version $this->disabled = (in_array(constant('PHPEXCEL_PATH'), array('disabled','disabled/'))?1:0); // A condition to disable module (used for native debian packages) @@ -112,7 +112,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverId() + public function getDriverId() { return $this->id; } @@ -122,7 +122,7 @@ class ExportExcel extends ModeleExports * * @return string Return driver label */ - function getDriverLabel() + public function getDriverLabel() { return $this->label; } @@ -132,7 +132,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverDesc() + public function getDriverDesc() { return $this->desc; } @@ -142,7 +142,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverExtension() + public function getDriverExtension() { return $this->extension; } @@ -152,7 +152,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getDriverVersion() + public function getDriverVersion() { return $this->version; } @@ -162,7 +162,7 @@ class ExportExcel extends ModeleExports * * @return string */ - function getLibLabel() + public function getLibLabel() { return $this->label_lib; } @@ -172,13 +172,13 @@ class ExportExcel extends ModeleExports * * @return string */ - function getLibVersion() + public function getLibVersion() { return $this->version_lib; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Open output file * @@ -186,7 +186,7 @@ class ExportExcel extends ModeleExports * @param Translate $outputlangs Output language object * @return int <0 if KO, >=0 if OK */ - function open_file($file, $outputlangs) + public function open_file($file, $outputlangs) { // phpcs:enable global $user,$conf,$langs; @@ -202,8 +202,7 @@ class ExportExcel extends ModeleExports $ret=1; $outputlangs->load("exports"); - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { + if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) { require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_workbookbig.inc.php'; require_once PHP_WRITEEXCEL_PATH.'class.writeexcel_worksheet.inc.php'; require_once PHP_WRITEEXCEL_PATH.'functions.writeexcel_utility.inc.php'; @@ -249,14 +248,14 @@ class ExportExcel extends ModeleExports return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write header * * @param Translate $outputlangs Object lang to translate values * @return int <0 if KO, >0 if OK */ - function write_header($outputlangs) + public function write_header($outputlangs) { // phpcs:enable //$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO @@ -265,7 +264,7 @@ class ExportExcel extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line into file * @@ -275,7 +274,7 @@ class ExportExcel extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -322,7 +321,7 @@ class ExportExcel extends ModeleExports return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record line into file * @@ -332,7 +331,7 @@ class ExportExcel extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -442,27 +441,27 @@ class ExportExcel extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write footer * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_footer($outputlangs) + public function write_footer($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close Excel file * * @return int <0 if KO, >0 if OK */ - function close_file() + public function close_file() { // phpcs:enable global $conf; @@ -483,42 +482,43 @@ class ExportExcel extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Clean a cell to respect rules of Excel file cells + * Clean a cell to respect rules of Excel file cells * - * @param string $newvalue String to clean - * @return string Value cleaned + * @param string $newvalue String to clean + * @return string Value cleaned */ - function excel_clean($newvalue) + public function excel_clean($newvalue) { // phpcs:enable - // Rule Dolibarr: No HTML - $newvalue=dol_string_nohtmltag($newvalue); + // Rule Dolibarr: No HTML + $newvalue=dol_string_nohtmltag($newvalue); - return $newvalue; + return $newvalue; } /** - * Convert a column to letter (1->A, 0->B, 27->AA, ...) + * Convert a column to letter (1->A, 0->B, 27->AA, ...) * - * @param int $c Column position - * @return string Letter + * @param int $c Column position + * @return string Letter */ - function column2Letter($c) + public function column2Letter($c) { - $c = intval($c); - if ($c <= 0) return ''; + $c = intval($c); + if ($c <= 0) { + return ''; + } - while ($c != 0) - { - $p = ($c - 1) % 26; - $c = intval(($c - $p) / 26); - $letter = chr(65 + $p) . $letter; - } + while ($c != 0) { + $p = ($c - 1) % 26; + $c = intval(($c - $p) / 26); + $letter = chr(65 + $p) . $letter; + } - return $letter; + return $letter; } } diff --git a/htdocs/core/modules/export/export_excel2007.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php index 28dae8ed6fd..1b6b973632a 100644 --- a/htdocs/core/modules/export/export_excel2007.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -70,7 +70,7 @@ class ExportExcel2007 extends ExportExcel * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $this->db = $db; @@ -108,29 +108,29 @@ class ExportExcel2007 extends ExportExcel } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close Excel file * * @return int <0 if KO, >0 if OK */ - function close_file() - { + public function close_file() + { // phpcs:enable - global $conf; + global $conf; - if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) - { - $this->workbook->close(); - } - else - { + if (! empty($conf->global->MAIN_USE_PHP_WRITEEXCEL)) + { + $this->workbook->close(); + } + else + { require_once PHPEXCEL_PATH.'PHPExcel/Writer/Excel5.php'; - $objWriter = new PHPExcel_Writer_Excel2007($this->workbook); + $objWriter = new PHPExcel_Writer_Excel2007($this->workbook); $objWriter->save($this->file); $this->workbook->disconnectWorksheets(); unset($this->workbook); - } - return 1; - } + } + return 1; + } } diff --git a/htdocs/core/modules/export/export_excel2007new.modules.php b/htdocs/core/modules/export/export_excel2007new.modules.php index b51aa7b00fc..10dbb2fa28c 100644 --- a/htdocs/core/modules/export/export_excel2007new.modules.php +++ b/htdocs/core/modules/export/export_excel2007new.modules.php @@ -72,7 +72,7 @@ class ExportExcel2007new extends ModeleExports * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $this->db = $db; @@ -105,7 +105,7 @@ class ExportExcel2007new extends ModeleExports * * @return string */ - function getDriverId() + public function getDriverId() { return $this->id; } @@ -115,7 +115,7 @@ class ExportExcel2007new extends ModeleExports * * @return string Return driver label */ - function getDriverLabel() + public function getDriverLabel() { return $this->label; } @@ -125,7 +125,7 @@ class ExportExcel2007new extends ModeleExports * * @return string */ - function getDriverDesc() + public function getDriverDesc() { return $this->desc; } @@ -135,7 +135,7 @@ class ExportExcel2007new extends ModeleExports * * @return string */ - function getDriverExtension() + public function getDriverExtension() { return $this->extension; } @@ -145,7 +145,7 @@ class ExportExcel2007new extends ModeleExports * * @return string */ - function getDriverVersion() + public function getDriverVersion() { return $this->version; } @@ -155,7 +155,7 @@ class ExportExcel2007new extends ModeleExports * * @return string */ - function getLibLabel() + public function getLibLabel() { return $this->label_lib; } @@ -165,13 +165,13 @@ class ExportExcel2007new extends ModeleExports * * @return string */ - function getLibVersion() + public function getLibVersion() { return $this->version_lib; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Open output file * @@ -179,7 +179,7 @@ class ExportExcel2007new extends ModeleExports * @param Translate $outputlangs Output language object * @return int <0 if KO, >=0 if OK */ - function open_file($file, $outputlangs) + public function open_file($file, $outputlangs) { // phpcs:enable global $user,$conf,$langs; @@ -227,14 +227,14 @@ class ExportExcel2007new extends ModeleExports return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write header * * @param Translate $outputlangs Object lang to translate values * @return int <0 if KO, >0 if OK */ - function write_header($outputlangs) + public function write_header($outputlangs) { // phpcs:enable //$outputlangs->charset_output='ISO-8859-1'; // Because Excel 5 format is ISO @@ -243,7 +243,7 @@ class ExportExcel2007new extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line into file * @@ -253,7 +253,7 @@ class ExportExcel2007new extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -286,7 +286,7 @@ class ExportExcel2007new extends ModeleExports return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record line into file * @@ -296,7 +296,7 @@ class ExportExcel2007new extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -333,32 +333,32 @@ class ExportExcel2007new extends ModeleExports if (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$/i', $newvalue)) { - $newvalue=dol_stringtotime($newvalue); - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue)); - $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); - $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd'); + $newvalue=dol_stringtotime($newvalue); + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue)); + $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); + $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd'); } elseif (preg_match('/^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]$/i', $newvalue)) { - $newvalue=dol_stringtotime($newvalue); - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue)); - $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); - $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss'); + $newvalue=dol_stringtotime($newvalue); + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel($newvalue)); + $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); + $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('yyyy-mm-dd h:mm:ss'); } else { - if ($typefield == 'Text' || $typefield == 'TextAuto') - { - //$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING); - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue); - $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); - $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@'); - $this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT); - } - else - { - $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue); - } + if ($typefield == 'Text' || $typefield == 'TextAuto') + { + //$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->setValueExplicit($newvalue, PHPExcel_Cell_DataType::TYPE_STRING); + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, (string) $newvalue); + $coord=$this->workbook->getActiveSheet()->getCellByColumnAndRow($this->col, $this->row+1)->getCoordinate(); + $this->workbook->getActiveSheet()->getStyle($coord)->getNumberFormat()->setFormatCode('@'); + $this->workbook->getActiveSheet()->getStyle($coord)->getAlignment()->setHorizontal(PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_LEFT); + } + else + { + $this->workbook->getActiveSheet()->SetCellValueByColumnAndRow($this->col, $this->row+1, $newvalue); + } } $this->col++; } @@ -367,48 +367,48 @@ class ExportExcel2007new extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Write footer * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_footer($outputlangs) + public function write_footer($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close Excel file * * @return int <0 if KO, >0 if OK */ - function close_file() + public function close_file() { // phpcs:enable - global $conf; + global $conf; - $objWriter = new Xlsx($this->workbook); - $objWriter->save($this->file); - $this->workbook->disconnectWorksheets(); - unset($this->workbook); + $objWriter = new Xlsx($this->workbook); + $objWriter->save($this->file); + $this->workbook->disconnectWorksheets(); + unset($this->workbook); return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Clean a cell to respect rules of Excel file cells * * @param string $newvalue String to clean * @return string Value cleaned */ - function excel_clean($newvalue) + public function excel_clean($newvalue) { // phpcs:enable // Rule Dolibarr: No HTML @@ -424,14 +424,13 @@ class ExportExcel2007new extends ModeleExports * @param int $c Column position * @return string Letter */ - function column2Letter($c) + public function column2Letter($c) { $c = intval($c); if ($c <= 0) return ''; - while ($c != 0) - { + while ($c != 0) { $p = ($c - 1) % 26; $c = intval(($c - $p) / 26); $letter = chr(65 + $p) . $letter; diff --git a/htdocs/core/modules/export/export_tsv.modules.php b/htdocs/core/modules/export/export_tsv.modules.php index e3855e5f17e..33d7d860368 100644 --- a/htdocs/core/modules/export/export_tsv.modules.php +++ b/htdocs/core/modules/export/export_tsv.modules.php @@ -59,11 +59,11 @@ class ExportTsv extends ModeleExports /** - * Constructor - * - * @param DoliDB $db Database handler + * Constructor + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $this->db = $db; @@ -85,7 +85,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverId() + public function getDriverId() { return $this->id; } @@ -95,7 +95,7 @@ class ExportTsv extends ModeleExports * * @return string Return driver label */ - function getDriverLabel() + public function getDriverLabel() { return $this->label; } @@ -105,7 +105,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverDesc() + public function getDriverDesc() { return $this->desc; } @@ -115,7 +115,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverExtension() + public function getDriverExtension() { return $this->extension; } @@ -125,7 +125,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getDriverVersion() + public function getDriverVersion() { return $this->version; } @@ -135,7 +135,7 @@ class ExportTsv extends ModeleExports * * @return string */ - function getLibLabel() + public function getLibLabel() { return $this->label_lib; } @@ -145,21 +145,21 @@ class ExportTsv extends ModeleExports * * @return string */ - function getLibVersion() + public function getLibVersion() { return $this->version_lib; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Open output file - * - * @param string $file Path of filename to generate - * @param Translate $outputlangs Output language object - * @return int <0 if KO, >=0 if OK - */ - function open_file($file, $outputlangs) + * Open output file + * + * @param string $file Path of filename to generate + * @param Translate $outputlangs Output language object + * @return int <0 if KO, >=0 if OK + */ + public function open_file($file, $outputlangs) { // phpcs:enable global $langs; @@ -180,21 +180,21 @@ class ExportTsv extends ModeleExports return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output header into file * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_header($outputlangs) + public function write_header($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line into file * @@ -203,8 +203,8 @@ class ExportTsv extends ModeleExports * @param Translate $outputlangs Object lang to translate values * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK - */ - function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) + */ + public function write_title($array_export_fields_label, $array_selected_sorted, $outputlangs, $array_types) { // phpcs:enable foreach($array_selected_sorted as $code => $value) @@ -219,7 +219,7 @@ class ExportTsv extends ModeleExports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record line into file * @@ -229,7 +229,7 @@ class ExportTsv extends ModeleExports * @param array $array_types Array with types of fields * @return int <0 if KO, >0 if OK */ - function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) + public function write_record($array_selected_sorted, $objp, $outputlangs, $array_types) { // phpcs:enable global $conf; @@ -263,33 +263,33 @@ class ExportTsv extends ModeleExports return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output footer into file * * @param Translate $outputlangs Output language object * @return int <0 if KO, >0 if OK */ - function write_footer($outputlangs) + public function write_footer($outputlangs) { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close file handle * * @return int <0 if KO, >0 if OK */ - function close_file() + public function close_file() { // phpcs:enable fclose($this->handle); return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Clean a cell to respect rules of TSV file cells * @@ -297,21 +297,20 @@ class ExportTsv extends ModeleExports * @param string $charset Input AND Output character set * @return string Value cleaned */ - function tsv_clean($newvalue, $charset) + public function tsv_clean($newvalue, $charset) { // phpcs:enable - // Rule Dolibarr: No HTML - $newvalue=dol_string_nohtmltag($newvalue, 1, $charset); + // Rule Dolibarr: No HTML + $newvalue=dol_string_nohtmltag($newvalue, 1, $charset); - // Rule 1 TSV: No CR, LF in cells - $newvalue=str_replace("\r", '', $newvalue); + // Rule 1 TSV: No CR, LF in cells + $newvalue=str_replace("\r", '', $newvalue); $newvalue=str_replace("\n", '\n', $newvalue); // Rule 2 TSV: If value contains tab, we must replace by space - if (preg_match('/'.$this->separator.'/', $newvalue)) - { - $newvalue=str_replace("\t", " ", $newvalue); - } + if (preg_match('/'.$this->separator.'/', $newvalue)) { + $newvalue=str_replace("\t", " ", $newvalue); + } return $newvalue; } diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 9ab3a45533d..17318e058ab 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -44,7 +44,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac public $libversion=array(); - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load into memory list of available export format * @@ -52,7 +52,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param integer $maxfilenamelength Max length of value to show * @return array List of templates (same content than array this->driverlabel) */ - function liste_modeles($db, $maxfilenamelength = 0) + public function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable dol_syslog(get_class($this)."::liste_modeles"); @@ -107,7 +107,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Picto string */ - function getPictoForKey($key) + public function getPictoForKey($key) { return $this->picto[$key]; } @@ -118,7 +118,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Label */ - function getDriverLabelForKey($key) + public function getDriverLabelForKey($key) { return $this->driverlabel[$key]; } @@ -129,7 +129,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Description */ - function getDriverDescForKey($key) + public function getDriverDescForKey($key) { return $this->driverdesc[$key]; } @@ -140,7 +140,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Driver version */ - function getDriverVersionForKey($key) + public function getDriverVersionForKey($key) { return $this->driverversion[$key]; } @@ -151,7 +151,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Label of library */ - function getLibLabelForKey($key) + public function getLibLabelForKey($key) { return $this->liblabel[$key]; } @@ -162,7 +162,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac * @param string $key Key of driver * @return string Version of library */ - function getLibVersionForKey($key) + public function getLibVersionForKey($key) { return $this->libversion[$key]; } 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 c5405d9c3a9..77a779d8ce0 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 @@ -63,8 +63,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $conf, $langs, $mysoc; // Load translation files required by the page @@ -99,7 +99,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures // Recupere emetteur $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // Par defaut, si n'etait pas defini - } + } /** @@ -108,8 +108,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) - { + public function info($langs) + { global $conf, $langs; // Load translation files required by the page @@ -188,11 +188,11 @@ class doc_generic_invoice_odt extends ModelePDFFactures $texte.= ''; return $texte; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build a document on disk using the generic odt module. + * Function to build a document on disk using the generic odt module. * * @param Facture $object Object source to build document * @param Translate $outputlangs Lang output object @@ -202,8 +202,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -521,5 +521,5 @@ class doc_generic_invoice_odt extends ModelePDFFactures } return -1; - } + } } diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index 3eb5905ccd2..1ba60bf9b41 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -137,7 +137,7 @@ class pdf_crabe extends ModelePDFFactures * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -218,7 +218,7 @@ class pdf_crabe extends ModelePDFFactures } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -230,7 +230,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; @@ -782,7 +782,7 @@ class pdf_crabe extends ModelePDFFactures } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * @@ -793,7 +793,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $heightforfooter height for footer * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0) { // phpcs:enable global $conf; @@ -928,7 +928,7 @@ class pdf_crabe extends ModelePDFFactures } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function _tableau_versements_header * @@ -942,7 +942,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $tab3_height height * @return void */ - function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) + private function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height) { // phpcs:enable $title=$outputlangs->transnoentities("PaymentsAlreadyDone"); @@ -967,7 +967,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -977,7 +977,7 @@ class pdf_crabe extends ModelePDFFactures * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -1126,7 +1126,7 @@ class pdf_crabe extends ModelePDFFactures } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -1137,7 +1137,7 @@ class pdf_crabe extends ModelePDFFactures * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -1455,7 +1455,7 @@ class pdf_crabe extends ModelePDFFactures * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1611,7 +1611,7 @@ class pdf_crabe extends ModelePDFFactures * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs; @@ -1886,7 +1886,7 @@ class pdf_crabe extends ModelePDFFactures * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 174f34bfb4b..da45babde4f 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -1,13 +1,13 @@ - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand - * Copyright (C) 2010-2014 Juanjo Menent - * Copyright (C) 2012 Christophe Battarel - * Copyright (C) 2012 Cédric Salvador - * Copyright (C) 2012-2014 Raphaël Doursenaud - * Copyright (C) 2015 Marcos García - * Copyright (C) 2017 Ferran Marcet +/* Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2008 Raphael Bertrand + * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2012 Christophe Battarel + * Copyright (C) 2012 Cédric Salvador + * Copyright (C) 2012-2014 Raphaël Doursenaud + * Copyright (C) 2015 Marcos García + * Copyright (C) 2017 Ferran Marcet * Copyright (C) 2018 Frédéric France * * This program is free software; you can redistribute it and/or modify @@ -26,9 +26,9 @@ */ /** - * \file htdocs/core/modules/facture/doc/pdf_sponge.modules.php - * \ingroup facture - * \brief File of class to generate customers invoices from sponge model + * \file htdocs/core/modules/facture/doc/pdf_sponge.modules.php + * \ingroup facture + * \brief File of class to generate customers invoices from sponge model */ require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; @@ -59,7 +59,7 @@ class pdf_sponge extends ModelePDFFactures public $description; /** - * @var int Save the name of generated file as the main doc when generating a doc with this template + * @var int Save the name of generated file as the main doc when generating a doc with this template */ public $update_main_doc_field; @@ -106,7 +106,7 @@ class pdf_sponge extends ModelePDFFactures * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -860,7 +860,7 @@ class pdf_sponge extends ModelePDFFactures * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK */ - function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs) + public function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs) { global $conf; @@ -1148,9 +1148,9 @@ class pdf_sponge extends ModelePDFFactures /** - * Show total to pay + * Show total to pay * - * @param PDF $pdf Object PDF + * @param PDF $pdf Object PDF * @param Facture $object Object invoice * @param int $deja_regle Montant deja regle * @param int $posy Position depart @@ -1478,7 +1478,7 @@ class pdf_sponge extends ModelePDFFactures * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1545,7 +1545,7 @@ class pdf_sponge extends ModelePDFFactures * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs; @@ -1818,7 +1818,7 @@ class pdf_sponge extends ModelePDFFactures * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; @@ -1826,16 +1826,16 @@ class pdf_sponge extends ModelePDFFactures } /** - * Define Array Column Field + * Define Array Column Field * - * @param object $object common object - * @param outputlangs $outputlangs langs - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref - * @return null - */ - function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + * @param object $object common object + * @param outputlangs $outputlangs langs + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref + * @return null + */ + public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $conf, $hookmanager; diff --git a/htdocs/core/modules/facture/mod_facture_mars.php b/htdocs/core/modules/facture/mod_facture_mars.php index 18bf4383200..0933d38306c 100644 --- a/htdocs/core/modules/facture/mod_facture_mars.php +++ b/htdocs/core/modules/facture/mod_facture_mars.php @@ -53,7 +53,7 @@ class mod_facture_mars extends ModeleNumRefFactures /** * Constructor */ - function __construct() + public function __construct() { if (! empty($conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX)) { @@ -66,7 +66,7 @@ class mod_facture_mars extends ModeleNumRefFactures * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -78,7 +78,7 @@ class mod_facture_mars extends ModeleNumRefFactures * * @return string Example */ - function getExample() + public function getExample() { return $this->prefixinvoice."0501-0001"; } @@ -89,7 +89,7 @@ class mod_facture_mars extends ModeleNumRefFactures * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs,$conf,$db; @@ -149,7 +149,7 @@ class mod_facture_mars extends ModeleNumRefFactures * @param string $mode 'next' for next value or 'last' for last value * @return string Value */ - function getNextValue($objsoc, $invoice, $mode = 'next') + public function getNextValue($objsoc, $invoice, $mode = 'next') { global $db; $prefix=$this->prefixinvoice; @@ -216,16 +216,16 @@ class mod_facture_mars extends ModeleNumRefFactures else dol_print_error('', 'Bad parameter for getNextValue'); } - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value - */ - function getNumRef($objsoc, $objforref, $mode = 'next') - { - return $this->getNextValue($objsoc, $objforref, $mode); - } + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next free value + */ + public function getNumRef($objsoc, $objforref, $mode = 'next') + { + return $this->getNextValue($objsoc, $objforref, $mode); + } } diff --git a/htdocs/core/modules/facture/mod_facture_mercure.php b/htdocs/core/modules/facture/mod_facture_mercure.php index 1cb86fdfdff..2ef492660b2 100644 --- a/htdocs/core/modules/facture/mod_facture_mercure.php +++ b/htdocs/core/modules/facture/mod_facture_mercure.php @@ -50,7 +50,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * * @return string Texte descripif */ - function info() + public function info() { global $db, $conf, $langs; @@ -108,7 +108,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -135,7 +135,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * @param string $mode 'next' for next value or 'last' for last value * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $invoice, $mode = 'next') + public function getNextValue($objsoc, $invoice, $mode = 'next') { global $db,$conf; @@ -182,7 +182,7 @@ class mod_facture_mercure extends ModeleNumRefFactures * @param string $mode 'next' for next value or 'last' for last value * @return string Next free value */ - function getNumRef($objsoc, $objforref, $mode = 'next') + public function getNumRef($objsoc, $objforref, $mode = 'next') { return $this->getNextValue($objsoc, $objforref, $mode); } diff --git a/htdocs/core/modules/facture/mod_facture_terre.php b/htdocs/core/modules/facture/mod_facture_terre.php index 5aa8f8e83b3..6e588aed098 100644 --- a/htdocs/core/modules/facture/mod_facture_terre.php +++ b/htdocs/core/modules/facture/mod_facture_terre.php @@ -50,7 +50,7 @@ class mod_facture_terre extends ModeleNumRefFactures /** * Constructor */ - function __construct() + public function __construct() { if (! empty($conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX)) { @@ -63,7 +63,7 @@ class mod_facture_terre extends ModeleNumRefFactures * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -75,7 +75,7 @@ class mod_facture_terre extends ModeleNumRefFactures * * @return string Example */ - function getExample() + public function getExample() { return $this->prefixinvoice."0501-0001"; } @@ -86,7 +86,7 @@ class mod_facture_terre extends ModeleNumRefFactures * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs,$conf,$db; @@ -167,7 +167,7 @@ class mod_facture_terre extends ModeleNumRefFactures * @param string $mode 'next' for next value or 'last' for last value * @return string Value */ - function getNextValue($objsoc, $invoice, $mode = 'next') + public function getNextValue($objsoc, $invoice, $mode = 'next') { global $db; @@ -231,16 +231,16 @@ class mod_facture_terre extends ModeleNumRefFactures else dol_print_error('', 'Bad parameter for getNextValue'); } - /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value - */ - function getNumRef($objsoc, $objforref, $mode = 'next') - { - return $this->getNextValue($objsoc, $objforref, $mode); - } + /** + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next free value + */ + public function getNumRef($objsoc, $objforref, $mode = 'next') + { + return $this->getNextValue($objsoc, $objforref, $mode); + } } diff --git a/htdocs/core/modules/facture/modules_facture.php b/htdocs/core/modules/facture/modules_facture.php index 7232853b4d8..7ed9eb7e94a 100644 --- a/htdocs/core/modules/facture/modules_facture.php +++ b/htdocs/core/modules/facture/modules_facture.php @@ -42,7 +42,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -50,7 +50,7 @@ abstract class ModelePDFFactures extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -80,7 +80,7 @@ abstract class ModeleNumRefFactures * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -90,7 +90,7 @@ abstract class ModeleNumRefFactures * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -102,7 +102,7 @@ abstract class ModeleNumRefFactures * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -115,7 +115,7 @@ abstract class ModeleNumRefFactures * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -127,7 +127,7 @@ abstract class ModeleNumRefFactures * @param Facture $facture Objet facture * @return string Value */ - function getNextValue($objsoc, $facture) + public function getNextValue($objsoc, $facture) { global $langs; return $langs->trans("NotAvailable"); @@ -138,15 +138,15 @@ abstract class ModeleNumRefFactures * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); } } diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php index 91a4ff6d332..559b4cd6d5e 100644 --- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php +++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php @@ -116,7 +116,7 @@ class pdf_soleil extends ModelePDFFicheinter * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -151,7 +151,7 @@ class pdf_soleil extends ModelePDFFicheinter $this->posxdesc=$this->marge_gauche+1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -163,7 +163,7 @@ class pdf_soleil extends ModelePDFFicheinter * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager; @@ -338,15 +338,12 @@ class pdf_soleil extends ModelePDFFicheinter // Description of product line $curX = $this->posxdesc-1; - // Description of product line - if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) - { - $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true); - } - else - { - $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true); - } + // Description of product line + if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) { + $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true); + } else { + $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true); + } if ($objectligne->duration > 0) { @@ -496,7 +493,7 @@ class pdf_soleil extends ModelePDFFicheinter * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf; @@ -556,7 +553,7 @@ class pdf_soleil extends ModelePDFFicheinter * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -732,7 +729,7 @@ class pdf_soleil extends ModelePDFFicheinter * @param int $hidefreetext 1=Hide free text * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index 08f3449d940..25b98473238 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -61,7 +61,7 @@ class mod_arctic extends ModeleNumRefFicheinter * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -101,7 +101,7 @@ class mod_arctic extends ModeleNumRefFicheinter * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -124,7 +124,7 @@ class mod_arctic extends ModeleNumRefFicheinter * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = 0, $object = '') { global $db,$conf; @@ -152,7 +152,7 @@ class mod_arctic extends ModeleNumRefFicheinter * @param Object $objforref Object for number to search * @return string Next free value */ - function getNumRef($objsoc, $objforref) + public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } diff --git a/htdocs/core/modules/fichinter/mod_pacific.php b/htdocs/core/modules/fichinter/mod_pacific.php index 472ffface10..4f66d6940f1 100644 --- a/htdocs/core/modules/fichinter/mod_pacific.php +++ b/htdocs/core/modules/fichinter/mod_pacific.php @@ -61,7 +61,7 @@ class mod_pacific extends ModeleNumRefFicheinter * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,7 +72,7 @@ class mod_pacific extends ModeleNumRefFicheinter * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -83,7 +83,7 @@ class mod_pacific extends ModeleNumRefFicheinter * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs,$conf,$db; @@ -122,7 +122,7 @@ class mod_pacific extends ModeleNumRefFicheinter * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = 0, $object = '') { global $db,$conf; @@ -158,7 +158,7 @@ class mod_pacific extends ModeleNumRefFicheinter * @param Object $objforref Object for number to search * @return string Next free value */ - function getNumRef($objsoc, $objforref) + public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } diff --git a/htdocs/core/modules/fichinter/modules_fichinter.php b/htdocs/core/modules/fichinter/modules_fichinter.php index 0c88cd88d56..f5056bf45bb 100644 --- a/htdocs/core/modules/fichinter/modules_fichinter.php +++ b/htdocs/core/modules/fichinter/modules_fichinter.php @@ -40,7 +40,7 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -48,7 +48,7 @@ abstract class ModelePDFFicheinter extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -79,7 +79,7 @@ abstract class ModeleNumRefFicheinter * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -89,7 +89,7 @@ abstract class ModeleNumRefFicheinter * * @return string Descriptive text */ - function info() + public function info() { global $langs; $langs->load("ficheinter"); @@ -101,7 +101,7 @@ abstract class ModeleNumRefFicheinter * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("ficheinter"); @@ -114,7 +114,7 @@ abstract class ModeleNumRefFicheinter * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -124,7 +124,7 @@ abstract class ModeleNumRefFicheinter * * @return string Value */ - function getNextValue() + public function getNextValue() { global $langs; return $langs->trans("NotAvailable"); @@ -135,21 +135,21 @@ abstract class ModeleNumRefFicheinter * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); } } -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps +// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create an intervention document on disk using template defined into FICHEINTER_ADDON_PDF * diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php index 3174208e85b..8c6fd9ebe97 100644 --- a/htdocs/core/modules/holiday/mod_holiday_immaculate.php +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -60,9 +60,9 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * * @return string text description */ - function info() + public function info() { - global $db, $conf, $langs; + global $db, $conf, $langs; $langs->load("bills"); @@ -96,7 +96,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$user; @@ -119,7 +119,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * @param Object $holiday holiday object * @return string Value if OK, 0 if KO */ - function getNextValue($user, $holiday) + public function getNextValue($user, $holiday) { global $db,$conf; @@ -138,7 +138,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays return $numFinal; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next value * @@ -146,7 +146,7 @@ class mod_holiday_immaculate extends ModelNumRefHolidays * @param Object $objforref Holiday object * @return string Value if OK, 0 if KO */ - function holiday_get_num($fuser, $objforref) + public function holiday_get_num($fuser, $objforref) { // phpcs:enable return $this->getNextValue($fuser, $objforref); diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php index 3e118d8aff9..187eb19d80d 100644 --- a/htdocs/core/modules/holiday/mod_holiday_madonna.php +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -62,7 +62,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * * @return string text description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -74,7 +74,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -85,7 +85,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -120,7 +120,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * @param Object $holiday Holiday object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $holiday) + public function getNextValue($objsoc, $holiday) { global $db,$conf; @@ -154,7 +154,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next value * @@ -162,7 +162,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays * @param Object $objforref Holiday object * @return string Value if OK, 0 if KO */ - function holiday_get_num($fuser, $objforref) + public function holiday_get_num($fuser, $objforref) { // phpcs:enable return $this->getNextValue($fuser, $objforref); diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php index 8076451b883..9bd0a448ebc 100644 --- a/htdocs/core/modules/holiday/modules_holiday.php +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -44,7 +44,7 @@ abstract class ModelePDFHoliday extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -52,7 +52,7 @@ abstract class ModelePDFHoliday extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -83,7 +83,7 @@ class ModelNumRefHolidays * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -93,7 +93,7 @@ class ModelNumRefHolidays * * @return string text description */ - function info() + public function info() { global $langs; $langs->load("holidays"); @@ -105,7 +105,7 @@ class ModelNumRefHolidays * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("holidays"); @@ -117,7 +117,7 @@ class ModelNumRefHolidays * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -129,7 +129,7 @@ class ModelNumRefHolidays * @param Object $contract contract object * @return string Value */ - function getNextValue($objsoc, $contract) + public function getNextValue($objsoc, $contract) { global $langs; return $langs->trans("NotAvailable"); @@ -140,7 +140,7 @@ class ModelNumRefHolidays * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -149,6 +149,6 @@ class ModelNumRefHolidays elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); elseif ($this->version == 'dolibarr') return DOL_VERSION; elseif ($this->version) return $this->version; - return $langs->trans("NotAvailable"); + else return $langs->trans("NotAvailable"); } } diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 17b6e556908..dbb8fadfe12 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -93,7 +93,7 @@ class ImportCsv extends ModeleImports * @param DoliDB $db Database handler * @param string $datatoimport String code describing import set (ex: 'societe_1') */ - function __construct($db, $datatoimport) + public function __construct($db, $datatoimport) { global $conf, $langs; $this->db = $db; @@ -118,20 +118,20 @@ class ImportCsv extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output header of an example file for this format * * @param Translate $outputlangs Output language * @return string */ - function write_header_example($outputlangs) + public function write_header_example($outputlangs) { // phpcs:enable return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line of an example file for this format * @@ -139,14 +139,14 @@ class ImportCsv extends ModeleImports * @param array $headerlinefields Array of fields name * @return string */ - function write_title_example($outputlangs, $headerlinefields) + public function write_title_example($outputlangs, $headerlinefields) { // phpcs:enable $s=join($this->separator, array_map('cleansep', $headerlinefields)); return $s."\n"; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record of an example file for this format * @@ -154,21 +154,21 @@ class ImportCsv extends ModeleImports * @param array $contentlinevalues Array of lines * @return string */ - function write_record_example($outputlangs, $contentlinevalues) + public function write_record_example($outputlangs, $contentlinevalues) { // phpcs:enable $s=join($this->separator, array_map('cleansep', $contentlinevalues)); return $s."\n"; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output footer of an example file for this format * * @param Translate $outputlangs Output language * @return string */ - function write_footer_example($outputlangs) + public function write_footer_example($outputlangs) { // phpcs:enable return ''; @@ -176,14 +176,14 @@ class ImportCsv extends ModeleImports - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Open input file * * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ - function import_open_file($file) + public function import_open_file($file) { // phpcs:enable global $langs; @@ -209,40 +209,40 @@ class ImportCsv extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return nb of records. File must be closed. * * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ - function import_get_nb_of_lines($file) + public function import_get_nb_of_lines($file) { // phpcs:enable return dol_count_nb_of_line($file); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Input header line from file * * @return int <0 if KO, >=0 if OK */ - function import_read_header() + public function import_read_header() { // phpcs:enable return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array of next record in input file. * * @return Array Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string) */ - function import_read_record() + public function import_read_record() { // phpcs:enable global $conf; @@ -293,13 +293,13 @@ class ImportCsv extends ModeleImports return $newarrayres; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close file handle * * @return integer */ - function import_close_file() + public function import_close_file() { // phpcs:enable fclose($this->handle); @@ -307,7 +307,7 @@ class ImportCsv extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert a record into database * @@ -319,7 +319,7 @@ class ImportCsv extends ModeleImports * @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. * @return int <0 if KO, >0 if OK */ - function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) + public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) { // phpcs:enable global $langs,$conf,$user; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 3cdd100068e..44134281fb4 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -95,7 +95,7 @@ class ImportXlsx extends ModeleImports * @param DoliDB $db Database handler * @param string $datatoimport String code describing import set (ex: 'societe_1') */ - function __construct($db, $datatoimport) + public function __construct($db, $datatoimport) { global $conf,$langs; $this->db = $db; @@ -125,14 +125,14 @@ class ImportXlsx extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output header of an example file for this format * * @param Translate $outputlangs Output language * @return string */ - function write_header_example($outputlangs) + public function write_header_example($outputlangs) { // phpcs:enable global $user,$conf,$langs; @@ -158,7 +158,7 @@ class ImportXlsx extends ModeleImports return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output title line of an example file for this format * @@ -166,7 +166,7 @@ class ImportXlsx extends ModeleImports * @param array $headerlinefields Array of fields name * @return string */ - function write_title_example($outputlangs, $headerlinefields) + public function write_title_example($outputlangs, $headerlinefields) { // phpcs:enable global $conf; @@ -184,7 +184,7 @@ class ImportXlsx extends ModeleImports return ''; // final output will be generated in footer } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output record of an example file for this format * @@ -192,7 +192,7 @@ class ImportXlsx extends ModeleImports * @param array $contentlinevalues Array of lines * @return string */ - function write_record_example($outputlangs, $contentlinevalues) + public function write_record_example($outputlangs, $contentlinevalues) { // phpcs:enable $col = 0; @@ -205,14 +205,14 @@ class ImportXlsx extends ModeleImports return ''; // final output will be generated in footer } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output footer of an example file for this format * * @param Translate $outputlangs Output language * @return string */ - function write_footer_example($outputlangs) + public function write_footer_example($outputlangs) { // phpcs:enable // return the file content as a string @@ -229,14 +229,14 @@ class ImportXlsx extends ModeleImports - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Open input file * * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ - function import_open_file($file) + public function import_open_file($file) { // phpcs:enable global $langs; @@ -253,14 +253,14 @@ class ImportXlsx extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return nb of records. File must be closed. * * @param string $file Path of filename * @return int <0 if KO, >=0 if OK */ - function import_get_nb_of_lines($file) + public function import_get_nb_of_lines($file) { // phpcs:enable $reader = new PHPExcel_Reader_Excel2007(); @@ -275,13 +275,13 @@ class ImportXlsx extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Input header line from file * * @return int <0 if KO, >=0 if OK */ - function import_read_header() + public function import_read_header() { // phpcs:enable // This is not called by the import code !!! @@ -294,13 +294,13 @@ class ImportXlsx extends ModeleImports } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return array of next record in input file. * * @return Array Array of field values. Data are UTF8 encoded. [fieldpos] => (['val']=>val, ['type']=>-1=null,0=blank,1=not empty string) */ - function import_read_record() + public function import_read_record() { // phpcs:enable global $conf; @@ -319,13 +319,13 @@ class ImportXlsx extends ModeleImports return $array; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Close file handle * * @return integer */ - function import_close_file() + public function import_close_file() { // phpcs:enable $this->workbook->disconnectWorksheets(); @@ -334,7 +334,7 @@ class ImportXlsx extends ModeleImports // What is this doing here ? it is common to all imports, is should be in the parent class - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert a record into database * @@ -346,7 +346,7 @@ class ImportXlsx extends ModeleImports * @param array $updatekeys Array of keys to use to try to do an update first before insert. This field are defined into the module descriptor. * @return int <0 if KO, >0 if OK */ - function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) + public function import_insert($arrayrecord, $array_match_file_to_database, $objimport, $maxfields, $importid, $updatekeys) { // phpcs:enable global $langs,$conf,$user; diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index 1c885bda1b4..7595c3c6c52 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -79,7 +79,7 @@ class ModeleImports /** * Constructor */ - function __construct() + public function __construct() { } @@ -89,7 +89,7 @@ class ModeleImports * * @return string Id */ - function getDriverId() + public function getDriverId() { return $this->id; } @@ -99,7 +99,7 @@ class ModeleImports * * @return string Label */ - function getDriverLabel() + public function getDriverLabel() { return $this->label; } @@ -109,7 +109,7 @@ class ModeleImports * * @return string Description */ - function getDriverDesc() + public function getDriverDesc() { return $this->desc; } @@ -119,7 +119,7 @@ class ModeleImports * * @return string Driver suffix */ - function getDriverExtension() + public function getDriverExtension() { return $this->extension; } @@ -129,7 +129,7 @@ class ModeleImports * * @return string Driver version */ - function getDriverVersion() + public function getDriverVersion() { return $this->version; } @@ -139,7 +139,7 @@ class ModeleImports * * @return string Label of external lib */ - function getLibLabel() + public function getLibLabel() { return $this->label_lib; } @@ -149,13 +149,13 @@ class ModeleImports * * @return string Version of external lib */ - function getLibVersion() + public function getLibVersion() { return $this->version_lib; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge en memoire et renvoie la liste des modeles actifs * @@ -163,7 +163,7 @@ class ModeleImports * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - function liste_modeles($db, $maxfilenamelength = 0) + public function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable dol_syslog(get_class($this)."::liste_modeles"); @@ -213,7 +213,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getPictoForKey($key) + public function getPictoForKey($key) { return $this->picto[$key]; } @@ -224,7 +224,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getDriverLabelForKey($key) + public function getDriverLabelForKey($key) { return $this->driverlabel[$key]; } @@ -235,7 +235,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getDriverDescForKey($key) + public function getDriverDescForKey($key) { return $this->driverdesc[$key]; } @@ -246,7 +246,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getDriverVersionForKey($key) + public function getDriverVersionForKey($key) { return $this->driverversion[$key]; } @@ -257,7 +257,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getLibLabelForKey($key) + public function getLibLabelForKey($key) { return $this->liblabel[$key]; } @@ -268,7 +268,7 @@ class ModeleImports * @param string $key Key * @return string */ - function getLibVersionForKey($key) + public function getLibVersionForKey($key) { return $this->libversion[$key]; } diff --git a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php index e8e5a6f9205..e84a05dd227 100644 --- a/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php +++ b/htdocs/core/modules/livraison/doc/pdf_typhon.modules.php @@ -117,7 +117,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -174,20 +174,20 @@ class pdf_typhon extends ModelePDFDeliveryOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * - * @param Object $object Object to generate - * @param Translate $outputlangs Lang output object - * @param string $srctemplatepath Full path of source filename for generator using a template file - * @param int $hidedetails Do not show line details - * @param int $hidedesc Do not show desc - * @param int $hideref Do not show ref + * @param Object $object Object to generate + * @param Translate $outputlangs Lang output object + * @param string $srctemplatepath Full path of source filename for generator using a template file + * @param int $hidedetails Do not show line details + * @param int $hidedesc Do not show desc + * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -637,7 +637,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -647,7 +647,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -678,7 +678,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -740,7 +740,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs,$hookmanager; @@ -910,18 +910,18 @@ class pdf_typhon extends ModelePDFDeliveryOrder } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) - { - global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } } diff --git a/htdocs/core/modules/livraison/mod_livraison_jade.php b/htdocs/core/modules/livraison/mod_livraison_jade.php index 89cb2794be3..fe94bf839c1 100644 --- a/htdocs/core/modules/livraison/mod_livraison_jade.php +++ b/htdocs/core/modules/livraison/mod_livraison_jade.php @@ -65,7 +65,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder * * @return string Texte descripif */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -76,7 +76,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -87,7 +87,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $langs,$conf,$db; @@ -125,7 +125,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -138,8 +138,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder $resql=$db->query($sql); dol_syslog("mod_livraison_jade::getNextValue", LOG_DEBUG); - if ($resql) - { + if ($resql) { $obj = $db->fetch_object($resql); if ($obj) $max = intval($obj->max); else $max=0; @@ -161,15 +160,15 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Return next free ref - * - * @param Societe $objsoc Object thirdparty - * @param Object $object Object livraison - * @return string Texte descriptif + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return next free ref + * + * @param Societe $objsoc Object thirdparty + * @param Object $object Object livraison + * @return string Texte descriptif */ - function livraison_get_num($objsoc = 0, $object = '') + public function livraison_get_num($objsoc = 0, $object = '') { // phpcs:enable return $this->getNextValue($objsoc, $object); diff --git a/htdocs/core/modules/livraison/mod_livraison_saphir.php b/htdocs/core/modules/livraison/mod_livraison_saphir.php index 4f8a0640816..2fc2e16d7fd 100644 --- a/htdocs/core/modules/livraison/mod_livraison_saphir.php +++ b/htdocs/core/modules/livraison/mod_livraison_saphir.php @@ -60,8 +60,8 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * * @return string Texte descripif */ - function info() - { + public function info() + { global $conf, $langs; $langs->load("bills"); @@ -100,7 +100,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -124,7 +124,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * @param Object $object Object delivery * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -152,13 +152,13 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * @param string $objforref Object for number to search * @return string Next free value */ - function getNumRef($objsoc, $objforref) + public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free ref * @@ -166,7 +166,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder * @param Object $object Objet livraison * @return string Texte descripif */ - function livraison_get_num($objsoc = 0, $object = '') + public function livraison_get_num($objsoc = 0, $object = '') { // phpcs:enable return $this->getNextValue($objsoc, $object); diff --git a/htdocs/core/modules/livraison/modules_livraison.php b/htdocs/core/modules/livraison/modules_livraison.php index 8ed70b102fd..ce9d9b77f77 100644 --- a/htdocs/core/modules/livraison/modules_livraison.php +++ b/htdocs/core/modules/livraison/modules_livraison.php @@ -36,119 +36,119 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; */ abstract class ModelePDFDeliveryOrder extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Return list of active generation modules - * - * @param DoliDB $db Database handler + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates - */ - static function liste_modeles($db, $maxfilenamelength = 0) - { + * @return array List of templates + */ + public static function liste_modeles($db, $maxfilenamelength = 0) + { // phpcs:enable - global $conf; + global $conf; - $type='delivery'; - $liste=array(); + $type='delivery'; + $liste=array(); - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $liste=getListOfModels($db, $type, $maxfilenamelength); + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db, $type, $maxfilenamelength); - return $liste; - } + return $liste; + } } /** - * \class ModeleNumRefDeliveryOrder - * \brief Classe mere des modeles de numerotation des references de bon de livraison + * \class ModeleNumRefDeliveryOrder + * \brief Classe mere des modeles de numerotation des references de bon de livraison */ abstract class ModeleNumRefDeliveryOrder { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - /** - * Return if a module can be used or not - * - * @return boolean true if module can be used - */ - function isEnabled() - { - return true; - } + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + public function isEnabled() + { + return true; + } - /** - * Renvoi la description par defaut du modele de numerotation - * - * @return string Texte descripif - */ - function info() - { - global $langs; - $langs->load("deliveries"); - return $langs->trans("NoDescription"); - } + /** + * Renvoi la description par defaut du modele de numerotation + * + * @return string Texte descripif + */ + public function info() + { + global $langs; + $langs->load("deliveries"); + return $langs->trans("NoDescription"); + } - /** - * Renvoi un exemple de numerotation - * - * @return string Example - */ - function getExample() - { - global $langs; - $langs->load("deliveries"); - return $langs->trans("NoExample"); - } + /** + * Renvoi un exemple de numerotation + * + * @return string Example + */ + public function getExample() + { + global $langs; + $langs->load("deliveries"); + return $langs->trans("NoExample"); + } - /** - * Test si les numeros deja en vigueur dans la base ne provoquent pas d - * de conflits qui empechera cette numerotation de fonctionner. - * - * @return boolean false si conflit, true si ok - */ - function canBeActivated() - { - return true; - } + /** + * Test si les numeros deja en vigueur dans la base ne provoquent pas d + * de conflits qui empechera cette numerotation de fonctionner. + * + * @return boolean false si conflit, true si ok + */ + public function canBeActivated() + { + return true; + } - /** - * Renvoi prochaine valeur attribuee - * - * @param Societe $objsoc Object third party - * @param Object $object Object delivery - * @return string Valeur - */ - function getNextValue($objsoc, $object) - { - global $langs; - return $langs->trans("NotAvailable"); - } + /** + * Renvoi prochaine valeur attribuee + * + * @param Societe $objsoc Object third party + * @param Object $object Object delivery + * @return string Valeur + */ + public function getNextValue($objsoc, $object) + { + global $langs; + return $langs->trans("NotAvailable"); + } - /** - * Renvoi version du module numerotation - * - * @return string Valeur - */ - function getVersion() - { - global $langs; - $langs->load("admin"); + /** + * Renvoi version du module numerotation + * + * @return string Valeur + */ + public function getVersion() + { + global $langs; + $langs->load("admin"); - if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); - } + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); + } } diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 180feec8699..a29fdd119bf 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -25,13 +25,13 @@ include_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; */ class mailing_advthirdparties extends MailingTargets { - var $name='ThirdPartyAdvancedTargeting'; + public $name='ThirdPartyAdvancedTargeting'; // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc="Third parties"; - var $require_admin=0; + public $desc="Third parties"; + public $require_admin=0; - var $require_module=array("none"); // This module should not be displayed as Selector in mailling - var $picto='company'; + public $require_module=array("none"); // This module should not be displayed as Selector in mailling + public $picto='company'; /** * @var DoliDB Database handler. @@ -44,13 +44,13 @@ class mailing_advthirdparties extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This is the main function that returns the array of emails * @@ -60,7 +60,7 @@ class mailing_advthirdparties extends MailingTargets * @param array $contactid Array of contact id to add * @return int <0 if error, number of emails added if ok */ - function add_to_target_spec($mailing_id, $socid, $type_of_target, $contactid) + public function add_to_target_spec($mailing_id, $socid, $type_of_target, $contactid) { // phpcs:enable global $conf, $langs; @@ -190,7 +190,7 @@ class mailing_advthirdparties extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { // CHANGE THIS: Optionnal @@ -208,7 +208,7 @@ class mailing_advthirdparties extends MailingTargets * @param string $sql Not use here * @return int Nb of recipients */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { global $conf; @@ -228,7 +228,7 @@ class mailing_advthirdparties extends MailingTargets * * @return string A html select zone */ - function formFilter() + public function formFilter() { global $conf, $langs; @@ -287,7 +287,7 @@ class mailing_advthirdparties extends MailingTargets * @param string $type type * @return string Url link */ - function url($id, $type) + public function url($id, $type) { if ($type=='thirdparty') { $companystatic=new Societe($this->db); diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 77d1cc10d72..79c58b1c7ce 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -32,12 +32,12 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; */ class mailing_contacts1 extends MailingTargets { - var $name='ContactCompanies'; // Identifiant du module mailing + public $name='ContactCompanies'; // Identifiant du module mailing // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Contacts of thirdparties (prospects, customers, suppliers...)'; - var $require_module=array("societe"); // Module mailing actif si modules require_module actifs - var $require_admin=0; // Module mailing actif pour user admin ou non - var $picto='contact'; + public $desc='Contacts of thirdparties (prospects, customers, suppliers...)'; + public $require_module=array("societe"); // Module mailing actif si modules require_module actifs + public $require_admin=0; // Module mailing actif pour user admin ou non + public $picto='contact'; /** * @var DoliDB Database handler. @@ -45,15 +45,15 @@ class mailing_contacts1 extends MailingTargets public $db; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db=$db; + } /** @@ -64,8 +64,8 @@ class mailing_contacts1 extends MailingTargets * * @return string[] Array with SQL requests */ - function getSqlArrayForStats() - { + public function getSqlArrayForStats() + { global $conf, $langs; $langs->load("commercial"); @@ -80,7 +80,7 @@ class mailing_contacts1 extends MailingTargets $statssql[0].= " AND c.statut = 1"; return $statssql; - } + } /** @@ -91,8 +91,8 @@ class mailing_contacts1 extends MailingTargets * @param string $sql Requete sql de comptage * @return int */ - function getNbOfRecipients($sql = '') - { + public function getNbOfRecipients($sql = '') + { global $conf; $sql = "SELECT count(distinct(c.email)) as nb"; @@ -105,7 +105,7 @@ class mailing_contacts1 extends MailingTargets // The request must return a field called "nb" to be understandable by parent::getNbOfRecipients return parent::getNbOfRecipients($sql); - } + } /** @@ -113,8 +113,8 @@ class mailing_contacts1 extends MailingTargets * * @return string Retourne zone select */ - function formFilter() - { + public function formFilter() + { global $langs; // Load translation files required by the page @@ -311,7 +311,7 @@ class mailing_contacts1 extends MailingTargets $s.=''; return $s; - } + } /** @@ -320,21 +320,21 @@ class mailing_contacts1 extends MailingTargets * @param int $id ID * @return string Url lien */ - function url($id) - { - return ''.img_object('', "contact").''; - } + public function url($id) + { + return ''.img_object('', "contact").''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing * @return int <0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id) - { + public function add_to_target($mailing_id) + { // phpcs:enable global $conf, $langs; @@ -448,5 +448,5 @@ class mailing_contacts1 extends MailingTargets } return parent::add_to_target($mailing_id, $cibles); - } + } } diff --git a/htdocs/core/modules/mailings/example.modules.php b/htdocs/core/modules/mailings/example.modules.php index 8feadc6b6e2..45af3dd5b4d 100644 --- a/htdocs/core/modules/mailings/example.modules.php +++ b/htdocs/core/modules/mailings/example.modules.php @@ -26,17 +26,17 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; class mailing_example extends MailingTargets { // CHANGE THIS: Put here a name not already used - var $name='example'; + public $name='example'; // CHANGE THIS: Put here a description of your selector module. // This label is used if no translation is found for key MailingModuleDescXXX where XXX=name is found - var $desc='Put here a description'; - // CHANGE THIS: Set to 1 if selector is available for admin users only - var $require_admin=0; + public $desc='Put here a description'; + // CHANGE THIS: Set to 1 if selector is available for admin users only + public $require_admin=0; // CHANGE THIS: Add a tooltip language key to add a tooltip help icon after the email target selector - var $tooltip='MyTooltipLangKey'; + public $tooltip='MyTooltipLangKey'; - var $require_module=array(); - var $picto=''; + public $require_module=array(); + public $picto=''; /** * @var DoliDB Database handler. @@ -50,20 +50,20 @@ class mailing_example extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This is the main function that returns the array of emails * * @param int $mailing_id Id of mailing. No need to use it. * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable $target = array(); @@ -92,7 +92,7 @@ class mailing_example extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { // CHANGE THIS: Optionnal @@ -103,14 +103,14 @@ class mailing_example extends MailingTargets /** - * Return here number of distinct emails returned by your selector. - * For example if this selector is used to extract 500 different - * emails from a text file, this function must return 500. + * Return here number of distinct emails returned by your selector. + * For example if this selector is used to extract 500 different + * emails from a text file, this function must return 500. * * @param string $sql Requete sql de comptage - * @return int|string Number of recipient or '?' + * @return int|string Number of recipient or '?' */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { // CHANGE THIS: Optionnal @@ -121,11 +121,11 @@ class mailing_example extends MailingTargets /** * This is to add a form filter to provide variant of selector - * If used, the HTML select must be called "filter" + * If used, the HTML select must be called "filter" * * @return string A html select zone */ - function formFilter() + public function formFilter() { // CHANGE THIS: Optionnal @@ -141,7 +141,7 @@ class mailing_example extends MailingTargets * @param int $id ID * @return string Url link */ - function url($id) + public function url($id) { // CHANGE THIS: Optionnal diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index d417bdc8bef..2ea4ba8e3b5 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -33,14 +33,14 @@ include_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; */ class mailing_fraise extends MailingTargets { - var $name='FundationMembers'; // Identifiant du module mailing + public $name='FundationMembers'; // Identifiant du module mailing // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Foundation members with emails'; + public $desc='Foundation members with emails'; // Set to 1 if selector is available for admin users only - var $require_admin=0; + public $require_admin=0; - var $require_module=array('adherent'); - var $picto='user'; + public $require_module=array('adherent'); + public $picto='user'; /** * @var DoliDB Database handler. @@ -52,7 +52,7 @@ class mailing_fraise extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -66,7 +66,7 @@ class mailing_fraise extends MailingTargets * * @return string[] Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { global $langs; @@ -90,7 +90,7 @@ class mailing_fraise extends MailingTargets * @param string $sql Requete sql de comptage * @return int Nb of recipients */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { $sql = "SELECT count(distinct(a.email)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; @@ -107,7 +107,7 @@ class mailing_fraise extends MailingTargets * * @return string Retourne zone select */ - function formFilter() + public function formFilter() { global $conf, $langs; @@ -214,20 +214,20 @@ class mailing_fraise extends MailingTargets * @param int $id ID * @return string Url lien */ - function url($id) + public function url($id) { return ''.img_object('', "user").''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable global $langs,$_POST; diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index 0e28b156e09..f3ee3396acb 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -49,7 +49,7 @@ class MailingTargets // This can't be abstract as it is used for some method * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -59,7 +59,7 @@ class MailingTargets // This can't be abstract as it is used for some method * * @return string Return translation of module label. Try translation of $this->name then translation of 'MailingModuleDesc'.$this->name, or $this->desc if not found */ - function getDesc() + public function getDesc() { global $langs, $form; @@ -80,7 +80,7 @@ class MailingTargets // This can't be abstract as it is used for some method * * @return integer Example */ - function getNbOfRecords() + public function getNbOfRecords() { return 0; } @@ -91,7 +91,7 @@ class MailingTargets // This can't be abstract as it is used for some method * @param string $sql Sql request to count * @return int Nb of recipient, or <0 if error */ - function getNbOfRecipients($sql) + public function getNbOfRecipients($sql) { $result=$this->db->query($sql); if ($result) @@ -112,19 +112,19 @@ class MailingTargets // This can't be abstract as it is used for some method * * @return string Retourne zone select */ - function formFilter() + public function formFilter() { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Met a jour nombre de destinataires * * @param int $mailing_id Id of emailing * @return int < 0 si erreur, nb destinataires si ok */ - function update_nb($mailing_id) + public function update_nb($mailing_id) { // phpcs:enable // Mise a jour nombre de destinataire dans table des mailings @@ -151,7 +151,7 @@ class MailingTargets // This can't be abstract as it is used for some method return $nb; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * @@ -159,7 +159,7 @@ class MailingTargets // This can't be abstract as it is used for some method * @param array $cibles Array with targets * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id, $cibles) + public function add_to_target($mailing_id, $cibles) { // phpcs:enable global $conf; @@ -247,14 +247,14 @@ class MailingTargets // This can't be abstract as it is used for some method return $j; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Supprime tous les destinataires de la table des cibles * - * @param int $mailing_id Id of emailing - * @return void + * @param int $mailing_id Id of emailing + * @return void */ - function clear_target($mailing_id) + public function clear_target($mailing_id) { // phpcs:enable $sql = "DELETE FROM ".MAIN_DB_PREFIX."mailing_cibles"; diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index a0815aac9ec..74dc86c1d9a 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -30,12 +30,12 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; */ class mailing_pomme extends MailingTargets { - var $name='DolibarrUsers'; // Identifiant du module mailing + public $name='DolibarrUsers'; // Identifiant du module mailing // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Dolibarr users with emails'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e - var $require_module=array(); // Module mailing actif si modules require_module actifs - var $require_admin=1; // Module mailing actif pour user admin ou non - var $picto='user'; + public $desc='Dolibarr users with emails'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e + public $require_module=array(); // Module mailing actif si modules require_module actifs + public $require_admin=1; // Module mailing actif pour user admin ou non + public $picto='user'; /** * @var DoliDB Database handler. @@ -48,7 +48,7 @@ class mailing_pomme extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } @@ -62,7 +62,7 @@ class mailing_pomme extends MailingTargets * * @return string[] Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { global $conf, $langs; @@ -88,7 +88,7 @@ class mailing_pomme extends MailingTargets * @param string $sql SQL request to use to count * @return int Number of recipients */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { global $conf; @@ -108,7 +108,7 @@ class mailing_pomme extends MailingTargets * * @return string Retourne zone select */ - function formFilter() + public function formFilter() { global $langs; @@ -140,20 +140,20 @@ class mailing_pomme extends MailingTargets * @param int $id ID * @return string Url lien */ - function url($id) + public function url($id) { return ''.img_object('', "user").''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable global $conf, $langs; @@ -191,17 +191,17 @@ class mailing_pomme extends MailingTargets if ($old <> $obj->email) { $cibles[$j] = array( - 'email' => $obj->email, - 'fk_contact' => $obj->fk_contact, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'other' => - ($langs->transnoentities("Login").'='.$obj->login).';'. - ($langs->transnoentities("UserTitle").'='.$obj->civility_id).';'. - ($langs->transnoentities("PhonePro").'='.$obj->office_phone), - 'source_url' => $this->url($obj->id), - 'source_id' => $obj->id, - 'source_type' => 'user' + 'email' => $obj->email, + 'fk_contact' => $obj->fk_contact, + 'lastname' => $obj->lastname, + 'firstname' => $obj->firstname, + 'other' => + ($langs->transnoentities("Login").'='.$obj->login).';'. + ($langs->transnoentities("UserTitle").'='.$obj->civility_id).';'. + ($langs->transnoentities("PhonePro").'='.$obj->office_phone), + 'source_url' => $this->url($obj->id), + 'source_id' => $obj->id, + 'source_type' => 'user' ); $old = $obj->email; $j++; @@ -218,5 +218,5 @@ class mailing_pomme extends MailingTargets } return parent::add_to_target($mailing_id, $cibles); - } + } } diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 4835fe5123d..9a30a063ad3 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -24,13 +24,13 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/mailings/modules_mailings.php'; */ class mailing_thirdparties extends MailingTargets { - var $name='ThirdPartiesByCategories'; + public $name='ThirdPartiesByCategories'; // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc="Third parties (by categories)"; - var $require_admin=0; + public $desc="Third parties (by categories)"; + public $require_admin=0; - var $require_module=array("societe"); // This module allows to select by categories must be also enabled if category module is not activated - var $picto='company'; + public $require_module=array("societe"); // This module allows to select by categories must be also enabled if category module is not activated + public $picto='company'; /** * @var DoliDB Database handler. @@ -43,7 +43,7 @@ class mailing_thirdparties extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; $langs->load("companies"); @@ -52,14 +52,14 @@ class mailing_thirdparties extends MailingTargets } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This is the main function that returns the array of emails * * @param int $mailing_id Id of mailing. No need to use it. * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable global $conf, $langs; @@ -200,7 +200,7 @@ class mailing_thirdparties extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { // CHANGE THIS: Optionnal @@ -218,7 +218,7 @@ class mailing_thirdparties extends MailingTargets * @param string $sql Requete sql de comptage * @return int Nb of recipients */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { global $conf; @@ -238,7 +238,7 @@ class mailing_thirdparties extends MailingTargets * * @return string A html select zone */ - function formFilter() + public function formFilter() { global $conf, $langs; @@ -319,7 +319,7 @@ class mailing_thirdparties extends MailingTargets * @param int $id ID * @return string Url link */ - function url($id) + public function url($id) { return ''.img_object('', "company").''; } diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 5c6438b469f..a19c5480722 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -22,20 +22,20 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; */ class mailing_thirdparties_services_expired extends MailingTargets { - var $name='DolibarrContractsLinesExpired'; + public $name='DolibarrContractsLinesExpired'; // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='Third parties with expired contract\'s lines'; - var $require_admin=0; + public $desc='Third parties with expired contract\'s lines'; + public $require_admin=0; - var $require_module=array('contrat'); - var $picto='company'; + public $require_module=array('contrat'); + public $picto='company'; /** * @var DoliDB Database handler. */ public $db; - var $arrayofproducts=array(); + public $arrayofproducts=array(); /** @@ -43,7 +43,7 @@ class mailing_thirdparties_services_expired extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -77,14 +77,14 @@ class mailing_thirdparties_services_expired extends MailingTargets } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * This is the main function that returns the array of emails * * @param int $mailing_id Id of mailing. No need to use it. * @return int <0 if error, number of emails added if ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable $key=GETPOST('filter', 'int'); @@ -171,7 +171,7 @@ class mailing_thirdparties_services_expired extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { //var $statssql=array(); @@ -189,7 +189,7 @@ class mailing_thirdparties_services_expired extends MailingTargets * @param string $sql SQL request to use to count * @return int Number of recipients */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { $now=dol_now(); @@ -215,7 +215,7 @@ class mailing_thirdparties_services_expired extends MailingTargets * * @return string A html select zone */ - function formFilter() + public function formFilter() { global $langs; @@ -238,7 +238,7 @@ class mailing_thirdparties_services_expired extends MailingTargets * @param int $id ID * @return string Url link */ - function url($id) + public function url($id) { return ''.img_object('', "company").''; } diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index 92f4bb3f059..adcd03b6307 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -30,24 +30,24 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; */ class mailing_xinputfile extends MailingTargets { - var $name='EmailsFromFile'; // Identifiant du module mailing - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='EMails from a file'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e - var $require_module=array(); // Module mailing actif si modules require_module actifs - var $require_admin=0; // Module mailing actif pour user admin ou non - var $picto='generic'; - var $tooltip='UseFormatFileEmailToTarget'; + public $name='EmailsFromFile'; // Identifiant du module mailing + // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + public $desc='EMails from a file'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e + public $require_module=array(); // Module mailing actif si modules require_module actifs + public $require_admin=0; // Module mailing actif pour user admin ou non + public $picto='generic'; + public $tooltip='UseFormatFileEmailToTarget'; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db=$db; + } /** @@ -58,7 +58,7 @@ class mailing_xinputfile extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { global $langs; $langs->load("users"); @@ -76,7 +76,7 @@ class mailing_xinputfile extends MailingTargets * @param string $sql Sql request to count * @return string '' means NA */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { return ''; } @@ -88,7 +88,7 @@ class mailing_xinputfile extends MailingTargets * @param int $id ID * @return string Url lien */ - function url($id) + public function url($id) { global $langs; return $langs->trans('LineInFile', $id); @@ -101,7 +101,7 @@ class mailing_xinputfile extends MailingTargets * * @return string Retourne zone select */ - function formFilter() + public function formFilter() { global $langs; @@ -110,14 +110,14 @@ class mailing_xinputfile extends MailingTargets return $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable global $conf,$langs,$_FILES; diff --git a/htdocs/core/modules/mailings/xinputuser.modules.php b/htdocs/core/modules/mailings/xinputuser.modules.php index 96177483542..62990ec6f90 100644 --- a/htdocs/core/modules/mailings/xinputuser.modules.php +++ b/htdocs/core/modules/mailings/xinputuser.modules.php @@ -30,13 +30,13 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; */ class mailing_xinputuser extends MailingTargets { - var $name='EmailsFromUser'; // Identifiant du module mailing + public $name='EmailsFromUser'; // Identifiant du module mailing // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - var $desc='EMails input by user'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e - var $require_module=array(); // Module mailing actif si modules require_module actifs - var $require_admin=0; // Module mailing actif pour user admin ou non - var $picto='generic'; - var $tooltip='UseFormatInputEmailToTarget'; + public $desc='EMails input by user'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e + public $require_module=array(); // Module mailing actif si modules require_module actifs + public $require_admin=0; // Module mailing actif pour user admin ou non + public $picto='generic'; + public $tooltip='UseFormatInputEmailToTarget'; /** @@ -44,7 +44,7 @@ class mailing_xinputuser extends MailingTargets * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } @@ -58,7 +58,7 @@ class mailing_xinputuser extends MailingTargets * * @return array Array with SQL requests */ - function getSqlArrayForStats() + public function getSqlArrayForStats() { global $langs; $langs->load("users"); @@ -76,7 +76,7 @@ class mailing_xinputuser extends MailingTargets * @param string $sql Sql request to count * @return string '' means NA */ - function getNbOfRecipients($sql = '') + public function getNbOfRecipients($sql = '') { return ''; } @@ -88,7 +88,7 @@ class mailing_xinputuser extends MailingTargets * @param int $id ID * @return string Url lien */ - function url($id) + public function url($id) { return ''; } @@ -99,7 +99,7 @@ class mailing_xinputuser extends MailingTargets * * @return string Retourne zone select */ - function formFilter() + public function formFilter() { global $langs; @@ -108,14 +108,14 @@ class mailing_xinputuser extends MailingTargets return $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Ajoute destinataires dans table des cibles * * @param int $mailing_id Id of emailing * @return int < 0 si erreur, nb ajout si ok */ - function add_to_target($mailing_id) + public function add_to_target($mailing_id) { // phpcs:enable global $conf,$langs,$_FILES; diff --git a/htdocs/core/modules/member/doc/pdf_standard.class.php b/htdocs/core/modules/member/doc/pdf_standard.class.php index 40b591aed3a..f3a105f99f1 100644 --- a/htdocs/core/modules/member/doc/pdf_standard.class.php +++ b/htdocs/core/modules/member/doc/pdf_standard.class.php @@ -42,12 +42,12 @@ class pdf_standard extends CommonStickerGenerator * @param array $param Associative array containing label content and optional parameters * @return void */ - function addSticker(&$pdf, $outputlangs, $param) + public function addSticker(&$pdf, $outputlangs, $param) { // use this method in future refactoring } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) * - __LOGO__ is replace with company logo @@ -63,7 +63,7 @@ class pdf_standard extends CommonStickerGenerator * @param string $photo Photo (full path to image file used as replacement for key __PHOTOS__ into left, right, header or footer text) * @return void */ - function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '') + public function Add_PDF_card(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $idmember = 0, $photo = '') { // phpcs:enable global $db,$mysoc,$conf,$langs; @@ -237,7 +237,7 @@ class pdf_standard extends CommonStickerGenerator } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP stream. * @@ -248,7 +248,7 @@ class pdf_standard extends CommonStickerGenerator * @param int $nooutput 1=Generate only file on disk and do not return it on response * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $mode = 'member', $nooutput = 0) { // phpcs:enable global $user,$conf,$langs,$mysoc,$_Avery_Labels; diff --git a/htdocs/core/modules/member/modules_cards.php b/htdocs/core/modules/member/modules_cards.php index 4d70e984d69..cf665b45759 100644 --- a/htdocs/core/modules/member/modules_cards.php +++ b/htdocs/core/modules/member/modules_cards.php @@ -40,7 +40,7 @@ class ModelePDFCards public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -48,7 +48,7 @@ class ModelePDFCards * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - function liste_modeles($db, $maxfilenamelength = 0) + public function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/modAccounting.class.php b/htdocs/core/modules/modAccounting.class.php index 2a4ff0fc42e..ea247d3b5f9 100644 --- a/htdocs/core/modules/modAccounting.class.php +++ b/htdocs/core/modules/modAccounting.class.php @@ -37,7 +37,7 @@ class modAccounting extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php index 6cf5e45c7f2..c0d5e8f4116 100644 --- a/htdocs/core/modules/modAdherent.class.php +++ b/htdocs/core/modules/modAdherent.class.php @@ -38,23 +38,23 @@ class modAdherent extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $conf; + global $conf; $this->db = $db; $this->numero = 310; $this->family = "hr"; $this->module_position = '55'; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) + $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Management of members of a foundation or association"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'dolibarr'; $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto='user'; @@ -67,9 +67,9 @@ class modAdherent extends DolibarrModules // Dependencies $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled - $this->requiredby = array(); // List of module ids to disable if this one is disabled - $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with + $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled + $this->requiredby = array(); // List of module ids to disable if this one is disabled + $this->conflictwith = array('modMailmanSpip'); // List of module class names as string this module is in conflict with $this->langfiles = array("members","companies"); $this->phpmin = array(5,4); // Minimum version of PHP required by module @@ -248,9 +248,9 @@ class modAdherent extends DolibarrModules $this->rights[$r][5] = 'creer'; - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. // Exports @@ -269,36 +269,36 @@ class modAdherent extends DolibarrModules $this->export_label[$r]='MembersAndSubscriptions'; $this->export_permission[$r]=array(array("adherent","export")); $this->export_fields_array[$r]=array( - 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature', - 'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country", - 'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status", - 'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation', - 'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel', - 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' - ); + 'a.rowid'=>'Id','a.civility'=>"UserTitle",'a.lastname'=>"Lastname",'a.firstname'=>"Firstname",'a.login'=>"Login",'a.gender'=>"Gender",'a.morphy'=>'Nature', + 'a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town",'d.nom'=>"State",'co.code'=>"CountryCode",'co.label'=>"Country", + 'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile",'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status", + 'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate",'a.datec'=>'DateCreation','a.datevalid'=>'DateValidation', + 'a.tms'=>'DateLastModification','a.datefin'=>'DateEndSubscription','ta.rowid'=>'MemberTypeId','ta.libelle'=>'MemberTypeLabel', + 'c.rowid'=>'SubscriptionId','c.dateadh'=>'DateSubscription','c.subscription'=>'Amount' + ); $this->export_TypeFields_array[$r]=array( - 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", - 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", - 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', - 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' - ); + 'a.civility'=>"Text",'a.lastname'=>"Text",'a.firstname'=>"Text",'a.login'=>"Text",'a.gender'=>'Text','a.morphy'=>'Text','a.societe'=>'Text','a.address'=>"Text", + 'a.zip'=>"Text",'a.town'=>"Text",'d.nom'=>"Text",'co.code'=>'Text','co.label'=>"Text",'a.phone'=>"Text",'a.phone_perso'=>"Text",'a.phone_mobile'=>"Text", + 'a.email'=>"Text",'a.birth'=>"Date",'a.statut'=>"Status",'a.note_public'=>"Text",'a.note_private'=>"Text",'a.datec'=>'Date','a.datevalid'=>'Date', + 'a.tms'=>'Date','a.datefin'=>'Date','ta.rowid'=>'List:adherent_type:libelle::member_type','ta.libelle'=>'Text','c.rowid'=>'Numeric','c.dateadh'=>'Date','c.subscription'=>'Numeric' + ); $this->export_entities_array[$r]=array( - 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member', - 'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member", - 'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member", - 'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member', - 'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription' - ); + 'a.rowid'=>'member','a.civility'=>"member",'a.lastname'=>"member",'a.firstname'=>"member",'a.login'=>"member",'a.gender'=>'member','a.morphy'=>'member', + 'a.societe'=>'member','a.address'=>"member",'a.zip'=>"member",'a.town'=>"member",'d.nom'=>"member",'co.code'=>"member",'co.label'=>"member", + 'a.phone'=>"member",'a.phone_perso'=>"member",'a.phone_mobile'=>"member",'a.email'=>"member",'a.birth'=>"member",'a.statut'=>"member", + 'a.photo'=>"member",'a.note_public'=>"member",'a.note_private'=>"member",'a.datec'=>'member','a.datevalid'=>'member','a.tms'=>'member', + 'a.datefin'=>'member','ta.rowid'=>'member_type','ta.libelle'=>'member_type','c.rowid'=>'subscription','c.dateadh'=>'subscription','c.subscription'=>'subscription' + ); // Add extra fields $keyforselect='adherent'; $keyforelement='member'; $keyforaliasextra='extra'; include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - // End add axtra fields + // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM ('.MAIN_DB_PREFIX.'adherent_type as ta, '.MAIN_DB_PREFIX.'adherent as a)'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'adherent_extrafields as extra ON a.rowid = extra.fk_object'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'subscription as c ON c.fk_adherent = a.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid'; - $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_departements as d ON a.state_id = d.rowid'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co ON a.country = co.rowid'; $this->export_sql_end[$r] .=' WHERE a.fk_adherent_type = ta.rowid AND ta.entity IN ('.getEntity('member_type').') '; $this->export_dependencies_array[$r]=array('subscription'=>'c.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them @@ -317,54 +317,54 @@ class modAdherent extends DolibarrModules $this->import_tables_array[$r]=array('a'=>MAIN_DB_PREFIX.'adherent','extra'=>MAIN_DB_PREFIX.'adherent_extrafields'); $this->import_tables_creator_array[$r]=array('a'=>'fk_user_author'); // Fields to store import user id $this->import_fields_array[$r]=array( - 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password", - "a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town", - 'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile", - 'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate", - 'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription' - ); - // Add extra fields - $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; - $resql=$this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj=$this->db->fetch_object($resql)) - { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); - } - } - // End add extra fields - $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) - $this->import_regex_array[$r]=array( - 'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)', - 'a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); + 'a.civility'=>"UserTitle",'a.lastname'=>"Lastname*",'a.firstname'=>"Firstname",'a.gender'=>"Gender",'a.login'=>"Login*","a.pass"=>"Password", + "a.fk_adherent_type"=>"MemberType*",'a.morphy'=>'Nature*','a.societe'=>'Company','a.address'=>"Address",'a.zip'=>"Zip",'a.town'=>"Town", + 'a.state_id'=>'StateId','a.country'=>"CountryId",'a.phone'=>"PhonePro",'a.phone_perso'=>"PhonePerso",'a.phone_mobile'=>"PhoneMobile", + 'a.email'=>"Email",'a.birth'=>"Birthday",'a.statut'=>"Status*",'a.photo'=>"Photo",'a.note_public'=>"NotePublic",'a.note_private'=>"NotePrivate", + 'a.datec'=>'DateCreation','a.datefin'=>'DateEndSubscription' + ); + // Add extra fields + $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); + } + } + // End add extra fields + $this->import_fieldshidden_array[$r]=array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'adherent'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent) + $this->import_regex_array[$r]=array( + 'a.civility'=>'code@'.MAIN_DB_PREFIX.'c_civility','a.fk_adherent_type'=>'rowid@'.MAIN_DB_PREFIX.'adherent_type','a.morphy'=>'(phy|mor)', + 'a.statut'=>'^[0|1]','a.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$','a.datefin'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$'); $this->import_examplevalues_array[$r]=array( - 'a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1', - 'a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1', - 'a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member", - 'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now, '%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d') - ); + 'a.civility'=>"MR",'a.lastname'=>'Smith','a.firstname'=>'John','a.login'=>'jsmith','a.pass'=>'passofjsmith','a.fk_adherent_type'=>'1', + 'a.morphy'=>'"mor" or "phy"','a.societe'=>'JS company','a.address'=>'21 jump street','a.zip'=>'55000','a.town'=>'New York','a.country'=>'1', + 'a.email'=>'jsmith@example.com','a.birth'=>'1972-10-10','a.statut'=>"0 or 1",'a.note_public'=>"This is a public comment on member", + 'a.note_private'=>"This is private comment on member",'a.datec'=>dol_print_date($now, '%Y-%m__%d'),'a.datefin'=>dol_print_date(dol_time_plus_duree($now, 1, 'y'), '%Y-%m-%d') + ); // Cronjobs $arraydate=dol_getdate(dol_now()); $datestart=dol_mktime(22, 0, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']); $this->cronjobs = array( - 0=>array( - 'label'=>'SendReminderForExpiredSubscriptionTitle', - 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', - 'objectname'=>'Adherent', - 'method'=>'sendReminderForExpiredSubscription', - 'parameters'=>'10;0', - 'comment'=>'SendReminderForExpiredSubscription', - 'frequency'=>1, - 'unitfrequency'=> 3600 * 24, - 'priority'=>50, - 'status'=>1, - 'test'=>'$conf->adherent->enabled', - 'datestart'=>$datestart - ), + 0=>array( + 'label'=>'SendReminderForExpiredSubscriptionTitle', + 'jobtype'=>'method', 'class'=>'adherents/class/adherent.class.php', + 'objectname'=>'Adherent', + 'method'=>'sendReminderForExpiredSubscription', + 'parameters'=>'10;0', + 'comment'=>'SendReminderForExpiredSubscription', + 'frequency'=>1, + 'unitfrequency'=> 3600 * 24, + 'priority'=>50, + 'status'=>1, + 'test'=>'$conf->adherent->enabled', + 'datestart'=>$datestart + ), ); } @@ -377,7 +377,7 @@ class modAdherent extends DolibarrModules * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index fc2c173d90c..9877cb8bacb 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -43,7 +43,7 @@ class modAgenda extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -204,18 +204,20 @@ class modAgenda extends DolibarrModules // 'target'=>'', // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // $r++; - $this->menu[$r]=array('fk_menu'=>0, - 'type'=>'top', - 'titre'=>'TMenuAgenda', - 'mainmenu'=>'agenda', - 'url'=>'/comm/action/index.php', - 'langs'=>'agenda', - 'position'=>86, - 'perms'=>'$user->rights->agenda->myactions->read', - 'enabled'=>'$conf->agenda->enabled', - 'target'=>'', - 'user'=>2); - $r++; + $this->menu[$r]=array( + 'fk_menu'=>0, + 'type'=>'top', + 'titre'=>'TMenuAgenda', + 'mainmenu'=>'agenda', + 'url'=>'/comm/action/index.php', + 'langs'=>'agenda', + 'position'=>86, + 'perms'=>'$user->rights->agenda->myactions->read', + 'enabled'=>'$conf->agenda->enabled', + 'target'=>'', + 'user'=>2, + ); + $r++; $this->menu[$r]=array('fk_menu'=>'r=0', 'type'=>'left', diff --git a/htdocs/core/modules/modApi.class.php b/htdocs/core/modules/modApi.class.php index 8bfec6a1734..b860bf5b9bc 100644 --- a/htdocs/core/modules/modApi.class.php +++ b/htdocs/core/modules/modApi.class.php @@ -38,7 +38,7 @@ class modApi extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; @@ -224,14 +224,14 @@ class modApi extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { - $sql = array(); + public function init($options = '') + { + $sql = array(); - $result=$this->_load_tables('/api/sql/'); + $result = $this->_load_tables('/api/sql/'); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } /** * Function called when module is disabled. @@ -241,7 +241,7 @@ class modApi extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function remove($options = '') + public function remove($options = '') { // Remove old constants with entity fields different of 0 $sql = array( diff --git a/htdocs/core/modules/modAsset.class.php b/htdocs/core/modules/modAsset.class.php index d7464c8ac0e..b162fabc559 100644 --- a/htdocs/core/modules/modAsset.class.php +++ b/htdocs/core/modules/modAsset.class.php @@ -313,22 +313,22 @@ class modAsset extends DolibarrModules } /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') - { - global $conf; + public function init($options = '') + { + global $conf; - // Permissions - $this->remove($options); + // Permissions + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 08dcd61351d..fb2c818043e 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -41,7 +41,7 @@ class modBanque extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -210,7 +210,7 @@ class modBanque extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modBarcode.class.php b/htdocs/core/modules/modBarcode.class.php index 7c4fcd78bf1..d3efcd1dbdd 100644 --- a/htdocs/core/modules/modBarcode.class.php +++ b/htdocs/core/modules/modBarcode.class.php @@ -39,7 +39,7 @@ class modBarcode extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 55; @@ -129,7 +129,7 @@ class modBarcode extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 0ed248f00ab..d9833e2978e 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -30,21 +30,21 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modBlockedLog extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $langs, $conf, $mysoc; + global $langs, $conf, $mysoc; $this->db = $db; $this->numero = 3200; // Key text used to identify module (for permissions, menus, etc...) $this->rights_class = 'blockedlog'; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "base"; // Module position in the family on 2 digits ('01', '10', '20', ...) $this->module_position = '75'; @@ -67,10 +67,10 @@ class modBlockedLog extends DolibarrModules // Dependancies //------------- - $this->hidden = false; // A condition to disable module - $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled + $this->hidden = false; // A condition to disable module + $this->depends = array('always'=>'modFacture'); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array('blockedlog'); $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) @@ -81,24 +81,24 @@ class modBlockedLog extends DolibarrModules // enable this module. /*if (! empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) { - $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); - $this->automatic_activation = array(); - foreach($tmp as $key) - { - $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; - } + $tmp=explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY); + $this->automatic_activation = array(); + foreach($tmp as $key) + { + $this->automatic_activation[$key]='BlockedLogActivatedBecauseRequiredByYourCountryLegislation'; + } }*/ //var_dump($this->automatic_activation); $this->always_enabled = (!empty($conf->blockedlog->enabled) - && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) - && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) - && $this->alreadyUsed(1)); + && !empty($conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY) + && in_array($mysoc->country_code, explode(',', $conf->global->BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY)) + && $this->alreadyUsed(1)); // Constants //----------- $this->const = array( - 1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0) + 1=>array('BLOCKEDLOG_DISABLE_NOT_ALLOWED_FOR_COUNTRY', 'chaine', 'FR', 'This is list of country code where the module may be mandatory', 0, 'current', 0) ); // New pages on tabs @@ -145,12 +145,11 @@ class modBlockedLog extends DolibarrModules * * @return boolean True if already used, otherwise False */ - function alreadyUsed() + public function alreadyUsed() { - - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $b=new BlockedLog($this->db); - return $b->alreadyUsed(1); + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + $b=new BlockedLog($this->db); + return $b->alreadyUsed(1); } @@ -162,89 +161,89 @@ class modBlockedLog extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { - global $conf, $user; + global $conf, $user; - $sql = array(); + $sql = array(); - // If already used, we add an entry to show we enable module - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + // If already used, we add an entry to show we enable module + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $object=new stdClass(); - $object->id = 1; - $object->element = 'module'; - $object->ref = 'systemevent'; - $object->entity = $conf->entity; - $object->date = dol_now(); + $object=new stdClass(); + $object->id = 1; + $object->element = 'module'; + $object->ref = 'systemevent'; + $object->entity = $conf->entity; + $object->date = dol_now(); - $b=new BlockedLog($this->db); - $result = $b->setObjectData($object, 'MODULE_SET', 0); - if ($result < 0) - { - $this->error = $b->error; - $this->errors = $b->erros; - return 0; - } + $b=new BlockedLog($this->db); + $result = $b->setObjectData($object, 'MODULE_SET', 0); + if ($result < 0) + { + $this->error = $b->error; + $this->errors = $b->erros; + return 0; + } - $res = $b->create($user); - if ($res<=0) { - $this->error = $b->error; - $this->errors = $b->errors; - return $res; - } + $res = $b->create($user); + if ($res<=0) { + $this->error = $b->error; + $this->errors = $b->errors; + return $res; + } - return $this->_init($sql, $options); + return $this->_init($sql, $options); } /** - * Function called when module is disabled. - * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function remove($options = '') + * Function called when module is disabled. + * The remove function removes tabs, constants, boxes, permissions and menus from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') { - global $conf, $user; + global $conf, $user; - $sql = array(); + $sql = array(); - // If already used, we add an entry to show we enable module - require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; + // If already used, we add an entry to show we enable module + require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; - $object=new stdClass(); - $object->id = 1; - $object->element = 'module'; - $object->ref = 'systemevent'; - $object->entity = $conf->entity; - $object->date = dol_now(); + $object=new stdClass(); + $object->id = 1; + $object->element = 'module'; + $object->ref = 'systemevent'; + $object->entity = $conf->entity; + $object->date = dol_now(); - $b=new BlockedLog($this->db); - $result = $b->setObjectData($object, 'MODULE_RESET', 0); - if ($result < 0) - { - $this->error = $b->error; - $this->errors = $b->erros; - return 0; - } + $b=new BlockedLog($this->db); + $result = $b->setObjectData($object, 'MODULE_RESET', 0); + if ($result < 0) + { + $this->error = $b->error; + $this->errors = $b->erros; + return 0; + } - if ($b->alreadyUsed(1)) - { - $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error - } - else - { - $res = $b->create($user); - } - if ($res<=0) { - $this->error = $b->error; - $this->errors = $b->errors; - return $res; - } + if ($b->alreadyUsed(1)) + { + $res = $b->create($user, '0000000000'); // If already used for something else than SET or UNSET, we log with error + } + else + { + $res = $b->create($user); + } + if ($res<=0) { + $this->error = $b->error; + $this->errors = $b->errors; + return $res; + } - return $this->_remove($sql, $options); + return $this->_remove($sql, $options); } } diff --git a/htdocs/core/modules/modBookmark.class.php b/htdocs/core/modules/modBookmark.class.php index 38da9a62059..0717236a1bb 100644 --- a/htdocs/core/modules/modBookmark.class.php +++ b/htdocs/core/modules/modBookmark.class.php @@ -38,7 +38,7 @@ class modBookmark extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 330; diff --git a/htdocs/core/modules/modCashDesk.class.php b/htdocs/core/modules/modCashDesk.class.php index ed1a4485152..68dda5a94f2 100644 --- a/htdocs/core/modules/modCashDesk.class.php +++ b/htdocs/core/modules/modCashDesk.class.php @@ -35,7 +35,7 @@ class modCashDesk extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -121,24 +121,24 @@ class modCashDesk extends DolibarrModules // 'target'=>'', // 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both // $r++; - } + } /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') - { - $sql = array(); + public function init($options = '') + { + $sql = array(); - // Remove permissions and default values - $this->remove($options); + // Remove permissions and default values + $this->remove($options); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modCategorie.class.php b/htdocs/core/modules/modCategorie.class.php index 82d0d9d8289..d8f8b6915f3 100644 --- a/htdocs/core/modules/modCategorie.class.php +++ b/htdocs/core/modules/modCategorie.class.php @@ -37,7 +37,7 @@ class modCategorie extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -483,7 +483,7 @@ class modCategorie extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modClickToDial.class.php b/htdocs/core/modules/modClickToDial.class.php index 6e8ad1d3041..a25b0fd4571 100644 --- a/htdocs/core/modules/modClickToDial.class.php +++ b/htdocs/core/modules/modClickToDial.class.php @@ -38,7 +38,7 @@ class modClickToDial extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 58; diff --git a/htdocs/core/modules/modCollab.class.php b/htdocs/core/modules/modCollab.class.php index 1e1db01f616..62de6a62b0c 100644 --- a/htdocs/core/modules/modCollab.class.php +++ b/htdocs/core/modules/modCollab.class.php @@ -32,33 +32,33 @@ class modCollab extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { - global $langs,$conf; + global $langs,$conf; $this->db = $db; $this->numero = 30000; - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page + // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' + // It is used to group modules in module setup page $this->family = "portal"; $this->module_position = '51'; // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i', '', get_class($this)); $this->description = "Enable the public collaboration features, like shared pad, shared online sheets, etc..."; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version + // Possible values for version are: 'development', 'experimental', 'dolibarr' or version $this->version = 'development'; // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Name of image file used for this module. $this->picto='globe'; - // Data directories to create when module is enabled - $this->dirs = array("/collab/temp"); + // Data directories to create when module is enabled + $this->dirs = array("/collab/temp"); // Config pages //------------- @@ -66,15 +66,15 @@ class modCollab extends DolibarrModules // Dependancies //------------- - $this->hidden = ! empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module - $this->depends = array(); // List of modules id that must be enabled if this module is enabled + $this->hidden = ! empty($conf->global->MODULE_COLLAB_DISABLED); // A condition to disable module + $this->depends = array(); // List of modules id that must be enabled if this module is enabled $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->conflictwith = array(); // List of modules id this module is in conflict with + $this->conflictwith = array(); // List of modules id this module is in conflict with $this->langfiles = array("collab"); // Constants //----------- - $this->const = array(); + $this->const = array(); // New pages on tabs // ----------------- @@ -84,42 +84,42 @@ class modCollab extends DolibarrModules //------ $this->boxes = array(); - // Permissions - $this->rights = array(); // Permission array used by this module - $this->rights_class = 'collab'; - $r=0; + // Permissions + $this->rights = array(); // Permission array used by this module + $this->rights_class = 'collab'; + $r=0; - /*$this->rights[$r][0] = 30001; - $this->rights[$r][1] = 'Read website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'read'; - $r++; + /*$this->rights[$r][0] = 30001; + $this->rights[$r][1] = 'Read website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'read'; + $r++; - $this->rights[$r][0] = 30002; - $this->rights[$r][1] = 'Create/modify website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'write'; - $r++; + $this->rights[$r][0] = 30002; + $this->rights[$r][1] = 'Create/modify website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'write'; + $r++; - $this->rights[$r][0] = 30003; - $this->rights[$r][1] = 'Delete website content'; - $this->rights[$r][3] = 0; - $this->rights[$r][4] = 'delete'; - $r++;*/ + $this->rights[$r][0] = 30003; + $this->rights[$r][1] = 'Delete website content'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'delete'; + $r++;*/ // Main menu entries $r=0; $this->menu[$r]=array( 'fk_menu'=>'0', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', // This is a Left menu entry - 'titre'=>'Collab', + 'type'=>'top', // This is a Left menu entry + 'titre'=>'Collab', 'mainmenu'=>'collab', - 'url'=>'/collab/index.php', - 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>100, - 'enabled'=>'$conf->collab->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + 'url'=>'/collab/index.php', + 'langs'=>'collab', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>100, + 'enabled'=>'$conf->collab->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both $r++; } } diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 63e2fe4bf88..025bbf0a50c 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -43,7 +43,7 @@ class modCommande extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -269,7 +269,7 @@ class modCommande extends DolibarrModules * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; @@ -299,6 +299,6 @@ class modCommande extends DolibarrModules "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','order',".$conf->entity.")" ); - return $this->_init($sql, $options); + return $this->_init($sql, $options); } } diff --git a/htdocs/core/modules/modComptabilite.class.php b/htdocs/core/modules/modComptabilite.class.php index 226292537f5..01692979c13 100644 --- a/htdocs/core/modules/modComptabilite.class.php +++ b/htdocs/core/modules/modComptabilite.class.php @@ -40,7 +40,7 @@ class modComptabilite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -101,16 +101,16 @@ class modComptabilite extends DolibarrModules } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { global $conf; // Nettoyage avant activation diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php index 8bcc645d3ba..b3053cceae0 100644 --- a/htdocs/core/modules/modContrat.class.php +++ b/htdocs/core/modules/modContrat.class.php @@ -39,7 +39,7 @@ class modContrat extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; @@ -212,7 +212,7 @@ class modContrat extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 31d27abac0b..f07ddeaeaae 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -37,7 +37,7 @@ class modCron extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs, $conf; diff --git a/htdocs/core/modules/modDataPolicy.class.php b/htdocs/core/modules/modDataPolicy.class.php index 5dfc0fb83dd..be88c709090 100644 --- a/htdocs/core/modules/modDataPolicy.class.php +++ b/htdocs/core/modules/modDataPolicy.class.php @@ -210,15 +210,15 @@ class modDataPolicy extends DolibarrModules { */ public function init($options = '') { - global $langs; + global $langs; - $this->_load_tables('/datapolicy/sql/'); + $this->_load_tables('/datapolicy/sql/'); // Create extrafields include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php'; $extrafields = new ExtraFields($this->db); - /* + /* // Extrafield contact $result1 = $extrafields->addExtraField('datapolicy_consentement', $langs->trans("DATAPOLICY_consentement"), 'boolean', 101, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); $result1 = $extrafields->addExtraField('datapolicy_opposition_traitement', $langs->trans("DATAPOLICY_opposition_traitement"), 'boolean', 102, 3, 'thirdparty', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); @@ -239,7 +239,7 @@ class modDataPolicy extends DolibarrModules { $result1 = $extrafields->addExtraField('datapolicy_opposition_prospection', $langs->trans("DATAPOLICY_opposition_prospection"), 'boolean', 103, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0, '', '', 'datapolicy@datapolicy', '$conf->datapolicy->enabled'); $result1 = $extrafields->addExtraField('datapolicy_date', $langs->trans("DATAPOLICY_date"), 'date', 104, 3, 'adherent', 0, 0, '', '', 1, '', '3', 0); $result1 = $extrafields->addExtraField('datapolicy_send', $langs->trans("DATAPOLICY_send"), 'date', 105, 3, 'adherent', 0, 0, '', '', 0, '', '0', 0); - */ + */ $sql = array(); diff --git a/htdocs/core/modules/modDeplacement.class.php b/htdocs/core/modules/modDeplacement.class.php index ce2a8056e48..61b725f1d8e 100644 --- a/htdocs/core/modules/modDeplacement.class.php +++ b/htdocs/core/modules/modDeplacement.class.php @@ -37,7 +37,7 @@ class modDeplacement extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -152,7 +152,7 @@ class modDeplacement extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modDocumentGeneration.class.php b/htdocs/core/modules/modDocumentGeneration.class.php index 455c28914da..8b1ad690efe 100644 --- a/htdocs/core/modules/modDocumentGeneration.class.php +++ b/htdocs/core/modules/modDocumentGeneration.class.php @@ -39,7 +39,7 @@ class modDocumentGeneration extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 1520; @@ -96,15 +96,15 @@ class modDocumentGeneration extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function init($options = '') - { + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { global $conf; // Permissions diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index bb27b309c1d..d196cdb1c0e 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -40,7 +40,7 @@ class modDon extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 700; @@ -151,7 +151,7 @@ class modDon extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modDynamicPrices.class.php b/htdocs/core/modules/modDynamicPrices.class.php index 6e915afc6f8..708f0fb86a7 100644 --- a/htdocs/core/modules/modDynamicPrices.class.php +++ b/htdocs/core/modules/modDynamicPrices.class.php @@ -36,7 +36,7 @@ class modDynamicPrices extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2200; diff --git a/htdocs/core/modules/modECM.class.php b/htdocs/core/modules/modECM.class.php index 602bc37a03c..0208541d2e2 100644 --- a/htdocs/core/modules/modECM.class.php +++ b/htdocs/core/modules/modECM.class.php @@ -37,7 +37,7 @@ class modECM extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index 443146d13a4..e096d840864 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -41,7 +41,7 @@ class modExpedition extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -308,14 +308,14 @@ class modExpedition extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modExpenseReport.class.php b/htdocs/core/modules/modExpenseReport.class.php index d715cb119ca..d6ef55fe646 100644 --- a/htdocs/core/modules/modExpenseReport.class.php +++ b/htdocs/core/modules/modExpenseReport.class.php @@ -36,7 +36,7 @@ class modExpenseReport extends DolibarrModules * * @param Database $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -203,14 +203,14 @@ class modExpenseReport extends DolibarrModules } /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories. + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories. * - * @param string $options Options - * @return int 1 if OK, 0 if KO + * @param string $options Options + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modExport.class.php b/htdocs/core/modules/modExport.class.php index b0d95137316..d636772caff 100644 --- a/htdocs/core/modules/modExport.class.php +++ b/htdocs/core/modules/modExport.class.php @@ -38,7 +38,7 @@ class modExport extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 240; diff --git a/htdocs/core/modules/modExternalRss.class.php b/htdocs/core/modules/modExternalRss.class.php index e384bccbcba..4e271b4573f 100644 --- a/htdocs/core/modules/modExternalRss.class.php +++ b/htdocs/core/modules/modExternalRss.class.php @@ -38,7 +38,7 @@ class modExternalRss extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -86,7 +86,7 @@ class modExternalRss extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; @@ -126,7 +126,7 @@ class modExternalRss extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function remove($options = '') + public function remove($options = '') { $sql = array(); diff --git a/htdocs/core/modules/modExternalSite.class.php b/htdocs/core/modules/modExternalSite.class.php index 0a720579eda..6cbd7141af8 100644 --- a/htdocs/core/modules/modExternalSite.class.php +++ b/htdocs/core/modules/modExternalSite.class.php @@ -39,7 +39,7 @@ class modExternalSite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modFTP.class.php b/htdocs/core/modules/modFTP.class.php index a54cbc24963..699617cd99e 100644 --- a/htdocs/core/modules/modFTP.class.php +++ b/htdocs/core/modules/modFTP.class.php @@ -33,12 +33,12 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modFTP extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index c8e29205306..106de48e96d 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -40,7 +40,7 @@ class modFacture extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -347,14 +347,14 @@ class modFacture extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf, $langs; diff --git a/htdocs/core/modules/modFckeditor.class.php b/htdocs/core/modules/modFckeditor.class.php index 873aba7eb30..7085fbef000 100644 --- a/htdocs/core/modules/modFckeditor.class.php +++ b/htdocs/core/modules/modFckeditor.class.php @@ -39,7 +39,7 @@ class modFckeditor extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2000; diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php index de2d40490c0..8267000297b 100644 --- a/htdocs/core/modules/modFicheinter.class.php +++ b/htdocs/core/modules/modFicheinter.class.php @@ -42,7 +42,7 @@ class modFicheinter extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -201,14 +201,14 @@ class modFicheinter extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 3510834a836..12193b630c8 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -39,7 +39,7 @@ class modFournisseur extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -61,12 +61,13 @@ class modFournisseur extends DolibarrModules $this->picto='company'; // Data directories to create when module is enabled - $this->dirs = array("/fournisseur/temp", - "/fournisseur/commande", - "/fournisseur/commande/temp", - "/fournisseur/facture", - "/fournisseur/facture/temp" - ); + $this->dirs = array( + "/fournisseur/temp", + "/fournisseur/commande", + "/fournisseur/commande/temp", + "/fournisseur/facture", + "/fournisseur/facture/temp" + ); // Dependencies $this->depends = array("modSociete"); @@ -622,7 +623,7 @@ class modFournisseur extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modGeoIPMaxmind.class.php b/htdocs/core/modules/modGeoIPMaxmind.class.php index 0b090abfa80..91c82e713db 100644 --- a/htdocs/core/modules/modGeoIPMaxmind.class.php +++ b/htdocs/core/modules/modGeoIPMaxmind.class.php @@ -37,7 +37,7 @@ class modGeoIPMaxmind extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2900; diff --git a/htdocs/core/modules/modGravatar.class.php b/htdocs/core/modules/modGravatar.class.php index 9dbf4ee124f..bfff235bdae 100644 --- a/htdocs/core/modules/modGravatar.class.php +++ b/htdocs/core/modules/modGravatar.class.php @@ -36,7 +36,7 @@ class modGravatar extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php index 68aad4e3533..ea4ff52f473 100644 --- a/htdocs/core/modules/modHRM.class.php +++ b/htdocs/core/modules/modHRM.class.php @@ -131,7 +131,7 @@ class modHRM extends DolibarrModules * @param string $options Enabling module ('', 'noboxes') * @return int if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 01a70a429ad..09a30e16914 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -41,7 +41,7 @@ class modHoliday extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modIFTTT.class.php b/htdocs/core/modules/modIFTTT.class.php index 55739978715..c3bab06ed93 100644 --- a/htdocs/core/modules/modIFTTT.class.php +++ b/htdocs/core/modules/modIFTTT.class.php @@ -31,12 +31,12 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; class modIFTTT extends DolibarrModules { /** - * Constructor. Define names, constants, directories, boxes, permissions + * Constructor. Define names, constants, directories, boxes, permissions * - * @param DoliDB $db Database handler - */ - function __construct($db) - { + * @param DoliDB $db Database handler + */ + public function __construct($db) + { global $langs,$conf; $this->db = $db; @@ -116,12 +116,12 @@ class modIFTTT extends DolibarrModules $this->tabs = array(); // Dictionaries - if (! isset($conf->ifttt->enabled)) + if (! isset($conf->ifttt->enabled)) { $conf->ifttt=new stdClass(); $conf->ifttt->enabled=0; } - $this->dictionaries=array(); + $this->dictionaries=array(); // Boxes // Add here list of php file(s) stored in core/boxes that contains class to show a box. @@ -214,14 +214,14 @@ class modIFTTT extends DolibarrModules } /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { $sql = array(); @@ -230,22 +230,22 @@ class modIFTTT extends DolibarrModules return $this->_init($sql, $options); } - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted. - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function remove($options = '') - { - // Remove old constants with entity fields different of 0 - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('MAIN_MODULE_IFTTT', 1), - "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('IFTTT_PRODUCTION_MODE', 1) - ); + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted. + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + // Remove old constants with entity fields different of 0 + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('MAIN_MODULE_IFTTT', 1), + "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = ".$this->db->encrypt('IFTTT_PRODUCTION_MODE', 1) + ); - return $this->_remove($sql, $options); - } + return $this->_remove($sql, $options); + } } diff --git a/htdocs/core/modules/modImport.class.php b/htdocs/core/modules/modImport.class.php index e7d47763013..2f5c8c77db8 100644 --- a/htdocs/core/modules/modImport.class.php +++ b/htdocs/core/modules/modImport.class.php @@ -38,7 +38,7 @@ class modImport extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 250; diff --git a/htdocs/core/modules/modIncoterm.class.php b/htdocs/core/modules/modIncoterm.class.php index 9d07028c5dd..8cae0980ff7 100644 --- a/htdocs/core/modules/modIncoterm.class.php +++ b/htdocs/core/modules/modIncoterm.class.php @@ -38,8 +38,8 @@ class modIncoterm extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $langs,$conf; $this->db = $db; diff --git a/htdocs/core/modules/modLabel.class.php b/htdocs/core/modules/modLabel.class.php index c0f02229f2b..fefc7117b10 100644 --- a/htdocs/core/modules/modLabel.class.php +++ b/htdocs/core/modules/modLabel.class.php @@ -38,7 +38,7 @@ class modLabel extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 60; @@ -100,13 +100,13 @@ class modLabel extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { // Permissions $this->remove($options); $sql = array(); return $this->_init($sql, $options); - } + } } diff --git a/htdocs/core/modules/modLdap.class.php b/htdocs/core/modules/modLdap.class.php index a2a355060d1..b2a290fe46a 100644 --- a/htdocs/core/modules/modLdap.class.php +++ b/htdocs/core/modules/modLdap.class.php @@ -37,7 +37,7 @@ class modLdap extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 200; diff --git a/htdocs/core/modules/modLoan.class.php b/htdocs/core/modules/modLoan.class.php index 43a2876ef79..e4d1a048c6f 100644 --- a/htdocs/core/modules/modLoan.class.php +++ b/htdocs/core/modules/modLoan.class.php @@ -37,7 +37,7 @@ class modLoan extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -149,14 +149,14 @@ class modLoan extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php index bbcd651d453..36893ddfa13 100644 --- a/htdocs/core/modules/modMailing.class.php +++ b/htdocs/core/modules/modMailing.class.php @@ -39,7 +39,7 @@ class modMailing extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 22; @@ -142,14 +142,14 @@ class modMailing extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modMailmanSpip.class.php b/htdocs/core/modules/modMailmanSpip.class.php index 2c4123fc3fa..ecae27155b5 100644 --- a/htdocs/core/modules/modMailmanSpip.class.php +++ b/htdocs/core/modules/modMailmanSpip.class.php @@ -38,7 +38,7 @@ class modMailmanSpip extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 105; diff --git a/htdocs/core/modules/modMargin.class.php b/htdocs/core/modules/modMargin.class.php index 22124404673..f5b79570c1a 100644 --- a/htdocs/core/modules/modMargin.class.php +++ b/htdocs/core/modules/modMargin.class.php @@ -35,7 +35,7 @@ class modMargin extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modModuleBuilder.class.php b/htdocs/core/modules/modModuleBuilder.class.php index 94d307ae522..59b3dcde2ce 100644 --- a/htdocs/core/modules/modModuleBuilder.class.php +++ b/htdocs/core/modules/modModuleBuilder.class.php @@ -35,7 +35,7 @@ class modModuleBuilder extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php index 32bd1bd5980..e3f37c5f284 100644 --- a/htdocs/core/modules/modMultiCurrency.class.php +++ b/htdocs/core/modules/modMultiCurrency.class.php @@ -38,8 +38,8 @@ class modMultiCurrency extends DolibarrModules * * @param DoliDB $db Database handler */ - public function __construct($db) - { + public function __construct($db) + { global $langs, $conf; $this->db = $db; diff --git a/htdocs/core/modules/modNotification.class.php b/htdocs/core/modules/modNotification.class.php index 54698dca703..c73c8210072 100644 --- a/htdocs/core/modules/modNotification.class.php +++ b/htdocs/core/modules/modNotification.class.php @@ -36,7 +36,7 @@ class modNotification extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 600; @@ -89,7 +89,7 @@ class modNotification extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/modOauth.class.php b/htdocs/core/modules/modOauth.class.php index 27310e9c84e..f4f52eae80a 100644 --- a/htdocs/core/modules/modOauth.class.php +++ b/htdocs/core/modules/modOauth.class.php @@ -40,7 +40,7 @@ class modOauth extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 66000; @@ -130,7 +130,7 @@ class modOauth extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modOpenSurvey.class.php b/htdocs/core/modules/modOpenSurvey.class.php index a47a2791b60..be2e9b6e449 100644 --- a/htdocs/core/modules/modOpenSurvey.class.php +++ b/htdocs/core/modules/modOpenSurvey.class.php @@ -37,8 +37,8 @@ class modOpenSurvey extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $langs,$conf; $this->db = $db; @@ -119,51 +119,57 @@ class modOpenSurvey extends DolibarrModules $r++; - // Menus - //------- + // Menus + //------- $r=0; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'Survey', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey', - 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', - 'langs'=>'opensurvey', - 'position'=>200, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->read', - 'target'=>'', - 'user'=>0); - $r++; + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=tools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'Survey', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey', + 'url'=>'/opensurvey/index.php?mainmenu=tools&leftmenu=opensurvey', + 'langs'=>'opensurvey', + 'position'=>200, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->read', + 'target'=>'', + 'user'=>0, + ); + $r++; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'NewSurvey', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey_new', - 'url'=>'/opensurvey/wizard/index.php', - 'langs'=>'opensurvey', - 'position'=>210, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->write', - 'target'=>'', - 'user'=>0); - $r++; + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'NewSurvey', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey_new', + 'url'=>'/opensurvey/wizard/index.php', + 'langs'=>'opensurvey', + 'position'=>210, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->write', + 'target'=>'', + 'user'=>0, + ); + $r++; - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', - 'titre'=>'List', - 'mainmenu'=>'tools', - 'leftmenu'=>'opensurvey_list', - 'url'=>'/opensurvey/list.php', - 'langs'=>'opensurvey', - 'position'=>220, - 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. - 'perms'=>'$user->rights->opensurvey->read', - 'target'=>'', - 'user'=>0); - $r++; - } + $this->menu[$r]=array( + 'fk_menu'=>'fk_mainmenu=tools,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', + 'titre'=>'List', + 'mainmenu'=>'tools', + 'leftmenu'=>'opensurvey_list', + 'url'=>'/opensurvey/list.php', + 'langs'=>'opensurvey', + 'position'=>220, + 'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled. + 'perms'=>'$user->rights->opensurvey->read', + 'target'=>'', + 'user'=>0, + ); + $r++; + } /** * Function called when module is enabled. @@ -173,13 +179,13 @@ class modOpenSurvey extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { - // Permissions - $this->remove($options); + public function init($options = '') + { + // Permissions + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modPaybox.class.php b/htdocs/core/modules/modPaybox.class.php index 6349d5474b3..635c428f3fa 100644 --- a/htdocs/core/modules/modPaybox.class.php +++ b/htdocs/core/modules/modPaybox.class.php @@ -36,7 +36,7 @@ class modPayBox extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modPaypal.class.php b/htdocs/core/modules/modPaypal.class.php index a4aa8fcc6b0..99ef4dd45de 100644 --- a/htdocs/core/modules/modPaypal.class.php +++ b/htdocs/core/modules/modPaypal.class.php @@ -37,7 +37,7 @@ class modPaypal extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modPrelevement.class.php b/htdocs/core/modules/modPrelevement.class.php index f18bf1bf03c..ec4c4ca3a46 100644 --- a/htdocs/core/modules/modPrelevement.class.php +++ b/htdocs/core/modules/modPrelevement.class.php @@ -40,7 +40,7 @@ class modPrelevement extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -124,40 +124,41 @@ class modPrelevement extends DolibarrModules $this->rights[$r][4] = 'bons'; $this->rights[$r][5] = 'credit'; -/* $this->rights[2][0] = 154; + /* + $this->rights[2][0] = 154; $this->rights[2][1] = 'Setup withdraw account'; $this->rights[2][2] = 'w'; $this->rights[2][3] = 0; $this->rights[2][4] = 'bons'; $this->rights[2][5] = 'configurer'; -*/ + */ - // Menus - //------- - $this->menu = 1; // This module add menu entries. They are coded into menu manager. - } + // Menus + //------- + $this->menu = 1; // This module add menu entries. They are coded into menu manager. + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function init($options = '') - { - global $conf; + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + global $conf; - // Permissions - $this->remove($options); + // Permissions + $this->remove($options); - $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")", - ); + $sql = array( + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'bankaccount' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','bankaccount',".$conf->entity.")", + ); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modPrinting.class.php b/htdocs/core/modules/modPrinting.class.php index bb8a2be6120..09992bd176d 100644 --- a/htdocs/core/modules/modPrinting.class.php +++ b/htdocs/core/modules/modPrinting.class.php @@ -40,7 +40,7 @@ class modPrinting extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 64000; diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index 4c6c420aa50..368a41a6fac 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -42,7 +42,7 @@ class modProduct extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $mysoc; @@ -521,7 +521,7 @@ class modProduct extends DolibarrModules if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type')); -$this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( + $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array( 'sp.price'=>"PriceQtyMinHT*", 'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty 'sp.remise_percent'=>'DiscountQtyMin' @@ -625,20 +625,20 @@ $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - function init($options = '') - { - $this->remove($options); + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $this->remove($options); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } } diff --git a/htdocs/core/modules/modProductBatch.class.php b/htdocs/core/modules/modProductBatch.class.php index f5e8fc6324c..65cefa6676a 100644 --- a/htdocs/core/modules/modProductBatch.class.php +++ b/htdocs/core/modules/modProductBatch.class.php @@ -38,7 +38,7 @@ class modProductBatch extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; @@ -114,7 +114,7 @@ class modProductBatch extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $db,$conf; diff --git a/htdocs/core/modules/modProjet.class.php b/htdocs/core/modules/modProjet.class.php index eeca1e8883f..f100e8629e7 100644 --- a/htdocs/core/modules/modProjet.class.php +++ b/htdocs/core/modules/modProjet.class.php @@ -41,7 +41,7 @@ class modProjet extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -310,7 +310,7 @@ class modProjet extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index a2a32241065..b28477f3719 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -41,7 +41,7 @@ class modPropale extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -265,7 +265,7 @@ class modPropale extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modReceiptPrinter.class.php b/htdocs/core/modules/modReceiptPrinter.class.php index 6d00acb2d16..2694b852b7a 100644 --- a/htdocs/core/modules/modReceiptPrinter.class.php +++ b/htdocs/core/modules/modReceiptPrinter.class.php @@ -40,7 +40,7 @@ class modReceiptPrinter extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db ; $this->numero = 67000; @@ -130,7 +130,7 @@ class modReceiptPrinter extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; // Clean before activation diff --git a/htdocs/core/modules/modReception.class.php b/htdocs/core/modules/modReception.class.php index 663a854f7a5..9fc82dc9ad6 100644 --- a/htdocs/core/modules/modReception.class.php +++ b/htdocs/core/modules/modReception.class.php @@ -36,7 +36,7 @@ class modReception extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -243,7 +243,7 @@ class modReception extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modSalaries.class.php b/htdocs/core/modules/modSalaries.class.php index 4756f2a1a41..e111e81ef6b 100644 --- a/htdocs/core/modules/modSalaries.class.php +++ b/htdocs/core/modules/modSalaries.class.php @@ -43,7 +43,7 @@ class modSalaries extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -159,14 +159,14 @@ class modSalaries extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modService.class.php b/htdocs/core/modules/modService.class.php index 2e3ed91bf06..9efab10ca9f 100644 --- a/htdocs/core/modules/modService.class.php +++ b/htdocs/core/modules/modService.class.php @@ -40,7 +40,7 @@ class modService extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $mysoc; @@ -363,7 +363,7 @@ class modService extends DolibarrModules * @param string $options Options when enabling module ('', 'newboxdefonly', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { $this->remove($options); diff --git a/htdocs/core/modules/modSocialNetworks.class.php b/htdocs/core/modules/modSocialNetworks.class.php index b7e1bfd44a3..d8d8d8fb76e 100644 --- a/htdocs/core/modules/modSocialNetworks.class.php +++ b/htdocs/core/modules/modSocialNetworks.class.php @@ -36,7 +36,7 @@ class modSocialNetworks extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index b879959946d..32b3b4b97fc 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -41,7 +41,7 @@ class modSociete extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $user; @@ -720,15 +720,15 @@ class modSociete extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { global $conf, $langs; // We disable this to prevent pb of modules not correctly disabled diff --git a/htdocs/core/modules/modStock.class.php b/htdocs/core/modules/modStock.class.php index fa283c58137..230d9dd5fbe 100644 --- a/htdocs/core/modules/modStock.class.php +++ b/htdocs/core/modules/modStock.class.php @@ -40,7 +40,7 @@ class modStock extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs; @@ -351,14 +351,14 @@ class modStock extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modStripe.class.php b/htdocs/core/modules/modStripe.class.php index a2b2a68127a..ae15e763fd8 100644 --- a/htdocs/core/modules/modStripe.class.php +++ b/htdocs/core/modules/modStripe.class.php @@ -36,7 +36,7 @@ class modStripe extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; diff --git a/htdocs/core/modules/modSupplierProposal.class.php b/htdocs/core/modules/modSupplierProposal.class.php index 3d580fa439c..882b02b5fb4 100644 --- a/htdocs/core/modules/modSupplierProposal.class.php +++ b/htdocs/core/modules/modSupplierProposal.class.php @@ -42,7 +42,7 @@ class modSupplierProposal extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -57,10 +57,10 @@ class modSupplierProposal extends DolibarrModules $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->picto='supplier_proposal'; - + // Data directories to create when module is enabled. $this->dirs = array(); - + // Config pages. Put here list of php page names stored in admin directory used to setup module. $this->config_page_url = array("supplier_proposal.php"); @@ -206,7 +206,7 @@ class modSupplierProposal extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modSyslog.class.php b/htdocs/core/modules/modSyslog.class.php index a291b7977ee..1ac6ead1087 100644 --- a/htdocs/core/modules/modSyslog.class.php +++ b/htdocs/core/modules/modSyslog.class.php @@ -37,7 +37,7 @@ class modSyslog extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 42; diff --git a/htdocs/core/modules/modTax.class.php b/htdocs/core/modules/modTax.class.php index a2f51ef0cc1..c113f9a339a 100644 --- a/htdocs/core/modules/modTax.class.php +++ b/htdocs/core/modules/modTax.class.php @@ -41,7 +41,7 @@ class modTax extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -185,7 +185,7 @@ class modTax extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf; diff --git a/htdocs/core/modules/modUser.class.php b/htdocs/core/modules/modUser.class.php index bef84b3a157..baf7f94d0f4 100644 --- a/htdocs/core/modules/modUser.class.php +++ b/htdocs/core/modules/modUser.class.php @@ -38,7 +38,7 @@ class modUser extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -331,8 +331,8 @@ class modUser extends DolibarrModules * @param string $options Options when enabling module ('', 'noboxes') * @return int 1 if OK, 0 if KO */ - function init($options = '') - { + public function init($options = '') + { global $conf; // Permissions @@ -341,5 +341,5 @@ class modUser extends DolibarrModules $sql = array(); return $this->_init($sql, $options); - } + } } diff --git a/htdocs/core/modules/modWebServices.class.php b/htdocs/core/modules/modWebServices.class.php index 9d32b03df79..2aa98e80679 100644 --- a/htdocs/core/modules/modWebServices.class.php +++ b/htdocs/core/modules/modWebServices.class.php @@ -35,7 +35,7 @@ class modWebServices extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2600; diff --git a/htdocs/core/modules/modWebServicesClient.class.php b/htdocs/core/modules/modWebServicesClient.class.php index 6ec7bb5aae9..33c7bae997a 100644 --- a/htdocs/core/modules/modWebServicesClient.class.php +++ b/htdocs/core/modules/modWebServicesClient.class.php @@ -35,7 +35,7 @@ class modWebServicesClient extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->numero = 2660; diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index 4fd6cd2976f..6f882f082ad 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -36,7 +36,7 @@ class modWebsite extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; @@ -138,14 +138,14 @@ class modWebsite extends DolibarrModules /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { global $conf,$langs; diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php index 955165ffd80..7d2e833a4fc 100644 --- a/htdocs/core/modules/modWorkflow.class.php +++ b/htdocs/core/modules/modWorkflow.class.php @@ -37,7 +37,7 @@ class modWorkflow extends DolibarrModules * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -137,9 +137,9 @@ class modWorkflow extends DolibarrModules * It also creates data directories * * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO + * @return int 1 if OK, 0 if KO */ - function init($options = '') + public function init($options = '') { // Permissions $this->remove($options); diff --git a/htdocs/core/modules/payment/mod_payment_ant.php b/htdocs/core/modules/payment/mod_payment_ant.php index 42f7b0c8be0..19e74cf3c19 100644 --- a/htdocs/core/modules/payment/mod_payment_ant.php +++ b/htdocs/core/modules/payment/mod_payment_ant.php @@ -59,7 +59,7 @@ class mod_payment_ant extends ModeleNumRefPayments * * @return string Texte descripif */ - function info() + public function info() { global $db, $conf, $langs; @@ -99,7 +99,7 @@ class mod_payment_ant extends ModeleNumRefPayments * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -122,7 +122,7 @@ class mod_payment_ant extends ModeleNumRefPayments * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -143,7 +143,7 @@ class mod_payment_ant extends ModeleNumRefPayments } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -151,7 +151,7 @@ class mod_payment_ant extends ModeleNumRefPayments * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/payment/mod_payment_cicada.php b/htdocs/core/modules/payment/mod_payment_cicada.php index c8c850affda..a6cfca7e1df 100644 --- a/htdocs/core/modules/payment/mod_payment_cicada.php +++ b/htdocs/core/modules/payment/mod_payment_cicada.php @@ -60,7 +60,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,7 +72,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -155,7 +155,7 @@ class mod_payment_cicada extends ModeleNumRefPayments } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -163,7 +163,7 @@ class mod_payment_cicada extends ModeleNumRefPayments * @param string $objforref Object for number to search * @return string Next free value */ - function payment_get_num($objsoc, $objforref) + public function payment_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/payment/modules_payment.php b/htdocs/core/modules/payment/modules_payment.php index 0773204a1c8..b85c97008e3 100644 --- a/htdocs/core/modules/payment/modules_payment.php +++ b/htdocs/core/modules/payment/modules_payment.php @@ -33,7 +33,7 @@ abstract class ModeleNumRefPayments * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -43,7 +43,7 @@ abstract class ModeleNumRefPayments * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -55,7 +55,7 @@ abstract class ModeleNumRefPayments * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -67,7 +67,7 @@ abstract class ModeleNumRefPayments * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -79,7 +79,7 @@ abstract class ModeleNumRefPayments * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -90,15 +90,15 @@ abstract class ModeleNumRefPayments * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); } } diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index f4c10aa5952..3bbf1c879ea 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -47,7 +47,7 @@ class PrintingDriver * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -59,7 +59,7 @@ class PrintingDriver * @param integer $maxfilenamelength Max length of value to show * @return array List of drivers */ - static function listDrivers($db, $maxfilenamelength = 0) + public static function listDrivers($db, $maxfilenamelength = 0) { global $conf; @@ -80,7 +80,7 @@ class PrintingDriver * * @return string Return translation of key PrintingModuleDescXXX where XXX is module name, or $this->desc if not exists */ - function getDesc() + public function getDesc() { global $langs; $langs->load("printing"); diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php index d061fc33b7d..b8bccf0280b 100644 --- a/htdocs/core/modules/printing/printgcp.modules.php +++ b/htdocs/core/modules/printing/printgcp.modules.php @@ -70,7 +70,7 @@ class printing_printgcp extends PrintingDriver * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $dolibarr_main_url_root; @@ -89,47 +89,47 @@ class printing_printgcp extends PrintingDriver ); } else { - $this->google_id = $conf->global->OAUTH_GOOGLE_ID; - $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; - // Token storage - $storage = new DoliStorage($this->db, $this->conf); - //$storage->clearToken($this->OAUTH_SERVICENAME_GOOGLE); - // Setup the credentials for the requests + $this->google_id = $conf->global->OAUTH_GOOGLE_ID; + $this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET; + // Token storage + $storage = new DoliStorage($this->db, $this->conf); + //$storage->clearToken($this->OAUTH_SERVICENAME_GOOGLE); + // Setup the credentials for the requests $credentials = new Credentials( - $this->google_id, - $this->google_secret, - $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' - ); - $access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?'HasAccessToken':'NoAccessToken'); - $serviceFactory = new \OAuth\ServiceFactory(); - $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); - $token_ok=true; - try { - $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - $token_ok = false; - } - //var_dump($this->errors);exit; + $this->google_id, + $this->google_secret, + $urlwithroot.'/core/modules/oauth/google_oauthcallback.php' + ); + $access = ($storage->hasAccessToken($this->OAUTH_SERVICENAME_GOOGLE)?'HasAccessToken':'NoAccessToken'); + $serviceFactory = new \OAuth\ServiceFactory(); + $apiService = $serviceFactory->createService($this->OAUTH_SERVICENAME_GOOGLE, $credentials, $storage, array()); + $token_ok=true; + try { + $token = $storage->retrieveAccessToken($this->OAUTH_SERVICENAME_GOOGLE); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + $token_ok = false; + } + //var_dump($this->errors);exit; - $expire = false; - // Is token expired or will token expire in the next 30 seconds - if ($token_ok) { - $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); - } + $expire = false; + // Is token expired or will token expire in the next 30 seconds + if ($token_ok) { + $expire = ($token->getEndOfLife() !== -9002 && $token->getEndOfLife() !== -9001 && time() > ($token->getEndOfLife() - 30)); + } - // Token expired so we refresh it - if ($token_ok && $expire) { - try { - // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois - $refreshtoken = $token->getRefreshToken(); - $token = $apiService->refreshAccessToken($token); - $token->setRefreshToken($refreshtoken); - $storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token); - } catch (Exception $e) { - $this->errors[] = $e->getMessage(); - } - } + // Token expired so we refresh it + if ($token_ok && $expire) { + try { + // il faut sauvegarder le refresh token car google ne le donne qu'une seule fois + $refreshtoken = $token->getRefreshToken(); + $token = $apiService->refreshAccessToken($token); + $token->setRefreshToken($refreshtoken); + $storage->storeAccessToken($this->OAUTH_SERVICENAME_GOOGLE, $token); + } catch (Exception $e) { + $this->errors[] = $e->getMessage(); + } + } if ($this->google_id != '' && $this->google_secret != '') { $this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info'); $this->conf[] = array( diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index af650b1695e..f5ebbdd53de 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -62,7 +62,7 @@ class printing_printipp extends PrintingDriver * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -152,7 +152,7 @@ class printing_printipp extends PrintingDriver * * @return int 0 if OK, >0 if KO */ - function listAvailablePrinters() + public function listAvailablePrinters() { global $conf, $langs; $error = 0; diff --git a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php index fab88a91bfd..e178d16d5bc 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_standardlabel.class.php @@ -41,12 +41,12 @@ class pdf_standardlabel extends CommonStickerGenerator * @param array $param Associative array containing label content and optional parameters * @return void */ - function addSticker(&$pdf, $outputlangs, $param) + public function addSticker(&$pdf, $outputlangs, $param) { // use this method in future refactoring } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a sticker on page at position _COUNTX, _COUNTY (_COUNTX and _COUNTY start from 0) * - %LOGO% is replace with company logo @@ -61,7 +61,7 @@ class pdf_standardlabel extends CommonStickerGenerator * @param string $photo Photo (full path to image file used as replacement for key %PHOTOS% into left, right, header or footer text) * @return void */ - function Add_PDF_label(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $photo = '') + public function Add_PDF_label(&$pdf, $textleft, $header, $footer, $outputlangs, $textright = '', $photo = '') { // phpcs:enable global $mysoc, $conf, $langs; @@ -227,7 +227,7 @@ class pdf_standardlabel extends CommonStickerGenerator - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP strem. * @@ -238,7 +238,7 @@ class pdf_standardlabel extends CommonStickerGenerator * @param string $filename Short file name of PDF output file * @return int 1=OK, 0=KO */ - function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf') + public function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf') { // phpcs:enable global $user,$conf,$langs,$mysoc,$_Avery_Labels; diff --git a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php index f6641d1365d..7670a623c49 100644 --- a/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php +++ b/htdocs/core/modules/printsheet/doc/pdf_tcpdflabel.class.php @@ -96,7 +96,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator * @param array $param Associative array containing label content and optional parameters * @return void */ - function addSticker(&$pdf, $outputlangs, $param) + public function addSticker(&$pdf, $outputlangs, $param) { global $mysoc,$conf; @@ -266,7 +266,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build PDF on disk, then output on HTTP strem. * @@ -277,7 +277,7 @@ class pdf_tcpdflabel extends CommonStickerGenerator * @param string $filename Short file name of PDF output file * @return int 1=OK, 0=KO */ - function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf') + public function write_file($arrayofrecords, $outputlangs, $srctemplatepath, $outputdir = '', $filename = 'tmp_address_sheet.pdf') { // phpcs:enable global $user,$conf,$langs,$mysoc,$_Avery_Labels; diff --git a/htdocs/core/modules/printsheet/modules_labels.php b/htdocs/core/modules/printsheet/modules_labels.php index b64d2a4dfe3..7377c56aa3b 100644 --- a/htdocs/core/modules/printsheet/modules_labels.php +++ b/htdocs/core/modules/printsheet/modules_labels.php @@ -40,7 +40,7 @@ class ModelePDFLabels public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -48,7 +48,7 @@ class ModelePDFLabels * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - function liste_modeles($db, $maxfilenamelength = 0) + public function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; 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 048c0e06846..edb54b13ace 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 @@ -61,7 +61,7 @@ class doc_generic_product_odt extends ModelePDFProduct * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -101,12 +101,12 @@ class doc_generic_product_odt extends ModelePDFProduct /** - * Return description of a module + * Return description of a module * - * @param Translate $langs Lang object to use for output - * @return string Description + * @param Translate $langs Lang object to use for output + * @return string Description */ - function info($langs) + public function info($langs) { global $conf, $langs; @@ -205,7 +205,7 @@ class doc_generic_product_odt extends ModelePDFProduct return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -217,7 +217,7 @@ class doc_generic_product_odt extends ModelePDFProduct * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $product,$langs,$conf,$mysoc,$hookmanager,$user; @@ -320,8 +320,8 @@ class doc_generic_product_odt extends ModelePDFProduct $contactobject=null; if (! empty($usecontact)) { - // On peut utiliser le nom de la societe du contact - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + // On peut utiliser le nom de la societe du contact + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $socobject = $object->contact; } else { $socobject = $object->thirdparty; diff --git a/htdocs/core/modules/product/doc/pdf_standard.modules.php b/htdocs/core/modules/product/doc/pdf_standard.modules.php index d5bfd453322..b8b05410fb1 100644 --- a/htdocs/core/modules/product/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/product/doc/pdf_standard.modules.php @@ -148,7 +148,7 @@ class pdf_standard extends ModelePDFProduct } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -160,8 +160,8 @@ class pdf_standard extends ModelePDFProduct * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager; @@ -204,7 +204,7 @@ class pdf_standard extends ModelePDFProduct if (file_exists($dir)) { - // Add pdfgeneration hook + // Add pdfgeneration hook if (! is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; @@ -592,7 +592,7 @@ class pdf_standard extends ModelePDFProduct $this->error=$langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR"); return 0; } - } + } /** @@ -608,7 +608,7 @@ class pdf_standard extends ModelePDFProduct * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -718,7 +718,7 @@ class pdf_standard extends ModelePDFProduct * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") { global $conf,$langs,$hookmanager; @@ -853,24 +853,24 @@ class pdf_standard extends ModelePDFProduct $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); */ - } + } - $pdf->SetTextColor(0, 0, 0); - } + $pdf->SetTextColor(0, 0, 0); + } - /** - * Show footer of page. Need this->emetteur object - * - * @param TCPDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text - */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) - { - global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } + /** + * Show footer of page. Need this->emetteur object + * + * @param TCPDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } } diff --git a/htdocs/core/modules/product/mod_codeproduct_elephant.php b/htdocs/core/modules/product/mod_codeproduct_elephant.php index 8d48d4aa85e..97a00a14575 100644 --- a/htdocs/core/modules/product/mod_codeproduct_elephant.php +++ b/htdocs/core/modules/product/mod_codeproduct_elephant.php @@ -72,7 +72,7 @@ class mod_codeproduct_elephant extends ModeleProductCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 0; $this->code_modifiable = 1; @@ -83,13 +83,14 @@ class mod_codeproduct_elephant extends ModeleProductCode } - /** Return description of module - * - * @param Translate $langs Object langs - * @return string Description of module - */ - function info($langs) - { + /** + * Return description of module + * + * @param Translate $langs Object langs + * @return string Description of module + */ + public function info($langs) + { global $conf, $mc; global $form; @@ -127,7 +128,7 @@ class mod_codeproduct_elephant extends ModeleProductCode $texte.= ''; return $texte; - } + } /** @@ -138,7 +139,7 @@ class mod_codeproduct_elephant extends ModeleProductCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - function getExample($langs, $objproduct = 0, $type = -1) + public function getExample($langs, $objproduct = 0, $type = -1) { if ($type == 0 || $type == -1) { @@ -179,7 +180,7 @@ class mod_codeproduct_elephant extends ModeleProductCode * @param int $type Produit ou service (0:product, 1:service) * @return string Value if OK, '' if module not configured, <0 if KO */ - function getNextValue($objproduct = 0, $type = -1) + public function getNextValue($objproduct = 0, $type = -1) { global $db,$conf; @@ -219,13 +220,13 @@ class mod_codeproduct_elephant extends ModeleProductCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if mask/numbering use prefix * * @return int 0 or 1 */ - function verif_prefixIsUsed() + public function verif_prefixIsUsed() { // phpcs:enable global $conf; @@ -254,7 +255,7 @@ class mod_codeproduct_elephant extends ModeleProductCode * -4 ErrorPrefixRequired * -5 Other (see this->error) */ - function verif($db, &$code, $product, $type) + public function verif($db, &$code, $product, $type) { global $conf; @@ -296,16 +297,16 @@ class mod_codeproduct_elephant extends ModeleProductCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi si un code est pris ou non (par autre tiers) + * Renvoi si un code est pris ou non (par autre tiers) * - * @param DoliDB $db Handler acces base - * @param string $code Code a verifier - * @param Product $product Objet product - * @return int 0 if available, <0 if KO + * @param DoliDB $db Handler acces base + * @param string $code Code a verifier + * @param Product $product Objet product + * @return int 0 if available, <0 if KO */ - function verif_dispo($db, $code, $product) + public function verif_dispo($db, $code, $product) { // phpcs:enable $sql = "SELECT ref FROM ".MAIN_DB_PREFIX."product"; diff --git a/htdocs/core/modules/product/mod_codeproduct_leopard.php b/htdocs/core/modules/product/mod_codeproduct_leopard.php index 1cf17fef6e7..a7b03eed2f0 100644 --- a/htdocs/core/modules/product/mod_codeproduct_leopard.php +++ b/htdocs/core/modules/product/mod_codeproduct_leopard.php @@ -71,7 +71,7 @@ class mod_codeproduct_leopard extends ModeleProductCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 1; $this->code_modifiable = 1; @@ -81,12 +81,13 @@ class mod_codeproduct_leopard extends ModeleProductCode } - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ - function info($langs) + public function info($langs) { $langs->load("companies"); return $langs->trans("LeopardNumRefModelDesc"); @@ -100,7 +101,7 @@ class mod_codeproduct_leopard extends ModeleProductCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return next value */ - function getNextValue($objproduct = 0, $type = -1) + public function getNextValue($objproduct = 0, $type = -1) { global $langs; return ''; @@ -108,19 +109,19 @@ class mod_codeproduct_leopard extends ModeleProductCode /** - * Check validity of code according to its rules + * Check validity of code according to its rules * - * @param DoliDB $db Database handler - * @param string $code Code to check/correct - * @param Product $product Object product + * @param DoliDB $db Database handler + * @param string $code Code to check/correct + * @param Product $product Object product * @param int $type 0 = product , 1 = service - * @return int 0 if OK - * -1 ErrorBadProductCodeSyntax - * -2 ErrorProductCodeRequired - * -3 ErrorProductCodeAlreadyUsed - * -4 ErrorPrefixRequired + * @return int 0 if OK + * -1 ErrorBadProductCodeSyntax + * -2 ErrorProductCodeRequired + * -3 ErrorProductCodeAlreadyUsed + * -4 ErrorPrefixRequired */ - function verif($db, &$code, $product, $type) + public function verif($db, &$code, $product, $type) { global $conf; @@ -131,7 +132,7 @@ class mod_codeproduct_leopard extends ModeleProductCode { $result=0; } - elseif (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED)) ) + elseif (empty($code) && (! $this->code_null || ! empty($conf->global->MAIN_COMPANY_CODE_ALWAYS_REQUIRED))) { $result=-2; } diff --git a/htdocs/core/modules/product/modules_product.class.php b/htdocs/core/modules/product/modules_product.class.php index c0f83c1eace..30350d9378f 100644 --- a/htdocs/core/modules/product/modules_product.class.php +++ b/htdocs/core/modules/product/modules_product.class.php @@ -33,13 +33,13 @@ */ abstract class ModelePDFProduct extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error=''; + /** + * @var string Error code (or message) + */ + public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -47,33 +47,33 @@ abstract class ModelePDFProduct extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) - { + public static function liste_modeles($db, $maxfilenamelength = 0) + { // phpcs:enable - global $conf; + global $conf; - $type='product'; - $liste=array(); + $type='product'; + $liste=array(); - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $liste=getListOfModels($db, $type, $maxfilenamelength); - return $liste; - } + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db, $type, $maxfilenamelength); + return $liste; + } } abstract class ModeleProductCode { /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; /** Renvoi la description par defaut du modele de numerotation * * @param Translate $langs Object langs * @return string Texte descripif */ - function info($langs) + public function info($langs) { $langs->load("bills"); return $langs->trans("NoDescription"); @@ -84,7 +84,7 @@ abstract class ModeleProductCode * @param Translate $langs Object langs * @return string Nom du module */ - function getNom($langs) + public function getNom($langs) { return empty($this->name)?$this->nom:$this->name; } @@ -95,7 +95,7 @@ abstract class ModeleProductCode * @param Translate $langs Object langs * @return string Example */ - function getExample($langs) + public function getExample($langs) { $langs->load("bills"); return $langs->trans("NoExample"); @@ -106,7 +106,7 @@ abstract class ModeleProductCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -118,7 +118,7 @@ abstract class ModeleProductCode * @param int $type Type * @return string Value */ - function getNextValue($objproduct = 0, $type = -1) + public function getNextValue($objproduct = 0, $type = -1) { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); @@ -129,7 +129,7 @@ abstract class ModeleProductCode * * @return string Version */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -141,7 +141,7 @@ abstract class ModeleProductCode return $langs->trans("NotAvailable"); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi la liste des modeles de numérotation * @@ -149,7 +149,7 @@ abstract class ModeleProductCode * @param integer $maxfilenamelength Max length of value to show * @return array List of numbers */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable $liste=array(); @@ -175,22 +175,24 @@ abstract class ModeleProductCode } /** - * Return description of module parameters + * Return description of module parameters * - * @param Translate $langs Output language - * @param Product $product Product object - * @param int $type -1=Nothing, 0=Customer, 1=Supplier - * @return string HTML translated description + * @param Translate $langs Output language + * @param Product $product Product object + * @param int $type -1=Nothing, 0=Customer, 1=Supplier + * @return string HTML translated description */ - function getToolTip($langs, $product, $type) + public function getToolTip($langs, $product, $type) { global $conf; $langs->load("admin"); $s=''; - if ($type == -1) $s.=$langs->trans("Name").': '.$this->getNom($langs).'
'; - if ($type == -1) $s.=$langs->trans("Version").': '.$this->getVersion().'
'; + if ($type == -1) { + $s.=$langs->trans("Name").': '.$this->getNom($langs).'
'; + $s.=$langs->trans("Version").': '.$this->getVersion().'
'; + } if ($type == 0) $s.=$langs->trans("ProductCodeDesc").'
'; if ($type == 1) $s.=$langs->trans("ServiceCodeDesc").'
'; if ($type != -1) $s.=$langs->trans("ValidityControledByModule").': '.$this->getNom($langs).'
'; @@ -241,13 +243,13 @@ abstract class ModeleProductCode return $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Check if mask/numbering use prefix - * - * @return int 0=no, 1=yes - */ - function verif_prefixIsUsed() + * Check if mask/numbering use prefix + * + * @return int 0=no, 1=yes + */ + public function verif_prefixIsUsed() { // phpcs:enable return 0; diff --git a/htdocs/core/modules/product_batch/modules_product_batch.class.php b/htdocs/core/modules/product_batch/modules_product_batch.class.php index 5708033a8ea..38cd9dda385 100644 --- a/htdocs/core/modules/product_batch/modules_product_batch.class.php +++ b/htdocs/core/modules/product_batch/modules_product_batch.class.php @@ -38,30 +38,30 @@ */ abstract class ModelePDFProductBatch extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error=''; - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Return list of active generation modules - * + * @var string Error code (or message) + */ + public $error=''; + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * * @param DoliDB $db Database handler * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) - { + public static function liste_modeles($db, $maxfilenamelength = 0) + { // phpcs:enable - global $conf; + global $conf; - $type='product_batch'; - $list = array(); + $type = 'product_batch'; + $list = array(); - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $list = getListOfModels($db, $type, $maxfilenamelength); - return $list; - } + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $list = getListOfModels($db, $type, $maxfilenamelength); + return $list; + } } 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 e1c54a13a35..b925a29327c 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 @@ -78,7 +78,7 @@ class doc_generic_project_odt extends ModelePDFProjects * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -117,7 +117,7 @@ class doc_generic_project_odt extends ModelePDFProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -126,7 +126,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param string $array_key Name of the key for return array * @return array Array of substitution */ - function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -156,7 +156,7 @@ class doc_generic_project_odt extends ModelePDFProjects return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -164,7 +164,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_tasks(Task $task, $outputlangs) + public function get_substitutionarray_tasks(Task $task, $outputlangs) { // phpcs:enable global $conf; @@ -197,7 +197,7 @@ class doc_generic_project_odt extends ModelePDFProjects return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -205,7 +205,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_contacts($contact, $outputlangs) + public function get_substitutionarray_project_contacts($contact, $outputlangs) { // phpcs:enable global $conf; @@ -255,7 +255,7 @@ class doc_generic_project_odt extends ModelePDFProjects return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -263,19 +263,19 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_file($file, $outputlangs) - { + public function get_substitutionarray_project_file($file, $outputlangs) + { // phpcs:enable - global $conf; + global $conf; - return array( - 'projfile_name'=>$file['name'], - 'projfile_date'=>dol_print_date($file['date'], 'day'), - 'projfile_size'=>$file['size'] - ); - } + return array( + 'projfile_name'=>$file['name'], + 'projfile_date'=>dol_print_date($file['date'], 'day'), + 'projfile_size'=>$file['size'] + ); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -283,23 +283,23 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_reference($refdetail, $outputlangs) - { + public function get_substitutionarray_project_reference($refdetail, $outputlangs) + { // phpcs:enable - global $conf; + global $conf; - return array( - 'projref_type'=>$refdetail['type'], - 'projref_ref'=>$refdetail['ref'], - 'projref_date'=>dol_print_date($refdetail['date'], 'day'), - 'projref_socname'=>$refdetail['socname'], - 'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs), - 'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs), - 'projref_status'=>$refdetail['status'] - ); - } + return array( + 'projref_type'=>$refdetail['type'], + 'projref_ref'=>$refdetail['ref'], + 'projref_date'=>dol_print_date($refdetail['date'], 'day'), + 'projref_socname'=>$refdetail['socname'], + 'projref_amountht'=>price($refdetail['amountht'], 0, $outputlangs), + 'projref_amountttc'=>price($refdetail['amountttc'], 0, $outputlangs), + 'projref_status'=>$refdetail['status'] + ); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -307,7 +307,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_tasksressource($taskressource, $outputlangs) + public function get_substitutionarray_tasksressource($taskressource, $outputlangs) { // phpcs:enable global $conf; @@ -323,7 +323,7 @@ class doc_generic_project_odt extends ModelePDFProjects ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -331,7 +331,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_taskstime($tasktime, $outputlangs) + public function get_substitutionarray_taskstime($tasktime, $outputlangs) { // phpcs:enable global $conf; @@ -352,7 +352,7 @@ class doc_generic_project_odt extends ModelePDFProjects ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -360,7 +360,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_task_file($file, $outputlangs) + public function get_substitutionarray_task_file($file, $outputlangs) { // phpcs:enable global $conf; @@ -379,7 +379,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -462,7 +462,7 @@ class doc_generic_project_odt extends ModelePDFProjects return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -471,7 +471,7 @@ class doc_generic_project_odt extends ModelePDFProjects * @param string $srctemplatepath Full path of source filename for generator using a template file * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath) + public function write_file($object, $outputlangs, $srctemplatepath) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -588,7 +588,7 @@ class doc_generic_project_odt extends ModelePDFProjects // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->projet->dir_temp, diff --git a/htdocs/core/modules/project/doc/pdf_baleine.modules.php b/htdocs/core/modules/project/doc/pdf_baleine.modules.php index 8b05da32e37..e5f5e9a9654 100644 --- a/htdocs/core/modules/project/doc/pdf_baleine.modules.php +++ b/htdocs/core/modules/project/doc/pdf_baleine.modules.php @@ -116,7 +116,7 @@ class pdf_baleine extends ModelePDFProjects * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -165,7 +165,7 @@ class pdf_baleine extends ModelePDFProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant le projet sur le disque * @@ -173,7 +173,7 @@ class pdf_baleine extends ModelePDFProjects * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs) + public function write_file($object, $outputlangs) { // phpcs:enable global $conf, $hookmanager, $langs, $user; @@ -533,7 +533,7 @@ class pdf_baleine extends ModelePDFProjects * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -580,7 +580,7 @@ class pdf_baleine extends ModelePDFProjects * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -665,15 +665,15 @@ class pdf_baleine extends ModelePDFProjects } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Project $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return integer + * @param PDF $pdf PDF + * @param Project $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/project/doc/pdf_beluga.modules.php b/htdocs/core/modules/project/doc/pdf_beluga.modules.php index 8f9c9932389..f24f400f2af 100644 --- a/htdocs/core/modules/project/doc/pdf_beluga.modules.php +++ b/htdocs/core/modules/project/doc/pdf_beluga.modules.php @@ -1,7 +1,7 @@ - * Copyright (C) 2015-2018 Charlene Benke - * Copyright (C) 2018 Laurent Destailleur +/* Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2015-2018 Charlene Benke + * Copyright (C) 2018 Laurent Destailleur * * 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 @@ -65,7 +65,7 @@ class pdf_beluga extends ModelePDFProjects * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -114,7 +114,7 @@ class pdf_beluga extends ModelePDFProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant le projet sur le disque * @@ -122,7 +122,7 @@ class pdf_beluga extends ModelePDFProjects * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs) + public function write_file($object, $outputlangs) { // phpcs:enable global $conf, $hookmanager, $langs, $user; @@ -685,7 +685,7 @@ class pdf_beluga extends ModelePDFProjects * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -732,7 +732,7 @@ class pdf_beluga extends ModelePDFProjects * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -793,15 +793,15 @@ class pdf_beluga extends ModelePDFProjects } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Project $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return integer + * @param PDF $pdf PDF + * @param Project $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return integer */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/project/doc/pdf_timespent.modules.php b/htdocs/core/modules/project/doc/pdf_timespent.modules.php index 047f1cf946f..1846e556b1e 100644 --- a/htdocs/core/modules/project/doc/pdf_timespent.modules.php +++ b/htdocs/core/modules/project/doc/pdf_timespent.modules.php @@ -48,7 +48,7 @@ class pdf_timespent extends ModelePDFProjects * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -97,7 +97,7 @@ class pdf_timespent extends ModelePDFProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant le projet sur le disque * @@ -105,7 +105,7 @@ class pdf_timespent extends ModelePDFProjects * @param Translate $outputlangs Lang output object * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs) + public function write_file($object, $outputlangs) { // phpcs:enable global $conf, $hookmanager, $langs, $user; @@ -464,7 +464,7 @@ class pdf_timespent extends ModelePDFProjects * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf,$mysoc; @@ -511,7 +511,7 @@ class pdf_timespent extends ModelePDFProjects * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs,$conf,$mysoc; @@ -595,19 +595,19 @@ class pdf_timespent extends ModelePDFProjects */ } - /** - * Show footer of page. Need this->emetteur object + /** + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Project $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return integer - */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) - { - global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } + * @param PDF $pdf PDF + * @param Project $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return integer + */ + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } } diff --git a/htdocs/core/modules/project/mod_project_simple.php b/htdocs/core/modules/project/mod_project_simple.php index 68d0feaf2dc..25553fb19c9 100644 --- a/htdocs/core/modules/project/mod_project_simple.php +++ b/htdocs/core/modules/project/mod_project_simple.php @@ -62,7 +62,7 @@ class mod_project_simple extends ModeleNumRefProjects * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -74,7 +74,7 @@ class mod_project_simple extends ModeleNumRefProjects * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -85,7 +85,7 @@ class mod_project_simple extends ModeleNumRefProjects * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -122,7 +122,7 @@ class mod_project_simple extends ModeleNumRefProjects * @param Project $project Object project * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $project) + public function getNextValue($objsoc, $project) { global $db,$conf; @@ -159,7 +159,7 @@ class mod_project_simple extends ModeleNumRefProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next reference not yet used as a reference * @@ -167,7 +167,7 @@ class mod_project_simple extends ModeleNumRefProjects * @param Project $project Object project * @return string Next not used reference */ - function project_get_num($objsoc = 0, $project = '') + public function project_get_num($objsoc = 0, $project = '') { // phpcs:enable return $this->getNextValue($objsoc, $project); diff --git a/htdocs/core/modules/project/mod_project_universal.php b/htdocs/core/modules/project/mod_project_universal.php index 7d2d3665582..f987d4d3b32 100644 --- a/htdocs/core/modules/project/mod_project_universal.php +++ b/htdocs/core/modules/project/mod_project_universal.php @@ -59,7 +59,7 @@ class mod_project_universal extends ModeleNumRefProjects * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -100,7 +100,7 @@ class mod_project_universal extends ModeleNumRefProjects * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -123,7 +123,7 @@ class mod_project_universal extends ModeleNumRefProjects * @param Project $project Object project * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $project) + public function getNextValue($objsoc, $project) { global $db,$conf; @@ -145,7 +145,7 @@ class mod_project_universal extends ModeleNumRefProjects } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next reference not yet used as a reference * @@ -153,7 +153,7 @@ class mod_project_universal extends ModeleNumRefProjects * @param Project $project Object project * @return string Next not used reference */ - function project_get_num($objsoc = 0, $project = '') + public function project_get_num($objsoc = 0, $project = '') { // phpcs:enable return $this->getNextValue($objsoc, $project); diff --git a/htdocs/core/modules/project/modules_project.php b/htdocs/core/modules/project/modules_project.php index 65a424941b8..f77111bade3 100644 --- a/htdocs/core/modules/project/modules_project.php +++ b/htdocs/core/modules/project/modules_project.php @@ -37,7 +37,7 @@ abstract class ModelePDFProjects extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -45,7 +45,7 @@ abstract class ModelePDFProjects extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -77,7 +77,7 @@ abstract class ModeleNumRefProjects * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -87,7 +87,7 @@ abstract class ModeleNumRefProjects * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("projects"); @@ -99,7 +99,7 @@ abstract class ModeleNumRefProjects * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("projects"); @@ -112,7 +112,7 @@ abstract class ModeleNumRefProjects * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -124,7 +124,7 @@ abstract class ModeleNumRefProjects * @param Project $project Object project * @return string Valeur */ - function getNextValue($objsoc, $project) + public function getNextValue($objsoc, $project) { global $langs; return $langs->trans("NotAvailable"); @@ -135,15 +135,15 @@ abstract class ModeleNumRefProjects * * @return string Valeur */ - function getVersion() - { + public function getVersion() + { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; - return $langs->trans("NotAvailable"); - } + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; + else return $langs->trans("NotAvailable"); + } } 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 fefaefc426c..151d800f04d 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 @@ -62,7 +62,7 @@ class doc_generic_task_odt extends ModelePDFTask public $emetteur; /** - * @var array() Minimum version of PHP required by module. + * @var array Minimum version of PHP required by module. * e.g.: PHP ≥ 5.4 = array(5, 4) */ public $phpmin = array(5, 4); @@ -79,7 +79,7 @@ class doc_generic_task_odt extends ModelePDFTask * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -118,7 +118,7 @@ class doc_generic_task_odt extends ModelePDFTask } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -127,7 +127,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param string $array_key Name of the key for return array * @return array Array of substitution */ - function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') { // phpcs:enable global $conf; @@ -163,7 +163,7 @@ class doc_generic_task_odt extends ModelePDFTask return $resarray; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -171,30 +171,30 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_tasks($task, $outputlangs) - { + public function get_substitutionarray_tasks($task, $outputlangs) + { // phpcs:enable - global $conf; + global $conf; - return array( - 'task_ref'=>$task->ref, - 'task_fk_project'=>$task->fk_project, - 'task_projectref'=>$task->projectref, - 'task_projectlabel'=>$task->projectlabel, - 'task_label'=>$task->label, - 'task_description'=>$task->description, - 'task_fk_parent'=>$task->fk_parent, - 'task_duration'=>$task->duration, - 'task_progress'=>$task->progress, - 'task_public'=>$task->public, - 'task_date_start'=>dol_print_date($task->date_start, 'day'), - 'task_date_end'=>dol_print_date($task->date_end, 'day'), - 'task_note_private'=>$task->note_private, - 'task_note_public'=>$task->note_public - ); - } + return array( + 'task_ref'=>$task->ref, + 'task_fk_project'=>$task->fk_project, + 'task_projectref'=>$task->projectref, + 'task_projectlabel'=>$task->projectlabel, + 'task_label'=>$task->label, + 'task_description'=>$task->description, + 'task_fk_parent'=>$task->fk_parent, + 'task_duration'=>$task->duration, + 'task_progress'=>$task->progress, + 'task_public'=>$task->public, + 'task_date_start'=>dol_print_date($task->date_start, 'day'), + 'task_date_end'=>dol_print_date($task->date_end, 'day'), + 'task_note_private'=>$task->note_private, + 'task_note_public'=>$task->note_public + ); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -202,7 +202,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_contacts($contact, $outputlangs) + public function get_substitutionarray_project_contacts($contact, $outputlangs) { // phpcs:enable global $conf; @@ -219,7 +219,7 @@ class doc_generic_task_odt extends ModelePDFTask ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -227,7 +227,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_file($file, $outputlangs) + public function get_substitutionarray_project_file($file, $outputlangs) { // phpcs:enable global $conf; @@ -239,7 +239,7 @@ class doc_generic_task_odt extends ModelePDFTask ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -247,7 +247,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_project_reference($refdetail, $outputlangs) + public function get_substitutionarray_project_reference($refdetail, $outputlangs) { // phpcs:enable global $conf; @@ -263,7 +263,7 @@ class doc_generic_task_odt extends ModelePDFTask ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -271,7 +271,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_tasksressource($taskressource, $outputlangs) + public function get_substitutionarray_tasksressource($taskressource, $outputlangs) { // phpcs:enable global $conf; @@ -287,7 +287,7 @@ class doc_generic_task_odt extends ModelePDFTask ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -295,7 +295,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_taskstime($tasktime, $outputlangs) + public function get_substitutionarray_taskstime($tasktime, $outputlangs) { // phpcs:enable global $conf; @@ -312,7 +312,7 @@ class doc_generic_task_odt extends ModelePDFTask ); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define array with couple substitution key => substitution value * @@ -320,7 +320,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $outputlangs Lang object to use for output * @return array Return a substitution array */ - function get_substitutionarray_task_file($file, $outputlangs) + public function get_substitutionarray_task_file($file, $outputlangs) { // phpcs:enable global $conf; @@ -339,7 +339,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -422,7 +422,7 @@ class doc_generic_task_odt extends ModelePDFTask return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -431,7 +431,7 @@ class doc_generic_task_odt extends ModelePDFTask * @param string $srctemplatepath Full path of source filename for generator using a template file * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath) + public function write_file($object, $outputlangs, $srctemplatepath) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; @@ -515,7 +515,7 @@ class doc_generic_task_odt extends ModelePDFTask // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->projet->dir_temp, diff --git a/htdocs/core/modules/project/task/mod_task_simple.php b/htdocs/core/modules/project/task/mod_task_simple.php index 47baf9e7d4c..4632fedec4a 100644 --- a/htdocs/core/modules/project/task/mod_task_simple.php +++ b/htdocs/core/modules/project/task/mod_task_simple.php @@ -62,7 +62,7 @@ class mod_task_simple extends ModeleNumRefTask * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -74,7 +74,7 @@ class mod_task_simple extends ModeleNumRefTask * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -85,7 +85,7 @@ class mod_task_simple extends ModeleNumRefTask * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -123,7 +123,7 @@ class mod_task_simple extends ModeleNumRefTask * @param Task $object Object Task * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -159,7 +159,7 @@ class mod_task_simple extends ModeleNumRefTask } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next reference not yet used as a reference * @@ -167,7 +167,7 @@ class mod_task_simple extends ModeleNumRefTask * @param Task $object Object task * @return string Next not used reference */ - function task_get_num($objsoc = 0, $object = '') + public function task_get_num($objsoc = 0, $object = '') { return $this->getNextValue($objsoc, $object); } diff --git a/htdocs/core/modules/project/task/mod_task_universal.php b/htdocs/core/modules/project/task/mod_task_universal.php index b92fe03ae3f..f1d295802a9 100644 --- a/htdocs/core/modules/project/task/mod_task_universal.php +++ b/htdocs/core/modules/project/task/mod_task_universal.php @@ -59,7 +59,7 @@ class mod_task_universal extends ModeleNumRefTask * * @return string Texte descripif */ - function info() + public function info() { global $conf,$langs; @@ -100,7 +100,7 @@ class mod_task_universal extends ModeleNumRefTask * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -123,7 +123,7 @@ class mod_task_universal extends ModeleNumRefTask * @param Task $object Object task * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -145,7 +145,7 @@ class mod_task_universal extends ModeleNumRefTask } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next reference not yet used as a reference * @@ -153,7 +153,7 @@ class mod_task_universal extends ModeleNumRefTask * @param Task $object Object task * @return string Next not used reference */ - function project_get_num($objsoc = 0, $object = '') + public function project_get_num($objsoc = 0, $object = '') { // phpcs:enable return $this->getNextValue($objsoc, $object); diff --git a/htdocs/core/modules/project/task/modules_task.php b/htdocs/core/modules/project/task/modules_task.php index 3e1b00fcf47..e37c4b1dabb 100644 --- a/htdocs/core/modules/project/task/modules_task.php +++ b/htdocs/core/modules/project/task/modules_task.php @@ -38,7 +38,7 @@ abstract class ModelePDFTask extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -46,7 +46,7 @@ abstract class ModelePDFTask extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -78,7 +78,7 @@ abstract class ModeleNumRefTask * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -88,7 +88,7 @@ abstract class ModeleNumRefTask * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("projects"); @@ -100,7 +100,7 @@ abstract class ModeleNumRefTask * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("projects"); @@ -113,7 +113,7 @@ abstract class ModeleNumRefTask * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -125,7 +125,7 @@ abstract class ModeleNumRefTask * @param Project $project Object project * @return string Valeur */ - function getNextValue($objsoc, $project) + public function getNextValue($objsoc, $project) { global $langs; return $langs->trans("NotAvailable"); @@ -136,7 +136,7 @@ abstract class ModeleNumRefTask * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); 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 4af8e8d1e32..d303e52d734 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 @@ -60,7 +60,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -105,7 +105,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -219,7 +219,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -231,7 +231,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php index fd254490ec1..24fe36b3213 100644 --- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php @@ -125,7 +125,7 @@ class pdf_azur extends ModelePDFPropales * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf,$langs,$mysoc; @@ -202,7 +202,7 @@ class pdf_azur extends ModelePDFPropales $this->atleastonediscount=0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -214,7 +214,7 @@ class pdf_azur extends ModelePDFPropales * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; @@ -837,7 +837,7 @@ class pdf_azur extends ModelePDFPropales } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * @@ -847,13 +847,13 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -863,7 +863,7 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -1034,7 +1034,7 @@ class pdf_azur extends ModelePDFPropales } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -1045,7 +1045,7 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -1323,7 +1323,7 @@ class pdf_azur extends ModelePDFPropales * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1442,7 +1442,7 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; @@ -1665,14 +1665,14 @@ class pdf_azur extends ModelePDFPropales * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show area for the customer to sign * @@ -1682,7 +1682,7 @@ class pdf_azur extends ModelePDFPropales * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _signature_area(&$pdf, $object, $posy, $outputlangs) + private function _signature_area(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php index 936309fb6d8..668693e67cc 100644 --- a/htdocs/core/modules/propale/doc/pdf_cyan.modules.php +++ b/htdocs/core/modules/propale/doc/pdf_cyan.modules.php @@ -903,7 +903,7 @@ class pdf_cyan extends ModelePDFPropales * @param Translate $outputlangs Langs object * @return void */ - function drawInfoTable(&$pdf, $object, $posy, $outputlangs) + public function drawInfoTable(&$pdf, $object, $posy, $outputlangs) { global $conf; $default_font_size = pdf_getPDFFontSize($outputlangs); @@ -1360,7 +1360,7 @@ class pdf_cyan extends ModelePDFPropales * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1427,7 +1427,7 @@ class pdf_cyan extends ModelePDFPropales * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs; @@ -1652,7 +1652,7 @@ class pdf_cyan extends ModelePDFPropales * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; @@ -1705,7 +1705,7 @@ class pdf_cyan extends ModelePDFPropales * @param int $hideref Do not show ref * @return null */ - function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { global $conf, $hookmanager; diff --git a/htdocs/core/modules/propale/mod_propale_marbre.php b/htdocs/core/modules/propale/mod_propale_marbre.php index abbc4df42b6..0e03574a3d4 100644 --- a/htdocs/core/modules/propale/mod_propale_marbre.php +++ b/htdocs/core/modules/propale/mod_propale_marbre.php @@ -62,7 +62,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -74,7 +74,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -86,7 +86,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -124,7 +124,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * @param Propal $propal Object commercial proposal * @return string Next value */ - function getNextValue($objsoc, $propal) + public function getNextValue($objsoc, $propal) { global $db,$conf; @@ -165,7 +165,7 @@ class mod_propale_marbre extends ModeleNumRefPropales * @param Object $objforref Object for number to search * @return string Next free value */ - function getNumRef($objsoc, $objforref) + public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index f30ef4e48d1..972bb94cb64 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -62,7 +62,7 @@ class mod_propale_saphir extends ModeleNumRefPropales * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -102,7 +102,7 @@ class mod_propale_saphir extends ModeleNumRefPropales * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -128,7 +128,7 @@ class mod_propale_saphir extends ModeleNumRefPropales * @param Propal $propal Object commercial proposal * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $propal) + public function getNextValue($objsoc, $propal) { global $db,$conf; diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php index cb4e253fc09..dc01941ece4 100644 --- a/htdocs/core/modules/propale/modules_propale.php +++ b/htdocs/core/modules/propale/modules_propale.php @@ -42,7 +42,7 @@ abstract class ModelePDFPropales extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -50,7 +50,7 @@ abstract class ModelePDFPropales extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -81,7 +81,7 @@ abstract class ModeleNumRefPropales * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -91,7 +91,7 @@ abstract class ModeleNumRefPropales * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("propale"); @@ -103,7 +103,7 @@ abstract class ModeleNumRefPropales * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("propale"); @@ -116,7 +116,7 @@ abstract class ModeleNumRefPropales * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ abstract class ModeleNumRefPropales * @param Propal $propal Object commercial proposal * @return string Valeur */ - function getNextValue($objsoc, $propal) + public function getNextValue($objsoc, $propal) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ abstract class ModeleNumRefPropales * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/rapport/pdf_paiement.class.php b/htdocs/core/modules/rapport/pdf_paiement.class.php index 15682551670..127c7a92352 100644 --- a/htdocs/core/modules/rapport/pdf_paiement.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement.class.php @@ -37,7 +37,7 @@ class pdf_paiement * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs,$conf; @@ -83,7 +83,7 @@ class pdf_paiement } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction generant la rapport sur le disque * @@ -93,7 +93,7 @@ class pdf_paiement * @param string $outputlangs Lang output object * @return int <0 if KO, >0 if OK */ - function write_file($_dir, $month, $year, $outputlangs) + public function write_file($_dir, $month, $year, $outputlangs) { // phpcs:enable include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -125,7 +125,7 @@ class pdf_paiement $year = sprintf("%04d", $year); $file = $dir . "/payments-".$year."-".$month.".pdf"; - switch ($this->doc_type) { + switch ($this->doc_type) { case "client": $file = $dir . "/payments-".$year."-".$month.".pdf"; break; @@ -159,9 +159,9 @@ class pdf_paiement $num=0; $lines=array(); - // count number of lines of payment - $sql = "SELECT p.rowid as prowid"; - switch ($this->doc_type) { + // count number of lines of payment + $sql = "SELECT p.rowid as prowid"; + switch ($this->doc_type) { case "client": $sql.= " FROM ".MAIN_DB_PREFIX."paiement as p"; break; @@ -340,6 +340,7 @@ class pdf_paiement return 1; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** * Show top header of page. * @@ -349,8 +350,9 @@ class pdf_paiement * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $page, $showaddress, $outputlangs) + protected function _pagehead(&$pdf, $page, $showaddress, $outputlangs) { + // phpcs:enable global $langs, $conf; // Do not add the BACKGROUND as this is a report @@ -359,7 +361,7 @@ class pdf_paiement $default_font_size = pdf_getPDFFontSize($outputlangs); $title=$conf->global->MAIN_INFO_SOCIETE_NOM; - switch($this->doc_type) { + switch($this->doc_type) { case "client": $title.=' - '.$outputlangs->transnoentities("ListOfCustomerPayments"); break; @@ -412,7 +414,7 @@ class pdf_paiement } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output body * @@ -422,7 +424,7 @@ class pdf_paiement * @param Translate $outputlangs Object langs * @return void */ - function Body(&$pdf, $page, $lines, $outputlangs) + public function Body(&$pdf, $page, $lines, $outputlangs) { // phpcs:enable global $langs; diff --git a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php index 0b823e0419e..b25b979783e 100644 --- a/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php +++ b/htdocs/core/modules/rapport/pdf_paiement_fourn.class.php @@ -35,7 +35,7 @@ class pdf_paiement_fourn extends pdf_paiement * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { parent::__construct($db); $this->doc_type = "fourn"; 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 fdd2a92d15b..4854af7bfac 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 @@ -58,8 +58,8 @@ class doc_generic_reception_odt extends ModelePdfReception * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $conf,$langs,$mysoc; $langs->load("main"); @@ -94,18 +94,18 @@ class doc_generic_reception_odt extends ModelePdfReception // Recupere emetteur $this->emetteur=$mysoc; if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default if not defined - } + } - /** - * Return description of a module - * - * @param Translate $langs Lang object to use for output - * @return string Description - */ - function info($langs) - { - global $conf,$langs; + /** + * Return description of a module + * + * @param Translate $langs Lang object to use for output + * @return string Description + */ + public function info($langs) + { + global $conf,$langs; $langs->load("companies"); $langs->load("errors"); @@ -183,22 +183,22 @@ class doc_generic_reception_odt extends ModelePdfReception $texte.= ''; return $texte; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build a document on disk using the generic odt module. + * Function to build a document on disk using the generic odt module. * - * @param Reception $object Object source to build document - * @param Translate $outputlangs Lang output object + * @param Reception $object Object source to build document + * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details * @param int $hidedesc Do not show desc * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager; diff --git a/htdocs/core/modules/reception/doc/pdf_squille.modules.php b/htdocs/core/modules/reception/doc/pdf_squille.modules.php index 9a4c3b2010d..dec1f35e7b0 100644 --- a/htdocs/core/modules/reception/doc/pdf_squille.modules.php +++ b/htdocs/core/modules/reception/doc/pdf_squille.modules.php @@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; */ class pdf_squille extends ModelePdfReception { - var $emetteur; // Objet societe qui emet + public $emetteur; // Objet societe qui emet /** @@ -40,7 +40,7 @@ class pdf_squille extends ModelePdfReception * * @param DoliDB $db Database handler */ - function __construct($db = 0) + public function __construct($db = 0) { global $conf,$langs,$mysoc; @@ -98,7 +98,7 @@ class pdf_squille extends ModelePdfReception } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -110,7 +110,7 @@ class pdf_squille extends ModelePdfReception * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$conf,$langs,$hookmanager; @@ -592,7 +592,7 @@ class pdf_squille extends ModelePdfReception } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -604,7 +604,7 @@ class pdf_squille extends ModelePdfReception * @param int $totalOrdered Total ordered * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered) { // phpcs:enable global $conf,$mysoc; @@ -707,7 +707,7 @@ class pdf_squille extends ModelePdfReception * @param int $hidebottom Hide bottom bar of array * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) { global $conf; @@ -786,7 +786,7 @@ class pdf_squille extends ModelePdfReception * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf,$langs,$mysoc; @@ -1037,7 +1037,7 @@ class pdf_squille extends ModelePdfReception * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/reception/mod_reception_beryl.php b/htdocs/core/modules/reception/mod_reception_beryl.php index 7624ec5cec0..09b3fbfb1f5 100644 --- a/htdocs/core/modules/reception/mod_reception_beryl.php +++ b/htdocs/core/modules/reception/mod_reception_beryl.php @@ -28,10 +28,10 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/reception/modules_reception.php'; */ class mod_reception_beryl extends ModelNumRefReception { - var $version='dolibarr'; - var $prefix='RCP'; - var $error=''; - var $nom='Beryl'; + public $version='dolibarr'; + public $prefix='RCP'; + public $error=''; + public $nom='Beryl'; /** @@ -39,7 +39,7 @@ class mod_reception_beryl extends ModelNumRefReception * * @return string text description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -51,7 +51,7 @@ class mod_reception_beryl extends ModelNumRefReception * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -62,7 +62,7 @@ class mod_reception_beryl extends ModelNumRefReception * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -97,7 +97,7 @@ class mod_reception_beryl extends ModelNumRefReception * @param Object $shipment Shipment object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $shipment) { global $db,$conf; @@ -130,7 +130,7 @@ class mod_reception_beryl extends ModelNumRefReception return $this->prefix.$yymm."-".$num; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -138,7 +138,7 @@ class mod_reception_beryl extends ModelNumRefReception * @param Object $objforref Shipment object * @return string Next free value */ - function reception_get_num($objsoc, $objforref) + public function reception_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/reception/mod_reception_moonstone.php b/htdocs/core/modules/reception/mod_reception_moonstone.php index bbf5443255a..6f7d66f8ef3 100644 --- a/htdocs/core/modules/reception/mod_reception_moonstone.php +++ b/htdocs/core/modules/reception/mod_reception_moonstone.php @@ -29,16 +29,16 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/reception/modules_reception.php'; */ class mod_reception_moonstone extends ModelNumRefReception { - var $version='dolibarr'; - var $error = ''; - var $nom = 'Moonstone'; + public $version='dolibarr'; + public $error = ''; + public $nom = 'Moonstone'; - /** - * Return default description of numbering model - * - * @return string text description - */ - function info() + /** + * Return default description of numbering model + * + * @return string text description + */ + public function info() { global $conf,$langs; @@ -74,7 +74,7 @@ class mod_reception_moonstone extends ModelNumRefReception * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -100,7 +100,7 @@ class mod_reception_moonstone extends ModelNumRefReception * @param Object $reception Reception object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $reception) + public function getNextValue($objsoc, $reception) { global $db,$conf; @@ -119,9 +119,9 @@ class mod_reception_moonstone extends ModelNumRefReception $numFinal=get_next_value($db, $mask, 'reception', 'ref', '', $objsoc, $date); return $numFinal; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -129,7 +129,7 @@ class mod_reception_moonstone extends ModelNumRefReception * @param Object $objforref Reception object * @return string Next free value */ - function reception_get_num($objsoc, $objforref) + public function reception_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/reception/modules_reception.php b/htdocs/core/modules/reception/modules_reception.php index 62e2434d9ac..f258ce04d5c 100644 --- a/htdocs/core/modules/reception/modules_reception.php +++ b/htdocs/core/modules/reception/modules_reception.php @@ -32,7 +32,7 @@ abstract class ModelePdfReception extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -40,7 +40,7 @@ abstract class ModelePdfReception extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -61,13 +61,13 @@ abstract class ModelePdfReception extends CommonDocGenerator */ abstract class ModelNumRefReception { - var $error=''; + public $error=''; /** Return if a model can be used or not * * @return boolean true if model can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -77,7 +77,7 @@ abstract class ModelNumRefReception * * @return string text description */ - function info() + public function info() { global $langs; $langs->load("reception"); @@ -89,7 +89,7 @@ abstract class ModelNumRefReception * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("reception"); @@ -101,7 +101,7 @@ abstract class ModelNumRefReception * * @return boolean false if conflit, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -113,7 +113,7 @@ abstract class ModelNumRefReception * @param Object $shipment Shipment object * @return string Value */ - function getNextValue($objsoc, $shipment) + public function getNextValue($objsoc, $shipment) { global $langs; return $langs->trans("NotAvailable"); @@ -124,15 +124,15 @@ abstract class ModelNumRefReception * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; return $langs->trans("NotAvailable"); } } diff --git a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php index b0caa7d0b15..c9bdff46ece 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassNone.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassNone.class.php @@ -56,7 +56,7 @@ class modGeneratePassNone extends ModeleGenPassword * @param Translate $langs Handler de langue * @param User $user Handler du user connecte */ - function __construct($db, $conf, $langs, $user) + public function __construct($db, $conf, $langs, $user) { $this->id = "none"; $this->length = 0; @@ -72,7 +72,7 @@ class modGeneratePassNone extends ModeleGenPassword * * @return string Description of text */ - function getDescription() + public function getDescription() { global $langs; return $langs->trans("PasswordGenerationNone"); @@ -83,7 +83,7 @@ class modGeneratePassNone extends ModeleGenPassword * * @return string Example of password */ - function getExample() + public function getExample() { return $this->langs->trans("None"); } @@ -93,7 +93,7 @@ class modGeneratePassNone extends ModeleGenPassword * * @return string Return a new generated password */ - function getNewGeneratedPassword() + public function getNewGeneratedPassword() { return ""; } @@ -104,7 +104,7 @@ class modGeneratePassNone extends ModeleGenPassword * @param string $password Password to check * @return int 0 if KO, >0 if OK */ - function validatePassword($password) + public function validatePassword($password) { return 1; } diff --git a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php index 3e4ee4326d3..bccb1353087 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassPerso.class.php @@ -70,7 +70,7 @@ class modGeneratePassPerso extends ModeleGenPassword * @param Translate $langs Handler de langue * @param User $user Handler du user connecte */ - function __construct($db, $conf, $langs, $user) + public function __construct($db, $conf, $langs, $user) { $this->id = "Perso"; $this->length = $langs->trans("SetupPerso"); @@ -120,7 +120,7 @@ class modGeneratePassPerso extends ModeleGenPassword * * @return string Description of text */ - function getDescription() + public function getDescription() { global $langs; return $langs->trans("PasswordGenerationPerso"); @@ -131,39 +131,42 @@ class modGeneratePassPerso extends ModeleGenPassword * * @return string Example of password */ - function getExample() + public function getExample() { return $this->getNewGeneratedPassword(); } /** - * Build new password + * Build new password * - * @return string Return a new generated password + * @return string Return a new generated password */ - function getNewGeneratedPassword() + public function getNewGeneratedPassword() { $pass = ""; - for($i=0; $i<$this->NbMaj; $i++){ // Y + for ($i=0; $i<$this->NbMaj; $i++) { + // Y $pass .= $this->Maj[mt_rand(0, strlen($this->Maj) - 1)]; } - for($i=0; $i<$this->NbNum; $i++){ // X + for ($i=0; $i<$this->NbNum; $i++) { + // X $pass .= $this->Nb[mt_rand(0, strlen($this->Nb) - 1)]; } - for($i=0; $i<$this->NbSpe; $i++){ // @ + for ($i=0; $i<$this->NbSpe; $i++) { + // @ $pass .= $this->Spe[mt_rand(0, strlen($this->Spe) - 1)]; } - for($i=strlen($pass);$i<$this->length2; $i++){ // y + for ($i=strlen($pass);$i<$this->length2; $i++) { + // y $pass .= $this->All[mt_rand(0, strlen($this->All) -1)]; } $pass = str_shuffle($pass); - if ($this->validatePassword($pass)) - { + if ($this->validatePassword($pass)) { return $pass; } @@ -171,31 +174,31 @@ class modGeneratePassPerso extends ModeleGenPassword } /** - * Validate a password + * Validate a password * - * @param string $password Password to check - * @return int 0 if KO, >0 if OK + * @param string $password Password to check + * @return int 0 if KO, >0 if OK */ - function validatePassword($password) + public function validatePassword($password) { $password_a = str_split($password); $maj = str_split($this->Maj); $num = str_split($this->Nb); $spe = str_split($this->Spe); - if(count(array_intersect($password_a, $maj)) < $this->NbMaj){ + if (count(array_intersect($password_a, $maj)) < $this->NbMaj) { return 0; } - if(count(array_intersect($password_a, $num)) < $this->NbNum){ + if (count(array_intersect($password_a, $num)) < $this->NbNum) { return 0; } - if(count(array_intersect($password_a, $spe)) < $this->NbSpe){ + if (count(array_intersect($password_a, $spe)) < $this->NbSpe) { return 0; } - if(!$this->consecutiveInterationSameCharacter($password)){ + if (!$this->consecutiveInterationSameCharacter($password)) { return 0; } @@ -203,25 +206,25 @@ class modGeneratePassPerso extends ModeleGenPassword } /** - * consecutive iterations of the same character + * consecutive iterations of the same character * - * @param string $password Password to check - * @return int 0 if KO, >0 if OK + * @param string $password Password to check + * @return int 0 if KO, >0 if OK */ - function consecutiveInterationSameCharacter($password) + public function consecutiveInterationSameCharacter($password) { $last = ""; $count = 0; $char = str_split($password); - foreach($char as $c){ - if($c != $last){ + foreach($char as $c) { + if($c != $last) { $last = $c; $count = 0; - }else{ + } else { $count++; } - if($count >= $this->NbRepeat) { + if ($count >= $this->NbRepeat) { return 0; } } diff --git a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php index 124ecf32321..88dc53e7e32 100644 --- a/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php +++ b/htdocs/core/modules/security/generate/modGeneratePassStandard.class.php @@ -56,7 +56,7 @@ class modGeneratePassStandard extends ModeleGenPassword * @param Translate $langs Handler de langue * @param User $user Handler du user connecte */ - function __construct($db, $conf, $langs, $user) + public function __construct($db, $conf, $langs, $user) { $this->id = "standard"; $this->length = 8; @@ -72,7 +72,7 @@ class modGeneratePassStandard extends ModeleGenPassword * * @return string Description of module */ - function getDescription() + public function getDescription() { global $langs; return $langs->trans("PasswordGenerationStandard"); @@ -83,7 +83,7 @@ class modGeneratePassStandard extends ModeleGenPassword * * @return string Example of password */ - function getExample() + public function getExample() { return $this->getNewGeneratedPassword(); } @@ -93,7 +93,7 @@ class modGeneratePassStandard extends ModeleGenPassword * * @return string Return a new generated password */ - function getNewGeneratedPassword() + public function getNewGeneratedPassword() { // start with a blank password $password = ""; @@ -123,15 +123,15 @@ class modGeneratePassStandard extends ModeleGenPassword return $password; } - /** - * Validate a password - * - * @param string $password Password to check - * @return int 0 if KO, >0 if OK - */ - function validatePassword($password) - { - if (dol_strlen($password) < $this->length) return 0; - return 1; - } + /** + * Validate a password + * + * @param string $password Password to check + * @return int 0 if KO, >0 if OK + */ + public function validatePassword($password) + { + if (dol_strlen($password) < $this->length) return 0; + return 1; + } } diff --git a/htdocs/core/modules/security/generate/modules_genpassword.php b/htdocs/core/modules/security/generate/modules_genpassword.php index a22d19e0845..5515a298379 100644 --- a/htdocs/core/modules/security/generate/modules_genpassword.php +++ b/htdocs/core/modules/security/generate/modules_genpassword.php @@ -40,7 +40,7 @@ abstract class ModeleGenPassword * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -50,18 +50,18 @@ abstract class ModeleGenPassword * * @return string Description of text */ - function getDescription() + public function getDescription() { global $langs; return $langs->trans("NoDescription"); } /** - * Return an example of password generated by this module + * Return an example of password generated by this module * - * @return string Example of password + * @return string Example of password */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -69,11 +69,11 @@ abstract class ModeleGenPassword } /** - * Build new password + * Build new password * - * @return string Return a new generated password + * @return string Return a new generated password */ - function getNewGeneratedPassword() + public function getNewGeneratedPassword() { global $langs; return $langs->trans("NotAvailable"); @@ -85,7 +85,7 @@ abstract class ModeleGenPassword * @param string $password Password to check * @return int 0 if KO, >0 if OK */ - function validatePassword($password) + public function validatePassword($password) { return 1; } 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 1b5707330da..0043f14990d 100644 --- a/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php +++ b/htdocs/core/modules/societe/doc/doc_generic_odt.modules.php @@ -54,7 +54,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -90,7 +90,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc * @param Translate $langs Object language * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -174,7 +174,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -186,10 +186,10 @@ class doc_generic_odt extends ModeleThirdPartyDoc * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable - global $user,$langs,$conf,$mysoc,$hookmanager; + global $user,$langs,$conf,$mysoc,$hookmanager; if (empty($srctemplatepath)) { @@ -265,7 +265,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity], @@ -419,7 +419,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc } $odfHandler->saveToDisk($file); - }catch (Exception $e){ + } catch (Exception $e){ $this->error=$e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); return -1; diff --git a/htdocs/core/modules/societe/mod_codeclient_elephant.php b/htdocs/core/modules/societe/mod_codeclient_elephant.php index 75cc33df4bd..f8d4f137048 100644 --- a/htdocs/core/modules/societe/mod_codeclient_elephant.php +++ b/htdocs/core/modules/societe/mod_codeclient_elephant.php @@ -72,7 +72,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 0; $this->code_modifiable = 1; @@ -83,12 +83,13 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode } - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ - function info($langs) + public function info($langs) { global $conf, $mc; global $form; @@ -139,7 +140,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = 0, $type = -1) { if ($type == 0 || $type == -1) { @@ -200,7 +201,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * @param int $type Client ou fournisseur (0:customer, 1:supplier) * @return string Value if OK, '' if module not configured, <0 if KO */ - function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = 0, $type = -1) { global $db,$conf; @@ -237,13 +238,13 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if mask/numbering use prefix * * @return int 0 or 1 */ - function verif_prefixIsUsed() + public function verif_prefixIsUsed() { // phpcs:enable global $conf; @@ -272,7 +273,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * -4 ErrorPrefixRequired * -5 Other (see this->error) */ - function verif($db, &$code, $soc, $type) + public function verif($db, &$code, $soc, $type) { global $conf; @@ -314,7 +315,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi si un code est pris ou non (par autre tiers) * @@ -324,7 +325,7 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode * @param int $type 0 = customer/prospect , 1 = supplier * @return int 0 if available, <0 if KO */ - function verif_dispo($db, $code, $soc, $type = 0) + public function verif_dispo($db, $code, $soc, $type = 0) { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; diff --git a/htdocs/core/modules/societe/mod_codeclient_leopard.php b/htdocs/core/modules/societe/mod_codeclient_leopard.php index 77be301464c..c7d204a5010 100644 --- a/htdocs/core/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/core/modules/societe/mod_codeclient_leopard.php @@ -70,7 +70,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode /** * Constructor */ - function __construct() + public function __construct() { $this->code_null = 1; $this->code_modifiable = 1; @@ -80,12 +80,13 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode } - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ - function info($langs) + public function info($langs) { $langs->load("companies"); return $langs->trans("LeopardNumRefModelDesc"); @@ -99,7 +100,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return next value */ - function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = 0, $type = -1) { global $langs; return ''; @@ -119,7 +120,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $soc, $type) + public function verif($db, &$code, $soc, $type) { global $conf; diff --git a/htdocs/core/modules/societe/mod_codeclient_monkey.php b/htdocs/core/modules/societe/mod_codeclient_monkey.php index 97acb109b97..69ee75911a6 100644 --- a/htdocs/core/modules/societe/mod_codeclient_monkey.php +++ b/htdocs/core/modules/societe/mod_codeclient_monkey.php @@ -70,7 +70,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode /** * Constructor */ - function __construct() + public function __construct() { $this->nom = "Monkey"; $this->name = "Monkey"; @@ -84,12 +84,13 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode } - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ - function info($langs) + public function info($langs) { return $langs->trans("MonkeyNumRefModelDesc", $this->prefixcustomer, $this->prefixsupplier); } @@ -103,7 +104,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = 0, $type = -1) { return $this->prefixcustomer.'0901-00001
'.$this->prefixsupplier.'0901-00001'; } @@ -112,11 +113,11 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode /** * Return next value * - * @param Societe $objsoc Object third party - * @param int $type Client ou fournisseur (1:client, 2:fournisseur) + * @param Societe $objsoc Object third party + * @param int $type Client ou fournisseur (1:client, 2:fournisseur) * @return string Value if OK, '' if module not configured, <0 if KO */ - function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = 0, $type = -1) { global $db, $conf, $mc; @@ -177,7 +178,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * -3 ErrorCustomerCodeAlreadyUsed * -4 ErrorPrefixRequired */ - function verif($db, &$code, $soc, $type) + public function verif($db, &$code, $soc, $type) { global $conf; @@ -224,7 +225,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi si un code est pris ou non (par autre tiers) * @@ -234,7 +235,7 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode * @param int $type 0 = customer/prospect , 1 = supplier * @return int 0 if available, <0 if KO */ - function verif_dispo($db, $code, $soc, $type = 0) + public function verif_dispo($db, $code, $soc, $type = 0) { // phpcs:enable global $conf, $mc; @@ -265,14 +266,14 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi si un code respecte la syntaxe + * Renvoi si un code respecte la syntaxe * - * @param string $code Code a verifier - * @return int 0 si OK, <0 si KO + * @param string $code Code a verifier + * @return int 0 si OK, <0 si KO */ - function verif_syntax($code) + public function verif_syntax($code) { // phpcs:enable $res = 0; diff --git a/htdocs/core/modules/societe/mod_codecompta_aquarium.php b/htdocs/core/modules/societe/mod_codecompta_aquarium.php index 835213a7402..1472bd982c7 100644 --- a/htdocs/core/modules/societe/mod_codecompta_aquarium.php +++ b/htdocs/core/modules/societe/mod_codecompta_aquarium.php @@ -57,7 +57,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode /** * Constructor */ - function __construct() + public function __construct() { global $conf; if (! isset($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) || trim($conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER) == '') $conf->global->COMPANY_AQUARIUM_MASK_CUSTOMER='411'; @@ -73,7 +73,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * @param Translate $langs Object langs * @return string Description of module */ - function info($langs) + public function info($langs) { global $conf; global $form; @@ -112,7 +112,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Return string example */ - function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = 0, $type = -1) { $s=''; $s.=$this->prefixcustomeraccountancycode.'CUSTCODE'; @@ -122,7 +122,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set accountancy account code for a third party into this->code * @@ -131,7 +131,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * @param string $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ - function get_code($db, $societe, $type = '') + public function get_code($db, $societe, $type = '') { // phpcs:enable global $conf; @@ -196,7 +196,7 @@ class mod_codecompta_aquarium extends ModeleAccountancyCode * @param string $type 'supplier' or 'customer' * @return int 0 if OK but not available, >0 if OK and available, <0 if KO */ - function verif($db, $code, $societe, $type) + public function verif($db, $code, $societe, $type) { $sql = "SELECT "; if ($type == 'customer') $sql.= "code_compta"; diff --git a/htdocs/core/modules/societe/mod_codecompta_panicum.php b/htdocs/core/modules/societe/mod_codecompta_panicum.php index 65cbba944b1..373e20b8eb6 100644 --- a/htdocs/core/modules/societe/mod_codecompta_panicum.php +++ b/htdocs/core/modules/societe/mod_codecompta_panicum.php @@ -52,7 +52,7 @@ class mod_codecompta_panicum extends ModeleAccountancyCode /** * Constructor */ - function __construct() + public function __construct() { } @@ -63,7 +63,7 @@ class mod_codecompta_panicum extends ModeleAccountancyCode * @param Translate $langs Object langs * @return string Description of module */ - function info($langs) + public function info($langs) { return $langs->trans("ModuleCompanyCode".$this->name); } @@ -76,12 +76,12 @@ class mod_codecompta_panicum extends ModeleAccountancyCode * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) * @return string Example */ - function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = 0, $type = -1) { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set accountancy account code for a third party into this->code * @@ -90,7 +90,7 @@ class mod_codecompta_panicum extends ModeleAccountancyCode * @param int $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ - function get_code($db, $societe, $type = '') + public function get_code($db, $societe, $type = '') { // phpcs:enable $this->code=''; diff --git a/htdocs/core/modules/societe/modules_societe.class.php b/htdocs/core/modules/societe/modules_societe.class.php index fe2b3d4feb3..d185b4cfcf7 100644 --- a/htdocs/core/modules/societe/modules_societe.class.php +++ b/htdocs/core/modules/societe/modules_societe.class.php @@ -38,7 +38,7 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator */ public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -46,7 +46,7 @@ abstract class ModeleThirdPartyDoc extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -77,7 +77,7 @@ abstract class ModeleThirdPartyCode * @param Translate $langs Object langs * @return string Texte descripif */ - function info($langs) + public function info($langs) { $langs->load("bills"); return $langs->trans("NoDescription"); @@ -88,7 +88,7 @@ abstract class ModeleThirdPartyCode * @param Translate $langs Object langs * @return string Nom du module */ - function getNom($langs) + public function getNom($langs) { return $this->nom; } @@ -99,7 +99,7 @@ abstract class ModeleThirdPartyCode * @param Translate $langs Object langs * @return string Example */ - function getExample($langs) + public function getExample($langs) { $langs->load("bills"); return $langs->trans("NoExample"); @@ -110,7 +110,7 @@ abstract class ModeleThirdPartyCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -122,18 +122,19 @@ abstract class ModeleThirdPartyCode * @param int $type Type * @return string Value */ - function getNextValue($objsoc = 0, $type = -1) + public function getNextValue($objsoc = 0, $type = -1) { global $langs; return $langs->trans("Function_getNextValue_InModuleNotWorking"); } - /** Return version of module + /** + * Return version of module * - * @return string Version + * @return string Version */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -145,7 +146,7 @@ abstract class ModeleThirdPartyCode return $langs->trans("NotAvailable"); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la liste des modeles de numérotation * @@ -153,7 +154,7 @@ abstract class ModeleThirdPartyCode * @param integer $maxfilenamelength Max length of value to show * @return array List of numbers */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable $liste=array(); @@ -186,7 +187,7 @@ abstract class ModeleThirdPartyCode * @param int $type -1=Nothing, 0=Customer, 1=Supplier * @return string HTML translated description */ - function getToolTip($langs, $soc, $type) + public function getToolTip($langs, $soc, $type) { global $conf; @@ -245,13 +246,13 @@ abstract class ModeleThirdPartyCode return $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Check if mask/numbering use prefix * * @return int 0=no, 1=yes */ - function verif_prefixIsUsed() + public function verif_prefixIsUsed() { // phpcs:enable return 0; @@ -271,25 +272,27 @@ abstract class ModeleAccountancyCode public $error=''; - /** Return description of module + /** + * Return description of module * - * @param Translate $langs Object langs - * @return string Description of module + * @param Translate $langs Object langs + * @return string Description of module */ - function info($langs) + public function info($langs) { $langs->load("bills"); return $langs->trans("NoDescription"); } - /** Return an example of result returned by getNextValue + /** + * Return an example of result returned by getNextValue * - * @param Translate $langs Object langs - * @param societe $objsoc Object thirdparty - * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) - * @return string Example + * @param Translate $langs Object langs + * @param societe $objsoc Object thirdparty + * @param int $type Type of third party (1:customer, 2:supplier, -1:autodetect) + * @return string Example */ - function getExample($langs, $objsoc = 0, $type = -1) + public function getExample($langs, $objsoc = 0, $type = -1) { $langs->load("bills"); return $langs->trans("NoExample"); @@ -300,16 +303,17 @@ abstract class ModeleAccountancyCode * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } - /** Return version of module + /** + * Return version of module * - * @return string Version + * @return string Version */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); @@ -322,14 +326,14 @@ abstract class ModeleAccountancyCode } /** - * Return description of module parameters + * Return description of module parameters * - * @param Translate $langs Output language - * @param Societe $soc Third party object - * @param int $type -1=Nothing, 0=Customer, 1=Supplier - * @return string HTML translated description + * @param Translate $langs Output language + * @param Societe $soc Third party object + * @param int $type -1=Nothing, 0=Customer, 1=Supplier + * @return string HTML translated description */ - function getToolTip($langs, $soc, $type) + public function getToolTip($langs, $soc, $type) { global $conf,$db; @@ -358,7 +362,7 @@ abstract class ModeleAccountancyCode return $s; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set accountancy account code for a third party into this->code * @@ -367,7 +371,7 @@ abstract class ModeleAccountancyCode * @param int $type 'customer' or 'supplier' * @return int >=0 if OK, <0 if KO */ - function get_code($db, $societe, $type = '') + public function get_code($db, $societe, $type = '') { // phpcs:enable global $langs; @@ -377,8 +381,6 @@ abstract class ModeleAccountancyCode } - -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Create a document onto disk according to template module. * @@ -396,8 +398,7 @@ abstract class ModeleAccountancyCode */ function thirdparty_doc_create(DoliDB $db, Societe $object, $message, $modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - // phpcs:enable - dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); + dol_syslog(__METHOD__ . " is deprecated", LOG_WARNING); - return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); + return $object->generateDocument($modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } 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 c5bc5f53c8e..4c8f33b3506 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 @@ -61,7 +61,7 @@ class doc_generic_stock_odt extends ModelePDFStock * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -106,7 +106,7 @@ class doc_generic_stock_odt extends ModelePDFStock * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf, $langs; @@ -205,7 +205,7 @@ class doc_generic_stock_odt extends ModelePDFStock return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -217,7 +217,7 @@ class doc_generic_stock_odt extends ModelePDFStock * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $stock,$langs,$conf,$mysoc,$hookmanager,$user; @@ -357,13 +357,13 @@ class doc_generic_stock_odt extends ModelePDFStock // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( - $srctemplatepath, - array( - 'PATH_TO_TMP' => $conf->produit->dir_temp, - 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. - 'DELIMITER_LEFT' => '{', - 'DELIMITER_RIGHT' => '}' + $odfHandler = new odf( + $srctemplatepath, + array( + 'PATH_TO_TMP' => $conf->produit->dir_temp, + 'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy. + 'DELIMITER_LEFT' => '{', + 'DELIMITER_RIGHT' => '}' ) ); } diff --git a/htdocs/core/modules/stock/doc/pdf_standard.modules.php b/htdocs/core/modules/stock/doc/pdf_standard.modules.php index c46799b6e41..7f174149e09 100644 --- a/htdocs/core/modules/stock/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_standard.modules.php @@ -51,7 +51,7 @@ class pdf_standard extends ModelePDFStock */ public $description; - /** + /** * @var string document type */ public $type; @@ -177,7 +177,7 @@ class pdf_standard extends ModelePDFStock } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -189,7 +189,7 @@ class pdf_standard extends ModelePDFStock * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager; @@ -834,17 +834,17 @@ class pdf_standard extends ModelePDFStock /** * Show table for lines * - * @param TCPDF $pdf Object PDF - * @param string $tab_top Top position of table - * @param string $tab_height Height of table (rectangle) - * @param int $nexY Y (not used) - * @param Translate $outputlangs Langs object - * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title - * @param int $hidebottom Hide bottom bar of array - * @param string $currency Currency code - * @return void + * @param TCPDF $pdf Object PDF + * @param string $tab_top Top position of table + * @param string $tab_height Height of table (rectangle) + * @param int $nexY Y (not used) + * @param Translate $outputlangs Langs object + * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title + * @param int $hidebottom Hide bottom bar of array + * @param string $currency Currency code + * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -914,8 +914,7 @@ class pdf_standard extends ModelePDFStock if (empty($hidetop)) { $pdf->SetXY($this->posxunit - 1, $tab_top + 1); -$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '', - 'C'); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '', 'C'); } //$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); @@ -948,7 +947,7 @@ $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->tran * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") { global $conf,$langs,$db,$hookmanager; @@ -1176,7 +1175,7 @@ $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->tran * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php index 495dd3a6ef8..563c2ea1011 100644 --- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php +++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php @@ -179,7 +179,7 @@ class pdf_stdmovement extends ModelePDFMovement } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -191,7 +191,7 @@ class pdf_stdmovement extends ModelePDFMovement * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager; @@ -203,9 +203,9 @@ class pdf_stdmovement extends ModelePDFMovement // Load traductions files requiredby by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries")); - /** - * TODO: get from object - */ + /** + * TODO: get from object + */ $id=GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -327,9 +327,9 @@ class pdf_stdmovement extends ModelePDFMovement $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($result); - /* - * END TODO - **/ + /* + * END TODO + **/ //$nblignes = count($object->lines); @@ -822,7 +822,7 @@ class pdf_stdmovement extends ModelePDFMovement * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -948,7 +948,7 @@ class pdf_stdmovement extends ModelePDFMovement * @param string $titlekey Translation key to show as title of document * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") { global $conf,$langs,$db,$hookmanager; @@ -1168,15 +1168,15 @@ class pdf_stdmovement extends ModelePDFMovement } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param TCPDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param TCPDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/stock/modules_movement.php b/htdocs/core/modules/stock/modules_movement.php index b6298fa6cc9..76548664524 100644 --- a/htdocs/core/modules/stock/modules_movement.php +++ b/htdocs/core/modules/stock/modules_movement.php @@ -36,7 +36,7 @@ abstract class ModelePDFMovement extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -44,7 +44,7 @@ abstract class ModelePDFMovement extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/stock/modules_stock.php b/htdocs/core/modules/stock/modules_stock.php index c7d564ef082..a60437cd38a 100644 --- a/htdocs/core/modules/stock/modules_stock.php +++ b/htdocs/core/modules/stock/modules_stock.php @@ -19,25 +19,25 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; /** - * Parent class for stock models of doc generators + * Parent class for stock models of doc generators */ abstract class ModelePDFStock extends CommonDocGenerator { /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * - * @param DoliDB $db Database handler - * @param integer $maxfilenamelength Max length of value to show - * @return array List of templates + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php index 46707dfaa14..8302db4ab31 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php @@ -33,11 +33,11 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_invoice/modules_facturef */ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices { - /** + /** * Dolibarr version of the loaded document * @public string */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' + public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' /** * @var string Error code (or message) @@ -64,24 +64,24 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** - * Return description of numbering model + * Return description of numbering model * * @return string Text with description */ - function info() + public function info() { - global $langs; - $langs->load("bills"); - return $langs->trans("CactusNumRefModelDesc1", $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit); + global $langs; + $langs->load("bills"); + return $langs->trans("CactusNumRefModelDesc1", $this->prefixinvoice, $this->prefixcreditnote, $this->prefixdeposit); } /** - * Returns a numbering example + * Returns a numbering example * * @return string Example */ - function getExample() + public function getExample() { return $this->prefixinvoice."1301-0001"; } @@ -92,7 +92,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -164,13 +164,13 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** * Return next value - * - * @param Societe $objsoc Object third party - * @param Object $object Object invoice + * + * @param Societe $objsoc Object third party + * @param Object $object Object invoice * @param string $mode 'next' for next value or 'last' for last value - * @return string Value if OK, 0 if KO + * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object, $mode = 'next') + public function getNextValue($objsoc, $object, $mode = 'next') { global $db,$conf; @@ -236,14 +236,14 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices /** - * Return next free value - * + * Return next free value + * * @param Societe $objsoc Object third party * @param string $objforref Object for number to search * @param string $mode 'next' for next value or 'last' for last value * @return string Next free value */ - function getNumRef($objsoc, $objforref, $mode = 'next') + public function getNumRef($objsoc, $objforref, $mode = 'next') { return $this->getNextValue($objsoc, $objforref, $mode); } diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 4e2b84edcc8..7f85cbe5bb6 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -65,9 +65,9 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices * * @return string Description Text */ - function info() + public function info() { - global $conf, $langs; + global $conf, $langs; // Load translation files required by the page $langs->loadLangs(array("bills","admin")); @@ -98,7 +98,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $texte.= '
'; $texte.= ''; - + // Parametrage du prefix des avoirs $texte.= ''; $texte.= ''; @@ -129,7 +129,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -153,7 +153,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices * @param string $mode 'next' for next value or 'last' for last value * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object, $mode = 'next') + public function getNextValue($objsoc, $object, $mode = 'next') { global $db,$conf; @@ -182,18 +182,18 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices $numFinal=get_next_value($db, $mask, 'facture_fourn', 'ref', '', $objsoc, $object->date); return $numFinal; - } + } /** - * Return next free value - * - * @param Societe $objsoc Object third party - * @param string $objforref Object for number to search - * @param string $mode 'next' for next value or 'last' for last value - * @return string Next free value + * Return next free value + * + * @param Societe $objsoc Object third party + * @param string $objforref Object for number to search + * @param string $mode 'next' for next value or 'last' for last value + * @return string Next free value */ - function getNumRef($objsoc, $objforref, $mode = 'next') - { - return $this->getNextValue($objsoc, $objforref, $mode); - } + public function getNumRef($objsoc, $objforref, $mode = 'next') + { + return $this->getNextValue($objsoc, $objforref, $mode); + } } diff --git a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php index 593d4f9d51a..6949ae3924f 100644 --- a/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php +++ b/htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php @@ -40,7 +40,7 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models * @@ -48,7 +48,7 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of numbers */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -77,7 +77,7 @@ abstract class ModeleNumRefSuppliersInvoices * * @return boolean true if model can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -86,7 +86,7 @@ abstract class ModeleNumRefSuppliersInvoices * * @return string Description Text */ - function info() + public function info() { global $langs; $langs->load("invoices"); @@ -97,7 +97,7 @@ abstract class ModeleNumRefSuppliersInvoices * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("invoices"); @@ -108,7 +108,7 @@ abstract class ModeleNumRefSuppliersInvoices * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -120,18 +120,18 @@ abstract class ModeleNumRefSuppliersInvoices * @param string $mode 'next' for next value or 'last' for last value * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $object, $mode) - { + public function getNextValue($objsoc, $object, $mode) + { global $langs; return $langs->trans("NotAvailable"); - } + } /** Returns version of the model numbering * * @return string Value */ - function getVersion() - { + public function getVersion() + { global $langs; $langs->load("admin"); @@ -140,5 +140,5 @@ abstract class ModeleNumRefSuppliersInvoices if ($this->version == 'dolibarr') return DOL_VERSION; if ($this->version) return $this->version; return $langs->trans("NotAvailable"); - } + } } diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 2d2164ebeb1..7e3f7c68c88 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -117,8 +117,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { global $conf, $langs, $mysoc; // Load translation files required by the page @@ -180,10 +180,10 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->localtax2=array(); $this->atleastoneratenotnull=0; $this->atleastonediscount=0; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -195,8 +195,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { + public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { // phpcs:enable global $user,$langs,$conf,$mysoc,$hookmanager,$nblignes; @@ -608,9 +608,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices $this->error=$langs->trans("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR"); return 0; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -621,7 +621,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -832,7 +832,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -932,17 +932,17 @@ class pdf_canelle extends ModelePDFSuppliersInvoices } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * - * @param PDF $pdf Object PDF - * @param FactureFournisseur $object Object invoice - * @param int $posy Position y in PDF - * @param Translate $outputlangs Object langs for output - * @return int <0 if KO, >0 if OK + * @param PDF $pdf Object PDF + * @param FactureFournisseur $object Object invoice + * @param int $posy Position y in PDF + * @param Translate $outputlangs Object langs for output + * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -1028,13 +1028,13 @@ class pdf_canelle extends ModelePDFSuppliersInvoices /** * Show top header of page. * - * @param PDF $pdf Object PDF - * @param FactureFournisseur $object Object to show - * @param int $showaddress 0=no, 1=yes - * @param Translate $outputlangs Object lang for output - * @return void + * @param PDF $pdf Object PDF + * @param FactureFournisseur $object Object to show + * @param int $showaddress 0=no, 1=yes + * @param Translate $outputlangs Object lang for output + * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs, $conf, $mysoc; @@ -1238,19 +1238,19 @@ class pdf_canelle extends ModelePDFSuppliersInvoices return $top_shift; } - /** - * Show footer of page. Need this->emetteur object + /** + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param FactureFournisseur $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text - */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) - { - global $conf; - $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } + * @param PDF $pdf PDF + * @param FactureFournisseur $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + { + global $conf; + $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } } diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php index 4fb3f4b2e9d..6f0cb59ca89 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php @@ -60,7 +60,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders /** * Constructor */ - function __construct() + public function __construct() { global $conf; @@ -72,7 +72,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -84,7 +84,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -96,7 +96,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -132,7 +132,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * @param Object $object Object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = 0, $object = '') { global $db,$conf; @@ -163,7 +163,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la reference de commande suivante non utilisee * @@ -171,7 +171,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders * @param Object $object Object * @return string Texte descripif */ - function commande_get_num($objsoc = 0, $object = '') + public function commande_get_num($objsoc = 0, $object = '') { // phpcs:enable return $this->getNextValue($objsoc, $object); diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index 556ca56d2db..320c33dce7d 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -61,7 +61,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * * @return string Texte descripif */ - function info() + public function info() { global $db, $conf, $langs; @@ -102,7 +102,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -125,7 +125,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * @param Object $object Object * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc = 0, $object = '') + public function getNextValue($objsoc = 0, $object = '') { global $db,$conf; @@ -146,7 +146,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoie la reference de commande suivante non utilisee * @@ -154,7 +154,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders * @param Object $object Object * @return string Texte descripif */ - function commande_get_num($objsoc = 0, $object = '') + public function commande_get_num($objsoc = 0, $object = '') { // phpcs:enable return $this->getNextValue($objsoc, $object); diff --git a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php index b462814f624..e7cba73672d 100644 --- a/htdocs/core/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/core/modules/supplier_order/modules_commandefournisseur.php @@ -43,7 +43,7 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models * @@ -51,7 +51,7 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -82,7 +82,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return boolean true if model can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -91,7 +91,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return string Description Text */ - function info() + public function info() { global $langs; $langs->load("orders"); @@ -102,7 +102,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("orders"); @@ -113,7 +113,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return boolean false if conflict, true if ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -122,7 +122,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return string Valeur */ - function getNextValue() + public function getNextValue() { global $langs; return $langs->trans("NotAvailable"); @@ -132,7 +132,7 @@ abstract class ModeleNumRefSuppliersOrders * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); diff --git a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php index a95440ad42f..0cc9d4f6af3 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -120,7 +120,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -197,7 +197,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -209,7 +209,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$hookmanager,$mysoc,$nblignes; @@ -708,7 +708,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * @@ -718,13 +718,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -734,7 +734,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param Translate $outputlangs Langs object * @return integer */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -789,7 +789,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders return $posy; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -800,7 +800,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -1017,7 +1017,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1126,7 +1126,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs, $conf, $mysoc; @@ -1363,15 +1363,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders } /** - * Show footer of page. Need this->emetteur object + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param CommandeFournisseur $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text + * @param PDF $pdf PDF + * @param CommandeFournisseur $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 87b4791524e..cb52a14f721 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -117,7 +117,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -176,7 +176,7 @@ class pdf_standard extends ModelePDFSuppliersPayments } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -188,7 +188,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; @@ -517,7 +517,7 @@ class pdf_standard extends ModelePDFSuppliersPayments } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -527,7 +527,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_cheque(&$pdf, $object, $posy, $outputlangs) + private function _tableau_cheque(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -590,7 +590,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf,$mysoc; @@ -631,7 +631,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $langs, $conf, $mysoc; @@ -810,7 +810,7 @@ class pdf_standard extends ModelePDFSuppliersPayments * @param int $hidefreetext 1=Hide free text * @return int Return height of bottom margin including footer text */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php index a947573dd1a..c1f6e003d6d 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_brodator.php @@ -59,7 +59,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -99,7 +99,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -122,7 +122,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -143,7 +143,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -151,7 +151,7 @@ class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments * @param string $objforref Object for number to search * @return string Next free value */ - function commande_get_num($objsoc, $objforref) + public function commande_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php index 5ab0909e720..e071f8d5505 100644 --- a/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php +++ b/htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php @@ -60,7 +60,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -72,7 +72,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -84,7 +84,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -119,7 +119,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * @param Object $object Object we need next value for * @return string Value if KO, <0 if KO */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $db,$conf; @@ -155,7 +155,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return next free value * @@ -163,7 +163,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments * @param string $objforref Object for number to search * @return string Next free value */ - function payment_get_num($objsoc, $objforref) + public function payment_get_num($objsoc, $objforref) { // phpcs:enable return $this->getNextValue($objsoc, $objforref); diff --git a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php index f8afdeea063..a3f7495efb5 100644 --- a/htdocs/core/modules/supplier_payment/modules_supplier_payment.php +++ b/htdocs/core/modules/supplier_payment/modules_supplier_payment.php @@ -28,7 +28,7 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation models * @@ -36,7 +36,7 @@ abstract class ModelePDFSuppliersPayments extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of numbers */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -68,7 +68,7 @@ abstract class ModeleNumRefSupplierPayments * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -78,7 +78,7 @@ abstract class ModeleNumRefSupplierPayments * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("bills"); @@ -90,7 +90,7 @@ abstract class ModeleNumRefSupplierPayments * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("bills"); @@ -102,7 +102,7 @@ abstract class ModeleNumRefSupplierPayments * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -114,7 +114,7 @@ abstract class ModeleNumRefSupplierPayments * @param Object $object Object we need next value for * @return string Valeur */ - function getNextValue($objsoc, $object) + public function getNextValue($objsoc, $object) { global $langs; return $langs->trans("NotAvailable"); @@ -125,15 +125,15 @@ abstract class ModeleNumRefSupplierPayments * * @return string Value */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); if ($this->version == 'development') return $langs->trans("VersionDevelopment"); - if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); - if ($this->version == 'dolibarr') return DOL_VERSION; - if ($this->version) return $this->version; + elseif ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + elseif ($this->version == 'dolibarr') return DOL_VERSION; + elseif ($this->version) return $this->version; return $langs->trans("NotAvailable"); } } 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 27163ac32db..d2dffce83c4 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 @@ -62,7 +62,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -107,7 +107,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf, $langs; @@ -221,7 +221,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -233,7 +233,7 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; 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 faad9b8d66a..e5759d9ff6d 100644 --- a/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php @@ -193,7 +193,7 @@ class pdf_aurore extends ModelePDFSupplierProposal $this->atleastonediscount=0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * @@ -205,7 +205,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param int $hideref Do not show ref * @return int 1=OK, 0=KO */ - function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes; @@ -704,7 +704,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show payments table * @@ -714,13 +714,13 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Translate $outputlangs Object langs for output * @return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + private function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show miscellaneous information (payment mode, payment term, ...) * @@ -730,7 +730,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Translate $outputlangs Langs object * @return void */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) + private function _tableau_info(&$pdf, $object, $posy, $outputlangs) { // phpcs:enable global $conf; @@ -888,7 +888,7 @@ class pdf_aurore extends ModelePDFSupplierProposal } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Show total to pay * @@ -899,7 +899,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Translate $outputlangs Objet langs * @return int Position pour suite */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + private function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) { // phpcs:enable global $conf,$mysoc; @@ -1174,7 +1174,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param string $currency Currency code * @return void */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') + private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { global $conf; @@ -1283,7 +1283,7 @@ class pdf_aurore extends ModelePDFSupplierProposal * @param Translate $outputlangs Object lang for output * @return void */ - function _pagehead(&$pdf, $object, $showaddress, $outputlangs) + private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) { global $conf, $langs; @@ -1491,16 +1491,16 @@ class pdf_aurore extends ModelePDFSupplierProposal return $top_shift; } - /** - * Show footer of page. Need this->emetteur object + /** + * Show footer of page. Need this->emetteur object * - * @param PDF $pdf PDF - * @param Object $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text - */ - function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) + * @param PDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ + private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) { global $conf; $showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php index 7e80c009388..21c2a68e629 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php @@ -62,7 +62,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * * @return string Text with description */ - function info() + public function info() { global $langs; return $langs->trans("SimpleNumRefModelDesc", $this->prefix); @@ -74,7 +74,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * * @return string Example */ - function getExample() + public function getExample() { return $this->prefix."0501-0001"; } @@ -86,7 +86,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { global $conf,$langs,$db; @@ -124,7 +124,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * @param Propal $supplier_proposal Object commercial proposal * @return string Next value */ - function getNextValue($objsoc, $supplier_proposal) + public function getNextValue($objsoc, $supplier_proposal) { global $db,$conf; @@ -165,7 +165,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal * @param Object $objforref Object for number to search * @return string Next free value */ - function getNumRef($objsoc, $objforref) + public function getNumRef($objsoc, $objforref) { return $this->getNextValue($objsoc, $objforref); } diff --git a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php index 5ae686f3542..f8cd365d5a7 100644 --- a/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php +++ b/htdocs/core/modules/supplier_proposal/mod_supplier_proposal_saphir.php @@ -62,7 +62,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal * * @return string Texte descripif */ - function info() + public function info() { global $conf, $langs; @@ -102,7 +102,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal * * @return string Example */ - function getExample() + public function getExample() { global $conf,$langs,$mysoc; @@ -125,7 +125,7 @@ class mod_supplier_proposal_saphir extends ModeleNumRefSupplierProposal * @param Propal $supplier_proposal Object supplier_proposal * @return string Value if OK, 0 if KO */ - function getNextValue($objsoc, $supplier_proposal) + public function getNextValue($objsoc, $supplier_proposal) { global $db,$conf; diff --git a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php index 8b09d011da4..a7c12a9aeed 100644 --- a/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php +++ b/htdocs/core/modules/supplier_proposal/modules_supplier_proposal.php @@ -42,7 +42,7 @@ abstract class ModelePDFSupplierProposal extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -50,7 +50,7 @@ abstract class ModelePDFSupplierProposal extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; @@ -81,7 +81,7 @@ abstract class ModeleNumRefSupplierProposal * * @return boolean true if module can be used */ - function isEnabled() + public function isEnabled() { return true; } @@ -91,7 +91,7 @@ abstract class ModeleNumRefSupplierProposal * * @return string Texte descripif */ - function info() + public function info() { global $langs; $langs->load("supplier_proposal"); @@ -103,7 +103,7 @@ abstract class ModeleNumRefSupplierProposal * * @return string Example */ - function getExample() + public function getExample() { global $langs; $langs->load("supplier_proposal"); @@ -116,7 +116,7 @@ abstract class ModeleNumRefSupplierProposal * * @return boolean false si conflit, true si ok */ - function canBeActivated() + public function canBeActivated() { return true; } @@ -128,7 +128,7 @@ abstract class ModeleNumRefSupplierProposal * @param Propal $propal Object commercial proposal * @return string Valeur */ - function getNextValue($objsoc, $propal) + public function getNextValue($objsoc, $propal) { global $langs; return $langs->trans("NotAvailable"); @@ -139,7 +139,7 @@ abstract class ModeleNumRefSupplierProposal * * @return string Valeur */ - function getVersion() + public function getVersion() { global $langs; $langs->load("admin"); 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 b58c327e1bc..80e95037d24 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 @@ -59,7 +59,7 @@ class doc_generic_user_odt extends ModelePDFUser * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -104,7 +104,7 @@ class doc_generic_user_odt extends ModelePDFUser * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf, $langs; @@ -203,9 +203,9 @@ class doc_generic_user_odt extends ModelePDFUser return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Function to build a document on disk using the generic odt module. + * Function to build a document on disk using the generic odt module. * * @param User $object Object source to build document * @param Translate $outputlangs Lang output object @@ -215,7 +215,7 @@ class doc_generic_user_odt extends ModelePDFUser * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; @@ -330,7 +330,7 @@ class doc_generic_user_odt extends ModelePDFUser // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->user->dir_temp, @@ -439,7 +439,7 @@ class doc_generic_user_odt extends ModelePDFUser return -1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * get substitution array for object * @@ -448,7 +448,7 @@ class doc_generic_user_odt extends ModelePDFUser * @param string $array_key key for array * @return array array of substitutions */ - function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') + public function get_substitutionarray_object($object, $outputlangs, $array_key = 'object') { // phpcs:enable $array_other = array(); diff --git a/htdocs/core/modules/user/modules_user.class.php b/htdocs/core/modules/user/modules_user.class.php index 7add1cf99d1..bdd04f1c097 100644 --- a/htdocs/core/modules/user/modules_user.class.php +++ b/htdocs/core/modules/user/modules_user.class.php @@ -44,7 +44,7 @@ abstract class ModelePDFUser extends CommonDocGenerator public $error=''; - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of active generation modules * @@ -52,7 +52,7 @@ abstract class ModelePDFUser extends CommonDocGenerator * @param integer $maxfilenamelength Max length of value to show * @return array List of templates */ - static function liste_modeles($db, $maxfilenamelength = 0) + public static function liste_modeles($db, $maxfilenamelength = 0) { // phpcs:enable global $conf; 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 2dfd2cfcfee..0840f40a868 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 @@ -62,7 +62,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf, $langs, $mysoc; @@ -107,7 +107,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup * @param Translate $langs Lang object to use for output * @return string Description */ - function info($langs) + public function info($langs) { global $conf,$langs; @@ -206,7 +206,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -218,7 +218,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { // phpcs:enable global $user, $langs, $conf, $mysoc, $hookmanager; @@ -353,7 +353,7 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->user->dir_temp, @@ -527,6 +527,6 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup } } - return -1; - } + return -1; + } } diff --git a/htdocs/core/modules/usergroup/modules_usergroup.class.php b/htdocs/core/modules/usergroup/modules_usergroup.class.php index 2bd717624d7..6259366aeed 100644 --- a/htdocs/core/modules/usergroup/modules_usergroup.class.php +++ b/htdocs/core/modules/usergroup/modules_usergroup.class.php @@ -38,30 +38,30 @@ */ abstract class ModelePDFUserGroup extends CommonDocGenerator { - /** - * @var string Error code (or message) - */ - public $error=''; - - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Return list of active generation modules - * + * @var string Error code (or message) + */ + public $error=''; + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return list of active generation modules + * * @param DoliDB $db Database handler * @param integer $maxfilenamelength Max length of value to show * @return array List of templates - */ - static function liste_modeles($db, $maxfilenamelength = 0) - { + */ + public static function liste_modeles($db, $maxfilenamelength = 0) + { // phpcs:enable - global $conf; + global $conf; - $type = 'group'; - $list = array(); + $type = 'group'; + $list = array(); - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $list = getListOfModels($db, $type, $maxfilenamelength); - return $list; - } + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $list = getListOfModels($db, $type, $maxfilenamelength); + return $list; + } } diff --git a/htdocs/core/triggers/dolibarrtriggers.class.php b/htdocs/core/triggers/dolibarrtriggers.class.php index a66eb12c78e..19518b60e6c 100644 --- a/htdocs/core/triggers/dolibarrtriggers.class.php +++ b/htdocs/core/triggers/dolibarrtriggers.class.php @@ -134,16 +134,16 @@ abstract class DolibarrTriggers } } - /** - * Function called when a Dolibarrr business event is done. - * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) - * - * @param string $action Event action code - * @param Object $object Object - * @param User $user Object user - * @param Translate $langs Object langs - * @param conf $conf Object conf - * @return int <0 if KO, 0 if no triggered ran, >0 if OK - */ - abstract function runTrigger($action, $object, User $user, Translate $langs, Conf $conf); + /** + * Function called when a Dolibarrr business event is done. + * All functions "runTrigger" are triggered if file is inside directory htdocs/core/triggers or htdocs/module/code/triggers (and declared) + * + * @param string $action Event action code + * @param Object $object Object + * @param User $user Object user + * @param Translate $langs Object langs + * @param conf $conf Object conf + * @return int <0 if KO, 0 if no triggered ran, >0 if OK + */ + public abstract function runTrigger($action, $object, User $user, Translate $langs, Conf $conf); } diff --git a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php index 8570eaba8d1..ec195030448 100644 --- a/htdocs/core/triggers/interface_50_modNotification_Notification.class.php +++ b/htdocs/core/triggers/interface_50_modNotification_Notification.class.php @@ -96,7 +96,7 @@ class InterfaceNotification extends DolibarrTriggers * * @return array Array of events managed by notification module */ - function getListOfManagedEvents() + public function getListOfManagedEvents() { global $conf; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index b4289f60f36..1f22e7b910c 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -108,7 +108,7 @@ class Cronjob extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -121,7 +121,7 @@ class Cronjob extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -302,7 +302,7 @@ class Cronjob extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -393,7 +393,7 @@ class Cronjob extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load object in memory from the database * @@ -406,7 +406,7 @@ class Cronjob extends CommonObject * @param int $processing Processing or not * @return int <0 if KO, >0 if OK */ - function fetch_all($sortorder = 'DESC', $sortfield = 't.rowid', $limit = 0, $offset = 0, $status = 1, $filter = '', $processing = -1) + public function fetch_all($sortorder = 'DESC', $sortfield = 't.rowid', $limit = 0, $offset = 0, $status = 1, $filter = '', $processing = -1) { // phpcs:enable global $langs; @@ -541,7 +541,7 @@ class Cronjob extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -691,37 +691,21 @@ class Cronjob extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { $error=0; $this->db->begin(); -// if (! $error) -// { -// if (! $notrigger) -// { - // Uncomment this and change MYOBJECT to your own tag if you - // want this action calls a trigger. + $sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob"; + $sql.= " WHERE rowid=".$this->id; - //// Call triggers - //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - //$interface=new Interfaces($this->db); - //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); - //if ($result < 0) { $error++; $this->errors=$interface->errors; } - //// End call triggers -// } -// } - -// if (! $error) -// { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."cronjob"; - $sql.= " WHERE rowid=".$this->id; - - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } -// } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { + $error++; + $this->errors[]="Error ".$this->db->lasterror(); + } // Commit or rollback if ($error) @@ -749,7 +733,7 @@ class Cronjob extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -805,7 +789,7 @@ class Cronjob extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; $this->ref=0; @@ -852,7 +836,7 @@ class Cronjob extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -909,7 +893,7 @@ class Cronjob extends CommonObject * * @return int */ - function info() + public function info() { $sql = "SELECT"; $sql.= " f.rowid, f.datec, f.tms, f.fk_user_mod, f.fk_user_author"; @@ -941,7 +925,7 @@ class Cronjob extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Run a job. * Once job is finished, status and nb of run is updated. @@ -950,7 +934,7 @@ class Cronjob extends CommonObject * @param string $userlogin User login * @return int <0 if KO, >0 if OK */ - function run_jobs($userlogin) + public function run_jobs($userlogin) { // phpcs:enable global $langs, $conf, $hookmanager; @@ -1127,8 +1111,7 @@ class Cronjob extends CommonObject } } - if($this->jobtype == 'function') - { + if ($this->jobtype == 'function') { //load lib $libpath = '/' . strtolower($this->module_name) . '/lib/' . $this->libname; $ret = dol_include_once($libpath); @@ -1219,7 +1202,7 @@ class Cronjob extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reprogram a job * @@ -1227,7 +1210,7 @@ class Cronjob extends CommonObject * @param timestamp $now Date returned by dol_now() * @return int <0 if KO, >0 if OK */ - function reprogram_jobs($userlogin, $now) + public function reprogram_jobs($userlogin, $now) { // phpcs:enable dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG); @@ -1303,12 +1286,12 @@ class Cronjob extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode, $this->processing); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -1317,7 +1300,7 @@ class Cronjob extends CommonObject * @param int $processing 0=Not running, 1=Running * @return string Label of status */ - function LibStatut($status, $mode = 0, $processing = 0) + public function LibStatut($status, $mode = 0, $processing = 0) { // phpcs:enable global $langs; @@ -1351,12 +1334,12 @@ class Cronjob extends CommonObject if ($status == 1) return img_picto($langs->trans('Enabled').$moretext, 'statut'.($processing?'1':'4'), 'class="pictostatus"').' '.$langs->trans('Enabled').$moretext; elseif ($status == 0) return img_picto($langs->trans('Disabled').$moretext, 'statut5', 'class="pictostatus"').' '.$langs->trans('Disabled').$moretext; } - elseif ($mode == 5) - { - if ($status == 1) return $langs->trans('Enabled').$moretext.' '.img_picto($langs->trans('Enabled').$moretext, 'statut'.($processing?'1':'4'), 'class="pictostatus"'); - elseif ($status == 0) return $langs->trans('Disabled').$moretext.' '.img_picto($langs->trans('Disabled').$moretext, 'statut5', 'class="pictostatus"'); - } - } + elseif ($mode == 5) + { + if ($status == 1) return $langs->trans('Enabled').$moretext.' '.img_picto($langs->trans('Enabled').$moretext, 'statut'.($processing?'1':'4'), 'class="pictostatus"'); + elseif ($status == 0) return $langs->trans('Disabled').$moretext.' '.img_picto($langs->trans('Disabled').$moretext, 'statut5', 'class="pictostatus"'); + } + } } @@ -1425,7 +1408,7 @@ class Cronjobline * Constructor * */ - function __construct() + public function __construct() { return 1; } diff --git a/htdocs/datapolicy/class/actions_datapolicy.class.php b/htdocs/datapolicy/class/actions_datapolicy.class.php index 7362542e8d6..e336e8d6df6 100644 --- a/htdocs/datapolicy/class/actions_datapolicy.class.php +++ b/htdocs/datapolicy/class/actions_datapolicy.class.php @@ -72,7 +72,7 @@ class ActionsDatapolicy * =0 if OK but we want to process standard actions too, * >0 if OK and we want to replace standard actions. */ - function getNomUrl($parameters, &$object, &$action) + public function getNomUrl($parameters, &$object, &$action) { global $db, $langs, $conf, $user; $this->resprints = ''; @@ -300,7 +300,7 @@ class ActionsDatapolicy * =0 if OK but we want to process standard actions too, * >0 if OK and we want to replace standard actions. */ - function beforePDFCreation($parameters, &$object, &$action) + public function beforePDFCreation($parameters, &$object, &$action) { global $conf, $user, $langs; global $hookmanager; @@ -329,7 +329,7 @@ class ActionsDatapolicy * @param HookManager $hookmanager Hook manager * @return void */ - function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) + public function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) { global $conf, $user, $langs; $langs->load('datapolicy@datapolicy'); @@ -388,7 +388,7 @@ class ActionsDatapolicy * @param HookManager $hookmanager Hook manager * @return void */ - function printCommonFooter($parameters, &$object, &$action, $hookmanager) + public function printCommonFooter($parameters, &$object, &$action, $hookmanager) { global $conf, $user, $langs; diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index 01953fba0ee..ea720e0586f 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -35,7 +35,7 @@ Class DataPolicy * * @return number */ - function getAllContactNotInformed() + public function getAllContactNotInformed() { global $langs, $conf, $db, $user; @@ -71,7 +71,7 @@ Class DataPolicy * * @return number */ - function getAllCompaniesNotInformed() + public function getAllCompaniesNotInformed() { global $langs, $conf, $db, $user; @@ -106,7 +106,7 @@ Class DataPolicy * * @return number */ - function getAllAdherentsNotInformed() + public function getAllAdherentsNotInformed() { global $langs, $conf, $db, $user; @@ -142,73 +142,73 @@ Class DataPolicy * @param mixed $contact Contact * @return void */ - function sendMailDataPolicyContact($contact) + public function sendMailDataPolicyContact($contact) { - global $langs, $conf, $db, $user; + global $langs, $conf, $db, $user; - $error = 0; + $error = 0; - $from = $user->getFullName($langs) . ' <' . $user->email . '>'; + $from = $user->getFullName($langs) . ' <' . $user->email . '>'; - $sendto = $contact->email; - $code= md5($contact->email); - if (!empty($contact->default_lang)) { - $l = $contact->default_lang; - } else { - $l = $langs->defaultlang; - } - $s = "DATAPOLICIESSUBJECT_" . $l; - $ma = "DATAPOLICIESCONTENT_" . $l; - $la = 'TXTLINKDATAPOLICIESACCEPT_' . $l; - $lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l; + $sendto = $contact->email; + $code= md5($contact->email); + if (!empty($contact->default_lang)) { + $l = $contact->default_lang; + } else { + $l = $langs->defaultlang; + } + $s = "DATAPOLICIESSUBJECT_" . $l; + $ma = "DATAPOLICIESCONTENT_" . $l; + $la = 'TXTLINKDATAPOLICIESACCEPT_' . $l; + $lr = 'TXTLINKDATAPOLICIESREFUSE_' . $l; - $subject = $conf->global->$s; - $message = $conf->global->$ma; - $linka = $conf->global->$la; - $linkr = $conf->global->$lr; - $sendtocc = $sendtobcc = ''; - $filepath = $mimetype = $filename = array(); - $deliveryreceipt = 0; + $subject = $conf->global->$s; + $message = $conf->global->$ma; + $linka = $conf->global->$la; + $linkr = $conf->global->$lr; + $sendtocc = $sendtobcc = ''; + $filepath = $mimetype = $filename = array(); + $deliveryreceipt = 0; - $substitutionarray = array( - '__LINKACCEPT__' => ''.$linka.'', - '__LINKREFUSED__' => ''.$linkr.'', - '__FIRSTNAME__' => $contact->firstname, - '__NAME__' => $contact->lastname, - '__CIVILITY__' => $contact->civility, - ); - $subject = make_substitutions($subject, $substitutionarray); - $message = make_substitutions($message, $substitutionarray); + $substitutionarray = array( + '__LINKACCEPT__' => ''.$linka.'', + '__LINKREFUSED__' => ''.$linkr.'', + '__FIRSTNAME__' => $contact->firstname, + '__NAME__' => $contact->lastname, + '__CIVILITY__' => $contact->civility, + ); + $subject = make_substitutions($subject, $substitutionarray); + $message = make_substitutions($message, $substitutionarray); - $actiontypecode = 'AC_EMAIL'; - $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; - if ($message) { - if ($sendtocc) - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg = dol_concatdesc($actionmsg, $message); - } + $actiontypecode = 'AC_EMAIL'; + $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; + if ($message) { + if ($sendtocc) + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); + } - // Send mail - require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1); + // Send mail + require_once DOL_DOCUMENT_ROOT . '/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject, $sendto, $from, $message, $filepath, $mimetype, $filename, $sendtocc, $sendtobcc, $deliveryreceipt, -1); - if ($mailfile->error) { - $resultmasssend .= '
' . $mailfile->error . '
'; - } else { - $result4 = $mailfile->sendfile(); - if (!$error) { + if ($mailfile->error) { + $resultmasssend .= '
' . $mailfile->error . '
'; + } else { + $result4 = $mailfile->sendfile(); + if (!$error) { - $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; - $contact->array_options['options_datapolicy_send'] = date('Y-m-d', time()); - $contact->update($contact->id); - } else { - dol_print_error($db); - } - } - setEventMessage($resultmasssend); + $resultmasssend .= $langs->trans("MailSent") . ': ' . $sendto . "
"; + $contact->array_options['options_datapolicy_send'] = date('Y-m-d', time()); + $contact->update($contact->id); + } else { + dol_print_error($db); + } + } + setEventMessage($resultmasssend); } /** @@ -217,7 +217,7 @@ Class DataPolicy * @param Societe $societe Object societe * @return void */ - function sendMailDataPolicyCompany($societe) + public function sendMailDataPolicyCompany($societe) { global $langs, $conf, $db, $user; @@ -291,7 +291,7 @@ Class DataPolicy * @param Adherent $adherent Member * @return void */ - function sendMailDataPolicyAdherent($adherent) + public function sendMailDataPolicyAdherent($adherent) { global $langs, $conf, $db, $user; diff --git a/htdocs/dav/dav.class.php b/htdocs/dav/dav.class.php index 226fdf48c94..eea023951e3 100644 --- a/htdocs/dav/dav.class.php +++ b/htdocs/dav/dav.class.php @@ -41,7 +41,7 @@ class CdavLib * @param DoliDB $db Database handler * @param Translate $langs translation */ - function __construct($user, $db, $langs) + public function __construct($user, $db, $langs) { $this->user = $user; $this->db = $db; @@ -245,15 +245,15 @@ class CdavLib return $caldata; } - /** - * getFullCalendarObjects - * - * @param int $calendarId Calendar id - * @param int $bCalendarData Add calendar data - * @return array|string[][] - */ - public function getFullCalendarObjects($calendarId, $bCalendarData) - { + /** + * getFullCalendarObjects + * + * @param int $calendarId Calendar id + * @param int $bCalendarData Add calendar data + * @return array|string[][] + */ + public function getFullCalendarObjects($calendarId, $bCalendarData) + { $calid = ($calendarId*1); $calevents = array(); diff --git a/htdocs/don/class/api_donations.class.php b/htdocs/don/class/api_donations.class.php index de854ce806d..06ddd5616c0 100644 --- a/htdocs/don/class/api_donations.class.php +++ b/htdocs/don/class/api_donations.class.php @@ -44,10 +44,10 @@ class Donations extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->don = new Don($this->db); } @@ -61,7 +61,7 @@ class Donations extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { if(! DolibarrApiAccess::$user->rights->don->lire) { throw new RestException(401); @@ -99,7 +99,7 @@ class Donations extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -115,7 +115,7 @@ class Donations extends DolibarrApi $sql.= ' WHERE t.entity IN ('.getEntity('don').')'; if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) ) $sql.= " AND t.fk_soc = sc.fk_soc"; if ($thirdparty_ids) $sql.= " AND t.fk_soc = ".$thirdparty_ids." "; - + // Add sql filters if ($sqlfilters) { @@ -140,7 +140,7 @@ class Donations extends DolibarrApi dol_syslog("API Rest request"); $result = $db->query($sql); - + if ($result) { $num = $db->num_rows($result); @@ -164,7 +164,7 @@ class Donations extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No donation found'); } - + return $obj_ret; } @@ -174,15 +174,15 @@ class Donations extends DolibarrApi * @param array $request_data Request data * @return int ID of order */ - function post($request_data = null) + public function post($request_data = null) { - if(! DolibarrApiAccess::$user->rights->don->creer) { + if (! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401, "Insuffisant rights"); } // Check mandatory fields $result = $this->_validate($request_data); - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { $this->don->$field = $value; } /*if (isset($request_data["lines"])) { @@ -208,7 +208,7 @@ class Donations extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); @@ -222,7 +222,7 @@ class Donations extends DolibarrApi if (! DolibarrApi::_checkAccessToResource('donation', $this->don->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - foreach($request_data as $field => $value) { + foreach ($request_data as $field => $value) { if ($field == 'id') continue; $this->don->$field = $value; } @@ -243,7 +243,7 @@ class Donations extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->don->supprimer) { throw new RestException(401); @@ -291,7 +291,7 @@ class Donations extends DolibarrApi * * @return array */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->don->creer) { throw new RestException(401); @@ -332,7 +332,7 @@ class Donations extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -354,7 +354,7 @@ class Donations extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $don = array(); foreach (Orders::$FIELDS as $field) { diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index f361299f83a..834f16c7737 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2016 Juanjo Menent * Copyright (C) 2019 Thibault FOUCART + * Copyright (C) 2019 Frédéric France * * 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 @@ -103,7 +104,7 @@ class Don extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -115,12 +116,12 @@ class Don extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -128,7 +129,7 @@ class Don extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable if (empty($this->labelstatut) || empty($this->labelstatutshort)) @@ -198,7 +199,7 @@ class Don extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $conf, $user,$langs; @@ -257,7 +258,7 @@ class Don extends CommonObject * @param int $minimum Minimum * @return int 0 if KO, >0 if OK */ - function check($minimum = 0) + public function check($minimum = 0) { global $langs; $langs->load('main'); @@ -350,7 +351,7 @@ class Don extends CommonObject * @return int <0 if KO, id of created donation if OK * TODO add numbering module for Ref */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -429,7 +430,7 @@ class Don extends CommonObject // End call triggers } } - else + else { $this->error = $this->db->lasterror(); $this->errno = $this->db->lasterrno(); @@ -473,7 +474,7 @@ class Don extends CommonObject * @param int $notrigger Disable triggers * @return int >0 if OK, <0 if KO */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs, $conf; @@ -564,7 +565,7 @@ class Don extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, 0 if not possible, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $user, $conf, $langs; require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -639,7 +640,7 @@ class Don extends CommonObject * @param string $ref Ref of donation to load * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $conf; @@ -729,12 +730,12 @@ class Don extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function setValid($user, $notrigger = 0) + public function setValid($user, $notrigger = 0) { return $this->valid_promesse($this->id, $user->id, $notrigger); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Validate a promise of donation * @@ -743,7 +744,7 @@ class Don extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function valid_promesse($id, $userid, $notrigger = 0) + public function valid_promesse($id, $userid, $notrigger = 0) { // phpcs:enable global $langs, $user; @@ -786,7 +787,7 @@ class Don extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Classify the donation as paid, the donation was received * @@ -794,7 +795,7 @@ class Don extends CommonObject * @param int $modepayment mode of payment * @return int <0 if KO, >0 if OK */ - function set_paid($id, $modepayment = 0) + public function set_paid($id, $modepayment = 0) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2"; @@ -823,14 +824,14 @@ class Don extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set donation to status cancelled * * @param int $id id of donation * @return int <0 if KO, >0 if OK */ - function set_cancel($id) + public function set_cancel($id) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = -1 WHERE rowid = ".$id; @@ -854,14 +855,14 @@ class Don extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Sum of donations * * @param string $param 1=promesses de dons validees , 2=xxx, 3=encaisses * @return int Summ of donations */ - function sum_donations($param) + public function sum_donations($param) { // phpcs:enable global $conf; @@ -883,13 +884,13 @@ class Don extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb pour le tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -926,7 +927,7 @@ class Don extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $notooltip = 0) + public function getNomUrl($withpicto = 0, $notooltip = 0) { global $langs; @@ -950,7 +951,7 @@ class Don extends CommonObject * @param int $id Id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT d.rowid, d.datec, d.fk_user_author, d.fk_user_valid,'; $sql.= ' d.tms'; diff --git a/htdocs/don/class/donstats.class.php b/htdocs/don/class/donstats.class.php index 2418f1babfd..bf6a61bb248 100644 --- a/htdocs/don/class/donstats.class.php +++ b/htdocs/don/class/donstats.class.php @@ -39,12 +39,12 @@ class DonationStats extends Stats */ public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -55,7 +55,7 @@ class DonationStats extends Stats * @param string $mode Option (not used) * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -77,13 +77,13 @@ class DonationStats extends Stats } /** - * Return shipment number by month for a year + * Return shipment number by month for a year * - * @param int $year Year to scan - * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @return array Array with number by month + * @param int $year Year to scan + * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month + * @return array Array with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -104,7 +104,7 @@ class DonationStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -117,21 +117,21 @@ class DonationStats extends Stats return $this->_getNbByYear($sql); } - /** - * Return nb, total and average - * - * @return array Array of values - */ - function getAllByYear() - { - global $user; + /** + * Return nb, total and average + * + * @return array Array of values + */ + public function getAllByYear() + { + global $user; - $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; - $sql.= " FROM ".$this->from; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + $sql = "SELECT date_format(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg"; + $sql.= " FROM ".$this->from; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index deec339c1cc..ac35e3f5c44 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -88,7 +88,7 @@ class PaymentDonation extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -101,7 +101,7 @@ class PaymentDonation extends CommonObject * @param bool $notrigger false=launch triggers after, true=disable triggers * @return int <0 if KO, id of payment if OK */ - function create($user, $notrigger = false) + public function create($user, $notrigger = false) { global $conf, $langs; @@ -193,7 +193,7 @@ class PaymentDonation extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -264,7 +264,7 @@ class PaymentDonation extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -344,7 +344,7 @@ class PaymentDonation extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -411,7 +411,7 @@ class PaymentDonation extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -467,12 +467,12 @@ class PaymentDonation extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -480,13 +480,13 @@ class PaymentDonation extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($statut, $mode = 0) - { + public function LibStatut($statut, $mode = 0) + { // phpcs:enable global $langs; - return ''; - } + return ''; + } /** @@ -496,7 +496,7 @@ class PaymentDonation extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -526,7 +526,7 @@ class PaymentDonation extends CommonObject * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ - function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $conf; @@ -597,14 +597,14 @@ class PaymentDonation extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** * Update link between the donation payment and the generated line in llx_bank * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; @@ -629,7 +629,7 @@ class PaymentDonation extends CommonObject * @param int $maxlen Longueur max libelle * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 1d2b7f34ba6..d0f4f3e6567 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -105,7 +105,7 @@ class EcmDirectory // extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; return 1; @@ -118,7 +118,7 @@ class EcmDirectory // extends CommonObject * @param User $user User that create * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -230,7 +230,7 @@ class EcmDirectory // extends CommonObject * @param int $notrigger 0=no, 1=yes (no update trigger) * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; @@ -288,7 +288,7 @@ class EcmDirectory // extends CommonObject * @param string $value '+' or '-' or new number * @return int <0 if KO, >0 if OK */ - function changeNbOfFiles($value) + public function changeNbOfFiles($value) { // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."ecm_directories SET"; @@ -320,7 +320,7 @@ class EcmDirectory // extends CommonObject * @param int $id Id of object * @return int <0 if KO, 0 if not found, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = "SELECT"; $sql.= " t.rowid,"; @@ -375,7 +375,7 @@ class EcmDirectory // extends CommonObject * @param int $deletedirrecursive 1=Agree to delete content recursiveley (otherwise an error will be returned when trying to delete) * @return int <0 if KO, >0 if OK */ - function delete($user, $mode = 'all', $deletedirrecursive = 0) + public function delete($user, $mode = 'all', $deletedirrecursive = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -448,7 +448,7 @@ class EcmDirectory // extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -468,7 +468,7 @@ class EcmDirectory // extends CommonObject * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $more = '', $notooltip = 0) { global $langs; @@ -501,7 +501,7 @@ class EcmDirectory // extends CommonObject * @param int $force Force reload of full arbo even if already loaded * @return string Relative physical path */ - function getRelativePath($force = 0) + public function getRelativePath($force = 0) { $this->get_full_arbo($force); @@ -535,13 +535,13 @@ class EcmDirectory // extends CommonObject return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load this->motherof that is array(id_son=>id_parent, ...) * * @return int <0 if KO, >0 if OK */ - function load_motherof() + public function load_motherof() { // phpcs:enable global $conf; @@ -579,12 +579,12 @@ class EcmDirectory // extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -592,7 +592,7 @@ class EcmDirectory // extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto * @return string Label of status */ - static function LibStatut($status, $mode = 0) + public static function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -600,7 +600,7 @@ class EcmDirectory // extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reconstruit l'arborescence des categories sous la forme d'un tableau à partir de la base de donnée * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: @@ -620,7 +620,7 @@ class EcmDirectory // extends CommonObject * @param int $force Force reload of full arbo even if already loaded in cache $this->cats * @return array Tableau de array */ - function get_full_arbo($force = 0) + public function get_full_arbo($force = 0) { // phpcs:enable global $conf; @@ -701,7 +701,7 @@ class EcmDirectory // extends CommonObject return $this->cats; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define properties fullpath, fullrelativename, fulllabel of a directory of array this->cats and all its childs. * Separator between directories is always '/', whatever is OS. @@ -710,7 +710,7 @@ class EcmDirectory // extends CommonObject * @param int $protection Deep counter to avoid infinite loop * @return void */ - function build_path_from_id_categ($id_categ, $protection = 0) + public function build_path_from_id_categ($id_categ, $protection = 0) { // phpcs:enable // Define fullpath @@ -750,7 +750,7 @@ class EcmDirectory // extends CommonObject * @param int $all 0=refresh record using this->id , 1=refresh record using this->entity * @return int -1 if KO, Nb of files in directory if OK */ - function refreshcachenboffile($all = 0) + public function refreshcachenboffile($all = 0) { global $conf; include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -787,7 +787,7 @@ class EcmDirectory // extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Call trigger based on this instance * @@ -799,7 +799,7 @@ class EcmDirectory // extends CommonObject * @param User $user Object user * @return int Result of run_triggers */ - function call_trigger($trigger_name, $user) + public function call_trigger($trigger_name, $user) { // phpcs:enable global $langs,$conf; diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index 3b229f48c1c..4f4c8dfea61 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -28,8 +28,6 @@ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; -//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; /** * Class to manage ECM files @@ -766,7 +764,7 @@ class EcmFiles extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $db, $conf, $langs; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -815,12 +813,12 @@ class EcmFiles extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the status * @@ -828,7 +826,7 @@ class EcmFiles extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 5=Long label + Picto * @return string Label of status */ - static function LibStatut($status, $mode = 0) + public static function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; diff --git a/htdocs/ecm/class/htmlecm.form.class.php b/htdocs/ecm/class/htmlecm.form.class.php index 7877b85b0a5..c210d0ae2d4 100644 --- a/htdocs/ecm/class/htmlecm.form.class.php +++ b/htdocs/ecm/class/htmlecm.form.class.php @@ -27,15 +27,15 @@ require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php'; */ class FormEcm { - /** + /** * @var DoliDB Database handler. */ public $db; - - /** - * @var string Error code (or message) - */ - public $error=''; + + /** + * @var string Error code (or message) + */ + public $error=''; /** @@ -43,7 +43,7 @@ class FormEcm * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -57,7 +57,7 @@ class FormEcm * @param string $module Module ('ecm', 'medias', ...) * @return string String with HTML select */ - function selectAllSections($selected = 0, $select_name = '', $module = 'ecm') + public function selectAllSections($selected = 0, $select_name = '', $module = 'ecm') { global $conf, $langs; $langs->load("ecm"); @@ -70,7 +70,7 @@ class FormEcm $cat = new EcmDirectory($this->db); $cate_arbo = $cat->get_full_arbo(); } - if ($module == 'medias') + elseif ($module == 'medias') { include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $path = $conf->medias->multidir_output[$conf->entity]; diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 7a4744d789f..e0f745dabec 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -99,22 +99,22 @@ class EmailCollector extends CommonObject 'login' => array('type'=>'varchar(128)', 'label'=>'Login', 'visible'=>1, 'enabled'=>1, 'position'=>101, 'notnull'=>-1, 'index'=>1, 'comment'=>"IMAP login", 'help'=>'Example: myaccount@gmail.com'), 'password' => array('type'=>'password', 'label'=>'Password', 'visible'=>-1, 'enabled'=>1, 'position'=>102, 'notnull'=>-1, 'comment'=>"IMAP password"), 'source_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxSourceDirectory', 'visible'=>-1, 'enabled'=>1, 'position'=>103, 'notnull'=>1, 'default' => 'Inbox', 'help'=>'Example: INBOX'), - //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), - //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), + //'filter' => array('type'=>'text', 'label'=>'Filter', 'visible'=>1, 'enabled'=>1, 'position'=>105), + //'actiontodo' => array('type'=>'varchar(255)', 'label'=>'ActionToDo', 'visible'=>1, 'enabled'=>1, 'position'=>106), 'target_directory' => array('type'=>'varchar(255)', 'label'=>'MailboxTargetDirectory', 'visible'=>1, 'enabled'=>1, 'position'=>110, 'notnull'=>0, 'comment'=>"Where to store messages once processed"), 'datelastresult' => array('type'=>'datetime', 'label'=>'DateLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>121, 'notnull'=>-1,), 'codelastresult' => array('type'=>'varchar(16)', 'label'=>'CodeLastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>122, 'notnull'=>-1,), - 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), - 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), - 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), + 'lastresult' => array('type'=>'varchar(255)', 'label'=>'LastResult', 'visible'=>1, 'enabled'=>'$action != "create" && $action != "edit"', 'position'=>123, 'notnull'=>-1,), + 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'visible'=>0, 'enabled'=>1, 'position'=>61, 'notnull'=>-1,), + 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'visible'=>0, 'enabled'=>1, 'position'=>62, 'notnull'=>-1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), - //'date_validation' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), - 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), - 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), - //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Inactive', '1'=>'Active')) + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1,), + //'date_validation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502), + 'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'visible'=>-2, 'enabled'=>1, 'position'=>510, 'notnull'=>1,), + 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'visible'=>-2, 'enabled'=>1, 'position'=>511, 'notnull'=>-1,), + //'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'visible'=>-2, 'enabled'=>1, 'position'=>1000, 'notnull'=>-1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Inactive', '1'=>'Active')) ); @@ -305,14 +305,16 @@ class EmailCollector extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - /*public function fetchLines() - { - $this->lines=array(); + /* + public function fetchLines() + { + $this->lines=array(); - // Load lines with object EmailCollectorLine + // Load lines with object EmailCollectorLine - return count($this->lines)?1:0; - }*/ + return count($this->lines)?1:0; + } + */ /** * Fetch all account and load objects into an array @@ -407,7 +409,7 @@ class EmailCollector extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -549,7 +551,7 @@ class EmailCollector extends CommonObject */ public function info($id) { - $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; $sql.= ' fk_user_creat, fk_user_modif'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; $sql.= ' WHERE t.rowid = '.$id; @@ -673,7 +675,7 @@ class EmailCollector extends CommonObject * * @return string */ - function getConnectStringIMAP() + public function getConnectStringIMAP() { // Connect to IMAP $flags ='/service=imap'; // IMAP diff --git a/htdocs/emailcollector/class/emailcollectoraction.class.php b/htdocs/emailcollector/class/emailcollectoraction.class.php index 6eec6190b71..11ccfbc858e 100644 --- a/htdocs/emailcollector/class/emailcollectoraction.class.php +++ b/htdocs/emailcollector/class/emailcollectoraction.class.php @@ -32,298 +32,298 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php'; */ class EmailCollectorAction extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element = 'emailcollectoraction'; + /** + * @var string ID to identify managed object + */ + public $element = 'emailcollectoraction'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element = 'emailcollector_emailcollectoraction'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'emailcollector_emailcollectoraction'; - /** - * @var int Does emailcollectoraction support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe - */ - public $ismultientitymanaged = 0; + /** + * @var int Does emailcollectoraction support multicompany module ? 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + */ + public $ismultientitymanaged = 0; - /** - * @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes - */ - public $isextrafieldmanaged = 0; + /** + * @var int Does emailcollectoraction support extrafields ? 0=No, 1=Yes + */ + public $isextrafieldmanaged = 0; - /** - * @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png - */ - public $picto = 'emailcollectoraction@emailcollector'; + /** + * @var string String with name of icon for emailcollectoraction. Must be the part after the 'object_' into object_emailcollectoraction.png + */ + public $picto = 'emailcollectoraction@emailcollector'; - /** - * 'type' if the field format. - * 'label' the translation key. - * 'enabled' is a condition when the field must be managed. - * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) - * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). - * 'default' is a default value for creation (can still be replaced by the global setup of default values) - * 'index' if we want an index in database. - * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). - * 'position' is the sort order of field. - * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. - * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). - * 'css' is the CSS style to use on field. For example: 'maxwidth200' - * 'help' is a string visible as a tooltip on field - * 'comment' is not used. You can store here any text of your choice. It is not used by application. - * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record - * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") - */ + /** + * 'type' if the field format. + * 'label' the translation key. + * 'enabled' is a condition when the field must be managed. + * 'visible' says if field is visible in list (Examples: 0=Not visible, 1=Visible on list and create/update/view forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing) + * 'notnull' is set to 1 if not null in database. Set to -1 if we must set data to null if empty ('' or 0). + * 'default' is a default value for creation (can still be replaced by the global setup of default values) + * 'index' if we want an index in database. + * 'foreignkey'=>'tablename.field' if the field is a foreign key (it is recommanded to name the field fk_...). + * 'position' is the sort order of field. + * 'searchall' is 1 if we want to search in this field when making a search from the quick search button. + * 'isameasure' must be set to 1 if you want to have a total on list for this field. Field type must be summable like integer or double(24,8). + * 'css' is the CSS style to use on field. For example: 'maxwidth200' + * 'help' is a string visible as a tooltip on field + * 'comment' is not used. You can store here any text of your choice. It is not used by application. + * 'showoncombobox' if value of the field must be visible into the label of the combobox that list record + * 'arraykeyval' to set list of value if type is a list of predefined values. For example: array("0"=>"Draft","1"=>"Active","-1"=>"Cancel") + */ - // BEGIN MODULEBUILDER PROPERTIES - /** - * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. - */ - public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), - 'fk_emailcollector' => array('type'=>'integer', 'label'=>'Id of emailcollector', 'foreignkey'=>'emailcollector.rowid'), - 'type' => array('type'=>'varchar(128)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1), - 'actionparam' => array('type'=>'varchar(255)', 'label'=>'ParamForAction', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>-1), - 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), - 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,), - 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',), - 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), - 'position' => array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>1, 'position'=>600, 'default'=>'0',), - 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), - 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled')), - ); - public $rowid; - public $fk_emailcollector; - public $type; - public $actionparam; - public $date_creation; - public $tms; - public $fk_user_creat; - public $fk_user_modif; - public $position; - public $import_key; - public $status; - // END MODULEBUILDER PROPERTIES + // BEGIN MODULEBUILDER PROPERTIES + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields=array( + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",), + 'fk_emailcollector' => array('type'=>'integer', 'label'=>'Id of emailcollector', 'foreignkey'=>'emailcollector.rowid'), + 'type' => array('type'=>'varchar(128)', 'label'=>'Type', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1), + 'actionparam' => array('type'=>'varchar(255)', 'label'=>'ParamForAction', 'enabled'=>1, 'visible'=>1, 'position'=>40, 'notnull'=>-1), + 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>500, 'notnull'=>1,), + 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'position'=>501, 'notnull'=>1,), + 'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'enabled'=>1, 'visible'=>-2, 'position'=>510, 'notnull'=>1, 'foreignkey'=>'llx_user.rowid',), + 'fk_user_modif' => array('type'=>'integer', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'position'=>511, 'notnull'=>-1,), + 'position' => array('type'=>'integer', 'label'=>'Position', 'enabled'=>1, 'visible'=>1, 'position'=>600, 'default'=>'0',), + 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,), + 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'default'=>1, 'arrayofkeyval'=>array('0'=>'Disabled', '1'=>'Enabled')), + ); + public $rowid; + public $fk_emailcollector; + public $type; + public $actionparam; + public $date_creation; + public $tms; + public $fk_user_creat; + public $fk_user_modif; + public $position; + public $import_key; + public $status; + // END MODULEBUILDER PROPERTIES - // If this object has a subtable with lines + // If this object has a subtable with lines - /** - * @var int Name of subtable line - */ - //public $table_element_line = 'emailcollectoractiondet'; + // /** + // * @var int Name of subtable line + // */ + //public $table_element_line = 'emailcollectoractiondet'; - /** - * @var int Field with ID of parent key if this field has a parent - */ - //public $fk_element = 'fk_emailcollectoraction'; + // /** + // * @var int Field with ID of parent key if this field has a parent + // */ + //public $fk_element = 'fk_emailcollectoraction'; - /** - * @var int Name of subtable class that manage subtable lines - */ - //public $class_element_line = 'EmailcollectorActionline'; + // /** + // * @var int Name of subtable class that manage subtable lines + // */ + //public $class_element_line = 'EmailcollectorActionline'; - /** - * @var array Array of child tables (child tables to delete before deleting a record) - */ - //protected $childtables=array('emailcollectoractiondet'); + // /** + // * @var array Array of child tables (child tables to delete before deleting a record) + // */ + //protected $childtables=array('emailcollectoractiondet'); - /** - * @var EmailcollectorActionLine[] Array of subtable lines - */ - //public $lines = array(); + // /** + // * @var EmailcollectorActionLine[] Array of subtable lines + // */ + //public $lines = array(); - /** - * Constructor - * - * @param DoliDb $db Database handler - */ - public function __construct(DoliDB $db) - { - global $conf, $langs, $user; + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs, $user; - $this->db = $db; + $this->db = $db; - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; - if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) $this->fields['rowid']['visible']=0; + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) $this->fields['entity']['enabled']=0; - // Unset fields that are disabled - foreach($this->fields as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) - { - unset($this->fields[$key]); - } - } + // Unset fields that are disabled + foreach($this->fields as $key => $val) + { + if (isset($val['enabled']) && empty($val['enabled'])) + { + unset($this->fields[$key]); + } + } - // Translate some data of arrayofkeyval - foreach($this->fields as $key => $val) - { - if (is_array($this->fields['status']['arrayofkeyval'])) - { - foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) - { - $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); - } - } - } - } + // Translate some data of arrayofkeyval + foreach($this->fields as $key => $val) + { + if (is_array($this->fields['status']['arrayofkeyval'])) + { + foreach($this->fields['status']['arrayofkeyval'] as $key2 => $val2) + { + $this->fields['status']['arrayofkeyval'][$key2]=$langs->trans($val2); + } + } + } + } - /** - * Create object into database - * - * @param User $user User that creates - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, Id of created object if OK - */ - public function create(User $user, $notrigger = false) - { - global $langs; - if (empty($this->type)) - { - $langs->load("errors"); - $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); - return -1; - } + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + global $langs; + if (empty($this->type)) + { + $langs->load("errors"); + $this->errors[]=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")); + return -1; + } - return $this->createCommon($user, $notrigger); - } + return $this->createCommon($user, $notrigger); + } - /** - * Clone and object into another one - * - * @param User $user User that creates - * @param int $fromid Id of object to clone - * @return mixed New object created, <0 if KO - */ - public function createFromClone(User $user, $fromid) - { - global $langs, $hookmanager, $extrafields; - $error = 0; + /** + * Clone and object into another one + * + * @param User $user User that creates + * @param int $fromid Id of object to clone + * @return mixed New object created, <0 if KO + */ + public function createFromClone(User $user, $fromid) + { + global $langs, $hookmanager, $extrafields; + $error = 0; - dol_syslog(__METHOD__, LOG_DEBUG); + dol_syslog(__METHOD__, LOG_DEBUG); - $object = new self($this->db); + $object = new self($this->db); - $this->db->begin(); + $this->db->begin(); - // Load source object - $object->fetchCommon($fromid); - // Reset some properties - unset($object->id); - unset($object->fk_user_creat); - unset($object->import_key); + // Load source object + $object->fetchCommon($fromid); + // Reset some properties + unset($object->id); + unset($object->fk_user_creat); + unset($object->import_key); - // Clear fields - $object->ref = "copy_of_".$object->ref; - $object->title = $langs->trans("CopyOf")." ".$object->title; - // ... - // Clear extrafields that are unique - if (is_array($object->array_options) && count($object->array_options) > 0) - { - $extrafields->fetch_name_optionals_label($this->element); - foreach($object->array_options as $key => $option) - { - $shortkey = preg_replace('/options_/', '', $key); - if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) - { - //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; - unset($object->array_options[$key]); - } - } - } + // Clear fields + $object->ref = "copy_of_".$object->ref; + $object->title = $langs->trans("CopyOf")." ".$object->title; + // ... + // Clear extrafields that are unique + if (is_array($object->array_options) && count($object->array_options) > 0) + { + $extrafields->fetch_name_optionals_label($this->element); + foreach($object->array_options as $key => $option) + { + $shortkey = preg_replace('/options_/', '', $key); + if (! empty($extrafields->attributes[$this->element]['unique'][$shortkey])) + { + //var_dump($key); var_dump($clonedObj->array_options[$key]); exit; + unset($object->array_options[$key]); + } + } + } - // Create clone - $object->context['createfromclone'] = 'createfromclone'; - $result = $object->createCommon($user); - if ($result < 0) { - $error++; - $this->error = $object->error; - $this->errors = $object->errors; - } + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->createCommon($user); + if ($result < 0) { + $error++; + $this->error = $object->error; + $this->errors = $object->errors; + } - unset($object->context['createfromclone']); + unset($object->context['createfromclone']); - // End - if (!$error) { - $this->db->commit(); - return $object; - } else { - $this->db->rollback(); - return -1; - } - } + // End + if (!$error) { + $this->db->commit(); + return $object; + } else { + $this->db->rollback(); + return -1; + } + } - /** - * Load object in memory from the database - * - * @param int $id Id object - * @param string $ref Ref - * @return int <0 if KO, 0 if not found, >0 if OK - */ - public function fetch($id, $ref = null) - { - $result = $this->fetchCommon($id, $ref); - if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); - return $result; - } + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines(); + return $result; + } - /** - * Load object lines in memory from the database - * - * @return int <0 if KO, 0 if not found, >0 if OK - */ - /*public function fetchLines() - { - $this->lines=array(); + /** + * Load object lines in memory from the database + * + * @return int <0 if KO, 0 if not found, >0 if OK + */ + /*public function fetchLines() + { + $this->lines=array(); - // Load lines with object EmailcollectorActionLine + // Load lines with object EmailcollectorActionLine - return count($this->lines)?1:0; - }*/ + return count($this->lines)?1:0; + }*/ - /** - * Update object into database - * - * @param User $user User that modifies - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function update(User $user, $notrigger = false) - { - return $this->updateCommon($user, $notrigger); - } + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } - /** - * Delete object in database - * - * @param User $user User that deletes - * @param bool $notrigger false=launch triggers after, true=disable triggers - * @return int <0 if KO, >0 if OK - */ - public function delete(User $user, $notrigger = false) - { - return $this->deleteCommon($user, $notrigger); - } + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) * @param int $notooltip 1=Disable tooltip * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs, $hookmanager; + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; @@ -340,10 +340,10 @@ class EmailCollectorAction extends CommonObject if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkclose=''; @@ -366,152 +366,152 @@ class EmailCollectorAction extends CommonObject } else $linkclose = ($morecss?' class="'.$morecss.'"':''); - $linkstart = ''; - $linkend=''; + $linkstart = ''; + $linkend=''; - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action,$hookmanager; - $hookmanager->initHooks(array('emailcollectoractiondao')); - $parameters=array('id'=>$this->id, 'getnomurl'=>$result); - $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $result = $hookmanager->resPrint; - else $result .= $hookmanager->resPrint; + global $action,$hookmanager; + $hookmanager->initHooks(array('emailcollectoractiondao')); + $parameters=array('id'=>$this->id, 'getnomurl'=>$result); + $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) $result = $hookmanager->resPrint; + else $result .= $hookmanager->resPrint; - return $result; - } + return $result; + } - /** - * Return label of the status - * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function getLibStatut($mode = 0) - { - return $this->LibStatut($this->status, $mode); - } + /** + * Return label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return the status - * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status - */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - if (empty($this->labelstatus)) - { - global $langs; - //$langs->load("emailcollector"); - $this->labelstatus[1] = $langs->trans('Enabled'); - $this->labelstatus[0] = $langs->trans('Disabled'); - } + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelstatus)) + { + global $langs; + //$langs->load("emailcollector"); + $this->labelstatus[1] = $langs->trans('Enabled'); + $this->labelstatus[0] = $langs->trans('Disabled'); + } - if ($mode == 0) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 1) - { - return $this->labelstatus[$status]; - } - elseif ($mode == 2) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 3) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 4) - { - if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; - } - elseif ($mode == 5) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - elseif ($mode == 6) - { - if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); - elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); - } - } + if ($mode == 0) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 1) + { + return $this->labelstatus[$status]; + } + elseif ($mode == 2) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 3) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 4) + { + if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status]; + } + elseif ($mode == 5) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + elseif ($mode == 6) + { + if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle'); + elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle'); + } + } - /** - * Charge les informations d'ordre info dans l'objet commande - * - * @param int $id Id of order - * @return void - */ - public function info($id) - { - $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; - $sql.= ' fk_user_creat, fk_user_modif'; - $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; - $sql.= ' WHERE t.rowid = '.$id; - $result=$this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { - $obj = $this->db->fetch_object($result); - $this->id = $obj->rowid; - if ($obj->fk_user_author) - { - $cuser = new User($this->db); - $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; - } + /** + * Charge les informations d'ordre info dans l'objet commande + * + * @param int $id Id of order + * @return void + */ + public function info($id) + { + $sql = 'SELECT rowid, date_creation as datec, tms as datem,'; + $sql.= ' fk_user_creat, fk_user_modif'; + $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t'; + $sql.= ' WHERE t.rowid = '.$id; + $result=$this->db->query($sql); + if ($result) + { + if ($this->db->num_rows($result)) + { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) + { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } - if ($obj->fk_user_valid) - { - $vuser = new User($this->db); - $vuser->fetch($obj->fk_user_valid); - $this->user_validation = $vuser; - } + if ($obj->fk_user_valid) + { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } - if ($obj->fk_user_cloture) - { - $cluser = new User($this->db); - $cluser->fetch($obj->fk_user_cloture); - $this->user_cloture = $cluser; - } + if ($obj->fk_user_cloture) + { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } - $this->date_creation = $this->db->jdate($obj->datec); - $this->date_modification = $this->db->jdate($obj->datem); - $this->date_validation = $this->db->jdate($obj->datev); - } + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - public function initAsSpecimen() - { - $this->initAsSpecimenCommon(); - } + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->initAsSpecimenCommon(); + } } diff --git a/htdocs/emailcollector/class/emailcollectorfilter.class.php b/htdocs/emailcollector/class/emailcollectorfilter.class.php index e0556bf865b..d46dfb1c9ae 100644 --- a/htdocs/emailcollector/class/emailcollectorfilter.class.php +++ b/htdocs/emailcollector/class/emailcollectorfilter.class.php @@ -296,7 +296,7 @@ class EmailCollectorFilter extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; diff --git a/htdocs/expedition/class/api_shipments.class.php b/htdocs/expedition/class/api_shipments.class.php index 3352927f7c9..73923105c7d 100644 --- a/htdocs/expedition/class/api_shipments.class.php +++ b/htdocs/expedition/class/api_shipments.class.php @@ -46,10 +46,10 @@ class Shipments extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->shipment = new Expedition($this->db); } @@ -60,26 +60,26 @@ class Shipments extends DolibarrApi * * @param int $id ID of shipment * @return array|mixed data without useless information - * + * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->expedition->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expedition->lire) { + throw new RestException(401); + } $result = $this->shipment->fetch($id); if( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->shipment->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->shipment); + return $this->_cleanObjectDatas($this->shipment); } @@ -97,9 +97,9 @@ class Shipments extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of shipment objects * - * @throws RestException + * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -134,7 +134,7 @@ class Shipments extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -173,7 +173,7 @@ class Shipments extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No shipment found'); } - return $obj_ret; + return $obj_ret; } /** @@ -182,7 +182,7 @@ class Shipments extends DolibarrApi * @param array $request_data Request data * @return int ID of shipment */ - function post($request_data = null) + public function post($request_data = null) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,7 +218,7 @@ class Shipments extends DolibarrApi * @return int */ /* - function getLines($id) + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->expedition->lire) { throw new RestException(401); @@ -252,7 +252,7 @@ class Shipments extends DolibarrApi * @return int */ /* - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -315,7 +315,7 @@ class Shipments extends DolibarrApi * @return object */ /* - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -376,32 +376,32 @@ class Shipments extends DolibarrApi * @throws 401 * @throws 404 */ - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { - if(! DolibarrApiAccess::$user->rights->expedition->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expedition->creer) { + throw new RestException(401); + } - $result = $this->shipment->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Shipment not found'); - } + $result = $this->shipment->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Shipment not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - // TODO Check the lineid $lineid is a line of ojbect + // TODO Check the lineid $lineid is a line of ojbect - $request_data = (object) $request_data; - $updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid); - if ($updateRes > 0) { - return $this->get($id); - } - else - { - throw new RestException(405, $this->shipment->error); - } + $request_data = (object) $request_data; + $updateRes = $this->shipment->deleteline(DolibarrApiAccess::$user, $lineid); + if ($updateRes > 0) { + return $this->get($id); + } + else + { + throw new RestException(405, $this->shipment->error); + } } /** @@ -412,7 +412,7 @@ class Shipments extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { throw new RestException(401); @@ -423,9 +423,9 @@ class Shipments extends DolibarrApi throw new RestException(404, 'Shipment not found'); } - if (! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; $this->shipment->$field = $value; @@ -437,7 +437,7 @@ class Shipments extends DolibarrApi } else { - throw new RestException(500, $this->shipment->error); + throw new RestException(500, $this->shipment->error); } } @@ -448,19 +448,19 @@ class Shipments extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->shipment->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->shipment->fetch($id); if( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->shipment->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when deleting shipment : '.$this->shipment->error); @@ -493,26 +493,26 @@ class Shipments extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if (! DolibarrApiAccess::$user->rights->expedition->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->shipment->fetch($id); if ( ! $result ) { throw new RestException(404, 'Shipment not found'); } - if ( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('expedition', $this->shipment->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->shipment->valid(DolibarrApiAccess::$user, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Shipment: '.$this->shipment->error); + $result = $this->shipment->valid(DolibarrApiAccess::$user, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Shipment: '.$this->shipment->error); } $result = $this->shipment->fetch($id); if ( ! $result ) { @@ -542,7 +542,8 @@ class Shipments extends DolibarrApi * @throws 404 * @throws 405 */ -/* function setinvoiced($id) + /* + public function setinvoiced($id) { if(! DolibarrApiAccess::$user->rights->expedition->creer) { @@ -562,7 +563,7 @@ class Shipments extends DolibarrApi } return $result; } -*/ + */ /** @@ -579,7 +580,7 @@ class Shipments extends DolibarrApi * @throws 405 */ /* - function createShipmentFromOrder($orderid) + public function createShipmentFromOrder($orderid) { require_once DOL_DOCUMENT_ROOT . '/commande/class/commande.class.php'; @@ -607,7 +608,7 @@ class Shipments extends DolibarrApi $this->shipment->fetchObjectLinked(); return $this->_cleanObjectDatas($this->shipment); } - */ + */ /** * Clean sensible object datas @@ -615,7 +616,7 @@ class Shipments extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -633,15 +634,15 @@ class Shipments extends DolibarrApi { foreach ($object->lines as $line) { - unset($line->tva_tx); - unset($line->vat_src_code); - unset($line->total_ht); - unset($line->total_ttc); - unset($line->total_tva); - unset($line->total_localtax1); - unset($line->total_localtax2); - unset($line->remise_percent); - } + unset($line->tva_tx); + unset($line->vat_src_code); + unset($line->total_ht); + unset($line->total_ttc); + unset($line->total_tva); + unset($line->total_localtax1); + unset($line->total_localtax2); + unset($line->remise_percent); + } } return $object; @@ -654,7 +655,7 @@ class Shipments extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $shipment = array(); foreach (Shipments::$FIELDS as $field) { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 84853fe51e6..afb1469da26 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -171,7 +171,7 @@ class Expedition extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $conf; @@ -207,7 +207,7 @@ class Expedition extends CommonObject * @param Societe $soc Thirdparty object * @return string Free reference for contract */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $langs, $conf; $langs->load("sendings"); @@ -264,7 +264,7 @@ class Expedition extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si erreur, id expedition creee si ok */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $hookmanager; @@ -434,7 +434,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a expedition line * @@ -444,7 +444,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, line_id if OK */ - function create_line($entrepot_id, $origin_line_id, $qty, $array_options = 0) + public function create_line($entrepot_id, $origin_line_id, $qty, $array_options = 0) { //phpcs:enable $expeditionline = new ExpeditionLigne($this->db); @@ -462,7 +462,7 @@ class Expedition extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create the detail (eat-by date) of the expedition line * @@ -470,7 +470,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function create_line_batch($line_ext, $array_options = 0) + public function create_line_batch($line_ext, $array_options = 0) { // phpcs:enable $error = 0; @@ -520,7 +520,7 @@ class Expedition extends CommonObject * @param string $ref_int Internal reference of other object * @return int >0 if OK, 0 if not found, <0 if KO */ - function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($id, $ref = '', $ref_ext = '', $ref_int = '') { global $conf; @@ -646,7 +646,7 @@ class Expedition extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if OK, >0 if KO */ - function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { global $conf, $langs; @@ -862,14 +862,14 @@ class Expedition extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a delivery receipt from a shipment * * @param User $user User * @return int <0 if KO, >=0 if OK */ - function create_delivery($user) + public function create_delivery($user) { // phpcs:enable global $conf; @@ -908,7 +908,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function addline($entrepot_id, $id, $qty, $array_options = 0) + public function addline($entrepot_id, $id, $qty, $array_options = 0) { global $conf, $langs; @@ -971,7 +971,7 @@ class Expedition extends CommonObject $this->lines[$num] = $line; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a shipment line with batch record * @@ -979,7 +979,7 @@ class Expedition extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function addline_batch($dbatch, $array_options = 0) + public function addline_batch($dbatch, $array_options = 0) { // phpcs:enable global $conf,$langs; @@ -1048,7 +1048,7 @@ class Expedition extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf; $error=0; @@ -1152,7 +1152,7 @@ class Expedition extends CommonObject * * @return int >0 if OK, 0 if deletion done but failed to delete files, <0 if KO */ - function delete() + public function delete() { global $conf, $langs, $user; @@ -1360,13 +1360,13 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines * * @return int >0 if OK, Otherwise if KO */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable global $conf, $mysoc; @@ -1548,7 +1548,7 @@ class Expedition extends CommonObject * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - function deleteline($user, $lineid) + public function deleteline($user, $lineid) { global $user; @@ -1593,7 +1593,7 @@ class Expedition extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $notooltip = 0, $save_lastsearch_value = -1) { global $langs; @@ -1643,12 +1643,12 @@ class Expedition extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -1656,7 +1656,7 @@ class Expedition extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @return string Label of status */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -1700,7 +1700,7 @@ class Expedition extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $langs; @@ -1772,7 +1772,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the planned delivery date * @@ -1780,7 +1780,7 @@ class Expedition extends CommonObject * @param timestamp $date_livraison Date de livraison * @return int <0 if KO, >0 if OK */ - function set_date_livraison($user, $date_livraison) + public function set_date_livraison($user, $date_livraison) { // phpcs:enable if ($user->rights->expedition->creer) @@ -1808,13 +1808,13 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch deliveries method and return an array. Load array this->meths(rowid=>label). * * @return void */ - function fetch_delivery_methods() + public function fetch_delivery_methods() { // phpcs:enable global $langs; @@ -1836,14 +1836,14 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch all deliveries method and return an array. Load array this->listmeths. * * @param id $id only this carrier, all if none * @return void */ - function list_delivery_methods($id = '') + public function list_delivery_methods($id = '') { // phpcs:enable global $langs; @@ -1872,7 +1872,7 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update/create delivery method. * @@ -1880,7 +1880,7 @@ class Expedition extends CommonObject * * @return void */ - function update_delivery_method($id = '') + public function update_delivery_method($id = '') { // phpcs:enable if ($id=='') @@ -1902,7 +1902,7 @@ class Expedition extends CommonObject if ($resql < 0) dol_print_error($this->db, ''); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Activate delivery method. * @@ -1910,7 +1910,7 @@ class Expedition extends CommonObject * * @return void */ - function activ_delivery_method($id) + public function activ_delivery_method($id) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=1'; @@ -1919,7 +1919,7 @@ class Expedition extends CommonObject $resql = $this->db->query($sql); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * DesActivate delivery method. * @@ -1927,7 +1927,7 @@ class Expedition extends CommonObject * * @return void */ - function disable_delivery_method($id) + public function disable_delivery_method($id) { // phpcs:enable $sql = 'UPDATE '.MAIN_DB_PREFIX.'c_shipment_mode SET active=0'; @@ -1943,7 +1943,7 @@ class Expedition extends CommonObject * @param string $value Value * @return void */ - function getUrlTrackingStatus($value = '') + public function getUrlTrackingStatus($value = '') { if (! empty($this->shipping_method_id)) { @@ -1977,7 +1977,7 @@ class Expedition extends CommonObject * * @return int <0 if KO, >0 if OK */ - function setClosed() + public function setClosed() { global $conf,$langs,$user; @@ -2123,13 +2123,13 @@ class Expedition extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Classify the shipping as invoiced (used when WORKFLOW_BILL_ON_SHIPMENT is on) * * @return int <0 if ko, >0 if ok */ - function set_billed() + public function set_billed() { // phpcs:enable global $user; @@ -2174,7 +2174,7 @@ class Expedition extends CommonObject * * @return int <0 if KO, 0 if already open, >0 if OK */ - function reOpen() + public function reOpen() { global $conf,$langs,$user; @@ -2273,14 +2273,13 @@ class Expedition extends CommonObject } } - if (! $error) - { + if (! $error) { // Call trigger $result=$this->call_trigger('SHIPPING_REOPEN', $user); if ($result < 0) { $error++; } - } + } } else { $error++; $this->errors[]=$this->db->lasterror(); @@ -2510,7 +2509,7 @@ class ExpeditionLigne extends CommonObjectLine * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db=$db; } @@ -2521,7 +2520,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $rowid Id line order * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT ed.rowid, ed.fk_expedition, ed.fk_entrepot, ed.fk_origin_line, ed.qty, ed.rang'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as ed'; @@ -2556,7 +2555,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $notrigger 1 = disable triggers * @return int <0 if KO, line id >0 if OK */ - function insert($user = null, $notrigger = 0) + public function insert($user = null, $notrigger = 0) { global $langs, $conf; @@ -2638,7 +2637,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int >0 if OK, <0 if KO */ - function delete($user = null, $notrigger = 0) + public function delete($user = null, $notrigger = 0) { global $conf; @@ -2715,7 +2714,7 @@ class ExpeditionLigne extends CommonObjectLine * @param int $notrigger 1 = disable triggers * @return int < 0 if KO, > 0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf; diff --git a/htdocs/expedition/class/expeditionbatch.class.php b/htdocs/expedition/class/expeditionbatch.class.php index e15e766c439..1cc0f277af6 100644 --- a/htdocs/expedition/class/expeditionbatch.class.php +++ b/htdocs/expedition/class/expeditionbatch.class.php @@ -35,21 +35,21 @@ class ExpeditionLineBatch extends CommonObject private static $_table_element='expeditiondet_batch'; //!< Name of table without prefix where object is stored - var $sellby; - var $eatby; - var $batch; - var $qty; - var $dluo_qty; // deprecated, use qty - var $entrepot_id; - var $fk_origin_stock; - var $fk_expeditiondet; + public $sellby; + public $eatby; + public $batch; + public $qty; + public $dluo_qty; // deprecated, use qty + public $entrepot_id; + public $fk_origin_stock; + public $fk_expeditiondet; /** * Constructor * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -60,7 +60,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $id_stockdluo Rowid in product_batch table * @return int -1 if KO, 1 if OK */ - function fetchFromStock($id_stockdluo) + public function fetchFromStock($id_stockdluo) { $sql = "SELECT"; $sql.= " pb.batch,"; @@ -104,7 +104,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $id_line_expdet rowid of expedtiondet record * @return int <0 if KO, Id of record (>0) if OK */ - function create($id_line_expdet) + public function create($id_line_expdet) { $error = 0; @@ -155,7 +155,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $id_expedition rowid of shipment * @return int -1 if KO, 1 if OK */ - static function deletefromexp($db, $id_expedition) + public static function deletefromexp($db, $id_expedition) { $id_expedition = (int) $id_expedition; @@ -181,7 +181,7 @@ class ExpeditionLineBatch extends CommonObject * @param int $fk_product If provided, load also detailed information of lot * @return int|array -1 if KO, array of ExpeditionLineBatch if OK */ - static function fetchAll($db, $id_line_expdet, $fk_product = 0) + public static function fetchAll($db, $id_line_expdet, $fk_product = 0) { $sql="SELECT"; $sql.= " eb.rowid,"; diff --git a/htdocs/expedition/class/expeditionstats.class.php b/htdocs/expedition/class/expeditionstats.class.php index e1bb3c0b219..d6ac5e2242a 100644 --- a/htdocs/expedition/class/expeditionstats.class.php +++ b/htdocs/expedition/class/expeditionstats.class.php @@ -34,17 +34,17 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class ExpeditionStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; /** @@ -55,7 +55,7 @@ class ExpeditionStats extends Stats * @param string $mode Option (not used) * @param int $userid Id user for filter (creation user) */ - function __construct($db, $socid, $mode, $userid = 0) + public function __construct($db, $socid, $mode, $userid = 0) { global $user, $conf; @@ -88,7 +88,7 @@ class ExpeditionStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array with number by month */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { global $user; @@ -110,7 +110,7 @@ class ExpeditionStats extends Stats * @return array Array with number by year * */ - function getNbByYear() + public function getNbByYear() { global $user; @@ -129,7 +129,7 @@ class ExpeditionStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { global $user; diff --git a/htdocs/expensereport/class/api_expensereports.class.php b/htdocs/expensereport/class/api_expensereports.class.php index 02e1021a141..35ce9f9a4a2 100644 --- a/htdocs/expensereport/class/api_expensereports.class.php +++ b/htdocs/expensereport/class/api_expensereports.class.php @@ -45,7 +45,7 @@ class ExpenseReports extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -59,26 +59,26 @@ class ExpenseReports extends DolibarrApi * * @param int $id ID of Expense Report * @return array|mixed Data without useless information - * + * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->expensereport->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expensereport->lire) { + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'Expense report not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } $this->expensereport->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->expensereport); + return $this->_cleanObjectDatas($this->expensereport); } /** @@ -94,7 +94,7 @@ class ExpenseReports extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of Expense Report objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; @@ -115,7 +115,7 @@ class ExpenseReports extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -152,7 +152,7 @@ class ExpenseReports extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No Expense Report found'); } - return $obj_ret; + return $obj_ret; } /** @@ -161,7 +161,7 @@ class ExpenseReports extends DolibarrApi * @param array $request_data Request data * @return int ID of Expense Report */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401, "Insuffisant rights"); @@ -195,8 +195,8 @@ class ExpenseReports extends DolibarrApi * * @return int */ -/* - function getLines($id) + /* + public function getLines($id) { if(! DolibarrApiAccess::$user->rights->expensereport->lire) { throw new RestException(401); @@ -217,7 +217,7 @@ class ExpenseReports extends DolibarrApi } return $result; } -*/ + */ /** * Add a line to given Expense Report @@ -229,22 +229,22 @@ class ExpenseReports extends DolibarrApi * * @return int */ -/* - function postLine($id, $request_data = null) + /* + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $request_data = (object) $request_data; + $request_data = (object) $request_data; $updateRes = $this->expensereport->addline( $request_data->desc, $request_data->subprice, @@ -279,7 +279,7 @@ class ExpenseReports extends DolibarrApi } return false; } -*/ + */ /** * Update a line to given Expense Report @@ -293,22 +293,22 @@ class ExpenseReports extends DolibarrApi * @return object */ /* - function putLine($id, $lineid, $request_data = null) + public function putLine($id, $lineid, $request_data = null) { - if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->expensereport->creer) { + throw new RestException(401); + } - $result = $this->expensereport->fetch($id); - if( ! $result ) { - throw new RestException(404, 'expensereport not found'); - } + $result = $this->expensereport->fetch($id); + if( ! $result ) { + throw new RestException(404, 'expensereport not found'); + } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $request_data = (object) $request_data; - $updateRes = $this->expensereport->updateline( + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $request_data = (object) $request_data; + $updateRes = $this->expensereport->updateline( $lineid, $request_data->desc, $request_data->subprice, @@ -330,16 +330,16 @@ class ExpenseReports extends DolibarrApi $request_data->special_code, $request_data->array_options, $request_data->fk_unit - ); + ); - if ($updateRes > 0) { - $result = $this->get($id); - unset($result->line); - return $this->_cleanObjectDatas($result); - } - return false; + if ($updateRes > 0) { + $result = $this->get($id); + unset($result->line); + return $this->_cleanObjectDatas($result); + } + return false; } - */ + */ /** * Delete a line of given Expense Report @@ -352,19 +352,19 @@ class ExpenseReports extends DolibarrApi * @return int */ /* - function deleteLine($id, $lineid) + public function deleteLine($id, $lineid) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } // TODO Check the lineid $lineid is a line of ojbect @@ -385,7 +385,7 @@ class ExpenseReports extends DolibarrApi * * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { throw new RestException(401); @@ -407,11 +407,11 @@ class ExpenseReports extends DolibarrApi if ($this->expensereport->update(DolibarrApiAccess::$user) > 0) { return $this->get($id); - } - else - { - throw new RestException(500, $this->expensereport->error); - } + } + else + { + throw new RestException(500, $this->expensereport->error); + } } /** @@ -421,19 +421,19 @@ class ExpenseReports extends DolibarrApi * * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->expensereport->supprimer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'Expense Report not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport', $this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->expensereport->delete(DolibarrApiAccess::$user)) { throw new RestException(500, 'Error when delete Expense Report : '.$this->expensereport->error); @@ -463,19 +463,19 @@ class ExpenseReports extends DolibarrApi * } */ /* - function validate($id, $idwarehouse=0) + public function validate($id, $idwarehouse=0) { if(! DolibarrApiAccess::$user->rights->expensereport->creer) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->expensereport->fetch($id); if( ! $result ) { throw new RestException(404, 'expensereport not found'); } - if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('expensereport',$this->expensereport->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( ! $this->expensereport->valid(DolibarrApiAccess::$user, $idwarehouse)) { throw new RestException(500, 'Error when validate expensereport'); @@ -495,17 +495,17 @@ class ExpenseReports extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder); - return $object; + return $object; } /** @@ -515,7 +515,7 @@ class ExpenseReports extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $expensereport = array(); foreach (ExpenseReports::$FIELDS as $field) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 8dc0cbcdcf8..bbada0e22f7 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -44,62 +44,62 @@ class ExpenseReport extends CommonObject */ public $table_element='expensereport'; - var $table_element_line = 'expensereport_det'; - var $fk_element = 'fk_expensereport'; - var $picto = 'trip'; + public $table_element_line = 'expensereport_det'; + public $fk_element = 'fk_expensereport'; + public $picto = 'trip'; - var $lines=array(); + public $lines=array(); public $date_debut; public $date_fin; - var $status; - var $fk_statut; // -- 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied - var $fk_c_paiement; - var $paid; + public $status; + public $fk_statut; // -- 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied + public $fk_c_paiement; + public $paid; - var $user_author_infos; - var $user_validator_infos; + public $user_author_infos; + public $user_validator_infos; - var $fk_typepayment; - var $num_payment; - var $code_paiement; - var $code_statut; + public $fk_typepayment; + public $num_payment; + public $code_paiement; + public $code_statut; // ACTIONS // Create - var $date_create; - var $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. + public $date_create; + public $fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for. // Update - var $date_modif; - var $fk_user_modif; + public $date_modif; + public $fk_user_modif; // Refus - var $date_refuse; - var $detail_refuse; - var $fk_user_refuse; + public $date_refuse; + public $detail_refuse; + public $fk_user_refuse; // Annulation - var $date_cancel; - var $detail_cancel; - var $fk_user_cancel; + public $date_cancel; + public $detail_cancel; + public $fk_user_cancel; - var $fk_user_validator; // User that is defined to approve + public $fk_user_validator; // User that is defined to approve // Validation - var $date_valid; // User making validation - var $fk_user_valid; - var $user_valid_infos; + public $date_valid; // User making validation + public $fk_user_valid; + public $user_valid_infos; // Approve - var $date_approve; - var $fk_user_approve; // User that has approved + public $date_approve; + public $fk_user_approve; // User that has approved // Paiement - var $user_paid_infos; + public $user_paid_infos; /* END ACTIONS @@ -137,7 +137,7 @@ class ExpenseReport extends CommonObject * * @param DoliDB $db Handler acces base de donnees */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->total_ht = 0; @@ -155,10 +155,10 @@ class ExpenseReport extends CommonObject * Create object in database * * @param User $user User that create - * @param int $notrigger Disable triggers + * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf; @@ -307,7 +307,7 @@ class ExpenseReport extends CommonObject * @param int $fk_user_author Id of new user * @return int New id of clone */ - function createFromClone($fk_user_author) + public function createFromClone($fk_user_author) { global $user,$hookmanager; @@ -377,7 +377,7 @@ class ExpenseReport extends CommonObject * @param User $userofexpensereport New user we want to have the expense report on. * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0, $userofexpensereport = null) + public function update($user, $notrigger = 0, $userofexpensereport = null) { global $langs; @@ -447,7 +447,7 @@ class ExpenseReport extends CommonObject * @param string $ref Ref {@name ref} * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $conf; @@ -545,7 +545,7 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Classify the expense report as paid * @@ -554,7 +554,7 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function set_paid($id, $fuser, $notrigger = 0) + public function set_paid($id, $fuser, $notrigger = 0) { // phpcs:enable $error = 0; @@ -613,12 +613,12 @@ class ExpenseReport extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the label of a statut * @@ -626,7 +626,7 @@ class ExpenseReport extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -660,7 +660,7 @@ class ExpenseReport extends CommonObject * @param int $id Id of object * @return void */ - function info($id) + public function info($id) { global $conf; @@ -684,16 +684,16 @@ class ExpenseReport extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; + $this->id = $obj->rowid; - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->date_modification); - $this->date_validation = $this->db->jdate($obj->datev); - $this->date_approbation = $this->db->jdate($obj->datea); + $this->date_validation = $this->db->jdate($obj->datev); + $this->date_approbation = $this->db->jdate($obj->datea); $cuser = new User($this->db); $cuser->fetch($obj->fk_user_author); - $this->user_creation = $cuser; + $this->user_creation = $cuser; if ($obj->fk_user_creation) { @@ -737,7 +737,7 @@ class ExpenseReport extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; @@ -767,8 +767,7 @@ class ExpenseReport extends CommonObject $this->note_public='SPECIMEN'; $nbp = 5; $xnbp = 0; - while ($xnbp < $nbp) - { + while ($xnbp < $nbp) { $line=new ExpenseReportLine($this->db); $line->comments=$langs->trans("Comment")." ".$xnbp; $line->date=($now-3600*(1+$xnbp)); @@ -793,7 +792,7 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * fetch_line_by_project * @@ -801,7 +800,7 @@ class ExpenseReport extends CommonObject * @param User $user User * @return int <0 if KO, >0 if OK */ - function fetch_line_by_project($projectid, $user = '') + public function fetch_line_by_project($projectid, $user = '') { // phpcs:enable global $conf,$db,$langs; @@ -906,7 +905,7 @@ class ExpenseReport extends CommonObject * @param int $id Id of expense report * @return int <0 if KO, >0 if OK */ - function recalculer($id) + public function recalculer($id) { $sql = 'SELECT tt.total_ht, tt.total_ttc, tt.total_tva'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as tt'; @@ -950,13 +949,13 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * fetch_lines * * @return int <0 if OK, >0 if KO */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->lines=array(); @@ -1038,7 +1037,7 @@ class ExpenseReport extends CommonObject * @param User $fuser User that delete * @return int <0 if KO, >0 if OK */ - function delete(User $fuser = null) + public function delete(User $fuser = null) { global $user,$langs,$conf; @@ -1078,7 +1077,7 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, 0 if nothing done, >0 if OK */ - function setValidate($fuser, $notrigger = 0) + public function setValidate($fuser, $notrigger = 0) { global $conf,$langs,$user; @@ -1195,14 +1194,14 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * set_save_from_refuse * * @param User $fuser User * @return int <0 if KO, >0 if OK */ - function set_save_from_refuse($fuser) + public function set_save_from_refuse($fuser) { // phpcs:enable global $conf,$langs; @@ -1249,16 +1248,15 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, 0 if nothing done, >0 if OK */ - function setApproved($fuser, $notrigger = 0) + public function setApproved($fuser, $notrigger = 0) { $now=dol_now(); - $error = 0; + $error = 0; // date approval $this->date_approve = $now; - if ($this->fk_statut != 5) - { - $this->db->begin(); + if ($this->fk_statut != 5) { + $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql.= " SET ref = '".$this->db->escape($this->ref)."', fk_statut = 5, fk_user_approve = ".$fuser->id.","; @@ -1309,10 +1307,10 @@ class ExpenseReport extends CommonObject * * @param User $fuser User * @param Details $details Details - * @param int $notrigger Disable triggers + * @param int $notrigger Disable triggers * @return int */ - function setDeny($fuser, $details, $notrigger = 0) + public function setDeny($fuser, $details, $notrigger = 0) { $now = dol_now(); $error = 0; @@ -1369,7 +1367,7 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * set_unpaid * @@ -1377,7 +1375,7 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function set_unpaid($fuser, $notrigger = 0) + public function set_unpaid($fuser, $notrigger = 0) { // phpcs:enable $error = 0; @@ -1430,7 +1428,7 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * set_cancel * @@ -1439,7 +1437,7 @@ class ExpenseReport extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function set_cancel($fuser, $detail, $notrigger = 0) + public function set_cancel($fuser, $detail, $notrigger = 0) { // phpcs:enable $error = 0; @@ -1499,7 +1497,7 @@ class ExpenseReport extends CommonObject * * @return string free ref */ - function getNextNumRef() + public function getNextNumRef() { global $langs, $conf; $langs->load("trips"); @@ -1559,7 +1557,7 @@ class ExpenseReport extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $max = 0, $short = 0, $moretitle = '', $notooltip = 0, $save_lastsearch_value = -1) { global $langs, $conf; @@ -1615,7 +1613,7 @@ class ExpenseReport extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total of an expense report when you add a line. * @@ -1623,7 +1621,7 @@ class ExpenseReport extends CommonObject * @param string $ligne_total_tva Amount of all taxes * @return void */ - function update_totaux_add($ligne_total_ht, $ligne_total_tva) + public function update_totaux_add($ligne_total_ht, $ligne_total_tva) { // phpcs:enable $this->total_ht = $this->total_ht + $ligne_total_ht; @@ -1645,7 +1643,7 @@ class ExpenseReport extends CommonObject endif; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total of an expense report when you delete a line. * @@ -1653,7 +1651,7 @@ class ExpenseReport extends CommonObject * @param string $ligne_total_tva Amount of all taxes * @return void */ - function update_totaux_del($ligne_total_ht, $ligne_total_tva) + public function update_totaux_del($ligne_total_ht, $ligne_total_tva) { // phpcs:enable $this->total_ht = $this->total_ht - $ligne_total_ht; @@ -1689,7 +1687,7 @@ class ExpenseReport extends CommonObject * @param int $type Type line * @return int <0 if KO, >0 if OK */ - function addline($qty = 0, $up = 0, $fk_c_type_fees = 0, $vatrate = 0, $date = '', $comments = '', $fk_project = 0, $fk_c_exp_tax_cat = 0, $type = 0) + public function addline($qty = 0, $up = 0, $fk_c_type_fees = 0, $vatrate = 0, $date = '', $comments = '', $fk_project = 0, $fk_c_exp_tax_cat = 0, $type = 0) { global $conf,$langs,$mysoc; @@ -1783,7 +1781,7 @@ class ExpenseReport extends CommonObject * @param string $seller seller, but actually he is unknown * @return true or false */ - function checkRules($type = 0, $seller = '') + public function checkRules($type = 0, $seller = '') { global $user,$conf,$db,$langs; @@ -1852,7 +1850,7 @@ class ExpenseReport extends CommonObject * * @return boolean true=applied, false=not applied */ - function applyOffset() + public function applyOffset() { global $conf; @@ -1900,7 +1898,7 @@ class ExpenseReport extends CommonObject * * @return bool */ - function offsetAlreadyGiven() + public function offsetAlreadyGiven() { $sql = 'SELECT e.rowid FROM '.MAIN_DB_PREFIX.'expensereport e'; $sql.= ' INNER JOIN '.MAIN_DB_PREFIX.'expensereport_det d ON (e.rowid = d.fk_expensereport)'; @@ -1939,7 +1937,7 @@ class ExpenseReport extends CommonObject * @param int $fk_c_exp_tax_cat id of category of car * @return int <0 if KO, >0 if OK */ - function updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $expensereport_id, $fk_c_exp_tax_cat = 0) + public function updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $expensereport_id, $fk_c_exp_tax_cat = 0) { global $user, $mysoc; @@ -2046,7 +2044,7 @@ class ExpenseReport extends CommonObject * @param User $fuser User * @return int <0 if KO, >0 if OK */ - function deleteline($rowid, $fuser = '') + public function deleteline($rowid, $fuser = '') { $this->db->begin(); @@ -2068,7 +2066,7 @@ class ExpenseReport extends CommonObject return 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * periode_existe * @@ -2077,7 +2075,7 @@ class ExpenseReport extends CommonObject * @param Date $date_fin End date * @return int <0 if KO, >0 if OK */ - function periode_existe($fuser, $date_debut, $date_fin) + public function periode_existe($fuser, $date_debut, $date_fin) { // phpcs:enable $sql = "SELECT rowid, date_debut, date_fin"; @@ -2086,8 +2084,7 @@ class ExpenseReport extends CommonObject dol_syslog(get_class($this)."::periode_existe sql=".$sql); $result = $this->db->query($sql); - if($result) - { + if ($result) { $num_lignes = $this->db->num_rows($result); $i = 0; if ($num_lignes>0) @@ -2126,14 +2123,14 @@ class ExpenseReport extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of people with permission to validate expense reports. * Search for permission "approve expense report" * * @return array Array of user ids */ - function fetch_users_approver_expensereport() + public function fetch_users_approver_expensereport() { // phpcs:enable $users_validator=array(); @@ -2207,7 +2204,7 @@ class ExpenseReport extends CommonObject * @param int $active Active or not * @return array */ - function listOfTypes($active = 1) + public function listOfTypes($active = 1) { global $langs; $ret=array(); @@ -2234,13 +2231,13 @@ class ExpenseReport extends CommonObject return $ret; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb pour le tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -2253,10 +2250,8 @@ class ExpenseReport extends CommonObject $sql.= " AND ex.entity IN (".getEntity('expensereport').")"; $resql=$this->db->query($sql); - if ($resql) - { - while ($obj=$this->db->fetch_object($resql)) - { + if ($resql) { + while ($obj=$this->db->fetch_object($resql)) { $this->nb["expensereports"]=$obj->nb; } $this->db->free($resql); @@ -2270,7 +2265,7 @@ class ExpenseReport extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -2278,16 +2273,16 @@ class ExpenseReport extends CommonObject * @param string $option 'topay' or 'toapprove' * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user, $option = 'topay') + public function load_board($user, $option = 'topay') { // phpcs:enable global $conf, $langs; if ($user->societe_id) return -1; // protection pour eviter appel par utilisateur externe - $now=dol_now(); + $now=dol_now(); - $userchildids = $user->getAllChildIds(1); + $userchildids = $user->getAllChildIds(1); $sql = "SELECT ex.rowid, ex.date_valid"; $sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex"; @@ -2484,17 +2479,17 @@ class ExpenseReportLine public $projet_ref; public $projet_title; - var $vatrate; - var $total_ht; - var $total_tva; - var $total_ttc; + public $vatrate; + public $total_ht; + public $total_tva; + public $total_ttc; /** * Constructor * * @param DoliDB $db Handlet database */ - function __construct($db) + public function __construct($db) { $this->db= $db; } @@ -2505,7 +2500,7 @@ class ExpenseReportLine * @param int $rowid Id of object to load * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT fde.rowid, fde.fk_expensereport, fde.fk_c_type_fees, fde.fk_c_exp_tax_cat, fde.fk_projet, fde.date,'; $sql.= ' fde.tva_tx as vatrate, fde.vat_src_code, fde.comments, fde.qty, fde.value_unit, fde.total_ht, fde.total_tva, fde.total_ttc,'; @@ -2557,7 +2552,7 @@ class ExpenseReportLine * @param bool $fromaddline false=keep default behavior, true=exclude the update_price() of parent object * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0, $fromaddline = false) + public function insert($notrigger = 0, $fromaddline = false) { global $langs,$user,$conf; @@ -2679,7 +2674,7 @@ class ExpenseReportLine * @param User $fuser User * @return int <0 if KO, >0 if OK */ - function update($fuser) + public function update($fuser) { global $fuser,$langs,$conf; @@ -2758,7 +2753,6 @@ class ExpenseReportLine } -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Retourne la liste deroulante des differents etats d'une note de frais. * Les valeurs de la liste sont les id de la table c_expensereport_statuts @@ -2771,7 +2765,6 @@ class ExpenseReportLine */ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $useempty = 1, $useshortlabel = 0) { - // phpcs:enable global $db, $langs; $tmpep=new ExpenseReport($db); @@ -2796,7 +2789,6 @@ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $u print ''; } -// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** * Return list of types of notes with select value = id * @@ -2808,7 +2800,6 @@ function select_expensereport_statut($selected = '', $htmlname = 'fk_statut', $u */ function select_type_fees_id($selected = '', $htmlname = 'type', $showempty = 0, $active = 1) { - // phpcs:enable global $db,$langs,$user; $langs->load("trips"); diff --git a/htdocs/expensereport/class/expensereportstats.class.php b/htdocs/expensereport/class/expensereportstats.class.php index 0eec447d997..082e3ce016e 100644 --- a/htdocs/expensereport/class/expensereportstats.class.php +++ b/htdocs/expensereport/class/expensereportstats.class.php @@ -50,7 +50,7 @@ class ExpenseReportStats extends Stats * @param int $userid Id user for filter * @return void */ - function __construct($db, $socid = 0, $userid = 0) + public function __construct($db, $socid = 0, $userid = 0) { global $conf, $user; @@ -89,7 +89,7 @@ class ExpenseReportStats extends Stats * * @return array Array of values */ - function getNbByYear() + public function getNbByYear() { $sql = "SELECT YEAR(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -107,7 +107,7 @@ class ExpenseReportStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getNbByMonth($year, $format = 0) + public function getNbByMonth($year, $format = 0) { $sql = "SELECT MONTH(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').") as dm, count(*)"; $sql.= " FROM ".$this->from; @@ -129,7 +129,7 @@ class ExpenseReportStats extends Stats * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month * @return array Array of values */ - function getAmountByMonth($year, $format = 0) + public function getAmountByMonth($year, $format = 0) { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, sum(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -149,7 +149,7 @@ class ExpenseReportStats extends Stats * @param int $year Year to scan * @return array Array of values */ - function getAverageByMonth($year) + public function getAverageByMonth($year) { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%m') as dm, avg(".$this->field.")"; $sql.= " FROM ".$this->from; @@ -166,7 +166,7 @@ class ExpenseReportStats extends Stats * * @return array Array of values */ - function getAllByYear() + public function getAllByYear() { $sql = "SELECT date_format(".$this->db->ifsql('e.date_valid IS NULL', 'e.date_create', 'e.date_valid').",'%Y') as year, count(*) as nb, sum(".$this->field.") as total, avg(".$this->field.") as avg"; $sql.= " FROM ".$this->from; @@ -174,6 +174,6 @@ class ExpenseReportStats extends Stats $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } } diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 655c148069e..f731638ea1d 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -92,7 +92,7 @@ class PaymentExpenseReport extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -104,7 +104,7 @@ class PaymentExpenseReport extends CommonObject * @param User $user User making payment * @return int <0 if KO, id of payment if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -113,8 +113,7 @@ class PaymentExpenseReport extends CommonObject $now=dol_now(); // Validate parameters - if (! $this->datepaid) - { + if (! $this->datepaid) { $this->error='ErrorBadValueForParameterCreatePaymentExpenseReport'; return -1; } @@ -184,10 +183,10 @@ class PaymentExpenseReport extends CommonObject /** * Load object in memory from database * - * @param int $id Id object + * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -258,7 +257,7 @@ class PaymentExpenseReport extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { // phpcs:enable global $conf, $langs; @@ -266,7 +265,7 @@ class PaymentExpenseReport extends CommonObject // Clean parameters - if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); + if (isset($this->fk_expensereport)) $this->fk_expensereport=trim($this->fk_expensereport); if (isset($this->amount)) $this->amount=trim($this->amount); if (isset($this->fk_typepayment)) $this->fk_typepayment=trim($this->fk_typepayment); if (isset($this->num_payment)) $this->num_payment=trim($this->num_payment); @@ -341,11 +340,11 @@ class PaymentExpenseReport extends CommonObject /** * Delete object in database * - * @param User $user User that delete + * @param User $user User that delete * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { // phpcs:enable global $conf, $langs; @@ -370,13 +369,16 @@ class PaymentExpenseReport extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (! $resql) { + $error++; + $this->errors[]="Error ".$this->db->lasterror(); + } } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -386,8 +388,8 @@ class PaymentExpenseReport extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback if ($error) @@ -415,7 +417,7 @@ class PaymentExpenseReport extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -444,11 +446,6 @@ class PaymentExpenseReport extends CommonObject $error++; } - if (! $error) - { - - } - unset($object->context['createfromclone']); // End @@ -471,12 +468,12 @@ class PaymentExpenseReport extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return ''; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -484,13 +481,13 @@ class PaymentExpenseReport extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($statut, $mode = 0) - { + public function LibStatut($statut, $mode = 0) + { // phpcs:enable - global $langs; + global $langs; - return ''; - } + return ''; + } /** @@ -500,7 +497,7 @@ class PaymentExpenseReport extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; @@ -530,7 +527,7 @@ class PaymentExpenseReport extends CommonObject * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ - function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $langs,$conf; @@ -631,14 +628,14 @@ class PaymentExpenseReport extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between the expense report payment and the generated line in llx_bank * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."payment_expensereport SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; @@ -659,11 +656,11 @@ class PaymentExpenseReport extends CommonObject /** * Return clicable name (with picto eventually) * - * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto - * @param int $maxlen Longueur max libelle - * @return string Chaine avec URL + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen Longueur max libelle + * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; @@ -691,8 +688,8 @@ class PaymentExpenseReport extends CommonObject * @param int $id Payment id * @return void */ - function info($id) - { + public function info($id) + { $sql = 'SELECT e.rowid, e.datec, e.fk_user_creat, e.fk_user_modif, e.tms'; $sql.= ' FROM '.MAIN_DB_PREFIX.'payment_expensereport as e'; $sql.= ' WHERE e.rowid = '.$id; @@ -718,7 +715,7 @@ class PaymentExpenseReport extends CommonObject $muser->fetch($obj->fk_user_modif); $this->user_modification = $muser; } - $this->date_creation = $this->db->jdate($obj->datec); + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->tms); } $this->db->free($result); @@ -727,5 +724,5 @@ class PaymentExpenseReport extends CommonObject { dol_print_error($this->db); } - } + } } diff --git a/htdocs/exports/class/export.class.php b/htdocs/exports/class/export.class.php index a964f5f373a..7ce39a43354 100644 --- a/htdocs/exports/class/export.class.php +++ b/htdocs/exports/class/export.class.php @@ -35,28 +35,28 @@ class Export */ public $db; - var $array_export_code=array(); // Tableau de "idmodule_numlot" - var $array_export_module=array(); // Tableau de "nom de modules" - var $array_export_label=array(); // Tableau de "libelle de lots" - var $array_export_sql_start=array(); // Tableau des "requetes sql" - var $array_export_sql_end=array(); // Tableau des "requetes sql" - var $array_export_sql_order=array(); // Tableau des "requetes sql" + public $array_export_code=array(); // Tableau de "idmodule_numlot" + public $array_export_module=array(); // Tableau de "nom de modules" + public $array_export_label=array(); // Tableau de "libelle de lots" + public $array_export_sql_start=array(); // Tableau des "requetes sql" + public $array_export_sql_end=array(); // Tableau des "requetes sql" + public $array_export_sql_order=array(); // Tableau des "requetes sql" - var $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter - var $array_export_TypeFields=array(); // Tableau des listes de champ+Type de filtre - var $array_export_FilterValue=array(); // Tableau des listes de champ+Valeur a filtrer - var $array_export_entities=array(); // Tableau des listes de champ+alias a exporter - var $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export - var $array_export_special=array(); // Tableau des operations speciales sur champ - var $array_export_examplevalues=array(); // array with examples + public $array_export_fields=array(); // Tableau des listes de champ+libelle a exporter + public $array_export_TypeFields=array(); // Tableau des listes de champ+Type de filtre + public $array_export_FilterValue=array(); // Tableau des listes de champ+Valeur a filtrer + public $array_export_entities=array(); // Tableau des listes de champ+alias a exporter + public $array_export_dependencies=array(); // array of list of entities that must take care of the DISTINCT if a field is added into export + public $array_export_special=array(); // Tableau des operations speciales sur champ + public $array_export_examplevalues=array(); // array with examples - // To store export modules - var $hexa; - var $hexafiltervalue; - var $datatoexport; - var $model_name; + // To store export modules + public $hexa; + public $hexafiltervalue; + public $datatoexport; + public $model_name; - var $sqlusedforexport; + public $sqlusedforexport; /** @@ -64,13 +64,13 @@ class Export * * @param DoliDB $db Database handler */ - function __construct($db) - { - $this->db=$db; - } + public function __construct($db) + { + $this->db=$db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load an exportable dataset * @@ -78,12 +78,12 @@ class Export * @param string $filter Load a particular dataset only * @return int <0 if KO, >0 if OK */ - function load_arrays($user, $filter = '') - { + public function load_arrays($user, $filter = '') + { // phpcs:enable - global $langs,$conf,$mysoc; + global $langs,$conf,$mysoc; - dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter); + dol_syslog(get_class($this)."::load_arrays user=".$user->id." filter=".$filter); $i=0; @@ -206,10 +206,10 @@ class Export } return 1; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the sql export request. * Arrays this->array_export_xxx are already loaded for required datatoexport @@ -219,8 +219,8 @@ class Export * @param array $array_filterValue Filter records on array of value for fields * @return string SQL String. Example "select s.rowid as r_rowid, s.status as s_status from ..." */ - function build_sql($indice, $array_selected, $array_filterValue) - { + public function build_sql($indice, $array_selected, $array_filterValue) + { // phpcs:enable // Build the sql request $sql=$this->array_export_sql_start[$indice]; @@ -273,7 +273,7 @@ class Export return $sql; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build the conditionnal string from filter the query * @@ -282,8 +282,8 @@ class Export * @param string $ValueField Value of the field for filter. Must not be '' * @return string sql string of then field ex : "field='xxx'>" */ - function build_filterQuery($TypeField, $NameField, $ValueField) - { + public function build_filterQuery($TypeField, $NameField, $ValueField) + { // phpcs:enable //print $TypeField." ".$NameField." ".$ValueField; $InfoFieldList = explode(":", $TypeField); @@ -352,23 +352,23 @@ class Export } /** - * conditionDate + * conditionDate * * @param string $Field Field operand 1 * @param string $Value Value operand 2 * @param string $Sens Comparison operator * @return string */ - function conditionDate($Field, $Value, $Sens) - { + public function conditionDate($Field, $Value, $Sens) + { // TODO date_format is forbidden, not performant and not portable. Use instead BETWEEN if (strlen($Value)==4) $Condition=" date_format(".$Field.",'%Y') ".$Sens." '".$Value."'"; elseif (strlen($Value)==6) $Condition=" date_format(".$Field.",'%Y%m') ".$Sens." '".$Value."'"; else $Condition=" date_format(".$Field.",'%Y%m%d') ".$Sens." ".$Value; return $Condition; - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build an input field used to filter the query * @@ -377,8 +377,8 @@ class Export * @param string $ValueField Initial value of the field to filter * @return string html string of the input field ex : "" */ - function build_filterField($TypeField, $NameField, $ValueField) - { + public function build_filterField($TypeField, $NameField, $ValueField) + { // phpcs:enable global $conf,$langs; @@ -488,16 +488,16 @@ class Export } return $szFilterField; - } + } - /** - * Build an input field used to filter the query - * - * @param string $TypeField Type of Field to filter - * @return string html string of the input field ex : "" - */ - function genDocFilter($TypeField) - { + /** + * Build an input field used to filter the query + * + * @param string $TypeField Type of Field to filter + * @return string html string of the input field ex : "" + */ + public function genDocFilter($TypeField) + { global $langs; $szMsg=''; @@ -523,7 +523,7 @@ class Export return $szMsg; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build export file. * File is built into directory $conf->export->dir_temp.'/'.$user->id @@ -537,8 +537,8 @@ class Export * @param string $sqlquery If set, transmit the sql request for select (otherwise, sql request is generated from arrays) * @return int <0 if KO, >0 if OK */ - function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') - { + public function build_file($user, $model, $datatoexport, $array_selected, $array_filterValue, $sqlquery = '') + { // phpcs:enable global $conf,$langs; @@ -698,7 +698,7 @@ class Export * @param User $user Object user that save * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf; @@ -741,11 +741,11 @@ class Export /** * Load an export profil from database * - * @param int $id Id of profil to load - * @return int <0 if KO, >0 if OK + * @param int $id Id of profil to load + * @return int <0 if KO, >0 if OK */ - function fetch($id) - { + public function fetch($id) + { $sql = 'SELECT em.rowid, em.label, em.type, em.field, em.filter'; $sql.= ' FROM '.MAIN_DB_PREFIX.'export_model as em'; $sql.= ' WHERE em.rowid = '.$id; @@ -757,12 +757,12 @@ class Export $obj = $this->db->fetch_object($result); if ($obj) { - $this->id = $obj->rowid; - $this->model_name = $obj->label; - $this->datatoexport = $obj->type; + $this->id = $obj->rowid; + $this->model_name = $obj->label; + $this->datatoexport = $obj->type; - $this->hexa = $obj->field; - $this->hexafiltervalue = $obj->filter; + $this->hexa = $obj->field; + $this->hexafiltervalue = $obj->filter; return 1; } @@ -787,7 +787,7 @@ class Export * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -835,15 +835,15 @@ class Export } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output list all export models * TODO Move this into a class htmlxxx.class.php * * @return void */ - function list_export_model() - { + public function list_export_model() + { // phpcs:enable global $conf, $langs; @@ -886,9 +886,8 @@ class Export $i++; } - } - else { - dol_print_error($this->db); - } - } + } else { + dol_print_error($this->db); + } + } } diff --git a/htdocs/fichinter/class/api_interventions.class.php b/htdocs/fichinter/class/api_interventions.class.php index 26173db12af..d49f58ed52e 100644 --- a/htdocs/fichinter/class/api_interventions.class.php +++ b/htdocs/fichinter/class/api_interventions.class.php @@ -55,10 +55,10 @@ class Interventions extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->fichinter = new Fichinter($this->db); } @@ -72,23 +72,23 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention report not found'); - } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention report not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fichinter', $this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->fichinter->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->fichinter); + $this->fichinter->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->fichinter); } /** @@ -106,7 +106,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') { global $db, $conf; @@ -130,8 +130,7 @@ class Interventions extends DolibarrApi if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter - if ($search_sale > 0) - { + if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters @@ -141,7 +140,7 @@ class Interventions extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -169,7 +168,7 @@ class Interventions extends DolibarrApi $obj = $db->fetch_object($result); $fichinter_static = new Fichinter($db); if($fichinter_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($fichinter_static); + $obj_ret[] = $this->_cleanObjectDatas($fichinter_static); } $i++; } @@ -180,7 +179,7 @@ class Interventions extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No finchinter found'); } - return $obj_ret; + return $obj_ret; } /** @@ -189,7 +188,7 @@ class Interventions extends DolibarrApi * @param array $request_data Request data * @return int ID of intervention */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,28 +217,28 @@ class Interventions extends DolibarrApi * @return int */ /* TODO - function getLines($id) + public function getLines($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->lire) { + throw new RestException(401); + } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention not found'); - } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - $this->fichinter->getLinesArray(); - $result = array(); - foreach ($this->fichinter->lines as $line) { - array_push($result,$this->_cleanObjectDatas($line)); - } - return $result; + if( ! DolibarrApi::_checkAccessToResource('fichinter',$this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $this->fichinter->getLinesArray(); + $result = array(); + foreach ($this->fichinter->lines as $line) { + array_push($result,$this->_cleanObjectDatas($line)); + } + return $result; } - */ + */ /** * Add a line to given intervention @@ -251,7 +250,7 @@ class Interventions extends DolibarrApi * * @return int */ - function postLine($id, $request_data = null) + public function postLine($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -292,30 +291,30 @@ class Interventions extends DolibarrApi * @param int $id Order ID * @return array */ - function delete($id) + public function delete($id) { - if(! DolibarrApiAccess::$user->rights->ficheinter->supprimer) { - throw new RestException(401); - } - $result = $this->fichinter->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Intervention not found'); - } + if(! DolibarrApiAccess::$user->rights->ficheinter->supprimer) { + throw new RestException(401); + } + $result = $this->fichinter->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Intervention not found'); + } - if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('commande', $this->fichinter->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - if( ! $this->fichinter->delete(DolibarrApiAccess::$user)) { - throw new RestException(500, 'Error when delete intervention : '.$this->fichinter->error); - } + if( ! $this->fichinter->delete(DolibarrApiAccess::$user)) { + throw new RestException(500, 'Error when delete intervention : '.$this->fichinter->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Intervention deleted' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Intervention deleted' + ) + ); } /** @@ -333,7 +332,7 @@ class Interventions extends DolibarrApi * * @return array */ - function validate($id, $notrigger = 0) + public function validate($id, $notrigger = 0) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { throw new RestException(401, "Insuffisant rights"); @@ -369,7 +368,7 @@ class Interventions extends DolibarrApi * * @return array */ - function closeFichinter($id) + public function closeFichinter($id) { if(! DolibarrApiAccess::$user->rights->ficheinter->creer) { @@ -406,7 +405,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $fichinter = array(); foreach (Interventions::$FIELDS as $field) { @@ -424,16 +423,16 @@ class Interventions extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - unset($object->statuts_short); - unset($object->statuts_logo); - unset($object->statuts); + unset($object->statuts_short); + unset($object->statuts_logo); + unset($object->statuts); - return $object; + return $object; } /** @@ -444,7 +443,7 @@ class Interventions extends DolibarrApi * * @throws RestException */ - function _validateLine($data) + private function _validateLine($data) { $fichinter = array(); foreach (Interventions::$FIELDSLINE as $field) { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 00210277db1..43cd79bfe70 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -122,20 +122,20 @@ class Fichinter extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) - { + public function __construct($db) + { $this->db = $db; $this->products = array(); - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators into this->nb for board * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $user; @@ -179,7 +179,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs; @@ -313,7 +313,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable all triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { if (! is_numeric($this->duration)) { $this->duration = 0; @@ -373,7 +373,7 @@ class Fichinter extends CommonObject * @param string $ref Ref of intervention * @return int <0 if KO, >0 if OK */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { $sql = "SELECT f.rowid, f.ref, f.description, f.fk_soc, f.fk_statut,"; $sql.= " f.datec, f.dateo, f.datee, f.datet, f.fk_user_author,"; @@ -410,12 +410,12 @@ class Fichinter extends CommonObject $this->fk_project = $obj->fk_project; $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; - $this->modelpdf = $obj->model_pdf; - $this->fk_contrat = $obj->fk_contrat; + $this->modelpdf = $obj->model_pdf; + $this->fk_contrat = $obj->fk_contrat; - $this->user_creation= $obj->fk_user_author; + $this->user_creation = $obj->fk_user_author; - $this->extraparams = (array) json_decode($obj->extraparams, true); + $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; @@ -447,7 +447,7 @@ class Fichinter extends CommonObject * @param User $user User that set draft * @return int <0 if KO, >0 if OK */ - function setDraft($user) + public function setDraft($user) { global $langs, $conf; @@ -483,7 +483,7 @@ class Fichinter extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function setValid($user, $notrigger = 0) + public function setValid($user, $notrigger = 0) { global $conf; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -595,7 +595,7 @@ class Fichinter extends CommonObject * * @return float Amount */ - function getAmount() + public function getAmount() { global $db; @@ -653,12 +653,12 @@ class Fichinter extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the label of a statut * @@ -666,7 +666,7 @@ class Fichinter extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable // Init/load array of translation of status @@ -716,7 +716,7 @@ class Fichinter extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $save_lastsearch_value = -1) { global $conf, $langs, $hookmanager; @@ -782,7 +782,7 @@ class Fichinter extends CommonObject * @param Societe $soc Thirdparty object * @return string Free reference for intervention */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf, $db, $langs; $langs->load("interventions"); @@ -838,7 +838,7 @@ class Fichinter extends CommonObject * @param int $id Id of object * @return void */ - function info($id) + public function info($id) { global $conf; @@ -897,7 +897,7 @@ class Fichinter extends CommonObject * @param int $notrigger Disable trigger * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -1002,16 +1002,16 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Defines a delivery date of intervention + * Defines a delivery date of intervention * - * @param User $user Object user who define - * @param date $date_delivery date of delivery - * @return int <0 if ko, >0 if ok - */ - function set_date_delivery($user, $date_delivery) - { + * @param User $user Object user who define + * @param date $date_delivery date of delivery + * @return int <0 if ko, >0 if ok + */ + public function set_date_delivery($user, $date_delivery) + { // phpcs:enable global $conf; @@ -1036,7 +1036,7 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Define the label of the intervention * @@ -1044,7 +1044,7 @@ class Fichinter extends CommonObject * @param string $description description * @return int <0 if KO, >0 if OK */ - function set_description($user, $description) + public function set_description($user, $description) { // phpcs:enable global $conf; @@ -1071,7 +1071,7 @@ class Fichinter extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Link intervention to a contract * @@ -1079,8 +1079,8 @@ class Fichinter extends CommonObject * @param int $contractid Description * @return int <0 if ko, >0 if ok */ - function set_contrat($user, $contractid) - { + public function set_contrat($user, $contractid) + { // phpcs:enable global $conf; @@ -1112,7 +1112,7 @@ class Fichinter extends CommonObject * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$hookmanager; @@ -1205,7 +1205,7 @@ class Fichinter extends CommonObject * @param array $array_options Array option * @return int >0 if ok, <0 if ko */ - function addline($user, $fichinterid, $desc, $date_intervention, $duration, $array_options = '') + public function addline($user, $fichinterid, $desc, $date_intervention, $duration, $array_options = '') { dol_syslog(get_class($this)."::addline $fichinterid, $desc, $date_intervention, $duration"); @@ -1249,7 +1249,7 @@ class Fichinter extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; @@ -1280,14 +1280,14 @@ class Fichinter extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines ->lines * * @return int <0 if KO, >0 if OK */ - function fetch_lines() - { + public function fetch_lines() + { // phpcs:enable $this->lines = array(); @@ -1395,7 +1395,7 @@ class FichinterLigne extends CommonObjectLine * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -1406,7 +1406,7 @@ class FichinterLigne extends CommonObjectLine * @param int $rowid Line id * @return int <0 if KO, >0 if OK */ - function fetch($rowid) + public function fetch($rowid) { $sql = 'SELECT ft.rowid, ft.fk_fichinter, ft.description, ft.duree, ft.rang,'; $sql.= ' ft.date as datei'; @@ -1443,7 +1443,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int <0 if ko, >0 if ok */ - function insert($user, $notrigger = 0) + public function insert($user, $notrigger = 0) { global $langs,$conf; @@ -1539,7 +1539,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int <0 if ko, >0 if ok */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $langs,$conf; @@ -1600,13 +1600,13 @@ class FichinterLigne extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update total duration into llx_fichinter * * @return int <0 si ko, >0 si ok */ - function update_total() + public function update_total() { // phpcs:enable global $conf; @@ -1660,7 +1660,7 @@ class FichinterLigne extends CommonObjectLine * @param int $notrigger Disable all triggers * @return int >0 if ok, <0 if ko */ - function deleteline($user, $notrigger = 0) + public function deleteline($user, $notrigger = 0) { global $langs,$conf; diff --git a/htdocs/fichinter/class/fichinterstats.class.php b/htdocs/fichinter/class/fichinterstats.class.php index 80d7e6107c8..7112f6cdf77 100644 --- a/htdocs/fichinter/class/fichinterstats.class.php +++ b/htdocs/fichinter/class/fichinterstats.class.php @@ -33,181 +33,181 @@ include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; */ class FichinterStats extends Stats { - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element; - var $socid; - var $userid; + public $socid; + public $userid; - var $from; - var $field; - var $where; + public $from; + public $field; + public $where; - /** - * Constructor - * - * @param DoliDB $db Database handler - * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. - * @param string $mode Option ('customer', 'supplier') - * @param int $userid Id user for filter (creation user) - */ - function __construct($db, $socid, $mode, $userid = 0) - { - global $user, $conf; + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param int $socid Id third party for filter. This value must be forced during the new to external user company if user is an external user. + * @param string $mode Option ('customer', 'supplier') + * @param int $userid Id user for filter (creation user) + */ + public function __construct($db, $socid, $mode, $userid = 0) + { + global $user, $conf; - $this->db = $db; + $this->db = $db; - $this->socid = ($socid > 0 ? $socid : 0); + $this->socid = ($socid > 0 ? $socid : 0); $this->userid = $userid; - $this->cachefilesuffix = $mode; + $this->cachefilesuffix = $mode; - $this->where.= " c.entity = ".$conf->entity; - if ($mode == 'customer') - { - $object=new Fichinter($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; - $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; - $this->field='0'; - $this->field_line='0'; - //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled - } - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($this->socid) - { - $this->where.=" AND c.fk_soc = ".$this->socid; - } + $this->where.= " c.entity = ".$conf->entity; + if ($mode == 'customer') + { + $object=new Fichinter($this->db); + $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; + $this->from_line = MAIN_DB_PREFIX.$object->table_element_line." as tl"; + $this->field='0'; + $this->field_line='0'; + //$this->where.= " AND c.fk_statut > 0"; // Not draft and not cancelled + } + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($this->socid) + { + $this->where.=" AND c.fk_soc = ".$this->socid; + } if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; - } + } - /** - * Return intervention number by month for a year - * - * @param int $year Year to scan + /** + * Return intervention number by month for a year + * + * @param int $year Year to scan * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @return array Array with number by month - */ - function getNbByMonth($year, $format = 0) - { - global $user; + * @return array Array with number by month + */ + public function getNbByMonth($year, $format = 0) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getNbByMonth($year, $sql, $format); - return $res; - } + $res=$this->_getNbByMonth($year, $sql, $format); + return $res; + } - /** - * Return interventions number per year - * - * @return array Array with number by year - * - */ - function getNbByYear() - { - global $user; + /** + * Return interventions number per year + * + * @return array Array with number by year + * + */ + public function getNbByYear() + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - return $this->_getNbByYear($sql); - } + return $this->_getNbByYear($sql); + } - /** - * Return the intervention amount by month for a year - * - * @param int $year Year to scan + /** + * Return the intervention amount by month for a year + * + * @param int $year Year to scan * @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is month number, 2=Label of absiss is first letter of month - * @return array Array with amount by month - */ - function getAmountByMonth($year, $format = 0) - { - global $user; + * @return array Array with amount by month + */ + public function getAmountByMonth($year, $format = 0) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - $res=$this->_getAmountByMonth($year, $sql, $format); - return $res; - } + $res=$this->_getAmountByMonth($year, $sql, $format); + return $res; + } - /** - * Return the intervention amount average by month for a year - * - * @param int $year year for stats - * @return array array with number by month - */ - function getAverageByMonth($year) - { - global $user; + /** + * Return the intervention amount average by month for a year + * + * @param int $year year for stats + * @return array array with number by month + */ + public function getAverageByMonth($year) + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; - $sql.= " AND ".$this->where; - $sql.= " GROUP BY dm"; + $sql = "SELECT date_format(c.date_valid,'%m') as dm, 0"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm', 'DESC'); - return $this->_getAverageByMonth($year, $sql); - } + return $this->_getAverageByMonth($year, $sql); + } - /** - * Return nb, total and average - * - * @return array Array of values - */ - function getAllByYear() - { - global $user; + /** + * Return nb, total and average + * + * @return array Array of values + */ + public function getAllByYear() + { + global $user; - $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg"; - $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " GROUP BY year"; + $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, 0 as total, 0 as avg"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; $sql.= $this->db->order('year', 'DESC'); - return $this->_getAllByYear($sql); - } + return $this->_getAllByYear($sql); + } - /** - * Return nb, amount of predefined product for year - * - * @param int $year Year to scan - * @return array Array of values - */ - function getAllByProduct($year) - { - global $user; + /** + * Return nb, amount of predefined product for year + * + * @param int $year Year to scan + * @return array Array of values + */ + public function getAllByProduct($year) + { + global $user; - $sql = "SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg"; - $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; - //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE ".$this->where; - $sql.= " AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid"; - $sql.= " AND c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; - $sql.= " GROUP BY product.ref"; + $sql = "SELECT product.ref, COUNT(product.ref) as nb, 0 as total, 0 as avg"; + $sql.= " FROM ".$this->from.", ".$this->from_line.", ".MAIN_DB_PREFIX."product as product"; + //if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " AND c.rowid = tl.fk_fichinter AND tl.fk_product = product.rowid"; + $sql.= " AND c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'"; + $sql.= " GROUP BY product.ref"; $sql.= $this->db->order('nb', 'DESC'); //$sql.= $this->db->plimit(20); - return $this->_getAllByProduct($sql); - } + return $this->_getAllByProduct($sql); + } } diff --git a/htdocs/fourn/class/api_supplier_invoices.class.php b/htdocs/fourn/class/api_supplier_invoices.class.php index 4391d14ea3c..3f94401bc9d 100644 --- a/htdocs/fourn/class/api_supplier_invoices.class.php +++ b/htdocs/fourn/class/api_supplier_invoices.class.php @@ -44,10 +44,10 @@ class SupplierInvoices extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->invoice = new FactureFournisseur($this->db); } @@ -61,23 +61,23 @@ class SupplierInvoices extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->fournisseur->facture->lire) { + throw new RestException(401); + } $result = $this->invoice->fetch($id); if( ! $result ) { throw new RestException(404, 'Supplier invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->invoice->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->invoice); + $this->invoice->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->invoice); } /** @@ -94,9 +94,9 @@ class SupplierInvoices extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" * @return array Array of invoice objects * - * @throws RestException + * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') { global $db, $conf; @@ -120,14 +120,21 @@ class SupplierInvoices extends DolibarrApi if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - // Filter by status - if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; - if ($status == 'unpaid') $sql.= " AND t.fk_statut IN (1)"; - if ($status == 'paid') $sql.= " AND t.fk_statut IN (2)"; - if ($status == 'cancelled') $sql.= " AND t.fk_statut IN (3)"; + // Filter by status + if ($status == 'draft') { + $sql.= " AND t.fk_statut IN (0)"; + } + if ($status == 'unpaid') { + $sql.= " AND t.fk_statut IN (1)"; + } + if ($status == 'paid') { + $sql.= " AND t.fk_statut IN (2)"; + } + if ($status == 'cancelled') { + $sql.= " AND t.fk_statut IN (3)"; + } // Insert sale filter - if ($search_sale > 0) - { + if ($search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } // Add sql filters @@ -137,7 +144,7 @@ class SupplierInvoices extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -182,7 +189,7 @@ class SupplierInvoices extends DolibarrApi * @param array $request_data Request datas * @return int ID of supplier invoice */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { throw new RestException(401, "Insuffisant rights"); @@ -218,7 +225,7 @@ class SupplierInvoices extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { throw new RestException(401); @@ -229,9 +236,9 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; @@ -250,7 +257,7 @@ class SupplierInvoices extends DolibarrApi * @param int $id Supplier invoice ID * @return type */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->fournisseur->facture->supprimer) { throw new RestException(401); @@ -260,9 +267,9 @@ class SupplierInvoices extends DolibarrApi throw new RestException(404, 'Supplier invoice not found'); } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if( $this->invoice->delete(DolibarrApiAccess::$user) < 0) { @@ -296,34 +303,34 @@ class SupplierInvoices extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { - throw new RestException(401); - } - $result = $this->invoice->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Invoice not found'); - } + if(! DolibarrApiAccess::$user->rights->fournisseur->facture->creer) { + throw new RestException(401); + } + $result = $this->invoice->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Invoice not found'); + } if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->invoice->id, 'facture_fourn', 'facture')) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); - } + $result = $this->invoice->validate(DolibarrApiAccess::$user, '', $idwarehouse, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Invoice: '.$this->invoice->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Invoice validated (Ref='.$this->invoice->ref.')' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Invoice validated (Ref='.$this->invoice->ref.')' + ) + ); } /** @@ -332,7 +339,7 @@ class SupplierInvoices extends DolibarrApi * @param Object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -354,7 +361,7 @@ class SupplierInvoices extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $invoice = array(); foreach (SupplierInvoices::$FIELDS as $field) { diff --git a/htdocs/fourn/class/api_supplier_orders.class.php b/htdocs/fourn/class/api_supplier_orders.class.php index 38c9ab9e200..9a898fae3a7 100644 --- a/htdocs/fourn/class/api_supplier_orders.class.php +++ b/htdocs/fourn/class/api_supplier_orders.class.php @@ -44,7 +44,7 @@ class SupplierOrders extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -61,23 +61,23 @@ class SupplierOrders extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->lire) { + throw new RestException(401); + } $result = $this->order->fetch($id); if ( ! $result ) { throw new RestException(404, 'Supplier order not found'); } - if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $this->order->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->order); + $this->order->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->order); } /** @@ -94,9 +94,9 @@ class SupplierOrders extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" * @return array Array of order objects * - * @throws RestException + * @throws RestException */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $status = '', $sqlfilters = '') { global $db, $conf; @@ -120,7 +120,7 @@ class SupplierOrders extends DolibarrApi if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - // Filter by status + // Filter by status if ($status == 'draft') $sql.= " AND t.fk_statut IN (0)"; if ($status == 'validated') $sql.= " AND t.fk_statut IN (1)"; if ($status == 'approved') $sql.= " AND t.fk_statut IN (2)"; @@ -141,7 +141,7 @@ class SupplierOrders extends DolibarrApi { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } @@ -178,7 +178,7 @@ class SupplierOrders extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No supplier order found'); } - return $obj_ret; + return $obj_ret; } /** @@ -187,7 +187,7 @@ class SupplierOrders extends DolibarrApi * @param array $request_data Request datas * @return int ID of supplier order */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { throw new RestException(401, "Insuffisant rights"); @@ -223,7 +223,7 @@ class SupplierOrders extends DolibarrApi * @param array $request_data Datas * @return int */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { throw new RestException(401); @@ -234,9 +234,9 @@ class SupplierOrders extends DolibarrApi throw new RestException(404, 'Supplier order not found'); } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { if ($field == 'id') continue; @@ -255,7 +255,7 @@ class SupplierOrders extends DolibarrApi * @param int $id Supplier order ID * @return type */ - function delete($id) + public function delete($id) { if (! DolibarrApiAccess::$user->rights->fournisseur->commande->supprimer) { throw new RestException(401); @@ -265,9 +265,9 @@ class SupplierOrders extends DolibarrApi throw new RestException(404, 'Supplier order not found'); } - if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if ( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if ( $this->order->delete(DolibarrApiAccess::$user) < 0) { throw new RestException(500); @@ -300,34 +300,34 @@ class SupplierOrders extends DolibarrApi * "notrigger": 0 * } */ - function validate($id, $idwarehouse = 0, $notrigger = 0) + public function validate($id, $idwarehouse = 0, $notrigger = 0) { - if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { - throw new RestException(401); - } - $result = $this->order->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Order not found'); - } + if(! DolibarrApiAccess::$user->rights->fournisseur->commande->creer) { + throw new RestException(401); + } + $result = $this->order->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Order not found'); + } - if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('fournisseur', $this->order->id, '', 'commande')) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger); - if ($result == 0) { - throw new RestException(304, 'Error nothing done. May be object is already validated'); - } - if ($result < 0) { - throw new RestException(500, 'Error when validating Order: '.$this->order->error); - } + $result = $this->order->valid(DolibarrApiAccess::$user, $idwarehouse, $notrigger); + if ($result == 0) { + throw new RestException(304, 'Error nothing done. May be object is already validated'); + } + if ($result < 0) { + throw new RestException(500, 'Error when validating Order: '.$this->order->error); + } - return array( - 'success' => array( - 'code' => 200, - 'message' => 'Order validated (Ref='.$this->order->ref.')' - ) - ); + return array( + 'success' => array( + 'code' => 200, + 'message' => 'Order validated (Ref='.$this->order->ref.')' + ) + ); } /** @@ -336,7 +336,7 @@ class SupplierOrders extends DolibarrApi * @param Object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -358,7 +358,7 @@ class SupplierOrders extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $order = array(); foreach (SupplierOrders::$FIELDS as $field) { diff --git a/htdocs/fourn/class/fournisseur.class.php b/htdocs/fourn/class/fournisseur.class.php index 0636a356111..42e9b9153db 100644 --- a/htdocs/fourn/class/fournisseur.class.php +++ b/htdocs/fourn/class/fournisseur.class.php @@ -33,7 +33,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; */ class Fournisseur extends Societe { - var $next_prev_filter="te.fournisseur = 1"; // Used to add a filter in Form::showrefnav method + public $next_prev_filter="te.fournisseur = 1"; // Used to add a filter in Form::showrefnav method /** @@ -41,7 +41,7 @@ class Fournisseur extends Societe * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -55,7 +55,7 @@ class Fournisseur extends Societe * * @return int Nb of orders */ - function getNbOfOrders() + public function getNbOfOrders() { $sql = "SELECT rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; @@ -81,7 +81,7 @@ class Fournisseur extends Societe * * @return int Nb of ref prices, or <0 if error */ - function nbOfProductRefs() + public function nbOfProductRefs() { global $conf; @@ -102,13 +102,13 @@ class Fournisseur extends Societe } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load statistics indicators * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -145,7 +145,7 @@ class Fournisseur extends Societe } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a supplier category * @@ -153,7 +153,7 @@ class Fournisseur extends Societe * @param string $name Category name * @return int <0 if KO, 0 if OK */ - function CreateCategory($user, $name) + public function CreateCategory($user, $name) { // phpcs:enable $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label,visible,type)"; @@ -175,13 +175,13 @@ class Fournisseur extends Societe } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return the suppliers list * * @return array Array of suppliers */ - function ListArray() + public function ListArray() { // phpcs:enable global $conf; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9ee3883bb60..fbc53183ea1 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -9,7 +9,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2018 Nicolas ZABOURI - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Ferran Marcet * * This program is free software; you can redistribute it and/or modify @@ -262,7 +262,7 @@ class CommandeFournisseur extends CommonOrder $sql.= " c.date_commande as date_commande, c.date_livraison as date_livraison, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_projet as fk_project, c.remise_percent, c.source, c.fk_input_method,"; $sql.= " c.fk_account,"; $sql.= " c.note_private, c.note_public, c.model_pdf, c.extraparams, c.billed,"; - $sql.= " c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc,"; + $sql.= " c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc,"; $sql.= " cm.libelle as methode_commande,"; $sql.= " cr.code as cond_reglement_code, cr.libelle as cond_reglement_libelle,"; $sql.= " p.code as mode_reglement_code, p.libelle as mode_reglement_libelle"; @@ -272,7 +272,7 @@ class CommandeFournisseur extends CommonOrder $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_payment_term as cr ON c.fk_cond_reglement = cr.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as p ON c.fk_mode_reglement = p.id"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_input_method as cm ON cm.rowid = c.fk_input_method"; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_incoterms as i ON c.fk_incoterms = i.rowid'; $sql.= " WHERE c.entity = ".$conf->entity; if ($ref) $sql.= " AND c.ref='".$this->db->escape($ref)."'"; else $sql.= " AND c.rowid=".$id; @@ -375,14 +375,14 @@ class CommandeFournisseur extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load array lines * * @param int $only_product Return only physical products * @return int <0 if KO, >0 if OK */ - function fetch_lines($only_product = 0) + public function fetch_lines($only_product = 0) { // phpcs:enable //$result=$this->fetch_lines(); @@ -616,7 +616,7 @@ class CommandeFournisseur extends CommonOrder return $this->LibStatut($this->statut, $mode, $this->billed); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -625,7 +625,7 @@ class CommandeFournisseur extends CommonOrder * @param int $billed 1=Billed * @return string Label of status */ - function LibStatut($statut, $mode = 0, $billed = 0) + public function LibStatut($statut, $mode = 0, $billed = 0) { // phpcs:enable global $conf, $langs; @@ -1079,7 +1079,7 @@ class CommandeFournisseur extends CommonOrder return $result ; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Cancel an approved order. * The cancellation is done after approval @@ -1088,12 +1088,12 @@ class CommandeFournisseur extends CommonOrder * @param int $idwarehouse Id warehouse to use for stock change (not used for supplier orders). * @return int >0 if Ok, <0 if Ko */ - function Cancel($user, $idwarehouse = -1) + public function Cancel($user, $idwarehouse = -1) { // phpcs:enable global $langs,$conf; - $error=0; + $error=0; //dol_syslog("CommandeFournisseur::Cancel"); $result = 0; @@ -2006,13 +2006,13 @@ class CommandeFournisseur extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Get list of order methods * * @return int 0 if OK, <0 if KO */ - function get_methodes_commande() + public function get_methodes_commande() { // phpcs:enable $sql = "SELECT rowid, libelle"; @@ -2093,7 +2093,7 @@ class CommandeFournisseur extends CommonOrder } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set a delivery in database for this supplier order * @@ -2103,7 +2103,7 @@ class CommandeFournisseur extends CommonOrder * @param string $comment Comment * @return int <0 if KO, >0 if OK */ - function Livraison($user, $date, $type, $comment) + public function Livraison($user, $date, $type, $comment) { // phpcs:enable global $conf, $langs; @@ -2210,7 +2210,7 @@ class CommandeFournisseur extends CommonOrder return $result ; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the planned delivery date * @@ -2219,7 +2219,7 @@ class CommandeFournisseur extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function set_date_livraison($user, $date_livraison, $notrigger = 0) + public function set_date_livraison($user, $date_livraison, $notrigger = 0) { // phpcs:enable if ($user->rights->fournisseur->commande->creer) @@ -2276,7 +2276,7 @@ class CommandeFournisseur extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the id projet * @@ -2285,7 +2285,7 @@ class CommandeFournisseur extends CommonOrder * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 si ko, >0 si ok */ - function set_id_projet($user, $id_projet, $notrigger = 0) + public function set_id_projet($user, $id_projet, $notrigger = 0) { // phpcs:enable if ($user->rights->fournisseur->commande->creer) @@ -2469,7 +2469,7 @@ class CommandeFournisseur extends CommonOrder */ public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $type = 0, $notrigger = 0, $date_start = '', $date_end = '', $array_options = 0, $fk_unit = null, $pu_ht_devise = 0, $ref_supplier = '') { - global $mysoc, $conf; + global $mysoc, $conf; dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $txtva, $price_base_type, $info_bits, $type, $fk_unit"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -2739,13 +2739,13 @@ class CommandeFournisseur extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 si ko, >0 si ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -2782,14 +2782,14 @@ class CommandeFournisseur extends CommonOrder } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Objet user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -2918,7 +2918,7 @@ class CommandeFournisseur extends CommonOrder * @return Translated string */ public function getMaxDeliveryTimeDay($langs) - { + { if (empty($this->lines)) return ''; $obj = new ProductFournisseur($this->db); @@ -3155,7 +3155,7 @@ class CommandeFournisseur extends CommonOrder * @param int $filtre_statut Filter on shipment status * @return int <0 if KO, Nb of lines found if OK */ - function loadReceptions($filtre_statut = -1) + public function loadReceptions($filtre_statut = -1) { $this->receptions = array(); @@ -3579,7 +3579,7 @@ class CommandeFournisseurLigne extends CommonOrderLine * @param int $notrigger 1=Disable call to triggers * @return int <0 if KO, >0 if OK */ - function delete($notrigger) + public function delete($notrigger) { global $user; diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 49f23cf5191..6db4607573c 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -17,21 +17,19 @@ */ /** - * \file fourn/class/fournisseur.commande.dispatch.class.php + * \file htdocs/fourn/class/fournisseur.commande.dispatch.class.php * \ingroup fournisseur stock * \brief This file is an example for a CRUD class file (Create/Read/Update/Delete) - * Initialy built by build_class_from_table on 2015-02-24 10:38 + * Initialy built by build_class_from_table on 2015-02-24 10:38 */ // Put here all includes required by your class file require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; require_once DOL_DOCUMENT_ROOT."/reception/class/reception.class.php"; -//require_once DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"; -//require_once DOL_DOCUMENT_ROOT."/product/class/product.class.php"; /** - * Class to manage table commandefournisseurdispatch + * Class to manage table commandefournisseurdispatch */ class CommandeFournisseurDispatch extends CommonObject { @@ -114,7 +112,7 @@ class CommandeFournisseurDispatch extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -135,7 +133,7 @@ class CommandeFournisseurDispatch extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf, $langs, $hookmanager; $error=0; @@ -256,7 +254,7 @@ class CommandeFournisseurDispatch extends CommonObject * @param string $ref Ref * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $langs; $sql = "SELECT"; @@ -325,7 +323,7 @@ class CommandeFournisseurDispatch extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user, $notrigger = 0) + public function update($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -420,7 +418,7 @@ class CommandeFournisseurDispatch extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -477,7 +475,7 @@ class CommandeFournisseurDispatch extends CommonObject * @param int $fromid Id of object to clone * @return int New id of clone */ - function createFromClone($fromid) + public function createFromClone($fromid) { global $user,$langs; @@ -531,15 +529,15 @@ class CommandeFournisseurDispatch extends CommonObject /** * Return label of the status of object * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status * @@ -547,7 +545,7 @@ class CommandeFournisseurDispatch extends CommonObject * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -568,20 +566,20 @@ class CommandeFournisseurDispatch extends CommonObject elseif ($mode == 3) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4'); - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4'); + elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut8'); } elseif ($mode == 4) { if ($statut==0) return img_picto($langs->trans($this->statuts[$statut]), 'statut0').' '.$langs->trans($this->statuts[$statut]); - if ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); - if ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut==1) return img_picto($langs->trans($this->statuts[$statut]), 'statut4').' '.$langs->trans($this->statuts[$statut]); + elseif ($statut==2) return img_picto($langs->trans($this->statuts[$statut]), 'statut8').' '.$langs->trans($this->statuts[$statut]); } elseif ($mode == 5) { if ($statut==0) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut0'); - if ($statut==1) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut4'); - if ($statut==2) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut8'); + elseif ($statut==1) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut4'); + elseif ($statut==2) return ''.$langs->trans($this->statutshort[$statut]).' '.img_picto($langs->trans($this->statuts[$statut]), 'statut8'); } } @@ -592,7 +590,7 @@ class CommandeFournisseurDispatch extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { $this->id=0; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 05b6754bc5d..d2c7ad43a00 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -29,9 +29,9 @@ */ /** - * \file htdocs/fourn/class/fournisseur.facture.class.php - * \ingroup fournisseur,facture - * \brief File of class to manage suppliers invoices + * \file htdocs/fourn/class/fournisseur.facture.class.php + * \ingroup fournisseur,facture + * \brief File of class to manage suppliers invoices */ include_once DOL_DOCUMENT_ROOT.'/core/class/commoninvoice.class.php'; @@ -53,14 +53,14 @@ class FactureFournisseur extends CommonInvoice public $table_element='facture_fourn'; /** - * @var int Name of subtable line - */ - public $table_element_line='facture_fourn_det'; + * @var int Name of subtable line + */ + public $table_element_line='facture_fourn_det'; /** - * @var int Field with ID of parent key if this field has a parent - */ - public $fk_element='fk_facture_fourn'; + * @var int Field with ID of parent key if this field has a parent + */ + public $fk_element='fk_facture_fourn'; public $picto='bill'; @@ -707,22 +707,22 @@ class FactureFournisseur extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load this->lines * * @return int 1 si ok, < 0 si erreur */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable - $this->lines = array(); + $this->lines = array(); $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.date_start, f.date_end, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.vat_src_code, f.tva_tx'; $sql.= ', f.localtax1_tx, f.localtax2_tx, f.localtax1_type, f.localtax2_type, f.total_localtax1, f.total_localtax2, f.fk_facture_fourn '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits, f.rang, f.special_code, f.fk_parent_line, f.fk_unit'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; - $sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; + $sql.= ', f.fk_multicurrency, f.multicurrency_code, f.multicurrency_subprice, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn_det as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid'; $sql.= ' WHERE fk_facture_fourn='.$this->id; @@ -783,12 +783,12 @@ class FactureFournisseur extends CommonInvoice $line->fk_unit = $obj->fk_unit; // Multicurrency - $line->fk_multicurrency = $obj->fk_multicurrency; - $line->multicurrency_code = $obj->multicurrency_code; - $line->multicurrency_subprice = $obj->multicurrency_subprice; - $line->multicurrency_total_ht = $obj->multicurrency_total_ht; - $line->multicurrency_total_tva = $obj->multicurrency_total_tva; - $line->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + $line->fk_multicurrency = $obj->fk_multicurrency; + $line->multicurrency_code = $obj->multicurrency_code; + $line->multicurrency_subprice = $obj->multicurrency_subprice; + $line->multicurrency_total_ht = $obj->multicurrency_total_ht; + $line->multicurrency_total_tva = $obj->multicurrency_total_tva; + $line->multicurrency_total_ttc = $obj->multicurrency_total_ttc; $this->lines[$i] = $line; @@ -934,14 +934,14 @@ class FactureFournisseur extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add a discount line into an invoice (as an invoice line) using an existing absolute discount (Consume the discount) * * @param int $idremise Id of absolute discount * @return int >0 if OK, <0 if KO */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -1187,16 +1187,16 @@ class FactureFournisseur extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag invoice as a payed invoice * * @param User $user Object user - * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet. Not implementd yet. - * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet. Not implementd yet. + * @param string $close_code Code renseigne si on classe a payee completement alors que paiement incomplet. Not implementd yet. + * @param string $close_note Commentaire renseigne si on classe a payee alors que paiement incomplet. Not implementd yet. * @return int <0 si ko, >0 si ok */ - function set_paid($user, $close_code = '', $close_note = '') + public function set_paid($user, $close_code = '', $close_note = '') { // phpcs:enable global $conf,$langs; @@ -1237,7 +1237,7 @@ class FactureFournisseur extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag la facture comme non payee completement + appel trigger BILL_UNPAYED * Fonction utilisee quand un paiement prelevement est refuse, @@ -1246,7 +1246,7 @@ class FactureFournisseur extends CommonInvoice * @param User $user Object user that change status * @return int <0 si ok, >0 si ok */ - function set_unpaid($user) + public function set_unpaid($user) { // phpcs:enable global $conf,$langs; @@ -1450,7 +1450,7 @@ class FactureFournisseur extends CommonInvoice } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * @@ -1458,7 +1458,7 @@ class FactureFournisseur extends CommonInvoice * @param int $idwarehouse Id warehouse to use for stock change. * @return int <0 if KO, >0 if OK */ - function set_draft($user, $idwarehouse = -1) + public function set_draft($user, $idwarehouse = -1) { // phpcs:enable global $conf,$langs; @@ -2033,7 +2033,7 @@ class FactureFournisseur extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi liste des factures remplacables * Statut validee ou abandonnee pour raison autre + non payee + aucun paiement + pas deja remplacee @@ -2042,7 +2042,7 @@ class FactureFournisseur extends CommonInvoice * @return array|int Tableau des factures ('id'=>id, 'ref'=>ref, 'status'=>status, 'paymentornot'=>0/1) * <0 if error */ - function list_replacable_supplier_invoices($socid = 0) + public function list_replacable_supplier_invoices($socid = 0) { // phpcs:enable global $conf; @@ -2084,7 +2084,7 @@ class FactureFournisseur extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi liste des factures qualifiables pour correction par avoir * Les factures qui respectent les regles suivantes sont retournees: @@ -2094,7 +2094,7 @@ class FactureFournisseur extends CommonInvoice * @return array|int Tableau des factures ($id => array('ref'=>,'paymentornot'=>,'status'=>,'paye'=>) * <0 if error */ - function list_qualified_avoir_supplier_invoices($socid = 0) + public function list_qualified_avoir_supplier_invoices($socid = 0) { // phpcs:enable global $conf; @@ -2137,14 +2137,14 @@ class FactureFournisseur extends CommonInvoice } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @param User $user Object user * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - function load_board($user) + public function load_board($user) { // phpcs:enable global $conf, $langs; @@ -2246,8 +2246,8 @@ class FactureFournisseur extends CommonInvoice if (! empty($this->total_ttc)) $label.= '
' . $langs->trans('AmountTTC') . ': ' . price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency); if ($this->type == self::TYPE_REPLACEMENT) $label=$langs->transnoentitiesnoconv("ShowInvoiceReplace").': '.$this->ref; - if ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; - if ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; + elseif ($this->type == self::TYPE_CREDIT_NOTE) $label=$langs->transnoentitiesnoconv("ShowInvoiceAvoir").': '.$this->ref; + elseif ($this->type == self::TYPE_DEPOSIT) $label=$langs->transnoentitiesnoconv("ShowInvoiceDeposit").': '.$this->ref; if ($moretitle) $label.=' - '.$moretitle; $ref=$this->ref; @@ -2434,13 +2434,13 @@ class FactureFournisseur extends CommonInvoice $this->total_ttc = $xnbp*119.6; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -3187,13 +3187,13 @@ class SupplierInvoiceLine extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour de l'objet ligne de commande en base * * @return int <0 si ko, >0 si ok */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 731695d8d27..bbdea07270e 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -107,7 +107,7 @@ class ProductFournisseur extends Product * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { global $langs; @@ -118,14 +118,14 @@ class ProductFournisseur extends Product - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove all prices for this couple supplier-product * * @param int $id_fourn Supplier Id * @return int < 0 if error, > 0 if ok */ - function remove_fournisseur($id_fourn) + public function remove_fournisseur($id_fourn) { // phpcs:enable $ok=1; @@ -156,14 +156,14 @@ class ProductFournisseur extends Product } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a price for a couple supplier-product * * @param int $rowid Line id of price * @return int <0 if KO, >0 if OK */ - function remove_product_fournisseur_price($rowid) + public function remove_product_fournisseur_price($rowid) { // phpcs:enable global $conf, $user; @@ -202,7 +202,7 @@ class ProductFournisseur extends Product } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Modify the purchase price for a supplier * @@ -229,7 +229,7 @@ class ProductFournisseur extends Product * @param string $desc_fourn Custom description for product_fourn_price * @return int <0 if KO, >=0 if OK */ - function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '') + public function update_buyprice($qty, $buyprice, $user, $price_base_type, $fourn, $availability, $ref_fourn, $tva_tx, $charges = 0, $remise_percent = 0, $remise = 0, $newnpr = 0, $delivery_time_days = 0, $supplier_reputation = '', $localtaxes_array = array(), $newdefaultvatcode = '', $multicurrency_buyprice = 0, $multicurrency_price_base_type = 'HT', $multicurrency_tx = 1, $multicurrency_code = '', $desc_fourn = '') { // phpcs:enable global $conf, $langs; @@ -473,7 +473,7 @@ class ProductFournisseur extends Product } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Loads the price information of a provider * @@ -481,7 +481,7 @@ class ProductFournisseur extends Product * @param int $ignore_expression Ignores the math expression for calculating price and uses the db value instead * @return int < 0 if KO, 0 if OK but not found, > 0 if OK */ - function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) + public function fetch_product_fournisseur_price($rowid, $ignore_expression = 0) { // phpcs:enable global $conf; @@ -563,7 +563,7 @@ class ProductFournisseur extends Product } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * List all supplier prices of a product * @@ -574,7 +574,7 @@ class ProductFournisseur extends Product * @param int $offset Offset * @return array Array of Products with new properties to define supplier price */ - function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) + public function list_product_fournisseur_price($prodid, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) { // phpcs:enable global $conf; @@ -666,7 +666,7 @@ class ProductFournisseur extends Product } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load properties for minimum price * @@ -675,7 +675,7 @@ class ProductFournisseur extends Product * @param int $socid get min price for specific supplier * @return int <0 if KO, 0=Not found of no product id provided, >0 if OK */ - function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) + public function find_min_price_product_fournisseur($prodid, $qty = 0, $socid = 0) { // phpcs:enable global $conf; @@ -810,7 +810,7 @@ class ProductFournisseur extends Product * @param int $expression_id Expression * @return int <0 if KO, >0 if OK */ - function setSupplierPriceExpression($expression_id) + public function setSupplierPriceExpression($expression_id) { global $conf; @@ -848,7 +848,7 @@ class ProductFournisseur extends Product * @return string String with supplier price * TODO Remove this method. Use getNomUrl directly. */ - function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) + public function getSocNomUrl($withpicto = 0, $option = 'supplier', $maxlen = 0, $notooltip = 0) { $thirdparty = new Fournisseur($this->db); $thirdparty->fetch($this->fourn_id); @@ -856,7 +856,7 @@ class ProductFournisseur extends Product return $thirdparty->getNomUrl($withpicto, $option, $maxlen, $notooltip); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Display price of product * @@ -868,7 +868,7 @@ class ProductFournisseur extends Product * to display in table format. * @return string String with supplier price */ - function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) + public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array()) { // phpcs:enable global $langs; @@ -921,7 +921,7 @@ class ProductFournisseur extends Product * @param int $offset Offset * @return array Array of Log prices */ - function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) + public function listProductFournisseurPriceLog($product_fourn_price_id, $sortfield = '', $sortorder = '', $limit = 0, $offset = 0) { global $conf; @@ -967,7 +967,7 @@ class ProductFournisseur extends Product * to display in table format. * @return string HTML String with supplier price */ - function displayPriceProductFournisseurLog($productFournLogList = array()) + public function displayPriceProductFournisseurLog($productFournLogList = array()) { global $langs; @@ -1001,7 +1001,7 @@ class ProductFournisseur extends Product * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $db, $conf, $langs; @@ -1056,7 +1056,7 @@ class ProductFournisseur extends Product return $result; } - + /** * Private function to log price history * diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 56d1e95a164..a5016822c66 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -48,7 +48,7 @@ class PaiementFourn extends Paiement public $picto = 'payment'; - var $statut; //Status of payment. 0 = unvalidated; 1 = validated + public $statut; //Status of payment. 0 = unvalidated; 1 = validated // fk_paiement dans llx_paiement est l'id du type de paiement (7 pour CHQ, ...) // fk_paiement dans llx_paiement_facture est le rowid du paiement @@ -69,7 +69,7 @@ class PaiementFourn extends Paiement * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -82,7 +82,7 @@ class PaiementFourn extends Paiement * @param int $fk_bank Id of bank line associated to payment * @return int <0 if KO, -2 if not found, >0 if OK */ - function fetch($id, $ref = '', $fk_bank = '') + public function fetch($id, $ref = '', $fk_bank = '') { $error=0; @@ -146,7 +146,7 @@ class PaiementFourn extends Paiement * @param Societe $thirdparty Thirdparty * @return int id of created payment, < 0 if error */ - function create($user, $closepaidinvoices = 0, $thirdparty = null) + public function create($user, $closepaidinvoices = 0, $thirdparty = null) { global $langs,$conf; @@ -319,7 +319,7 @@ class PaiementFourn extends Paiement * @param int $notrigger No trigger * @return int <0 si ko, >0 si ok */ - function delete($notrigger = 0) + public function delete($notrigger = 0) { global $conf, $user, $langs; @@ -421,7 +421,7 @@ class PaiementFourn extends Paiement * @param int $id Id du paiement dont il faut afficher les infos * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT c.rowid, datec, fk_user_author as fk_user_creat, tms'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn as c'; @@ -465,7 +465,7 @@ class PaiementFourn extends Paiement * @param string $filter SQL filter * @return array Array of supplier invoice id */ - function getBillsArray($filter = '') + public function getBillsArray($filter = '') { $sql = 'SELECT fk_facturefourn'; $sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'facture_fourn as f'; @@ -503,12 +503,12 @@ class PaiementFourn extends Paiement * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -516,7 +516,7 @@ class PaiementFourn extends Paiement * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Libelle du statut */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -570,7 +570,7 @@ class PaiementFourn extends Paiement * @param int $notooltip 1=Disable tooltip * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0) + public function getNomUrl($withpicto = 0, $option = '', $mode = 'withlistofinvoices', $notooltip = 0) { global $langs; @@ -606,7 +606,7 @@ class PaiementFourn extends Paiement * @param string $option ''=Create a specimen invoice with lines, 'nolines'=No lines * @return void */ - function initAsSpecimen($option = '') + public function initAsSpecimen($option = '') { global $user,$langs,$conf; @@ -631,7 +631,7 @@ class PaiementFourn extends Paiement * @param string $mode 'next' for next value or 'last' for last value * @return string free ref or last ref */ - function getNextNumRef($soc, $mode = 'next') + public function getNextNumRef($soc, $mode = 'next') { global $conf, $db, $langs; $langs->load("bills"); @@ -755,7 +755,7 @@ class PaiementFourn extends Paiement * * @return string 'dolibarr' if standard comportment or paid in dolibarr currency, 'customer' if payment received from multicurrency inputs */ - function getWay() + public function getWay() { global $conf; @@ -776,14 +776,14 @@ class PaiementFourn extends Paiement } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load the third party of object, from id into this->thirdparty * * @param int $force_thirdparty_id Force thirdparty id * @return int <0 if KO, >0 if OK */ - function fetch_thirdparty($force_thirdparty_id = 0) + public function fetch_thirdparty($force_thirdparty_id = 0) { // phpcs:enable require_once DOL_DOCUMENT_ROOT . '/fourn/class/fournisseur.facture.class.php'; diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 078fcb2c59d..45146324e32 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -149,7 +149,7 @@ class Holiday extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -162,7 +162,7 @@ class Holiday extends CommonObject * @param Societe $objsoc third party object * @return string Holiday free reference */ - function getNextNumRef($objsoc) + public function getNextNumRef($objsoc) { global $langs, $conf; $langs->load("order"); @@ -221,7 +221,7 @@ class Holiday extends CommonObject * * @return int <0 if KO, >0 if OK */ - function updateBalance() + public function updateBalance() { $this->db->begin(); @@ -250,7 +250,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, Id of created object if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf; $error=0; @@ -336,7 +336,7 @@ class Holiday extends CommonObject * @param string $ref Ref object * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '') + public function fetch($id, $ref = '') { global $langs; @@ -420,7 +420,7 @@ class Holiday extends CommonObject * @param string $filter SQL Filter * @return int -1 if KO, 1 if OK, 2 if no result */ - function fetchByUser($user_id, $order = '', $filter = '') + public function fetchByUser($user_id, $order = '', $filter = '') { global $langs, $conf; @@ -548,7 +548,7 @@ class Holiday extends CommonObject * @param string $filter SQL Filter * @return int -1 if KO, 1 if OK, 2 if no result */ - function fetchAll($order, $filter) + public function fetchAll($order, $filter) { global $langs; @@ -674,7 +674,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function validate($user = null, $notrigger = 0) + public function validate($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -745,7 +745,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function approve($user = null, $notrigger = 0) + public function approve($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -858,7 +858,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = null, $notrigger = 0) + public function update($user = null, $notrigger = 0) { global $conf, $langs; $error=0; @@ -972,7 +972,7 @@ class Holiday extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -1022,15 +1022,15 @@ class Holiday extends CommonObject * This function can be used to avoid to have 2 leave requests on same period for example. * Warning: It consumes a lot of memory because it load in ->holiday all holiday of a dedicated user at each call. * - * @param int $fk_user Id user - * @param date $dateStart Start date of period to check - * @param date $dateEnd End date of period to check - * @param int $halfday Tag to define how start and end the period to check: - * 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning + * @param int $fk_user Id user + * @param date $dateStart Start date of period to check + * @param date $dateEnd End date of period to check + * @param int $halfday Tag to define how start and end the period to check: + * 0:Full days, 2:Start afternoon end morning, -1:Start afternoon end afternoon, 1:Start morning end morning * @return boolean False = New range overlap an existing holiday, True = no overlapping (is never on holiday during checked period). * @see verifDateHolidayForTimestamp */ - function verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday = 0) + public function verifDateHolidayCP($fk_user, $dateStart, $dateEnd, $halfday = 0) { $this->fetchByUser($fk_user, '', ''); @@ -1112,7 +1112,7 @@ class Holiday extends CommonObject * @return array array('morning'=> ,'afternoon'=> ), Boolean is true if user is available for day timestamp. * @see verifDateHolidayCP */ - function verifDateHolidayForTimestamp($fk_user, $timestamp, $status = '-1') + public function verifDateHolidayForTimestamp($fk_user, $timestamp, $status = '-1') { global $langs, $conf; @@ -1175,7 +1175,7 @@ class Holiday extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) { global $langs; @@ -1211,12 +1211,12 @@ class Holiday extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode, $this->date_debut); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Returns the label of a statut * @@ -1225,7 +1225,7 @@ class Holiday extends CommonObject * @param date $startdate Date holiday should start * @return string Label */ - function LibStatut($statut, $mode = 0, $startdate = '') + public function LibStatut($statut, $mode = 0, $startdate = '') { // phpcs:enable global $langs; @@ -1290,7 +1290,7 @@ class Holiday extends CommonObject * @param string $htmlname Name of HTML select field * @return string Show select of status */ - function selectStatutCP($selected = '', $htmlname = 'select_statut') + public function selectStatutCP($selected = '', $htmlname = 'select_statut') { global $langs; @@ -1324,7 +1324,7 @@ class Holiday extends CommonObject * @param string $value vrai si mise à jour OK sinon faux * @return boolean ok or ko */ - function updateConfCP($name, $value) + public function updateConfCP($name, $value) { $sql = "UPDATE ".MAIN_DB_PREFIX."holiday_config SET"; @@ -1348,7 +1348,7 @@ class Holiday extends CommonObject * @param string $createifnotfound 'stringvalue'=Create entry with string value if not found. For example 'YYYYMMDDHHMMSS'. * @return string Value of parameter. Example: 'YYYYMMDDHHMMSS' or < 0 if error */ - function getConfCP($name, $createifnotfound = '') + public function getConfCP($name, $createifnotfound = '') { $sql = "SELECT value"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_config"; @@ -1403,7 +1403,7 @@ class Holiday extends CommonObject * @param int $fk_type Type of vacation * @return int 0=Nothing done, 1=OK, -1=KO */ - function updateSoldeCP($userID = '', $nbHoliday = '', $fk_type = '') + public function updateSoldeCP($userID = '', $nbHoliday = '', $fk_type = '') { global $user, $langs; @@ -1552,7 +1552,7 @@ class Holiday extends CommonObject * @param string $name name du paramètre de configuration * @return string retourne checked si > 0 */ - function getCheckOption($name) + public function getCheckOption($name) { $sql = "SELECT value"; @@ -1579,7 +1579,7 @@ class Holiday extends CommonObject * @param int $userid Id user * @return void */ - function createCPusers($single = false, $userid = '') + public function createCPusers($single = false, $userid = '') { // Si c'est l'ensemble des utilisateurs à ajouter if (! $single) @@ -1614,7 +1614,7 @@ class Holiday extends CommonObject * @param int $user_id ID de l'utilisateur à supprimer * @return boolean Vrai si pas d'erreur, faut si Erreur */ - function deleteCPuser($user_id) + public function deleteCPuser($user_id) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."holiday_users"; @@ -1631,7 +1631,7 @@ class Holiday extends CommonObject * @param int $fk_type Filter on type * @return float Retourne le solde de congés payés de l'utilisateur */ - function getCPforUser($user_id, $fk_type = 0) + public function getCPforUser($user_id, $fk_type = 0) { $sql = "SELECT nb_holiday"; $sql.= " FROM ".MAIN_DB_PREFIX."holiday_users"; @@ -1661,7 +1661,7 @@ class Holiday extends CommonObject * @param string $filters Filters * @return array|string|int Return an array */ - function fetchUsers($stringlist = true, $type = true, $filters = '') + public function fetchUsers($stringlist = true, $type = true, $filters = '') { global $conf; @@ -1874,14 +1874,14 @@ class Holiday extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of people with permission to validate leave requests. * Search for permission "approve leave requests" * * @return array Array of user ids */ - function fetch_users_approver_holiday() + public function fetch_users_approver_holiday() { // phpcs:enable $users_validator=array(); @@ -1922,7 +1922,7 @@ class Holiday extends CommonObject * * @return int retourne le nombre d'utilisateur */ - function countActiveUsers() + public function countActiveUsers() { $sql = "SELECT count(u.rowid) as compteur"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; @@ -1938,7 +1938,7 @@ class Holiday extends CommonObject * * @return int retourne le nombre d'utilisateur */ - function countActiveUsersWithoutCP() + public function countActiveUsersWithoutCP() { $sql = "SELECT count(u.rowid) as compteur"; @@ -1958,7 +1958,7 @@ class Holiday extends CommonObject * @param int $userCP Number of active users into table of holidays * @return int <0 if KO, >0 if OK */ - function verifNbUsers($userDolibarrWithoutCP, $userCP) + public function verifNbUsers($userDolibarrWithoutCP, $userCP) { if (empty($userCP)) $userCP=0; dol_syslog(get_class($this).'::verifNbUsers userDolibarr='.$userDolibarrWithoutCP.' userCP='.$userCP); @@ -1976,7 +1976,7 @@ class Holiday extends CommonObject * @param int $fk_type Type of vacation * @return int Id of record added, 0 if nothing done, < 0 if KO */ - function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type) + public function addLogCP($fk_user_action, $fk_user_update, $label, $new_solde, $fk_type) { global $conf, $langs; @@ -2045,7 +2045,7 @@ class Holiday extends CommonObject * @param string $filter Filtre de séléction * @return int -1 si erreur, 1 si OK et 2 si pas de résultat */ - function fetchLog($order, $filter) + public function fetchLog($order, $filter) { global $langs; @@ -2122,7 +2122,7 @@ class Holiday extends CommonObject * @param int $affect Filter on affect (a request will change sold or not). -1 = Both * @return array Return array with list of types */ - function getTypes($active = -1, $affect = -1) + public function getTypes($active = -1, $affect = -1) { global $mysoc; @@ -2159,7 +2159,7 @@ class Holiday extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php index f39a9ee374a..8d8098642e2 100644 --- a/htdocs/hrm/class/establishment.class.php +++ b/htdocs/hrm/class/establishment.class.php @@ -102,7 +102,7 @@ class Establishment extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -116,7 +116,7 @@ class Establishment extends CommonObject * @param User $user User making creation * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -187,12 +187,12 @@ class Establishment extends CommonObject * @param User $user User making update * @return int <0 if KO, >0 if OK */ - function update($user) + public function update($user) { global $langs; - // Check parameters - if (empty($this->name)) + // Check parameters + if (empty($this->name)) { $this->error='ErrorBadParameter'; return -1; @@ -229,7 +229,7 @@ class Establishment extends CommonObject * @param int $id Id of record to load * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status, e.fk_country as country_id, e.entity,"; $sql.= ' c.code as country_code, c.label as country'; @@ -271,7 +271,7 @@ class Establishment extends CommonObject * @param int $id Id of record to delete * @return int <0 if KO, >0 if OK */ - function delete($id) + public function delete($id) { $this->db->begin(); @@ -298,12 +298,12 @@ class Establishment extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Give a label from a status * @@ -311,7 +311,7 @@ class Establishment extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -352,7 +352,7 @@ class Establishment extends CommonObject * @param int $id Id of record * @return void */ - function info($id) + public function info($id) { $sql = 'SELECT e.rowid, e.datec, e.fk_user_author, e.tms, e.fk_user_mod, e.entity'; $sql.= ' FROM '.MAIN_DB_PREFIX.'establishment as e'; @@ -391,14 +391,14 @@ class Establishment extends CommonObject dol_print_error($this->db); } } - + /** * Get on record Establishment * * @param int $id Id of record * @return Object */ - function getEstablishment($id) + public function getEstablishment($id) { $sql = 'SELECT e.rowid, e.name, e.datec, e.fk_user_author, e.tms, e.fk_user_mod, e.entity'; $sql.= ' FROM '.MAIN_DB_PREFIX.'establishment as e'; @@ -429,7 +429,7 @@ class Establishment extends CommonObject * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @return string String with URL */ - function getNomUrl($withpicto = 0) + public function getNomUrl($withpicto = 0) { global $langs; @@ -447,7 +447,7 @@ class Establishment extends CommonObject if ($withpicto != 2) $result.=$link.$this->name.$linkend; return $result; } - + /** * Return clicable name (with picto eventually) * @@ -455,13 +455,13 @@ class Establishment extends CommonObject * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto * @return string String with URL */ - function getNomUrlParent($id = 0, $withpicto = 0) + public function getNomUrlParent($id = 0, $withpicto = 0) { global $langs, $conf; $result=''; - - $obj = $this->getEstablishment(($id>0)?$id:$conf->entity); + + $obj = $this->getEstablishment(($id>0)?$id:$conf->entity); $link = ''; $linkend=''; @@ -481,7 +481,7 @@ class Establishment extends CommonObject * * @return string country code */ - function getCountryCode() + public function getCountryCode() { global $mysoc; diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 59a110f5090..aebf983b541 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -27,21 +27,21 @@ */ class Import { - var $array_import_module; - var $array_import_perms; - var $array_import_icon; - var $array_import_code; - var $array_import_label; - var $array_import_tables; - var $array_import_tables_creator; - var $array_import_fields; - var $array_import_fieldshidden; - var $array_import_entities; - var $array_import_regex; - var $array_import_updatekeys; - var $array_import_examplevalues; - var $array_import_convertvalue; - var $array_import_run_sql_after; + public $array_import_module; + public $array_import_perms; + public $array_import_icon; + public $array_import_code; + public $array_import_label; + public $array_import_tables; + public $array_import_tables_creator; + public $array_import_fields; + public $array_import_fieldshidden; + public $array_import_entities; + public $array_import_regex; + public $array_import_updatekeys; + public $array_import_examplevalues; + public $array_import_convertvalue; + public $array_import_run_sql_after; /** * @var string Error code (or message) @@ -54,18 +54,18 @@ class Import public $errors = array(); - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db=$db; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load description int this->array_import_module, this->array_import_fields, ... of an importable dataset * @@ -73,7 +73,7 @@ class Import * @param string $filter Load a particular dataset only. Index will start to 0. * @return int <0 if KO, >0 if OK */ - function load_arrays($user, $filter = '') + public function load_arrays($user, $filter = '') { // phpcs:enable global $langs,$conf; @@ -185,7 +185,7 @@ class Import - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Build an import example file. * Arrays this->array_export_xxx are already loaded for required datatoexport @@ -196,7 +196,7 @@ class Import * @param string $datatoimport Dataset to import * @return string <0 if KO, >0 if OK */ - function build_example_file($model, $headerlinefields, $contentlinevalues, $datatoimport) + public function build_example_file($model, $headerlinefields, $contentlinevalues, $datatoimport) { // phpcs:enable global $conf,$langs; @@ -236,7 +236,7 @@ class Import * @param User $user Object user that save * @return int <0 if KO, >0 if OK */ - function create($user) + public function create($user) { global $conf; @@ -276,7 +276,7 @@ class Import * @param int $id Id of profil to load * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { $sql = 'SELECT em.rowid, em.field, em.label, em.type'; $sql.= ' FROM '.MAIN_DB_PREFIX.'import_model as em'; @@ -316,7 +316,7 @@ class Import * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index e85f33b18a8..49904ef44f5 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -73,7 +73,7 @@ class Livraison extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; $this->lines = array(); @@ -91,7 +91,7 @@ class Livraison extends CommonObject * @param User $user Objet du user qui cree * @return int <0 si erreur, id livraison cree si ok */ - function create($user) + public function create($user) { global $conf; @@ -227,7 +227,7 @@ class Livraison extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a line * @@ -237,8 +237,8 @@ class Livraison extends CommonObject * @param string $description Description * @return int <0 if KO, >0 if OK */ - function create_line($origin_id, $qty, $fk_product, $description) - { + public function create_line($origin_id, $qty, $fk_product, $description) + { // phpcs:enable $error = 0; $idprod = $fk_product; @@ -269,7 +269,7 @@ class Livraison extends CommonObject * @param int $id Id of object to load * @return integer */ - function fetch($id) + public function fetch($id) { global $conf; @@ -353,7 +353,7 @@ class Livraison extends CommonObject * @param User $user Object user that validate * @return int */ - function valid($user) + public function valid($user) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -499,7 +499,7 @@ class Livraison extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Creating the delivery slip from an existing shipment * @@ -507,7 +507,7 @@ class Livraison extends CommonObject * @param int $sending_id Id of the expedition that serves as a model * @return integer */ - function create_from_sending($user, $sending_id) + public function create_from_sending($user, $sending_id) { // phpcs:enable $expedition = new Expedition($this->db); @@ -546,7 +546,7 @@ class Livraison extends CommonObject return $this->create($user); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update a livraison line (only extrafields) * @@ -554,7 +554,7 @@ class Livraison extends CommonObject * @param array $array_options extrafields array * @return int <0 if KO, >0 if OK */ - function update_line($id, $array_options = 0) + public function update_line($id, $array_options = 0) { // phpcs:enable global $conf; @@ -586,7 +586,7 @@ class Livraison extends CommonObject * @param int $qty Qty * @return void */ - function addline($origin_id, $qty) + public function addline($origin_id, $qty) { $num = count($this->lines); $line = new LivraisonLigne($this->db); @@ -603,7 +603,7 @@ class Livraison extends CommonObject * @param int $lineid Line id * @return integer|null */ - function deleteline($lineid) + public function deleteline($lineid) { if ($this->statut == 0) { @@ -628,7 +628,7 @@ class Livraison extends CommonObject * * @return integer */ - function delete() + public function delete() { global $conf, $langs, $user; @@ -716,7 +716,7 @@ class Livraison extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string Chaine avec URL */ - function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $save_lastsearch_value = -1) { global $langs; @@ -745,13 +745,13 @@ class Livraison extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load lines * * @return void */ - function fetch_lines() + public function fetch_lines() { // phpcs:enable $this->lines = array(); @@ -811,12 +811,12 @@ class Livraison extends CommonObject * @param int $mode Mode * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -824,7 +824,7 @@ class Livraison extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label */ - function LibStatut($statut, $mode) + public function LibStatut($statut, $mode) { // phpcs:enable global $langs; @@ -863,7 +863,7 @@ class Livraison extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; @@ -918,7 +918,7 @@ class Livraison extends CommonObject * @return array Product remaining to be delivered * TODO use new function */ - function getRemainingDelivered() + public function getRemainingDelivered() { global $langs; @@ -989,7 +989,7 @@ class Livraison extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set the planned delivery date * @@ -997,7 +997,7 @@ class Livraison extends CommonObject * @param timestamp $date_livraison Date de livraison * @return int <0 if KO, >0 if OK */ - function set_date_livraison($user, $date_livraison) + public function set_date_livraison($user, $date_livraison) { // phpcs:enable if ($user->rights->expedition->creer) @@ -1087,13 +1087,13 @@ class LivraisonLigne extends CommonObjectLine */ public $db; - // From llx_expeditiondet - var $qty; - var $qty_asked; - var $qty_shipped; - var $price; - var $fk_product; - var $origin_id; + // From llx_expeditiondet + public $qty; + public $qty_asked; + public $qty_shipped; + public $price; + public $fk_product; + public $origin_id; /** * @var string delivery note lines label @@ -1129,13 +1129,13 @@ class LivraisonLigne extends CommonObjectLine */ public $table_element='livraisondet'; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db=$db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db=$db; + } } diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index c1e421d5ef9..f262805b3fe 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -66,7 +66,7 @@ class Loan extends CommonObject public $date_creation; public $date_modification; public $date_validation; - + public $insurance_amount; /** @@ -95,7 +95,7 @@ class Loan extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -106,7 +106,7 @@ class Loan extends CommonObject * @param int $id id object * @return int <0 error , >=0 no error */ - function fetch($id) + public function fetch($id) { $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.nbterm, l.rate, l.note_private, l.note_public, l.insurance_amount,"; $sql.= " l.paid, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest, l.fk_projet as fk_project"; @@ -162,7 +162,7 @@ class Loan extends CommonObject * @param User $user User making creation * @return int <0 if KO, id if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -255,7 +255,7 @@ class Loan extends CommonObject * @param User $user Object user making delete * @return int <0 if KO, >0 if OK */ - function delete($user) + public function delete($user) { $error=0; @@ -325,7 +325,7 @@ class Loan extends CommonObject * @param User $user User who modified * @return int <0 if error, >0 if ok */ - function update($user) + public function update($user) { $this->db->begin(); @@ -364,14 +364,14 @@ class Loan extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Tag loan as payed completely * * @param User $user Object user making change * @return int <0 if KO, >0 if OK */ - function set_paid($user) + public function set_paid($user) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."loan SET"; @@ -393,12 +393,12 @@ class Loan extends CommonObject * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ - function getLibStatut($mode = 0, $alreadypaid = -1) + public function getLibStatut($mode = 0, $alreadypaid = -1) { return $this->LibStatut($this->paid, $mode, $alreadypaid); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label for given status * @@ -407,7 +407,7 @@ class Loan extends CommonObject * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ - function LibStatut($statut, $mode = 0, $alreadypaid = -1) + public function LibStatut($statut, $mode = 0, $alreadypaid = -1) { // phpcs:enable global $langs; @@ -460,7 +460,7 @@ class Loan extends CommonObject * @param int $maxlen Label max length * @return string Chaine with URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; @@ -490,7 +490,7 @@ class Loan extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user, $langs, $conf; @@ -518,7 +518,7 @@ class Loan extends CommonObject * * @return int Amount of payment already done, <0 if KO */ - function getSumPayment() + public function getSumPayment() { $table='payment_loan'; $field='fk_loan'; @@ -552,7 +552,7 @@ class Loan extends CommonObject * @param int $id Id of record * @return integer|null */ - function info($id) + public function info($id) { $sql = 'SELECT l.rowid, l.datec, l.fk_user_author, l.fk_user_modif,'; $sql.= ' l.tms'; @@ -597,5 +597,5 @@ class Loan extends CommonObject $this->error=$this->db->lasterror(); return -1; } - } + } } diff --git a/htdocs/loan/class/loanschedule.class.php b/htdocs/loan/class/loanschedule.class.php index 8d73e667d52..c370f2115bd 100644 --- a/htdocs/loan/class/loanschedule.class.php +++ b/htdocs/loan/class/loanschedule.class.php @@ -354,22 +354,21 @@ class LoanSchedule extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - public function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; $this->db->begin(); - if (! $error) - { + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; $sql.= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - } + } if (! $error) { @@ -403,7 +402,7 @@ class LoanSchedule extends CommonObject $this->db->commit(); return 1; } - } + } /** * Calculate Monthly Payments diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 6e4bab7f444..f75ffde1849 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -113,7 +113,7 @@ class PaymentLoan extends CommonObject * @param User $user User making payment * @return int <0 if KO, id of payment if OK */ - function create($user) + public function create($user) { global $conf, $langs; @@ -196,7 +196,7 @@ class PaymentLoan extends CommonObject * @param int $id Id object * @return int <0 if KO, >0 if OK */ - function fetch($id) + public function fetch($id) { global $langs; $sql = "SELECT"; @@ -273,7 +273,7 @@ class PaymentLoan extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update($user = 0, $notrigger = 0) + public function update($user = 0, $notrigger = 0) { global $conf, $langs; $error=0; @@ -361,7 +361,7 @@ class PaymentLoan extends CommonObject * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf, $langs; $error=0; @@ -388,10 +388,10 @@ class PaymentLoan extends CommonObject if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } } - if (! $error) - { - if (! $notrigger) - { + //if (! $error) + //{ + // if (! $notrigger) + // { // Uncomment this and change MYOBJECT to your own tag if you // want this action call a trigger. @@ -401,8 +401,8 @@ class PaymentLoan extends CommonObject //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); //if ($result < 0) { $error++; $this->errors=$interface->errors; } //// End call triggers - } - } + // } + //} // Commit or rollback if ($error) @@ -435,7 +435,7 @@ class PaymentLoan extends CommonObject * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ - function addPaymentToBank($user, $fk_loan, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + public function addPaymentToBank($user, $fk_loan, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $conf; @@ -452,7 +452,7 @@ class PaymentLoan extends CommonObject if ($mode == 'payment_loan') $total=-$total; // Insert payment into llx_bank -$bank_line_id = $acc->addline( + $bank_line_id = $acc->addline( $this->datep, $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") $label, @@ -513,14 +513,14 @@ $bank_line_id = $acc->addline( } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update link between loan's payment and the line generate in llx_bank * * @param int $id_bank Id if bank * @return int >0 if OK, <=0 if KO */ - function update_fk_bank($id_bank) + public function update_fk_bank($id_bank) { // phpcs:enable $sql = "UPDATE ".MAIN_DB_PREFIX."payment_loan SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; @@ -546,7 +546,7 @@ $bank_line_id = $acc->addline( * @param int $maxlen Max length label * @return string Chaine with URL */ - function getNomUrl($withpicto = 0, $maxlen = 0) + public function getNomUrl($withpicto = 0, $maxlen = 0) { global $langs; diff --git a/htdocs/mailmanspip/class/mailmanspip.class.php b/htdocs/mailmanspip/class/mailmanspip.class.php index 64f162a7de8..d80edaf725f 100644 --- a/htdocs/mailmanspip/class/mailmanspip.class.php +++ b/htdocs/mailmanspip/class/mailmanspip.class.php @@ -65,7 +65,7 @@ class MailmanSpip * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -75,7 +75,7 @@ class MailmanSpip * * @return boolean */ - function isSpipEnabled() + public function isSpipEnabled() { if (defined("ADHERENT_USE_SPIP") && (ADHERENT_USE_SPIP == 1)) { @@ -90,7 +90,7 @@ class MailmanSpip * * @return boolean */ - function checkSpipConfig() + public function checkSpipConfig() { if (defined('ADHERENT_SPIP_SERVEUR') && defined('ADHERENT_SPIP_USER') && defined('ADHERENT_SPIP_PASS') && defined('ADHERENT_SPIP_DB')) { @@ -108,7 +108,7 @@ class MailmanSpip * * @return boolean|DoliDB Boolean of DoliDB */ - function connectSpip() + public function connectSpip() { $resource = getDoliDBInstance('mysql', ADHERENT_SPIP_SERVEUR, ADHERENT_SPIP_USER, ADHERENT_SPIP_PASS, ADHERENT_SPIP_DB, ADHERENT_SPIP_PORT); @@ -176,14 +176,14 @@ class MailmanSpip return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction qui donne les droits redacteurs dans spip * * @param Adherent $object Object with data (->firstname, ->lastname, ->email and ->login) * @return int =0 if KO, >0 if OK */ - function add_to_spip($object) + public function add_to_spip($object) { // phpcs:enable dol_syslog(get_class($this)."::add_to_spip"); @@ -220,14 +220,14 @@ class MailmanSpip return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction qui enleve les droits redacteurs dans spip * * @param Adherent $object Object with data (->login) * @return int =0 if KO, >0 if OK */ - function del_to_spip($object) + public function del_to_spip($object) { // phpcs:enable dol_syslog(get_class($this)."::del_to_spip"); @@ -261,14 +261,14 @@ class MailmanSpip return 0; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fonction qui dit si cet utilisateur est un redacteur existant dans spip * * @param object $object Object with data (->login) * @return int 1=exists, 0=does not exists, -1=error */ - function is_in_spip($object) + public function is_in_spip($object) { // phpcs:enable if ($this->isSpipEnabled()) @@ -313,7 +313,7 @@ class MailmanSpip return -1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Subscribe an email to all mailing-lists * @@ -321,7 +321,7 @@ class MailmanSpip * @param array $listes To force mailing-list (string separated with ,) * @return int <0 if KO, >=0 if OK */ - function add_to_mailman($object, $listes = '') + public function add_to_mailman($object, $listes = '') { // phpcs:enable global $conf,$langs,$user; @@ -386,7 +386,7 @@ class MailmanSpip } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Unsubscribe an email from all mailing-lists * Used when a user is resiliated @@ -395,7 +395,7 @@ class MailmanSpip * @param array $listes To force mailing-list (string separated with ,) * @return int <0 if KO, >=0 if OK */ - function del_to_mailman($object, $listes = '') + public function del_to_mailman($object, $listes = '') { // phpcs:enable global $conf,$langs,$user; diff --git a/htdocs/modulebuilder/template/.editorconfig b/htdocs/modulebuilder/template/.editorconfig index 2df455f0d4f..3c4bd7d679d 100644 --- a/htdocs/modulebuilder/template/.editorconfig +++ b/htdocs/modulebuilder/template/.editorconfig @@ -7,8 +7,13 @@ root = true charset = utf-8 end_of_line = lf insert_final_newline = true + +# PHP PSR-2 Coding Standards +# http://www.php-fig.org/psr/psr-2/ [*.php] -indent_style = tab +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true [*.js] indent_style = tab [*.css] diff --git a/htdocs/modulebuilder/template/class/actions_mymodule.class.php b/htdocs/modulebuilder/template/class/actions_mymodule.class.php index 9143d8bf273..9925374dfac 100644 --- a/htdocs/modulebuilder/template/class/actions_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/actions_mymodule.class.php @@ -44,201 +44,201 @@ class ActionsMyModule public $errors = array(); - /** - * @var array Hook results. Propagated to $hookmanager->resArray for later reuse - */ - public $results = array(); + /** + * @var array Hook results. Propagated to $hookmanager->resArray for later reuse + */ + public $results = array(); - /** - * @var string String displayed by executeHook() immediately after return - */ - public $resprints; + /** + * @var string String displayed by executeHook() immediately after return + */ + public $resprints; - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { - $this->db = $db; - } + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } - /** - * Execute action - * - * @param array $parameters Array of parameters - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action 'add', 'update', 'view' - * @return int <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. - */ - function getNomUrl($parameters, &$object, &$action) - { - global $db,$langs,$conf,$user; - $this->resprints = ''; - return 0; - } + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + public function getNomUrl($parameters, &$object, &$action) + { + global $db,$langs,$conf,$user; + $this->resprints = ''; + return 0; + } - /** - * Overloading the doActions function : replacing the parent's function with the one below - * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - public function doActions($parameters, &$object, &$action, $hookmanager) - { - global $conf, $user, $langs; + /** + * Overloading the doActions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function doActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; - $error = 0; // Error counter + $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { - // Do what you want here... - // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. - } + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + // Do what you want here... + // You can for example call global vars like $fieldstosearchall to overwrite them, or update database depending on $action and $_POST values. + } - if (! $error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } - } + if (! $error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } - /** - * Overloading the doActions function : replacing the parent's function with the one below - * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - public function doMassActions($parameters, &$object, &$action, $hookmanager) - { - global $conf, $user, $langs; + /** + * Overloading the doActions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function doMassActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; - $error = 0; // Error counter + $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { - foreach($parameters['toselect'] as $objectid) - { - // Do action on each object id - } - } + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + foreach($parameters['toselect'] as $objectid) + { + // Do action on each object id + } + } - if (! $error) { - $this->results = array('myreturn' => 999); - $this->resprints = 'A text to show'; - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } - } + if (! $error) { + $this->results = array('myreturn' => 999); + $this->resprints = 'A text to show'; + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } - /** - * Overloading the addMoreMassActions function : replacing the parent's function with the one below - * - * @param array $parameters Hook metadatas (context, etc...) - * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) - * @param string $action Current action (if set). Generally create or edit or null - * @param HookManager $hookmanager Hook manager propagated to allow calling another hook - * @return int < 0 on error, 0 on success, 1 to replace standard code - */ - public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) - { - global $conf, $user, $langs; + /** + * Overloading the addMoreMassActions function : replacing the parent's function with the one below + * + * @param array $parameters Hook metadatas (context, etc...) + * @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) + * @param string $action Current action (if set). Generally create or edit or null + * @param HookManager $hookmanager Hook manager propagated to allow calling another hook + * @return int < 0 on error, 0 on success, 1 to replace standard code + */ + public function addMoreMassActions($parameters, &$object, &$action, $hookmanager) + { + global $conf, $user, $langs; - $error = 0; // Error counter + $error = 0; // Error counter /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { - $this->resprints = ''; - } + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { + $this->resprints = ''; + } - if (! $error) { - return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } - } + if (! $error) { + return 0; // or return 1 to replace standard code + } else { + $this->errors[] = 'Error message'; + return -1; + } + } - /** - * Execute action - * - * @param array $parameters Array of parameters - * @param Object $object Object output on PDF - * @param string $action 'add', 'update', 'view' - * @return int <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. - */ - function beforePDFCreation($parameters, &$object, &$action) - { - global $conf, $user, $langs; - global $hookmanager; + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param Object $object Object output on PDF + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + public function beforePDFCreation($parameters, &$object, &$action) + { + global $conf, $user, $langs; + global $hookmanager; - $outputlangs=$langs; + $outputlangs=$langs; - $ret=0; $deltemp=array(); - dol_syslog(get_class($this).'::executeHooks action='.$action); + $ret=0; $deltemp=array(); + dol_syslog(get_class($this).'::executeHooks action='.$action); - /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { - } + } - return $ret; - } + return $ret; + } - /** - * Execute action - * - * @param array $parameters Array of parameters - * @param Object $pdfhandler PDF builder handler - * @param string $action 'add', 'update', 'view' - * @return int <0 if KO, - * =0 if OK but we want to process standard actions too, - * >0 if OK and we want to replace standard actions. - */ - function afterPDFCreation($parameters, &$pdfhandler, &$action) - { - global $conf, $user, $langs; - global $hookmanager; + /** + * Execute action + * + * @param array $parameters Array of parameters + * @param Object $pdfhandler PDF builder handler + * @param string $action 'add', 'update', 'view' + * @return int <0 if KO, + * =0 if OK but we want to process standard actions too, + * >0 if OK and we want to replace standard actions. + */ + public function afterPDFCreation($parameters, &$pdfhandler, &$action) + { + global $conf, $user, $langs; + global $hookmanager; - $outputlangs=$langs; + $outputlangs=$langs; - $ret=0; $deltemp=array(); - dol_syslog(get_class($this).'::executeHooks action='.$action); + $ret=0; $deltemp=array(); + dol_syslog(get_class($this).'::executeHooks action='.$action); - /* print_r($parameters); print_r($object); echo "action: " . $action; */ - if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' - { + /* print_r($parameters); print_r($object); echo "action: " . $action; */ + if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2' + { - } + } - return $ret; - } + return $ret; + } - /* Add here any other hooked methods... */ + /* Add here any other hooked methods... */ } diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php index 30896449c93..cdb5a4b74f4 100644 --- a/htdocs/modulebuilder/template/class/api_mymodule.class.php +++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php @@ -56,10 +56,10 @@ class MyModuleApi extends DolibarrApi * @url GET / * */ - function __construct() + public function __construct() { - global $db, $conf; - $this->db = $db; + global $db, $conf; + $this->db = $db; $this->myobject = new MyObject($this->db); } @@ -70,26 +70,26 @@ class MyModuleApi extends DolibarrApi * * @param int $id ID of myobject * @return array|mixed data without useless information - * + * * @url GET myobjects/{id} * @throws RestException */ - function get($id) + public function get($id) { - if(! DolibarrApiAccess::$user->rights->myobject->read) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->myobject->read) { + throw new RestException(401); + } $result = $this->myobject->fetch($id); if( ! $result ) { throw new RestException(404, 'MyObject not found'); } - if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - return $this->_cleanObjectDatas($this->myobject); + return $this->_cleanObjectDatas($this->myobject); } @@ -109,7 +109,7 @@ class MyModuleApi extends DolibarrApi * * @url GET /myobjects/ */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '') { global $db, $conf; @@ -140,24 +140,21 @@ class MyModuleApi extends DolibarrApi if ($restictonsocid && $socid) $sql.= " AND t.fk_soc = ".$socid; if ($restictonsocid && $search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale // Insert sale filter - if ($restictonsocid && $search_sale > 0) - { + if ($restictonsocid && $search_sale > 0) { $sql .= " AND sc.fk_user = ".$search_sale; } if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { + if (! DolibarrApi::_checkFilters($sqlfilters)) { throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } $sql.= $db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) - { + if ($page < 0) { $page = 0; } $offset = $limit * $page; @@ -185,7 +182,7 @@ class MyModuleApi extends DolibarrApi if( ! count($obj_ret)) { throw new RestException(404, 'No myobject found'); } - return $obj_ret; + return $obj_ret; } /** @@ -196,7 +193,7 @@ class MyModuleApi extends DolibarrApi * * @url POST myobjects/ */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->myobject->create) { throw new RestException(401); @@ -222,7 +219,7 @@ class MyModuleApi extends DolibarrApi * * @url PUT myobjects/{id} */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { if(! DolibarrApiAccess::$user->rights->myobject->create) { throw new RestException(401); @@ -233,9 +230,9 @@ class MyModuleApi extends DolibarrApi throw new RestException(404, 'MyObject not found'); } - if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if( ! DolibarrApi::_checkAccessToResource('myobject', $this->myobject->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach($request_data as $field => $value) { $this->myobject->$field = $value; @@ -255,11 +252,11 @@ class MyModuleApi extends DolibarrApi * * @url DELETE myobject/{id} */ - function delete($id) + public function delete($id) { - if(! DolibarrApiAccess::$user->rights->myobject->delete) { - throw new RestException(401); - } + if(! DolibarrApiAccess::$user->rights->myobject->delete) { + throw new RestException(401); + } $result = $this->myobject->fetch($id); if( ! $result ) { throw new RestException(404, 'MyObject not found'); @@ -269,7 +266,7 @@ class MyModuleApi extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - if( !$this->myobject->delete(DolibarrApiAccess::$user, 0)) + if( !$this->myobject->delete(DolibarrApiAccess::$user, 0)) { throw new RestException(500); } @@ -289,18 +286,18 @@ class MyModuleApi extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - /*unset($object->note); - unset($object->address); - unset($object->barcode_type); - unset($object->barcode_type_code); - unset($object->barcode_type_label); - unset($object->barcode_type_coder);*/ + /*unset($object->note); + unset($object->address); + unset($object->barcode_type); + unset($object->barcode_type_code); + unset($object->barcode_type_label); + unset($object->barcode_type_coder);*/ - return $object; + return $object; } /** @@ -311,7 +308,7 @@ class MyModuleApi extends DolibarrApi * * @throws RestException */ - function _validate($data) + private function _validate($data) { $myobject = array(); foreach (MyObjectApi::$FIELDS as $field) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index af96bcebf37..e23177dca11 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -432,19 +432,19 @@ class MyObject extends CommonObject //return $this->deleteCommon($user, $notrigger, 1); } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param string $option On what the link point to ('nolink', ...) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs, $hookmanager; + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; @@ -460,10 +460,10 @@ class MyObject extends CommonObject if ($option != 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkclose=''; @@ -504,7 +504,7 @@ class MyObject extends CommonObject else $result .= $hookmanager->resPrint; return $result; - } + } /** * Return label of the status @@ -673,11 +673,11 @@ class MyObject extends CommonObject /* class MyObjectLine { - // @var int ID - public $id; - // @var mixed Sample line property 1 - public $prop1; - // @var mixed Sample line property 2 - public $prop2; + // @var int ID + public $id; + // @var mixed Sample line property 1 + public $prop1; + // @var mixed Sample line property 2 + public $prop2; } */ diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index 66cf8ab05eb..7416eb1c35e 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -194,18 +194,18 @@ class mymodulewidget1 extends ModeleBoxes ); } - /** - * Method to show box. Called by Dolibarr eatch time it wants to display the box. - * - * @param array $head Array with properties of box title - * @param array $contents Array with properties of box lines + /** + * Method to show box. Called by Dolibarr eatch time it wants to display the box. + * + * @param array $head Array with properties of box title + * @param array $contents Array with properties of box lines * @param int $nooutput No print, only return string - * @return void - */ - public function showBox($head = null, $contents = null, $nooutput = 0) - { - // You may make your own code here… - // … or use the parent's class function using the provided head and contents templates - parent::showBox($this->info_box_head, $this->info_box_contents); - } + * @return void + */ + public function showBox($head = null, $contents = null, $nooutput = 0) + { + // You may make your own code here… + // … or use the parent's class function using the provided head and contents templates + parent::showBox($this->info_box_head, $this->info_box_contents); + } } diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index a62cf3924d6..83644cd1f0e 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -17,46 +17,46 @@ dol_include_once("/mymodule/class/myobject.class.php"); */ class mailing_mailinglist_mymodule_myobject extends MailingTargets { - // CHANGE THIS: Put here a name not already used - var $name='mailinglist_mymodule_myobject'; - // CHANGE THIS: Put here a description of your selector module - var $desc='My object emailing target selector'; - // CHANGE THIS: Set to 1 if selector is available for admin users only - var $require_admin=0; + // CHANGE THIS: Put here a name not already used + public $name='mailinglist_mymodule_myobject'; + // CHANGE THIS: Put here a description of your selector module + public $desc='My object emailing target selector'; + // CHANGE THIS: Set to 1 if selector is available for admin users only + public $require_admin=0; - var $enabled=0; - var $require_module=array(); - var $picto='mymodule@mymodule'; + public $enabled=0; + public $require_module=array(); + public $picto='mymodule@mymodule'; - /** + /** * @var DoliDB Database handler. */ public $db; - /** - * Constructor + /** + * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ - function __construct($db) - { - global $conf; + public function __construct($db) + { + global $conf; - $this->db=$db; - if (is_array($conf->modules)) - { - $this->enabled=in_array('mymodule', $conf->modules)?1:0; - } - } + $this->db=$db; + if (is_array($conf->modules)) + { + $this->enabled=in_array('mymodule', $conf->modules)?1:0; + } + } /** - * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings + * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings * - * @return string Retourne zone select + * @return string Retourne zone select */ - function formFilter() + public function formFilter() { global $langs; $langs->load("members"); @@ -71,7 +71,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets $s.=''; foreach($arraystatus as $status) { - $s.=''; + $s.=''; } $s.=''; $s.='
'; @@ -81,122 +81,122 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets /** - * Renvoie url lien vers fiche de la source du destinataire du mailing - * - * @param int $id ID - * @return string Url lien - */ - function url($id) - { - return ''.img_object('', "generic").''; - } + * Renvoie url lien vers fiche de la source du destinataire du mailing + * + * @param int $id ID + * @return string Url lien + */ + public function url($id) + { + return ''.img_object('', "generic").''; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * This is the main function that returns the array of emails - * - * @param int $mailing_id Id of emailing - * @return int <0 if error, number of emails added if ok - */ - function add_to_target($mailing_id) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * This is the main function that returns the array of emails + * + * @param int $mailing_id Id of emailing + * @return int <0 if error, number of emails added if ok + */ + public function add_to_target($mailing_id) + { // phpcs:enable - $target = array(); - $j = 0; + $target = array(); + $j = 0; - $sql = " select rowid as id, email, firstname, lastname, plan, partner"; - $sql.= " from ".MAIN_DB_PREFIX."myobject"; - $sql.= " where email IS NOT NULL AND email != ''"; - if (! empty($_POST['filter']) && $_POST['filter'] != 'none') $sql.= " AND status = '".$this->db->escape($_POST['filter'])."'"; - $sql.= " ORDER BY email"; + $sql = " select rowid as id, email, firstname, lastname, plan, partner"; + $sql.= " from ".MAIN_DB_PREFIX."myobject"; + $sql.= " where email IS NOT NULL AND email != ''"; + if (! empty($_POST['filter']) && $_POST['filter'] != 'none') $sql.= " AND status = '".$this->db->escape($_POST['filter'])."'"; + $sql.= " ORDER BY email"; - // Stocke destinataires dans target - $result=$this->db->query($sql); - if ($result) - { - $num = $this->db->num_rows($result); - $i = 0; + // Stocke destinataires dans target + $result=$this->db->query($sql); + if ($result) + { + $num = $this->db->num_rows($result); + $i = 0; - dol_syslog("mailinglist_mymodule_myobject.modules.php: mailing ".$num." targets found"); + dol_syslog("mailinglist_mymodule_myobject.modules.php: mailing ".$num." targets found"); - $old = ''; - while ($i < $num) - { - $obj = $this->db->fetch_object($result); - if ($old <> $obj->email) - { - $target[$j] = array( - 'email' => $obj->email, - 'name' => $obj->lastname, - 'id' => $obj->id, - 'firstname' => $obj->firstname, - 'other' => $obj->plan.';'.$obj->partner, - 'source_url' => $this->url($obj->id), - 'source_id' => $obj->id, - 'source_type' => 'dolicloud' - ); - $old = $obj->email; - $j++; - } + $old = ''; + while ($i < $num) + { + $obj = $this->db->fetch_object($result); + if ($old <> $obj->email) + { + $target[$j] = array( + 'email' => $obj->email, + 'name' => $obj->lastname, + 'id' => $obj->id, + 'firstname' => $obj->firstname, + 'other' => $obj->plan.';'.$obj->partner, + 'source_url' => $this->url($obj->id), + 'source_id' => $obj->id, + 'source_type' => 'dolicloud' + ); + $old = $obj->email; + $j++; + } - $i++; - } - } - else - { - dol_syslog($this->db->error()); - $this->error=$this->db->error(); - return -1; - } + $i++; + } + } + else + { + dol_syslog($this->db->error()); + $this->error=$this->db->error(); + return -1; + } - // You must fill the $target array with record like this - // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0'); - // ... - // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n'); + // You must fill the $target array with record like this + // $target[0]=array('email'=>'email_0','name'=>'name_0','firstname'=>'firstname_0'); + // ... + // $target[n]=array('email'=>'email_n','name'=>'name_n','firstname'=>'firstname_n'); - // Example: $target[0]=array('email'=>'myemail@mydomain.com','name'=>'Doe','firstname'=>'John'); + // Example: $target[0]=array('email'=>'myemail@mydomain.com','name'=>'Doe','firstname'=>'John'); - // ----- Your code end here ----- + // ----- Your code end here ----- - return parent::add_to_target($mailing_id, $target); - } + return parent::add_to_target($mailing_id, $target); + } - /** - * On the main mailing area, there is a box with statistics. - * If you want to add a line in this report you must provide an - * array of SQL request that returns two field: - * One called "label", One called "nb". - * - * @return array - */ - function getSqlArrayForStats() - { - // CHANGE THIS: Optionnal + /** + * On the main mailing area, there is a box with statistics. + * If you want to add a line in this report you must provide an + * array of SQL request that returns two field: + * One called "label", One called "nb". + * + * @return array + */ + public function getSqlArrayForStats() + { + // CHANGE THIS: Optionnal - //var $statssql=array(); - //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; + //var $statssql=array(); + //$this->statssql[0]="SELECT field1 as label, count(distinct(email)) as nb FROM mytable WHERE email IS NOT NULL"; - return array(); - } + return array(); + } - /** - * Return here number of distinct emails returned by your selector. - * For example if this selector is used to extract 500 different - * emails from a text file, this function must return 500. - * - * @param string $filter Filter - * @param string $option Options - * @return int Nb of recipients or -1 if KO - */ - function getNbOfRecipients($filter = 1, $option = '') - { - $a=parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''"); + /** + * Return here number of distinct emails returned by your selector. + * For example if this selector is used to extract 500 different + * emails from a text file, this function must return 500. + * + * @param string $filter Filter + * @param string $option Options + * @return int Nb of recipients or -1 if KO + */ + public function getNbOfRecipients($filter = 1, $option = '') + { + $a=parent::getNbOfRecipients("select count(distinct(email)) as nb from ".MAIN_DB_PREFIX."myobject as p where email IS NOT NULL AND email != ''"); - if ($a < 0) return -1; - return $a; - } + if ($a < 0) return -1; + return $a; + } } diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index db6dd961c6c..0f350e83226 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -1,6 +1,7 @@ - * Copyright (C) 2018 Nicolas ZABOURI +/* Copyright (C) 2004-2018 Laurent Destailleur + * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2019 Frédéric France * Copyright (C) ---Put here your own copyright and developer email--- * * This program is free software; you can redistribute it and/or modify @@ -33,314 +34,370 @@ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; */ class modMyModule extends DolibarrModules { - /** - * Constructor. Define names, constants, directories, boxes, permissions - * - * @param DoliDB $db Database handler - */ - public function __construct($db) - { + /** + * Constructor. Define names, constants, directories, boxes, permissions + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { global $langs,$conf; $this->db = $db; - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'mymodule'; + // Id for module (must be unique). + // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). + $this->numero = 500000; // TODO Go on page https://wiki.dolibarr.org/index.php/List_of_modules_id to reserve id number for your module + // Key text used to identify module (for permissions, menus, etc...) + $this->rights_class = 'mymodule'; - // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' - // It is used to group modules by family in module setup page - $this->family = "other"; - // Module position in the family on 2 digits ('01', '10', '20', ...) - $this->module_position = '90'; - // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) - //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); + // Family can be 'base' (core modules),'crm','financial','hr','projects','products','ecm','technic' (transverse modules),'interface' (link with external tools),'other','...' + // It is used to group modules by family in module setup page + $this->family = "other"; + // Module position in the family on 2 digits ('01', '10', '20', ...) + $this->module_position = '90'; + // Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this) + //$this->familyinfo = array('myownfamily' => array('position' => '01', 'label' => $langs->trans("MyOwnFamily"))); - // Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModule is name of module). - $this->name = preg_replace('/^mod/i', '', get_class($this)); - // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module). - $this->description = "MyModuleDescription"; - // Used only if file README.md and README-LL.md not found. - $this->descriptionlong = "MyModule description (Long)"; + // Module label (no space allowed), used if translation string 'ModuleMyModuleName' not found (MyModule is name of module). + $this->name = preg_replace('/^mod/i', '', get_class($this)); + // Module description, used if translation string 'ModuleMyModuleDesc' not found (MyModule is name of module). + $this->description = "MyModuleDescription"; + // Used only if file README.md and README-LL.md not found. + $this->descriptionlong = "MyModule description (Long)"; - $this->editor_name = 'Editor name'; - $this->editor_url = 'https://www.example.com'; + $this->editor_name = 'Editor name'; + $this->editor_url = 'https://www.example.com'; - // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' - $this->version = '1.0'; + // Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z' + $this->version = '1.0'; //Url to the file with your last numberversion of this module //$this->url_last_version = 'http://www.example.com/versionmodule.txt'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Name of image file used for this module. - // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' - // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' - $this->picto='generic'; + // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) + $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); + // Name of image file used for this module. + // If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue' + // If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module' + $this->picto='generic'; - // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) - $this->module_parts = array( - 'triggers' => 1, // Set this to 1 if module has its own trigger directory (core/triggers) - 'login' => 0, // Set this to 1 if module has its own login method file (core/login) - 'substitutions' => 1, // Set this to 1 if module has its own substitution function file (core/substitutions) - 'menus' => 0, // Set this to 1 if module has its own menus handler directory (core/menus) - 'theme' => 0, // Set this to 1 if module has its own theme directory (theme) - 'tpl' => 0, // Set this to 1 if module overwrite template dir (core/tpl) - 'barcode' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) - 'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) - 'css' => array('/mymodule/css/mymodule.css.php'), // Set this to relative path of css file if module has its own css file - 'js' => array('/mymodule/js/mymodule.js.php'), // Set this to relative path of js file if module must load a js on all pages - 'hooks' => array('data'=>array('hookcontext1','hookcontext2'), 'entity'=>'0'), // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' - 'moduleforexternal' => 0 // Set this to 1 if feature of module are opened to external users - ); + // Define some features supported by module (triggers, login, substitutions, menus, css, etc...) + $this->module_parts = array( + // Set this to 1 if module has its own trigger directory (core/triggers) + 'triggers' => 1, + // Set this to 1 if module has its own login method file (core/login) + 'login' => 0, + // Set this to 1 if module has its own substitution function file (core/substitutions) + 'substitutions' => 1, + // Set this to 1 if module has its own menus handler directory (core/menus) + 'menus' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, + // Set this to 1 if module overwrite template dir (core/tpl) + 'tpl' => 0, + // Set this to 1 if module has its own barcode directory (core/modules/barcode) + 'barcode' => 0, + // Set this to 1 if module has its own models directory (core/modules/xxx) + 'models' => 0, + // Set this to relative path of css file if module has its own css file + 'css' => array( + '/mymodule/css/mymodule.css.php', + ), + // Set this to relative path of js file if module must load a js on all pages + 'js' => array( + '/mymodule/js/mymodule.js.php', + ), + // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all' + 'hooks' => array( + 'data' => array( + 'hookcontext1', + 'hookcontext2', + ), + 'entity' => '0', + ), + // Set this to 1 if feature of module are opened to external users + 'moduleforexternal' => 0, + ); - // Data directories to create when module is enabled. - // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir"); - $this->dirs = array("/mymodule/temp"); + // Data directories to create when module is enabled. + // Example: this->dirs = array("/mymodule/temp","/mymodule/subdir"); + $this->dirs = array("/mymodule/temp"); - // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. - $this->config_page_url = array("setup.php@mymodule"); + // Config pages. Put here list of php page, stored into mymodule/admin directory, to use to setup module. + $this->config_page_url = array("setup.php@mymodule"); - // Dependencies - $this->hidden = false; // A condition to hide module - $this->depends = array(); // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) - $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) - $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) - $this->langfiles = array("mymodule@mymodule"); - //$this->phpmin = array(5,4); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module - $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) - //$this->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice'); - //$this->always_enabled = true; // If true, can't be disabled + // Dependencies + // A condition to hide module + $this->hidden = false; + // List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...) + $this->depends = array(); + $this->requiredby = array(); // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...) + $this->conflictwith = array(); // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...) + $this->langfiles = array("mymodule@mymodule"); + //$this->phpmin = array(5,4); // Minimum version of PHP required by module + $this->need_dolibarr_version = array(4,0); // Minimum version of Dolibarr required by module + $this->warnings_activation = array(); // Warning to show when we activate module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + $this->warnings_activation_ext = array(); // Warning to show when we activate an external module. array('always'='text') or array('FR'='textfr','ES'='textes'...) + //$this->automatic_activation = array('FR'=>'MyModuleWasAutomaticallyActivatedBecauseOfYourCountryChoice'); + //$this->always_enabled = true; // If true, can't be disabled - // Constants - // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) - // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), - // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) - // ); - $this->const = array( - 1=>array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) - ); + // Constants + // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive) + // Example: $this->const=array(0=>array('MYMODULE_MYNEWCONST1','chaine','myvalue','This is a constant to add',1), + // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1) + // ); + $this->const = array( + 1 => array('MYMODULE_MYCONSTANT', 'chaine', 'avalue', 'This is a constant to add', 1, 'allentities', 1) + ); - // Some keys to add into the overwriting translation tables - /*$this->overwrite_translation = array( - 'en_US:ParentCompany'=>'Parent company or reseller', - 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' - )*/ + // Some keys to add into the overwriting translation tables + /*$this->overwrite_translation = array( + 'en_US:ParentCompany'=>'Parent company or reseller', + 'fr_FR:ParentCompany'=>'Maison mère ou revendeur' + )*/ - if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled)) - { - $conf->mymodule=new stdClass(); - $conf->mymodule->enabled=0; - } + if (! isset($conf->mymodule) || ! isset($conf->mymodule->enabled)) { + $conf->mymodule=new stdClass(); + $conf->mymodule->enabled=0; + } - // Array to add new pages in new tabs + // Array to add new pages in new tabs $this->tabs = array(); - // Example: - // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 + // Example: + // $this->tabs[] = array('data'=>'objecttype:+tabname1:Title1:mylangfile@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__'); // To add a new tab identified by code tabname1 // $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key. // $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove'); // To remove an existing tab identified by code tabname // // Where objecttype can be - // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) - // 'contact' to add a tab in contact view - // 'contract' to add a tab in contract view - // 'group' to add a tab in group view - // 'intervention' to add a tab in intervention view - // 'invoice' to add a tab in customer invoice view - // 'invoice_supplier' to add a tab in supplier invoice view - // 'member' to add a tab in fundation member view - // 'opensurveypoll' to add a tab in opensurvey poll view - // 'order' to add a tab in customer order view - // 'order_supplier' to add a tab in supplier order view - // 'payment' to add a tab in payment view - // 'payment_supplier' to add a tab in supplier payment view - // 'product' to add a tab in product view - // 'propal' to add a tab in propal view - // 'project' to add a tab in project view - // 'stock' to add a tab in stock view - // 'thirdparty' to add a tab in third party view - // 'user' to add a tab in user view + // 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member) + // 'contact' to add a tab in contact view + // 'contract' to add a tab in contract view + // 'group' to add a tab in group view + // 'intervention' to add a tab in intervention view + // 'invoice' to add a tab in customer invoice view + // 'invoice_supplier' to add a tab in supplier invoice view + // 'member' to add a tab in fundation member view + // 'opensurveypoll' to add a tab in opensurvey poll view + // 'order' to add a tab in customer order view + // 'order_supplier' to add a tab in supplier order view + // 'payment' to add a tab in payment view + // 'payment_supplier' to add a tab in supplier payment view + // 'product' to add a tab in product view + // 'propal' to add a tab in propal view + // 'project' to add a tab in project view + // 'stock' to add a tab in stock view + // 'thirdparty' to add a tab in third party view + // 'user' to add a tab in user view // Dictionaries - $this->dictionaries=array(); + $this->dictionaries=array(); /* Example: $this->dictionaries=array( 'langs'=>'mylangfile@mymodule', - 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), // List of tables we want to see into dictonnary editor - 'tablib'=>array("Table1","Table2","Table3"), // Label of tables - 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), // Request to select fields - 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), // Sort order - 'tabfield'=>array("code,label","code,label","code,label"), // List of fields (result of select to show dictionary) - 'tabfieldvalue'=>array("code,label","code,label","code,label"), // List of fields (list of fields to edit a record) - 'tabfieldinsert'=>array("code,label","code,label","code,label"), // List of fields (list of fields for insert) - 'tabrowid'=>array("rowid","rowid","rowid"), // Name of columns with primary key (try to always name it 'rowid') - 'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled) // Condition to show each dictionary + // List of tables we want to see into dictonnary editor + 'tabname'=>array(MAIN_DB_PREFIX."table1",MAIN_DB_PREFIX."table2",MAIN_DB_PREFIX."table3"), + // Label of tables + 'tablib'=>array("Table1","Table2","Table3"), + // Request to select fields + 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table1 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table2 as f','SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'table3 as f'), + // Sort order + 'tabsqlsort'=>array("label ASC","label ASC","label ASC"), + // List of fields (result of select to show dictionary) + 'tabfield'=>array("code,label","code,label","code,label"), + // List of fields (list of fields to edit a record) + 'tabfieldvalue'=>array("code,label","code,label","code,label"), + // List of fields (list of fields for insert) + 'tabfieldinsert'=>array("code,label","code,label","code,label"), + // Name of columns with primary key (try to always name it 'rowid') + 'tabrowid'=>array("rowid","rowid","rowid"), + // Condition to show each dictionary + 'tabcond'=>array($conf->mymodule->enabled,$conf->mymodule->enabled,$conf->mymodule->enabled) ); */ // Boxes/Widgets - // Add here list of php file(s) stored in mymodule/core/boxes that contains class to show a widget. + // Add here list of php file(s) stored in mymodule/core/boxes that contains class to show a widget. $this->boxes = array( - 0=>array('file'=>'mymodulewidget1.php@mymodule','note'=>'Widget provided by MyModule','enabledbydefaulton'=>'Home'), - //1=>array('file'=>'mymodulewidget2.php@mymodule','note'=>'Widget provided by MyModule'), - //2=>array('file'=>'mymodulewidget3.php@mymodule','note'=>'Widget provided by MyModule') + 0 => array( + 'file' => 'mymodulewidget1.php@mymodule', + 'note' => 'Widget provided by MyModule', + 'enabledbydefaulton' => 'Home', + ), + //1=>array('file'=>'mymodulewidget2.php@mymodule','note'=>'Widget provided by MyModule'), + //2=>array('file'=>'mymodulewidget3.php@mymodule','note'=>'Widget provided by MyModule') ); - // Cronjobs (List of cron jobs entries to add when module is enabled) - // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week - $this->cronjobs = array( - 0=>array('label'=>'MyJob label', 'jobtype'=>'method', 'class'=>'/mymodule/class/myobject.class.php', 'objectname'=>'MyObject', 'method'=>'doScheduledJob', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) - ); - // Example: $this->cronjobs=array(0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50), - // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) - // ); + // Cronjobs (List of cron jobs entries to add when module is enabled) + // unit_frequency must be 60 for minute, 3600 for hour, 86400 for day, 604800 for week + $this->cronjobs = array( + 0 => array( + 'label' => 'MyJob label', + 'jobtype' => 'method', + 'class' => '/mymodule/class/myobject.class.php', + 'objectname' => 'MyObject', + 'method' => 'doScheduledJob', + 'parameters' => '', + 'comment' => 'Comment', + 'frequency' => 2, + 'unitfrequency' => 3600, + 'status' => 0, + 'test' => '$conf->mymodule->enabled', + 'priority' => 50, + ), + ); + // Example: $this->cronjobs=array( + // 0=>array('label'=>'My label', 'jobtype'=>'method', 'class'=>'/dir/class/file.class.php', 'objectname'=>'MyClass', 'method'=>'myMethod', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>2, 'unitfrequency'=>3600, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50), + // 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'param1, param2', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24, 'status'=>0, 'test'=>'$conf->mymodule->enabled', 'priority'=>50) + // ); - // Permissions - $this->rights = array(); // Permission array used by this module + // Permissions + $this->rights = array(); // Permission array used by this module - $r=0; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Read myobject of MyModule'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $r=0; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Read myobject of MyModule'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'read'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Create/Update myobject of MyModule'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Create/Update myobject of MyModule'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'write'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $r++; - $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) - $this->rights[$r][1] = 'Delete myobject of MyModule'; // Permission label - $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $r++; + $this->rights[$r][0] = $this->numero + $r; // Permission id (must not be already used) + $this->rights[$r][1] = 'Delete myobject of MyModule'; // Permission label + $this->rights[$r][3] = 1; // Permission by default for new user (0/1) + $this->rights[$r][4] = 'delete'; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) + $this->rights[$r][5] = ''; // In php code, permission will be checked by test if ($user->rights->mymodule->level1->level2) - // Main menu entries - $this->menu = array(); // List of menus to add - $r=0; + // Main menu entries + $this->menu = array(); // List of menus to add + $r=0; - // Add here entries to declare new menus + // Add here entries to declare new menus - /* BEGIN MODULEBUILDER TOPMENU */ - $this->menu[$r++]=array('fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'top', // This is a Top menu entry - 'titre'=>'MyModule', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'', - 'url'=>'/mymodule/mymoduleindex.php', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + /* BEGIN MODULEBUILDER TOPMENU */ + $this->menu[$r++]=array( + 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'top', // This is a Top menu entry + 'titre'=>'MyModule', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'', + 'url'=>'/mymodule/mymoduleindex.php', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); - /* END MODULEBUILDER TOPMENU */ + /* END MODULEBUILDER TOPMENU */ - /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT - $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'List MyObject', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule_myobject_list', - 'url'=>'/mymodule/myobject_list.php', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - $this->menu[$r++]=array( 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'type'=>'left', // This is a Left menu entry - 'titre'=>'New MyObject', - 'mainmenu'=>'mymodule', - 'leftmenu'=>'mymodule_myobject_new', - 'url'=>'/mymodule/myobject_page.php?action=create', - 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>1000+$r, - 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules - 'target'=>'', - 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both - END MODULEBUILDER LEFTMENU MYOBJECT */ + /* BEGIN MODULEBUILDER LEFTMENU MYOBJECT + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'List MyObject', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'mymodule_myobject_list', + 'url'=>'/mymodule/myobject_list.php', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + $this->menu[$r++]=array( + 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'New MyObject', + 'mainmenu'=>'mymodule', + 'leftmenu'=>'mymodule_myobject_new', + 'url'=>'/mymodule/myobject_page.php?action=create', + 'langs'=>'mymodule@mymodule', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>1000+$r, + 'enabled'=>'$conf->mymodule->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'1', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both + ); + END MODULEBUILDER LEFTMENU MYOBJECT */ - // Exports - $r=1; + // Exports + $r=1; - /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ - /* - $langs->load("mymodule@mymodule"); - $this->export_code[$r]=$this->rights_class.'_'.$r; - $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) - $this->export_icon[$r]='myobject@mymodule'; - $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; - $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; - include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; - //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) - $this->export_sql_start[$r]='SELECT DISTINCT '; - $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; - $this->export_sql_end[$r] .=' WHERE 1 = 1'; - $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; - $r++; */ - /* END MODULEBUILDER EXPORT MYOBJECT */ - } + /* BEGIN MODULEBUILDER EXPORT MYOBJECT */ + /* + $langs->load("mymodule@mymodule"); + $this->export_code[$r]=$this->rights_class.'_'.$r; + $this->export_label[$r]='MyObjectLines'; // Translation key (used only if key ExportDataset_xxx_z not found) + $this->export_icon[$r]='myobject@mymodule'; + $keyforclass = 'MyObject'; $keyforclassfile='/mymobule/class/myobject.class.php'; $keyforelement='myobject'; + include DOL_DOCUMENT_ROOT.'/core/commonfieldsinexport.inc.php'; + $keyforselect='myobject'; $keyforaliasextra='extra'; $keyforelement='myobject'; + include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; + //$this->export_dependencies_array[$r]=array('mysubobject'=>'ts.rowid', 't.myfield'=>array('t.myfield2','t.myfield3')); // To force to activate one or several fields if we select some fields that need same (like to select a unique key if we ask a field of a child to avoid the DISTINCT to discard them, or for computed field than need several other fields) + $this->export_sql_start[$r]='SELECT DISTINCT '; + $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'myobject as t'; + $this->export_sql_end[$r] .=' WHERE 1 = 1'; + $this->export_sql_end[$r] .=' AND t.entity IN ('.getEntity('myobject').')'; + $r++; */ + /* END MODULEBUILDER EXPORT MYOBJECT */ + } - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function init($options = '') - { - $result=$this->_load_tables('/mymodule/sql/'); - if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') + /** + * Function called when module is enabled. + * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. + * It also creates data directories + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function init($options = '') + { + $result=$this->_load_tables('/mymodule/sql/'); + if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default') - // Create extrafields - include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; - $extrafields = new ExtraFields($this->db); + // Create extrafields + include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); - //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'varchar', 1, 10, 'project', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'varchar', 1, 10, 'bank_account', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); + //$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled'); - $sql = array(); + $sql = array(); - return $this->_init($sql, $options); - } + return $this->_init($sql, $options); + } - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted - * - * @param string $options Options when enabling module ('', 'noboxes') - * @return int 1 if OK, 0 if KO - */ - public function remove($options = '') - { - $sql = array(); + /** + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO + */ + public function remove($options = '') + { + $sql = array(); - return $this->_remove($sql, $options); - } + return $this->_remove($sql, $options); + } } diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php index 6a524fa5a99..69c0b07958e 100644 --- a/htdocs/multicurrency/class/multicurrency.class.php +++ b/htdocs/multicurrency/class/multicurrency.class.php @@ -429,9 +429,9 @@ class MultiCurrency extends CommonObject * * @return int -1 if KO, 1 if OK, 2 if label found and OK */ - function addRateFromDolibarr($code, $rate) - { - global $db, $user; + public function addRateFromDolibarr($code, $rate) + { + global $db, $user; $currency = new MultiCurrency($db); $currency->code = $code; @@ -455,7 +455,7 @@ class MultiCurrency extends CommonObject } return -1; - } + } /** * Add new entry into llx_multicurrency_rate to historise @@ -463,9 +463,9 @@ class MultiCurrency extends CommonObject * @param double $rate rate value * * @return int <0 if KO, >0 if OK - */ - public function updateRate($rate) - { + */ + public function updateRate($rate) + { return $this->addRate($rate); } @@ -474,8 +474,8 @@ class MultiCurrency extends CommonObject * * @return int <0 if KO, 0 if not found, >0 if OK */ - public function getRate() - { + public function getRate() + { $sql = 'SELECT cr.rowid'; $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element_line.' as cr'; $sql.= ' WHERE cr.fk_multicurrency = '.$this->id; @@ -497,8 +497,8 @@ class MultiCurrency extends CommonObject * * @return 0 if not found, >0 if OK */ - public static function getIdFromCode(&$db, $code) - { + public static function getIdFromCode(&$db, $code) + { global $conf; $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'multicurrency WHERE code = \''.$db->escape($code).'\' AND entity = '.$conf->entity; @@ -519,8 +519,8 @@ class MultiCurrency extends CommonObject * @return array [0] => id currency * [1] => rate */ - public static function getIdAndTxFromCode(&$db, $code, $date_document = '') - { + public static function getIdAndTxFromCode(&$db, $code, $date_document = '') + { global $conf; $sql1 = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m'; diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 5d06cb23faa..a688f12654b 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -34,72 +34,72 @@ require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"; */ class Opensurveysondage extends CommonObject { - /** - * @var string ID to identify managed object - */ - public $element='opensurvey_sondage'; + /** + * @var string ID to identify managed object + */ + public $element='opensurvey_sondage'; - /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='opensurvey_sondage'; + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element='opensurvey_sondage'; public $picto = 'opensurvey'; - public $id_sondage; - /** - * @deprecated - * @see description - */ - public $commentaires; + public $id_sondage; + /** + * @deprecated + * @see description + */ + public $commentaires; - /** - * @var string description - */ - public $description; + /** + * @var string description + */ + public $description; - public $mail_admin; - public $nom_admin; + public $mail_admin; + public $nom_admin; - /** - * Id of user author of the poll - * @var int - */ - public $fk_user_creat; + /** + * Id of user author of the poll + * @var int + */ + public $fk_user_creat; - public $titre; - public $date_fin=''; - public $status=1; - public $format; - public $mailsonde; + public $titre; + public $date_fin=''; + public $status=1; + public $format; + public $mailsonde; - public $sujet; + public $sujet; - /** - * Allow comments on this poll - * @var bool - */ - public $allow_comments; + /** + * Allow comments on this poll + * @var bool + */ + public $allow_comments; - /** - * Allow users see others vote - * @var bool - */ - public $allow_spy; + /** + * Allow users see others vote + * @var bool + */ + public $allow_spy; - /** - * Draft status (not used) - */ - const STATUS_DRAFT = 0; - /** - * Validated/Opened status - */ - const STATUS_VALIDATED = 1; - /** - * Closed - */ - const STATUS_CLOSED = 2; + /** + * Draft status (not used) + */ + const STATUS_DRAFT = 0; + /** + * Validated/Opened status + */ + const STATUS_VALIDATED = 1; + /** + * Closed + */ + const STATUS_CLOSED = 2; @@ -108,7 +108,7 @@ class Opensurveysondage extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -117,87 +117,87 @@ class Opensurveysondage extends CommonObject /** * Create object into database * - * @param User $user User that creates - * @param int $notrigger 0=launch triggers after, 1=disable triggers - * @return int <0 if KO, Id of created object if OK + * @param User $user User that creates + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK */ - function create(User $user, $notrigger = 0) + public function create(User $user, $notrigger = 0) { - $error=0; + $error=0; - // Clean parameters - $this->cleanParameters(); + // Clean parameters + $this->cleanParameters(); - // Check parameters - if (! $this->date_fin > 0) - { - $this->error='BadValueForEndDate'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); - return -1; - } + // Check parameters + if (! $this->date_fin > 0) + { + $this->error='BadValueForEndDate'; + dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR); + return -1; + } // Insert request - $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage("; - $sql.= "id_sondage,"; - $sql.= "commentaires,"; - $sql.= "fk_user_creat,"; - $sql.= "titre,"; - $sql.= "date_fin,"; - $sql.= "status,"; - $sql.= "format,"; - $sql.= "mailsonde,"; - $sql.= "allow_comments,"; - $sql.= "allow_spy,"; - $sql.= "sujet"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage("; + $sql.= "id_sondage,"; + $sql.= "commentaires,"; + $sql.= "fk_user_creat,"; + $sql.= "titre,"; + $sql.= "date_fin,"; + $sql.= "status,"; + $sql.= "format,"; + $sql.= "mailsonde,"; + $sql.= "allow_comments,"; + $sql.= "allow_spy,"; + $sql.= "sujet"; $sql.= ") VALUES ("; - $sql.= "'".$this->db->escape($this->id_sondage)."',"; - $sql.= " ".(empty($this->commentaires)?'NULL':"'".$this->db->escape($this->commentaires)."'").","; - $sql.= " ".$user->id.","; - $sql.= " '".$this->db->escape($this->titre)."',"; - $sql.= " '".$this->db->idate($this->date_fin)."',"; - $sql.= " ".$this->status.","; - $sql.= " '".$this->db->escape($this->format)."',"; - $sql.= " ".$this->db->escape($this->mailsonde).","; - $sql.= " ".$this->db->escape($this->allow_comments).","; - $sql.= " ".$this->db->escape($this->allow_spy).","; - $sql.= " '".$this->db->escape($this->sujet)."'"; - $sql.= ")"; + $sql.= "'".$this->db->escape($this->id_sondage)."',"; + $sql.= " ".(empty($this->commentaires)?'NULL':"'".$this->db->escape($this->commentaires)."'").","; + $sql.= " ".$user->id.","; + $sql.= " '".$this->db->escape($this->titre)."',"; + $sql.= " '".$this->db->idate($this->date_fin)."',"; + $sql.= " ".$this->status.","; + $sql.= " '".$this->db->escape($this->format)."',"; + $sql.= " ".$this->db->escape($this->mailsonde).","; + $sql.= " ".$this->db->escape($this->allow_comments).","; + $sql.= " ".$this->db->escape($this->allow_spy).","; + $sql.= " '".$this->db->escape($this->sujet)."'"; + $sql.= ")"; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::create", LOG_DEBUG); + dol_syslog(get_class($this)."::create", LOG_DEBUG); $resql=$this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) + if (! $error) { - if (! $notrigger) - { - global $langs, $conf; + if (! $notrigger) + { + global $langs, $conf; // Call trigger $result=$this->call_trigger('OPENSURVEY_CREATE', $user); if ($result < 0) $error++; // End call triggers - } + } } // Commit or rollback if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); return $this->id; - } + } } @@ -208,27 +208,27 @@ class Opensurveysondage extends CommonObject * @param string $numsurvey Ref of survey (admin or not) * @return int <0 if KO, >0 if OK */ - function fetch($id, $numsurvey = '') + public function fetch($id, $numsurvey = '') { - $sql = "SELECT"; - $sql.= " t.id_sondage,"; - $sql.= " t.commentaires as description,"; - $sql.= " t.mail_admin,"; - $sql.= " t.nom_admin,"; - $sql.= " t.fk_user_creat,"; - $sql.= " t.titre,"; - $sql.= " t.date_fin,"; - $sql.= " t.status,"; - $sql.= " t.format,"; - $sql.= " t.mailsonde,"; - $sql.= " t.allow_comments,"; - $sql.= " t.allow_spy,"; - $sql.= " t.sujet,"; - $sql.= " t.tms"; + $sql = "SELECT"; + $sql.= " t.id_sondage,"; + $sql.= " t.commentaires as description,"; + $sql.= " t.mail_admin,"; + $sql.= " t.nom_admin,"; + $sql.= " t.fk_user_creat,"; + $sql.= " t.titre,"; + $sql.= " t.date_fin,"; + $sql.= " t.status,"; + $sql.= " t.format,"; + $sql.= " t.mailsonde,"; + $sql.= " t.allow_comments,"; + $sql.= " t.allow_spy,"; + $sql.= " t.sujet,"; + $sql.= " t.tms"; $sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t"; $sql.= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'"; - dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { @@ -236,29 +236,29 @@ class Opensurveysondage extends CommonObject { $obj = $this->db->fetch_object($resql); - $this->id_sondage = $obj->id_sondage; - $this->ref = $this->id_sondage; //For compatibility + $this->id_sondage = $obj->id_sondage; + $this->ref = $this->id_sondage; //For compatibility - $this->commentaires = $obj->description; // deprecated - $this->description = $obj->description; - $this->mail_admin = $obj->mail_admin; - $this->nom_admin = $obj->nom_admin; - $this->titre = $obj->titre; - $this->date_fin = $this->db->jdate($obj->date_fin); - $this->status = $obj->status; - $this->format = $obj->format; - $this->mailsonde = $obj->mailsonde; - $this->allow_comments = $obj->allow_comments; - $this->allow_spy = $obj->allow_spy; - $this->sujet = $obj->sujet; - $this->fk_user_creat = $obj->fk_user_creat; + $this->commentaires = $obj->description; // deprecated + $this->description = $obj->description; + $this->mail_admin = $obj->mail_admin; + $this->nom_admin = $obj->nom_admin; + $this->titre = $obj->titre; + $this->date_fin = $this->db->jdate($obj->date_fin); + $this->status = $obj->status; + $this->format = $obj->format; + $this->mailsonde = $obj->mailsonde; + $this->allow_comments = $obj->allow_comments; + $this->allow_spy = $obj->allow_spy; + $this->sujet = $obj->sujet; + $this->fk_user_creat = $obj->fk_user_creat; - $this->date_m = $this->db->jdate($obj->tls); - $ret=1; + $this->date_m = $this->db->jdate($obj->tls); + $ret=1; } else { - $sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey); + $sondage = ($id ? 'id='.$id : 'sondageid='.$numsurvey); $this->error='Fetch no poll found for '.$sondage; dol_syslog($this->error, LOG_ERR); $ret = 0; @@ -268,7 +268,7 @@ class Opensurveysondage extends CommonObject } else { - $this->error="Error ".$this->db->lasterror(); + $this->error="Error ".$this->db->lasterror(); $ret=-1; } @@ -279,73 +279,73 @@ class Opensurveysondage extends CommonObject /** * Update object into database * - * @param User $user User that modifies - * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @param User $user User that modifies + * @param int $notrigger 0=launch triggers after, 1=disable triggers * @return int <0 if KO, >0 if OK */ - function update(User $user, $notrigger = 0) + public function update(User $user, $notrigger = 0) { - global $conf, $langs; - $error=0; + global $conf, $langs; + $error=0; - // Clean parameters - $this->cleanParameters(); + // Clean parameters + $this->cleanParameters(); - // Check parameters - // Put here code to add a control on parameters values + // Check parameters + // Put here code to add a control on parameters values // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."opensurvey_sondage SET"; - $sql.= " id_sondage=".(isset($this->id_sondage)?"'".$this->db->escape($this->id_sondage)."'":"null").","; - $sql.= " commentaires=".(isset($this->commentaires)?"'".$this->db->escape($this->commentaires)."'":"null").","; - $sql.= " mail_admin=".(isset($this->mail_admin)?"'".$this->db->escape($this->mail_admin)."'":"null").","; - $sql.= " nom_admin=".(isset($this->nom_admin)?"'".$this->db->escape($this->nom_admin)."'":"null").","; - $sql.= " titre=".(isset($this->titre)?"'".$this->db->escape($this->titre)."'":"null").","; - $sql.= " date_fin=".(dol_strlen($this->date_fin)!=0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; - $sql.= " status=".(isset($this->status)?"'".$this->db->escape($this->status)."'":"null").","; - $sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").","; - $sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").","; - $sql.= " allow_comments=".$this->db->escape($this->allow_comments).","; - $sql.= " allow_spy=".$this->db->escape($this->allow_spy); + $sql.= " id_sondage=".(isset($this->id_sondage)?"'".$this->db->escape($this->id_sondage)."'":"null").","; + $sql.= " commentaires=".(isset($this->commentaires)?"'".$this->db->escape($this->commentaires)."'":"null").","; + $sql.= " mail_admin=".(isset($this->mail_admin)?"'".$this->db->escape($this->mail_admin)."'":"null").","; + $sql.= " nom_admin=".(isset($this->nom_admin)?"'".$this->db->escape($this->nom_admin)."'":"null").","; + $sql.= " titre=".(isset($this->titre)?"'".$this->db->escape($this->titre)."'":"null").","; + $sql.= " date_fin=".(dol_strlen($this->date_fin)!=0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').","; + $sql.= " status=".(isset($this->status)?"'".$this->db->escape($this->status)."'":"null").","; + $sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").","; + $sql.= " mailsonde=".(isset($this->mailsonde)?$this->db->escape($this->mailsonde):"null").","; + $sql.= " allow_comments=".$this->db->escape($this->allow_comments).","; + $sql.= " allow_spy=".$this->db->escape($this->allow_spy); - $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; + $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::update", LOG_DEBUG); + dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - if (! $error) - { - if (! $notrigger) - { - // Call triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // End call triggers - } - } + if (! $error) + { + if (! $notrigger) + { + // Call triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('OPENSURVEY_MODIFY', $this, $user, $langs, $conf); + if ($result < 0) { $error++; $this->errors=$interface->errors; } + // End call triggers + } + } // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } } /** @@ -356,328 +356,328 @@ class Opensurveysondage extends CommonObject * @param string $numsondage Num sondage admin to delete * @return int <0 if KO, >0 if OK */ - function delete(User $user, $notrigger = 0, $numsondage = '') + public function delete(User $user, $notrigger = 0, $numsondage = '') { - global $conf, $langs; - $error=0; + global $conf, $langs; + $error=0; - if (empty($numsondage)) - { - $numsondage = $this->id_sondage; - } + if (empty($numsondage)) + { + $numsondage = $this->id_sondage; + } - $this->db->begin(); + $this->db->begin(); - if (! $error) - { - if (! $notrigger) - { + if (! $error) + { + if (! $notrigger) + { // Call trigger $result=$this->call_trigger('OPENSURVEY_DELETE', $user); if ($result < 0) $error++; // End call triggers - } - } + } + } - if (! $error) - { + if (! $error) + { - $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); - $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'"; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql=$this->db->query($sql); + $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); + $sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql=$this->db->query($sql); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage"; - $sql.= " WHERE id_sondage = '".$this->db->escape($numsondage)."'"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage"; + $sql.= " WHERE id_sondage = '".$this->db->escape($numsondage)."'"; - dol_syslog(get_class($this)."::delete", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - } + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + } // Commit or rollback - if ($error) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } - } + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } - /** - * Return a link to the object card (with optionaly the picto) - * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) - * @param int $notooltip 1=Disable tooltip - * @param string $morecss Add more css on link - * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking - * @return string String with URL - */ - function getNomUrl($withpicto = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) - { - global $db, $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $result = ''; - $companylink = ''; + $result = ''; + $companylink = ''; - $label = '' . $langs->trans("ShowSurvey") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; - $label.= '' . $langs->trans('Title') . ': ' . $this->title.'
'; + $label = '' . $langs->trans("ShowSurvey") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; + $label.= '' . $langs->trans('Title') . ': ' . $this->title.'
'; - $url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id; + $url = DOL_URL_ROOT.'/opensurvey/card.php?id='.$this->id; - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; - $linkclose=''; - if (empty($notooltip)) - { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowMyObject"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowMyObject"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); - $linkstart = ''; - $linkend=''; + $linkstart = ''; + $linkend=''; - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; - $result .= $linkend; + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; - return $result; - } + return $result; + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Return array of lines - * - * @return int <0 if KO, >0 if OK - */ - function fetch_lines() - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return array of lines + * + * @return int <0 if KO, >0 if OK + */ + public function fetch_lines() + { // phpcs:enable - $ret=array(); + $ret=array(); - $sql = "SELECT id_users, nom as name, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; - $sql.= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; - $resql=$this->db->query($sql); + $sql = "SELECT id_users, nom as name, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs"; + $sql.= " WHERE id_sondage = '".$this->db->escape($this->id_sondage)."'"; + $resql=$this->db->query($sql); - if ($resql) - { - $num=$this->db->num_rows($resql); - $i=0; - while ($i < $num) - { - $obj=$this->db->fetch_object($resql); - $tmp=array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); + if ($resql) + { + $num=$this->db->num_rows($resql); + $i=0; + while ($i < $num) + { + $obj=$this->db->fetch_object($resql); + $tmp=array('id_users'=>$obj->id_users, 'nom'=>$obj->name, 'reponses'=>$obj->reponses); - $ret[]=$tmp; - $i++; - } - } - else dol_print_error($this->db); + $ret[]=$tmp; + $i++; + } + } + else dol_print_error($this->db); - $this->lines=$ret; + $this->lines=$ret; - return count($this->lines); - } + return count($this->lines); + } - /** - * Initialise object with example values - * Id must be 0 if object instance is a specimen - * - * @return void - */ - function initAsSpecimen() - { - $this->id=0; + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + $this->id=0; - $this->id_sondage=''; - $this->commentaires='Comment of the specimen survey'; - $this->mail_admin=''; - $this->nom_admin=''; - $this->titre='This is a specimen survey'; - $this->date_fin=dol_now()+3600*24*10; - $this->status=1; - $this->format='classic'; - $this->mailsonde=''; - } + $this->id_sondage=''; + $this->commentaires='Comment of the specimen survey'; + $this->mail_admin=''; + $this->nom_admin=''; + $this->titre='This is a specimen survey'; + $this->date_fin=dol_now()+3600*24*10; + $this->status=1; + $this->format='classic'; + $this->mailsonde=''; + } - /** - * Returns all comments for the current opensurvey poll - * - * @return Object[] - */ - public function getComments() - { - $comments = array(); + /** + * Returns all comments for the current opensurvey poll + * + * @return Object[] + */ + public function getComments() + { + $comments = array(); - $sql = 'SELECT id_comment, usercomment, comment'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; - $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; - $sql.= " ORDER BY id_comment"; - $resql = $this->db->query($sql); + $sql = 'SELECT id_comment, usercomment, comment'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments'; + $sql.= " WHERE id_sondage='".$this->db->escape($this->id_sondage)."'"; + $sql.= " ORDER BY id_comment"; + $resql = $this->db->query($sql); - if ($resql) - { - $num_rows=$this->db->num_rows($resql); + if ($resql) + { + $num_rows=$this->db->num_rows($resql); - if ($num_rows > 0) - { - while ($obj = $this->db->fetch_object($resql)) - { - $comments[] = $obj; - } - } - } + if ($num_rows > 0) + { + while ($obj = $this->db->fetch_object($resql)) + { + $comments[] = $obj; + } + } + } - return $comments; - } + return $comments; + } - /** - * Adds a comment to the poll - * - * @param string $comment Comment content - * @param string $comment_user Comment author - * @return boolean False in case of the query fails, true if it was successful - */ - public function addComment($comment, $comment_user) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)"; - $sql.= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; - $resql = $this->db->query($sql); + /** + * Adds a comment to the poll + * + * @param string $comment Comment content + * @param string $comment_user Comment author + * @return boolean False in case of the query fails, true if it was successful + */ + public function addComment($comment, $comment_user) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)"; + $sql.= " VALUES ('".$this->db->escape($this->id_sondage)."','".$this->db->escape($comment)."','".$this->db->escape($comment_user)."')"; + $resql = $this->db->query($sql); - if (!$resql) { - return false; - } + if (!$resql) { + return false; + } - return true; - } + return true; + } - /** - * Deletes a comment of the poll - * - * @param int $id_comment Id of the comment - * @return boolean False in case of the query fails, true if it was successful - */ - public function deleteComment($id_comment) - { - $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"'; - $resql = $this->db->query($sql); + /** + * Deletes a comment of the poll + * + * @param int $id_comment Id of the comment + * @return boolean False in case of the query fails, true if it was successful + */ + public function deleteComment($id_comment) + { + $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$id_comment.' AND id_sondage = "'.$this->db->escape($this->id_sondage).'"'; + $resql = $this->db->query($sql); - if (!$resql) { - return false; - } + if (!$resql) { + return false; + } - return true; - } + return true; + } - /** - * Cleans all the class variables before doing an update or an insert - * - * @return void - */ - private function cleanParameters() - { - $this->id_sondage = trim($this->id_sondage); - $this->commentaires = trim($this->commentaires); - $this->mail_admin = trim($this->mail_admin); - $this->nom_admin = trim($this->nom_admin); - $this->titre = trim($this->titre); - $this->status = trim($this->status); - $this->format = trim($this->format); - $this->mailsonde = ($this->mailsonde ? 1 : 0); - $this->allow_comments = ($this->allow_comments ? 1 : 0); - $this->allow_spy = ($this->allow_spy ? 1 : 0); - $this->sujet = trim($this->sujet); - } + /** + * Cleans all the class variables before doing an update or an insert + * + * @return void + */ + private function cleanParameters() + { + $this->id_sondage = trim($this->id_sondage); + $this->commentaires = trim($this->commentaires); + $this->mail_admin = trim($this->mail_admin); + $this->nom_admin = trim($this->nom_admin); + $this->titre = trim($this->titre); + $this->status = trim($this->status); + $this->format = trim($this->format); + $this->mailsonde = ($this->mailsonde ? 1 : 0); + $this->allow_comments = ($this->allow_comments ? 1 : 0); + $this->allow_spy = ($this->allow_spy ? 1 : 0); + $this->sujet = trim($this->sujet); + } - /** - * Return status label of Order - * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle - */ - function getLibStatut($mode) - { - return $this->LibStatut($this->status, $mode); - } + /** + * Return status label of Order + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + public function getLibStatut($mode) + { + return $this->LibStatut($this->status, $mode); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Return label of status - * - * @param int $status Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - function LibStatut($status, $mode) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return label of status + * + * @param int $status Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode) + { // phpcs:enable - global $langs, $conf; + global $langs, $conf; - //print 'x'.$status.'-'.$billed; - if ($mode == 0) - { - if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); - if ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); - if ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); - } - elseif ($mode == 1) - { - if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); - if ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); - if ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); - } - elseif ($mode == 2) - { - if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); - if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'), 'statut1').' '.$langs->trans('Opened'); - if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6').' '.$langs->trans('Closed'); - } - elseif ($mode == 3) - { - if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0'); - if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'), 'statut1'); - if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6'); - } - elseif ($mode == 4) - { - if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); - if ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened').$billedtext, 'statut1').' '.$langs->trans('Opened'); - if ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6').' '.$langs->trans('Closed'); - } - elseif ($mode == 5) - { - if ($status==self::STATUS_DRAFT) return ''.$langs->trans('Draft').' '.img_picto($langs->trans('Draft'), 'statut0'); - if ($status==self::STATUS_VALIDATED) return ''.$langs->trans('Opened').' '.img_picto($langs->trans('Opened'), 'statut1'); - if ($status==self::STATUS_CLOSED) return ''.$langs->trans('Closed').' '.img_picto($langs->trans('Closed'), 'statut6'); - } - } + //print 'x'.$status.'-'.$billed; + if ($mode == 0) + { + if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); + elseif ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); + elseif ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); + } + elseif ($mode == 1) + { + if ($status==self::STATUS_DRAFT) return $langs->trans('Draft'); + elseif ($status==self::STATUS_VALIDATED) return $langs->trans('Opened'); + elseif ($status==self::STATUS_CLOSED) return $langs->trans('Closed'); + } + elseif ($mode == 2) + { + if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); + elseif ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'), 'statut1').' '.$langs->trans('Opened'); + elseif ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6').' '.$langs->trans('Closed'); + } + elseif ($mode == 3) + { + if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0'); + elseif ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened'), 'statut1'); + elseif ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6'); + } + elseif ($mode == 4) + { + if ($status==self::STATUS_DRAFT) return img_picto($langs->trans('Draft'), 'statut0').' '.$langs->trans('Draft'); + elseif ($status==self::STATUS_VALIDATED) return img_picto($langs->trans('Opened').$billedtext, 'statut1').' '.$langs->trans('Opened'); + elseif ($status==self::STATUS_CLOSED) return img_picto($langs->trans('Closed'), 'statut6').' '.$langs->trans('Closed'); + } + elseif ($mode == 5) + { + if ($status==self::STATUS_DRAFT) return ''.$langs->trans('Draft').' '.img_picto($langs->trans('Draft'), 'statut0'); + elseif ($status==self::STATUS_VALIDATED) return ''.$langs->trans('Opened').' '.img_picto($langs->trans('Opened'), 'statut1'); + elseif ($status==self::STATUS_CLOSED) return ''.$langs->trans('Closed').' '.img_picto($langs->trans('Closed'), 'statut6'); + } + } } diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 98f296d5060..461fa942679 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -28,29 +28,29 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class ActionsCardProduct { - var $targetmodule; - var $canvas; - var $card; + public $targetmodule; + public $canvas; + public $card; //! Template container - var $tpl = array(); + public $tpl = array(); // List of fiels for action=list - var $field_list =array(); + public $field_list =array(); public $list_datas = array(); /** - * Constructor - * + * Constructor + * * @param DoliDB $db Database handler * @param string $dirmodule Name of directory of module * @param string $targetmodule Name of directory where canvas is stored * @param string $canvas Name of canvas * @param string $card Name of tab (sub-canvas) - */ - function __construct($db, $dirmodule, $targetmodule, $canvas, $card) - { + */ + public function __construct($db, $dirmodule, $targetmodule, $canvas, $card) + { $this->db = $db; $this->dirmodule = $dirmodule; $this->targetmodule = $targetmodule; @@ -64,7 +64,7 @@ class ActionsCardProduct } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas (for example into this->tpl to be used by templates) * @@ -73,7 +73,7 @@ class ActionsCardProduct * @param string $ref Ref of object * @return void */ - function assign_values(&$action, $id = 0, $ref = '') + public function assign_values(&$action, $id = 0, $ref = '') { // phpcs:enable global $limit, $offset, $sortfield, $sortorder; @@ -86,8 +86,7 @@ class ActionsCardProduct //parent::assign_values($action); - foreach($this->object as $key => $value) - { + foreach($this->object as $key => $value) { $this->tpl[$key] = $value; } @@ -296,7 +295,7 @@ class ActionsCardProduct } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -306,7 +305,7 @@ class ActionsCardProduct * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - function LoadListDatas($limit, $offset, $sortfield, $sortorder) + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) { // phpcs:enable global $conf, $langs; diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index 5f5c78cfbc1..fab5794c82a 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -28,15 +28,15 @@ include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; */ class ActionsCardService { - var $targetmodule; - var $canvas; - var $card; + public $targetmodule; + public $canvas; + public $card; //! Template container - var $tpl = array(); + public $tpl = array(); // List of fiels for action=list - var $field_list =array(); + public $field_list =array(); public $list_datas = array(); @@ -48,7 +48,7 @@ class ActionsCardService * @param string $canvas Name of canvas * @param string $card Name of tab (sub-canvas) */ - function __construct($db, $targetmodule, $canvas, $card) + public function __construct($db, $targetmodule, $canvas, $card) { $this->db = $db; $this->targetmodule = $targetmodule; @@ -63,7 +63,7 @@ class ActionsCardService } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign custom values for canvas (for example into this->tpl to be used by templates) * @@ -72,7 +72,7 @@ class ActionsCardService * @param string $ref Ref of object * @return void */ - function assign_values(&$action, $id = 0, $ref = '') + public function assign_values(&$action, $id = 0, $ref = '') { // phpcs:enable global $limit, $offset, $sortfield, $sortorder; @@ -274,7 +274,7 @@ class ActionsCardService } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Fetch datas list and save into ->list_datas * @@ -284,7 +284,7 @@ class ActionsCardService * @param string $sortorder Sort order ('ASC' or 'DESC') * @return void */ - function LoadListDatas($limit, $offset, $sortfield, $sortorder) + public function LoadListDatas($limit, $offset, $sortfield, $sortorder) { // phpcs:enable global $conf; diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index c0e0b485d71..c95bcdcb8f4 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -44,7 +44,7 @@ class Products extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -68,14 +68,14 @@ class Products extends DolibarrApi * @throws 403 * @throws 404 */ - function get($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0) + public function get($id, $ref = '', $ref_ext = '', $barcode = '', $includestockdata = 0) { if (empty($id) && empty($ref) && empty($ref_ext) && empty($barcode)) { throw new RestException(400, 'bad value for parameter id, ref, ref_ext or barcode'); } $id = (empty($id)?0:$id); - + if(! DolibarrApiAccess::$user->rights->produit->lire) { throw new RestException(403); } @@ -84,7 +84,7 @@ class Products extends DolibarrApi if(! $result ) { throw new RestException(404, 'Product not found'); } - + if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } @@ -110,7 +110,7 @@ class Products extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)" * @return array Array of product objects */ - function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '') + public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $mode = 0, $category = 0, $sqlfilters = '') { global $db, $conf; @@ -185,7 +185,7 @@ class Products extends DolibarrApi * @param array $request_data Request data * @return int ID of product */ - function post($request_data = null) + public function post($request_data = null) { if(! DolibarrApiAccess::$user->rights->produit->creer) { throw new RestException(401); @@ -215,7 +215,7 @@ class Products extends DolibarrApi * @throws 401 * @throws 404 */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { global $conf; @@ -300,7 +300,7 @@ class Products extends DolibarrApi * @param int $id Product ID * @return array */ - function delete($id) + public function delete($id) { if(! DolibarrApiAccess::$user->rights->produit->supprimer) { throw new RestException(401); @@ -335,7 +335,7 @@ class Products extends DolibarrApi * * @url GET {id}/categories */ - function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) + public function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) { if (! DolibarrApiAccess::$user->rights->categorie->lire) { throw new RestException(401); @@ -365,7 +365,7 @@ class Products extends DolibarrApi * * @url GET {id}/selling_multiprices/per_segment */ - function getCustomerPricesPerSegment($id) + public function getCustomerPricesPerSegment($id) { global $conf; @@ -387,13 +387,13 @@ class Products extends DolibarrApi } return array( - 'multiprices'=>$this->product->multiprices, - 'multiprices_inc_tax'=>$this->product->multiprices_ttc, - 'multiprices_min'=>$this->product->multiprices_min, - 'multiprices_min_inc_tax'=>$this->product->multiprices_min_ttc, - 'multiprices_vat'=>$this->product->multiprices_tva_tx, - 'multiprices_base_type'=>$this->product->multiprices_base_type, - //'multiprices_default_vat_code'=>$this->product->multiprices_default_vat_code + 'multiprices'=>$this->product->multiprices, + 'multiprices_inc_tax'=>$this->product->multiprices_ttc, + 'multiprices_min'=>$this->product->multiprices_min, + 'multiprices_min_inc_tax'=>$this->product->multiprices_min_ttc, + 'multiprices_vat'=>$this->product->multiprices_tva_tx, + 'multiprices_base_type'=>$this->product->multiprices_base_type, + //'multiprices_default_vat_code'=>$this->product->multiprices_default_vat_code ); } @@ -406,7 +406,7 @@ class Products extends DolibarrApi * * @url GET {id}/selling_multiprices/per_customer */ - function getCustomerPricesPerCustomer($id) + public function getCustomerPricesPerCustomer($id) { global $conf; @@ -440,7 +440,7 @@ class Products extends DolibarrApi * * @url GET {id}/selling_multiprices/per_quantity */ - function getCustomerPricesPerQuantity($id) + public function getCustomerPricesPerQuantity($id) { global $conf; @@ -474,7 +474,7 @@ class Products extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); @@ -502,7 +502,7 @@ class Products extends DolibarrApi * @return array * @throws RestException */ - function _validate($data) + private function _validate($data) { $product = array(); foreach (Products::$FIELDS as $field) { diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 93d239cc207..1bafd063dec 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -45,11 +45,11 @@ class FormProduct /** - * Constructor + * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; } @@ -69,7 +69,7 @@ class FormProduct * @param array $exclude warehouses ids to exclude * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ - function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '') + public function loadWarehouses($fk_product = 0, $batch = '', $status = '', $sumStock = true, $exclude = '') { global $conf, $langs; @@ -210,7 +210,7 @@ class FormProduct * @param int $showfullpath 1=Show full path of name (parent ref into label), 0=Show only ref of current warehouse * @return string HTML select */ - function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1) + public function selectWarehouses($selected = '', $htmlname = 'idwarehouse', $filterstatus = '', $empty = 0, $disabled = 0, $fk_product = 0, $empty_label = '', $showstock = 0, $forcecombo = 0, $events = array(), $morecss = 'minwidth200', $exclude = '', $showfullpath = 1) { global $conf,$langs,$user; @@ -255,7 +255,7 @@ class FormProduct * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. * @return void */ - function formSelectWarehouses($page, $selected = '', $htmlname = 'warehouse_id', $addempty = 0) + public function formSelectWarehouses($page, $selected = '', $htmlname = 'warehouse_id', $addempty = 0) { global $langs; if ($htmlname != "none") { @@ -280,7 +280,7 @@ class FormProduct } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output a combo box with list of units * pour l'instant on ne definit pas les unites dans la base @@ -291,24 +291,24 @@ class FormProduct * @param int $adddefault Add empty unit called "Default" * @return void */ - function select_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) + public function select_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) { //phpcs:enable print $this->load_measuring_units($name, $measuring_style, $default, $adddefault); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return a combo box with list of units * For the moment, units labels are defined in measuring_units_string * - * @param string $name Name of HTML field + * @param string $name Name of HTML field * @param string $measuring_style Unit to show: weight, size, surface, volume * @param string $default Force unit - * @param int $adddefault Add empty unit called "Default" - * @return string + * @param int $adddefault Add empty unit called "Default" + * @return string */ - function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) + public function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) { //phpcs:enable global $langs, $conf, $mysoc, $db; @@ -320,10 +320,16 @@ class FormProduct require_once DOL_DOCUMENT_ROOT . '/core/class/cunits.class.php'; $measuringUnits = new CUnits($db); - $result = $measuringUnits->fetchAll('', '', 0, 0, array( - 't.unit_type' => $measuring_style, - 't.active' => 1 - )); + $result = $measuringUnits->fetchAll( + '', + '', + 0, + 0, + array( + 't.unit_type' => $measuring_style, + 't.active' => 1, + ) + ); if ($result < 0) { dol_print_error($db); return - 1; @@ -332,8 +338,7 @@ class FormProduct if ($adddefault) $return .= ''; - foreach ($measuringUnits->records as $lines) - { + foreach ($measuringUnits->records as $lines) { $return .= '
'; @@ -141,13 +140,11 @@ class ActionsStripeconnect $object->fetch_thirdparty(); $customer=$stripe->customerStripe($object, $stripe->getStripeAccount($service)); $this->resprints.= $customer->id; - } - else { + } else { $this->resprints.= $langs->trans("NoStripe"); } $this->resprints.= ''; - } - elseif (is_object($object) && $object->element == 'adherent_type'){ + } elseif (is_object($object) && $object->element == 'adherent_type'){ $this->resprints.= ''; + print ''; + print '
'.$options.''; - $out .= ' '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/',$langs->transnoentitiesnoconv("OriginFileName"),$savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); + $out .= ' '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName")); $out .= '
 
'.$langs->trans("Mask").' ('.$langs->trans("InvoiceAvoir").'):'.$form->textwithpicto('', $tooltip, 1, 1).'
'; $this->resprints.= ''; } return 0; - } + } /** * addMoreActionsButtons @@ -178,8 +174,8 @@ class ActionsStripeconnect * @param string $action action * @return int 0 */ - function addMoreActionsButtons($parameters, &$object, &$action) - { + public function addMoreActionsButtons($parameters, &$object, &$action) + { global $db,$conf,$user,$langs,$form; if (is_object($object) && $object->element == 'facture'){ // On verifie si la facture a des paiements @@ -234,5 +230,5 @@ class ActionsStripeconnect print ''.$langs->trans("StripeAutoSubscription").''; } return 0; - } + } } diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index fa881a834ea..8aad2a1b891 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -91,17 +91,14 @@ class Stripe extends CommonObject dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); $result = $this->db->query($sql); - if ($result) - { - if ($this->db->num_rows($result)) - { + if ($result) { + if ($this->db->num_rows($result)) { $obj = $this->db->fetch_object($result); $tokenstring=$obj->tokenstring; $tmparray = dol_json_decode($tokenstring); $key = $tmparray->stripe_user_id; - } - else { + } else { $tokenstring=''; } } @@ -311,8 +308,7 @@ class Stripe extends CommonObject $fee = round(($object->total_ttc * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE) * 100); if ($fee >= ($conf->global->STRIPE_APPLICATION_FEE_MAXIMAL * 100) && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL>$conf->global->STRIPE_APPLICATION_FEE_MINIMAL) { $fee = round($conf->global->STRIPE_APPLICATION_FEE_MAXIMAL * 100); - } - elseif ($fee < ($conf->global->STRIPE_APPLICATION_FEE_MINIMAL * 100)) { + } elseif ($fee < ($conf->global->STRIPE_APPLICATION_FEE_MINIMAL * 100)) { $fee = round($conf->global->STRIPE_APPLICATION_FEE_MINIMAL * 100); } diff --git a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php index d856cd1250d..15f4278bf49 100644 --- a/htdocs/supplier_proposal/class/api_supplier_proposals.class.php +++ b/htdocs/supplier_proposal/class/api_supplier_proposals.class.php @@ -30,164 +30,164 @@ require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class class Supplierproposals extends DolibarrApi { - /** - * @var array $FIELDS Mandatory fields, checked when create and update object - */ - static $FIELDS = array( - 'socid' - ); + /** + * @var array $FIELDS Mandatory fields, checked when create and update object + */ + static $FIELDS = array( + 'socid' + ); - /** - * @var SupplierProposal $supplier_proposal {@type SupplierProposal} - */ - public $supplier_proposal; + /** + * @var SupplierProposal $supplier_proposal {@type SupplierProposal} + */ + public $supplier_proposal; - /** - * Constructor - */ - function __construct() - { - global $db, $conf; - $this->db = $db; - $this->supplier_proposal = new SupplierProposal($this->db); - } - - /** - * Get properties of a supplier proposal (price request) object - * - * Return an array with supplier proposal informations - * - * @param int $id ID of supplier proposal - * @return array|mixed data without useless information - * - * @throws RestException - */ - function get($id) - { - if(! DolibarrApiAccess::$user->rights->supplier_proposal->lire) { - throw new RestException(401); - } - - $result = $this->supplier_proposal->fetch($id); - if( ! $result ) { - throw new RestException(404, 'Supplier Proposal not found'); - } - - if( ! DolibarrApi::_checkAccessToResource('supplier_proposal', $this->propal->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } - - $this->supplier_proposal->fetchObjectLinked(); - return $this->_cleanObjectDatas($this->supplier_proposal); - } - - /** - * List supplier proposals - * - * Get a list of supplier proposals - * - * @param string $sortfield Sort field - * @param string $sortorder Sort order - * @param int $limit Limit for list - * @param int $page Page number - * @param string $thirdparty_ids Thirdparty ids to filter supplier proposals. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} - * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" - * @return array Array of order objects - */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + /** + * Constructor + */ + public function __construct() { - global $db, $conf; + global $db, $conf; + $this->db = $db; + $this->supplier_proposal = new SupplierProposal($this->db); + } - $obj_ret = array(); + /** + * Get properties of a supplier proposal (price request) object + * + * Return an array with supplier proposal informations + * + * @param int $id ID of supplier proposal + * @return array|mixed data without useless information + * + * @throws RestException + */ + public function get($id) + { + if(! DolibarrApiAccess::$user->rights->supplier_proposal->lire) { + throw new RestException(401); + } - // case of external user, $thirdparty_ids param is ignored and replaced by user's socid - $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; + $result = $this->supplier_proposal->fetch($id); + if( ! $result ) { + throw new RestException(404, 'Supplier Proposal not found'); + } - // If the internal user must only see his customers, force searching by him - $search_sale = 0; - if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; + if( ! DolibarrApi::_checkAccessToResource('supplier_proposal', $this->propal->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } - $sql = "SELECT t.rowid"; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) - $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t"; + $this->supplier_proposal->fetchObjectLinked(); + return $this->_cleanObjectDatas($this->supplier_proposal); + } - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + /** + * List supplier proposals + * + * Get a list of supplier proposals + * + * @param string $sortfield Sort field + * @param string $sortorder Sort order + * @param int $limit Limit for list + * @param int $page Page number + * @param string $thirdparty_ids Thirdparty ids to filter supplier proposals. {@example '1' or '1,2,3'} {@pattern /^[0-9,]*$/i} + * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.datec:<:'20160101')" + * @return array Array of order objects + */ + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $thirdparty_ids = '', $sqlfilters = '') + { + global $db, $conf; - $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; - if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; - if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; - if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale - // Insert sale filter - if ($search_sale > 0) - { - $sql .= " AND sc.fk_user = ".$search_sale; - } - // Add sql filters - if ($sqlfilters) - { - if (! DolibarrApi::_checkFilters($sqlfilters)) - { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; - } + $obj_ret = array(); - $sql.= $db->order($sortfield, $sortorder); - if ($limit) { - if ($page < 0) - { - $page = 0; - } - $offset = $limit * $page; + // case of external user, $thirdparty_ids param is ignored and replaced by user's socid + $socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids; - $sql.= $db->plimit($limit + 1, $offset); - } + // If the internal user must only see his customers, force searching by him + $search_sale = 0; + if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id; - $result = $db->query($sql); + $sql = "SELECT t.rowid"; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects) + $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as t"; - if ($result) - { - $num = $db->num_rows($result); - $min = min($num, ($limit <= 0 ? $num : $limit)); - $i=0; - while ($i < $min) - { - $obj = $db->fetch_object($result); - $propal_static = new SupplierProposal($db); - if($propal_static->fetch($obj->rowid)) { - $obj_ret[] = $this->_cleanObjectDatas($propal_static); - } - $i++; - } - } - else { - throw new RestException(503, 'Error when retrieving supplier proposal list : '.$db->lasterror()); - } - if( ! count($obj_ret)) { - throw new RestException(404, 'No supplier proposal found'); - } - return $obj_ret; - } + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale + + $sql.= ' WHERE t.entity IN ('.getEntity('propal').')'; + if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= " AND t.fk_soc = sc.fk_soc"; + if ($socids) $sql.= " AND t.fk_soc IN (".$socids.")"; + if ($search_sale > 0) $sql.= " AND t.rowid = sc.fk_soc"; // Join for the needed table to filter by sale + // Insert sale filter + if ($search_sale > 0) + { + $sql .= " AND sc.fk_user = ".$search_sale; + } + // Add sql filters + if ($sqlfilters) + { + if (! DolibarrApi::_checkFilters($sqlfilters)) + { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + } + + $sql.= $db->order($sortfield, $sortorder); + if ($limit) { + if ($page < 0) + { + $page = 0; + } + $offset = $limit * $page; + + $sql.= $db->plimit($limit + 1, $offset); + } + + $result = $db->query($sql); + + if ($result) + { + $num = $db->num_rows($result); + $min = min($num, ($limit <= 0 ? $num : $limit)); + $i=0; + while ($i < $min) + { + $obj = $db->fetch_object($result); + $propal_static = new SupplierProposal($db); + if($propal_static->fetch($obj->rowid)) { + $obj_ret[] = $this->_cleanObjectDatas($propal_static); + } + $i++; + } + } + else { + throw new RestException(503, 'Error when retrieving supplier proposal list : '.$db->lasterror()); + } + if( ! count($obj_ret)) { + throw new RestException(404, 'No supplier proposal found'); + } + return $obj_ret; + } - /** - * Validate fields before create or update object - * - * @param array $data Array with data to verify - * @return array - * @throws RestException - */ - function _validate($data) - { - $propal = array(); - foreach (SupplierProposals::$FIELDS as $field) { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $propal[$field] = $data[$field]; - } - return $propal; - } + /** + * Validate fields before create or update object + * + * @param array $data Array with data to verify + * @return array + * @throws RestException + */ + private function _validate($data) + { + $propal = array(); + foreach (SupplierProposals::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $propal[$field] = $data[$field]; + } + return $propal; + } /** @@ -196,7 +196,7 @@ class Supplierproposals extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { $object = parent::_cleanObjectDatas($object); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 5e01c29c1fc..24ce18bf676 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -47,23 +47,23 @@ require_once DOL_DOCUMENT_ROOT .'/multicurrency/class/multicurrency.class.php'; class SupplierProposal extends CommonObject { /** - * @var string ID to identify managed object - */ - public $element='supplier_proposal'; + * @var string ID to identify managed object + */ + public $element='supplier_proposal'; /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='supplier_proposal'; + * @var string Name of table without prefix where object is stored + */ + public $table_element='supplier_proposal'; /** - * @var int Name of subtable line - */ - public $table_element_line='supplier_proposaldet'; + * @var int Name of subtable line + */ + public $table_element_line='supplier_proposaldet'; - /** - * @var int Field with ID of parent key if this field has a parent - */ + /** + * @var int Field with ID of parent key if this field has a parent + */ public $fk_element='fk_supplier_proposal'; public $picto='propal'; @@ -87,10 +87,10 @@ class SupplierProposal extends CommonObject public $socid; // Id client - /** - * @deprecated - * @see user_author_id - */ + /** + * @deprecated + * @see user_author_id + */ public $author; public $ref_fourn; //Reference saisie lors de l'ajout d'une ligne à la demande @@ -99,51 +99,51 @@ class SupplierProposal extends CommonObject public $date; // Date of proposal public $date_livraison; - /** - * @deprecated - * @see date_creation - */ - public $datec; + /** + * @deprecated + * @see date_creation + */ + public $datec; - /** - * Creation date - * @var int - */ - public $date_creation; + /** + * Creation date + * @var int + */ + public $date_creation; - /** - * @deprecated - * @see date_validation - */ - public $datev; + /** + * @deprecated + * @see date_validation + */ + public $datev; - /** - * Validation date - * @var int - */ - public $date_validation; + /** + * Validation date + * @var int + */ + public $date_validation; public $user_author_id; public $user_valid_id; public $user_close_id; - /** - * @deprecated - * @see price_ht - */ + /** + * @deprecated + * @see price_ht + */ public $price; - /** - * @deprecated - * @see total_tva - */ + /** + * @deprecated + * @see total_tva + */ public $tva; - /** - * @deprecated - * @see total_ttc - */ + /** + * @deprecated + * @see total_ttc + */ public $total; public $cond_reglement_code; @@ -166,42 +166,42 @@ class SupplierProposal extends CommonObject public $specimen; - // Multicurrency - /** + // Multicurrency + /** * @var int ID */ - public $fk_multicurrency; + public $fk_multicurrency; - public $multicurrency_code; - public $multicurrency_tx; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; + public $multicurrency_code; + public $multicurrency_tx; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; - /** - * Draft status - */ - const STATUS_DRAFT = 0; + /** + * Draft status + */ + const STATUS_DRAFT = 0; - /** - * Validated status - */ - const STATUS_VALIDATED = 1; + /** + * Validated status + */ + const STATUS_VALIDATED = 1; - /** - * Signed quote - */ - const STATUS_SIGNED = 2; + /** + * Signed quote + */ + const STATUS_SIGNED = 2; - /** - * Not signed quote, canceled - */ - const STATUS_NOTSIGNED = 3; + /** + * Not signed quote, canceled + */ + const STATUS_NOTSIGNED = 3; - /** - * Billed or closed/processed quote - */ - const STATUS_CLOSE = 4; + /** + * Billed or closed/processed quote + */ + const STATUS_CLOSE = 4; @@ -212,7 +212,7 @@ class SupplierProposal extends CommonObject * @param int $socid Id third party * @param int $supplier_proposalid Id supplier_proposal */ - function __construct($db, $socid = "", $supplier_proposalid = 0) + public function __construct($db, $socid = "", $supplier_proposalid = 0) { global $conf,$langs; @@ -225,7 +225,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add line into array products * $this->client doit etre charge @@ -238,7 +238,7 @@ class SupplierProposal extends CommonObject * TODO Remplacer les appels a cette fonction par generation objet Ligne * insere dans tableau $this->products */ - function add_product($idproduct, $qty, $remise_percent = 0) + public function add_product($idproduct, $qty, $remise_percent = 0) { // phpcs:enable global $conf, $mysoc; @@ -282,14 +282,14 @@ class SupplierProposal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Adding line of fixed discount in the proposal in DB * * @param int $idremise Id of fixed discount * @return int >0 if OK, <0 if KO */ - function insert_discount($idremise) + public function insert_discount($idremise) { // phpcs:enable global $langs; @@ -386,18 +386,18 @@ class SupplierProposal extends CommonObject * @param int $pa_ht Buying price without tax * @param string $label ??? * @param array $array_option extrafields array - * @param string $ref_supplier Supplier price reference - * @param int $fk_unit Id of the unit to use. - * @param string $origin 'order', 'supplier_proposal', ... - * @param int $origin_id Id of origin line + * @param string $ref_supplier Supplier price reference + * @param int $fk_unit Id of the unit to use. + * @param string $origin 'order', 'supplier_proposal', ... + * @param int $origin_id Id of origin line * @param double $pu_ht_devise Amount in currency * @return int >0 if OK, <0 if KO * * @see add_product */ - function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0) + public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $pu_ttc = 0, $info_bits = 0, $type = 0, $rang = -1, $special_code = 0, $fk_parent_line = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $array_option = 0, $ref_supplier = '', $fk_unit = '', $origin = '', $origin_id = 0, $pu_ht_devise = 0) { - global $mysoc, $conf; + global $mysoc, $conf; dol_syslog(get_class($this)."::addline supplier_proposalid=$this->id, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, fk_product=$fk_product, remise_except=$remise_percent, price_base_type=$price_base_type, pu_ttc=$pu_ttc, info_bits=$info_bits, type=$type"); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; @@ -417,7 +417,7 @@ class SupplierProposal extends CommonObject $txtva=price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - $pa_ht=price2num($pa_ht); + $pa_ht=price2num($pa_ht); if ($price_base_type=='HT') { $pu=$pu_ht; @@ -436,65 +436,65 @@ class SupplierProposal extends CommonObject if ($fk_product > 0) { - if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) - { - // Check quantity is enough - dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_fournprice=".$fk_fournprice." qty=".$qty." ref_supplier=".$ref_supplier); - $prod = new Product($this->db, $fk_product); - if ($prod->fetch($fk_product) > 0) - { - $product_type = $prod->type; - $label = $prod->label; - $fk_prod_fourn_price = $fk_fournprice; + if (! empty($conf->global->SUPPLIER_PROPOSAL_WITH_PREDEFINED_PRICES_ONLY)) + { + // Check quantity is enough + dol_syslog(get_class($this)."::addline we check supplier prices fk_product=".$fk_product." fk_fournprice=".$fk_fournprice." qty=".$qty." ref_supplier=".$ref_supplier); + $prod = new Product($this->db, $fk_product); + if ($prod->fetch($fk_product) > 0) + { + $product_type = $prod->type; + $label = $prod->label; + $fk_prod_fourn_price = $fk_fournprice; - // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. - // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. - $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc - if ($result > 0) - { - $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice - $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice - // is remise percent not keyed but present for the product we add it - if ($remise_percent == 0 && $prod->remise_percent !=0) - $remise_percent =$prod->remise_percent; - } - if ($result == 0) // If result == 0, we failed to found the supplier reference price - { - $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); - $this->db->rollback(); - dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); - //$pu = $prod->fourn_pu; // We do not overwrite unit price - //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price - return -1; - } - if ($result == -1) - { - $langs->load("errors"); - $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); - $this->db->rollback(); - dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); - return -1; - } - if ($result < -1) - { - $this->error=$prod->error; - $this->db->rollback(); - dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); - return -1; - } - } - else - { - $this->error=$prod->error; - $this->db->rollback(); - return -1; - } - } + // We use 'none' instead of $ref_supplier, because fourn_ref may not exists anymore. So we will take the first supplier price ok. + // If we want a dedicated supplier price, we must provide $fk_prod_fourn_price. + $result=$prod->get_buyprice($fk_prod_fourn_price, $qty, $fk_product, 'none', ($this->fk_soc?$this->fk_soc:$this->socid)); // Search on couple $fk_prod_fourn_price/$qty first, then on triplet $qty/$fk_product/$ref_supplier/$this->fk_soc + if ($result > 0) + { + $pu = $prod->fourn_pu; // Unit price supplier price set by get_buyprice + $ref_supplier = $prod->ref_supplier; // Ref supplier price set by get_buyprice + // is remise percent not keyed but present for the product we add it + if ($remise_percent == 0 && $prod->remise_percent !=0) + $remise_percent =$prod->remise_percent; + } + if ($result == 0) // If result == 0, we failed to found the supplier reference price + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline we did not found supplier price, so we can't guess unit price"); + //$pu = $prod->fourn_pu; // We do not overwrite unit price + //$ref = $prod->ref_fourn; // We do not overwrite ref supplier price + return -1; + } + if ($result == -1) + { + $langs->load("errors"); + $this->error = "Ref " . $prod->ref . " " . $langs->trans("ErrorQtyTooLowForThisSupplier"); + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_DEBUG); + return -1; + } + if ($result < -1) + { + $this->error=$prod->error; + $this->db->rollback(); + dol_syslog(get_class($this)."::addline result=".$result." - ".$this->error, LOG_ERR); + return -1; + } + } + else + { + $this->error=$prod->error; + $this->db->rollback(); + return -1; + } + } } else { - $product_type = $type; + $product_type = $type; } // Calcul du total TTC et de la TVA pour la ligne a partir de @@ -517,8 +517,8 @@ class SupplierProposal extends CommonObject $total_localtax2 = $tabprice[10]; $pu = $pu_ht = $tabprice[3]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; $pu_ht_devise = $tabprice[19]; @@ -552,7 +552,7 @@ class SupplierProposal extends CommonObject $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->localtax2_type = $localtaxes_type[2]; $this->line->fk_product=$fk_product; $this->line->remise_percent=$remise_percent; $this->line->subprice=$pu_ht; @@ -569,25 +569,25 @@ class SupplierProposal extends CommonObject $this->line->fk_unit=$fk_unit; $this->line->origin=$origin; $this->line->origin_id=$origin_id; - $this->line->ref_fourn = $this->db->escape($ref_supplier); + $this->line->ref_fourn = $this->db->escape($ref_supplier); - // infos marge - if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { - // by external module, take lowest buying price - include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } - $this->line->pa_ht = $pa_ht; + // infos marge + if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { + // by external module, take lowest buying price + include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } + $this->line->pa_ht = $pa_ht; - // Multicurrency - $this->line->fk_multicurrency = $this->fk_multicurrency; - $this->line->multicurrency_code = $this->multicurrency_code; + // Multicurrency + $this->line->fk_multicurrency = $this->fk_multicurrency; + $this->line->multicurrency_code = $this->multicurrency_code; $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; + $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -599,7 +599,7 @@ class SupplierProposal extends CommonObject $this->line->remise=$remise; if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + $this->line->array_options=$array_option; } $result=$this->line->insert(); @@ -652,12 +652,12 @@ class SupplierProposal extends CommonObject * @param int $pa_ht Price (without tax) of product when it was bought * @param string $label ??? * @param int $type 0/1=Product/service - * @param array $array_option extrafields array - * @param string $ref_supplier Supplier price reference - * @param int $fk_unit Id of the unit to use. + * @param array $array_option extrafields array + * @param string $ref_supplier Supplier price reference + * @param int $fk_unit Id of the unit to use. * @return int 0 if OK, <0 if KO */ - function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_option = 0, $ref_supplier = '', $fk_unit = '') + public function updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $desc = '', $price_base_type = 'HT', $info_bits = 0, $special_code = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = 0, $pa_ht = 0, $label = '', $type = 0, $array_option = 0, $ref_supplier = '', $fk_unit = '') { global $conf,$user,$langs, $mysoc; @@ -671,7 +671,7 @@ class SupplierProposal extends CommonObject $txtva = price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - $pa_ht=price2num($pa_ht); + $pa_ht=price2num($pa_ht); if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag @@ -694,8 +694,8 @@ class SupplierProposal extends CommonObject $total_localtax1 = $tabprice[9]; $total_localtax2 = $tabprice[10]; - // MultiCurrency - $multicurrency_total_ht = $tabprice[16]; + // MultiCurrency + $multicurrency_total_ht = $tabprice[16]; $multicurrency_total_tva = $tabprice[17]; $multicurrency_total_ttc = $tabprice[18]; @@ -730,8 +730,8 @@ class SupplierProposal extends CommonObject $this->line->tva_tx = $txtva; $this->line->localtax1_tx = $txlocaltax1; $this->line->localtax2_tx = $txlocaltax2; - $this->line->localtax1_type = $localtaxes_type[0]; - $this->line->localtax2_type = $localtaxes_type[2]; + $this->line->localtax1_type = $localtaxes_type[0]; + $this->line->localtax2_type = $localtaxes_type[2]; $this->line->remise_percent = $remise_percent; $this->line->subprice = $pu; $this->line->info_bits = $info_bits; @@ -744,18 +744,18 @@ class SupplierProposal extends CommonObject $this->line->fk_parent_line = $fk_parent_line; $this->line->skip_update_total = $skip_update_total; $this->line->ref_fourn = $ref_supplier; - $this->line->fk_unit = $fk_unit; + $this->line->fk_unit = $fk_unit; // infos marge if (!empty($fk_product) && empty($fk_fournprice) && empty($pa_ht)) { // by external module, take lowest buying price include_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; - $productFournisseur = new ProductFournisseur($this->db); - $productFournisseur->find_min_price_product_fournisseur($fk_product); - $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; - } else { - $this->line->fk_fournprice = $fk_fournprice; - } + $productFournisseur = new ProductFournisseur($this->db); + $productFournisseur->find_min_price_product_fournisseur($fk_product); + $this->line->fk_fournprice = $productFournisseur->product_fourn_price_id; + } else { + $this->line->fk_fournprice = $fk_fournprice; + } $this->line->pa_ht = $pa_ht; // TODO deprecated @@ -763,12 +763,12 @@ class SupplierProposal extends CommonObject $this->line->remise=$remise; if (is_array($array_option) && count($array_option)>0) { - $this->line->array_options=$array_option; + $this->line->array_options=$array_option; } - // Multicurrency - $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); - $this->line->multicurrency_total_ht = $multicurrency_total_ht; + // Multicurrency + $this->line->multicurrency_subprice = price2num($pu * $this->multicurrency_tx); + $this->line->multicurrency_total_ht = $multicurrency_total_ht; $this->line->multicurrency_total_tva = $multicurrency_total_tva; $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; @@ -807,7 +807,7 @@ class SupplierProposal extends CommonObject * @param int $lineid Id of line to delete * @return int >0 if OK, <0 if KO */ - function deleteline($lineid) + public function deleteline($lineid) { if ($this->statut == 0) { @@ -842,7 +842,7 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $langs, $conf, $mysoc, $hookmanager; $error=0; @@ -861,26 +861,26 @@ class SupplierProposal extends CommonObject } // Check parameters - if (! empty($this->ref)) // We check that ref is not already used - { - $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used - if ($result > 0) - { - $this->error='ErrorRefAlreadyExists'; - dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); - $this->db->rollback(); - return -1; - } - } + if (! empty($this->ref)) // We check that ref is not already used + { + $result=self::isExistingObject($this->element, 0, $this->ref); // Check ref is not yet used + if ($result > 0) + { + $this->error='ErrorRefAlreadyExists'; + dol_syslog(get_class($this)."::create ".$this->error, LOG_WARNING); + $this->db->rollback(); + return -1; + } + } - // Multicurrency - if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); - if (empty($this->fk_multicurrency)) - { - $this->multicurrency_code = $conf->currency; - $this->fk_multicurrency = 0; - $this->multicurrency_tx = 1; - } + // Multicurrency + if (!empty($this->multicurrency_code)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code); + if (empty($this->fk_multicurrency)) + { + $this->multicurrency_code = $conf->currency; + $this->fk_multicurrency = 0; + $this->multicurrency_tx = 1; + } $this->db->begin(); @@ -931,9 +931,9 @@ class SupplierProposal extends CommonObject $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL'); $sql.= ", ".($this->fk_project?$this->fk_project:"null"); $sql.= ", ".$conf->entity; - $sql.= ", ".(int) $this->fk_multicurrency; - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".(double) $this->multicurrency_tx; + $sql.= ", ".(int) $this->fk_multicurrency; + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".(double) $this->multicurrency_tx; $sql.= ")"; dol_syslog(get_class($this)."::create", LOG_DEBUG); @@ -953,34 +953,34 @@ class SupplierProposal extends CommonObject if (! empty($this->linkedObjectsIds) && empty($this->linked_objects)) // To use new linkedObjectsIds instead of old linked_objects { - $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds + $this->linked_objects = $this->linkedObjectsIds; // TODO Replace linked_objects with linkedObjectsIds } // Add object linked if (! $error && $this->id && is_array($this->linked_objects) && ! empty($this->linked_objects)) { - foreach($this->linked_objects as $origin => $tmp_origin_id) - { - if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) - { - foreach($tmp_origin_id as $origin_id) - { - $ret = $this->add_object_linked($origin, $origin_id); - if (! $ret) - { - dol_print_error($this->db); - $error++; - } - } - } - } + foreach($this->linked_objects as $origin => $tmp_origin_id) + { + if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...)) + { + foreach($tmp_origin_id as $origin_id) + { + $ret = $this->add_object_linked($origin, $origin_id); + if (! $ret) + { + dol_print_error($this->db); + $error++; + } + } + } + } } // Add linked object (deprecated, use ->linkedObjectsIds instead) if (! $error && $this->origin && $this->origin_id) { - $ret = $this->add_object_linked(); - if (! $ret) dol_print_error($this->db); + $ret = $this->add_object_linked(); + if (! $ret) dol_print_error($this->db); } /* @@ -998,31 +998,31 @@ class SupplierProposal extends CommonObject $fk_parent_line = 0; } - $result = $this->addline( - $this->lines[$i]->desc, - $this->lines[$i]->subprice, - $this->lines[$i]->qty, - $this->lines[$i]->tva_tx, - $this->lines[$i]->localtax1_tx, - $this->lines[$i]->localtax2_tx, - $this->lines[$i]->fk_product, - $this->lines[$i]->remise_percent, - 'HT', - 0, - 0, - $this->lines[$i]->product_type, - $this->lines[$i]->rang, - $this->lines[$i]->special_code, - $fk_parent_line, - $this->lines[$i]->fk_fournprice, - $this->lines[$i]->pa_ht, - $this->lines[$i]->label, - $this->lines[$i]->array_options, - $this->lines[$i]->ref_fourn, - $this->lines[$i]->fk_unit, - 'supplier_proposal', - $this->lines[$i]->rowid - ); + $result = $this->addline( + $this->lines[$i]->desc, + $this->lines[$i]->subprice, + $this->lines[$i]->qty, + $this->lines[$i]->tva_tx, + $this->lines[$i]->localtax1_tx, + $this->lines[$i]->localtax2_tx, + $this->lines[$i]->fk_product, + $this->lines[$i]->remise_percent, + 'HT', + 0, + 0, + $this->lines[$i]->product_type, + $this->lines[$i]->rang, + $this->lines[$i]->special_code, + $fk_parent_line, + $this->lines[$i]->fk_fournprice, + $this->lines[$i]->pa_ht, + $this->lines[$i]->label, + $this->lines[$i]->array_options, + $this->lines[$i]->ref_fourn, + $this->lines[$i]->fk_unit, + 'supplier_proposal', + $this->lines[$i]->rowid + ); if ($result < 0) { @@ -1044,17 +1044,17 @@ class SupplierProposal extends CommonObject $resql=$this->update_price(1); if ($resql) { - $action='update'; + $action='update'; - // Actions on extra fields - if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + // Actions on extra fields + if (! $error && empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (! $error && ! $notrigger) { @@ -1065,14 +1065,14 @@ class SupplierProposal extends CommonObject } } else - { + { $this->error=$this->db->lasterror(); $error++; } } } else - { + { $this->error=$this->db->lasterror(); $error++; } @@ -1098,7 +1098,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Insert into DB a supplier_proposal object completely defined by its data members (ex, results from copy). * @@ -1106,7 +1106,7 @@ class SupplierProposal extends CommonObject * @return int Id of the new object if ok, <0 if ko * @see create */ - function create_from($user) + public function create_from($user) { // phpcs:enable $this->products=$this->lines; @@ -1120,7 +1120,7 @@ class SupplierProposal extends CommonObject * @param int $socid Id of thirdparty * @return int New id of clone */ - function createFromClone($socid = 0) + public function createFromClone($socid = 0) { global $user,$langs,$conf,$hookmanager; @@ -1129,12 +1129,12 @@ class SupplierProposal extends CommonObject $this->db->begin(); - // get extrafields so they will be clone - foreach($this->lines as $line) - $line->fetch_optionals(); + // get extrafields so they will be clone + foreach($this->lines as $line) + $line->fetch_optionals(); - // Load source object - $objFrom = clone $this; + // Load source object + $objFrom = clone $this; $objsoc=new Societe($this->db); @@ -1215,7 +1215,7 @@ class SupplierProposal extends CommonObject * @param string $ref Ref of proposal * @return int >0 if OK, <0 if KO */ - function fetch($rowid, $ref = '') + public function fetch($rowid, $ref = '') { global $conf; @@ -1232,7 +1232,7 @@ class SupplierProposal extends CommonObject $sql.= ", p.fk_mode_reglement"; $sql.= ', p.fk_account'; $sql.= ", p.fk_shipping_method"; - $sql.= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc"; + $sql.= ", p.fk_multicurrency, p.multicurrency_code, p.multicurrency_tx, p.multicurrency_total_ht, p.multicurrency_total_tva, p.multicurrency_total_ttc"; $sql.= ", c.label as statut_label"; $sql.= ", cr.code as cond_reglement_code, cr.libelle as cond_reglement, cr.libelle_facture as cond_reglement_libelle_doc"; $sql.= ", cp.code as mode_reglement_code, cp.libelle as mode_reglement"; @@ -1295,13 +1295,13 @@ class SupplierProposal extends CommonObject $this->user_valid_id = $obj->fk_user_valid; $this->user_close_id = $obj->fk_user_cloture; - // Multicurrency - $this->fk_multicurrency = $obj->fk_multicurrency; - $this->multicurrency_code = $obj->multicurrency_code; - $this->multicurrency_tx = $obj->multicurrency_tx; - $this->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + // Multicurrency + $this->fk_multicurrency = $obj->fk_multicurrency; + $this->multicurrency_code = $obj->multicurrency_code; + $this->multicurrency_tx = $obj->multicurrency_tx; + $this->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->multicurrency_total_ttc = $obj->multicurrency_total_ttc; if ($obj->fk_statut == 0) { @@ -1318,10 +1318,10 @@ class SupplierProposal extends CommonObject // Lines of supplier proposals $sql = "SELECT d.rowid, d.fk_supplier_proposal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,"; - $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; + $sql.= " d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,"; $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; $sql.= ' d.ref_fourn as ref_produit_fourn,'; - $sql.= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc, d.fk_unit'; + $sql.= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc, d.fk_unit'; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposaldet as d"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON d.fk_product = p.rowid"; $sql.= " WHERE d.fk_supplier_proposal = ".$this->id; @@ -1361,11 +1361,11 @@ class SupplierProposal extends CommonObject $line->total_localtax1 = $objp->total_localtax1; $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; - $line->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); - $line->pa_ht = $marginInfos[0]; - $line->marge_tx = $marginInfos[1]; - $line->marque_tx = $marginInfos[2]; + $line->fk_fournprice = $objp->fk_fournprice; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; $line->special_code = $objp->special_code; $line->rang = $objp->rang; @@ -1378,16 +1378,16 @@ class SupplierProposal extends CommonObject $line->product_desc = $objp->product_desc; // Description produit $line->fk_product_type = $objp->fk_product_type; - $line->ref_fourn = $objp->ref_produit_fourn; + $line->ref_fourn = $objp->ref_produit_fourn; - // Multicurrency - $line->fk_multicurrency = $objp->fk_multicurrency; - $line->multicurrency_code = $objp->multicurrency_code; - $line->multicurrency_subprice = $objp->multicurrency_subprice; - $line->multicurrency_total_ht = $objp->multicurrency_total_ht; - $line->multicurrency_total_tva = $objp->multicurrency_total_tva; - $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $line->fk_unit = $objp->fk_unit; + // Multicurrency + $line->fk_multicurrency = $objp->fk_multicurrency; + $line->multicurrency_code = $objp->multicurrency_code; + $line->multicurrency_subprice = $objp->multicurrency_subprice; + $line->multicurrency_total_ht = $objp->multicurrency_total_ht; + $line->multicurrency_total_tva = $objp->multicurrency_total_tva; + $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $line->fk_unit = $objp->fk_unit; $this->lines[$i] = $line; @@ -1425,17 +1425,17 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >=0 if OK */ - function valid($user, $notrigger = 0) + public function valid($user, $notrigger = 0) { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - global $conf,$langs; + global $conf,$langs; $error=0; $now=dol_now(); if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->creer)) - || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->supplier_proposal->validate_advance))) { $this->db->begin(); @@ -1446,11 +1446,11 @@ class SupplierProposal extends CommonObject // Define new ref if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) // empty should not happened, but when it occurs, the test save life { - $num = $this->getNextNumRef($soc); + $num = $this->getNextNumRef($soc); } else { - $num = $this->ref; + $num = $this->ref; } $this->newref = $num; @@ -1460,16 +1460,16 @@ class SupplierProposal extends CommonObject $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; dol_syslog(get_class($this)."::valid", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - dol_print_error($this->db); - $error++; - } + $resql=$this->db->query($sql); + if (! $resql) + { + dol_print_error($this->db); + $error++; + } - // Trigger calls - if (! $error && ! $notrigger) - { + // Trigger calls + if (! $error && ! $notrigger) + { // Call trigger $result=$this->call_trigger('SUPPLIER_PROPOSAL_VALIDATE', $user); if ($result < 0) { $error++; } @@ -1478,61 +1478,61 @@ class SupplierProposal extends CommonObject if (! $error) { - $this->oldref = $this->ref; + $this->oldref = $this->ref; - // Rename directory if dir was a temporary ref - if (preg_match('/^[\(]?PROV/i', $this->ref)) - { - // Rename of propal directory ($this->ref = old ref, $num = new ref) - // to not lose the linked files - $oldref = dol_sanitizeFileName($this->ref); - $newref = dol_sanitizeFileName($num); - $dirsource = $conf->supplier_proposal->dir_output.'/'.$oldref; - $dirdest = $conf->supplier_proposal->dir_output.'/'.$newref; + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) + { + // Rename of propal directory ($this->ref = old ref, $num = new ref) + // to not lose the linked files + $oldref = dol_sanitizeFileName($this->ref); + $newref = dol_sanitizeFileName($num); + $dirsource = $conf->supplier_proposal->dir_output.'/'.$oldref; + $dirdest = $conf->supplier_proposal->dir_output.'/'.$newref; - if (file_exists($dirsource)) - { - dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); - if (@rename($dirsource, $dirdest)) - { - dol_syslog("Rename ok"); - // Rename docs starting with $oldref with $newref - $listoffiles=dol_dir_list($conf->supplier_proposal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); - foreach($listoffiles as $fileentry) - { - $dirsource=$fileentry['name']; - $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); - $dirsource=$fileentry['path'].'/'.$dirsource; - $dirdest=$fileentry['path'].'/'.$dirdest; - @rename($dirsource, $dirdest); - } - } - } - } + if (file_exists($dirsource)) + { + dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest); + if (@rename($dirsource, $dirdest)) + { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $listoffiles=dol_dir_list($conf->supplier_proposal->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + foreach($listoffiles as $fileentry) + { + $dirsource=$fileentry['name']; + $dirdest=preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); + $dirsource=$fileentry['path'].'/'.$dirsource; + $dirdest=$fileentry['path'].'/'.$dirdest; + @rename($dirsource, $dirdest); + } + } + } + } - $this->ref=$num; - $this->brouillon=0; - $this->statut = 1; - $this->user_valid_id=$user->id; - $this->datev=$now; + $this->ref=$num; + $this->brouillon=0; + $this->statut = 1; + $this->user_valid_id=$user->id; + $this->datev=$now; - $this->db->commit(); - return 1; + $this->db->commit(); + return 1; } else - { - $this->db->rollback(); - return -1; + { + $this->db->rollback(); + return -1; } } else { - dol_syslog("You don't have permission to validate supplier proposal", LOG_WARNING); - return -2; + dol_syslog("You don't have permission to validate supplier proposal", LOG_WARNING); + return -2; } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set delivery date * @@ -1540,7 +1540,7 @@ class SupplierProposal extends CommonObject * @param int $date_livraison Delivery date * @return int <0 if ko, >0 if ok */ - function set_date_livraison($user, $date_livraison) + public function set_date_livraison($user, $date_livraison) { // phpcs:enable if (! empty($user->rights->supplier_proposal->creer)) @@ -1563,7 +1563,7 @@ class SupplierProposal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an overall discount on the proposal * @@ -1571,7 +1571,7 @@ class SupplierProposal extends CommonObject * @param double $remise Amount discount * @return int <0 if ko, >0 if ok */ - function set_remise_percent($user, $remise) + public function set_remise_percent($user, $remise) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -1598,7 +1598,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set an absolute overall discount on the proposal * @@ -1606,7 +1606,7 @@ class SupplierProposal extends CommonObject * @param double $remise Amount discount * @return int <0 if ko, >0 if ok */ - function set_remise_absolue($user, $remise) + public function set_remise_absolue($user, $remise) { // phpcs:enable $remise=trim($remise)?trim($remise):0; @@ -1644,7 +1644,7 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function reopen($user, $statut, $note = '', $notrigger = 0) + public function reopen($user, $statut, $note = '', $notrigger = 0) { global $langs,$conf; @@ -1653,47 +1653,47 @@ class SupplierProposal extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."supplier_proposal"; $sql.= " SET fk_statut = ".$this->statut.","; - if (! empty($note)) $sql.= " note_private = '".$this->db->escape($note)."',"; + if (! empty($note)) $sql.= " note_private = '".$this->db->escape($note)."',"; $sql.= " date_cloture=NULL, fk_user_cloture=NULL"; $sql.= " WHERE rowid = ".$this->id; - $this->db->begin(); + $this->db->begin(); - dol_syslog(get_class($this)."::reopen", LOG_DEBUG); - $resql = $this->db->query($sql); - if (! $resql) { - $error++; $this->errors[]="Error ".$this->db->lasterror(); - } - if (! $error) - { - if (! $notrigger) - { + dol_syslog(get_class($this)."::reopen", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { + $error++; $this->errors[]="Error ".$this->db->lasterror(); + } + if (! $error) + { + if (! $notrigger) + { // Call trigger $result=$this->call_trigger('SUPPLIER_PROPOSAL_REOPEN', $user); if ($result < 0) { $error++; } // End call triggers - } - } + } + } - // Commit or rollback - if ($error) - { - if (!empty($this->errors)) - { - foreach($this->errors as $errmsg) - { - dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); - $this->error.=($this->error?', '.$errmsg:$errmsg); - } - } - $this->db->rollback(); - return -1*$error; - } - else - { - $this->db->commit(); - return 1; - } + // Commit or rollback + if ($error) + { + if (!empty($this->errors)) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } } @@ -1705,7 +1705,7 @@ class SupplierProposal extends CommonObject * @param string $note Comment * @return int <0 if KO, >0 if OK */ - function cloture($user, $statut, $note) + public function cloture($user, $statut, $note) { global $langs,$conf; @@ -1722,13 +1722,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:$this->modelpdf; - $trigger_name='SUPPLIER_PROPOSAL_CLOSE_REFUSED'; + $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_CLOSED:$this->modelpdf; + $trigger_name='SUPPLIER_PROPOSAL_CLOSE_REFUSED'; if ($statut == 2) { - $trigger_name='SUPPLIER_PROPOSAL_CLOSE_SIGNED'; - $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL:$this->modelpdf; + $trigger_name='SUPPLIER_PROPOSAL_CLOSE_SIGNED'; + $modelpdf=$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL?$conf->global->SUPPLIER_PROPOSAL_ADDON_PDF_ODT_TOBILL:$this->modelpdf; 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 { @@ -1737,21 +1737,21 @@ class SupplierProposal extends CommonObject } if ($statut == 4) { - $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; + $trigger_name='SUPPLIER_PROPOSAL_CLASSIFY_BILLED'; } if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("", $conf); - $newlang=(GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); - $outputlangs->setDefaultLang($newlang); - } - //$ret=$object->fetch($id); // Reload to get new records - $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("", $conf); + $newlang=(GETPOST('lang_id', 'aZ09') ? GETPOST('lang_id', 'aZ09') : $this->thirdparty->default_lang); + $outputlangs->setDefaultLang($newlang); + } + //$ret=$object->fetch($id); // Reload to get new records + $this->generateDocument($modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); } // Call trigger @@ -1779,106 +1779,106 @@ class SupplierProposal extends CommonObject } } - /** + /** * Add or update supplier price according to result of proposal * - * @param User $user Object user - * @return int > 0 if OK + * @param User $user Object user + * @return int > 0 if OK */ - function updateOrCreatePriceFournisseur($user) - { - $productsupplier = new ProductFournisseur($this->db); + public function updateOrCreatePriceFournisseur($user) + { + $productsupplier = new ProductFournisseur($this->db); - dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); - foreach ($this->lines as $product) - { - if ($product->subprice <= 0) continue; + dol_syslog(get_class($this)."::updateOrCreatePriceFournisseur", LOG_DEBUG); + foreach ($this->lines as $product) + { + if ($product->subprice <= 0) continue; - $idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty); - $res = $productsupplier->fetch($idProductFourn); + $idProductFourn = $productsupplier->find_min_price_product_fournisseur($product->fk_product, $product->qty); + $res = $productsupplier->fetch($idProductFourn); - if ($productsupplier->id) { - if ($productsupplier->fourn_qty == $product->qty) { - $this->updatePriceFournisseur($productsupplier->product_fourn_price_id, $product, $user); - } else { - $this->createPriceFournisseur($product, $user); - } - } else { - $this->createPriceFournisseur($product, $user); - } - } + if ($productsupplier->id) { + if ($productsupplier->fourn_qty == $product->qty) { + $this->updatePriceFournisseur($productsupplier->product_fourn_price_id, $product, $user); + } else { + $this->createPriceFournisseur($product, $user); + } + } else { + $this->createPriceFournisseur($product, $user); + } + } - return 1; - } + return 1; + } - /** + /** * Upate ProductFournisseur * - * @param int $idProductFournPrice id of llx_product_fournisseur_price - * @param Product $product contain informations to update - * @param User $user Object user + * @param int $idProductFournPrice id of llx_product_fournisseur_price + * @param Product $product contain informations to update + * @param User $user Object user * @return int <0 if KO, >0 if OK */ - function updatePriceFournisseur($idProductFournPrice, $product, $user) + public function updatePriceFournisseur($idProductFournPrice, $product, $user) { - $price=price2num($product->subprice*$product->qty, 'MU'); - $unitPrice = price2num($product->subprice, 'MU'); + $price=price2num($product->subprice*$product->qty, 'MU'); + $unitPrice = price2num($product->subprice, 'MU'); - $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; + $sql = 'UPDATE '.MAIN_DB_PREFIX.'product_fournisseur_price SET '.(!empty($product->ref_fourn) ? 'ref_fourn = "'.$product->ref_fourn.'", ' : '').' price ='.$price.', unitprice ='.$unitPrice.' WHERE rowid = '.$idProductFournPrice; - $resql = $this->db->query($sql); - if (!$resql) { - $this->error=$this->db->error(); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error=$this->db->error(); $this->db->rollback(); return -1; - } - } + } + } - /** + /** * Create ProductFournisseur - * + * * @param Product $product Object Product - * @param User $user Object user + * @param User $user Object user * @return int <0 if KO, >0 if OK */ - function createPriceFournisseur($product, $user) + public function createPriceFournisseur($product, $user) { - $price=price2num($product->subprice*$product->qty, 'MU'); - $qty=price2num($product->qty); - $unitPrice = price2num($product->subprice, 'MU'); - $now=dol_now(); + $price=price2num($product->subprice*$product->qty, 'MU'); + $qty=price2num($product->qty); + $unitPrice = price2num($product->subprice, 'MU'); + $now=dol_now(); - $values = array( - "'".$this->db->idate($now)."'", - $product->fk_product, - $this->thirdparty->id, - "'".$product->ref_fourn."'", - $price, - $qty, - $unitPrice, - $product->tva_tx, - $user->id - ); + $values = array( + "'".$this->db->idate($now)."'", + $product->fk_product, + $this->thirdparty->id, + "'".$product->ref_fourn."'", + $price, + $qty, + $unitPrice, + $product->tva_tx, + $user->id + ); - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_fournisseur_price '; - $sql .= '(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user) VALUES ('.implode(',', $values).')'; + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'product_fournisseur_price '; + $sql .= '(datec, fk_product, fk_soc, ref_fourn, price, quantity, unitprice, tva_tx, fk_user) VALUES ('.implode(',', $values).')'; - $resql = $this->db->query($sql); - if (!$resql) { - $this->error=$this->db->error(); + $resql = $this->db->query($sql); + if (!$resql) { + $this->error=$this->db->error(); $this->db->rollback(); return -1; - } - } + } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set draft status * * @param User $user Object user that modify * @return int <0 if KO, >0 if OK */ - function set_draft($user) + public function set_draft($user) { // phpcs:enable global $conf,$langs; @@ -1899,7 +1899,7 @@ class SupplierProposal extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return list of askprice (eventually filtered on user) into an array * @@ -1913,7 +1913,7 @@ class SupplierProposal extends CommonObject * @param string $sortorder Sort order * @return int -1 if KO, array with result if OK */ - function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datec', $sortorder = 'DESC') + public function liste_array($shortlist = 0, $draft = 0, $notcurrentuser = 0, $socid = 0, $limit = 0, $offset = 0, $sortfield = 'p.datec', $sortorder = 'DESC') { // phpcs:enable global $conf,$user; @@ -1925,13 +1925,13 @@ class SupplierProposal extends CommonObject $sql.= " p.datep as dp, p.fin_validite as datelimite"; if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", sc.fk_soc, sc.fk_user"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."supplier_proposal as p, ".MAIN_DB_PREFIX."c_propalst as c"; - if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + if (! $user->rights->societe->client->voir && ! $socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.entity IN (".getEntity('supplier_proposal').")"; $sql.= " AND p.fk_soc = s.rowid"; $sql.= " AND p.fk_statut = c.id"; if (! $user->rights->societe->client->voir && ! $socid) //restriction { - $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; } if ($socid) $sql.= " AND s.rowid = ".$socid; if ($draft) $sql.= " AND p.fk_statut = 0"; @@ -1959,7 +1959,7 @@ class SupplierProposal extends CommonObject $ga[$obj->supplier_proposalid] = $obj->ref.' ('.$obj->name.')'; } else - { + { $ga[$i]['id'] = $obj->supplier_proposalid; $ga[$i]['ref'] = $obj->ref; $ga[$i]['name'] = $obj->name; @@ -1984,7 +1984,7 @@ class SupplierProposal extends CommonObject * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int 1 if ok, otherwise if error */ - function delete($user, $notrigger = 0) + public function delete($user, $notrigger = 0) { global $conf,$langs; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -2029,7 +2029,7 @@ class SupplierProposal extends CommonObject { $this->error='ErrorFailToDeleteFile'; $this->errors=array('ErrorFailToDeleteFile'); - $this->db->rollback(); + $this->db->rollback(); return 0; } } @@ -2050,16 +2050,16 @@ class SupplierProposal extends CommonObject // Removed extrafields if (! $error) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - $errorflag=-4; - dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); - } - } + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + $errorflag=-4; + dol_syslog(get_class($this)."::delete erreur ".$errorflag." ".$this->error, LOG_ERR); + } + } } if (! $error) @@ -2102,7 +2102,7 @@ class SupplierProposal extends CommonObject * @param int $id Proposal id * @return void */ - function info($id) + public function info($id) { $sql = "SELECT c.rowid, "; $sql.= " c.datec, c.date_valid as datev, c.date_cloture as dateo,"; @@ -2157,12 +2157,12 @@ class SupplierProposal extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return label of a status (draft, validated, ...) * @@ -2170,44 +2170,44 @@ class SupplierProposal extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function LibStatut($statut, $mode = 1) + public function LibStatut($statut, $mode = 1) { // phpcs:enable - // Init/load array of translation of status - if (empty($this->labelstatut) || empty($this->labelstatut_short)) - { - global $langs; - $langs->load("supplier_proposal"); - $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); - $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); - $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); - $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); - $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); - $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); - $this->labelstatut_short[1]=$langs->trans("Opened"); - $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); - $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); - $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); - } + // Init/load array of translation of status + if (empty($this->labelstatut) || empty($this->labelstatut_short)) + { + global $langs; + $langs->load("supplier_proposal"); + $this->labelstatut[0]=$langs->trans("SupplierProposalStatusDraft"); + $this->labelstatut[1]=$langs->trans("SupplierProposalStatusValidated"); + $this->labelstatut[2]=$langs->trans("SupplierProposalStatusSigned"); + $this->labelstatut[3]=$langs->trans("SupplierProposalStatusNotSigned"); + $this->labelstatut[4]=$langs->trans("SupplierProposalStatusClosed"); + $this->labelstatut_short[0]=$langs->trans("SupplierProposalStatusDraftShort"); + $this->labelstatut_short[1]=$langs->trans("Opened"); + $this->labelstatut_short[2]=$langs->trans("SupplierProposalStatusSignedShort"); + $this->labelstatut_short[3]=$langs->trans("SupplierProposalStatusNotSignedShort"); + $this->labelstatut_short[4]=$langs->trans("SupplierProposalStatusClosedShort"); + } - $statuttrans=''; - if ($statut==0) $statuttrans='statut0'; - elseif ($statut==1) $statuttrans='statut1'; - elseif ($statut==2) $statuttrans='statut3'; - elseif ($statut==3) $statuttrans='statut5'; - elseif ($statut==4) $statuttrans='statut6'; + $statuttrans=''; + if ($statut==0) $statuttrans='statut0'; + elseif ($statut==1) $statuttrans='statut1'; + elseif ($statut==2) $statuttrans='statut3'; + elseif ($statut==3) $statuttrans='statut5'; + elseif ($statut==4) $statuttrans='statut6'; - if ($mode == 0) return $this->labelstatut[$statut]; - elseif ($mode == 1) return $this->labelstatut_short[$statut]; - elseif ($mode == 2) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; - elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 4) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut[$statut]; - elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); - elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); - } + if ($mode == 0) return $this->labelstatut[$statut]; + elseif ($mode == 1) return $this->labelstatut_short[$statut]; + elseif ($mode == 2) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut_short[$statut]; + elseif ($mode == 3) return img_picto($this->labelstatut[$statut], $statuttrans); + elseif ($mode == 4) return img_picto($this->labelstatut[$statut], $statuttrans).' '.$this->labelstatut[$statut]; + elseif ($mode == 5) return ''.$this->labelstatut_short[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); + elseif ($mode == 6) return ''.$this->labelstatut[$statut].' '.img_picto($this->labelstatut[$statut], $statuttrans); + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * @@ -2215,7 +2215,7 @@ class SupplierProposal extends CommonObject * @param int $mode "opened" for askprice to close, "signed" for proposal to invoice * @return int <0 if KO, >0 if OK */ - function load_board($user, $mode) + public function load_board($user, $mode) { // phpcs:enable global $conf, $user, $langs; @@ -2242,21 +2242,21 @@ class SupplierProposal extends CommonObject if ($resql) { if ($mode == 'opened') { - $delay_warning=$conf->supplier_proposal->cloture->warning_delay; - $statut = self::STATUS_VALIDATED; - $label = $langs->trans("SupplierProposalsToClose"); + $delay_warning=$conf->supplier_proposal->cloture->warning_delay; + $statut = self::STATUS_VALIDATED; + $label = $langs->trans("SupplierProposalsToClose"); } if ($mode == 'signed') { - $delay_warning=$conf->supplier_proposal->facturation->warning_delay; - $statut = self::STATUS_SIGNED; - $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered + $delay_warning=$conf->supplier_proposal->facturation->warning_delay; + $statut = self::STATUS_SIGNED; + $label = $langs->trans("SupplierProposalsToProcess"); // May be billed or ordered } - $response = new WorkboardResponse(); - $response->warning_delay = $delay_warning/60/60/24; - $response->label = $label; - $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; - $response->img = img_object('', "propal"); + $response = new WorkboardResponse(); + $response->warning_delay = $delay_warning/60/60/24; + $response->label = $label; + $response->url = DOL_URL_ROOT.'/supplier_proposal/list.php?viewstatut='.$statut; + $response->img = img_object('', "propal"); // This assignment in condition is not a bug. It allows walking the results. while ($obj=$this->db->fetch_object($resql)) @@ -2290,7 +2290,7 @@ class SupplierProposal extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs,$conf; @@ -2355,8 +2355,8 @@ class SupplierProposal extends CommonObject if ($num_prods > 0) { - $prodid = mt_rand(1, $num_prods); - $line->fk_product=$prodids[$prodid]; + $prodid = mt_rand(1, $num_prods); + $line->fk_product=$prodids[$prodid]; } $this->lines[$xnbp]=$line; @@ -2369,13 +2369,13 @@ class SupplierProposal extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb de tableau de bord * * @return int <0 if ko, >0 if ok */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf, $user; @@ -2421,14 +2421,14 @@ class SupplierProposal extends CommonObject * @param Societe $soc Object thirdparty * @return string Reference libre pour la propale */ - function getNextNumRef($soc) + public function getNextNumRef($soc) { global $conf, $db, $langs; $langs->load("supplier_proposal"); if (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON)) { - $mybool=false; + $mybool=false; $file = $conf->global->SUPPLIER_PROPOSAL_ADDON.".php"; $classname = $conf->global->SUPPLIER_PROPOSAL_ADDON; @@ -2445,8 +2445,8 @@ class SupplierProposal extends CommonObject if (! $mybool) { - dol_print_error('', "Failed to include file ".$file); - return ''; + dol_print_error('', "Failed to include file ".$file); + return ''; } $obj = new $classname(); @@ -2458,13 +2458,13 @@ class SupplierProposal extends CommonObject return $numref; } else - { + { $this->error=$obj->error; return ""; } } else - { + { $langs->load("errors"); print $langs->trans("Error")." ".$langs->trans("ErrorModuleSetupNotComplete"); return ""; @@ -2481,7 +2481,7 @@ class SupplierProposal extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $get_params = '', $notooltip = 0, $save_lastsearch_value = -1) { global $langs, $conf, $user; @@ -2510,10 +2510,10 @@ class SupplierProposal extends CommonObject if ($option !== 'nolink') { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; } $linkclose=''; @@ -2544,10 +2544,10 @@ class SupplierProposal extends CommonObject /** * Retrieve an array of supplier proposal lines - * - * @return int >0 if OK, <0 if KO + * + * @return int >0 if OK, <0 if KO */ - function getLinesArray() + public function getLinesArray() { // For other object, here we call fetch_lines. But fetch_lines does not exists on supplier proposal @@ -2557,7 +2557,7 @@ class SupplierProposal extends CommonObject $sql.= ' pt.product_type, pt.rang, pt.fk_parent_line,'; $sql.= ' p.label as product_label, p.ref, p.fk_product_type, p.rowid as prodid,'; $sql.= ' p.description as product_desc, pt.ref_fourn as ref_supplier,'; - $sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; + $sql.= ' pt.fk_multicurrency, pt.multicurrency_code, pt.multicurrency_subprice, pt.multicurrency_total_ht, pt.multicurrency_total_tva, pt.multicurrency_total_ttc, pt.fk_unit'; $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pt'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid'; $sql.= ' WHERE pt.fk_supplier_proposal = '.$this->id; @@ -2594,26 +2594,26 @@ class SupplierProposal extends CommonObject $this->lines[$i]->total_ht = $obj->total_ht; $this->lines[$i]->total_tva = $obj->total_tva; $this->lines[$i]->total_ttc = $obj->total_ttc; - $this->lines[$i]->fk_fournprice = $obj->fk_fournprice; - $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht); - $this->lines[$i]->pa_ht = $marginInfos[0]; - $this->lines[$i]->marge_tx = $marginInfos[1]; - $this->lines[$i]->marque_tx = $marginInfos[2]; - $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; + $this->lines[$i]->fk_fournprice = $obj->fk_fournprice; + $marginInfos = getMarginInfos($obj->subprice, $obj->remise_percent, $obj->tva_tx, $obj->localtax1_tx, $obj->localtax2_tx, $this->lines[$i]->fk_fournprice, $obj->pa_ht); + $this->lines[$i]->pa_ht = $marginInfos[0]; + $this->lines[$i]->marge_tx = $marginInfos[1]; + $this->lines[$i]->marque_tx = $marginInfos[2]; + $this->lines[$i]->fk_parent_line = $obj->fk_parent_line; $this->lines[$i]->special_code = $obj->special_code; $this->lines[$i]->rang = $obj->rang; $this->lines[$i]->ref_fourn = $obj->ref_supplier; // deprecated $this->lines[$i]->ref_supplier = $obj->ref_supplier; - // Multicurrency - $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; - $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; - $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; - $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; - $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; - $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; - $this->lines[$i]->fk_unit = $obj->fk_unit; + // Multicurrency + $this->lines[$i]->fk_multicurrency = $obj->fk_multicurrency; + $this->lines[$i]->multicurrency_code = $obj->multicurrency_code; + $this->lines[$i]->multicurrency_subprice = $obj->multicurrency_subprice; + $this->lines[$i]->multicurrency_total_ht = $obj->multicurrency_total_ht; + $this->lines[$i]->multicurrency_total_tva = $obj->multicurrency_total_tva; + $this->lines[$i]->multicurrency_total_ttc = $obj->multicurrency_total_ttc; + $this->lines[$i]->fk_unit = $obj->fk_unit; $i++; } @@ -2628,56 +2628,56 @@ class SupplierProposal extends CommonObject } } - /** - * Create a document onto disk according to template module. - * - * @param string $modele Force model to use ('' to not force) - * @param Translate $outputlangs Object langs to use for output - * @param int $hidedetails Hide details of lines - * @param int $hidedesc Hide description - * @param int $hideref Hide ref + /** + * Create a document onto disk according to template module. + * + * @param string $modele Force model to use ('' to not force) + * @param Translate $outputlangs Object langs to use for output + * @param int $hidedetails Hide details of lines + * @param int $hidedesc Hide description + * @param int $hideref Hide ref * @param null|array $moreparams Array to provide more information - * @return int 0 if KO, 1 if OK - */ - public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) - { - global $conf, $langs; + * @return int 0 if KO, 1 if OK + */ + public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) + { + global $conf, $langs; - $langs->load("supplier_proposal"); + $langs->load("supplier_proposal"); - if (! dol_strlen($modele)) { + if (! dol_strlen($modele)) { - $modele = 'aurore'; + $modele = 'aurore'; - if ($this->modelpdf) { - $modele = $this->modelpdf; - } elseif (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)) { - $modele = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF; - } - } + if ($this->modelpdf) { + $modele = $this->modelpdf; + } elseif (! empty($conf->global->SUPPLIER_PROPOSAL_ADDON_PDF)) { + $modele = $conf->global->SUPPLIER_PROPOSAL_ADDON_PDF; + } + } - $modelpath = "core/modules/supplier_proposal/doc/"; + $modelpath = "core/modules/supplier_proposal/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); - } + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } - /** - * Function used to replace a thirdparty id with another one. - * - * @param DoliDB $db Database handler - * @param int $origin_id Old thirdparty id - * @param int $dest_id New thirdparty id - * @return bool - */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) - { - $tables = array( - 'supplier_proposal' - ); + /** + * Function used to replace a thirdparty id with another one. + * + * @param DoliDB $db Database handler + * @param int $origin_id Old thirdparty id + * @param int $dest_id New thirdparty id + * @return bool + */ + public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + { + $tables = array( + 'supplier_proposal' + ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); - } + return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + } } @@ -2692,19 +2692,19 @@ class SupplierProposalLine extends CommonObjectLine public $db; /** - * @var string Error code (or message) - */ - public $error=''; + * @var string Error code (or message) + */ + public $error=''; /** - * @var string ID to identify managed object - */ - public $element='supplier_proposaldet'; + * @var string ID to identify managed object + */ + public $element='supplier_proposaldet'; /** - * @var string Name of table without prefix where object is stored - */ - public $table_element='supplier_proposaldet'; + * @var string Name of table without prefix where object is stored + */ + public $table_element='supplier_proposaldet'; public $oldline; @@ -2712,11 +2712,11 @@ class SupplierProposalLine extends CommonObjectLine public $rowid; // deprecated /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; - /** + /** * @var int ID */ public $fk_supplier_proposal; @@ -2733,16 +2733,16 @@ class SupplierProposalLine extends CommonObjectLine */ public $fk_product; // Id produit predefini - /** - * @deprecated - * @see product_type - */ - public $fk_product_type; - /** - * Product type - * @var int - * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE - */ + /** + * @deprecated + * @see product_type + */ + public $fk_product_type; + /** + * Product type + * @var int + * @see Product::TYPE_PRODUCT, Product::TYPE_SERVICE + */ public $product_type = Product::TYPE_PRODUCT; public $qty; @@ -2760,11 +2760,11 @@ class SupplierProposalLine extends CommonObjectLine /** * @var int ID */ - public $fk_fournprice; + public $fk_fournprice; - public $pa_ht; - public $marge_tx; - public $marque_tx; + public $pa_ht; + public $marge_tx; + public $marque_tx; public $special_code; // Tag for special lines (exlusive tags) // 1: frais de port @@ -2779,53 +2779,53 @@ class SupplierProposalLine extends CommonObjectLine public $total_tva; // Total TVA de la ligne toute quantite et incluant la remise ligne public $total_ttc; // Total TTC de la ligne toute quantite et incluant la remise ligne - /** - * @deprecated - * @see remise_percent, fk_remise_except - */ + /** + * @deprecated + * @see remise_percent, fk_remise_except + */ public $remise; - /** - * @deprecated - * @see subprice - */ + /** + * @deprecated + * @see subprice + */ public $price; // From llx_product - /** - * @deprecated - * @see product_ref - */ - public $ref; + /** + * @deprecated + * @see product_ref + */ + public $ref; - /** - * Product reference - * @var string - */ - public $product_ref; + /** + * Product reference + * @var string + */ + public $product_ref; - /** - * @deprecated - * @see product_label - */ - public $libelle; + /** + * @deprecated + * @see product_label + */ + public $libelle; - /** - * Product label - * @var string - */ - public $product_label; + /** + * Product label + * @var string + */ + public $product_label; - /** - * Product description - * @var string - */ - public $product_desc; + /** + * Product description + * @var string + */ + public $product_desc; public $localtax1_tx; // Local tax 1 public $localtax2_tx; // Local tax 2 public $localtax1_type; // Local tax 1 type - public $localtax2_type; // Local tax 2 type + public $localtax2_type; // Local tax 2 type public $total_localtax1; // Line total local tax 1 public $total_localtax2; // Line total local tax 2 @@ -2834,24 +2834,24 @@ class SupplierProposalLine extends CommonObjectLine public $ref_fourn; public $ref_supplier; - // Multicurrency - /** + // Multicurrency + /** * @var int ID */ - public $fk_multicurrency; + public $fk_multicurrency; - public $multicurrency_code; - public $multicurrency_subprice; - public $multicurrency_total_ht; - public $multicurrency_total_tva; - public $multicurrency_total_ttc; + public $multicurrency_code; + public $multicurrency_subprice; + public $multicurrency_total_ht; + public $multicurrency_total_tva; + public $multicurrency_total_ttc; /** * Class line Contructor * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db= $db; } @@ -2862,79 +2862,79 @@ class SupplierProposalLine extends CommonObjectLine * @param int $rowid Propal line id * @return int <0 if KO, >0 if OK */ - function fetch($rowid) - { - $sql = 'SELECT pd.rowid, pd.fk_supplier_proposal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; - $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; - $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; - $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; - $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; - $sql.= ' pd.product_type, pd.ref_fourn as ref_produit_fourn,'; - $sql.= ' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc, pd.fk_unit'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pd'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; - $sql.= ' WHERE pd.rowid = '.$rowid; + public function fetch($rowid) + { + $sql = 'SELECT pd.rowid, pd.fk_supplier_proposal, pd.fk_parent_line, pd.fk_product, pd.label as custom_label, pd.description, pd.price, pd.qty, pd.tva_tx,'; + $sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,'; + $sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.fk_product_fournisseur_price as fk_fournprice, pd.buy_price_ht as pa_ht, pd.special_code, pd.rang,'; + $sql.= ' pd.localtax1_tx, pd.localtax2_tx, pd.total_localtax1, pd.total_localtax2,'; + $sql.= ' p.ref as product_ref, p.label as product_label, p.description as product_desc,'; + $sql.= ' pd.product_type, pd.ref_fourn as ref_produit_fourn,'; + $sql.= ' pd.fk_multicurrency, pd.multicurrency_code, pd.multicurrency_subprice, pd.multicurrency_total_ht, pd.multicurrency_total_tva, pd.multicurrency_total_ttc, pd.fk_unit'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'supplier_proposaldet as pd'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid'; + $sql.= ' WHERE pd.rowid = '.$rowid; - $result = $this->db->query($sql); - if ($result) - { - $objp = $this->db->fetch_object($result); + $result = $this->db->query($sql); + if ($result) + { + $objp = $this->db->fetch_object($result); - $this->rowid = $objp->rowid; // deprecated - $this->id = $objp->rowid; - $this->fk_supplier_proposal = $objp->fk_supplier_proposal; - $this->fk_parent_line = $objp->fk_parent_line; - $this->label = $objp->custom_label; - $this->desc = $objp->description; - $this->qty = $objp->qty; - $this->price = $objp->price; // deprecated - $this->subprice = $objp->subprice; - $this->tva_tx = $objp->tva_tx; - $this->remise = $objp->remise; - $this->remise_percent = $objp->remise_percent; - $this->fk_remise_except = $objp->fk_remise_except; - $this->fk_product = $objp->fk_product; - $this->info_bits = $objp->info_bits; + $this->rowid = $objp->rowid; // deprecated + $this->id = $objp->rowid; + $this->fk_supplier_proposal = $objp->fk_supplier_proposal; + $this->fk_parent_line = $objp->fk_parent_line; + $this->label = $objp->custom_label; + $this->desc = $objp->description; + $this->qty = $objp->qty; + $this->price = $objp->price; // deprecated + $this->subprice = $objp->subprice; + $this->tva_tx = $objp->tva_tx; + $this->remise = $objp->remise; + $this->remise_percent = $objp->remise_percent; + $this->fk_remise_except = $objp->fk_remise_except; + $this->fk_product = $objp->fk_product; + $this->info_bits = $objp->info_bits; - $this->total_ht = $objp->total_ht; - $this->total_tva = $objp->total_tva; - $this->total_ttc = $objp->total_ttc; + $this->total_ht = $objp->total_ht; + $this->total_tva = $objp->total_tva; + $this->total_ttc = $objp->total_ttc; - $this->fk_fournprice = $objp->fk_fournprice; + $this->fk_fournprice = $objp->fk_fournprice; - $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); - $this->pa_ht = $marginInfos[0]; - $this->marge_tx = $marginInfos[1]; - $this->marque_tx = $marginInfos[2]; + $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); + $this->pa_ht = $marginInfos[0]; + $this->marge_tx = $marginInfos[1]; + $this->marque_tx = $marginInfos[2]; - $this->special_code = $objp->special_code; - $this->product_type = $objp->product_type; - $this->rang = $objp->rang; + $this->special_code = $objp->special_code; + $this->product_type = $objp->product_type; + $this->rang = $objp->rang; - $this->ref = $objp->product_ref; // deprecated - $this->product_ref = $objp->product_ref; - $this->libelle = $objp->product_label; // deprecated - $this->product_label = $objp->product_label; - $this->product_desc = $objp->product_desc; + $this->ref = $objp->product_ref; // deprecated + $this->product_ref = $objp->product_ref; + $this->libelle = $objp->product_label; // deprecated + $this->product_label = $objp->product_label; + $this->product_desc = $objp->product_desc; - $this->ref_fourn = $objp->ref_produit_forun; + $this->ref_fourn = $objp->ref_produit_forun; - // Multicurrency - $this->fk_multicurrency = $objp->fk_multicurrency; - $this->multicurrency_code = $objp->multicurrency_code; - $this->multicurrency_subprice = $objp->multicurrency_subprice; - $this->multicurrency_total_ht = $objp->multicurrency_total_ht; - $this->multicurrency_total_tva = $objp->multicurrency_total_tva; - $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $this->fk_unit = $objp->fk_unit; + // Multicurrency + $this->fk_multicurrency = $objp->fk_multicurrency; + $this->multicurrency_code = $objp->multicurrency_code; + $this->multicurrency_subprice = $objp->multicurrency_subprice; + $this->multicurrency_total_ht = $objp->multicurrency_total_ht; + $this->multicurrency_total_tva = $objp->multicurrency_total_tva; + $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc; + $this->fk_unit = $objp->fk_unit; - $this->db->free($result); - } - else - { - dol_print_error($this->db); - } - } + $this->db->free($result); + } + else + { + dol_print_error($this->db); + } + } /** * Insert object line propal in database @@ -2942,7 +2942,7 @@ class SupplierProposalLine extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if KO, >0 if OK */ - function insert($notrigger = 0) + public function insert($notrigger = 0) { global $conf,$langs,$user; @@ -2955,7 +2955,7 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->localtax1_tx)) $this->localtax1_tx=0; if (empty($this->localtax2_tx)) $this->localtax2_tx=0; if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; + if (empty($this->localtax2_type)) $this->localtax2_type=0; if (empty($this->total_localtax1)) $this->total_localtax1=0; if (empty($this->total_localtax2)) $this->total_localtax2=0; if (empty($this->rang)) $this->rang=0; @@ -2970,18 +2970,18 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->pa_ht)) $this->pa_ht=0; - // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { - return $result; - } - else - { - $this->pa_ht = $result; - } - } + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } + } // Check parameters if ($this->product_type < 0) return -1; @@ -2991,12 +2991,12 @@ class SupplierProposalLine extends CommonObjectLine // Insert line into database $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'supplier_proposaldet'; $sql.= ' (fk_supplier_proposal, fk_parent_line, label, description, fk_product, product_type,'; - $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; + $sql.= ' fk_remise_except, qty, tva_tx, localtax1_tx, localtax2_tx, localtax1_type, localtax2_type,'; $sql.= ' subprice, remise_percent, '; $sql.= ' info_bits, '; $sql.= ' total_ht, total_tva, total_localtax1, total_localtax2, total_ttc, fk_product_fournisseur_price, buy_price_ht, special_code, rang,'; $sql.= ' ref_fourn,'; - $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; + $sql.= ' fk_multicurrency, multicurrency_code, multicurrency_subprice, multicurrency_total_ht, multicurrency_total_tva, multicurrency_total_ttc, fk_unit)'; $sql.= " VALUES (".$this->fk_supplier_proposal.","; $sql.= " ".($this->fk_parent_line>0?"'".$this->db->escape($this->fk_parent_line)."'":"null").","; $sql.= " ".(! empty($this->label)?"'".$this->db->escape($this->label)."'":"null").","; @@ -3008,8 +3008,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " ".price2num($this->tva_tx).","; $sql.= " ".price2num($this->localtax1_tx).","; $sql.= " ".price2num($this->localtax2_tx).","; - $sql.= " '".$this->db->escape($this->localtax1_type)."',"; - $sql.= " '".$this->db->escape($this->localtax2_type)."',"; + $sql.= " '".$this->db->escape($this->localtax1_type)."',"; + $sql.= " '".$this->db->escape($this->localtax2_type)."',"; $sql.= " ".(!empty($this->subprice)?price2num($this->subprice):"null").","; $sql.= " ".price2num($this->remise_percent).","; $sql.= " ".(isset($this->info_bits)?"'".$this->db->escape($this->info_bits)."'":"null").","; @@ -3023,29 +3023,29 @@ class SupplierProposalLine extends CommonObjectLine $sql.= ' '.$this->special_code.','; $sql.= ' '.$this->rang.','; $sql.= " '".$this->db->escape($this->ref_fourn)."'"; - $sql.= ", ".($this->fk_multicurrency > 0?$this->fk_multicurrency:'null'); - $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; - $sql.= ", ".$this->multicurrency_subprice; - $sql.= ", ".$this->multicurrency_total_ht; - $sql.= ", ".$this->multicurrency_total_tva; - $sql.= ", ".$this->multicurrency_total_ttc; + $sql.= ", ".($this->fk_multicurrency > 0?$this->fk_multicurrency:'null'); + $sql.= ", '".$this->db->escape($this->multicurrency_code)."'"; + $sql.= ", ".$this->multicurrency_subprice; + $sql.= ", ".$this->multicurrency_total_ht; + $sql.= ", ".$this->multicurrency_total_tva; + $sql.= ", ".$this->multicurrency_total_ttc; $sql.= ", ".($this->fk_unit?$this->fk_unit:'null'); - $sql.= ')'; + $sql.= ')'; dol_syslog(get_class($this).'::insert', LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { $this->rowid=$this->db->last_insert_id(MAIN_DB_PREFIX.'supplier_proposaldet'); - $this->id=$this->rowid; + $this->id=$this->rowid; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } } if (! $error && ! $notrigger) @@ -3076,7 +3076,7 @@ class SupplierProposalLine extends CommonObjectLine * * @return int <0 if ko, >0 if ok */ - function delete() + public function delete() { global $conf,$langs,$user; @@ -3088,17 +3088,17 @@ class SupplierProposalLine extends CommonObjectLine if ($this->db->query($sql) ) { - // Remove extrafields - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used - { - $this->id=$this->rowid; - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } - } + // Remove extrafields + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } + } // Call trigger $result=$this->call_trigger('LINESUPPLIER_PROPOSAL_DELETE', $user); @@ -3127,7 +3127,7 @@ class SupplierProposalLine extends CommonObjectLine * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <0 if ko, >0 if ok */ - function update($notrigger = 0) + public function update($notrigger = 0) { global $conf,$langs,$user; @@ -3139,8 +3139,8 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->localtax2_tx)) $this->localtax2_tx=0; if (empty($this->total_localtax1)) $this->total_localtax1=0; if (empty($this->total_localtax2)) $this->total_localtax2=0; - if (empty($this->localtax1_type)) $this->localtax1_type=0; - if (empty($this->localtax2_type)) $this->localtax2_type=0; + if (empty($this->localtax1_type)) $this->localtax1_type=0; + if (empty($this->localtax2_type)) $this->localtax2_type=0; if (empty($this->marque_tx)) $this->marque_tx=0; if (empty($this->marge_tx)) $this->marge_tx=0; if (empty($this->price)) $this->price=0; // TODO A virer @@ -3153,20 +3153,20 @@ class SupplierProposalLine extends CommonObjectLine if (empty($this->fk_unit)) $this->fk_unit=0; if (empty($this->subprice)) $this->subprice=0; - if (empty($this->pa_ht)) $this->pa_ht=0; + if (empty($this->pa_ht)) $this->pa_ht=0; - // if buy price not defined, define buyprice as configured in margin admin - if ($this->pa_ht == 0) - { - if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) - { - return $result; - } - else - { - $this->pa_ht = $result; - } - } + // if buy price not defined, define buyprice as configured in margin admin + if ($this->pa_ht == 0) + { + if (($result = $this->defineBuyPrice($this->subprice, $this->remise_percent, $this->fk_product)) < 0) + { + return $result; + } + else + { + $this->pa_ht = $result; + } + } $this->db->begin(); @@ -3178,8 +3178,8 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , tva_tx='".price2num($this->tva_tx)."'"; $sql.= " , localtax1_tx=".price2num($this->localtax1_tx); $sql.= " , localtax2_tx=".price2num($this->localtax2_tx); - $sql.= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'"; - $sql.= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; + $sql.= " , localtax1_type='".$this->db->escape($this->localtax1_type)."'"; + $sql.= " , localtax2_type='".$this->db->escape($this->localtax2_type)."'"; $sql.= " , qty='".price2num($this->qty)."'"; $sql.= " , subprice=".price2num($this->subprice).""; $sql.= " , remise_percent=".price2num($this->remise_percent).""; @@ -3194,35 +3194,35 @@ class SupplierProposalLine extends CommonObjectLine $sql.= " , total_localtax1=".price2num($this->total_localtax1).""; $sql.= " , total_localtax2=".price2num($this->total_localtax2).""; } - $sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); - $sql.= " , buy_price_ht=".price2num($this->pa_ht); + $sql.= " , fk_product_fournisseur_price=".(! empty($this->fk_fournprice)?"'".$this->db->escape($this->fk_fournprice)."'":"null"); + $sql.= " , buy_price_ht=".price2num($this->pa_ht); if (strlen($this->special_code)) $sql.= " , special_code=".$this->special_code; $sql.= " , fk_parent_line=".($this->fk_parent_line>0?$this->fk_parent_line:"null"); if (! empty($this->rang)) $sql.= ", rang=".$this->rang; $sql.= " , ref_fourn=".(! empty($this->ref_fourn)?"'".$this->db->escape($this->ref_fourn)."'":"null"); $sql.= " , fk_unit=".($this->fk_unit?$this->fk_unit:'null'); - // Multicurrency - $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; + // Multicurrency + $sql.= " , multicurrency_subprice=".price2num($this->multicurrency_subprice).""; $sql.= " , multicurrency_total_ht=".price2num($this->multicurrency_total_ht).""; $sql.= " , multicurrency_total_tva=".price2num($this->multicurrency_total_tva).""; $sql.= " , multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc).""; - $sql.= " WHERE rowid = ".$this->rowid; + $sql.= " WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::update", LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $this->id=$this->rowid; - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $this->id=$this->rowid; + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } if (! $error && ! $notrigger) { @@ -3247,14 +3247,14 @@ class SupplierProposalLine extends CommonObjectLine } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update DB line fields total_xxx * Used by migration * * @return int <0 if ko, >0 if ok */ - function update_total() + public function update_total() { // phpcs:enable $this->db->begin(); diff --git a/htdocs/ticket/class/actions_ticket.class.php b/htdocs/ticket/class/actions_ticket.class.php index 05b30c2b1a3..395ab2078c7 100644 --- a/htdocs/ticket/class/actions_ticket.class.php +++ b/htdocs/ticket/class/actions_ticket.class.php @@ -45,14 +45,14 @@ class ActionsTicket public $mesg; /** - * @var string Error code (or message) - */ - public $error; + * @var string Error code (or message) + */ + public $error; /** - * @var string[] Error codes (or messages) - */ - public $errors = array(); + * @var string[] Error codes (or messages) + */ + public $errors = array(); //! Numero de l'erreur public $errno = 0; @@ -66,18 +66,18 @@ class ActionsTicket public $label; /** - * @var string description - */ - public $description; + * @var string description + */ + public $description; - /** + /** * @var int ID */ public $fk_statut; /** - * @var int Thirdparty ID - */ + * @var int Thirdparty ID + */ public $fk_soc; /** @@ -119,7 +119,7 @@ class ActionsTicket if (GETPOST('addfile')) { // altairis : allow files from public interface if (GETPOST('track_id')) { - $res = $object->fetch('', '', GETPOST('track_id', 'alpha')); + $res = $object->fetch('', '', GETPOST('track_id', 'alpha')); } ////if($res > 0) @@ -374,7 +374,7 @@ class ActionsTicket if (! $error) // Update list of contacts { - // Si déjà un user assigné on le supprime des contacts + // Si déjà un user assigné on le supprime des contacts if ($useroriginassign > 0) { $internal_contacts = $object->listeContact(-1, 'internal'); @@ -760,12 +760,12 @@ class ActionsTicket // If public interface is not enable, use link to internal page into mail $url_public_ticket = (!empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE) ? - (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? - $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : - dol_buildpath('/public/ticket/view.php', 2) - ) : - dol_buildpath('/ticket/card.php', 2) - ) . '?track_id=' . $object->track_id; + (!empty($conf->global->TICKET_URL_PUBLIC_INTERFACE) ? + $conf->global->TICKET_URL_PUBLIC_INTERFACE . '/view.php' : + dol_buildpath('/public/ticket/view.php', 2) + ) : + dol_buildpath('/ticket/card.php', 2) + ) . '?track_id=' . $object->track_id; $message .= "\n" . $langs->trans('TicketNewEmailBodyInfosTrackUrlCustomer') . ' : ' . '' . $object->track_id . '' . "\n"; // Build final message @@ -779,8 +779,8 @@ class ActionsTicket } if ($object->fk_soc > 0 && ! in_array($object->origin_email, $sendto)) { - $object->socid = $object->fk_soc; - $object->fetch_thirdparty(); + $object->socid = $object->fk_soc; + $object->fetch_thirdparty(); if(!empty($object->thirdparty->email)) $sendto[] = $object->thirdparty->email; } @@ -954,7 +954,7 @@ class ActionsTicket header("Location: " . $url); exit; } else { - setEventMessages($object->error, $object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else { setEventMessages($this->error, $this->errors, 'errors'); @@ -1095,43 +1095,43 @@ class ActionsTicket */ public function viewTimelineTicketLogs($show_user = true, $object = true) { - global $conf, $langs; + global $conf, $langs; - // Load logs in cache - $ret = $object->loadCacheLogsTicket(); + // Load logs in cache + $ret = $object->loadCacheLogsTicket(); - if (is_array($object->cache_logs_ticket) && count($object->cache_logs_ticket) > 0) { - print '
'; + if (is_array($object->cache_logs_ticket) && count($object->cache_logs_ticket) > 0) { + print '
'; - foreach ($object->cache_logs_ticket as $id => $arraylogs) { - print '
'; - print '
'; - //print ''; - print '
'; + foreach ($object->cache_logs_ticket as $id => $arraylogs) { + print '
'; + print '
'; + //print ''; + print '
'; - print '
'; - print dol_nl2br($arraylogs['message']); + print '
'; + print dol_nl2br($arraylogs['message']); - print ''; - print dol_print_date($arraylogs['datec'], 'dayhour'); + print ''; + print dol_print_date($arraylogs['datec'], 'dayhour'); - if ($show_user) { - if ($arraylogs['fk_user_create'] > 0) { - $userstat = new User($this->db); - $res = $userstat->fetch($arraylogs['fk_user_create']); - if ($res) { - print '
'.$userstat->getNomUrl(1).''; - } - } - } - print '
'; - print '
'; - print '
'; - } - print '
'; - } else { - print '
' . $langs->trans('NoLogForThisTicket') . '
'; - } + if ($show_user) { + if ($arraylogs['fk_user_create'] > 0) { + $userstat = new User($this->db); + $res = $userstat->fetch($arraylogs['fk_user_create']); + if ($res) { + print '
'.$userstat->getNomUrl(1).''; + } + } + } + print ''; + print ' '; + print ' '; + } + print '
'; + } else { + print '
' . $langs->trans('NoLogForThisTicket') . '
'; + } } /** @@ -1144,55 +1144,55 @@ class ActionsTicket */ public function viewTicketOriginalMessage($user, $action, $object) { - global $langs; - if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { - // MESSAGE + global $langs; + if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { + // MESSAGE - print ''; - print ''; - print ''; - print ''; - } + print ''; + print ''; + print ''; + print ''; + } - // Initial message - print '
'; - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print '
'; $this->resprints.= $langs->trans('PlanStripe'); @@ -161,14 +158,13 @@ class ActionsStripeconnect $object->fetch_thirdparty(); $customer=$stripe->customerStripe($object, $stripe->getStripeAccount($service)); $this->resprints.= $customer->id; - } - else { + } else { $this->resprints.= $langs->trans("NoStripe"); } $this->resprints.= '
'; - print ''; + // Initial message + print '
'; + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'; - print $langs->trans("InitialMessage"); - print ''; - if ($user->rights->ticket->manage) { - print '' . img_edit($langs->trans('Modify')) . ''; - } - print '
'; + print ''; - print ''; - print ''; + print ''; - print ''; - print '
'; + print $langs->trans("InitialMessage"); + print ''; + if ($user->rights->ticket->manage) { + print '' . img_edit($langs->trans('Modify')) . ''; + } + print '
'; - if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { - // MESSAGE - $msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message; - include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $uselocalbrowser = true; - $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser); - $doleditor->Create(); - } else { - // Deal with format differences (text / HTML) - if (dol_textishtml($object->message)) { - print $object->message; - } else { - print dol_nl2br($object->message); - } + print '
'; + if (!empty($user->rights->ticket->manage) && $action == 'edit_message_init') { + // MESSAGE + $msg = GETPOST('message_initial', 'alpha') ? GETPOST('message_initial', 'alpha') : $object->message; + include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $uselocalbrowser = true; + $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser); + $doleditor->Create(); + } else { + // Deal with format differences (text / HTML) + if (dol_textishtml($object->message)) { + print $object->message; + } else { + print dol_nl2br($object->message); + } - //print '
' . $object->message . '
'; - } - print '
'; - if ($user->rights->ticket->manage && $action == 'edit_message_init') { - print ' '; - print ' '; - print ''; - } + //print '
' . $object->message . '
'; + } + print '
'; + if ($user->rights->ticket->manage && $action == 'edit_message_init') { + print ' '; + print ' '; + print ''; + } } /** * View html list of message for ticket @@ -1275,29 +1275,29 @@ class ActionsTicket */ public function viewTicketTimelineMessages($show_private, $show_user, Ticket $object) { - global $conf, $langs, $user; + global $conf, $langs, $user; - // Load logs in cache - $ret = $object->loadCacheMsgsTicket(); - $action = GETPOST('action'); + // Load logs in cache + $ret = $object->loadCacheMsgsTicket(); + $action = GETPOST('action'); - if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) { - print '
'; + if (is_array($object->cache_msgs_ticket) && count($object->cache_msgs_ticket) > 0) { + print '
'; - foreach ($object->cache_msgs_ticket as $id => $arraymsgs) { - if (!$arraymsgs['private'] - || ($arraymsgs['private'] == "1" && $show_private) - ) { - print '
'; - print '
'; - print ''; - print '
'; + foreach ($object->cache_msgs_ticket as $id => $arraymsgs) { + if (!$arraymsgs['private'] + || ($arraymsgs['private'] == "1" && $show_private) + ) { + print '
'; + print '
'; + print ''; + print '
'; - print '
'; - print $arraymsgs['message']; + print '
'; + print $arraymsgs['message']; - print ''; - print dol_print_date($arraymsgs['datec'], 'dayhour'); + print ''; + print dol_print_date($arraymsgs['datec'], 'dayhour'); if ($show_user) { if ($arraymsgs['fk_user_action'] > 0) { @@ -1312,18 +1312,18 @@ class ActionsTicket print $langs->trans('Customer'); } } - print ''; - print '
'; - print '
'; + print ''; + print '
'; + print '
'; } - } - print '
'; - } else { - print '
' . $langs->trans('NoMsgForThisTicket') . '
'; - } + } + print '
'; + } else { + print '
' . $langs->trans('NoMsgForThisTicket') . '
'; + } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * load_previous_next_ref * @@ -1331,7 +1331,7 @@ class ActionsTicket * @param int $fieldid Id * @return int 0 */ - function load_previous_next_ref($filter, $fieldid) + public function load_previous_next_ref($filter, $fieldid) { // phpcs:enable $this->getInstanceDao(); @@ -1498,9 +1498,9 @@ class ActionsTicket print '
'; if ($status == 1) - $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=mark_ticket_read'; // To set as read, we use a dedicated action - else - $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status; + $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=mark_ticket_read'; // To set as read, we use a dedicated action + else + $urlforbutton = $_SERVER['PHP_SELF'] . '?track_id=' . $object->track_id . '&action=set_status&new_status=' . $status; print ''; print img_picto($langs->trans($object->statuts_short[$status]), 'statut' . $status . '.png@ticket') . ' ' . $langs->trans($object->statuts_short[$status]); @@ -1512,14 +1512,14 @@ class ActionsTicket } - /** - * deleteObjectLinked - * - * @return number - */ + /** + * deleteObjectLinked + * + * @return number + */ public function deleteObjectLinked() { - return $this->dao->deleteObjectLinked(); + return $this->dao->deleteObjectLinked(); } /** @@ -1533,19 +1533,19 @@ class ActionsTicket */ public function emailElementlist($parameters, &$object, &$action, $hookmanager) { - global $langs; + global $langs; - $error = 0; + $error = 0; - if (in_array('admin', explode(':', $parameters['context']))) { + if (in_array('admin', explode(':', $parameters['context']))) { $this->results = array('ticket_send' => $langs->trans('MailToSendTicketMessage')); - } + } - if (! $error) { + if (! $error) { return 0; // or return 1 to replace standard code - } else { - $this->errors[] = 'Error message'; - return -1; - } + } else { + $this->errors[] = 'Error message'; + return -1; + } } } diff --git a/htdocs/ticket/class/api_tickets.class.php b/htdocs/ticket/class/api_tickets.class.php index fd698e6de06..005d8084f31 100644 --- a/htdocs/ticket/class/api_tickets.class.php +++ b/htdocs/ticket/class/api_tickets.class.php @@ -55,8 +55,8 @@ class Tickets extends DolibarrApi */ public function __construct() { - global $db; - $this->db = $db; + global $db; + $this->db = $db; $this->ticket = new Ticket($this->db); } @@ -72,9 +72,9 @@ class Tickets extends DolibarrApi * @throws 403 * @throws 404 */ - function get($id) + public function get($id) { - return $this->getCommon($id, '', ''); + return $this->getCommon($id, '', ''); } /** @@ -93,7 +93,7 @@ class Tickets extends DolibarrApi */ public function getByTrackId($track_id) { - return $this->getCommon(0, $track_id, ''); + return $this->getCommon(0, $track_id, ''); } /** @@ -112,13 +112,13 @@ class Tickets extends DolibarrApi */ public function getByRef($ref) { - try { - return $this->getCommon(0, '', $ref); - } - catch(Exception $e) - { - throw $e; - } + try { + return $this->getCommon(0, '', $ref); + } + catch(Exception $e) + { + throw $e; + } } /** @@ -301,22 +301,22 @@ class Tickets extends DolibarrApi } // Add sql filters if ($sqlfilters) { - if (! DolibarrApi::_checkFilters($sqlfilters)) { - throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); - } - $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; - $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; + if (! DolibarrApi::_checkFilters($sqlfilters)) { + throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters); + } + $regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; + $sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")"; } $sql.= $db->order($sortfield, $sortorder); if ($limit) { - if ($page < 0) { - $page = 0; - } - $offset = $limit * $page; + if ($page < 0) { + $page = 0; + } + $offset = $limit * $page; - $sql .= $this->db->plimit($limit, $offset); + $sql .= $this->db->plimit($limit, $offset); } $result = $db->query($sql); @@ -341,7 +341,7 @@ class Tickets extends DolibarrApi if (! count($obj_ret)) { throw new RestException(404, 'No ticket found'); } - return $obj_ret; + return $obj_ret; } /** @@ -355,8 +355,8 @@ class Tickets extends DolibarrApi { $ticketstatic = new Ticket($this->db); if (! DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } + throw new RestException(401); + } // Check mandatory fields $result = $this->_validate($request_data); @@ -417,17 +417,17 @@ class Tickets extends DolibarrApi public function put($id, $request_data = null) { if (! DolibarrApiAccess::$user->rights->ticket->write) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->ticket->fetch($id); if (! $result) { throw new RestException(404, 'Ticket not found'); } - if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } foreach ($request_data as $field => $value) { $this->ticket->$field = $value; @@ -450,16 +450,16 @@ class Tickets extends DolibarrApi public function delete($id) { if (! DolibarrApiAccess::$user->rights->ticket->delete) { - throw new RestException(401); - } + throw new RestException(401); + } $result = $this->ticket->fetch($id); if (! $result) { throw new RestException(404, 'Ticket not found'); } - if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { - throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); - } + if (! DolibarrApi::_checkAccessToResource('ticket', $this->ticket->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } if (!$this->ticket->delete($id)) { throw new RestException(500); @@ -523,12 +523,12 @@ class Tickets extends DolibarrApi * @todo use an array for properties to clean * */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { - $object = parent::_cleanObjectDatas($object); + $object = parent::_cleanObjectDatas($object); - // Other attributes to clean + // Other attributes to clean $attr2clean = array( "contact", "contact_id", @@ -568,8 +568,8 @@ class Tickets extends DolibarrApi "civility_id", "cache_msgs_ticket", "cache_logs_ticket", - "statuts_short", - "statuts" + "statuts_short", + "statuts" ); foreach ($attr2clean as $toclean) { unset($object->$toclean); diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 806bed19064..ec1e44e9f86 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -200,7 +200,7 @@ class Ticket extends CommonObject 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,), 'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>-1, 'enabled'=>1, 'position'=>540, 'notnull'=>-1, 'searchall'=>1, 'css'=>'right', 'help'=>""), 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>1, 'position'=>550, 'notnull'=>1), - 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')) + 'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted')) ); /** @@ -393,12 +393,12 @@ class Ticket extends CommonObject $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "ticket"); if (!$notrigger) { - // Call trigger - $result=$this->call_trigger('TICKET_CREATE', $user); - if ($result < 0) { + // Call trigger + $result=$this->call_trigger('TICKET_CREATE', $user); + if ($result < 0) { $error++; } - // End call triggers + // End call triggers } } @@ -537,10 +537,10 @@ class Ticket extends CommonObject $this->db->free($resql); return 1; } - else - { - return 0; - } + else + { + return 0; + } } else { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::fetch " . $this->error, LOG_ERR); @@ -595,7 +595,7 @@ class Ticket extends CommonObject $sql .= ", type.label as type_label, category.label as category_label, severity.label as severity_label"; // Add fields for extrafields foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? ",ef." . $key . ' as options_' . $key : ''); + $sql .= ($extrafields->attributes[$this->table_element]['type'][$key] != 'separate' ? ",ef." . $key . ' as options_' . $key : ''); } $sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_ticket_type as type ON type.code=t.type_code"; @@ -699,7 +699,7 @@ class Ticket extends CommonObject // Extra fields if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label'])) { - foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { + foreach ($extrafields->attributes[$this->table_element]['label'] as $key => $val) { $tmpkey = 'options_' . $key; $line->{$tmpkey} = $obj->$tmpkey; } @@ -839,12 +839,12 @@ class Ticket extends CommonObject } if (! $error && ! $notrigger) { - // Call trigger - $result=$this->call_trigger('TICKET_MODIFY', $user); - if ($result < 0) { + // Call trigger + $result=$this->call_trigger('TICKET_MODIFY', $user); + if ($result < 0) { $error++; } - // End call triggers + // End call triggers } // Commit or rollback @@ -902,18 +902,18 @@ class Ticket extends CommonObject } if (!$error) { - $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticket_msg"; - $sql .= " WHERE fk_track_id = '" . $this->db->escape($this->track_id) . "'"; - $resql = $this->db->query($sql); + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "ticket_msg"; + $sql .= " WHERE fk_track_id = '" . $this->db->escape($this->track_id) . "'"; + $resql = $this->db->query($sql); } // Removed extrafields if (!$error) { - $result = $this->deleteExtraFields(); - if ($result < 0) { - $error++; - dol_syslog(get_class($this) . "::delete error -3 " . $this->error, LOG_ERR); - } + $result = $this->deleteExtraFields(); + if ($result < 0) { + $error++; + dol_syslog(get_class($this) . "::delete error -3 " . $this->error, LOG_ERR); + } } if (!$error) { @@ -1167,7 +1167,7 @@ class Ticket extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return status label of object * @@ -1175,7 +1175,7 @@ class Ticket extends CommonObject * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto * @return string Label */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -1331,57 +1331,57 @@ class Ticket extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $db, $conf, $langs; - global $dolibarr_main_authentication, $dolibarr_main_demo; - global $menumanager; + global $db, $conf, $langs; + global $dolibarr_main_authentication, $dolibarr_main_demo; + global $menumanager; - if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips + if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips - $result = ''; - $companylink = ''; + $result = ''; + $companylink = ''; - $label = '' . $langs->trans("ShowTicket") . ''; - $label.= '
'; - $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; - $label.= '' . $langs->trans('TicketTrackId') . ': ' . $this->track_id.'
'; - $label.= '' . $langs->trans('Subject') . ': ' . $this->subject; + $label = '' . $langs->trans("ShowTicket") . ''; + $label.= '
'; + $label.= '' . $langs->trans('Ref') . ': ' . $this->ref.'
'; + $label.= '' . $langs->trans('TicketTrackId') . ': ' . $this->track_id.'
'; + $label.= '' . $langs->trans('Subject') . ': ' . $this->subject; - $url = dol_buildpath('/ticket/card.php', 1).'?id='.$this->id; + $url = dol_buildpath('/ticket/card.php', 1).'?id='.$this->id; - if ($option != 'nolink') - { - // Add param to save lastsearch_values or not - $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; - if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; - } + if ($option != 'nolink') + { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1; + if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1'; + } - $linkclose=''; - if (empty($notooltip)) - { - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) - { - $label=$langs->trans("ShowTicket"); - $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; - } - $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; - $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; - } - else $linkclose = ($morecss?' class="'.$morecss.'"':''); + $linkclose=''; + if (empty($notooltip)) + { + if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) + { + $label=$langs->trans("ShowTicket"); + $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"'; + } + else $linkclose = ($morecss?' class="'.$morecss.'"':''); - $linkstart = '
'; - $linkend=''; + $linkstart = ''; + $linkend=''; - $result .= $linkstart; - if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); - if ($withpicto != 2) $result.= $this->ref; - $result .= $linkend; - //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + $result .= $linkstart; + if ($withpicto) $result.=img_object(($notooltip?'':$label), ($this->picto?$this->picto:'generic'), ($notooltip?(($withpicto != 2) ? 'class="paddingright"' : ''):'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip?0:1); + if ($withpicto != 2) $result.= $this->ref; + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - return $result; + return $result; } @@ -1406,14 +1406,14 @@ class Ticket extends CommonObject dol_syslog(get_class($this) . "::markAsRead sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { - if (!$error && !$notrigger) { - // Call trigger - $result=$this->call_trigger('TICKET_MARK_READ', $user); - if ($result < 0) { + if (!$error && !$notrigger) { + // Call trigger + $result=$this->call_trigger('TICKET_MARK_READ', $user); + if ($result < 0) { $error++; } - // End call triggers - } + // End call triggers + } if (!$error) { @@ -1434,61 +1434,61 @@ class Ticket extends CommonObject } } - /** - * Mark a message as read - * - * @param User $user Object user - * @param int $id_assign_user ID of user assigned - * @param int $notrigger Disable trigger - * @return int <0 if KO, 0=Nothing done, >0 if OK - */ - public function assignUser($user, $id_assign_user, $notrigger = 0) - { - global $conf, $langs; + /** + * Mark a message as read + * + * @param User $user Object user + * @param int $id_assign_user ID of user assigned + * @param int $notrigger Disable trigger + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function assignUser($user, $id_assign_user, $notrigger = 0) + { + global $conf, $langs; - $this->db->begin(); + $this->db->begin(); - $sql = "UPDATE " . MAIN_DB_PREFIX . "ticket"; - if ($id_assign_user > 0) - { - $sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut=4"; - } - else - { - $sql .= " SET fk_user_assign=null, fk_statut=1"; - } - $sql .= " WHERE rowid = " . $this->id; + $sql = "UPDATE " . MAIN_DB_PREFIX . "ticket"; + if ($id_assign_user > 0) + { + $sql .= " SET fk_user_assign=".$id_assign_user.", fk_statut=4"; + } + else + { + $sql .= " SET fk_user_assign=null, fk_statut=1"; + } + $sql .= " WHERE rowid = " . $this->id; - dol_syslog(get_class($this) . "::assignUser sql=" . $sql); - $resql = $this->db->query($sql); - if ($resql) { - $this->fk_user_assign = $id_assign_user; // May be used by trigger + dol_syslog(get_class($this) . "::assignUser sql=" . $sql); + $resql = $this->db->query($sql); + if ($resql) { + $this->fk_user_assign = $id_assign_user; // May be used by trigger - if (! $notrigger) { - // Call trigger - $result = $this->call_trigger('TICKET_ASSIGNED', $user); - if ($result < 0) { - $error ++; - } - // End call triggers - } + if (! $notrigger) { + // Call trigger + $result = $this->call_trigger('TICKET_ASSIGNED', $user); + if ($result < 0) { + $error ++; + } + // End call triggers + } - if (! $error) { - $this->db->commit(); - return 1; - } else { - $this->db->rollback(); - $this->error = join(',', $this->errors); - dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); - return - 1; - } - } else { - $this->db->rollback(); - $this->error = $this->db->lasterror(); - dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); - return - 1; - } - } + if (! $error) { + $this->db->commit(); + return 1; + } else { + $this->db->rollback(); + $this->error = join(',', $this->errors); + dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); + return - 1; + } + } else { + $this->db->rollback(); + $this->error = $this->db->lasterror(); + dol_syslog(get_class($this) . "::assignUser " . $this->error, LOG_ERR); + return - 1; + } + } /** * Create log for the ticket @@ -1521,19 +1521,19 @@ class Ticket extends CommonObject // so the event is stored by the agenda/event trigger if (!$error) { - $this->db->commit(); + $this->db->commit(); - if ($conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL && !$noemail) { - $this->sendLogByEmail($user, $message); - } + if ($conf->global->TICKET_ACTIVATE_LOG_BY_EMAIL && !$noemail) { + $this->sendLogByEmail($user, $message); + } - return 1; + return 1; } else { - $this->db->rollback(); + $this->db->rollback(); - return -1; + return -1; } } @@ -1811,32 +1811,32 @@ class Ticket extends CommonObject $this->fetchObjectLinked($this->id, $this->element, null, 'fichinter'); if ($this->linkedObjectsIds) { - foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) { - $fichinter = new Fichinter($this->db); - $fichinter->fetch($fichinter_id); - if($fichinter->statut == 0) { - $result = $fichinter->setValid($user); - if (!$result) { - $this->errors[] = $fichinter->error; - $error++; - } - } - if ($fichinter->statut < 3) { - $result = $fichinter->setStatut(3); - if (!$result) { - $this->errors[] = $fichinter->error; - $error++; - } - } - } + foreach ($this->linkedObjectsIds['fichinter'] as $fichinter_id) { + $fichinter = new Fichinter($this->db); + $fichinter->fetch($fichinter_id); + if($fichinter->statut == 0) { + $result = $fichinter->setValid($user); + if (!$result) { + $this->errors[] = $fichinter->error; + $error++; + } + } + if ($fichinter->statut < 3) { + $result = $fichinter->setStatut(3); + if (!$result) { + $this->errors[] = $fichinter->error; + $error++; + } + } + } } - // Call trigger - $result=$this->call_trigger('TICKET_CLOSE', $user); - if ($result < 0) { + // Call trigger + $result=$this->call_trigger('TICKET_CLOSE', $user); + if ($result < 0) { $error++; } - // End call triggers + // End call triggers if (!$error) { $this->db->commit(); @@ -2299,7 +2299,7 @@ class Ticket extends CommonObject * @param string $code Filter on this code of contact type ('SHIPPING', 'BILLING', ...) * @return array Array of contacts */ - function listeContact($statut = -1, $source = 'external', $list = 0, $code = '') + public function listeContact($statut = -1, $source = 'external', $list = 0, $code = '') { global $langs; @@ -2363,22 +2363,22 @@ class Ticket extends CommonObject $transkey = "TypeContact_" . $obj->element . "_" . $obj->source . "_" . $obj->code; $libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle); $tab[$i] = array( - 'source' => $obj->source, - 'socid' => $obj->socid, - 'id' => $obj->id, - 'nom' => $obj->lastname, // For backward compatibility - 'civility' => $obj->civility, - 'lastname' => $obj->lastname, - 'firstname' => $obj->firstname, - 'email' => $obj->email, - 'rowid' => $obj->rowid, - 'code' => $obj->code, - 'libelle' => $libelle_type, - 'status' => $obj->statuslink, - 'statuscontact'=>$obj->statuscontact, - 'fk_c_type_contact' => $obj->fk_c_type_contact, - 'phone' => $obj->phone, - 'phone_mobile' => $obj->phone_mobile); + 'source' => $obj->source, + 'socid' => $obj->socid, + 'id' => $obj->id, + 'nom' => $obj->lastname, // For backward compatibility + 'civility' => $obj->civility, + 'lastname' => $obj->lastname, + 'firstname' => $obj->firstname, + 'email' => $obj->email, + 'rowid' => $obj->rowid, + 'code' => $obj->code, + 'libelle' => $libelle_type, + 'status' => $obj->statuslink, + 'statuscontact'=>$obj->statuscontact, + 'fk_c_type_contact' => $obj->fk_c_type_contact, + 'phone' => $obj->phone, + 'phone_mobile' => $obj->phone_mobile); } else { $tab[$i] = $obj->id; } @@ -2436,14 +2436,14 @@ class Ticket extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return if at least one photo is available - * - * @param string $sdir Directory to scan - * @return boolean True if at least one photo is available, False if not - */ - function is_photo_available($sdir) + * Return if at least one photo is available + * + * @param string $sdir Directory to scan + * @return boolean True if at least one photo is available, False if not + */ + public function is_photo_available($sdir) { // phpcs:enable include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php'; @@ -2479,9 +2479,9 @@ class Ticket extends CommonObject class TicketsLine { /** - * @var int ID - */ - public $id; + * @var int ID + */ + public $id; /** * @var string $ref Ticket reference @@ -2489,107 +2489,107 @@ class TicketsLine public $ref; /** - * Hash to identify ticket - */ + * Hash to identify ticket + */ public $track_id; /** - * @var int Thirdparty ID - */ + * @var int Thirdparty ID + */ public $fk_soc; /** - * Project ID - */ + * Project ID + */ public $fk_project; /** - * Person email who have create ticket - */ + * Person email who have create ticket + */ public $origin_email; /** - * User id who have create ticket - */ + * User id who have create ticket + */ public $fk_user_create; /** - * User id who have ticket assigned - */ + * User id who have ticket assigned + */ public $fk_user_assign; /** - * Ticket subject - */ + * Ticket subject + */ public $subject; /** - * Ticket message - */ + * Ticket message + */ public $message; /** - * Ticket statut - */ + * Ticket statut + */ public $fk_statut; /** - * State resolution - */ + * State resolution + */ public $resolution; /** - * Progress in percent - */ + * Progress in percent + */ public $progress; /** - * Duration for ticket - */ + * Duration for ticket + */ public $timing; /** - * Type code - */ + * Type code + */ public $type_code; /** - * Category code - */ + * Category code + */ public $category_code; /** - * Severity code - */ + * Severity code + */ public $severity_code; /** - * Type label - */ + * Type label + */ public $type_label; /** - * Category label - */ + * Category label + */ public $category_label; /** - * Severity label - */ + * Severity label + */ public $severity_label; /** - * Creation date - */ + * Creation date + */ public $datec = ''; /** - * Read date - */ + * Read date + */ public $date_read = ''; /** - * Close ticket date - */ + * Close ticket date + */ public $date_close = ''; } diff --git a/htdocs/ticket/class/ticketstats.class.php b/htdocs/ticket/class/ticketstats.class.php index 44360c788a5..2f2e04baba9 100644 --- a/htdocs/ticket/class/ticketstats.class.php +++ b/htdocs/ticket/class/ticketstats.class.php @@ -30,9 +30,9 @@ require_once 'ticket.class.php'; class TicketStats extends Stats { /** - * @var string Name of table without prefix where object is stored - */ - public $table_element; + * @var string Name of table without prefix where object is stored + */ + public $table_element; public $socid; public $userid; diff --git a/htdocs/user/class/api_users.class.php b/htdocs/user/class/api_users.class.php index 874e518511a..625fd913f5e 100644 --- a/htdocs/user/class/api_users.class.php +++ b/htdocs/user/class/api_users.class.php @@ -44,7 +44,7 @@ class Users extends DolibarrApi /** * Constructor */ - function __construct() + public function __construct() { global $db, $conf; $this->db = $db; @@ -65,7 +65,7 @@ class Users extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')" * @return array Array of User objects */ - function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') + public function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $user_ids = 0, $sqlfilters = '') { global $db, $conf; @@ -139,7 +139,7 @@ class Users extends DolibarrApi * * @throws RestException */ - function get($id) + public function get($id) { //if (!DolibarrApiAccess::$user->rights->user->user->lire) { //throw new RestException(401); @@ -166,7 +166,7 @@ class Users extends DolibarrApi * @param array $request_data New user data * @return int */ - function post($request_data = null) + public function post($request_data = null) { // check user authorization //if(! DolibarrApiAccess::$user->rights->user->creer) { @@ -201,7 +201,7 @@ class Users extends DolibarrApi * * @throws RestException */ - function put($id, $request_data = null) + public function put($id, $request_data = null) { //if (!DolibarrApiAccess::$user->rights->user->user->creer) { //throw new RestException(401); @@ -256,7 +256,7 @@ class Users extends DolibarrApi * * @url GET {id}/groups */ - function getGroups($id) + public function getGroups($id) { $obj_ret = array(); @@ -290,7 +290,7 @@ class Users extends DolibarrApi * * @url GET {id}/setGroup/{group} */ - function setGroup($id, $group, $entity = 1) + public function setGroup($id, $group, $entity = 1) { global $conf; @@ -335,7 +335,7 @@ class Users extends DolibarrApi * @param int $id Account ID * @return array */ - function delete($id) + public function delete($id) { //if (!DolibarrApiAccess::$user->rights->user->user->supprimer) { //throw new RestException(401); @@ -360,7 +360,7 @@ class Users extends DolibarrApi * @param object $object Object to clean * @return array Array of cleaned object properties */ - function _cleanObjectDatas($object) + private function _cleanObjectDatas($object) { global $conf; @@ -418,16 +418,15 @@ class Users extends DolibarrApi * @param array|null $data Data to validate * @return array * @throws RestException - */ - function _validate($data) + */ + private function _validate($data) { - $account = array(); - foreach (Users::$FIELDS as $field) - { - if (!isset($data[$field])) - throw new RestException(400, "$field field missing"); - $account[$field] = $data[$field]; - } - return $account; - } + $account = array(); + foreach (Users::$FIELDS as $field) { + if (!isset($data[$field])) + throw new RestException(400, "$field field missing"); + $account[$field] = $data[$field]; + } + return $account; + } } diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index aeb43905b4f..611ab7fadc2 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -1,17 +1,18 @@ - * Copyright (c) 2002-2003 Jean-Louis Bergamo - * Copyright (c) 2004-2012 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2017 Regis Houssin - * Copyright (C) 2005 Lionel Cousteix - * Copyright (C) 2011 Herve Prot - * Copyright (C) 2013-2018 Philippe Grand - * Copyright (C) 2013-2015 Alexandre Spangaro - * Copyright (C) 2015 Marcos García - * Copyright (C) 2018 charlene Benke - * Copyright (C) 2018 Nicolas ZABOURI +/* Copyright (c) 2002-2007 Rodolphe Quiedeville + * Copyright (c) 2002-2003 Jean-Louis Bergamo + * Copyright (c) 2004-2012 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2005 Lionel Cousteix + * Copyright (C) 2011 Herve Prot + * Copyright (C) 2013-2018 Philippe Grand + * Copyright (C) 2013-2015 Alexandre Spangaro + * Copyright (C) 2015 Marcos García + * Copyright (C) 2018 charlene Benke + * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2019 Frédéric France * * 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 @@ -174,7 +175,7 @@ class User extends CommonObject public $default_c_exp_tax_cat; public $default_range; - + public $fk_warehouse; public $fields = array( @@ -188,7 +189,7 @@ class User extends CommonObject * * @param DoliDb $db Database handler */ - function __construct($db) + public function __construct($db) { $this->db = $db; @@ -204,11 +205,11 @@ class User extends CommonObject $this->admin = 0; $this->employee = 1; - $this->conf = new stdClass(); - $this->rights = new stdClass(); - $this->rights->user = new stdClass(); - $this->rights->user->user = new stdClass(); - $this->rights->user->self = new stdClass(); + $this->conf = new stdClass(); + $this->rights = new stdClass(); + $this->rights->user = new stdClass(); + $this->rights->user->user = new stdClass(); + $this->rights->user->self = new stdClass(); } /** @@ -222,7 +223,7 @@ class User extends CommonObject * @param int $entity If a value is >= 0, we force the search on a specific entity. If -1, means search depens on default setup. * @return int <0 if KO, 0 not found, >0 if OK */ - function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 0, $entity = -1) + public function fetch($id = '', $login = '', $sid = '', $loadpersonalconf = 0, $entity = -1) { global $conf, $user; @@ -324,17 +325,17 @@ class User extends CommonObject $this->zip = $obj->zip; $this->town = $obj->town; - $this->country_id = $obj->country_id; + $this->country_id = $obj->country_id; $this->country_code = $obj->country_id?$obj->country_code:''; - //$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; + //$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->transnoentities('Country'.$obj->country_code):$obj->country):''; $this->state_id = $obj->state_id; $this->state_code = $obj->state_code; $this->state = ($obj->state!='-'?$obj->state:''); $this->office_phone = $obj->office_phone; - $this->office_fax = $obj->office_fax; - $this->user_mobile = $obj->user_mobile; + $this->office_fax = $obj->office_fax; + $this->user_mobile = $obj->user_mobile; $this->email = $obj->email; $this->skype = $obj->skype; $this->twitter = $obj->twitter; @@ -349,14 +350,14 @@ class User extends CommonObject $this->openid = $obj->openid; $this->lang = $obj->lang; $this->entity = $obj->entity; - $this->accountancy_code = $obj->accountancy_code; + $this->accountancy_code = $obj->accountancy_code; $this->thm = $obj->thm; $this->tjm = $obj->tjm; $this->salary = $obj->salary; - $this->salaryextra = $obj->salaryextra; - $this->weeklyhours = $obj->weeklyhours; - $this->color = $obj->color; - $this->dateemployment = $this->db->jdate($obj->dateemployment); + $this->salaryextra = $obj->salaryextra; + $this->weeklyhours = $obj->weeklyhours; + $this->color = $obj->color; + $this->dateemployment = $this->db->jdate($obj->dateemployment); $this->dateemploymentend = $this->db->jdate($obj->dateemploymentend); $this->datec = $this->db->jdate($obj->datec); @@ -364,16 +365,16 @@ class User extends CommonObject $this->datelastlogin = $this->db->jdate($obj->datel); $this->datepreviouslogin = $this->db->jdate($obj->datep); - $this->societe_id = $obj->fk_soc; // deprecated - $this->contact_id = $obj->fk_socpeople; // deprecated + $this->societe_id = $obj->fk_soc; // deprecated + $this->contact_id = $obj->fk_socpeople; // deprecated $this->socid = $obj->fk_soc; $this->contactid = $obj->fk_socpeople; $this->fk_member = $obj->fk_member; $this->fk_user = $obj->fk_user; - $this->default_range = $obj->default_range; - $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; - $this->fk_warehouse = $obj->fk_warehouse; + $this->default_range = $obj->default_range; + $this->default_c_exp_tax_cat = $obj->default_c_exp_tax_cat; + $this->fk_warehouse = $obj->fk_warehouse; // Protection when module multicompany was set, admin was set to first entity and then, the module was disabled, // in such case, this admin user must be admin for ALL entities. @@ -445,7 +446,7 @@ class User extends CommonObject * * @return int > 0 if OK, < 0 if KO */ - function loadDefaultValues() + public function loadDefaultValues() { global $conf; @@ -507,7 +508,7 @@ class User extends CommonObject * @return int > 0 if OK, < 0 if KO * @see clearrights, delrights, getrights */ - function addrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) + public function addrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) { global $conf, $user, $langs; @@ -633,7 +634,7 @@ class User extends CommonObject * @return int > 0 if OK, < 0 if OK * @see clearrights, addrights, getrights */ - function delrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) + public function delrights($rid, $allmodule = '', $allperms = '', $entity = 0, $notrigger = 0) { global $conf, $user, $langs; @@ -643,8 +644,7 @@ class User extends CommonObject $this->db->begin(); - if (! empty($rid)) - { + if (! empty($rid)) { // Si on a demande supression d'un droit en particulier, on recupere // les caracteristiques module, perms et subperms de ce droit. $sql = "SELECT module, perms, subperms"; @@ -669,8 +669,7 @@ class User extends CommonObject // Suppression des droits induits if ($subperms=='lire' || $subperms=='read') $wherefordel.=" OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)"; if ($perms=='lire' || $perms=='read') $wherefordel.=" OR (module='$module')"; - } - else { + } else { // On a demande suppression d'un droit sur la base d'un nom de module ou perms // Where pour la liste des droits a supprimer if (! empty($allmodule)) @@ -751,7 +750,7 @@ class User extends CommonObject * @return void * @see getrights */ - function clearrights() + public function clearrights() { dol_syslog(get_class($this)."::clearrights reset user->rights"); $this->rights=''; @@ -768,7 +767,7 @@ class User extends CommonObject * @return void * @see clearrights, delrights, addrights */ - function getrights($moduletag = '', $forcereload = 0) + public function getrights($moduletag = '', $forcereload = 0) { global $conf; @@ -925,7 +924,7 @@ class User extends CommonObject * @param int $statut Status to set * @return int <0 if KO, 0 if nothing is done, >0 if OK */ - function setstatus($statut) + public function setstatus($statut) { global $conf,$langs,$user; @@ -1016,7 +1015,7 @@ class User extends CommonObject * @param User $user User than delete * @return int <0 if KO, >0 if OK */ - function delete(User $user) + public function delete(User $user) { global $conf,$langs; @@ -1059,12 +1058,12 @@ class User extends CommonObject // Remove extrafields if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } } // Remove user @@ -1108,7 +1107,7 @@ class User extends CommonObject * @param int $notrigger 1=do not execute triggers, 0 otherwise * @return int <0 if KO, id of created user if OK */ - function create($user, $notrigger = 0) + public function create($user, $notrigger = 0) { global $conf,$langs; global $mysoc; @@ -1233,7 +1232,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user from a contact object. User will be internal but if contact is linked to a third party, user will be external * @@ -1242,7 +1241,7 @@ class User extends CommonObject * @param string $password Password to force * @return int <0 if error, if OK returns id of created user */ - function create_from_contact($contact, $login = '', $password = '') + public function create_from_contact($contact, $login = '', $password = '') { // phpcs:enable global $conf,$user,$langs; @@ -1250,24 +1249,24 @@ class User extends CommonObject $error=0; // Define parameters - $this->admin = 0; - $this->lastname = $contact->lastname; - $this->firstname = $contact->firstname; - $this->gender = $contact->gender; - $this->email = $contact->email; - $this->skype = $contact->skype; - $this->twitter = $contact->twitter; - $this->facebook = $contact->facebook; - $this->linkedin = $contact->linkedin; - $this->office_phone = $contact->phone_pro; - $this->office_fax = $contact->fax; - $this->user_mobile = $contact->phone_mobile; - $this->address = $contact->address; - $this->zip = $contact->zip; - $this->town = $contact->town; - $this->state_id = $contact->state_id; - $this->country_id = $contact->country_id; - $this->employee = 0; + $this->admin = 0; + $this->lastname = $contact->lastname; + $this->firstname = $contact->firstname; + $this->gender = $contact->gender; + $this->email = $contact->email; + $this->skype = $contact->skype; + $this->twitter = $contact->twitter; + $this->facebook = $contact->facebook; + $this->linkedin = $contact->linkedin; + $this->office_phone = $contact->phone_pro; + $this->office_fax = $contact->fax; + $this->user_mobile = $contact->phone_mobile; + $this->address = $contact->address; + $this->zip = $contact->zip; + $this->town = $contact->town; + $this->state_id = $contact->state_id; + $this->country_id = $contact->country_id; + $this->employee = 0; if (empty($login)) $login=strtolower(substr($contact->firstname, 0, 4)) . strtolower(substr($contact->lastname, 0, 4)); $this->login = $login; @@ -1315,7 +1314,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Create a user into database from a member object * @@ -1323,7 +1322,7 @@ class User extends CommonObject * @param string $login Login to force * @return int <0 if KO, if OK, return id of created account */ - function create_from_member($member, $login = '') + public function create_from_member($member, $login = '') { // phpcs:enable global $conf,$user,$langs; @@ -1390,13 +1389,13 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Assign rights by default * * @return integer erreur <0, si ok renvoi le nbre de droits par defaut positionnes */ - function set_default_rights() + public function set_default_rights() { // phpcs:enable global $conf; @@ -1445,7 +1444,7 @@ class User extends CommonObject * @param int $nosynccontact 0=Synchronize linked contact, 1=Do not synchronize linked contact * @return int <0 si KO, >=0 si OK */ - function update($user, $notrigger = 0, $nosyncmember = 0, $nosyncmemberpass = 0, $nosynccontact = 0) + public function update($user, $notrigger = 0, $nosyncmember = 0, $nosyncmemberpass = 0, $nosynccontact = 0) { global $conf, $langs; @@ -1487,8 +1486,8 @@ class User extends CommonObject $this->zip = empty($this->zip)?'':$this->zip; $this->town = empty($this->town)?'':$this->town; $this->accountancy_code = trim($this->accountancy_code); - $this->color = empty($this->color)?'':$this->color; - $this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment; + $this->color = empty($this->color)?'':$this->color; + $this->dateemployment = empty($this->dateemployment)?'':$this->dateemployment; $this->dateemploymentend = empty($this->dateemploymentend)?'':$this->dateemploymentend; $this->fk_warehouse = trim(empty($this->fk_warehouse)?'':$this->fk_warehouse); @@ -1746,14 +1745,14 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mise a jour en base de la date de derniere connexion d'un utilisateur * Fonction appelee lors d'une nouvelle connexion * * @return <0 si echec, >=0 si ok */ - function update_last_login_date() + public function update_last_login_date() { // phpcs:enable $now=dol_now(); @@ -1790,7 +1789,7 @@ class User extends CommonObject * @param int $nosyncmember Do not synchronize linked member * @return string If OK return clear password, 0 if no change, < 0 if error */ - function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) + public function setPassword($user, $password = '', $changelater = 0, $notrigger = 0, $nosyncmember = 0) { global $conf, $langs; require_once DOL_DOCUMENT_ROOT .'/core/lib/security2.lib.php'; @@ -1913,7 +1912,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Send new password by email * @@ -1922,7 +1921,7 @@ class User extends CommonObject * @param int $changelater 0=Send clear passwod into email, 1=Change password only after clicking on confirm email. @TODO Add method 2 = Send link to reset password * @return int < 0 si erreur, > 0 si ok */ - function send_password($user, $password = '', $changelater = 0) + public function send_password($user, $password = '', $changelater = 0) { // phpcs:enable global $conf, $langs; @@ -1990,8 +1989,8 @@ class User extends CommonObject dol_syslog(get_class($this)."::send_password changelater is on, url=".$url); } - $mailfile = new CMailFile( - $subject, + $mailfile = new CMailFile( + $subject, $this->email, $conf->global->MAIN_MAIL_EMAIL_FROM, $mesg, @@ -2001,8 +2000,8 @@ class User extends CommonObject '', '', 0, - $msgishtml - ); + $msgishtml + ); if ($mailfile->sendfile()) { @@ -2021,19 +2020,19 @@ class User extends CommonObject * * @return string chaine erreur */ - function error() + public function error() { return $this->error; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Read clicktodial information for user * * @return <0 if KO, >0 if OK */ - function fetch_clicktodial() + public function fetch_clicktodial() { // phpcs:enable $sql = "SELECT url, login, pass, poste "; @@ -2065,14 +2064,14 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update clicktodial info * * @return integer - */ - function update_clicktodial() - { + */ + public function update_clicktodial() + { // phpcs:enable $this->db->begin(); @@ -2103,10 +2102,10 @@ class User extends CommonObject $this->error=$this->db->lasterror(); return -1; } - } + } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Add user into a group * @@ -2115,7 +2114,7 @@ class User extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function SetInGroup($group, $entity, $notrigger = 0) + public function SetInGroup($group, $entity, $notrigger = 0) { // phpcs:enable global $conf, $langs, $user; @@ -2168,7 +2167,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Remove a user from a group * @@ -2177,7 +2176,7 @@ class User extends CommonObject * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function RemoveFromGroup($group, $entity, $notrigger = 0) + public function RemoveFromGroup($group, $entity, $notrigger = 0) { // phpcs:enable global $conf,$langs,$user; @@ -2237,7 +2236,7 @@ class User extends CommonObject * @param string $imagesize 'mini', 'small' or '' (original) * @return string String with URL link */ - function getPhotoUrl($width, $height, $cssclass = '', $imagesize = '') + public function getPhotoUrl($width, $height, $cssclass = '', $imagesize = '') { $result =''; $result.=Form::showphoto('userphoto', $this, $width, $height, 0, $cssclass, $imagesize); @@ -2261,7 +2260,7 @@ class User extends CommonObject * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpictoimg = 0, $option = '', $infologin = 0, $notooltip = 0, $maxlen = 24, $hidethirdpartylogo = 0, $mode = '', $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpictoimg = 0, $option = '', $infologin = 0, $notooltip = 0, $maxlen = 24, $hidethirdpartylogo = 0, $mode = '', $morecss = '', $save_lastsearch_value = -1) { global $langs, $conf, $db, $hookmanager, $user; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -2398,7 +2397,7 @@ class User extends CommonObject * @param string $option Sur quoi pointe le lien * @return string Chaine avec URL */ - function getLoginUrl($withpicto = 0, $option = '') + public function getLoginUrl($withpicto = 0, $option = '') { global $langs, $user; @@ -2435,21 +2434,21 @@ class User extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->statut, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps - /** - * Renvoi le libelle d'un statut donne - * - * @param int $statut Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status - */ - function LibStatut($statut, $mode = 0) - { + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $statut Id statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Label of status + */ + public function LibStatut($statut, $mode = 0) + { // phpcs:enable global $langs; $langs->load('users'); @@ -2487,7 +2486,7 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -2497,7 +2496,7 @@ class User extends CommonObject * 2=Return key only (RDN) (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -2508,13 +2507,13 @@ class User extends CommonObject return $dn; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialize the info array (array of LDAP values) that will be used to call LDAP functions * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -2637,7 +2636,7 @@ class User extends CommonObject * * @return void */ - function initAsSpecimen() + public function initAsSpecimen() { global $user,$langs; @@ -2683,7 +2682,7 @@ class User extends CommonObject * @param int $id Id of user to load * @return void */ - function info($id) + public function info($id) { $sql = "SELECT u.rowid, u.login as ref, u.datec,"; $sql.= " u.tms as date_modification, u.entity"; @@ -2699,10 +2698,10 @@ class User extends CommonObject $this->id = $obj->rowid; - $this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref; - $this->date_creation = $this->db->jdate($obj->datec); + $this->ref = (! $obj->ref) ? $obj->rowid : $obj->ref; + $this->date_creation = $this->db->jdate($obj->datec); $this->date_modification = $this->db->jdate($obj->date_modification); - $this->entity = $obj->entity; + $this->entity = $obj->entity; } $this->db->free($result); @@ -2719,7 +2718,7 @@ class User extends CommonObject * * @return int Number of EMailings */ - function getNbOfEMailings() + public function getNbOfEMailings() { $sql = "SELECT count(mc.email) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; @@ -2750,7 +2749,7 @@ class User extends CommonObject * @param int $admin Filter on admin tag * @return int Number of users */ - function getNbOfUsers($limitTo, $option = '', $admin = -1) + public function getNbOfUsers($limitTo, $option = '', $admin = -1) { global $conf; @@ -2784,7 +2783,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Update user using data from the LDAP * @@ -2792,7 +2791,7 @@ class User extends CommonObject * * @return int <0 if KO, >0 if OK */ - function update_ldap2dolibarr(&$ldapuser) + public function update_ldap2dolibarr(&$ldapuser) { // phpcs:enable // TODO: Voir pourquoi le update met à jour avec toutes les valeurs vide (global $user écrase ?) @@ -2825,14 +2824,14 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return and array with all instanciated first level children users of current user * * @return void * @see getAllChildIds */ - function get_children() + public function get_children() { // phpcs:enable $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."user"; @@ -2860,9 +2859,9 @@ class User extends CommonObject /** - * Load this->parentof that is array(id_son=>id_parent, ...) + * Load this->parentof that is array(id_son=>id_parent, ...) * - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ private function loadParentOf() { @@ -2893,7 +2892,7 @@ class User extends CommonObject } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Reconstruit l'arborescence hierarchique des users sous la forme d'un tableau * Set and return this->users that is an array sorted according to tree with arrays of: @@ -2907,8 +2906,8 @@ class User extends CommonObject * @param string $filter SQL filter on users * @return array Array of users $this->users. Note: $this->parentof is also set. */ - function get_full_tree($deleteafterid = 0, $filter = '') - { + public function get_full_tree($deleteafterid = 0, $filter = '') + { // phpcs:enable global $conf, $user; global $hookmanager; @@ -3009,8 +3008,8 @@ class User extends CommonObject * @return array Array of user id lower than user (all levels under user). This overwrite this->users. * @see get_children */ - function getAllChildIds($addcurrentuser = 0) - { + public function getAllChildIds($addcurrentuser = 0) + { $childids=array(); if (isset($this->cache_childids[$this->id])) @@ -3038,7 +3037,7 @@ class User extends CommonObject return $childids; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * For user id_user and its childs available in this->users, define property fullpath and fullname. * Function called by get_full_tree(). @@ -3047,8 +3046,8 @@ class User extends CommonObject * @param int $protection Deep counter to avoid infinite loop (no more required, a protection is added with array useridfound) * @return int < 0 if KO (infinit loop), >= 0 if OK */ - function build_path_from_id_user($id_user, $protection = 0) - { + public function build_path_from_id_user($id_user, $protection = 0) + { // phpcs:enable dol_syslog(get_class($this)."::build_path_from_id_user id_user=".$id_user." protection=".$protection, LOG_DEBUG); @@ -3102,13 +3101,13 @@ class User extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Charge indicateurs this->nb pour le tableau de bord * * @return int <0 if KO, >0 if OK */ - function load_state_board() + public function load_state_board() { // phpcs:enable global $conf; @@ -3174,7 +3173,7 @@ class User extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return property of user from its id * @@ -3182,7 +3181,7 @@ class User extends CommonObject * @param string $mode 'email' or 'mobile' * @return string Email of user with format: "Full name " */ - function user_get_property($rowid, $mode) + public function user_get_property($rowid, $mode) { // phpcs:enable $user_property=''; @@ -3224,9 +3223,9 @@ class User extends CommonObject * @param string $filtermode Filter mode (AND or OR) * @return int <0 if KO, >0 if OK */ - function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array(), $filtermode = 'AND') - { - global $conf; + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = array(), $filtermode = 'AND') + { + global $conf; $sql="SELECT t.rowid"; $sql.= ' FROM '.MAIN_DB_PREFIX .$this->table_element.' as t '; @@ -3279,8 +3278,8 @@ class User extends CommonObject } else { - $this->errors[] = $this->db->lasterror(); - return -1; - } - } + $this->errors[] = $this->db->lasterror(); + return -1; + } + } } diff --git a/htdocs/user/class/userbankaccount.class.php b/htdocs/user/class/userbankaccount.class.php index 8e9ad2745c3..18c1ab742a1 100644 --- a/htdocs/user/class/userbankaccount.class.php +++ b/htdocs/user/class/userbankaccount.class.php @@ -34,16 +34,16 @@ require_once DOL_DOCUMENT_ROOT .'/compta/bank/class/account.class.php'; */ class UserBankAccount extends Account { - var $socid; + public $socid; - var $datec; - var $datem; + public $datec; + public $datem; /** - * Constructor - * - * @param DoliDB $db Database handler + * Constructor + * + * @param DoliDB $db Database handler */ public function __construct(DoliDB $db) { @@ -62,7 +62,7 @@ class UserBankAccount extends Account * @param int $notrigger 1=Disable triggers * @return int <0 if KO, >= 0 if OK */ - function create(User $user = null, $notrigger = 0) + public function create(User $user = null, $notrigger = 0) { $now=dol_now(); @@ -92,9 +92,9 @@ class UserBankAccount extends Account * @param int $notrigger 1=Disable triggers * @return int <=0 if KO, >0 if OK */ - function update(User $user = null, $notrigger = 0) + public function update(User $user = null, $notrigger = 0) { - global $conf; + global $conf; if (! $this->id) { @@ -113,7 +113,7 @@ class UserBankAccount extends Account $sql.= ",proprio = '".$this->db->escape($this->proprio)."'"; $sql.= ",owner_address = '".$this->db->escape($this->owner_address)."'"; - if (trim($this->label) != '') + if (trim($this->label) != '') $sql.= ",label = '".$this->db->escape($this->label)."'"; else $sql.= ",label = NULL"; @@ -139,7 +139,7 @@ class UserBankAccount extends Account * @param int $userid User id * @return int <0 if KO, >0 if OK */ - function fetch($id, $ref = '', $userid = 0) + public function fetch($id, $ref = '', $userid = 0) { if (empty($id) && empty($ref) && empty($userid)) return -1; @@ -157,21 +157,21 @@ class UserBankAccount extends Account { $obj = $this->db->fetch_object($resql); - $this->id = $obj->rowid; - $this->socid = $obj->fk_soc; - $this->bank = $obj->bank; - $this->code_banque = $obj->code_banque; - $this->code_guichet = $obj->code_guichet; - $this->number = $obj->number; - $this->cle_rib = $obj->cle_rib; - $this->bic = $obj->bic; - $this->iban = $obj->iban; - $this->domiciliation = $obj->domiciliation; - $this->proprio = $obj->proprio; - $this->owner_address = $obj->owner_address; - $this->label = $obj->label; - $this->datec = $this->db->jdate($obj->datec); - $this->datem = $this->db->jdate($obj->datem); + $this->id = $obj->rowid; + $this->socid = $obj->fk_soc; + $this->bank = $obj->bank; + $this->code_banque = $obj->code_banque; + $this->code_guichet = $obj->code_guichet; + $this->number = $obj->number; + $this->cle_rib = $obj->cle_rib; + $this->bic = $obj->bic; + $this->iban = $obj->iban; + $this->domiciliation = $obj->domiciliation; + $this->proprio = $obj->proprio; + $this->owner_address = $obj->owner_address; + $this->label = $obj->label; + $this->datec = $this->db->jdate($obj->datec); + $this->datem = $this->db->jdate($obj->datem); } $this->db->free($resql); @@ -184,25 +184,25 @@ class UserBankAccount extends Account } } - /** - * Return RIB - * - * @param boolean $displayriblabel Prepend or Hide Label - * @return string RIB - */ - public function getRibLabel($displayriblabel = true) - { - $rib = ''; + /** + * Return RIB + * + * @param boolean $displayriblabel Prepend or Hide Label + * @return string RIB + */ + public function getRibLabel($displayriblabel = true) + { + $rib = ''; - if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) { + if ($this->code_banque || $this->code_guichet || $this->number || $this->cle_rib) { - if ($this->label && $displayriblabel) { - $rib = $this->label." : "; - } + if ($this->label && $displayriblabel) { + $rib = $this->label." : "; + } - $rib .= (string) $this; - } + $rib .= (string) $this; + } - return $rib; - } + return $rib; + } } diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index 4b199b4671d..cb63e99c5b2 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -1,5 +1,5 @@ +/* Copyright (c) 2005 Rodolphe Quiedeville * Copyright (c) 2005-2018 Laurent Destailleur * Copyright (c) 2005-2018 Regis Houssin * Copyright (C) 2012 Florian Henry @@ -91,23 +91,23 @@ class UserGroup extends CommonObject * Constructor de la classe * * @param DoliDb $db Database handler - */ - function __construct($db) - { - $this->db = $db; - $this->nb_rights = 0; - } + */ + public function __construct($db) + { + $this->db = $db; + $this->nb_rights = 0; + } /** - * Charge un objet group avec toutes ces caracteristiques (except ->members array) + * Charge un objet group avec toutes ces caracteristiques (except ->members array) * * @param int $id Id of group to load * @param string $groupname Name of group to load * @param boolean $load_members Load all members of the group * @return int <0 if KO, >0 if OK */ - function fetch($id = '', $groupname = '', $load_members = true) + public function fetch($id = '', $groupname = '', $load_members = true) { global $conf; @@ -163,13 +163,13 @@ class UserGroup extends CommonObject /** - * Return array of groups objects for a particular user + * Return array of groups objects for a particular user * - * @param int $userid User id to search + * @param int $userid User id to search * @param boolean $load_members Load all members of the group - * @return array Array of groups objects + * @return array Array of groups objects */ - function listGroupsForUser($userid, $load_members = true) + public function listGroupsForUser($userid, $load_members = true) { global $conf, $user; @@ -224,7 +224,7 @@ class UserGroup extends CommonObject * @param int $mode 0=Return array of user instance, 1=Return array of users id only * @return mixed Array of users or -1 on error */ - function listUsersForGroup($excludefilter = '', $mode = 0) + public function listUsersForGroup($excludefilter = '', $mode = 0) { global $conf, $user; @@ -289,7 +289,7 @@ class UserGroup extends CommonObject * @param int $entity Entity to use * @return int > 0 if OK, < 0 if KO */ - function addrights($rid, $allmodule = '', $allperms = '', $entity = 0) + public function addrights($rid, $allmodule = '', $allperms = '', $entity = 0) { global $conf, $user, $langs; @@ -415,7 +415,7 @@ class UserGroup extends CommonObject * @param int $entity Entity to use * @return int > 0 if OK, < 0 if OK */ - function delrights($rid, $allmodule = '', $allperms = '', $entity = 0) + public function delrights($rid, $allmodule = '', $allperms = '', $entity = 0) { global $conf, $user, $langs; @@ -456,8 +456,7 @@ class UserGroup extends CommonObject // Pour compatibilite, si lowid = 0, on est en mode suppression de tout // TODO A virer quand sera gere par l'appelant //if (substr($rid,-1,1) == 0) $wherefordel="module='$module'"; - } - else { + } else { // Where pour la liste des droits a supprimer if (! empty($allmodule)) { @@ -535,9 +534,9 @@ class UserGroup extends CommonObject * Charge dans l'objet group, la liste des permissions auquels le groupe a droit * * @param string $moduletag Name of module we want permissions ('' means all) - * @return int <0 if KO, >0 if OK + * @return int <0 if KO, >0 if OK */ - function getrights($moduletag = '') + public function getrights($moduletag = '') { global $conf; @@ -622,7 +621,7 @@ class UserGroup extends CommonObject * @param User $user User that delete * @return <0 if KO, > 0 if OK */ - function delete(User $user) + public function delete(User $user) { global $conf,$langs; @@ -638,15 +637,15 @@ class UserGroup extends CommonObject $sql .= " WHERE fk_usergroup = ".$this->id; $this->db->query($sql); - // Remove extrafields - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used + // Remove extrafields + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); + } } $sql = "DELETE FROM ".MAIN_DB_PREFIX."usergroup"; @@ -676,7 +675,7 @@ class UserGroup extends CommonObject * @param int $notrigger 0=triggers enabled, 1=triggers disabled * @return int <0 if KO, >=0 if OK */ - function create($notrigger = 0) + public function create($notrigger = 0) { global $user, $conf, $langs, $hookmanager; @@ -747,7 +746,7 @@ class UserGroup extends CommonObject * @param int $notrigger 0=triggers enabled, 1=triggers disabled * @return int <0 if KO, >=0 if OK */ - function update($notrigger = 0) + public function update($notrigger = 0) { global $user, $conf, $langs, $hookmanager; @@ -817,12 +816,12 @@ class UserGroup extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut(0, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un statut donne * @@ -830,7 +829,7 @@ class UserGroup extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($statut, $mode = 0) + public function LibStatut($statut, $mode = 0) { // phpcs:enable global $langs; @@ -840,16 +839,16 @@ class UserGroup extends CommonObject /** * Return a link to the user card (with optionaly the picto) - * Use this->id,this->lastname, this->firstname + * Use this->id,this->lastname, this->firstname * - * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) - * @param string $option On what the link point to ('nolink', ) + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small) + * @param string $option On what the link point to ('nolink', ) * @param integer $notooltip 1=Disable tooltip on picto and name * @param string $morecss Add more css on link * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { global $langs, $conf, $db, $hookmanager; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -915,7 +914,7 @@ class UserGroup extends CommonObject return $result; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Retourne chaine DN complete dans l'annuaire LDAP pour l'objet * @@ -925,7 +924,7 @@ class UserGroup extends CommonObject * 2=Return key only (uid=qqq) * @return string DN */ - function _load_ldap_dn($info, $mode = 0) + private function _load_ldap_dn($info, $mode = 0) { // phpcs:enable global $conf; @@ -937,13 +936,13 @@ class UserGroup extends CommonObject } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Initialize the info array (array of LDAP values) that will be used to call LDAP functions * * @return array Tableau info des attributs */ - function _load_ldap_info() + private function _load_ldap_info() { // phpcs:enable global $conf,$langs; @@ -979,8 +978,8 @@ class UserGroup extends CommonObject * id must be 0 if object instance is a specimen. * * @return void - */ - function initAsSpecimen() + */ + public function initAsSpecimen() { global $conf, $user, $langs; @@ -994,11 +993,11 @@ class UserGroup extends CommonObject $this->datec=time(); $this->datem=time(); - // Members of this group is just me - $this->members=array( - $user->id => $user - ); - } + // Members of this group is just me + $this->members=array( + $user->id => $user + ); + } /** * Create a document onto disk according to template module. diff --git a/htdocs/variants/class/ProductAttributeValue.class.php b/htdocs/variants/class/ProductAttributeValue.class.php index e5257c5fd0a..09c733e3dc7 100644 --- a/htdocs/variants/class/ProductAttributeValue.class.php +++ b/htdocs/variants/class/ProductAttributeValue.class.php @@ -63,7 +63,7 @@ class ProductAttributeValue $this->db = $db; $this->entity = $conf->entity; - } + } /** * Gets a product attribute value diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 9d36449da30..6bfbadfb197 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -134,15 +134,15 @@ class Website extends CommonObject if (isset($this->status)) { $this->status = (int) $this->status; } - if (empty($this->date_creation)) { + if (empty($this->date_creation)) { $this->date_creation = $now; } - if (empty($this->date_modification)) { + if (empty($this->date_modification)) { $this->date_modification = $now; } - // Check parameters - if (empty($this->entity)) { + // Check parameters + if (empty($this->entity)) { $this->entity = $conf->entity; } @@ -671,7 +671,7 @@ class Website extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $langs, $conf, $db; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -707,12 +707,12 @@ class Website extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un status donne * @@ -720,7 +720,7 @@ class Website extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -728,27 +728,27 @@ class Website extends CommonObject if ($mode == 0 || $mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } @@ -783,7 +783,7 @@ class Website extends CommonObject * * @return string Path to file with zip */ - function exportWebSite() + public function exportWebSite() { global $conf, $mysoc; @@ -958,7 +958,7 @@ class Website extends CommonObject * @param string $pathtofile Path of zip file * @return int <0 if KO, Id of new website if OK */ - function importWebSite($pathtofile) + public function importWebSite($pathtofile) { global $conf, $mysoc; @@ -1195,22 +1195,22 @@ class Website extends CommonObject $out.= ''; } $i=0; - if (is_array($languagecodes)) - { - foreach($languagecodes as $languagecode) - { - if ($languagecode == $languagecodeselected) continue; // Already output - $shortcode = strtolower(substr($languagecode, -2)); - $label = $weblangs->trans("Language_".$languagecode); - if ($shortcode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label); - $out.= '
  • '.$label; - if (empty($i) && empty($languagecodeselected)) $out.= ''; - $out.= '
  • '; - $i++; - } - } - $out.= ''; + if (is_array($languagecodes)) + { + foreach($languagecodes as $languagecode) + { + if ($languagecode == $languagecodeselected) continue; // Already output + $shortcode = strtolower(substr($languagecode, -2)); + $label = $weblangs->trans("Language_".$languagecode); + if ($shortcode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label); + $out.= '
  • '.$label; + if (empty($i) && empty($languagecodeselected)) $out.= ''; + $out.= '
  • '; + $i++; + } + } + $out.= ''; - return $out; - } + return $out; + } } diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 62a50ed1a56..8814756284c 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -148,12 +148,12 @@ class WebsitePage extends CommonObject /** * Load object in memory from the database * - * @param int $id Id object. - * - If this is 0, the value into $page will be used. If not found or $page not defined, the default page of website_id will be used or the first page found if not set. - * - If value is < 0, we must exclude this ID. - * @param string $website_id Web site id (page name must also be filled if this parameter is used) - * @param string $page Page name (website id must also be filled if this parameter is used) - * @param string $aliasalt Alternative alias to search page (slow) + * @param int $id Id object. + * - If this is 0, the value into $page will be used. If not found or $page not defined, the default page of website_id will be used or the first page found if not set. + * - If value is < 0, we must exclude this ID. + * @param string $website_id Web site id (page name must also be filled if this parameter is used) + * @param string $page Page name (website id must also be filled if this parameter is used) + * @param string $aliasalt Alternative alias to search page (slow) * * @return int <0 if KO, 0 if not found, >0 if OK */ @@ -472,7 +472,7 @@ class WebsitePage extends CommonObject * @param string $morecss Add more css on link * @return string String with URL */ - function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $maxlen = 24, $morecss = '') { global $langs, $conf, $db; global $dolibarr_main_authentication, $dolibarr_main_demo; @@ -507,12 +507,12 @@ class WebsitePage extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function getLibStatut($mode = 0) + public function getLibStatut($mode = 0) { return $this->LibStatut($this->status, $mode); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Renvoi le libelle d'un status donne * @@ -520,7 +520,7 @@ class WebsitePage extends CommonObject * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @return string Label of status */ - function LibStatut($status, $mode = 0) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; @@ -529,32 +529,32 @@ class WebsitePage extends CommonObject { $prefix=''; if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 1) { if ($status == 1) return $langs->trans('Enabled'); - if ($status == 0) return $langs->trans('Disabled'); + elseif ($status == 0) return $langs->trans('Disabled'); } elseif ($mode == 2) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 3) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); } elseif ($mode == 4) { if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - if ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); + elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); } elseif ($mode == 5) { if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - if ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); } } diff --git a/test/phpunit/AccountingAccountTest.php b/test/phpunit/AccountingAccountTest.php index 09a7a21d145..68332563e6c 100644 --- a/test/phpunit/AccountingAccountTest.php +++ b/test/phpunit/AccountingAccountTest.php @@ -57,9 +57,9 @@ class AccountingAccountTest extends PHPUnit\Framework\TestCase * * @return AccountingAccountTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); //$this->sharedFixture global $conf,$user,$langs,$db; @@ -187,19 +187,19 @@ class AccountingAccountTest extends PHPUnit\Framework\TestCase */ public function testAccountingAccountUpdate($localobject) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject->label='New label'; - $result=$localobject->update($user); + $localobject->label='New label'; + $result=$localobject->update($user); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject->id; } /** diff --git a/test/phpunit/ActionCommTest.php b/test/phpunit/ActionCommTest.php index 80bb9687529..f9c0928bad2 100644 --- a/test/phpunit/ActionCommTest.php +++ b/test/phpunit/ActionCommTest.php @@ -57,7 +57,7 @@ class ActionCommTest extends PHPUnit_Framework_TestCase * * @return ActionCommTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index f3ebb81ea7c..bd5ae5571cc 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -59,7 +59,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase * * @return AdherentTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/AdminLibTest.php b/test/phpunit/AdminLibTest.php index 9b405b5e360..bbf5ae2da00 100644 --- a/test/phpunit/AdminLibTest.php +++ b/test/phpunit/AdminLibTest.php @@ -57,7 +57,7 @@ class AdminLibTest extends PHPUnit_Framework_TestCase * * @return AdminLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/BankAccountTest.php b/test/phpunit/BankAccountTest.php index f8917a335ca..fa150742c4b 100644 --- a/test/phpunit/BankAccountTest.php +++ b/test/phpunit/BankAccountTest.php @@ -59,7 +59,7 @@ class BankAccountTest extends PHPUnit_Framework_TestCase * * @return BankAccountTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/BonPrelevementTest.php b/test/phpunit/BonPrelevementTest.php index 2ca1cfb431f..4ba05b2c0b6 100644 --- a/test/phpunit/BonPrelevementTest.php +++ b/test/phpunit/BonPrelevementTest.php @@ -60,7 +60,7 @@ class BonPrelevementTest extends PHPUnit_Framework_TestCase * * @return BankAccountTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index a4566c92f95..e8fa72a8f40 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -87,7 +87,7 @@ class BuildDocTest extends PHPUnit_Framework_TestCase * * @return BuildDocTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index bf365c7ddf7..b664b345c26 100755 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -57,7 +57,7 @@ class CMailFileTest extends PHPUnit_Framework_TestCase * * @return CMailFile */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index 005de68d3ef..80761a6e594 100644 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -58,7 +58,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase * * @return CategorieTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/ChargeSocialesTest.php b/test/phpunit/ChargeSocialesTest.php index b181c835b01..b037e50752d 100644 --- a/test/phpunit/ChargeSocialesTest.php +++ b/test/phpunit/ChargeSocialesTest.php @@ -31,9 +31,9 @@ require_once dirname(__FILE__).'/../../htdocs/compta/sociales/class/chargesocial if (empty($user->id)) { - print "Load permissions for admin user nb 1\n"; - $user->fetch(1); - $user->getrights(); + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); } $conf->global->MAIN_DISABLE_ALL_MAILS=1; @@ -47,74 +47,74 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; */ class ChargeSocialesTest extends PHPUnit_Framework_TestCase { - protected $savconf; - protected $savuser; - protected $savlangs; - protected $savdb; + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; - /** - * Constructor - * We save global variables into local variables - * - * @return ChargeSocialesTest - */ - function __construct() - { - parent::__construct(); - - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; - - print __METHOD__." db->type=".$db->type." user->id=".$user->id; - //print " - db ".$db->db; - print "\n"; - } - - // Static methods - public static function setUpBeforeClass() + /** + * Constructor + * We save global variables into local variables + * + * @return ChargeSocialesTest + */ + public function __construct() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + parent::__construct(); - print __METHOD__."\n"; + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; } // tear down after class public static function tearDownAfterClass() { - global $conf,$user,$langs,$db; - $db->rollback(); + global $conf,$user,$langs,$db; + $db->rollback(); - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * End phpunit tests - * - * @return void - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { - print __METHOD__."\n"; + print __METHOD__."\n"; } /** @@ -124,19 +124,19 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase */ public function testChargeSocialesCreate() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new ChargeSociales($this->savdb); - $localobject->initAsSpecimen(); - $result=$localobject->create($user, $langs, $conf); - print __METHOD__." result=".$result."\n"; + $localobject=new ChargeSociales($this->savdb); + $localobject->initAsSpecimen(); + $result=$localobject->create($user, $langs, $conf); + print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $result; + $this->assertLessThan($result, 0); + return $result; } /** @@ -150,18 +150,18 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase */ public function testChargeSocialesFetch($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new ChargeSociales($this->savdb); - $result=$localobject->fetch($id); - print __METHOD__." id=".$id." result=".$result."\n"; + $localobject=new ChargeSociales($this->savdb); + $result=$localobject->fetch($id); + print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $localobject; + $this->assertLessThan($result, 0); + return $localobject; } /** @@ -175,17 +175,17 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase */ public function testChargeSocialesValid($localobject) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $result=$localobject->set_paid($user); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $result=$localobject->set_paid($user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $localobject; + $this->assertLessThan($result, 0); + return $localobject; } /** @@ -213,7 +213,7 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThanOrEqual($result, 0); - return $localobject->id; + return $localobject->id; } /** @@ -227,18 +227,18 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase */ public function testChargeSocialesDelete($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new ChargeSociales($this->savdb); - $result=$localobject->fetch($id); - $result=$localobject->delete($id); + $localobject=new ChargeSociales($this->savdb); + $result=$localobject->fetch($id); + $result=$localobject->delete($id); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $result; + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $result; } } diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index fa424ba71a6..2a1dad01049 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -70,11 +70,11 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase * * @return SecurityTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -164,12 +164,12 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase preg_match_all('/(..)\s*\.\s*\$this->db->idate\(/', $filecontent, $matches, PREG_SET_ORDER); foreach($matches as $key => $val) { - if ($val[1] != '\'"' && $val[1] != '\'\'') - { - $ok=false; - break; - } - //if ($reg[0] != 'db') $ok=false; + if ($val[1] != '\'"' && $val[1] != '\'\'') + { + $ok=false; + break; + } + //if ($reg[0] != 'db') $ok=false; } //print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n"; $this->assertTrue($ok, 'Found a $this->db->idate to forge a sql request without quotes around this date field '.$file['fullname'].' :: '.$val[0]); @@ -201,7 +201,7 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase preg_match_all('/(..............)\$_SERVER\[\'QUERY_STRING\'\]/', $filecontent, $matches, PREG_SET_ORDER); foreach($matches as $key => $val) { - if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(') + if ($val[1] != 'scape_htmltag(' && $val[1] != 'ing_nohtmltag(' && $val[1] != 'dol_escape_js(') { $ok=false; break; @@ -217,8 +217,8 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase preg_match_all('/print_liste_field_titre\(\$langs/', $filecontent, $matches, PREG_SET_ORDER); foreach($matches as $key => $val) { - $ok=false; - break; + $ok=false; + break; } $this->assertTrue($ok, 'Found a use of print_liste_field_titre with fist parameter that is a translated value instead of just the translation key in file '.$file['fullname'].'. Bad.'); @@ -230,7 +230,7 @@ class CodingPhpTest extends PHPUnit_Framework_TestCase preg_match_all('/
    /', $filecontent, $matches, PREG_SET_ORDER); foreach($matches as $key => $val) { - if ($file['name'] != 'functions.lib.php') + if ($file['name'] != 'functions.lib.php') { $ok=false; break; diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 7c6d9e750b8..9c9655b1f5c 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -70,7 +70,7 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase * * @return SecurityTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index eeed83174c6..277328339ee 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -59,7 +59,7 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase * * @return CommandeFournisseurTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index 85e2b972cb5..00a0a4983c9 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -57,7 +57,7 @@ class CommandeTest extends PHPUnit_Framework_TestCase * * @return CommandeTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CommonInvoiceTest.php b/test/phpunit/CommonInvoiceTest.php index 4fab182ad69..2ce95dcafe1 100644 --- a/test/phpunit/CommonInvoiceTest.php +++ b/test/phpunit/CommonInvoiceTest.php @@ -57,7 +57,7 @@ class CommonInvoiceTest extends PHPUnit\Framework\TestCase * * @return CommonObjectTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CommonObjectTest.php b/test/phpunit/CommonObjectTest.php index 634573bc03f..549540bb0d0 100644 --- a/test/phpunit/CommonObjectTest.php +++ b/test/phpunit/CommonObjectTest.php @@ -58,7 +58,7 @@ class CommonObjectTest extends PHPUnit_Framework_TestCase * * @return CommonObjectTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/CompanyBankAccountTest.php b/test/phpunit/CompanyBankAccountTest.php index c50935c8aac..58eebfd0207 100644 --- a/test/phpunit/CompanyBankAccountTest.php +++ b/test/phpunit/CompanyBankAccountTest.php @@ -58,7 +58,7 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase * * @return CompanyBankAccountTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,13 +74,13 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/CompanyLibTest.php b/test/phpunit/CompanyLibTest.php index 1a08c4512e9..0fb1722aee9 100644 --- a/test/phpunit/CompanyLibTest.php +++ b/test/phpunit/CompanyLibTest.php @@ -57,7 +57,7 @@ class CompanyLibTest extends PHPUnit_Framework_TestCase * * @return AdminLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index edf103cb894..ef43bd06311 100755 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -66,7 +66,7 @@ class ContactTest extends PHPUnit_Framework_TestCase * * @return ContactTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -82,14 +82,14 @@ class ContactTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; + global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/ContratTest.php b/test/phpunit/ContratTest.php index 74b30e10268..c5342865979 100644 --- a/test/phpunit/ContratTest.php +++ b/test/phpunit/ContratTest.php @@ -31,9 +31,9 @@ require_once dirname(__FILE__).'/../../htdocs/contrat/class/contrat.class.php'; if (empty($user->id)) { - print "Load permissions for admin user nb 1\n"; - $user->fetch(1); - $user->getrights(); + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); } $conf->global->MAIN_DISABLE_ALL_MAILS=1; @@ -47,74 +47,74 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; */ class ContratTest extends PHPUnit_Framework_TestCase { - protected $savconf; - protected $savuser; - protected $savlangs; - protected $savdb; + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; - /** - * Constructor - * We save global variables into local variables - * - * @return ContratTest - */ - function __construct() - { - parent::__construct(); - - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; - - print __METHOD__." db->type=".$db->type." user->id=".$user->id; - //print " - db ".$db->db; - print "\n"; - } - - // Static methods - public static function setUpBeforeClass() + /** + * Constructor + * We save global variables into local variables + * + * @return ContratTest + */ + public function __construct() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + parent::__construct(); - print __METHOD__."\n"; + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; } // tear down after class public static function tearDownAfterClass() { - global $conf,$user,$langs,$db; - $db->rollback(); + global $conf,$user,$langs,$db; + $db->rollback(); - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * End phpunit tests - * - * @return void - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { - print __METHOD__."\n"; + print __METHOD__."\n"; } /** @@ -124,20 +124,20 @@ class ContratTest extends PHPUnit_Framework_TestCase */ public function testContratCreate() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Contrat($this->savdb); - $localobject->initAsSpecimen(); - $result=$localobject->create($user); + $localobject=new Contrat($this->savdb); + $localobject->initAsSpecimen(); + $result=$localobject->create($user); - print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + print __METHOD__." result=".$result."\n"; + $this->assertLessThan($result, 0); - return $result; + return $result; } /** @@ -151,19 +151,19 @@ class ContratTest extends PHPUnit_Framework_TestCase */ public function testContratFetch($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Contrat($this->savdb); - $result=$localobject->fetch($id); + $localobject=new Contrat($this->savdb); + $result=$localobject->fetch($id); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); - return $localobject; + return $localobject; } /** @@ -206,18 +206,18 @@ class ContratTest extends PHPUnit_Framework_TestCase */ public function testContratDelete($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Contrat($this->savdb); - $result=$localobject->fetch($id); - $result=$localobject->delete($user); + $localobject=new Contrat($this->savdb); + $result=$localobject->fetch($id); + $result=$localobject->delete($user); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $result; + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $result; } } diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php index 2d9697f9cfe..51a0f54698f 100644 --- a/test/phpunit/CoreTest.php +++ b/test/phpunit/CoreTest.php @@ -60,7 +60,7 @@ class CoreTest extends PHPUnit_Framework_TestCase * * @return CoreTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 44c1e77d9ae..6424cb4d8df 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -58,7 +58,7 @@ class DateLibTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,12 +75,12 @@ class DateLibTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/DateLibTzFranceTest.php b/test/phpunit/DateLibTzFranceTest.php index a59eb7bf242..fa7aef2bed8 100644 --- a/test/phpunit/DateLibTzFranceTest.php +++ b/test/phpunit/DateLibTzFranceTest.php @@ -58,7 +58,7 @@ class DateLibTzFranceTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,8 +74,8 @@ class DateLibTzFranceTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; diff --git a/test/phpunit/DiscountTest.php b/test/phpunit/DiscountTest.php index 724a97e6f3e..cd73a7ad173 100644 --- a/test/phpunit/DiscountTest.php +++ b/test/phpunit/DiscountTest.php @@ -58,7 +58,7 @@ class DiscountTest extends PHPUnit_Framework_TestCase * * @return DiscountTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,7 +75,7 @@ class DiscountTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/EntrepotTest.php b/test/phpunit/EntrepotTest.php index 1028fc2599d..9672123f103 100644 --- a/test/phpunit/EntrepotTest.php +++ b/test/phpunit/EntrepotTest.php @@ -58,7 +58,7 @@ class EntrepotTest extends PHPUnit_Framework_TestCase * * @return EntrepotTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,8 +74,8 @@ class EntrepotTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; diff --git a/test/phpunit/ExpenseReportTest.php b/test/phpunit/ExpenseReportTest.php index ed6ddf97fc7..dc053d8edb3 100644 --- a/test/phpunit/ExpenseReportTest.php +++ b/test/phpunit/ExpenseReportTest.php @@ -58,7 +58,7 @@ class ExpenseReportTest extends PHPUnit_Framework_TestCase * * @return ExpenseReportTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index 1b479cb1f30..7403cba3ddf 100644 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -62,7 +62,7 @@ class ExportTest extends PHPUnit_Framework_TestCase * * @return ExportTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -79,7 +79,7 @@ class ExportTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/FactureFournisseurTest.php b/test/phpunit/FactureFournisseurTest.php index 63c28945e65..2d6218471aa 100644 --- a/test/phpunit/FactureFournisseurTest.php +++ b/test/phpunit/FactureFournisseurTest.php @@ -59,7 +59,7 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase * * @return FactureFournisseurTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -76,7 +76,7 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/FactureRecTest.php b/test/phpunit/FactureRecTest.php index 720e1951788..de1bb164451 100644 --- a/test/phpunit/FactureRecTest.php +++ b/test/phpunit/FactureRecTest.php @@ -59,7 +59,7 @@ class FactureRecTest extends PHPUnit_Framework_TestCase * * @return FactureTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,10 +75,10 @@ class FactureRecTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; + global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. print __METHOD__."\n"; @@ -114,7 +114,7 @@ class FactureRecTest extends PHPUnit_Framework_TestCase * * @return void */ - protected function tearDown() + protected function tearDown() { print __METHOD__."\n"; } diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index 9ac4cd05f33..4f680ba32db 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -58,7 +58,7 @@ class FactureTest extends PHPUnit_Framework_TestCase * * @return FactureTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/FactureTestRounding.php b/test/phpunit/FactureTestRounding.php index dbaf598e1a0..a0df47cd97f 100644 --- a/test/phpunit/FactureTestRounding.php +++ b/test/phpunit/FactureTestRounding.php @@ -58,7 +58,7 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase * * @return FactureTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,7 +75,7 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. @@ -97,7 +97,7 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase * * @return void */ - protected function setUp() + protected function setUp() { global $conf,$user,$langs,$db; $conf=$this->savconf; @@ -113,7 +113,7 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase * * @return void */ - protected function tearDown() + protected function tearDown() { print __METHOD__."\n"; } diff --git a/test/phpunit/FichinterTest.php b/test/phpunit/FichinterTest.php index 5c966f4d4ec..35680559581 100644 --- a/test/phpunit/FichinterTest.php +++ b/test/phpunit/FichinterTest.php @@ -58,7 +58,7 @@ class FichinterTest extends PHPUnit_Framework_TestCase * * @return ContratTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,7 +75,7 @@ class FichinterTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index c1038271498..2411c5c9cf3 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -59,7 +59,7 @@ class FilesLibTest extends PHPUnit_Framework_TestCase * * @return FilesLibTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,8 +75,8 @@ class FilesLibTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/FormAdminTest.php b/test/phpunit/FormAdminTest.php index dc6ed409375..8532d6ac283 100644 --- a/test/phpunit/FormAdminTest.php +++ b/test/phpunit/FormAdminTest.php @@ -58,7 +58,7 @@ class FormAdminTest extends PHPUnit_Framework_TestCase * * @return FactureTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,7 +75,7 @@ class FormAdminTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. @@ -111,9 +111,9 @@ class FormAdminTest extends PHPUnit_Framework_TestCase /** * End phpunit tests * - * @return void - */ - protected function tearDown() + * @return void + */ + protected function tearDown() { print __METHOD__."\n"; } diff --git a/test/phpunit/Functions2LibTest.php b/test/phpunit/Functions2LibTest.php index 2f6a45e2599..50efabf9403 100644 --- a/test/phpunit/Functions2LibTest.php +++ b/test/phpunit/Functions2LibTest.php @@ -61,7 +61,7 @@ class Functions2LibTest extends PHPUnit_Framework_TestCase * * @return CoreTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 2ab796dfba8..5b2b65c9e50 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -61,11 +61,11 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase * * @return CoreTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -97,11 +97,11 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { global $conf,$user,$langs,$db; @@ -114,10 +114,10 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase } /** - * End phpunit tests - * - * @return void - */ + * End phpunit tests + * + * @return void + */ protected function tearDown() { print __METHOD__."\n"; @@ -131,22 +131,22 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testIsValidMXRecord() { - // Nb of line is same than entry text + // Nb of line is same than entry text - $input="yahoo.com"; - $result=isValidMXRecord($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals(1, $result); + $input="yahoo.com"; + $result=isValidMXRecord($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(1, $result); - $input="yhaoo.com"; - $result=isValidMXRecord($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals(0, $result); + $input="yhaoo.com"; + $result=isValidMXRecord($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(0, $result); - $input="dolibarr.fr"; - $result=isValidMXRecord($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals(0, $result); + $input="dolibarr.fr"; + $result=isValidMXRecord($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(0, $result); } /** @@ -156,87 +156,87 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolGetFirstLineOfText() { - // Nb of line is same than entry text + // Nb of line is same than entry text - $input="aaaa"; - $result=dolGetFirstLineOfText($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa", $result); + $input="aaaa"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa", $result); - $input="aaaa\nbbbbbbbbbbbb\n"; - $result=dolGetFirstLineOfText($input, 2); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); + $input="aaaa\nbbbbbbbbbbbb\n"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa\nbbbbbbbbbbbb", $result); - $input="aaaa
    bbbbbbbbbbbb
    "; - $result=dolGetFirstLineOfText($input, 2); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa
    \nbbbbbbbbbbbb", $result); + $input="aaaa
    bbbbbbbbbbbb
    "; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
    \nbbbbbbbbbbbb", $result); - // Nb of line is lower + // Nb of line is lower - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; - $result=dolGetFirstLineOfText($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa...", $result); + $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa...", $result); - $input="aaaa
    bbbbbbbbbbbb
    cccccc
    "; - $result=dolGetFirstLineOfText($input); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa...", $result); + $input="aaaa
    bbbbbbbbbbbb
    cccccc
    "; + $result=dolGetFirstLineOfText($input); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa...", $result); - $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; - $result=dolGetFirstLineOfText($input, 2); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); + $input="aaaa\nbbbbbbbbbbbb\ncccccc\n"; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa\nbbbbbbbbbbbb...", $result); - $input="aaaa
    bbbbbbbbbbbb
    cccccc
    "; - $result=dolGetFirstLineOfText($input, 2); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa
    \nbbbbbbbbbbbb...", $result); + $input="aaaa
    bbbbbbbbbbbb
    cccccc
    "; + $result=dolGetFirstLineOfText($input, 2); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
    \nbbbbbbbbbbbb...", $result); - // Nb of line is higher + // Nb of line is higher - $input="aaaa
    bbbbbbbbbbbb
    cccccc"; - $result=dolGetFirstLineOfText($input, 100); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa
    \nbbbbbbbbbbbb
    \ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); + $input="aaaa
    bbbbbbbbbbbb
    cccccc"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
    \nbbbbbbbbbbbb
    \ncccccc", $result, 'dolGetFirstLineOfText with nb 100 a'); - $input="aaaa
    bbbbbbbbbbbb
    cccccc
    "; - $result=dolGetFirstLineOfText($input, 100); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa
    \nbbbbbbbbbbbb
    \ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); + $input="aaaa
    bbbbbbbbbbbb
    cccccc
    "; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
    \nbbbbbbbbbbbb
    \ncccccc", $result, 'dolGetFirstLineOfText with nb 100 b'); - $input="aaaa
    bbbbbbbbbbbb
    cccccc
    \n"; - $result=dolGetFirstLineOfText($input, 100); - print __METHOD__." result=".$result."\n"; - $this->assertEquals("aaaa
    \nbbbbbbbbbbbb
    \ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); + $input="aaaa
    bbbbbbbbbbbb
    cccccc
    \n"; + $result=dolGetFirstLineOfText($input, 100); + print __METHOD__." result=".$result."\n"; + $this->assertEquals("aaaa
    \nbbbbbbbbbbbb
    \ncccccc", $result, 'dolGetFirstLineOfText with nb 100 c'); } - /** - * testDolBuildPath - * - * @return void - */ - public function testDolBuildPath() - { - /*$tmp=dol_buildpath('/google/oauth2callback.php', 0); - var_dump($tmp); - */ + /** + * testDolBuildPath + * + * @return void + */ + public function testDolBuildPath() + { + /*$tmp=dol_buildpath('/google/oauth2callback.php', 0); + var_dump($tmp); + */ - /*$tmp=dol_buildpath('/google/oauth2callback.php', 1); - var_dump($tmp); - */ + /*$tmp=dol_buildpath('/google/oauth2callback.php', 1); + var_dump($tmp); + */ - $result=dol_buildpath('/google/oauth2callback.php', 2); - print __METHOD__." result=".$result."\n"; - $this->assertStringStartsWith('http', $result); - - $result=dol_buildpath('/google/oauth2callback.php', 3); + $result=dol_buildpath('/google/oauth2callback.php', 2); print __METHOD__." result=".$result."\n"; $this->assertStringStartsWith('http', $result); - } + + $result=dol_buildpath('/google/oauth2callback.php', 3); + print __METHOD__." result=".$result."\n"; + $this->assertStringStartsWith('http', $result); + } /** @@ -246,82 +246,82 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testGetBrowserInfo() { - // MSIE 5.0 + // MSIE 5.0 $user_agent ='Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt; KITV4 Wanadoo; KITV5 Wanadoo)'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('ie', $tmp['browsername']); $this->assertEquals('5.0', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); - // Firefox 0.9.1 + // Firefox 0.9.1 $user_agent ='Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5a) Gecko/20030728 Mozilla Firefox/0.9.1'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('firefox', $tmp['browsername']); $this->assertEquals('0.9.1', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); $user_agent ='Mozilla/3.0 (Windows 98; U) Opera 6.03 [en]'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('opera', $tmp['browsername']); $this->assertEquals('6.03', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); $user_agent ='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('chrome', $tmp['browsername']); $this->assertEquals('19.0.1042.0', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); $user_agent ='chrome (Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11)'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('chrome', $tmp['browsername']); $this->assertEquals('17.0.963.56', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); $user_agent ='Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1'; $tmp=getBrowserInfo($user_agent); $this->assertEquals('safari', $tmp['browsername']); $this->assertEquals('533.21.1', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); - //Internet Explorer 11 - $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; - $tmp=getBrowserInfo($user_agent); - $this->assertEquals('ie', $tmp['browsername']); - $this->assertEquals('11.0', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + //Internet Explorer 11 + $user_agent = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; + $tmp=getBrowserInfo($user_agent); + $this->assertEquals('ie', $tmp['browsername']); + $this->assertEquals('11.0', $tmp['browserversion']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); - //Internet Explorer 11 bis - $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko'; - $tmp=getBrowserInfo($user_agent); - $this->assertEquals('ie', $tmp['browsername']); - $this->assertEquals('11.0', $tmp['browserversion']); - $this->assertEmpty($tmp['phone']); - $this->assertFalse($tmp['tablet']); - $this->assertEquals('classic', $tmp['layout']); + //Internet Explorer 11 bis + $user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; NP06; rv:11.0) like Gecko'; + $tmp=getBrowserInfo($user_agent); + $this->assertEquals('ie', $tmp['browsername']); + $this->assertEquals('11.0', $tmp['browserversion']); + $this->assertEmpty($tmp['phone']); + $this->assertFalse($tmp['tablet']); + $this->assertEquals('classic', $tmp['layout']); - //iPad - $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'; - $tmp=getBrowserInfo($user_agent); - $this->assertEquals('safari', $tmp['browsername']); - $this->assertEquals('8536.25', $tmp['browserversion']); - $this->assertEquals('ios', $tmp['browseros']); - $this->assertEquals('tablet', $tmp['layout']); - $this->assertEquals('iphone', $tmp['phone']); + //iPad + $user_agent = 'Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5355d Safari/8536.25'; + $tmp=getBrowserInfo($user_agent); + $this->assertEquals('safari', $tmp['browsername']); + $this->assertEquals('8536.25', $tmp['browserversion']); + $this->assertEquals('ios', $tmp['browseros']); + $this->assertEquals('tablet', $tmp['layout']); + $this->assertEquals('iphone', $tmp['phone']); } @@ -332,48 +332,48 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testGetLanguageCodeFromCountryCode() { - global $mysoc; + global $mysoc; - $language = getLanguageCodeFromCountryCode('US'); - $this->assertEquals('en_US', $language, 'US'); + $language = getLanguageCodeFromCountryCode('US'); + $this->assertEquals('en_US', $language, 'US'); - $language = getLanguageCodeFromCountryCode('ES'); - $this->assertEquals('es_ES', $language, 'ES'); + $language = getLanguageCodeFromCountryCode('ES'); + $this->assertEquals('es_ES', $language, 'ES'); - $language = getLanguageCodeFromCountryCode('CL'); - $this->assertEquals('es_CL', $language, 'CL'); + $language = getLanguageCodeFromCountryCode('CL'); + $this->assertEquals('es_CL', $language, 'CL'); - $language = getLanguageCodeFromCountryCode('CA'); - $this->assertEquals('en_CA', $language, 'CA'); + $language = getLanguageCodeFromCountryCode('CA'); + $this->assertEquals('en_CA', $language, 'CA'); - $language = getLanguageCodeFromCountryCode('MQ'); - $this->assertEquals('fr_CA', $language); + $language = getLanguageCodeFromCountryCode('MQ'); + $this->assertEquals('fr_CA', $language); - $language = getLanguageCodeFromCountryCode('FR'); - $this->assertEquals('fr_FR', $language); + $language = getLanguageCodeFromCountryCode('FR'); + $this->assertEquals('fr_FR', $language); - $language = getLanguageCodeFromCountryCode('BE'); - $this->assertEquals('fr_BE', $language); + $language = getLanguageCodeFromCountryCode('BE'); + $this->assertEquals('fr_BE', $language); - $mysoc->country_code = 'FR'; - $language = getLanguageCodeFromCountryCode('CH'); - $this->assertEquals('fr_CH', $language); + $mysoc->country_code = 'FR'; + $language = getLanguageCodeFromCountryCode('CH'); + $this->assertEquals('fr_CH', $language); - $mysoc->country_code = 'DE'; - $language = getLanguageCodeFromCountryCode('CH'); - $this->assertEquals('de_CH', $language); + $mysoc->country_code = 'DE'; + $language = getLanguageCodeFromCountryCode('CH'); + $this->assertEquals('de_CH', $language); - $language = getLanguageCodeFromCountryCode('DE'); - $this->assertEquals('de_DE', $language); + $language = getLanguageCodeFromCountryCode('DE'); + $this->assertEquals('de_DE', $language); - $language = getLanguageCodeFromCountryCode('SA'); - $this->assertEquals('ar_SA', $language); + $language = getLanguageCodeFromCountryCode('SA'); + $this->assertEquals('ar_SA', $language); - $language = getLanguageCodeFromCountryCode('SE'); - $this->assertEquals('sv_SE', $language); + $language = getLanguageCodeFromCountryCode('SE'); + $this->assertEquals('sv_SE', $language); - $language = getLanguageCodeFromCountryCode('DK'); - $this->assertEquals('da_DK', $language); + $language = getLanguageCodeFromCountryCode('DK'); + $this->assertEquals('da_DK', $language); } /** @@ -570,9 +570,9 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolHtmlEntitiesBr() { - // Text not already HTML + // Text not already HTML - $input="A string\nwith a é, &, < and >."; + $input="A string\nwith a é, &, < and >."; $after=dol_htmlentitiesbr($input, 0); // Add
    before \n $this->assertEquals("A string
    \nwith a é, &, < and >.", $after); @@ -645,9 +645,9 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolUnaccent() { - // Text not already HTML + // Text not already HTML - $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; + $input="A string\nwith a à ä é è ë ï ü ö ÿ, &, < and >."; $after=dol_string_unaccent($input); $this->assertEquals("A string\nwith a a a e e e i u o y, &, < and >.", $after); } @@ -738,14 +738,14 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolMkTime() { - global $conf; + global $conf; - $savtz=date_default_timezone_get(); + $savtz=date_default_timezone_get(); - // Some test for UTC TZ - date_default_timezone_set('UTC'); + // Some test for UTC TZ + date_default_timezone_set('UTC'); - // Check bad hours + // Check bad hours $result=dol_mktime(25, 0, 0, 1, 1, 1970, 1, 1); // Error (25 hours) print __METHOD__." result=".$result."\n"; $this->assertEquals('', $result); @@ -831,30 +831,30 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolFormatAddress() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $object=new Societe($db); - $object->initAsSpecimen(); + $object=new Societe($db); + $object->initAsSpecimen(); - $object->country_code='FR'; - $address=dol_format_address($object); - $this->assertEquals("21 jump street\n99999 MyTown", $address); + $object->country_code='FR'; + $address=dol_format_address($object); + $this->assertEquals("21 jump street\n99999 MyTown", $address); - $object->country_code='GB'; - $address=dol_format_address($object); - $this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address); + $object->country_code='GB'; + $address=dol_format_address($object); + $this->assertEquals("21 jump street\nMyTown, MyState\n99999", $address); - $object->country_code='US'; - $address=dol_format_address($object); - $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); + $object->country_code='US'; + $address=dol_format_address($object); + $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); - $object->country_code='AU'; - $address=dol_format_address($object); - $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); + $object->country_code='AU'; + $address=dol_format_address($object); + $this->assertEquals("21 jump street\nMyTown, MyState, 99999", $address); } @@ -903,7 +903,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase print __METHOD__." s=".$s."\n"; $this->assertContains('theme', $s, 'testImgPicto1'); - $s=img_picto('title', 'img.png', 'style="float: right"', 0); + $s=img_picto('title', 'img.png', 'style="float: right"', 0); print __METHOD__." s=".$s."\n"; $this->assertContains('theme', $s, 'testImgPicto2'); $this->assertContains('style="float: right"', $s, 'testImgPicto2'); @@ -978,13 +978,13 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase $companyfr=new Societe($db); $companyfr->country_code='FR'; $companyfr->tva_assuj=1; - $companyfr->tva_intra='FR9999'; + $companyfr->tva_intra='FR9999'; // Buyers $companymc=new Societe($db); $companymc->country_code='MC'; $companymc->tva_assuj=1; - $companyfr->tva_intra='MC9999'; + $companyfr->tva_intra='MC9999'; $companyit=new Societe($db); $companyit->country_code='IT'; @@ -1068,84 +1068,84 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testGetDefaultLocalTax() { - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; - $companyfrnovat=new Societe($db); - $companyfrnovat->country_code='FR'; - $companyfrnovat->tva_assuj=0; - $companyfrnovat->localtax1_assuj=0; - $companyfrnovat->localtax2_assuj=0; + $companyfrnovat=new Societe($db); + $companyfrnovat->country_code='FR'; + $companyfrnovat->tva_assuj=0; + $companyfrnovat->localtax1_assuj=0; + $companyfrnovat->localtax2_assuj=0; - $companyes=new Societe($db); - $companyes->country_code='ES'; - $companyes->tva_assuj=1; - $companyes->localtax1_assuj=1; - $companyes->localtax2_assuj=1; + $companyes=new Societe($db); + $companyes->country_code='ES'; + $companyes->tva_assuj=1; + $companyes->localtax1_assuj=1; + $companyes->localtax2_assuj=1; - $companymc=new Societe($db); - $companymc->country_code='MC'; - $companymc->tva_assuj=1; - $companymc->localtax1_assuj=0; - $companymc->localtax2_assuj=0; + $companymc=new Societe($db); + $companymc->country_code='MC'; + $companymc->tva_assuj=1; + $companymc->localtax1_assuj=0; + $companymc->localtax2_assuj=0; - $companyit=new Societe($db); - $companyit->country_code='IT'; - $companyit->tva_assuj=1; - $companyit->tva_intra='IT99999'; - $companyit->localtax1_assuj=0; - $companyit->localtax2_assuj=0; + $companyit=new Societe($db); + $companyit->country_code='IT'; + $companyit->tva_assuj=1; + $companyit->tva_intra='IT99999'; + $companyit->localtax1_assuj=0; + $companyit->localtax2_assuj=0; - $notcompanyit=new Societe($db); - $notcompanyit->country_code='IT'; - $notcompanyit->tva_assuj=1; - $notcompanyit->tva_intra=''; - $notcompanyit->typent_code='TE_PRIVATE'; - $notcompanyit->localtax1_assuj=0; - $notcompanyit->localtax2_assuj=0; + $notcompanyit=new Societe($db); + $notcompanyit->country_code='IT'; + $notcompanyit->tva_assuj=1; + $notcompanyit->tva_intra=''; + $notcompanyit->typent_code='TE_PRIVATE'; + $notcompanyit->localtax1_assuj=0; + $notcompanyit->localtax2_assuj=0; - $companyus=new Societe($db); - $companyus->country_code='US'; - $companyus->tva_assuj=1; - $companyus->tva_intra=''; - $companyus->localtax1_assuj=0; - $companyus->localtax2_assuj=0; + $companyus=new Societe($db); + $companyus->country_code='US'; + $companyus->tva_assuj=1; + $companyus->tva_intra=''; + $companyus->localtax1_assuj=0; + $companyus->localtax2_assuj=0; - // Test RULE FR-MC - $vat1=get_default_localtax($companyfrnovat, $companymc, 1, 0); - $vat2=get_default_localtax($companyfrnovat, $companymc, 2, 0); - $this->assertEquals(0, $vat1); - $this->assertEquals(0, $vat2); + // Test RULE FR-MC + $vat1=get_default_localtax($companyfrnovat, $companymc, 1, 0); + $vat2=get_default_localtax($companyfrnovat, $companymc, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); - // Test RULE ES-ES - $vat1=get_default_localtax($companyes, $companyes, 1, 0); - $vat2=get_default_localtax($companyes, $companyes, 2, 0); - $this->assertEquals($vat1, 5.2); - $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) + // Test RULE ES-ES + $vat1=get_default_localtax($companyes, $companyes, 1, 0); + $vat2=get_default_localtax($companyes, $companyes, 2, 0); + $this->assertEquals($vat1, 5.2); + $this->assertStringStartsWith((string) $vat2, '-19:-15:-9'); // Can be -19 (old version) or '-19:-15:-9' (new setup) - // Test RULE ES-IT - $vat1=get_default_localtax($companyes, $companyit, 1, 0); - $vat2=get_default_localtax($companyes, $companyit, 2, 0); - $this->assertEquals(0, $vat1); - $this->assertEquals(0, $vat2); + // Test RULE ES-IT + $vat1=get_default_localtax($companyes, $companyit, 1, 0); + $vat2=get_default_localtax($companyes, $companyit, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); - // Test RULE ES-IT - $vat1=get_default_localtax($companyes, $notcompanyit, 1, 0); - $vat2=get_default_localtax($companyes, $notcompanyit, 2, 0); - $this->assertEquals(0, $vat1); - $this->assertEquals(0, $vat2); + // Test RULE ES-IT + $vat1=get_default_localtax($companyes, $notcompanyit, 1, 0); + $vat2=get_default_localtax($companyes, $notcompanyit, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); - // Test RULE FR-IT - // Not tested + // Test RULE FR-IT + // Not tested - // Test RULE ES-US - $vat1=get_default_localtax($companyes, $companyus, 1, 0); - $vat2=get_default_localtax($companyes, $companyus, 2, 0); - $this->assertEquals(0, $vat1); - $this->assertEquals(0, $vat2); + // Test RULE ES-US + $vat1=get_default_localtax($companyes, $companyus, 1, 0); + $vat2=get_default_localtax($companyes, $companyus, 2, 0); + $this->assertEquals(0, $vat1); + $this->assertEquals(0, $vat2); } @@ -1156,108 +1156,108 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase */ public function testDolExplodeIntoArray() { - $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.'; - $tmp=dolExplodeIntoArray($stringtoexplode, '.', '='); + $stringtoexplode='AA=B/B.CC=.EE=FF.HH=GG;.'; + $tmp=dolExplodeIntoArray($stringtoexplode, '.', '='); print __METHOD__." tmp=".json_encode($tmp)."\n"; $this->assertEquals('{"AA":"B\/B","CC":"","EE":"FF","HH":"GG;"}', json_encode($tmp)); } - /** - * dol_nl2br - * - * @return void - */ + /** + * dol_nl2br + * + * @return void + */ public function testDolNl2Br() { - //String to encode - $string = "a\na"; + //String to encode + $string = "a\na"; - $this->assertEquals(dol_nl2br($string), "a
    \na"); + $this->assertEquals(dol_nl2br($string), "a
    \na"); - //With $forxml parameter - $this->assertEquals(dol_nl2br($string, 0, 1), "a
    \na"); + //With $forxml parameter + $this->assertEquals(dol_nl2br($string, 0, 1), "a
    \na"); - //Replacing \n by br - $this->assertEquals(dol_nl2br($string, 1), "a
    a"); + //Replacing \n by br + $this->assertEquals(dol_nl2br($string, 1), "a
    a"); - //With $forxml parameter - $this->assertEquals(dol_nl2br($string, 1, 1), "a
    a"); - } + //With $forxml parameter + $this->assertEquals(dol_nl2br($string, 1, 1), "a
    a"); + } - /** - * testDolPrice2Num - * - * @return boolean - */ - public function testDolPrice2Num() - { - $this->assertEquals(1000, price2num('1 000.0')); - $this->assertEquals(1000, price2num('1 000', 'MT')); - $this->assertEquals(1000, price2num('1 000', 'MU')); + /** + * testDolPrice2Num + * + * @return boolean + */ + public function testDolPrice2Num() + { + $this->assertEquals(1000, price2num('1 000.0')); + $this->assertEquals(1000, price2num('1 000', 'MT')); + $this->assertEquals(1000, price2num('1 000', 'MU')); - $this->assertEquals(1000.123456, price2num('1 000.123456')); + $this->assertEquals(1000.123456, price2num('1 000.123456')); - // Round down - $this->assertEquals(1000.12, price2num('1 000.123452', 'MT')); - $this->assertEquals(1000.12345, price2num('1 000.123452', 'MU'), "Test MU"); + // Round down + $this->assertEquals(1000.12, price2num('1 000.123452', 'MT')); + $this->assertEquals(1000.12345, price2num('1 000.123452', 'MU'), "Test MU"); - // Round up - $this->assertEquals(1000.13, price2num('1 000.125456', 'MT')); - $this->assertEquals(1000.12546, price2num('1 000.125456', 'MU'), "Test MU"); + // Round up + $this->assertEquals(1000.13, price2num('1 000.125456', 'MT')); + $this->assertEquals(1000.12546, price2num('1 000.125456', 'MU'), "Test MU"); - // Text can't be converted - $this->assertEquals('12.4$', price2num('12.4$')); - $this->assertEquals('12r.4$', price2num('12r.4$')); + // Text can't be converted + $this->assertEquals('12.4$', price2num('12.4$')); + $this->assertEquals('12r.4$', price2num('12r.4$')); - return true; - } + return true; + } - /** - * testDolGetDate - * - * @return boolean - */ - public function testDolGetDate() - { - global $conf; + /** + * testDolGetDate + * + * @return boolean + */ + public function testDolGetDate() + { + global $conf; - $conf->global->MAIN_START_WEEK = 0; + $conf->global->MAIN_START_WEEK = 0; - $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday - $this->assertEquals(4, $tmp['wday']); + $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday + $this->assertEquals(4, $tmp['wday']); - $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday - $this->assertEquals(5, $tmp['wday']); + $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday + $this->assertEquals(5, $tmp['wday']); - $conf->global->MAIN_START_WEEK = 1; + $conf->global->MAIN_START_WEEK = 1; - $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday - $this->assertEquals(4, $tmp['wday']); + $tmp=dol_getdate(1); // 1/1/1970 and 1 second = thirday + $this->assertEquals(4, $tmp['wday']); - $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday - $this->assertEquals(5, $tmp['wday']); + $tmp=dol_getdate(24*60*60+1); // 2/1/1970 and 1 second = friday + $this->assertEquals(5, $tmp['wday']); - return true; - } + return true; + } - /** - * testDolGetDate - * - * @return boolean - */ - public function testMakeSubstitutions() - { - global $conf, $langs; - $langs->load("main"); + /** + * testDolGetDate + * + * @return boolean + */ + public function testMakeSubstitutions() + { + global $conf, $langs; + $langs->load("main"); - $substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced"); - $chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__'; - $newstring = make_substitutions($chaine, $substit); - $this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__'); + $substit=array("AAA"=>'Not used', "BBB"=>'Not used', "CCC"=>"C replaced"); + $chaine='This is a string with __[MAIN_THEME]__ and __(DIRECTION)__ and __CCC__'; + $newstring = make_substitutions($chaine, $substit); + $this->assertEquals($newstring, 'This is a string with eldy and ltr and __C replaced__'); - return true; - } + return true; + } } diff --git a/test/phpunit/GetUrlLibTest.php b/test/phpunit/GetUrlLibTest.php index 754cea5f9c9..0e0cfb7d767 100644 --- a/test/phpunit/GetUrlLibTest.php +++ b/test/phpunit/GetUrlLibTest.php @@ -32,9 +32,9 @@ require_once dirname(__FILE__).'/../../htdocs/core/lib/geturl.lib.php'; if (empty($user->id)) { - print "Load permissions for admin user nb 1\n"; - $user->fetch(1); - $user->getrights(); + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); } $conf->global->MAIN_DISABLE_ALL_MAILS=1; @@ -48,123 +48,123 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; */ class GetUrlLibTest extends PHPUnit_Framework_TestCase { - protected $savconf; - protected $savuser; - protected $savlangs; - protected $savdb; + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; - /** - * Constructor - * We save global variables into local variables - * - * @return FilesLibTest - */ - function __construct() - { - parent::__construct(); - - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; - - print __METHOD__." db->type=".$db->type." user->id=".$user->id; - //print " - db ".$db->db; - print "\n"; - } - - // Static methods - public static function setUpBeforeClass() + /** + * Constructor + * We save global variables into local variables + * + * @return FilesLibTest + */ + public function __construct() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + parent::__construct(); - print __METHOD__."\n"; + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; } // tear down after class public static function tearDownAfterClass() { - global $conf,$user,$langs,$db; - $db->rollback(); + global $conf,$user,$langs,$db; + $db->rollback(); - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * End phpunit tests - * - * @return void - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** + /** * testGetRootURLFromURL * * @return int */ public function testGetRootURLFromURL() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com', $result, 'Test 1'); + $result=getRootURLFromURL('http://www.dolimed.com/screenshots/afile'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('http://www.dolimed.com', $result, 'Test 1'); - $result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com', $result, 'Test 2'); + $result=getRootURLFromURL('https://www.dolimed.com/screenshots/afile'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('https://www.dolimed.com', $result, 'Test 2'); - $result=getRootURLFromURL('http://www.dolimed.com/screenshots'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com', $result); + $result=getRootURLFromURL('http://www.dolimed.com/screenshots'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('http://www.dolimed.com', $result); - $result=getRootURLFromURL('https://www.dolimed.com/screenshots'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com', $result); + $result=getRootURLFromURL('https://www.dolimed.com/screenshots'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('https://www.dolimed.com', $result); - $result=getRootURLFromURL('http://www.dolimed.com/'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com', $result); + $result=getRootURLFromURL('http://www.dolimed.com/'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('http://www.dolimed.com', $result); - $result=getRootURLFromURL('https://www.dolimed.com/'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com', $result); + $result=getRootURLFromURL('https://www.dolimed.com/'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('https://www.dolimed.com', $result); - $result=getRootURLFromURL('http://www.dolimed.com'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('http://www.dolimed.com', $result); + $result=getRootURLFromURL('http://www.dolimed.com'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('http://www.dolimed.com', $result); - $result=getRootURLFromURL('https://www.dolimed.com'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('https://www.dolimed.com', $result); + $result=getRootURLFromURL('https://www.dolimed.com'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('https://www.dolimed.com', $result); - return 1; + return 1; } @@ -175,20 +175,20 @@ class GetUrlLibTest extends PHPUnit_Framework_TestCase */ public function testRemoveHtmlComment() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $result=removeHtmlComment('abcdef'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('abcdef', $result, 'Test 1'); + $result=removeHtmlComment('abcdef'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('abcdef', $result, 'Test 1'); - $result=removeHtmlComment('abcbbdef'); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('abcbbdef', $result, 'Test 1'); + $result=removeHtmlComment('abcbbdef'); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('abcbbdef', $result, 'Test 1'); - return 1; + return 1; } } diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index ce50174dc0b..a352a1722b9 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -32,9 +32,9 @@ $langs->load("dict"); if (empty($user->id)) { - print "Load permissions for admin user nb 1\n"; - $user->fetch(1); - $user->getrights(); + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); } $conf->global->MAIN_DISABLE_ALL_MAILS=1; @@ -49,75 +49,75 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; */ class HolidayTest extends PHPUnit_Framework_TestCase { - protected $savconf; - protected $savuser; - protected $savlangs; - protected $savdb; + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; - /** - * Constructor - * We save global variables into local variables - * - * @return HolidayTest - */ - function __construct() - { - parent::__construct(); - - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; - - print __METHOD__." db->type=".$db->type." user->id=".$user->id; - //print " - db ".$db->db; - print "\n"; - } - - // Static methods - public static function setUpBeforeClass() + /** + * Constructor + * We save global variables into local variables + * + * @return HolidayTest + */ + public function __construct() { - global $conf,$user,$langs,$db; + parent::__construct(); + + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + // Static methods + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class public static function tearDownAfterClass() { - global $conf,$user,$langs,$db; - $db->rollback(); + global $conf,$user,$langs,$db; + $db->rollback(); - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - print __METHOD__."\n"; + print __METHOD__."\n"; } - /** - * End phpunit tests - * - * @return void - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { - print __METHOD__."\n"; + print __METHOD__."\n"; } /** @@ -127,20 +127,20 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testHolidayCreate() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Holiday($this->savdb); - $localobject->initAsSpecimen(); - $result=$localobject->create($user); + $localobject=new Holiday($this->savdb); + $localobject->initAsSpecimen(); + $result=$localobject->create($user); print __METHOD__." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertLessThan($result, 0); - return $result; + return $result; } /** @@ -153,19 +153,19 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testHolidayFetch($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Holiday($this->savdb); - $result=$localobject->fetch($id); + $localobject=new Holiday($this->savdb); + $result=$localobject->fetch($id); print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertLessThan($result, 0); - return $localobject; + return $localobject; } /** @@ -179,55 +179,55 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testHolidayUpdate($localobject) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject->oldcopy = clone $localobject; + $localobject->oldcopy = clone $localobject; - $localobject->note_private='New private note after update'; - $localobject->note_public='New public note after update'; - $localobject->lastname='New name'; - $localobject->firstname='New firstname'; - $localobject->address='New address'; - $localobject->zip='New zip'; - $localobject->town='New town'; - $localobject->country_id=2; - //$localobject->status=0; - $localobject->phone_pro='New tel pro'; - $localobject->phone_perso='New tel perso'; - $localobject->phone_mobile='New tel mobile'; - $localobject->fax='New fax'; - $localobject->email='newemail@newemail.com'; - $localobject->jabberid='New im id'; - $localobject->default_lang='es_ES'; + $localobject->note_private='New private note after update'; + $localobject->note_public='New public note after update'; + $localobject->lastname='New name'; + $localobject->firstname='New firstname'; + $localobject->address='New address'; + $localobject->zip='New zip'; + $localobject->town='New town'; + $localobject->country_id=2; + //$localobject->status=0; + $localobject->phone_pro='New tel pro'; + $localobject->phone_perso='New tel perso'; + $localobject->phone_mobile='New tel mobile'; + $localobject->fax='New fax'; + $localobject->email='newemail@newemail.com'; + $localobject->jabberid='New im id'; + $localobject->default_lang='es_ES'; - $result=$localobject->update($localobject->id, $user); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0, 'Holiday::update error'); - - $result=$localobject->update_note($localobject->note_private, '_private'); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0, 'Holiday::update_note (private) error'); - - $result=$localobject->update_note($localobject->note_public, '_public'); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0, 'Holiday::update_note (public) error'); - - - $newobject=new Holiday($this->savdb); - $result=$newobject->fetch($localobject->id); + $result=$localobject->update($localobject->id, $user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0, 'Holiday::fetch error'); + $this->assertLessThan($result, 0, 'Holiday::update error'); - print __METHOD__." old=".$localobject->note." new=".$newobject->note."\n"; - $this->assertEquals($localobject->note, $newobject->note, 'Holiday::update_note error compare note'); - //print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n"; - //$this->assertEquals($localobject->note_public, $newobject->note_public); + $result=$localobject->update_note($localobject->note_private, '_private'); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0, 'Holiday::update_note (private) error'); - return $localobject; + $result=$localobject->update_note($localobject->note_public, '_public'); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0, 'Holiday::update_note (public) error'); + + + $newobject=new Holiday($this->savdb); + $result=$newobject->fetch($localobject->id); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0, 'Holiday::fetch error'); + + print __METHOD__." old=".$localobject->note." new=".$newobject->note."\n"; + $this->assertEquals($localobject->note, $newobject->note, 'Holiday::update_note error compare note'); + //print __METHOD__." old=".$localobject->note_public." new=".$newobject->note_public."\n"; + //$this->assertEquals($localobject->note_public, $newobject->note_public); + + return $localobject; } /** @@ -241,15 +241,15 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testHolidayOther($localobject) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - //$localobject->fetch($localobject->id); + //$localobject->fetch($localobject->id); - /* + /* $result=$localobject->getNomUrl(1); print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertNotEquals($result, ''); @@ -261,7 +261,7 @@ class HolidayTest extends PHPUnit_Framework_TestCase $localobject->info($localobject->id); print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; $this->assertNotEquals($localobject->date_creation, ''); - */ + */ return $localobject->id; } @@ -277,20 +277,20 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testHolidayDelete($id) { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - $localobject=new Holiday($this->savdb); - $result=$localobject->fetch($id); + $localobject=new Holiday($this->savdb); + $result=$localobject->fetch($id); - $result=$localobject->delete(0); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $result=$localobject->delete(0); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); - return $result; + return $result; } /** @@ -300,55 +300,55 @@ class HolidayTest extends PHPUnit_Framework_TestCase */ public function testVerifDateHolidayCP() { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; - // Create a leave request the 1st morning only - $localobjecta=new Holiday($this->savdb); - $localobjecta->initAsSpecimen(); - $localobjecta->date_debut = dol_mktime(0, 0, 0, 1, 1, 2020); - $localobjecta->date_fin = dol_mktime(0, 0, 0, 1, 1, 2020); - $localobjecta->halfday = 1; - $result=$localobjecta->create($user); + // Create a leave request the 1st morning only + $localobjecta=new Holiday($this->savdb); + $localobjecta->initAsSpecimen(); + $localobjecta->date_debut = dol_mktime(0, 0, 0, 1, 1, 2020); + $localobjecta->date_fin = dol_mktime(0, 0, 0, 1, 1, 2020); + $localobjecta->halfday = 1; + $result=$localobjecta->create($user); - // Create a leave request the 2 afternoon only - $localobjectb=new Holiday($this->savdb); - $localobjectb->initAsSpecimen(); - $localobjectb->date_debut = dol_mktime(0, 0, 0, 1, 2, 2020); - $localobjectb->date_fin = dol_mktime(0, 0, 0, 1, 2, 2020); - $localobjectb->halfday = -1; - $result=$localobjectb->create($user); + // Create a leave request the 2 afternoon only + $localobjectb=new Holiday($this->savdb); + $localobjectb->initAsSpecimen(); + $localobjectb->date_debut = dol_mktime(0, 0, 0, 1, 2, 2020); + $localobjectb->date_fin = dol_mktime(0, 0, 0, 1, 2, 2020); + $localobjectb->halfday = -1; + $result=$localobjectb->create($user); - $date_debut = dol_mktime(0, 0, 0, 1, 1, 2020); - $date_fin = dol_mktime(0, 0, 0, 1, 2, 2020); + $date_debut = dol_mktime(0, 0, 0, 1, 1, 2020); + $date_fin = dol_mktime(0, 0, 0, 1, 2, 2020); - $localobjectc=new Holiday($this->savdb); + $localobjectc=new Holiday($this->savdb); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 0); - $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 0); - $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 0); - $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 0); + $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 0); + $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 0); + $this->assertFalse($result, 'result should be false, there is overlapping, full day is not available.'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 1); - $this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 1); - $this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 1); - $this->assertTrue($result, 'result should be true, there is no overlapping'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, 1); + $this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 1); + $this->assertFalse($result, 'result should be false, there is overlapping, morning of first day is not available.'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, 1); + $this->assertTrue($result, 'result should be true, there is no overlapping'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, -1); - $this->assertTrue($result, 'result should be true, there is no overlapping'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, -1); - $this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, -1); - $this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_debut, -1); + $this->assertTrue($result, 'result should be true, there is no overlapping'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, -1); + $this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_fin, $date_fin, -1); + $this->assertFalse($result, 'result should be false, there is overlapping, afternoon of second day is not available'); - $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2); // start afternoon and end morning - $this->assertTrue($result, 'result should be true, there is no overlapping'); + $result=$localobjectc->verifDateHolidayCP($user->id, $date_debut, $date_fin, 2); // start afternoon and end morning + $this->assertTrue($result, 'result should be true, there is no overlapping'); } } diff --git a/test/phpunit/ImagesLibTest.php b/test/phpunit/ImagesLibTest.php index 0d579b7295d..4ecaab49d39 100644 --- a/test/phpunit/ImagesLibTest.php +++ b/test/phpunit/ImagesLibTest.php @@ -59,7 +59,7 @@ class ImagesLibTest extends PHPUnit_Framework_TestCase * * @return ImagesLibTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -76,7 +76,7 @@ class ImagesLibTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/ImportTest.php b/test/phpunit/ImportTest.php index 9797905acdb..10d906f2ede 100644 --- a/test/phpunit/ImportTest.php +++ b/test/phpunit/ImportTest.php @@ -60,7 +60,7 @@ class ImportTest extends PHPUnit_Framework_TestCase * * @return ImportTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -77,7 +77,7 @@ class ImportTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; //$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/JsonLibTest.php b/test/phpunit/JsonLibTest.php index 113d263eca4..bb33032a4a5 100644 --- a/test/phpunit/JsonLibTest.php +++ b/test/phpunit/JsonLibTest.php @@ -28,16 +28,16 @@ global $conf,$user,$langs,$db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; -if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) +if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1'); +if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1'); +if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1'); +if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1'); +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1'); +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1'); +if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) /** @@ -60,11 +60,11 @@ class JsonLibTest extends PHPUnit_Framework_TestCase * * @return CoreTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -94,11 +94,11 @@ class JsonLibTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } - /** - * Init phpunit tests - * - * @return void - */ + /** + * Init phpunit tests + * + * @return void + */ protected function setUp() { global $conf,$user,$langs,$db; @@ -109,11 +109,11 @@ class JsonLibTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } - /** - * End phpunit tests - * - * @return void - */ + /** + * End phpunit tests + * + * @return void + */ protected function tearDown() { print __METHOD__."\n"; @@ -135,39 +135,39 @@ class JsonLibTest extends PHPUnit_Framework_TestCase // Do a test with an array starting with 0 $arraytotest=array(0=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); - $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; + $arrayencodedexpected='[{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}]'; $encoded=json_encode($arraytotest); - $this->assertEquals($arrayencodedexpected,$encoded); - $decoded=json_decode($encoded,true); - $this->assertEquals($arraytotest,$decoded,'test for json_xxx'); + $this->assertEquals($arrayencodedexpected, $encoded); + $decoded=json_decode($encoded, true); + $this->assertEquals($arraytotest, $decoded, 'test for json_xxx'); $encoded=dol_json_encode($arraytotest); - $this->assertEquals($arrayencodedexpected,$encoded); - $decoded=dol_json_decode($encoded,true); - $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); + $this->assertEquals($arrayencodedexpected, $encoded); + $decoded=dol_json_decode($encoded, true); + $this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx'); - // Same test but array start with 2 instead of 0 + // Same test but array start with 2 instead of 0 $arraytotest=array(2=>array('key'=>1,'value'=>'PRODREF','label'=>'Product ref with é and special chars \\ \' "')); - $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; + $arrayencodedexpected='{"2":{"key":1,"value":"PRODREF","label":"Product ref with \u00e9 and special chars \\\\ \' \""}}'; $encoded=json_encode($arraytotest); - $this->assertEquals($arrayencodedexpected,$encoded); - $decoded=json_decode($encoded,true); - $this->assertEquals($arraytotest,$decoded,'test for json_xxx'); + $this->assertEquals($arrayencodedexpected, $encoded); + $decoded=json_decode($encoded, true); + $this->assertEquals($arraytotest, $decoded, 'test for json_xxx'); $encoded=dol_json_encode($arraytotest); - $this->assertEquals($arrayencodedexpected,$encoded); - $decoded=dol_json_decode($encoded,true); - $this->assertEquals($arraytotest,$decoded,'test for dol_json_xxx'); + $this->assertEquals($arrayencodedexpected, $encoded); + $decoded=dol_json_decode($encoded, true); + $this->assertEquals($arraytotest, $decoded, 'test for dol_json_xxx'); // Test with object - $now=gmmktime(12,0,0,1,1,1970); + $now=gmmktime(12, 0, 0, 1, 1, 1970); $objecttotest=new stdClass(); $objecttotest->property1='abc'; $objecttotest->property2=1234; $objecttotest->property3=$now; $encoded=dol_json_encode($objecttotest); - $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}',$encoded); + $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}', $encoded); } } diff --git a/test/phpunit/LangTest.php b/test/phpunit/LangTest.php index 82c2b45d8c7..228cde51901 100644 --- a/test/phpunit/LangTest.php +++ b/test/phpunit/LangTest.php @@ -70,7 +70,7 @@ class LangTest extends PHPUnit_Framework_TestCase * * @return SecurityTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -87,7 +87,7 @@ class LangTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/LoanTest.php b/test/phpunit/LoanTest.php index d54c810049d..b0ecd583514 100644 --- a/test/phpunit/LoanTest.php +++ b/test/phpunit/LoanTest.php @@ -58,7 +58,7 @@ class LoanTest extends PHPUnit_Framework_TestCase * * @return LoanTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,7 +75,7 @@ class LoanTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/MarginsLibTest.php b/test/phpunit/MarginsLibTest.php index f967d822f9a..81f4a512e4f 100644 --- a/test/phpunit/MarginsLibTest.php +++ b/test/phpunit/MarginsLibTest.php @@ -58,7 +58,7 @@ class MarginsLibTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,13 +74,13 @@ class MarginsLibTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/ModulesTest.php b/test/phpunit/ModulesTest.php index dc999fac750..ea16813d873 100755 --- a/test/phpunit/ModulesTest.php +++ b/test/phpunit/ModulesTest.php @@ -57,7 +57,7 @@ class ModulesTest extends PHPUnit_Framework_TestCase * * @return BuildDocTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,7 +74,7 @@ class ModulesTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/MouvementStockTest.php b/test/phpunit/MouvementStockTest.php index cc50460e15f..cedd5b4741c 100644 --- a/test/phpunit/MouvementStockTest.php +++ b/test/phpunit/MouvementStockTest.php @@ -60,7 +60,7 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase * * @return ContratTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -77,7 +77,7 @@ class MouvementStockTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index 16ac7cc0082..66c4c670128 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -57,7 +57,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase * * @return NumberingModulesTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,7 +74,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; @@ -113,7 +113,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase * * @return void */ - protected function tearDown() + protected function tearDown() { print __METHOD__."\n"; } diff --git a/test/phpunit/PaypalTest.php b/test/phpunit/PaypalTest.php index a596f9c88d1..98300a6a86a 100644 --- a/test/phpunit/PaypalTest.php +++ b/test/phpunit/PaypalTest.php @@ -59,7 +59,7 @@ class PaypalTest extends PHPUnit_Framework_TestCase * * @return ProductTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,8 +75,8 @@ class PaypalTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; diff --git a/test/phpunit/PdfDocTest.php b/test/phpunit/PdfDocTest.php index d7f81534cde..634a931da56 100644 --- a/test/phpunit/PdfDocTest.php +++ b/test/phpunit/PdfDocTest.php @@ -61,7 +61,7 @@ class PdfDocTest extends PHPUnit_Framework_TestCase * * @return PdfDocTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -77,8 +77,8 @@ class PdfDocTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/PgsqlTest.php b/test/phpunit/PgsqlTest.php index 8347bc32905..a1fcc180528 100644 --- a/test/phpunit/PgsqlTest.php +++ b/test/phpunit/PgsqlTest.php @@ -60,7 +60,7 @@ class PgsqlTest extends PHPUnit_Framework_TestCase * * @return ContactTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -76,8 +76,8 @@ class PgsqlTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index 2fe61f4fa0f..0203a1d4275 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -65,11 +65,11 @@ class PricesTest extends PHPUnit_Framework_TestCase * * @return CoreTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; @@ -100,9 +100,9 @@ class PricesTest extends PHPUnit_Framework_TestCase } /** - * Init phpunit tests - * - * @return void + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -116,9 +116,9 @@ class PricesTest extends PHPUnit_Framework_TestCase } /** - * End phpunit tests - * - * @return void + * End phpunit tests + * + * @return void */ protected function tearDown() { @@ -134,68 +134,68 @@ class PricesTest extends PHPUnit_Framework_TestCase */ public function testCalculPriceTotal() { - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; - global $mysoc; - $mysoc=new Societe($db); + global $mysoc; + $mysoc=new Societe($db); - // To force status that say module multicompany is on - //$conf->multicurrency=new stdClass(); - //$conf->multicurrency->enabled = 0; + // To force status that say module multicompany is on + //$conf->multicurrency=new stdClass(); + //$conf->multicurrency->enabled = 0; - /* - * Country France - */ + /* + * Country France + */ - // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT' (method we provide value) - $mysoc->country_code='FR'; - $mysoc->country_id=1; - $result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0); + // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT' (method we provide value) + $mysoc->country_code='FR'; + $mysoc->country_id=1; + $result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0); print __METHOD__." result1=".join(', ', $result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0, 1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0), $result1, 'Test1 FR'); - // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value) - $mysoc->country_code='FR'; - $mysoc->country_id=1; - $result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205); + // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value) + $mysoc->country_code='FR'; + $mysoc->country_id=1; + $result1=calcul_price_total(2, 8.56, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205); print __METHOD__." result1=".join(', ', $result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(17.12, 1.71, 18.83, 8.56, 0.856, 9.416, 17.12, 1.71, 18.83, 0, 0, 0, 0, 0, 0, 0, 18.7, 1.87, 20.57, 9.34795, 0.93479, 10.28274, 18.7, 1.87, 20.57, 0, 0), $result1, 'Test1b FR'); - // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 - $mysoc->country_code='FR'; - $mysoc->country_id=1; - $result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20); + // qty=2, unit_price=0, discount_line=0, vat_rate=10, price_base_type='HT', multicurrency_tx=1.09205 (method we provide value), pu_ht_devise=100 + $mysoc->country_code='FR'; + $mysoc->country_id=1; + $result1=calcul_price_total(2, 0, 0, 10, 0, 0, 0, 'HT', 0, 0, '', '', 100, 1.09205, 20); print __METHOD__." result1=".join(', ', $result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(36.63, 3.66, 40.29, 18.31418, 1.83142, 20.1456, 36.63, 3.66, 40.29, 0, 0, 0, 0, 0, 0, 0, 40, 4, 44, 20, 2, 22, 40, 4, 44, 0, 0), $result1, 'Test1c FR'); /* - * Country Spain - */ + * Country Spain + */ // 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (method we provide value) - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=0; - $result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=0; + $result2=calcul_price_total(10, 10, 0, 10, 0, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test1 ES'); // 10 * 10 HT - 0% discount with 10% vat, seller not using localtax1, not localtax2 (other method autodetect) - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=0; - $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=0; + $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1, 0% localtax2 print __METHOD__." result2=".join(', ', $result2)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test2 ES'); @@ -203,76 +203,76 @@ class PricesTest extends PHPUnit_Framework_TestCase // -------------------------------------------------------- // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (method we provide value) - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=1; - $mysoc->localtax2_assuj=0; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=1; + $mysoc->localtax2_assuj=0; $result2=calcul_price_total(10, 10, 0, 10, 1.4, 0, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ', $result2)."\n"; - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + print __METHOD__." result2=".join(', ', $result2)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0), $result2, 'Test3 ES'); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect) - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=1; - $mysoc->localtax2_assuj=0; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=1; + $mysoc->localtax2_assuj=0; $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ', $result2)."\n"; - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + print __METHOD__." result2=".join(', ', $result2)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0, 0.14, 0, 0, 1.4, 0, 100, 10, 111.4, 10, 1, 11.14, 100, 10, 111.4, 1.4, 0), $result2, 'Test4 ES'); // -------------------------------------------------------- // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 19% localtax2 type 5 (method we provide value), we provide a service and not a product - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=1; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, 0, -19, 0, 'HT', 0, 1); - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19), $result2, 'Test5 ES for service'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a service and not a product - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=1; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ', $result2)."\n"; - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test6 ES for product'); + print __METHOD__." result2=".join(', ', $result2)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + $this->assertEquals(array(100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0, 0, 0, 0, 0, 0, 100, 10, 110, 10, 1, 11, 100, 10, 110, 0, 0), $result2, 'Test6 ES for product'); // 10 * 10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 21% localtax2 type 5 (other method autodetect), we provide a product and not a service - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=1; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, 10, 0, 10, -1, -1, 0, 'HT', 0, 1); - print __METHOD__." result2=".join(', ', $result2)."\n"; - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19), $result2, 'Test6 ES for service'); + print __METHOD__." result2=".join(', ', $result2)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + $this->assertEquals(array(100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19, 0, -1.90, 0, 0, -19, 100, 10, 91, 10, 1, 9.1, 100, 10, 91, 0, -19), $result2, 'Test6 ES for service'); - // -------------------------------------------------------- + // -------------------------------------------------------- // Credit Note: 10 * -10 HT - 0% discount with 10% vat and 0% localtax1 type 3, 19% localtax2 type 5 (method we provide value), we provide a product and not a service - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=1; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, -10, 0, 10, 0, 19, 0, 'HT', 0, 0); - print __METHOD__." result2=".join(', ', $result2)."\n"; - // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0), $result2, 'Test7 ES for product'); + print __METHOD__." result2=".join(', ', $result2)."\n"; + // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) + $this->assertEquals(array(-100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0, 0, 0, 0, 0, 0, -100, -10, -110, -10, -1, -11, -100, -10, -110, 0, 0), $result2, 'Test7 ES for product'); // Credit Note: 10 * -10 HT - 0% discount with 10% vat and 1.4% localtax1 type 3, 0% localtax2 type 5 (other method autodetect), we provide a service and not a product - $mysoc->country_code='ES'; - $mysoc->country_id=4; - $mysoc->localtax1_assuj=0; - $mysoc->localtax2_assuj=1; + $mysoc->country_code='ES'; + $mysoc->country_id=4; + $mysoc->localtax1_assuj=0; + $mysoc->localtax2_assuj=1; $result2=calcul_price_total(10, -10, 0, 10, -1, -1, 0, 'HT', 0, 1); - print __METHOD__." result2=".join(', ', $result2)."\n"; - $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19), $result2, 'Test8 ES for service'); + print __METHOD__." result2=".join(', ', $result2)."\n"; + $this->assertEquals(array(-100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19, 0, 1.90, 0, 0, 19, -100, -10, -91, -10, -1, -9.1, -100, -10, -91, 0, 19), $result2, 'Test8 ES for service'); /* @@ -280,23 +280,23 @@ class PricesTest extends PHPUnit_Framework_TestCase */ // 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (method we provide value) - $mysoc->country_code='CI'; - $mysoc->country_id=21; - $mysoc->localtax1_assuj=1; - $mysoc->localtax2_assuj=0; + $mysoc->country_code='CI'; + $mysoc->country_id=21; + $mysoc->localtax1_assuj=1; + $mysoc->localtax2_assuj=0; //$localtaxes=getLocalTaxesFromRate(18, 0, null, $mysoc); //var_dump($locataxes); - $result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 + $result3=calcul_price_total(10, 10, 0, 18, 7.5, 0, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 print __METHOD__." result3=".join(', ', $result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0), $result3, 'Test9 CI'); // 10 * 10 HT - 0% discount with 18% vat, seller using localtax1 type 2, not localtax2 (other method autodetect) - $mysoc->country_code='CI'; - $mysoc->country_id=21; - $mysoc->localtax1_assuj=1; - $mysoc->localtax2_assuj=0; - $result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 + $mysoc->country_code='CI'; + $mysoc->country_id=21; + $mysoc->localtax1_assuj=1; + $mysoc->localtax2_assuj=0; + $result3=calcul_price_total(10, 10, 0, 18, -1, -1, 0, 'HT', 0, 0); // 10 * 10 HT - 0% discount with 18% vat and 7.5% localtax1, 0% localtax2 print __METHOD__." result3=".join(', ', $result3)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) $this->assertEquals(array(100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0, 0.885, 0, 0, 8.85, 0, 100, 18, 126.85, 10, 1.8, 12.685, 100, 18, 126.85, 8.85, 0), $result3, 'Test10 CI'); @@ -313,17 +313,17 @@ class PricesTest extends PHPUnit_Framework_TestCase */ public function testUpdatePrice() { - //$this->sharedFixture - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; - $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; + $conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0; - // Two lines of 1.24 give 2.48 HT and 2.72 TTC with standard vat rounding mode - $localobject=new Facture($this->savdb); + // Two lines of 1.24 give 2.48 HT and 2.72 TTC with standard vat rounding mode + $localobject=new Facture($this->savdb); $localobject->initAsSpecimen('nolines'); $invoiceid=$localobject->create($user); diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index 742dca85590..c57ef426d0b 100644 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -58,11 +58,11 @@ class ProductTest extends PHPUnit_Framework_TestCase * * @return ProductTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf=$conf; $this->savuser=$user; diff --git a/test/phpunit/ProjectTest.php b/test/phpunit/ProjectTest.php index 2779902cabd..faa533e2c00 100644 --- a/test/phpunit/ProjectTest.php +++ b/test/phpunit/ProjectTest.php @@ -59,7 +59,7 @@ class ProjectTest extends PHPUnit_Framework_TestCase * * @return ProjectTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -75,13 +75,13 @@ class ProjectTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/PropalTest.php b/test/phpunit/PropalTest.php index 81842063271..6a3d17d7806 100644 --- a/test/phpunit/PropalTest.php +++ b/test/phpunit/PropalTest.php @@ -58,7 +58,7 @@ class PropalTest extends PHPUnit_Framework_TestCase * * @return PropalTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -74,13 +74,13 @@ class PropalTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/RestAPIDocumentTest.php b/test/phpunit/RestAPIDocumentTest.php index d1be0630e6d..f0d3efe34e6 100644 --- a/test/phpunit/RestAPIDocumentTest.php +++ b/test/phpunit/RestAPIDocumentTest.php @@ -62,9 +62,9 @@ class RestAPIDocumentTest extends PHPUnit_Framework_TestCase */ public function __construct() { - parent::__construct(); + parent::__construct(); - //$this->sharedFixture + //$this->sharedFixture global $conf,$user,$langs,$db; $this->savconf = $conf; $this->savuser = $user; diff --git a/test/phpunit/RestAPIUserTest.php b/test/phpunit/RestAPIUserTest.php index 153e4166b8e..39f924e7e04 100644 --- a/test/phpunit/RestAPIUserTest.php +++ b/test/phpunit/RestAPIUserTest.php @@ -62,7 +62,7 @@ class RestAPIUserTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/ScriptsTest.php b/test/phpunit/ScriptsTest.php index d7011d23e06..4e43a036c7e 100644 --- a/test/phpunit/ScriptsTest.php +++ b/test/phpunit/ScriptsTest.php @@ -70,7 +70,7 @@ class ScriptsTest extends PHPUnit_Framework_TestCase * * @return SecurityTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -86,13 +86,13 @@ class ScriptsTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { - global $conf,$user,$langs,$db; - $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. - print __METHOD__."\n"; + print __METHOD__."\n"; } // tear down after class diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 263dc831ade..636fa923bc0 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -70,7 +70,7 @@ class SecurityTest extends PHPUnit_Framework_TestCase * * @return SecurityTest */ - function __construct() + public function __construct() { parent::__construct(); @@ -86,8 +86,8 @@ class SecurityTest extends PHPUnit_Framework_TestCase print "\n"; } - // Static methods - public static function setUpBeforeClass() + // Static methods + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index c102d3467e1..11eb6711862 100755 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -58,7 +58,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase * * @return SocieteTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/SupplierProposalTest.php b/test/phpunit/SupplierProposalTest.php index c284eb61178..14a63776444 100644 --- a/test/phpunit/SupplierProposalTest.php +++ b/test/phpunit/SupplierProposalTest.php @@ -61,9 +61,9 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase * * @return PropalTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); //$this->sharedFixture global $conf,$user,$langs,$db; @@ -78,7 +78,7 @@ class SupplierProposalTest extends PHPUnit_Framework_TestCase } // Static methods - public static function setUpBeforeClass() + public static function setUpBeforeClass() { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. diff --git a/test/phpunit/UserGroupTest.php b/test/phpunit/UserGroupTest.php index ba78fdfd8db..e524b989172 100644 --- a/test/phpunit/UserGroupTest.php +++ b/test/phpunit/UserGroupTest.php @@ -57,7 +57,7 @@ class UserGroupTest extends PHPUnit_Framework_TestCase * * @return UserGroupTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index c4cfe63e9dc..b87dfd84494 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -57,7 +57,7 @@ class UserTest extends PHPUnit_Framework_TestCase * * @return UserTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/UtilsTest.php b/test/phpunit/UtilsTest.php index f2f44daa31d..58074af1c1f 100644 --- a/test/phpunit/UtilsTest.php +++ b/test/phpunit/UtilsTest.php @@ -57,9 +57,9 @@ class UtilsTest extends PHPUnit_Framework_TestCase * * @return UserTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index e916e3d5a89..fb8e36af6a1 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -67,7 +67,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/WebservicesOrdersTest.php b/test/phpunit/WebservicesOrdersTest.php index 2dc22eb2027..8b989df273f 100644 --- a/test/phpunit/WebservicesOrdersTest.php +++ b/test/phpunit/WebservicesOrdersTest.php @@ -61,7 +61,7 @@ class WebservicesOrdersTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/WebservicesOtherTest.php b/test/phpunit/WebservicesOtherTest.php index af329bd9de5..bdc3a15b2b9 100644 --- a/test/phpunit/WebservicesOtherTest.php +++ b/test/phpunit/WebservicesOtherTest.php @@ -61,7 +61,7 @@ class WebservicesOtherTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/WebservicesProductsTest.php b/test/phpunit/WebservicesProductsTest.php index 1e80fd8f433..90147a429a4 100644 --- a/test/phpunit/WebservicesProductsTest.php +++ b/test/phpunit/WebservicesProductsTest.php @@ -68,7 +68,7 @@ class WebservicesProductsTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/WebservicesThirdpartyTest.php b/test/phpunit/WebservicesThirdpartyTest.php index 56425198e09..cb1f26d1980 100644 --- a/test/phpunit/WebservicesThirdpartyTest.php +++ b/test/phpunit/WebservicesThirdpartyTest.php @@ -68,9 +68,9 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { - parent::__construct(); + parent::__construct(); //$this->sharedFixture global $conf,$user,$langs,$db; diff --git a/test/phpunit/WebservicesUserTest.php b/test/phpunit/WebservicesUserTest.php index 32a96434ac8..7ca0d9e8ee8 100644 --- a/test/phpunit/WebservicesUserTest.php +++ b/test/phpunit/WebservicesUserTest.php @@ -61,7 +61,7 @@ class WebservicesUserTest extends PHPUnit_Framework_TestCase * * @return DateLibTest */ - function __construct() + public function __construct() { parent::__construct(); diff --git a/test/phpunit/XCalLibTest.php b/test/phpunit/XCalLibTest.php index bcc9ce0128c..4783bf4bc8f 100644 --- a/test/phpunit/XCalLibTest.php +++ b/test/phpunit/XCalLibTest.php @@ -57,7 +57,7 @@ class XCalLibTest extends PHPUnit_Framework_TestCase * * @return FilesLibTest */ - function __construct() + public function __construct() { parent::__construct();