From d14bd829fbf07c364a84b619367eede6a559ba5d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Aug 2018 17:01:22 +0200 Subject: [PATCH 1/4] FIX trans on null object --- htdocs/core/lib/functions2.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index ea596294bf7..4553fec4641 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1771,7 +1771,7 @@ function getSoapParams() */ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='') { - global $db,$conf; + global $db, $conf, $langs; $ret=''; From 9cc6533d1118d85f81bb1e1deb580806c5d81ad6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 30 Aug 2018 18:57:30 +0200 Subject: [PATCH 2/4] Fix td alignement --- htdocs/fourn/commande/dispatch.php | 33 +++++++++++++++--------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 20664b6d679..f1fa3214e12 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -511,9 +511,18 @@ if ($id > 0 || ! empty($ref)) { print ''; print '' . $langs->trans("Description") . ''; - print ''; - print ''; - print ''; + if (! empty($conf->productbatch->enabled)) + { + print '' . $langs->trans("batch_number") . ''; + print '' . $langs->trans("EatByDate") . ''; + print '' . $langs->trans("SellByDate") . ''; + } + else + { + print ''; + print ''; + print ''; + } print '' . $langs->trans("SupplierRef") . ''; print '' . $langs->trans("QtyOrdered") . ''; print '' . $langs->trans("QtyDispatchedShort") . ''; @@ -521,16 +530,6 @@ if ($id > 0 || ! empty($ref)) { print ''; print '' . $langs->trans("Warehouse") . ''; print "\n"; - - if (! empty($conf->productbatch->enabled)) { - print ''; - print ''; - print '' . $langs->trans("batch_number") . ''; - print '' . $langs->trans("EatByDate") . ''; - print '' . $langs->trans("SellByDate") . ''; - print ' '; - print "\n"; - } } $nbfreeproduct = 0; // Nb of lins of free products/services @@ -593,7 +592,7 @@ if ($id > 0 || ! empty($ref)) { // Supplier ref print ''.$objp->sref.''; - + // Qty ordered print '' . $objp->qty . ''; @@ -638,7 +637,7 @@ if ($id > 0 || ! empty($ref)) { $dluodatesuffix = dol_mktime(0, 0, 0, GETPOST('dluo' . $suffix . 'month'), GETPOST('dluo' . $suffix . 'day'), GETPOST('dluo' . $suffix . 'year')); $form->select_date($dluodatesuffix, 'dluo' . $suffix, '', '', 1, ""); print ''; - print ' '; // Qty ordered + qty already dispatached + print ' '; // Supplier ref + Qty ordered + qty already dispatched } else { $type = 'dispatch'; print ''; @@ -650,7 +649,7 @@ if ($id > 0 || ! empty($ref)) { print ''; print ''; - print ''; + print ''; print ''; print ''; @@ -672,7 +671,7 @@ if ($id > 0 || ! empty($ref)) { print ''; print ''; - print ''; + print ''; if (! empty($conf->productbatch->enabled) && $objp->tobatch == 1) { $type = 'batch'; //print img_picto($langs->trans('AddDispatchBatchLine'), 'split.png', 'class="splitbutton" onClick="addDispatchLine(' . $i . ',\'' . $type . '\')"'); From e7d4956f5b12335585c7befc40ff885d37127c1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Aug 2018 11:29:30 +0200 Subject: [PATCH 3/4] Clean not used function --- htdocs/societe/class/societe.class.php | 126 ++----------------------- 1 file changed, 9 insertions(+), 117 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 5c3363bc4c8..845a19cba58 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -45,12 +45,12 @@ class Societe extends CommonObject * @var string ID to identify managed object */ public $element='societe'; - + /** * @var string Name of table without prefix where object is stored */ public $table_element = 'societe'; - + public $fk_element='fk_soc'; public $fieldsforcombobox='nom,name_alias'; protected $childtables=array("supplier_proposal"=>'SupplierProposal',"propal"=>'Proposal',"commande"=>'Order',"facture"=>'Invoice',"facture_rec"=>'RecurringInvoiceTemplate',"contrat"=>'Contract',"fichinter"=>'Fichinter',"facture_fourn"=>'SupplierInvoice',"commande_fournisseur"=>'SupplierOrder',"projet"=>'Project',"expedition"=>'Shipment',"prelevement_lignes"=>'DirectDebitRecord'); // To test if we can delete object @@ -1348,114 +1348,6 @@ class Societe extends CommonObject return $result; } - /** - * Search and fetch thirparties by name - * - * @param string $name Name - * @param int $type Type of thirdparties (0=any, 1=customer, 2=prospect, 3=supplier) - * @param array $filters Array of couple field name/value to filter the companies with the same name - * @param boolean $exact Exact string search (true/false) - * @param boolean $case Case sensitive (true/false) - * @param boolean $similar Add test if string inside name into database, or name into database inside string. Do not use this: Not compatible with other database. - * @param string $clause Clause for filters - * @return array|int <0 if KO, array of thirdparties object if OK - */ - function searchByName($name, $type='0', $filters = array(), $exact = false, $case = false, $similar = false, $clause = 'AND') - { - $thirdparties = array(); - - dol_syslog("searchByName name=".$name." type=".$type." exact=".$exact); - - // Check parameter - if (empty($name)) - { - $this->errors[]='ErrorBadValueForParameter'; - return -1; - } - - // Generation requete recherche - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE entity IN (".getEntity('category').")"; - if (! empty($type)) - { - if ($type == 1 || $type == 2) - $sql.= " AND client = ".$type; - elseif ($type == 3) - $sql.= " AND fournisseur = 1"; - } - if (! empty($name)) - { - if (! $exact) - { - if (preg_match('/^([\*])?[^*]+([\*])?$/', $name, $regs) && count($regs) > 1) - { - $name = str_replace('*', '%', $name); - } - else - { - $name = '%'.$name.'%'; - } - } - $sql.= " AND "; - if (is_array($filters) && ! empty($filters)) - $sql.= "("; - if ($similar) - { - // For test similitude (string inside name into database, or name into database inside string) - // Do not use this. Not compatible with other database. - $sql.= "(LOCATE('".$this->db->escape($name)."', nom) > 0 OR LOCATE(nom, '".$this->db->escape($name)."') > 0)"; - } - else - { - if (! $case) - $sql.= "nom LIKE '".$this->db->escape($name)."'"; - else - $sql.= "nom LIKE BINARY '".$this->db->escape($name)."'"; - } - } - if (is_array($filters) && ! empty($filters)) - { - foreach($filters as $field => $value) - { - if (! $exact) - { - if (preg_match('/^([\*])?[^*]+([\*])?$/', $value, $regs) && count($regs) > 1) - { - $value = str_replace('*', '%', $value); - } - else - { - $value = '%'.$value.'%'; - } - } - if (! $case) - $sql.= " ".$clause." ".$field." LIKE '".$this->db->escape($value)."'"; - else - $sql.= " ".$clause." ".$field." LIKE BINARY '".$this->db->escape($value)."'"; - } - if (! empty($name)) - $sql.= ")"; - } - - $res = $this->db->query($sql); - if ($res) - { - while ($rec = $this->db->fetch_array($res)) - { - $soc = new Societe($this->db); - $soc->fetch($rec['rowid']); - $thirdparties[] = $soc; - } - - return $thirdparties; - } - else - { - $this->error=$this->db->lasterror(); - return -1; - } - } - /** * Delete a third party from database and all its dependencies (contacts, rib...) * @@ -1921,10 +1813,10 @@ class Societe extends CommonObject function add_commercial(User $user, $commid) { $error=0; - - - - + + + + if ($this->id > 0 && $commid > 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux"; @@ -1942,7 +1834,7 @@ class Societe extends CommonObject } else { $this->context=array('commercial_modified'=>$commid); - + $result=$this->call_trigger('COMPANY_LINK_SALE_REPRESENTATIVE',$user); if ($result < 0) $error++; } @@ -1960,10 +1852,10 @@ class Societe extends CommonObject { $error=0; $this->context=array('commercial_modified'=>$commid); - + $result=$this->call_trigger('COMPANY_UNLINK_SALE_REPRESENTATIVE',$user); if ($result < 0) $error++; - + if ($this->id > 0 && $commid > 0) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux "; From 7b1a705be4e7e4347342b08e1d9fe97311736fb1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 31 Aug 2018 13:50:58 +0200 Subject: [PATCH 4/4] Clean duplicate code --- htdocs/comm/propal/class/propal.class.php | 27 ++++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index cc918b5b9f1..955ee29845e 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -49,22 +49,22 @@ class Propal extends CommonObject * @var string ID to identify managed object */ public $element='propal'; - + /** * @var string Name of table without prefix where object is stored */ public $table_element='propal'; - + public $table_element_line='propaldet'; public $fk_element='fk_propal'; public $picto='propal'; - + /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe * @var int */ public $ismultientitymanaged = 1; - + /** * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user * @var integer @@ -1574,10 +1574,10 @@ class Propal extends CommonObject $sql = 'SELECT d.rowid, d.fk_propal, d.fk_parent_line, d.label as custom_label, d.description, d.price, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.fk_remise_except, d.remise_percent, d.subprice, d.fk_product,'; $sql.= ' d.info_bits, d.total_ht, d.total_tva, d.total_localtax1, d.total_localtax2, d.total_ttc, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht, d.special_code, d.rang, d.product_type,'; $sql.= ' d.fk_unit,'; - $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label,'; + $sql.= ' p.ref as product_ref, p.description as product_desc, p.fk_product_type, p.label as product_label, p.tobach as product_batch,'; $sql.= ' p.weight, p.weight_units, p.volume, p.volume_units,'; - $sql.= ' d.date_start, d.date_end'; - $sql.= ' ,d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc'; + $sql.= ' d.date_start, d.date_end,'; + $sql.= ' d.fk_multicurrency, d.multicurrency_code, d.multicurrency_subprice, d.multicurrency_total_ht, d.multicurrency_total_tva, d.multicurrency_total_ttc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as d'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON (d.fk_product = p.rowid)'; $sql.= ' WHERE d.fk_propal = '.$this->id; @@ -1639,7 +1639,8 @@ class Propal extends CommonObject $line->libelle = $objp->product_label; // TODO deprecated $line->product_label = $objp->product_label; $line->product_desc = $objp->product_desc; // Description produit - $line->fk_product_type = $objp->fk_product_type; + $line->product_tobatch = $objp->product_tobatch; + $line->fk_product_type = $objp->fk_product_type; // TODO deprecated $line->fk_unit = $objp->fk_unit; $line->weight = $objp->weight; $line->weight_units = $objp->weight_units; @@ -3201,7 +3202,7 @@ class Propal extends CommonObject { $response->nbtodo++; $response->total+=$obj->total_ht; - + if ($mode == 'opened') { $datelimit = $this->db->jdate($obj->datefin); @@ -3511,8 +3512,8 @@ class Propal extends CommonObject */ function getLinesArray() { - // TODO Duplicate with fetch_lines ? Wich one to keep ? - + return $this->fetch_lines(); + /* $this->lines = array(); $sql = 'SELECT pt.rowid, pt.label as custom_label, pt.description, pt.fk_product, pt.fk_remise_except,'; @@ -3601,7 +3602,7 @@ class Propal extends CommonObject { $this->error=$this->db->error(); return -1; - } + }*/ } /** @@ -3665,7 +3666,7 @@ class PropaleLigne extends CommonObjectLine * @var string ID to identify managed object */ public $element='propaldet'; - + /** * @var string Name of table without prefix where object is stored */