From 91fa823075d6f6983706d38817c4c7cea9e08deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 25 Feb 2015 18:03:31 +0100 Subject: [PATCH 1/5] Marked getStaticMember as deprecated --- htdocs/core/lib/functions.lib.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bb4176a00e3..0f06eadadce 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -44,6 +44,7 @@ include_once DOL_DOCUMENT_ROOT .'/core/lib/json.lib.php'; * @param string $class Class name * @param string $member Name of property * @return mixed Return value of static property + * @deprecated Dolibarr now requires 5.3.0+ */ function getStaticMember($class, $member) { From 0a5f17f1795f61cf4bc78607edb1879b1c8665fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 25 Feb 2015 18:06:54 +0100 Subject: [PATCH 2/5] Undefined variable + Unreachable statement --- htdocs/core/lib/functions.lib.php | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index bb4176a00e3..5aa6bb88e53 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3195,7 +3195,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller) { global $db; - dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local." thirdparty id=".(is_object($thirdparty)?$thirdparty->id:'')); + dol_syslog("getLocalTaxesFromRate vatrate=".$vatrate." local=".$local); // Search local taxes $sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy"; @@ -3253,30 +3253,6 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller) return array($obj->localtax1_type, $obj->localtax1, $obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy); } } - - if(! isOnlyOneLocalTax(2)) - { - if(! isOnlyOneLocalTax(1)) - { - return array($obj->localtax2_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, get_localtax($vatrate, 2, $buyer, $seller),$obj->accountancy_code_sell,$obj->accountancy_code_buy); - } - else - { - return array($obj->localtax2_type, get_localtax($vatrate, 1, $buyer, $seller), $obj->localtax2_type, $obj->localtax2,$obj->accountancy_code_sell,$obj->accountancy_code_buy); - } - } - else - { - if(! isOnlyOneLocalTax(1)) - { - return array($obj->localtax2_type, $obj->localtax2, $obj->localtax1_type,get_localtax($vatrate, 1, $buyer, $seller) ,$obj->accountancy_code_sell,$obj->accountancy_code_buy); - } - else - { - return array($obj->localtax2_type, $obj->localtax2, $obj->localtax1_type, $obj->localtax1,$obj->accountancy_code_sell,$obj->accountancy_code_buy); - } - } - } } From fb959abc63b694b50ba77fd8db3f3184df798809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 25 Feb 2015 18:24:36 +0100 Subject: [PATCH 3/5] Misc PHPdoc fixes --- htdocs/core/class/conf.class.php | 4 ++++ htdocs/core/lib/functions.lib.php | 30 ++++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 9127ed614b3..d63ba2fb4ef 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -54,6 +54,10 @@ class Conf 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()); var $logbuffer = array(); + + /** + * @var LogHandlerInterface[] + */ var $loghandlers = array(); //! To store properties of multi-company diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 5aa6bb88e53..0fe78707ec6 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -385,7 +385,7 @@ function dol_size($size,$type='') * * @param string $str String to clean * @param string $newstr String to replace bad chars with - * @param string $unaccent 1=Remove also accent (default), 0 do not remove them + * @param int $unaccent 1=Remove also accent (default), 0 do not remove them * @return string String cleaned (a-zA-Z_) * * @see dol_string_nospecial, dol_string_unaccent @@ -487,8 +487,8 @@ function dolEscapeXML($string) * Returns text escaped for inclusion into javascript code * * @param string $stringtoescape String to escape - * @param string $mode 0=Escape also ' and " into ', 1=Escape ' but not " for usage into 'string', 2=Escape " but not ' for usage into "string", 3=Escape ' and " with \ - * @param string $noescapebackslashn 0=Escape also \n. 1=Do not escape \n. + * @param int $mode 0=Escape also ' and " into ', 1=Escape ' but not " for usage into 'string', 2=Escape " but not ' for usage into "string", 3=Escape ' and " with \ + * @param int $noescapebackslashn 0=Escape also \n. 1=Do not escape \n. * @return string Escaped string. Both ' and " are escaped into ' if they are escaped. */ function dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0) @@ -572,7 +572,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' global $conf, $user; // If syslog module enabled - if (empty($conf->syslog->enabled)) return false; + if (empty($conf->syslog->enabled)) return; if (! empty($level)) { @@ -582,7 +582,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' { throw new Exception('Incorrect log level'); } - if ($level > $conf->global->SYSLOG_LEVEL) return false; + if ($level > $conf->global->SYSLOG_LEVEL) return; // If adding log inside HTML page is required if (! empty($_REQUEST['logtohtml']) && ! empty($conf->global->MAIN_LOGTOHTML)) @@ -590,6 +590,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename=' $conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message; } + //TODO: Remove this. MAIN_ENABLE_LOG_HTML should be deprecated and use a HTML handler // If enable html log tag enabled and url parameter log defined, we show output log on HTML comments if (! empty($conf->global->MAIN_ENABLE_LOG_HTML) && ! empty($_GET["log"])) { @@ -768,7 +769,7 @@ function dol_bc($var,$moreclass='') * @param Object $object A company or contact object * @param int $withcountry 1=Add country into address string * @param string $sep Separator to use to build string - * @param Tranlsate $outputlangs Object lang that contains language for text translation. + * @param Translate $outputlangs Object lang that contains language for text translation. * @return string Formated string */ function dol_format_address($object,$withcountry=0,$sep="\n",$outputlangs='') @@ -1348,7 +1349,7 @@ function dol_print_skype($skype,$cid=0,$socid=0,$addlink=0,$max=64) * @param string $country Country code to use for formatting * @param int $cid Id of contact if known * @param int $socid Id of third party if known - * @param int $addlink ''=no link to create action, 'AC_TEL'=add link to clicktodial (if module enabled) and add link to create event (if conf->global->AGENDA_ADDACTIONFORPHONE set) + * @param string $addlink ''=no link to create action, 'AC_TEL'=add link to clicktodial (if module enabled) and add link to create event (if conf->global->AGENDA_ADDACTIONFORPHONE set) * @param string $separ Separation between numbers for a better visibility example : xx.xx.xx.xx.xx * @return string Formated phone number */ @@ -1564,6 +1565,7 @@ function isValidEmail($address) /** * Return true if phone number syntax is ok * + * TODO: Decide what to do with this * @param string $phone phone (Ex: "0601010101") * @return boolean true if phone syntax is OK, false if KO or empty string */ @@ -2649,7 +2651,7 @@ function print_fiche_titre($title, $mesg='', $picto='title.png', $pictoisfullpat * @param int $id To force an id on html objects * @return string */ -function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id='') +function load_fiche_titre($titre, $mesg='', $picto='title.png', $pictoisfullpath=0, $id=0) { global $conf; @@ -3987,7 +3989,7 @@ function dol_textishtml($msg,$option=0) * * @param string $text1 Text 1 * @param string $text2 Text 2 - * @param string $forxml false=Use
, true=Use
+ * @param bool $forxml false=Use
, true=Use
* @return string Text 1 + new line + Text2 * @see dol_textishtml */ @@ -4029,7 +4031,7 @@ function make_substitutions($chaine,$substitutionarray) * * @param array $substitutionarray Array substitution old value => new value value * @param Translate $outputlangs If we want substitution from special constants, we provide a language - * @param Object $object If we want substitution from special constants, we provide data in a source object + * @param object $object If we want substitution from special constants, we provide data in a source object * @param Mixed $parameters Add more parameters (useful to pass product lines) * @param string $callfunc What is the name of the custom function that will be called? (default: completesubstitutionarray) * @return void @@ -4072,8 +4074,8 @@ function complete_substitutions_array(&$substitutionarray,$outputlangs,$object=' /** * Format output for start and end date * - * @param timestamp $date_start Start date - * @param timestamp $date_end End date + * @param int $date_start Start date + * @param int $date_end End date * @param string $format Output format * @param Translate $outputlangs Output language * @return void @@ -4086,8 +4088,8 @@ function print_date_range($date_start,$date_end,$format = '',$outputlangs='') /** * Format output for start and end date * - * @param timestamp $date_start Start date - * @param timestamp $date_end End date + * @param int $date_start Start date + * @param int $date_end End date * @param string $format Output format * @param Translate $outputlangs Output language * @return string String From 8a67a3af10e463ef1b8d1b2e30ca1b2dc0f5da76 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Mar 2015 16:12:55 +0100 Subject: [PATCH 4/5] Fix missing one param --- htdocs/projet/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index 8baa287731e..1619afd4a91 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -228,7 +228,7 @@ if ( $resql ) { $tasktmp->id = $obj->taskid; $tasktmp->ref = $obj->label; - print $tasktmp->getNomUrl(1); + print $tasktmp->getNomUrl(1, 'withproject'); } else print $langs->trans("NoTasks"); print ''; From 3475433eaf117bbf4cc936e5b8216a8bf7303757 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Mar 2015 02:59:59 +0100 Subject: [PATCH 5/5] Fix: the bank information were visible into pdf but were not using correct setup to decide which bank to show. --- htdocs/comm/propal.php | 5 ++++ htdocs/commande/card.php | 14 +++++----- htdocs/compta/facture.php | 26 +++++++++---------- .../commande/doc/pdf_einstein.modules.php | 21 ++++++++------- 4 files changed, 37 insertions(+), 29 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 3739b59c338..2ef03929a7e 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -957,6 +957,11 @@ if (empty($reshook)) if (GETPOST('model')) { $object->setDocModel($user, GETPOST('model')); } + if (GETPOST('fk_bank')) { // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank'); + } else { + $object->fk_bank = $object->fk_account; + } // Define output language $outputlangs = $langs; diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index eb5767b173a..12150f9a61e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -94,6 +94,7 @@ $hookmanager->initHooks(array('ordercard','globalcard')); $permissionnote = $user->rights->commande->creer; // Used by the include of actions_setnotes.inc.php + /* * Actions */ @@ -1072,18 +1073,19 @@ if (empty($reshook)) exit(); } + // Generate order document (define into /core/modules/commande/modules_commande.php) else if ($action == 'builddoc') // In get or post { - /* - * Generate order document - * define into /core/modules/commande/modules_commande.php - */ - // Save last template used to generate document if (GETPOST('model')) $object->setDocModel($user, GETPOST('model', 'alpha')); + if (GETPOST('fk_bank')) { // this field may come from an external module + $object->fk_bank = GETPOST('fk_bank'); + } else { + $object->fk_bank = $object->fk_account; + } - // Define output language + // Define output language $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 3d7a71f8133..87cbbec398b 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -3601,13 +3601,13 @@ if ($action == 'create') $formmail->withdeliveryreceipt = 1; $formmail->withcancel = 1; // Tableau des substitutions - $formmail->substit ['__FACREF__'] = $object->ref; - $formmail->substit ['__SIGNATURE__'] = $user->signature; - $formmail->substit ['__REFCLIENT__'] = $object->ref_client; - $formmail->substit ['__THIRPARTY_NAME__'] = $object->thirdparty->name; - $formmail->substit ['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); - $formmail->substit ['__PERSONALIZED__'] = ''; - $formmail->substit ['__CONTACTCIVNAME__'] = ''; + $formmail->substit['__FACREF__'] = $object->ref; + $formmail->substit['__SIGNATURE__'] = $user->signature; + $formmail->substit['__REFCLIENT__'] = $object->ref_client; + $formmail->substit['__THIRPARTY_NAME__'] = $object->thirdparty->name; + $formmail->substit['__PROJECT_REF__'] = (is_object($object->projet)?$object->projet->ref:''); + $formmail->substit['__PERSONALIZED__'] = ''; + $formmail->substit['__CONTACTCIVNAME__'] = ''; // Find the good contact adress $custcontact = ''; @@ -3616,7 +3616,7 @@ if ($action == 'create') if (is_array($contactarr) && count($contactarr) > 0) { foreach ($contactarr as $contact) { - if ($contact ['libelle'] == $langs->trans('TypeContact_facture_external_BILLING')) { // TODO Use code and not label + if ($contact['libelle'] == $langs->trans('TypeContact_facture_external_BILLING')) { // TODO Use code and not label require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php'; @@ -3627,15 +3627,15 @@ if ($action == 'create') } if (! empty($custcontact)) { - $formmail->substit ['__CONTACTCIVNAME__'] = $custcontact; + $formmail->substit['__CONTACTCIVNAME__'] = $custcontact; } } // Tableau des parametres complementaires du post - $formmail->param ['action'] = $action; - $formmail->param ['models'] = $modelmail; - $formmail->param ['facid'] = $object->id; - $formmail->param ['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; + $formmail->param['action'] = $action; + $formmail->param['models'] = $modelmail; + $formmail->param['facid'] = $object->id; + $formmail->param['returnurl'] = $_SERVER["PHP_SELF"] . '?id=' . $object->id; // Init list of files if (GETPOST("mode") == 'init') { diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php index f6d28a4f135..cbe711ab7df 100644 --- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php +++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php @@ -718,19 +718,20 @@ class pdf_einstein extends ModelePDFCommandes // If payment mode not forced or forced to VIR, show payment with BAN if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if (! empty($conf->global->FACTURE_RIB_NUMBER)) - { - $account = new Account($this->db); - $account->fetch($conf->global->FACTURE_RIB_NUMBER); + if (! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) + { + $bankid=(empty($object->fk_bank)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_bank); + $account = new Account($this->db); + $account->fetch($bankid); - $curx=$this->marge_gauche; - $cury=$posy; + $curx=$this->marge_gauche; + $cury=$posy; - $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size); + $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account,0,$default_font_size); - $posy+=2; - } - } + $posy+=2; + } + } return $posy; }