From 3722fc1014245c2e5622d909fbd5bd1a44228a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 16 Apr 2016 20:16:38 +0200 Subject: [PATCH 01/16] Refactored FormVentilation class --- .../class/html.formventilation.class.php | 344 +++++++----------- 1 file changed, 122 insertions(+), 222 deletions(-) diff --git a/htdocs/accountancy/class/html.formventilation.class.php b/htdocs/accountancy/class/html.formventilation.class.php index b0b58a7a921..e17e4406376 100644 --- a/htdocs/accountancy/class/html.formventilation.class.php +++ b/htdocs/accountancy/class/html.formventilation.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2016 Alexandre Spangaro * Copyright (C) 2015 Ari Elbaz (elarifr) + * Copyright (C) 2016 Marcos García * * 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 @@ -29,18 +30,6 @@ */ class FormVentilation extends Form { - var $db; - var $error; - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - public function __construct($db) { - $this->db = $db; - } - /** * Return select filter with date of transaction * @@ -49,38 +38,25 @@ class FormVentilation extends Form * @return string HTML edit field */ function select_bookkeeping_importkey($htmlname = 'importkey', $selectedkey = '') { + $options = array(); + $sql = 'SELECT DISTINCT import_key from ' . MAIN_DB_PREFIX . 'accounting_bookkeeping'; $sql .= ' ORDER BY import_key DESC'; - - $out = ''; - - return $out; + + while ($obj = $this->db->fetch_object($resql)) { + $options[$obj->import_key] = dol_print_date($obj->import_key, 'dayhourtext'); + } + + return Form::selectarray($htmlname, $options, $selectedkey); } /** @@ -100,8 +76,8 @@ class FormVentilation extends Form global $conf; require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php'; - - $out = ''; + + $trunclength = defined('ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT') ? $conf->global->ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT : 50; $sql = "SELECT DISTINCT aa.account_number, aa.label, aa.rowid, aa.fk_pcg_version"; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; @@ -110,49 +86,44 @@ class FormVentilation extends Form $sql .= " AND aa.active = 1"; $sql .= " ORDER BY aa.account_number"; - dol_syslog(get_class($this) . "::select_account sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::select_account", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) { - - $out .= ajax_combobox($htmlname, $event); - $out .= ''; - } else { + + if (!$resql) { $this->error = "Error " . $this->db->lasterror(); dol_syslog(get_class($this) . "::select_account " . $this->error, LOG_ERR); - return - 1; + return -1; } + + $out = ajax_combobox($htmlname, $event); + + $options = array(); + $selected = null; + + while ($obj = $this->db->fetch_object($resql)) { + $label = length_accountg($obj->account_number) . ' - ' . $obj->label; + $label = dol_trunc($label, $trunclength); + + $select_value_in = $obj->rowid; + $select_value_out = $obj->rowid; + + if ($select_in == 1) { + $select_value_in = $obj->account_number; + } + if ($select_out == 1) { + $select_value_out = $obj->account_number; + } + + // Remember guy's we store in database llx_facturedet the rowid of accounting_account and not the account_number + // Because same account_number can be share between different accounting_system and do have the same meaning + if (($selectid != '') && $selectid == $select_value_in) { + $selected = $select_value_out; + } + + $options[$select_value_out] = $label; + } + + $out .= Form::selectarray($htmlname, $options, $selected, $showempty); $this->db->free($resql); return $out; } @@ -170,44 +141,30 @@ class FormVentilation extends Form function select_pcgtype($selectid, $htmlname = 'pcg_type', $showempty = 0, $event = array()) { global $conf; - $out = ''; - $sql = "SELECT DISTINCT pcg_type "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " ORDER BY pcg_type"; - dol_syslog(get_class($this) . "::select_pcgtype sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::select_pcgtype", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) { - - $out .= ajax_combobox($htmlname, $event); - - $out .= ''; - } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_pcgtype " . $this->error, LOG_ERR); - return - 1; + + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_pcgtype ".$this->error, LOG_ERR); + return -1; } + + $options = array(); + $out = ajax_combobox($htmlname, $event); + + while ($obj = $this->db->fetch_object($resql)) { + $options[$obj->pcg_type] = $obj->pcg_type; + } + + $out .= Form::selectarray($htmlname, $options, $selectid, $showempty); + $this->db->free($resql); return $out; } @@ -225,44 +182,30 @@ class FormVentilation extends Form function select_pcgsubtype($selectid, $htmlname = 'pcg_subtype', $showempty = 0, $event = array()) { global $conf; - $out = ''; - $sql = "SELECT DISTINCT pcg_subtype "; $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_account as aa"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version"; $sql .= " AND asy.rowid = " . $conf->global->CHARTOFACCOUNTS; $sql .= " ORDER BY pcg_subtype"; - dol_syslog(get_class($this) . "::select_pcgsubtype sql=" . $sql, LOG_DEBUG); + dol_syslog(get_class($this) . "::select_pcgsubtype", LOG_DEBUG); $resql = $this->db->query($sql); - if ($resql) { - - $out .= ajax_combobox($htmlname, $event); - - $out .= ''; - } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_pcgsubtype " . $this->error, LOG_ERR); - return - 1; + + if (!$resql) { + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR); + return -1; } + + $options = array(); + $out = ajax_combobox($htmlname, $event); + + while ($obj = $this->db->fetch_object($resql)) { + $options[$obj->pcg_subtype] = $obj->pcg_subtype; + } + + $out .= Form::selectarray($htmlname, $options, $selectid, $showempty); + $this->db->free($resql); return $out; } @@ -278,68 +221,51 @@ class FormVentilation extends Form * @return string String with HTML select */ function select_auxaccount($selectid, $htmlname = 'account_num_aux', $showempty = 0, $event = array()) { - global $conf; - - $out = ''; - - $aux_account = array (); - + + $aux_account = array(); + // Auxiliary customer account $sql = "SELECT DISTINCT code_compta, nom "; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; $sql .= " ORDER BY code_compta"; - dol_syslog(get_class($this) . "::select_auxaccount", LOG_DEBUG); + dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - while ( $obj = $this->db->fetch_object($resql) ) { - if (! empty($obj->code_compta)) { - $aux_account[$obj->code_compta] = $obj->code_compta . ' (' . $obj->nom . ')'; + while ($obj = $this->db->fetch_object($resql)) { + if (!empty($obj->code_compta)) { + $aux_account[$obj->code_compta] = $obj->code_compta.' ('.$obj->nom.')'; } } } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_pcgsubtype " . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR); + return -1; } $this->db->free($resql); - + // Auxiliary supplier account $sql = "SELECT DISTINCT code_compta_fournisseur, nom "; - $sql .= " FROM " . MAIN_DB_PREFIX . "societe"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe"; $sql .= " ORDER BY code_compta"; - dol_syslog(get_class($this) . "::select_auxaccount", LOG_DEBUG); + dol_syslog(get_class($this)."::select_auxaccount", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { - while ( $obj = $this->db->fetch_object($resql) ) { - if (! empty($obj->code_compta_fournisseur)) { - $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur . ' (' . $obj->nom . ')'; + while ($obj = $this->db->fetch_object($resql)) { + if (!empty($obj->code_compta_fournisseur)) { + $aux_account[$obj->code_compta_fournisseur] = $obj->code_compta_fournisseur.' ('.$obj->nom.')'; } } } else { - $this->error = "Error " . $this->db->lasterror(); - dol_syslog(get_class($this) . "::select_pcgsubtype " . $this->error, LOG_ERR); - return - 1; + $this->error = "Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::select_pcgsubtype ".$this->error, LOG_ERR); + return -1; } $this->db->free($resql); - + // Build select - if (count($aux_account) > 0) { - - $out .= ajax_combobox($htmlname, $event); - - $out .= ''; - } - + $out = ajax_combobox($htmlname, $event); + $out .= Form::selectarray($htmlname, $aux_account, $selectid, $showempty); + return $out; } @@ -352,55 +278,29 @@ class FormVentilation 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') { - $out = ''; - $out_array = array (); - - if ($output_format == 'html') { - $out .= '\n"; - } - - if ($output_format == 'html' || $output_format == 'options') { - return $out; - } elseif ($output_format == 'array') { + return Form::selectarray($htmlname, $out_array, $selected, $useempty, 0, 0, 'placeholder="aa"'); + } else { return $out_array; } } From 863efcbc5d4b96d1212ca3babee9f379d15ad1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 16 Apr 2016 21:33:23 +0200 Subject: [PATCH 02/16] NEW Removed unused FormOrder::selectSourcesCommande function Also refactored select functions to avoid using HTML and encourage using Form::selectarray function --- htdocs/core/class/dolreceiptprinter.class.php | 44 +++---- htdocs/core/class/html.formcompany.class.php | 33 +++--- htdocs/core/class/html.formmailing.class.php | 34 +----- htdocs/core/class/html.formorder.class.php | 111 ++++++------------ htdocs/margin/admin/margin.php | 21 ++-- htdocs/product/document.php | 36 +----- .../canvas/actions_card_common.class.php | 12 +- 7 files changed, 91 insertions(+), 200 deletions(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 90bf948e215..2499176b58b 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -300,17 +300,17 @@ class dolReceiptPrinter extends Escpos function selectTypePrinter($selected='', $htmlname='printertypeid') { global $langs; - $error = 0; - $html = ''; - - $this->resprint = $html; - return $error; + + $options = array( + 1 => $langs->trans('CONNECTOR_DUMMY'), + 2 => $langs->trans('CONNECTOR_FILE_PRINT'), + 3 => $langs->trans('CONNECTOR_NETWORK_PRINT'), + 4 => $langs->trans('CONNECTOR_WINDOWS_PRINT') + ); + + $this->resprint = Form::selectarray($htmlname, $options, $selected); + + return 0; } @@ -324,17 +324,17 @@ class dolReceiptPrinter extends Escpos function selectProfilePrinter($selected='', $htmlname='printerprofileid') { global $langs; - $error = 0; - $html = ''; - - $this->profileresprint = $html; - return $error; + + $options = array( + 0 => $langs->trans('PROFILE_DEFAULT'), + 1 => $langs->trans('PROFILE_SIMPLE'), + 2 => $langs->trans('PROFILE_EPOSTEP'), + 3 => $langs->trans('PROFILE_P822D'), + 4 => $langs->trans('PROFILE_STAR') + ); + + $this->profileresprint = Form::selectarray($htmlname, $options, $selected); + return 0; } diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 9091b4aead0..d51765e2a16 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -146,9 +146,6 @@ class FormCompany print ''; print ''; print ''; diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php index 3c47aceee8a..0c63049f9d8 100644 --- a/htdocs/core/class/html.formmailing.class.php +++ b/htdocs/core/class/html.formmailing.class.php @@ -27,22 +27,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; */ class FormMailing extends Form { - public $db; - public $error; public $errors=array(); - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - return 1; - } - /** * Output a select with destinaries status * @@ -59,26 +45,14 @@ class FormMailing extends Form require_once DOL_DOCUMENT_ROOT.'/comm/mailing/class/mailing.class.php'; $mailing = new Mailing($this->db); - - $array = $mailing->statut_dest; - //Cannot use form->selectarray because empty value is defaulted to -1 in this method and we use here status -1... - - $out = ''; - return $out; + return Form::selectarray($htmlname, $options, $selectedid, 0, 0, 0, '', 1); } } diff --git a/htdocs/core/class/html.formorder.class.php b/htdocs/core/class/html.formorder.class.php index 4ecbef60b58..68fa96e03ee 100644 --- a/htdocs/core/class/html.formorder.class.php +++ b/htdocs/core/class/html.formorder.class.php @@ -1,5 +1,6 @@ + * Copyright (C) 2016 Marcos García * * 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 @@ -21,29 +22,14 @@ * \brief File of predefined functions for HTML forms for order module */ +require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php'; /** * Class to manage HTML output components for orders * Before adding component here, check they are not into common part Form.class.php */ -class FormOrder +class FormOrder extends Form { - var $db; - var $error; - - - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - return 1; - } - /** * Return combo list of differents status of a orders @@ -53,51 +39,32 @@ class FormOrder * @param string $hmlname Name of HTML select element * @return void */ - function selectSupplierOrderStatus($selected='', $short=0, $hmlname='order_status') + public function selectSupplierOrderStatus($selected='', $short=0, $hmlname='order_status') { - $tmpsupplierorder=new CommandeFournisseur($db); - - print ''; + // 7 is same label than 6. 8 does not exists (billed is another field) + $statustohow = array( + '0' => '0', + '1' => '1', + '2' => '2', + '3' => '3', + '4' => '4', + '5' => '5', + '6' => '6,7', + '9' => '9' + ); + + $tmpsupplierorder = new CommandeFournisseur($this->db); + + foreach ($statustohow as $key => $value) { + $tmpsupplierorder->statut = $key; + $options[$value] = $tmpsupplierorder->getLibStatut($short); + } + + print Form::selectarray($hmlname, $options, $selected, 1); } - /** - * Return list of way to order - * - * @param string $selected Id of preselected order origin - * @param string $htmlname Name of HTML select list - * @param int $addempty 0=liste sans valeur nulle, 1=ajoute valeur inconnue - * @return array Tableau des sources de commandes - */ - function selectSourcesCommande($selected='',$htmlname='source_id',$addempty=0) - { - global $conf,$langs; - print ''; - } - - /** * Return list of input method (mode used to receive order, like order received by email, fax, online) * List found into table c_input_method. @@ -107,11 +74,9 @@ class FormOrder * @param int $addempty 0=list with no empty value, 1=list with empty value * @return array Tableau des sources de commandes */ - function selectInputMethod($selected='',$htmlname='source_id',$addempty=0) + public function selectInputMethod($selected='',$htmlname='source_id',$addempty=0) { - global $conf,$langs,$form; - - if (! is_object($form)) $form=new Form($this->db); + global $langs; $listofmethods=array(); @@ -121,24 +86,18 @@ class FormOrder dol_syslog(get_class($this)."::selectInputMethod", LOG_DEBUG); $resql=$this->db->query($sql); - if ($resql) - { - $i = 0; - $num = $this->db->num_rows($resql); - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $listofmethods[$obj->rowid] = $langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):$obj->label; - $i++; - } - } - else - { + + if (!$resql) { dol_print_error($this->db); return -1; } - print $form->selectarray($htmlname,$listofmethods,$selected,$addempty); + while ($obj = $this->db->fetch_object($resql)) { + $listofmethods[$obj->rowid] = $langs->trans($obj->code) != $obj->code ? $langs->trans($obj->code) : $obj->label; + } + + print Form::selectarray($htmlname,$listofmethods,$selected,$addempty); + return 1; } diff --git a/htdocs/margin/admin/margin.php b/htdocs/margin/admin/margin.php index 6e84b13e286..3a61ee0e72e 100644 --- a/htdocs/margin/admin/margin.php +++ b/htdocs/margin/admin/margin.php @@ -236,6 +236,12 @@ print ''; print ''; // GLOBAL DISCOUNT MANAGEMENT +$methods = array( + 1 => $langs->trans('UseDiscountAsProduct'), + 2 => $langs->trans('UseDiscountAsService'), + 3 => $langs->trans('UseDiscountOnTotal') +); + $var=!$var; print ''; print ''; @@ -243,20 +249,7 @@ print ""; print ''; print ''; print ''; print '"; - print ''; + print ''; // Delivery address if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index 1e5ace7353e..91972673201 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -99,10 +99,10 @@ if ($id > 0 || ! empty($ref)) print ''; // Customer - if ( is_null($object->client) ) + if ( is_null($object->thirdparty) ) $object->fetch_thirdparty(); print ""; - print ''; + print ''; // Discounts print ''; // Customer - if (is_null($object->client)) $object->fetch_thirdparty(); + if (is_null($object->thirdparty)) $object->fetch_thirdparty(); print ""; - print ''; + print ''; // Delivery address if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT)) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4d216a80264..d89871674b7 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1932,7 +1932,7 @@ class Facture extends CommonInvoice $this->date=dol_now(); $this->date_lim_reglement=$this->calculate_date_lim_reglement(); } - $num = $this->getNextNumRef($this->client); + $num = $this->getNextNumRef($this->thirdparty); } else { @@ -1971,7 +1971,7 @@ class Facture extends CommonInvoice if (! $error) { // Define third party as a customer - $result=$this->client->set_as_client(); + $result=$this->thirdparty->set_as_client(); // Si active on decremente le produit principal et ses composants a la validation de facture if ($this->type != self::TYPE_DEPOSIT && $result >= 0 && ! empty($conf->stock->enabled) && ! empty($conf->global->STOCK_CALCULATE_ON_BILL) && $idwarehouse > 0) @@ -3085,7 +3085,7 @@ class Facture extends CommonInvoice // If not a draft invoice and not temporary invoice if ($facref != 'PROV') { - $maxfacnumber = $this->getNextNumRef($this->client,'last'); + $maxfacnumber = $this->getNextNumRef($this->thirdparty,'last'); $ventilExportCompta = $this->getVentilExportCompta(); // If there is no invoice into the reset range and not already dispatched, we can delete if ($maxfacnumber == '' && $ventilExportCompta == 0) return 1; diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index b07a8f8c2d4..c5a7cfcdab2 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -175,7 +175,7 @@ if ($id > 0 || ! empty($ref)) // Customer print ""; - print ''; + print ''; print "
'; - print ''; print ''.$langs->trans('ForceBuyingPriceIfNullDetails').'
'.$langs->trans("MARGIN_METHODE_FOR_DISCOUNT").''; -print ''; +print Form::selectarray('MARGIN_METHODE_FOR_DISCOUNT', $methods, $conf->global->MARGIN_METHODE_FOR_DISCOUNT); print ''; print ''; diff --git a/htdocs/product/document.php b/htdocs/product/document.php index facff9f9a52..ca207f8429f 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -262,43 +262,11 @@ if ($object->id) print '
'; - $delauft_lang = (empty($lang_id)) ? $langs->getDefaultLang() : $lang_id; + $delauft_lang = empty($lang_id) ? $langs->getDefaultLang() : $lang_id; $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12); - print ''; + print Form::selectarray('lang_id', $langs_available, $delauft_lang, 0, 0, 0, '', 0, 0, 0, 'ASC'); if ($conf->global->MAIN_MULTILANGS) { print ''; diff --git a/htdocs/societe/canvas/actions_card_common.class.php b/htdocs/societe/canvas/actions_card_common.class.php index 782a7f070c4..74a05cba39d 100644 --- a/htdocs/societe/canvas/actions_card_common.class.php +++ b/htdocs/societe/canvas/actions_card_common.class.php @@ -439,12 +439,12 @@ abstract class ActionsCardCommon if ($modCodeClient->code_auto) $this->tpl['prefix_customercode'] = $modCodeClient->verif_prefixIsUsed(); // TODO create a function - $this->tpl['select_customertype'] = ''; + $this->tpl['select_customertype'] = Form::selectarray('client', array( + 0 => $langs->trans('NorProspectNorCustomer'), + 1 => $langs->trans('Customer'), + 2 => $langs->trans('Prospect'), + 3 => $langs->trans('ProspectCustomer') + ), $this->object->client); // Customer $this->tpl['customercode'] = $this->object->code_client; From 84b58d27e680d3f59eb53ef44dec27678dcb3cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 16 Apr 2016 21:41:06 +0200 Subject: [PATCH 03/16] NEW Renamed ActionComm::add function to ActionComm::create --- htdocs/comm/action/card.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 20 ++++++++++++++++--- ...terface_50_modAgenda_ActionsAuto.class.php | 2 +- htdocs/webservices/server_actioncomm.php | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 62798371a58..4ca75ade9b9 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -318,7 +318,7 @@ if ($action == 'add') $db->begin(); // On cree l'action - $idaction=$object->add($user); + $idaction=$object->create($user); if ($idaction > 0) { diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index d4e56bb2715..c0e1f11579c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -173,7 +173,7 @@ class ActionComm extends CommonObject * * @param DoliDB $db Database handler */ - function __construct($db) + public function __construct(DoliDB $db) { $this->db = $db; @@ -189,7 +189,7 @@ class ActionComm extends CommonObject * @param int $notrigger 1 = disable triggers, 0 = enable triggers * @return int Id of created event, < 0 if KO */ - function add($user,$notrigger=0) + public function create(User $user, $notrigger = 0) { global $langs,$conf,$hookmanager; @@ -395,6 +395,20 @@ class ActionComm extends CommonObject } + /** + * Add an action/event into database. + * $this->type_id OR $this->type_code must be set. + * + * @param User $user Object user making action + * @param int $notrigger 1 = disable triggers, 0 = enable triggers + * @return int Id of created event, < 0 if KO + * @deprecated Use create instead + */ + public function add(User $user, $notrigger = 0) + { + $this->create($user, $notrigger); + } + /** * Load an object from its id and create a new one in database * @@ -436,7 +450,7 @@ class ActionComm extends CommonObject } // Create clone - $result=$this->add($fuser); + $result=$this->create($fuser); if ($result < 0) $error++; if (! $error) diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 0a5d4a81ed6..5c85309ed8c 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -803,7 +803,7 @@ class InterfaceActionsAuto extends DolibarrTriggers $actioncomm->fk_element = $object->id; $actioncomm->elementtype = $object->element; - $ret=$actioncomm->add($user); // User creating action + $ret=$actioncomm->create($user); // User creating action unset($object->actionmsg); unset($object->actionmsg2); unset($object->actiontypecode); // When several action are called on same object, we must be sure to not reuse value of first action. diff --git a/htdocs/webservices/server_actioncomm.php b/htdocs/webservices/server_actioncomm.php index dc07bc156ec..a5df31c2a7e 100644 --- a/htdocs/webservices/server_actioncomm.php +++ b/htdocs/webservices/server_actioncomm.php @@ -459,7 +459,7 @@ function createActionComm($authentication,$actioncomm) $db->begin(); - $result=$newobject->add($fuser); + $result=$newobject->create($fuser); if ($result <= 0) { $error++; From 21ba24a0cdfd3452f21dac5026e0f6e8585e5d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sat, 16 Apr 2016 22:13:28 +0200 Subject: [PATCH 04/16] NEW Deprecated Societe::set_prospect_level, Societe::set_commnucation_level, Societe::set_OutstandingBill functions --- htdocs/comm/card.php | 6 +- htdocs/societe/class/societe.class.php | 80 ++++---------------------- htdocs/societe/list.php | 2 +- 3 files changed, 14 insertions(+), 74 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 62b251ac01d..a5c4d4980e8 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -146,7 +146,7 @@ if (empty($reshook)) { $object->fetch($id); $object->fk_prospectlevel=GETPOST('prospect_level_id','alpha'); - $result=$object->set_prospect_level($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -155,7 +155,7 @@ if (empty($reshook)) { $object->fetch($id); $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); - $result=$object->set_commnucation_level($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } @@ -164,7 +164,7 @@ if (empty($reshook)) { $object->fetch($id); $object->outstanding_limit=GETPOST('outstanding_limit'); - $result=$object->set_OutstandingBill($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } } diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 1005b8c3c8d..60e954c9f6e 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -678,6 +678,7 @@ class Societe extends CommonObject $this->idprof5 = (! empty($this->idprof5)?trim($this->idprof5):''); $this->idprof6 = (! empty($this->idprof6)?trim($this->idprof6):''); $this->prefix_comm = trim($this->prefix_comm); + $this->outstanding_limit = price2num($this->outstanding_limit); $this->tva_assuj = trim($this->tva_assuj); $this->tva_intra = dol_sanitizeFileName($this->tva_intra,''); @@ -831,7 +832,7 @@ class Societe extends CommonObject $sql .= ",prefix_comm = ".(! empty($this->prefix_comm)?"'".$this->db->escape($this->prefix_comm)."'":"null"); $sql .= ",fk_effectif = ".(! empty($this->effectif_id)?"'".$this->db->escape($this->effectif_id)."'":"null"); - + $sql .= ",fk_stcomm='".$this->stcomm_id."'"; $sql .= ",fk_typent = ".(! empty($this->typent_id)?"'".$this->db->escape($this->typent_id)."'":"0"); $sql .= ",fk_forme_juridique = ".(! empty($this->forme_juridique_code)?"'".$this->db->escape($this->forme_juridique_code)."'":"null"); @@ -847,6 +848,8 @@ class Societe extends CommonObject $sql .= ",barcode = ".(! empty($this->barcode)?"'".$this->db->escape($this->barcode)."'":"null"); $sql .= ",default_lang = ".(! empty($this->default_lang)?"'".$this->db->escape($this->default_lang)."'":"null"); $sql .= ",logo = ".(! empty($this->logo)?"'".$this->db->escape($this->logo)."'":"null"); + $sql .= ",outstanding_limit= '".($this->outstanding_limit!=''?$this->outstanding_limit:'null')."'"; + $sql .= ",fk_prospectlevel='".$this->fk_prospectlevel."'"; $sql .= ",webservices_url = ".(! empty($this->webservices_url)?"'".$this->db->escape($this->webservices_url)."'":"null"); $sql .= ",webservices_key = ".(! empty($this->webservices_key)?"'".$this->db->escape($this->webservices_key)."'":"null"); @@ -3178,30 +3181,11 @@ class Societe extends CommonObject * * @param User $user Utilisateur qui definie la remise * @return int <0 if KO, >0 if OK + * @deprecated Use update function instead */ function set_prospect_level(User $user) { - if ($this->id) - { - $this->db->begin(); - - // Positionne remise courante - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql.= " fk_prospectlevel='".$this->fk_prospectlevel."'"; - $sql.= ",fk_user_modif='".$user->id."'"; - $sql.= " WHERE rowid = ".$this->id; - dol_syslog(get_class($this)."::set_prospect_level", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - $this->db->rollback(); - $this->error=$this->db->error(); - return -1; - } - - $this->db->commit(); - return 1; - } + return $this->update($this->id, $user); } /** @@ -3274,31 +3258,11 @@ class Societe extends CommonObject * * @param User $user User making change * @return int <0 if KO, >0 if OK + * @deprecated Use update function instead */ function set_commnucation_level($user) { - if ($this->id) - { - $this->db->begin(); - - // Positionne remise courante - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql.= " fk_stcomm='".$this->stcomm_id."'"; - $sql.= ",fk_user_modif='".$user->id."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::set_commnucation_level", LOG_DEBUG); - $resql=$this->db->query($sql); - if (! $resql) - { - $this->db->rollback(); - $this->error=$this->db->lasterror(); - return -1; - } - - $this->db->commit(); - return 1; - } + return $this->update($this->id, $user); } /** @@ -3306,35 +3270,11 @@ class Societe extends CommonObject * * @param User $user User making change * @return int <0 if KO, >0 if OK + * @deprecated Use update function instead */ function set_OutstandingBill(User $user) { - if ($this->id) - { - $this->db->begin(); - - // Clean parameters - $outstanding = price2num($this->outstanding_limit); - - // Set outstanding amount - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET "; - $sql.= " outstanding_limit= '".($outstanding!=''?$outstanding:'null')."'"; - $sql.= " WHERE rowid = ".$this->id; - - dol_syslog(get_class($this)."::set_outstanding", LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $this->db->commit(); - return 1; - } - else - { - $this->db->rollback(); - $this->error=$this->db->lasterror(); - return -1; - } - } + return $this->update($this->id, $user); } /** diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index e01331617ea..4e9d0b1ed18 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -191,7 +191,7 @@ if (empty($reshook)) $object = new Client($db); $result=$object->fetch(GETPOST('stcommsocid')); $object->stcomm_id=dol_getIdFromCode($db, GETPOST('stcomm','alpha'), 'c_stcomm'); - $result=$object->set_commnucation_level($user); + $result=$object->update($object->id, $user); if ($result < 0) setEventMessages($object->error,$object->errors,'errors'); $action=''; From d5980a5bf8039a4f86a400387841488d03abf5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 17 Apr 2016 12:20:45 +0200 Subject: [PATCH 05/16] Update html.formmail.class.php --- htdocs/core/class/html.formmail.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 46b485d8a3c..23b0fc5d6e2 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -920,6 +920,7 @@ class FormMail extends Form */ function setSubstitFromObject($object) { + global $user; $this->substit['__REF__'] = $object->ref; $this->substit['__SIGNATURE__'] = $user->signature; $this->substit['__REFCLIENT__'] = $object->ref_client; From 54dd1763fe56fba7f4f9360a167430e2ef704a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 17 Apr 2016 15:05:54 +0200 Subject: [PATCH 06/16] Little refactor --- htdocs/core/lib/company.lib.php | 20 ++++++++++---------- htdocs/core/lib/functions.lib.php | 7 ++----- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index e2d63d6d151..8631c576576 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -57,17 +57,17 @@ function societe_prepare_head(Societe $object) if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && ($object->client==1 || $object->client==3)) $head[$h][1] .= $langs->trans("Customer"); $head[$h][2] = 'customer'; $h++; - } - if (($object->client==1 || $object->client==2 || $object->client==3) && (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))) - { - $langs->load("products"); - // price - $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id; - $head[$h][1] = $langs->trans("CustomerPrices"); - $head[$h][2] = 'price'; - $h++; - } + if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) + { + $langs->load("products"); + // price + $head[$h][0] = DOL_URL_ROOT.'/societe/price.php?socid='.$object->id; + $head[$h][1] = $langs->trans("CustomerPrices"); + $head[$h][2] = 'price'; + $h++; + } + } if (! empty($conf->fournisseur->enabled) && $object->fournisseur && ! empty($user->rights->fournisseur->lire)) { $head[$h][0] = DOL_URL_ROOT.'/fourn/card.php?socid='.$object->id; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 6b69427eacd..befcf4ef4ff 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3929,13 +3929,10 @@ function get_product_localtax_for_country($idprod, $local, $thirdparty_seller) * @return float Taux de tva a appliquer, -1 si ne peut etre determine * @see get_default_npr, get_default_localtax */ -function get_default_tva($thirdparty_seller, $thirdparty_buyer, $idprod=0, $idprodfournprice=0) +function get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0) { global $conf; - if (!is_object($thirdparty_seller)) return -1; - if (!is_object($thirdparty_buyer)) return -1; - // Note: possible values for tva_assuj are 0/1 or franchise/reel $seller_use_vat=((is_numeric($thirdparty_seller->tva_assuj) && ! $thirdparty_seller->tva_assuj) || (! is_numeric($thirdparty_seller->tva_assuj) && $thirdparty_seller->tva_assuj=='franchise'))?0:1; @@ -4012,7 +4009,7 @@ function get_default_tva($thirdparty_seller, $thirdparty_buyer, $idprod=0, $idpr * @return float 0 or 1 * @see get_default_tva, get_default_localtax */ -function get_default_npr($thirdparty_seller, $thirdparty_buyer, $idprod=0, $idprodfournprice=0) +function get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0) { global $db; From e2c86d3fd856644adb0e12aec226a3ea1bc54a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Sun, 17 Apr 2016 15:24:22 +0200 Subject: [PATCH 07/16] NEW Removed deprecated CommonObject::client property. Please use CommonObject::thirdparty instead --- htdocs/comm/propal/class/propal.class.php | 14 +++++------ htdocs/comm/propal/contact.php | 2 +- htdocs/comm/propal/note.php | 4 ++-- htdocs/commande/class/commande.class.php | 12 +++++----- htdocs/commande/contact.php | 4 ++-- htdocs/compta/facture/class/facture.class.php | 6 ++--- htdocs/compta/facture/contact.php | 2 +- htdocs/compta/facture/fiche-rec.php | 2 +- htdocs/compta/facture/list.php | 2 +- htdocs/compta/paiement.php | 4 ++-- htdocs/core/class/commonobject.class.php | 8 ------- htdocs/core/lib/files.lib.php | 2 +- .../doc/doc_generic_order_odt.modules.php | 4 ++-- .../contract/doc/pdf_strato.modules.php | 12 +++++----- .../doc/doc_generic_shipment_odt.modules.php | 4 ++-- .../doc/doc_generic_invoice_odt.modules.php | 4 ++-- .../pdf/pdf_canelle.modules.php | 2 +- .../pdf/pdf_muscadet.modules.php | 6 ++--- ..._generic_supplier_proposal_odt.modules.php | 4 ++-- htdocs/don/card.php | 2 +- htdocs/expedition/card.php | 6 ++--- htdocs/expedition/shipment.php | 2 +- htdocs/fichinter/card.php | 24 +++++++++---------- htdocs/fichinter/contact.php | 4 ++-- htdocs/fichinter/document.php | 2 +- .../fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/commande/card.php | 6 ++--- htdocs/fourn/facture/card.php | 8 +++---- htdocs/livraison/card.php | 6 ++--- htdocs/product/card.php | 2 +- .../class/supplier_proposal.class.php | 16 ++++++------- htdocs/supplier_proposal/note.php | 4 ++-- 32 files changed, 87 insertions(+), 95 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index a83600072d4..99f5058ad3f 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -247,16 +247,16 @@ class Propal extends CommonObject $productdesc = $prod->description; - $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); - $tva_npr = get_default_npr($mysoc,$this->client,$prod->id); + $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); + $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->client,$tva_npr); - $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->client,$tva_npr); + $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->thirdparty,$tva_npr); + $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->thirdparty,$tva_npr); // multiprix - if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) + if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) { - $price = $prod->multiprices[$this->client->price_level]; + $price = $prod->multiprices[$this->thirdparty->price_level]; } else { @@ -1975,7 +1975,7 @@ class Propal extends CommonObject if (! empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->client->default_lang); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); } //$ret=$object->fetch($id); // Reload to get new records diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 544c5ab27e3..33504a1d27b 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -177,7 +177,7 @@ if ($object->id > 0) // Customer print "
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'.$object->thirdparty->getNomUrl(1).'
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'.$object->thirdparty->getNomUrl(1).'
'.$langs->trans('Discounts').''; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ae7c18ac077..827f3976fc8 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1420,15 +1420,15 @@ class Commande extends CommonOrder $prod=new Product($this->db); $prod->fetch($idproduct); - $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); - $tva_npr = get_default_npr($mysoc,$this->client,$prod->id); + $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); + $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx=get_localtax($tva_tx,1,$this->client,$mysoc,$tva_npr); - $localtax2_tx=get_localtax($tva_tx,2,$this->client,$mysoc,$tva_npr); + $localtax1_tx=get_localtax($tva_tx,1,$this->thirdparty,$mysoc,$tva_npr); + $localtax2_tx=get_localtax($tva_tx,2,$this->thirdparty,$mysoc,$tva_npr); // multiprix - if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) - $price = $prod->multiprices[$this->client->price_level]; + if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) + $price = $prod->multiprices[$this->thirdparty->price_level]; else $price = $prod->price; diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index 93d46c05997..da584f9197c 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -171,10 +171,10 @@ if ($id > 0 || ! empty($ref)) print '
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'.$object->thirdparty->getNomUrl(1).'
".$langs->trans("Company")."'.$object->client->getNomUrl(1,'compta').'
'.$object->thirdparty->getNomUrl(1,'compta').'
"; dol_fiche_end(); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 9b381c1af04..275724d3012 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -281,7 +281,7 @@ if ($action == 'create') $object->fetch_thirdparty(); // Third party - print ''.$langs->trans("Customer").''.$object->client->getNomUrl(1,'customer').''; + print ''.$langs->trans("Customer").''.$object->thirdparty->getNomUrl(1,'customer').''; print ''; print $langs->trans("Comment"); print ''; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 64813c56f1d..e2883081452 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -540,7 +540,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 37b6ebdc3eb..fa1341dcbc6 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -449,14 +449,14 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie print ''; print ''; print ''; - print ''; + print ''; dol_fiche_head(); print ''; // Third party - print '\n"; + print '\n"; // Date payment print ''; // Third party - print ""; + print ""; if (empty($conf->global->FICHINTER_DISABLE_DETAILS)) { @@ -1824,7 +1824,7 @@ else if ($id > 0 || ! empty($ref)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index b92c1442d14..b64a16f91ba 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -133,11 +133,11 @@ if ($id > 0 || ! empty($ref)) print ""; // Customer - if ( is_null($object->client) ) + if ( is_null($object->thirdparty) ) $object->fetch_thirdparty(); print ""; - print ''; + print ''; print "
'.$langs->trans('Company').''.$facture->client->getNomUrl(4)."
'.$langs->trans('Company').''.$facture->thirdparty->getNomUrl(4)."
'.$langs->trans('Date').''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7de64135245..7cc889a67e9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -130,12 +130,6 @@ abstract class CommonObject * @see fetch_thirdparty() */ public $thirdparty; - /** - * @deprecated - * @var Societe A related customer - * @see thirdparty - */ - public $client; /** * @var User A related user @@ -1016,12 +1010,10 @@ abstract class CommonObject if ($idtofetch) { $thirdparty = new Societe($this->db); $result = $thirdparty->fetch($idtofetch); - $this->client = $thirdparty; // deprecated $this->thirdparty = $thirdparty; // Use first price level if level not defined for third party if (!empty($conf->global->PRODUIT_MULTIPRICES) && empty($this->thirdparty->price_level)) { - $this->client->price_level = 1; // deprecated $this->thirdparty->price_level = 1; } diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 7d8ac5f1750..9be021b975e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1358,7 +1358,7 @@ function dol_meta_create($object) if (is_dir($dir)) { $nblignes = count($object->lines); - $client = $object->client->name . " " . $object->client->address . " " . $object->client->zip . " " . $object->client->town; + $client = $object->thirdparty->name . " " . $object->thirdparty->address . " " . $object->thirdparty->zip . " " . $object->thirdparty->town; $meta = "REFERENCE=\"" . $object->ref . "\" DATE=\"" . dol_print_date($object->date,'') . "\" NB_ITEMS=\"" . $nblignes . "\" 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 84dec7b817e..9e26b31b0ce 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 @@ -289,11 +289,11 @@ class doc_generic_order_odt extends ModelePDFCommandes { // 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->client; + else $socobject = $object->thirdparty; } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Make substitution diff --git a/htdocs/core/modules/contract/doc/pdf_strato.modules.php b/htdocs/core/modules/contract/doc/pdf_strato.modules.php index 25ae8c7f015..f8097249a5b 100644 --- a/htdocs/core/modules/contract/doc/pdf_strato.modules.php +++ b/htdocs/core/modules/contract/doc/pdf_strato.modules.php @@ -556,12 +556,12 @@ class pdf_strato extends ModelePDFContract $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_creation,"day",false,$outputlangs,true), '', 'R'); - if ($object->client->code_client) + if ($object->thirdparty->code_client) { $posy+=4; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->client->code_client), '', 'R'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CustomerCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_client), '', 'R'); } if ($showaddress) @@ -576,7 +576,7 @@ class pdf_strato extends ModelePDFContract $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Name").": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n"; } - $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->client); + $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender $posy=42; @@ -614,19 +614,19 @@ class pdf_strato extends ModelePDFContract $result=$object->fetch_contact($arrayidcontact[0]); } - $this->recipient = $object->client; + $this->recipient = $object->thirdparty; //Recipient name // On peut utiliser le nom de la societe du contact if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { - $thirdparty = $object->client; + $thirdparty = $object->thirdparty; } $this->recipient->name = pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->client, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object); + $carac_client=pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (isset($object->contact)?$object->contact:''), $usecontact, 'target', $object); // Show recipient $widthrecbox=100; 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 c2fcf108c10..2693a4f013a 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 @@ -289,11 +289,11 @@ class doc_generic_shipment_odt extends ModelePdfExpedition { // 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->client; + else $socobject = $object->thirdparty; } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Make substitution 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 2cd392a0bd6..a8baaab2282 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 @@ -291,14 +291,14 @@ class doc_generic_invoice_odt extends ModelePDFFactures // 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->client; + $socobject = $object->thirdparty; // if we have a BILLING contact and we dont use it as recipient we store the contact object for later use $contactobject = $object->contact; } } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Fetch info for linked propal 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 ae96756b9f0..ddbea30e833 100644 --- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -1061,7 +1061,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender $posy=42; 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 2d30037878d..225ff02e629 100644 --- a/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/core/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -1113,7 +1113,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($showaddress) { // Sender properties - $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->client); + $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); // Show sender $posy=42; @@ -1158,12 +1158,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { - $thirdparty = $object->client; + $thirdparty = $object->thirdparty; } $carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); - $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,($usecontact?$object->contact:''),$usecontact,'target',$object); + $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->thirdparty,($usecontact?$object->contact:''),$usecontact,'target',$object); // Show recipient $widthrecbox=100; 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 d1386d646a5..212685ba519 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 @@ -320,11 +320,11 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal { // 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->client; + else $socobject = $object->thirdparty; } else { - $socobject=$object->client; + $socobject=$object->thirdparty; } // Make substitution diff --git a/htdocs/don/card.php b/htdocs/don/card.php index cd8a2e174f8..fab2560f816 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -264,7 +264,7 @@ if ($action == 'builddoc') $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 8f461a2a0c0..4547a94566a 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -501,7 +501,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$shipment->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -1562,7 +1562,7 @@ else if ($id || $ref) $outputlangs = $langs; $newlang=''; if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id','alpha'); - if (empty($newlang)) $newlang=$object->client->default_lang; + if (empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -1850,7 +1850,7 @@ else if ($id || $ref) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 2677d06ec7b..5de764922e1 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -530,7 +530,7 @@ if ($id > 0 || ! empty($ref)) $outputlangs = $langs; $newlang=''; if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$commande->client->default_lang; + if (empty($newlang)) $newlang=$commande->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 74f50f26a5b..c3f2d28959e 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -123,7 +123,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -152,7 +152,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -410,7 +410,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -515,7 +515,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -612,7 +612,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -647,7 +647,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -668,7 +668,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -688,7 +688,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -750,12 +750,12 @@ if (empty($reshook)) // Recipient was provided from combo list if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party { - $sendto = $object->client->email; + $sendto = $object->thirdparty->email; $sendtoid = 0; } else // Id du contact { - $sendto = $object->client->contact_get_property(GETPOST('receiver'),'email'); + $sendto = $object->thirdparty->contact_get_property(GETPOST('receiver'),'email'); $sendtoid = GETPOST('receiver','alpha'); } } @@ -1277,7 +1277,7 @@ else if ($id > 0 || ! empty($ref)) print '
".$langs->trans("Company").''.$object->client->getNomUrl(1)."
".$langs->trans("Company").''.$object->thirdparty->getNomUrl(1)."
".$langs->trans("Company")."'.$object->client->getNomUrl(1).'
'.$object->thirdparty->getNomUrl(1).'
"; print ''; diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 38176068d72..aca31d4e7c2 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -111,7 +111,7 @@ if ($object->id) print ''; // Societe - print "".$langs->trans("Company")."".$object->client->getNomUrl(1).""; + print "".$langs->trans("Company")."".$object->thirdparty->getNomUrl(1).""; print ''.$langs->trans("NbOfAttachedFiles").''.count($filearray).''; print ''.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").''; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 0e11079f476..e209dd741d6 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -975,7 +975,7 @@ class FactureFournisseur extends CommonInvoice } else if (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref)) // empty should not happened, but when it occurs, the test save life { - $num = $this->getNextNumRef($this->client); + $num = $this->getNextNumRef($this->thirdparty); } else { diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 59bc805a120..31c2d0aba00 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1184,12 +1184,12 @@ if (empty($reshook)) // Recipient was provided from combo list if (GETPOST('receiver','alpha') == 'thirdparty') // Id of third party { - $sendto = $object->client->email; + $sendto = $object->thirdparty->email; $sendtoid = 0; } else // Id du contact { - $sendto = $object->client->contact_get_property(GETPOST('receiver','alpha'),'email'); + $sendto = $object->thirdparty->contact_get_property(GETPOST('receiver','alpha'),'email'); $sendtoid = GETPOST('receiver','alpha'); } } @@ -2451,7 +2451,7 @@ elseif (! empty($object->id)) if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 64f459886ae..b7e22e9e42f 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -976,12 +976,12 @@ if (empty($reshook)) // Recipient was provided from combo list if ($_POST['receiver'] == 'thirdparty') // Id of third party { - $sendto = $object->client->email; + $sendto = $object->thirdparty->email; $sendtoid = 0; } else // Id du contact { - $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); + $sendto = $object->thirdparty->contact_get_property($_POST['receiver'],'email'); $sendtoid = $_POST['receiver']; } } @@ -1120,7 +1120,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -2423,7 +2423,7 @@ else if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang = $_REQUEST['lang_id']; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) - $newlang = $object->client->default_lang; + $newlang = $object->thirdparty->default_lang; if (!empty($newlang)) { diff --git a/htdocs/livraison/card.php b/htdocs/livraison/card.php index 8a815c31edb..9ae66ee685e 100644 --- a/htdocs/livraison/card.php +++ b/htdocs/livraison/card.php @@ -255,7 +255,7 @@ if ($action == 'builddoc') // En get ou en post $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -413,7 +413,7 @@ if ($action == 'create') // Seems to no be used $outputlangs = $langs; $newlang=''; if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$commande->client->default_lang; + if (empty($newlang)) $newlang=$commande->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); @@ -755,7 +755,7 @@ else $outputlangs = $langs; $newlang=''; if (empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if (empty($newlang)) $newlang=$object->client->default_lang; + if (empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ef126a85b52..4632c7ebb5c 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -152,7 +152,7 @@ if (empty($reshook)) $outputlangs = $langs; $newlang=''; if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id','alpha')) $newlang=GETPOST('lang_id','alpha'); - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang; if (! empty($newlang)) { $outputlangs = new Translate("",$conf); diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 5f9fc3eacd6..f5675db86f3 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -221,16 +221,16 @@ class SupplierProposal extends CommonObject $productdesc = $prod->description; - $tva_tx = get_default_tva($mysoc,$this->client,$prod->id); - $tva_npr = get_default_npr($mysoc,$this->client,$prod->id); + $tva_tx = get_default_tva($mysoc,$this->thirdparty,$prod->id); + $tva_npr = get_default_npr($mysoc,$this->thirdparty,$prod->id); if (empty($tva_tx)) $tva_npr=0; - $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->client,$tva_npr); - $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->client,$tva_npr); + $localtax1_tx = get_localtax($tva_tx,1,$mysoc,$this->thirdparty,$tva_npr); + $localtax2_tx = get_localtax($tva_tx,2,$mysoc,$this->thirdparty,$tva_npr); // multiprix - if($conf->global->PRODUIT_MULTIPRICES && $this->client->price_level) + if($conf->global->PRODUIT_MULTIPRICES && $this->thirdparty->price_level) { - $price = $prod->multiprices[$this->client->price_level]; + $price = $prod->multiprices[$this->thirdparty->price_level]; } else { @@ -1662,7 +1662,7 @@ class SupplierProposal extends CommonObject if (! empty($conf->global->MAIN_MULTILANGS)) { $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->client->default_lang); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $this->thirdparty->default_lang); $outputlangs->setDefaultLang($newlang); } //$ret=$object->fetch($id); // Reload to get new records @@ -1764,7 +1764,7 @@ class SupplierProposal extends CommonObject $values = array( "'".$this->db->idate($now)."'", $product->fk_product, - $this->client->id, + $this->thirdparty->id, "'".$product->ref_fourn."'", $price, $qty, diff --git a/htdocs/supplier_proposal/note.php b/htdocs/supplier_proposal/note.php index 4e9f3affa50..a3799c0eb29 100644 --- a/htdocs/supplier_proposal/note.php +++ b/htdocs/supplier_proposal/note.php @@ -87,10 +87,10 @@ if ($id > 0 || ! empty($ref)) print ''; // Customer - if ( is_null($object->client) ) + if ( is_null($object->thirdparty) ) $object->fetch_thirdparty(); print "".$langs->trans("Supplier").""; - print ''.$object->client->getNomUrl(1).''; + print ''.$object->thirdparty->getNomUrl(1).''; print ''.$langs->trans('SupplierProposalDate').''; print dol_print_date($object->date_livraison,'daytext'); From bb554a73bd27e56a68e497e715315326926fe066 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Tue, 19 Apr 2016 06:18:34 +0200 Subject: [PATCH 08/16] FIX: Accounting library already declared in line 54 --- htdocs/product/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index ef126a85b52..cbef61d7590 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -44,7 +44,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/modules/product/modules_product.php'; From f0f4933905c3da568b7555ce49716af37e3bad5c Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 16 Apr 2016 11:19:46 +0100 Subject: [PATCH 09/16] new function updateExtraField to update one particular extrafield Conflicts: htdocs/core/class/commonobject.class.php --- htdocs/core/class/commonobject.class.php | 82 ++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 7de64135245..2017ef3e873 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -10,6 +10,7 @@ * Copyright (C) 2012-2015 Raphaël Doursenaud * Copyright (C) 2012 Cedric Salvador * Copyright (C) 2015 Alexandre Spangaro + * Copyright (C) 2016 Bahfir abbes * * 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 @@ -4237,6 +4238,87 @@ abstract class CommonObject } else return 0; } + /** + * Update an exta field value for the current object. + * Data to describe values to insert/update are stored into $this->array_options=array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) + * This function delte record with all extrafields and insert them again from the array $this->array_options. + * $key key of the extrafield + * @return int -1=error, O=did nothing, 1=OK + */ + function updateExtraField($key) + { + global $conf,$langs; + + $error=0; + + if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) return 0; // For avoid conflicts if trigger used + + if (! empty($this->array_options) && !empty($this->array_options["options_$key"])) + { + // Check parameters + $langs->load('admin'); + require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + $extrafields = new ExtraFields($this->db); + $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); + + $attributeType = $extrafields->attribute_type[$key]; + $attributeLabel = $extrafields->attribute_label[$key]; + $attributeParam = $extrafields->attribute_param[$key]; + switch ($attributeType) + { + case 'int': + if (!is_numeric($value) && $value!='') + { + $this->errors[]=$langs->trans("ExtraFieldHasWrongValue",$attributeLabel); + return -1; + } + elseif ($value=='') + { + $this->array_options[$key] = null; + } + break; + case 'price': + $this->array_options[$key] = price2num($this->array_options[$key]); + break; + case 'date': + $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + break; + case 'datetime': + $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + break; + case 'link': + $param_list=array_keys($attributeParam ['options']); + // 0 : ObjectName + // 1 : classPath + $InfoFieldList = explode(":", $param_list[0]); + dol_include_once($InfoFieldList[1]); + $object = new $InfoFieldList[0]($this->db); + if ($value) + { + $object->fetch(0,$value); + $this->array_options[$key]=$object->id; + } + break; + } + + $this->db->begin(); + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET $key=$value"; + $sql .= " WHERE fk_object = ".$this->id; + $resql = $this->db->query($sql); + if (! $resql) + { + $this->error=$this->db->lasterror(); + $this->db->rollback(); + return -1; + } + else + { + $this->db->commit(); + return 1; + } + } + else return 0; + } /** * Function to show lines of extrafields with output datas From 62aa6285245260af46a080039b09e5b7606776bc Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 16 Apr 2016 17:41:47 +0100 Subject: [PATCH 10/16] fixmycommit:new function updateExtraField to update one particular extrafield --- htdocs/core/class/commonobject.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 2017ef3e873..46278ffcdf4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -4261,6 +4261,7 @@ abstract class CommonObject $extrafields = new ExtraFields($this->db); $target_extrafields=$extrafields->fetch_name_optionals_label($this->table_element); + $value=$this->array_options["options_$key"]; $attributeType = $extrafields->attribute_type[$key]; $attributeLabel = $extrafields->attribute_label[$key]; $attributeParam = $extrafields->attribute_param[$key]; @@ -4274,17 +4275,17 @@ abstract class CommonObject } elseif ($value=='') { - $this->array_options[$key] = null; + $this->array_options["options_$key"] = null; } break; case 'price': - $this->array_options[$key] = price2num($this->array_options[$key]); + $this->array_options["options_$key"] = price2num($this->array_options["options_$key"]); break; case 'date': - $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + $this->array_options["options_$key"]=$this->db->idate($this->array_options["options_$key"]); break; case 'datetime': - $this->array_options[$key]=$this->db->idate($this->array_options[$key]); + $this->array_options["options_$key"]=$this->db->idate($this->array_options["options_$key"]); break; case 'link': $param_list=array_keys($attributeParam ['options']); @@ -4296,13 +4297,13 @@ abstract class CommonObject if ($value) { $object->fetch(0,$value); - $this->array_options[$key]=$object->id; + $this->array_options["options_$key"]=$object->id; } break; } $this->db->begin(); - $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET $key=$value"; + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET $key=".$this->array_options["options_$key"]; $sql .= " WHERE fk_object = ".$this->id; $resql = $this->db->query($sql); if (! $resql) From e673c1aad90fe814d31a2fef8f44d80773cbb16f Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 16 Apr 2016 16:12:50 +0100 Subject: [PATCH 11/16] fix:erroneous nested form --- htdocs/fichinter/card.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 74f50f26a5b..74bd63f2219 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1261,12 +1261,6 @@ else if ($id > 0 || ! empty($ref)) // Print form confirm print $formconfirm; - print ''; - print ''; - if ($action == 'edit_extras') print ''; - if ($action == 'contrat') print ''; - print ''; - print ''; $linkback = ''.$langs->trans("BackToList").''; @@ -1406,8 +1400,6 @@ else if ($id > 0 || ! empty($ref)) print "
"; - print ''; - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) { $blocname = 'contacts'; From c298b783ce8865c3e1cb0ba89cfdf7c251befa78 Mon Sep 17 00:00:00 2001 From: Philippe-OpenDSI Date: Wed, 20 Apr 2016 13:59:13 +0200 Subject: [PATCH 12/16] Product supplier list display only one product Last parameter of select_produits_fournisseurs_list is $limit, not $socidif --- htdocs/product/ajax/products.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/ajax/products.php b/htdocs/product/ajax/products.php index c17fdb65aea..05efcc24a0e 100644 --- a/htdocs/product/ajax/products.php +++ b/htdocs/product/ajax/products.php @@ -183,7 +183,7 @@ if (! empty($action) && $action == 'fetch' && ! empty($id)) if (empty($mode) || $mode == 1) { $arrayresult = $form->select_produits_list("", $htmlname, $type, "", $price_level, $searchkey, $status, $finished, $outjson, $socid); } elseif ($mode == 2) { - $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson, $socid); + $arrayresult = $form->select_produits_fournisseurs_list($socid, "", $htmlname, $type, "", $searchkey, $status, $outjson); } $db->close(); From 7bf9c2144e289a928a15e24ae5be837342f1ced5 Mon Sep 17 00:00:00 2001 From: placid0w Date: Wed, 20 Apr 2016 15:43:14 -0300 Subject: [PATCH 13/16] Fix #5054 --- htdocs/webservices/server_productorservice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 2e3314fff12..43facbb24fa 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -374,7 +374,7 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='' $product->load_stock(); $dir = (!empty($conf->product->dir_output)?$conf->product->dir_output:$conf->service->dir_output); - $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->id ."/photos/"; + $pdir = get_exdir($product->id,2,0,0,$product,'product') . $product->ref . "/"; $dir = $dir . '/'. $pdir; if (! empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"]; From ffd10a75608eebad55ae782323fe9fc9b5b622f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Apr 2016 02:38:49 +0200 Subject: [PATCH 14/16] Complete function loadExpedition to add filter on fk_product --- htdocs/commande/class/commande.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ae7c18ac077..dc3a3c254a4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1844,13 +1844,13 @@ class Commande extends CommonOrder /** * Load array this->expeditions of lines of shipments with nb of products sent for each order line - * + * Note: For a dedicated shipment, the fetch_lines load the qty_asked and qty_shipped. This function return qty_shipped cuulated for order + * * @param int $filtre_statut Filter on status + * @param int $fk_product Filter on a product * @return int <0 if KO, Nb of lines found if OK - * - * TODO deprecate, move to Shipping class */ - function loadExpeditions($filtre_statut=-1) + function loadExpeditions($filtre_statut=-1, $fk_product=0) { $this->expeditions = array(); @@ -1863,6 +1863,7 @@ class Commande extends CommonOrder if ($filtre_statut >= 0) $sql.= ' ed.fk_expedition = e.rowid AND'; $sql.= ' ed.fk_origin_line = cd.rowid'; $sql.= ' AND cd.fk_commande =' .$this->id; + if ($this->fk_product > 0) $sql.= ' AND cd.fk_product = '.$this->fk_product; if ($filtre_statut >= 0) $sql.=' AND e.fk_statut >= '.$filtre_statut; $sql.= ' GROUP BY cd.rowid, cd.fk_product'; //print $sql; From d9e846e5860c4cf5dee2b1948b4a125befb12cb0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Apr 2016 02:47:34 +0200 Subject: [PATCH 15/16] Update migrate script --- htdocs/install/mysql/migration/3.9.0-4.0.0.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql index cd74edd4c3f..7ce46730aa9 100644 --- a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -102,6 +102,8 @@ UPDATE llx_projet as p set p.opp_percent = (SELECT percent FROM llx_c_lead_statu ALTER TABLE llx_facturedet ADD COLUMN fk_contract_line integer NULL AFTER rang; ALTER TABLE llx_facturedet_rec ADD COLUMN import_key varchar(14); +--DROP TABLE llx_website_page; +--DROP TABLE llx_website; CREATE TABLE llx_website ( rowid integer AUTO_INCREMENT NOT NULL PRIMARY KEY, From c2de7adb327473fc2f80db6d9103967208c81794 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Apr 2016 03:18:42 +0200 Subject: [PATCH 16/16] Minor PHPCS fixes --- ChangeLog | 1 + dev/skeletons/skeleton_class.class.php | 1 - htdocs/categories/class/api_category.class.php | 2 ++ htdocs/websites/class/websitepage.class.php | 10 ++++------ 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec9b5d50ba0..06310ddce07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,7 @@ Following changes may create regression for some external modules, but were nece Dolibarr better: - Function log() of class CommandeFournisseur has been removed. Using it is no more required. - Method select_type_comptes_financiers() has been renamed into selectTypeOfBankAccount() +- Property ->client that was deprecated 6 years ago, is replaced in all core code with ->thirdparty. - File '/core/tpl/document_actions_pre_headers.tpl.php' were renamed into '/core/actions_linkedfiles.inc.php'. So if you included it into your module, change your code like this to be compatible with all version: $res=@include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; diff --git a/dev/skeletons/skeleton_class.class.php b/dev/skeletons/skeleton_class.class.php index 9a230a05698..2858e791ce8 100644 --- a/dev/skeletons/skeleton_class.class.php +++ b/dev/skeletons/skeleton_class.class.php @@ -71,7 +71,6 @@ class Skeleton_Class extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; - return 1; } /** diff --git a/htdocs/categories/class/api_category.class.php b/htdocs/categories/class/api_category.class.php index 5e558ddc486..e17bb273758 100644 --- a/htdocs/categories/class/api_category.class.php +++ b/htdocs/categories/class/api_category.class.php @@ -144,6 +144,7 @@ class CategoryApi extends DolibarrApi $result = $db->query($sql); if ($result) { + $i=0; $num = $db->num_rows($result); while ($i < $num) { @@ -224,6 +225,7 @@ class CategoryApi extends DolibarrApi $result = $db->query($sql); if ($result) { + $i=0; $num = $db->num_rows($result); while ($i < $num) { diff --git a/htdocs/websites/class/websitepage.class.php b/htdocs/websites/class/websitepage.class.php index a001c8ad56c..88b6cee2401 100644 --- a/htdocs/websites/class/websitepage.class.php +++ b/htdocs/websites/class/websitepage.class.php @@ -55,9 +55,9 @@ class WebsitePage extends CommonObject public $keywords; public $content; public $status; - public $date_creation = ''; - public $date_modification = ''; - public $tms = ''; + public $date_creation; + public $date_modification; + public $tms; /** */ @@ -71,7 +71,6 @@ class WebsitePage extends CommonObject public function __construct(DoliDB $db) { $this->db = $db; - return 1; } /** @@ -546,11 +545,10 @@ class WebsitePage extends CommonObject global $dolibarr_main_authentication, $dolibarr_main_demo; global $menumanager; - $result = ''; $companylink = ''; - $label = '' . $langs->trans("MyModule") . ''; + $label = '' . $langs->trans("Page") . ''; $label.= '
'; $label.= '' . $langs->trans('Ref') . ': ' . $this->ref;