From 56245e2c9a888da1d84d02b5dbca99602975bd23 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Tue, 4 Oct 2016 16:51:44 +0200 Subject: [PATCH 1/7] FIX: only show projects of related third if external user --- htdocs/core/boxes/box_project.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_project.php b/htdocs/core/boxes/box_project.php index 7d819ec0d2b..1db7b5729db 100644 --- a/htdocs/core/boxes/box_project.php +++ b/htdocs/core/boxes/box_project.php @@ -2,6 +2,7 @@ /* Copyright (C) 2012-2014 Charles-François BENKE * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Frederic France + * Copyright (C) 2016 Juan José Menent * * 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 @@ -79,8 +80,10 @@ class box_project extends ModeleBoxes $sql = "SELECT p.rowid, p.ref, p.title, p.fk_statut "; $sql.= " FROM ".MAIN_DB_PREFIX."projet as p"; + if($user->socid) $sql.= " INNER JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid=p.fk_soc"; $sql.= " WHERE p.entity = ".$conf->entity; - $sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts + if($user->socid) $sql.= " AND s.rowid = ".$user->socid; + $sql.= " AND p.fk_statut = 1"; // Seulement les projets ouverts $sql.= " ORDER BY p.datec DESC"; $sql.= $db->plimit($max, 0); From ee20704a8a1902319adcba6c4811d20113fd9e68 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 5 Oct 2016 17:20:56 +0200 Subject: [PATCH 2/7] FIX : missing column into SQL on thridparty list --- htdocs/societe/list.php | 43 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 93e757278c6..01d3c95270b 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -166,7 +166,7 @@ $arrayfields=array( // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]); } @@ -342,6 +342,7 @@ $sql.= " st.libelle as stcomm, s.fk_stcomm as stcomm_id, s.fk_prospectlevel, s.p $sql.= " s.siren as idprof1, s.siret as idprof2, ape as idprof3, idprof4 as idprof4, s.fk_pays,"; $sql.= " s.tms as date_update, s.datec as date_creation,"; $sql.= " typent.code as typent_code"; +$sql.= " ,s.code_compta,s.code_compta_fournisseur"; // We'll need these fields in order to filter by sale (including the case where the user can only see his prospects) if ($search_sale) $sql .= ", sc.fk_soc, sc.fk_user"; // We'll need these fields in order to filter by categ @@ -403,7 +404,7 @@ foreach ($search_array_options as $key => $val) $typ=$extrafields->attribute_type[$tmpkey]; $mode=0; if (in_array($typ, array('int','double'))) $mode=1; // Search on a numeric - if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) + if ($val && ( ($crit != '' && ! in_array($typ, array('select'))) || ! empty($crit))) { $sql .= natural_search('ef.'.$tmpkey, $crit, $mode); } @@ -462,8 +463,8 @@ if ($resql) $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); - } - + } + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies'); // Show delete result message @@ -491,13 +492,13 @@ if ($resql) print ''; print ''; print ''; - + if ($search_all) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); print $langs->trans("FilterOnInto", $search_all) . join(', ',$fieldstosearchall); } - + // Filter on categories $moreforfilter=''; if ($type == 'c' || $type == 'p') @@ -542,7 +543,7 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields - + print ''; print ''; @@ -568,9 +569,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); print_liste_field_titre($extralabels[$key],$_SERVER["PHP_SELF"],"ef.".$key,"",$param,($align?'align="'.$align.'"':''),$sortfield,$sortorder); @@ -701,7 +702,7 @@ if ($resql) print ''; print ''; } - + // Type (customer/prospect/supplier) print ''; - + if (! empty($arrayfields['s.fk_prospectlevel']['checked'])) { // Prospect level @@ -732,15 +733,15 @@ if ($resql) $options_to .= $langs->trans($tab_level_label); $options_to .= ''; } - + // Print these two select print $langs->trans("From").' '; print ' '; print $langs->trans("to").' '; - + print ''; } - + if (! empty($arrayfields['s.fk_stcomm']['checked'])) { // Prospect status @@ -756,9 +757,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { $align=$extrafields->getAlignFlag($key); $typeofextrafield=$extrafields->attribute_type[$key]; @@ -814,7 +815,7 @@ if ($resql) { $obj = $db->fetch_object($resql); $var=!$var; - + $companystatic->id=$obj->rowid; $companystatic->name=$obj->name; $companystatic->canvas=$obj->canvas; @@ -825,7 +826,7 @@ if ($resql) $companystatic->code_fournisseur=$obj->code_fournisseur; $companystatic->fk_prospectlevel=$obj->fk_prospectlevel; $companystatic->name_alias=$obj->name_alias; - + print ""; if (! empty($arrayfields['s.nom']['checked'])) { @@ -867,7 +868,7 @@ if ($resql) if (! empty($arrayfields['s.zip']['checked'])) { print "\n"; - } + } // Country if (! empty($arrayfields['country.code_iso']['checked'])) { @@ -957,9 +958,9 @@ if ($resql) // Extra fields if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) { - foreach($extrafields->attribute_label as $key => $val) + foreach($extrafields->attribute_label as $key => $val) { - if (! empty($arrayfields["ef.".$key]['checked'])) + if (! empty($arrayfields["ef.".$key]['checked'])) { print 'getAlignFlag($key); From b7b18e3355aaecb52c64cafc1aa03775d2c90af4 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Oct 2016 10:12:25 +0200 Subject: [PATCH 3/7] FIX: Error when CATEGORIE_RECURSIV_ADD is enabled and new category is daughter of an already linked to object --- htdocs/categories/class/categorie.class.php | 31 +++++++++++++-------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index e1e44a475ed..6202fe6eb0a 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -5,7 +5,7 @@ * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin - * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2013-2016 Juanjo Menent * Copyright (C) 2013 Philippe Grand * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Raphaël Doursenaud @@ -642,17 +642,24 @@ class Categorie extends CommonObject } else { - $this->db->rollback(); - if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $this->error=$this->db->lasterrno(); - return -3; - } - else - { - $this->error=$this->db->lasterror(); - } - return -1; + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + if (empty($conf->global->CATEGORIE_RECURSIV_ADD)) { + $this->db->rollback(); + $this->error = $this->db->lasterrno(); + return -3; + } + else { + $this->db->commit(); + return 1; + } + } + else + { + $this->db->rollback(); + $this->error=$this->db->lasterror(); + return -1; + } } } From 298e5cee61bc2ccc8a8def653f8a2415433e9d3b Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Oct 2016 22:21:50 +0200 Subject: [PATCH 4/7] Fix #5843 best way fixing --- htdocs/categories/class/categorie.class.php | 28 +++++++++++++-------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 6202fe6eb0a..410f0f80682 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -558,6 +558,7 @@ class Categorie extends CommonObject global $user,$langs,$conf; $error=0; + $trigger=true; if ($this->id == -1) return -2; @@ -598,12 +599,16 @@ class Categorie extends CommonObject { $cat = new Categorie($this->db); $cat->id=$objparent->fk_parent; - $result=$cat->add_type($obj, $type); - if ($result < 0) - { - $this->error=$cat->error; - $error++; - } + + if (! $cat->containsObject($type,$obj->id)) { + $result=$cat->add_type($obj, $type); + if ($result < 0) { + $this->error=$cat->error; + $error++; + } + } else { + $trigger=false; + } } } } @@ -624,10 +629,13 @@ class Categorie extends CommonObject $this->linkto=$obj; // Call trigger - $result=$this->call_trigger('CATEGORY_LINK',$user); - if ($result < 0) { $error++; } - // End call triggers - + if ($trigger) { + $result = $this->call_trigger('CATEGORY_LINK', $user); + if ($result < 0) { + $error++; + } + // End call triggers + } if (! $error) { $this->db->commit(); From 45dfb8ca628ee3e18fa782b4ef4962b3adb0f8ca Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Oct 2016 22:32:11 +0200 Subject: [PATCH 5/7] Fix #5843 best way fixing --- htdocs/categories/class/categorie.class.php | 72 +++++++++------------ 1 file changed, 29 insertions(+), 43 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 410f0f80682..2b88eaae209 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -558,7 +558,6 @@ class Categorie extends CommonObject global $user,$langs,$conf; $error=0; - $trigger=true; if ($this->id == -1) return -2; @@ -591,26 +590,23 @@ class Categorie extends CommonObject $resql=$this->db->query($sql); if ($resql) { - if ($this->db->num_rows($resql) > 0) - { - $objparent = $this->db->fetch_object($resql); + if ($this->db->num_rows($resql) > 0) { + $objparent = $this->db->fetch_object($resql); - if (!empty($objparent->fk_parent)) - { - $cat = new Categorie($this->db); - $cat->id=$objparent->fk_parent; + if (!empty($objparent->fk_parent)) { + $cat = new Categorie($this->db); + $cat->id = $objparent->fk_parent; + + if (!$cat->containsObject($type, $obj->id)) { + $result = $cat->add_type($obj, $type); + if ($result < 0) { + $this->error = $cat->error; + $error++; + } - if (! $cat->containsObject($type,$obj->id)) { - $result=$cat->add_type($obj, $type); - if ($result < 0) { - $this->error=$cat->error; - $error++; - } - } else { - $trigger=false; } - } - } + } + } } else { @@ -629,13 +625,10 @@ class Categorie extends CommonObject $this->linkto=$obj; // Call trigger - if ($trigger) { - $result = $this->call_trigger('CATEGORY_LINK', $user); - if ($result < 0) { - $error++; - } - // End call triggers - } + $result=$this->call_trigger('CATEGORY_LINK',$user); + if ($result < 0) { $error++; } + // End call triggers + if (! $error) { $this->db->commit(); @@ -650,24 +643,17 @@ class Categorie extends CommonObject } else { - if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - if (empty($conf->global->CATEGORIE_RECURSIV_ADD)) { - $this->db->rollback(); - $this->error = $this->db->lasterrno(); - return -3; - } - else { - $this->db->commit(); - return 1; - } - } - else - { - $this->db->rollback(); - $this->error=$this->db->lasterror(); - return -1; - } + $this->db->rollback(); + if ($this->db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $this->error=$this->db->lasterrno(); + return -3; + } + else + { + $this->error=$this->db->lasterror(); + } + return -1; } } From ffd486e3d65067845b5be2d4de026a1382820216 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Fri, 7 Oct 2016 22:54:08 +0200 Subject: [PATCH 6/7] Fix #5843 best way fixing --- htdocs/categories/class/categorie.class.php | 31 +++++++++++---------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 2b88eaae209..b3cb3d9cc52 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -590,23 +590,24 @@ class Categorie extends CommonObject $resql=$this->db->query($sql); if ($resql) { - if ($this->db->num_rows($resql) > 0) { + if ($this->db->num_rows($resql) > 0) + { $objparent = $this->db->fetch_object($resql); - if (!empty($objparent->fk_parent)) { - $cat = new Categorie($this->db); - $cat->id = $objparent->fk_parent; - - if (!$cat->containsObject($type, $obj->id)) { - $result = $cat->add_type($obj, $type); - if ($result < 0) { - $this->error = $cat->error; - $error++; - } - - } - } - } + if (!empty($objparent->fk_parent)) + { + $cat = new Categorie($this->db); + $cat->id = $objparent->fk_parent; + if (!$cat->containsObject($type, $obj->id)) { + $result = $cat->add_type($obj, $type); + if ($result < 0) + { + $this->error = $cat->error; + $error++; + } + } + } + } } else { From 567f7e5365ead8c4e0e372fbc62b65df3da2d330 Mon Sep 17 00:00:00 2001 From: Sergio Sanchis Climent Date: Fri, 14 Oct 2016 00:43:10 +0200 Subject: [PATCH 7/7] FIX: #5340 --- htdocs/core/modules/import/import_csv.modules.php | 4 ++++ htdocs/core/modules/modSociete.class.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index da59679b1be..2db005c5646 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -504,6 +504,10 @@ class ImportCsv extends ModeleImports } if (empty($newval)) $arrayrecord[($key-1)]['type']=-1; // If we get empty value, we will use "null" } + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='numeric') + { + $newval = price2num($newval); + } //print 'Val to use as insert is '.$newval.'
'; } diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 778fd7a9865..5116f94ae24 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -405,7 +405,8 @@ class modSociete extends DolibarrModules 's.code_client'=>array('rule'=>'getcustomercodeifauto'), 's.code_fournisseur'=>array('rule'=>'getsuppliercodeifauto'), 's.code_compta'=>array('rule'=>'getcustomeraccountancycodeifauto'), - 's.code_compta_fournisseur'=>array('rule'=>'getsupplieraccountancycodeifauto') + 's.code_compta_fournisseur'=>array('rule'=>'getsupplieraccountancycodeifauto'), + 's.capital'=>array('rule'=>'numeric') ); //$this->import_convertvalue_array[$r]=array('s.fk_soc'=>array('rule'=>'lastrowid',table='t'); $this->import_regex_array[$r]=array('s.status'=>'^[0|1]','s.client'=>'^[0|1|2|3]','s.fournisseur'=>'^[0|1]','s.fk_typent'=>'id@'.MAIN_DB_PREFIX.'c_typent','s.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])?$');
'; print '
".$obj->zip."