From 596ba8d6793caeac0df064f5d0b86db42b06c8de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 13 Apr 2020 01:10:35 +0200 Subject: [PATCH] Clean deprecated code. --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/comm/propal/card.php | 1 - htdocs/comm/propal/class/propal.class.php | 1 - htdocs/commande/orderstoinvoice.php | 3 --- .../facture/class/facture-rec.class.php | 3 +-- htdocs/compta/paiement.php | 6 ++--- htdocs/core/class/ccountry.class.php | 1 - htdocs/core/customreports.php | 23 +++++++++++++++++++ htdocs/fourn/commande/orderstoinvoice.php | 2 -- htdocs/societe/class/societe.class.php | 19 ++++++++------- htdocs/user/class/user.class.php | 2 -- 11 files changed, 37 insertions(+), 26 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 538e433cd16..4225dad5f31 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -273,7 +273,7 @@ class Adherent extends CommonObject 'zip' => array('type' => 'varchar(10)', 'label' => 'Zip', 'enabled' => 1, 'visible' => -1, 'position' => 80), 'town' => array('type' => 'varchar(50)', 'label' => 'Town', 'enabled' => 1, 'visible' => -1, 'position' => 85), 'state_id' => array('type' => 'integer', 'label' => 'State id', 'enabled' => 1, 'visible' => -1, 'position' => 90), - 'country' => array('type' => 'integer', 'label' => 'Country', 'enabled' => 1, 'visible' => -1, 'position' => 95), + 'country' => array('type' => 'integer:Ccountry:core/class/ccountry.class.php', 'label' => 'Country', 'enabled' => 1, 'visible' => -1, 'position' => 95), 'email' => array('type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'visible' => -1, 'position' => 100), 'socialnetworks' => array('type' => 'text', 'label' => 'Socialnetworks', 'enabled' => 1, 'visible' => -1, 'position' => 105), 'phone' => array('type' => 'varchar(30)', 'label' => 'Phone', 'enabled' => 1, 'visible' => -1, 'position' => 115), diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index d6e8208f792..92338ebf68e 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1513,7 +1513,6 @@ if ($action == 'create') $projectid = (!empty($objectsrc->fk_project) ? $objectsrc->fk_project : 0); $ref_client = (!empty($objectsrc->ref_client) ? $objectsrc->ref_client : ''); - $ref_int = (!empty($objectsrc->ref_int) ? $objectsrc->ref_int : ''); $soc = $objectsrc->thirdparty; diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 53fa6113caa..e14e3ec8f71 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -258,7 +258,6 @@ class Propal extends CommonObject 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>20), 'ref_client' =>array('type'=>'varchar(255)', 'label'=>'RefCustomer', 'enabled'=>1, 'visible'=>-1, 'position'=>22), 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>40), - 'ref_int' =>array('type'=>'varchar(255)', 'label'=>'RefInt', 'enabled'=>1, 'visible'=>0, 'position'=>45), // deprecated 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'position'=>23), 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>24), 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25), diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 2920760b492..d47e711bc77 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -169,7 +169,6 @@ if (($action == 'create' || $action == 'add') && !$error) $object->note_public = trim($_POST['note_public']); $object->note = trim($_POST['note']); $object->ref_client = $_POST['ref_client']; - $object->ref_int = $_POST['ref_int']; $object->modelpdf = $_POST['model']; $object->fk_project = $_POST['projectid']; $object->cond_reglement_id = ($_POST['type'] == 3 ? 1 : $_POST['cond_reglement_id']); @@ -407,8 +406,6 @@ if ($action == 'create' && !$error) print ''; print ''."\n"; print ''; - print ''; - print ''; print ''; print ''; print ''; diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 74180587cfc..205ca88290e 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -475,10 +475,9 @@ class FactureRec extends CommonInvoice * @param int $rowid Id of object to load * @param string $ref Reference of recurring invoice * @param string $ref_ext External reference of invoice - * @param int $ref_int Internal reference of other object * @return int >0 if OK, <0 if KO, 0 if not found */ - public function fetch($rowid, $ref = '', $ref_ext = '', $ref_int = '') + public function fetch($rowid, $ref = '', $ref_ext = '') { $sql = 'SELECT f.rowid, f.entity, f.titre as title, f.suspended, f.fk_soc, f.tva, f.localtax1, f.localtax2, f.total, f.total_ttc'; $sql .= ', f.remise_percent, f.remise_absolue, f.remise'; diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index b4da848ea5a..4a7e387987c 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -357,11 +357,11 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie } // Invoice with Paypal transaction - // TODO add hook possibility (regis) - if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_int)) + // TODO add hook here + if (!empty($conf->paypalplus->enabled) && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) { if (!empty($conf->global->PAYPAL_BANK_ACCOUNT)) $accountid = $conf->global->PAYPAL_BANK_ACCOUNT; - $paymentnum = $facture->ref_int; + $paymentnum = $facture->ref_ext; } // Add realtime total information diff --git a/htdocs/core/class/ccountry.class.php b/htdocs/core/class/ccountry.class.php index 18f2936e3ff..a70a2f9cafc 100644 --- a/htdocs/core/class/ccountry.class.php +++ b/htdocs/core/class/ccountry.class.php @@ -157,7 +157,6 @@ class Ccountry // extends CommonObject */ public function fetch($id, $code = '', $code_iso = '') { - global $langs; $sql = "SELECT"; $sql .= " t.rowid,"; $sql .= " t.code,"; diff --git a/htdocs/core/customreports.php b/htdocs/core/customreports.php index 5659d126211..8375e5f6770 100644 --- a/htdocs/core/customreports.php +++ b/htdocs/core/customreports.php @@ -214,6 +214,7 @@ if ($action == 'viewgraph') { } // Get all possible values of fields when a 'group by' is set, and save this into $arrayofvaluesforgroupby +// $arrayofvaluesforgroupby will be used to forge lael of each grouped series if (is_array($search_groupby) && count($search_groupby)) { foreach ($search_groupby as $gkey => $gval) { $gvalwithoutprefix = preg_replace('/^[a-z]+\./', '', $gval); @@ -260,11 +261,30 @@ if (is_array($search_groupby) && count($search_groupby)) { $keytouse = (string) $obj->val; $valuetranslated = $obj->val; } + + $regs = array(); if (!empty($object->fields[$gvalwithoutprefix]['arrayofkeyval'])) { $valuetranslated = $object->fields[$gvalwithoutprefix]['arrayofkeyval'][$obj->val]; if (is_null($valuetranslated)) $valuetranslated = $langs->transnoentitiesnoconv("UndefinedKey"); $valuetranslated = $langs->trans($valuetranslated); } + elseif (preg_match('/integer:([^:]+):([^:]+)$/', $object->fields[$gvalwithoutprefix]['type'], $regs)) { + $classname = $regs[1]; + $classpath = $regs[2]; + dol_include_once($classpath); + if (class_exists($classname)) { + $tmpobject = new $classname($db); + $tmpobject->fetch($obj->val); + foreach($tmpobject->fields as $fieldkey => $field) { + if ($field['showoncombobox']) { + $valuetranslated = $tmpobject->$fieldkey; + //if ($valuetranslated == '-') $valuetranslated = $langs->transnoentitiesnoconv("Unknown") + break; + } + } + //$valuetranslated = $tmpobject->ref.'eee'; + } + } $arrayofvaluesforgroupby['g_'.$gkey][$keytouse] = $valuetranslated; } @@ -578,6 +598,8 @@ if ($sql) { $fieldforxkey = 'x_0'; $xlabel = $obj->$fieldforxkey; $xvalwithoutprefix = preg_replace('/^[a-z]+\./', '', $xval); + + // Define $xlabel if (!empty($object->fields[$xvalwithoutprefix]['arrayofkeyval'])) { $xlabel = $object->fields[$xvalwithoutprefix]['arrayofkeyval'][$obj->$fieldforxkey]; } @@ -657,6 +679,7 @@ if ($sql) { $xlabel = $obj->$fieldforxkey; $xvalwithoutprefix = preg_replace('/^[a-z]+\./', '', $xval); + // Define $xlabel if (!empty($object->fields[$xvalwithoutprefix]['arrayofkeyval'])) { $xlabel = $object->fields[$xvalwithoutprefix]['arrayofkeyval'][$obj->$fieldforxkey]; } diff --git a/htdocs/fourn/commande/orderstoinvoice.php b/htdocs/fourn/commande/orderstoinvoice.php index ff3fc1f336e..0d011395b3e 100644 --- a/htdocs/fourn/commande/orderstoinvoice.php +++ b/htdocs/fourn/commande/orderstoinvoice.php @@ -327,8 +327,6 @@ if ($action == 'create' && !$error) { print ''; print ''."\n"; print ''; - print ''; - print ''; print ''; print ''; print ''; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 2267816f87b..39ec8fee2e1 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -132,17 +132,16 @@ class Societe extends CommonObject 'nom' =>array('type'=>'varchar(128)', 'label'=>'Nom', 'enabled'=>1, 'visible'=>-1, 'position'=>35, 'showoncombobox'=>1), 'name_alias' =>array('type'=>'varchar(128)', 'label'=>'Name alias', 'enabled'=>1, 'visible'=>-1, 'position'=>36, 'showoncombobox'=>1), 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>40, 'index'=>1), - 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>45), - 'ref_int' =>array('type'=>'varchar(60)', 'label'=>'Ref int', 'enabled'=>1, 'visible'=>0, 'position'=>50), // deprecated - 'code_client' =>array('type'=>'varchar(24)', 'label'=>'Code client', 'enabled'=>1, 'visible'=>-1, 'position'=>55), - 'code_fournisseur' =>array('type'=>'varchar(24)', 'label'=>'Code fournisseur', 'enabled'=>1, 'visible'=>-1, 'position'=>60), - 'code_compta' =>array('type'=>'varchar(24)', 'label'=>'Code compta', 'enabled'=>1, 'visible'=>-1, 'position'=>65), - 'code_compta_fournisseur' =>array('type'=>'varchar(24)', 'label'=>'Code compta fournisseur', 'enabled'=>1, 'visible'=>-1, 'position'=>70), + 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'RefExt', 'enabled'=>1, 'visible'=>0, 'position'=>45), + 'code_client' =>array('type'=>'varchar(24)', 'label'=>'CustomerCode', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'code_fournisseur' =>array('type'=>'varchar(24)', 'label'=>'SupplierCode', 'enabled'=>1, 'visible'=>-1, 'position'=>60), + 'code_compta' =>array('type'=>'varchar(24)', 'label'=>'CodeCompta', 'enabled'=>1, 'visible'=>-1, 'position'=>65), + 'code_compta_fournisseur' =>array('type'=>'varchar(24)', 'label'=>'CodeComptaSupplier', 'enabled'=>1, 'visible'=>-1, 'position'=>70), 'address' =>array('type'=>'varchar(255)', 'label'=>'Address', 'enabled'=>1, 'visible'=>-1, 'position'=>75), 'zip' =>array('type'=>'varchar(25)', 'label'=>'Zip', 'enabled'=>1, 'visible'=>-1, 'position'=>80), 'town' =>array('type'=>'varchar(50)', 'label'=>'Town', 'enabled'=>1, 'visible'=>-1, 'position'=>85), - 'fk_departement' =>array('type'=>'integer', 'label'=>'Fk departement', 'enabled'=>1, 'visible'=>-1, 'position'=>90), - 'fk_pays' =>array('type'=>'integer', 'label'=>'Fk pays', 'enabled'=>1, 'visible'=>-1, 'position'=>95), + 'fk_departement' =>array('type'=>'integer', 'label'=>'State', 'enabled'=>1, 'visible'=>-1, 'position'=>90), + 'fk_pays' =>array('type'=>'integer:Ccountry:core/class/ccountry.class.php', 'label'=>'Country', 'enabled'=>1, 'visible'=>-1, 'position'=>95), 'phone' =>array('type'=>'varchar(20)', 'label'=>'Phone', 'enabled'=>1, 'visible'=>-1, 'position'=>100), 'fax' =>array('type'=>'varchar(20)', 'label'=>'Fax', 'enabled'=>1, 'visible'=>-1, 'position'=>105), 'url' =>array('type'=>'varchar(255)', 'label'=>'Url', 'enabled'=>1, 'visible'=>-1, 'position'=>110), @@ -159,8 +158,8 @@ class Societe extends CommonObject 'twitter' =>array('type'=>'varchar(255)', 'label'=>'Twitter', 'enabled'=>1, 'visible'=>-1, 'position'=>165),*/ 'fk_effectif' =>array('type'=>'integer', 'label'=>'Fk effectif', 'enabled'=>1, 'visible'=>-1, 'position'=>170), 'fk_typent' =>array('type'=>'integer', 'label'=>'Fk typent', 'enabled'=>1, 'visible'=>-1, 'position'=>175), - 'fk_forme_juridique' =>array('type'=>'integer', 'label'=>'Fk forme juridique', 'enabled'=>1, 'visible'=>-1, 'position'=>180), - 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'Fk currency', 'enabled'=>1, 'visible'=>-1, 'position'=>185), + 'fk_forme_juridique' =>array('type'=>'integer', 'label'=>'JuridicalStatus', 'enabled'=>1, 'visible'=>-1, 'position'=>180), + 'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'Currency', 'enabled'=>1, 'visible'=>-1, 'position'=>185), 'siren' =>array('type'=>'varchar(128)', 'label'=>'Idprof1', 'enabled'=>1, 'visible'=>-1, 'position'=>190), 'siret' =>array('type'=>'varchar(128)', 'label'=>'Idprof2', 'enabled'=>1, 'visible'=>-1, 'position'=>195), 'ape' =>array('type'=>'varchar(128)', 'label'=>'Idprof3', 'enabled'=>1, 'visible'=>-1, 'position'=>200), diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index cd54717fc47..3380bab0fd9 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -304,7 +304,6 @@ class User extends CommonObject $sql .= " u.color,"; $sql .= " u.dateemployment, u.dateemploymentend,"; $sql .= " u.fk_warehouse,"; - $sql .= " u.ref_int,"; $sql .= " u.ref_ext,"; $sql .= " u.default_range, u.default_c_exp_tax_cat,"; // Expense report default mode $sql .= " c.code as country_code, c.label as country,"; @@ -359,7 +358,6 @@ class User extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->rowid; - $this->ref_int = $obj->ref_int; $this->ref_ext = $obj->ref_ext; $this->ldap_sid = $obj->ldap_sid;