From b4a9a0cafb202def9797bdf44f3d938bb362a8cb Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Tue, 8 Sep 2015 13:07:13 +0200 Subject: [PATCH 01/54] Allow contact definition on additionnal modules If additionnal module use contactelement feature, the module is referenced on element list on contact type --- htdocs/admin/dict.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index f9137a06acf..6fb9454ce58 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -464,6 +464,9 @@ if ($id == 11) 'fichinter' => $langs->trans('InterventionCard') ); if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty'); + + complete_elementList_with_modules($elementList); + asort($elementList); $sourceList = array( 'internal' => $langs->trans('Internal'), From e2a738bf5428f96cc074a1756720f2a928cd9611 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Tue, 8 Sep 2015 13:11:26 +0200 Subject: [PATCH 02/54] New fonction complete_elementList_with_modules if contactelement is defined on module definition, add module on definition type of contact --- htdocs/core/lib/admin.lib.php | 121 ++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 7469777fa89..571e24bf38a 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1019,6 +1019,127 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql return 1; } +/** + * Add external modules to list of contact element + * + * @param array $elementList elementList + * @return int 1 + */ +function complete_elementList_with_modules(&$elementList) +{ + global $db, $modules, $conf, $langs; + + // Search modules + $filename = array(); + $modules = array(); + $orders = array(); + $categ = array(); + $dirmod = array(); + $modulesdir = array(); + $i = 0; // is a sequencer of modules found + $j = 0; // j is module number. Automatically affected if module number not defined. + + foreach ($conf->file->dol_document_root as $type => $dirroot) + { + $modulesdir[$dirroot . '/core/modules/'] = $dirroot . '/core/modules/'; + + $handle=@opendir($dirroot); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') + { + if (is_dir($dirroot . '/' . $file . '/core/modules/')) + { + $modulesdir[$dirroot . '/' . $file . '/core/modules/'] = $dirroot . '/' . $file . '/core/modules/'; + } + } + } + closedir($handle); + } + } + + foreach ($modulesdir as $dir) + { + // Load modules attributes in arrays (name, numero, orders) from dir directory + //print $dir."\n
"; + dol_syslog("Scan directory ".$dir." for modules"); + $handle=@opendir(dol_osencode($dir)); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + //print "$i ".$file."\n
"; + if (is_readable($dir.$file) && substr($file, 0, 3) == 'mod' && substr($file, dol_strlen($file) - 10) == '.class.php') + { + $modName = substr($file, 0, dol_strlen($file) - 10); + + if ($modName) + { + include_once $dir.$file; + $objMod = new $modName($db); + + if ($objMod->numero > 0) + { + $j = $objMod->numero; + } + else + { + $j = 1000 + $i; + } + + $modulequalified=1; + + // We discard modules according to features level (PS: if module is activated we always show it) + $const_name = 'MAIN_MODULE_'.strtoupper(preg_replace('/^mod/i','',get_class($objMod))); + if ($objMod->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2 && ! $conf->global->$const_name) $modulequalified=0; + if ($objMod->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1 && ! $conf->global->$const_name) $modulequalified=0; + //If module is not activated disqualified + if (empty($conf->global->$const_name)) $modulequalified=0; + + if ($modulequalified) + { + // Load languages files of module + if (isset($objMod->langfiles) && is_array($objMod->langfiles)) + { + foreach($objMod->langfiles as $langfile) + { + $langs->load($langfile); + } + } + + $modules[$i] = $objMod; + $filename[$i]= $modName; + $orders[$i] = $objMod->family."_".$j; // Tri par famille puis numero module + //print "x".$modName." ".$orders[$i]."\n
"; + if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories + else $categ[$objMod->special]=1; + $dirmod[$i] = $dirroot; + + if (! empty($objMod->contactelement)) + { + $elementList[$objMod->name] = $langs->trans($objMod->name); + //exit; + } + + $j++; + $i++; + } + else dol_syslog("Module ".get_class($objMod)." not qualified"); + } + } + } + closedir($handle); + } + else + { + dol_syslog("htdocs/admin/modules.php: Failed to open directory ".$dir.". See permission and open_basedir option.", LOG_WARNING); + } + } + + return 1; +} /** * Show array with constants to edit From e43f1cee7ba5c0f26f6ce9355f009d702c293ef6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Oct 2015 10:52:46 +0200 Subject: [PATCH 03/54] Better error message --- htdocs/admin/modules.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 6530e41c3c1..b55830dff4d 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -141,7 +141,7 @@ foreach ($modulesdir as $dir) if (! $objMod->numero > 0) { - dol_syslog('a module descriptor must have a numero property', LOG_ERR); + dol_syslog('The module descriptor '.$modName.' must have a numero property', LOG_ERR); } $j = $objMod->numero; From dcf7d344cd151e9c42d18b062f5396e3479b2d95 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Oct 2015 12:54:22 +0200 Subject: [PATCH 04/54] Prepare database for future portal website --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 2 ++ htdocs/install/mysql/tables/llx_product.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 4942378e58c..a06736d3ce4 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -92,3 +92,5 @@ CREATE TABLE llx_ecm_files ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); + +ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 after tobuy; diff --git a/htdocs/install/mysql/tables/llx_product.sql b/htdocs/install/mysql/tables/llx_product.sql index 22006040327..42832a6b227 100755 --- a/htdocs/install/mysql/tables/llx_product.sql +++ b/htdocs/install/mysql/tables/llx_product.sql @@ -52,6 +52,7 @@ create table llx_product fk_user_modif integer, -- user making last change tosell tinyint DEFAULT 1, -- Product you sell tobuy tinyint DEFAULT 1, -- Product you buy + onportal tinyint DEFAULT 0, -- If it is a product you sell and you want to sell it on portal (module website must be on) tobatch tinyint DEFAULT 0 NOT NULL, -- Is it a product that need a batch or eat-by management fk_product_type integer DEFAULT 0, -- Type of product: 0 for regular product, 1 for service, 9 for other (used by external module) duration varchar(6), From 18725b554bfb2248e531c89db1e2fe07200f3292 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Oct 2015 13:23:45 +0200 Subject: [PATCH 05/54] Option MAIN_REPLACE_TRANS_xx_XX is now completely implemented. --- htdocs/core/class/translate.class.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 8235f99d129..89ab0019865 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -580,10 +580,9 @@ class Translate $str=$this->tab_translate[$key]; // Make some string replacement after translation - $replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang; - if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1,string2:newstring2 + $replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang; + if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2 { - // Overwrite translation with param MAIN_OVERWRITE_TRANS_xx_XX $tmparray=explode(';', $conf->global->$replacekey); foreach($tmparray as $tmp) { @@ -660,17 +659,17 @@ class Translate { $str=$this->tab_translate[$key]; - // Overwrite translation - $overwritekey='MAIN_OVERWRITE_TRANS_'.$this->defaultlang; - if (! empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2 + // Make some string replacement after translation + $replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang; + if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2 { - $tmparray=explode(',', $conf->global->$overwritekey); + $tmparray=explode(';', $conf->global->$replacekey); foreach($tmparray as $tmp) { $tmparray2=explode(':',$tmp); - if ($tmparray2[0]==$key) { $str=$tmparray2[1]; break; } + $str=preg_replace('/'.preg_quote($tmparray2[0]).'/',$tmparray2[1],$str); } - } + } if (! preg_match('/^Format/',$key)) { @@ -982,7 +981,8 @@ class Translate } /** - * Return an array with content of all loaded translation keys (found into this->tab_translate) + * Return an array with content of all loaded translation keys (found into this->tab_translate) so + * we get a substitution array we can use for substitutions (for mail or ODT generation for example) * * @return array Array of translation keys lang_key => string_translation_loaded */ @@ -997,9 +997,3 @@ class Translate return $substitutionarray; } } - - -function warning_handler($errno, $errstr, $errfile, $errline, array $errcontext) { - global $str; - print 'str='.$str; -} From d71ccc4a0292f3bbdd449768b51a4c310f4e744c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Oct 2015 14:39:55 +0200 Subject: [PATCH 06/54] NEW The free text in PDF footer can now be a HTML content. So the WYSIWYG editor is on by default to edit it into module setup. --- htdocs/core/class/conf.class.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 5417c8ef8ce..53be6607f38 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -439,9 +439,10 @@ class Conf if (! isset($this->global->MAIN_MAX_DECIMALS_TOT)) $this->global->MAIN_MAX_DECIMALS_TOT=2; if (! isset($this->global->MAIN_MAX_DECIMALS_SHOWN)) $this->global->MAIN_MAX_DECIMALS_SHOWN=8; - // Default pdf use dash between lines - if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1; - + // Default pdf option + if (! isset($this->global->MAIN_PDF_DASH_BETWEEN_LINES)) $this->global->MAIN_PDF_DASH_BETWEEN_LINES=1; // use dash between lines + if (! isset($this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) $this->global->PDF_ALLOW_HTML_FOR_FREE_TEXT=1; // allow html content into free footer text + // Set default value to MAIN_SHOW_LOGO if (! isset($this->global->MAIN_SHOW_LOGO)) $this->global->MAIN_SHOW_LOGO=1; From bbbd5f520290bfdd1abc33e58d4964cd90e60c6c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Oct 2015 14:55:01 +0200 Subject: [PATCH 07/54] Fix removed var_dump --- htdocs/core/lib/pdf.lib.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index d4ca1c485cf..fc3c61fabdd 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -303,12 +303,10 @@ function pdfGetHeightForHtmlContent(&$pdf, $htmlcontent) $pdf->startTransaction(); // store starting values $start_y = $pdf->GetY(); - var_dump($start_y); + //var_dump($start_y); $start_page = $pdf->getPage(); - // call your printing functions with your parameters - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // call printing functions with content $pdf->writeHTMLCell(0, 0, 0, $start_y, $htmlcontent, 0, 1, false, true, 'J',true); - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // get the new Y $end_y = $pdf->GetY(); $end_page = $pdf->getPage(); From ec043063483467a17786a7317b0b1e1f7164632f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Oct 2015 18:29:37 +0200 Subject: [PATCH 08/54] Fix #3772 Test lower value to avoid mysql limit --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 8 +++++--- htdocs/install/mysql/tables/llx_ecm_directories.sql | 2 +- htdocs/install/mysql/tables/llx_ecm_files.sql | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index a06736d3ce4..33593e7fac5 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -69,7 +69,7 @@ ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30); -ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(10000); +ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(1000); CREATE TABLE llx_ecm_files ( @@ -77,8 +77,8 @@ CREATE TABLE llx_ecm_files label varchar(64) NOT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id filename varchar(255) NOT NULL, -- file name only without any directory - fullpath varchar(10000) NOT NULL, -- relative to dolibarr document dir. example abc/def/myfile - fullpath_orig varchar(10000), -- full path of original filename, when file is uploaded from a local computer + fullpath varchar(750) NOT NULL, -- relative to dolibarr document dir. example abc/def/myfile + fullpath_orig varchar(750), -- full path of original filename, when file is uploaded from a local computer description text, keywords text, -- list of keywords, separated with comma cover text, -- is this file a file to use for a cover @@ -90,6 +90,8 @@ CREATE TABLE llx_ecm_files acl text -- for future permission 'per file' ) ENGINE=innodb; +ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(1000); + ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); diff --git a/htdocs/install/mysql/tables/llx_ecm_directories.sql b/htdocs/install/mysql/tables/llx_ecm_directories.sql index 22f77608029..518fdd4c9e1 100644 --- a/htdocs/install/mysql/tables/llx_ecm_directories.sql +++ b/htdocs/install/mysql/tables/llx_ecm_directories.sql @@ -27,7 +27,7 @@ CREATE TABLE llx_ecm_directories fk_parent integer, description varchar(255) NOT NULL, cachenbofdoc integer NOT NULL DEFAULT 0, - fullpath varchar(10000), + fullpath varchar(750), extraparams varchar(255), -- for stock other parameters with json format date_c datetime, date_m timestamp, diff --git a/htdocs/install/mysql/tables/llx_ecm_files.sql b/htdocs/install/mysql/tables/llx_ecm_files.sql index 1c4451d939a..e984c7c9098 100644 --- a/htdocs/install/mysql/tables/llx_ecm_files.sql +++ b/htdocs/install/mysql/tables/llx_ecm_files.sql @@ -22,8 +22,8 @@ CREATE TABLE llx_ecm_files label varchar(64) NOT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id filename varchar(255) NOT NULL, -- file name only without any directory - fullpath varchar(10000) NOT NULL, -- relative to dolibarr document dir. example abc/def/myfile - fullpath_orig varchar(10000), -- full path of original filename, when file is uploaded from a local computer + fullpath varchar(750) NOT NULL, -- relative to dolibarr document dir. example abc/def/myfile + fullpath_orig varchar(750), -- full path of original filename, when file is uploaded from a local computer description text, keywords text, -- list of keywords, separated with comma cover text, -- is this file a file to use for a cover From 2264ecfb2c3fa2b72a302dc7cc7a96660ef0af60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 20:58:36 +0200 Subject: [PATCH 09/54] Update llx_commande.sql --- htdocs/install/mysql/tables/llx_commande.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 3511aa7ec78..3df4e89b910 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -63,6 +63,7 @@ create table llx_commande date_livraison date default NULL, fk_shipping_method integer, -- shipping method id + fk_warehouse date default NULL, fk_availability integer NULL, fk_input_reason integer, -- id coming from c_input_reason, '0' if no defined fk_delivery_address integer, -- delivery address (deprecated) From 1d9f9c7f5bbca2472b2f27bcaf359b943712fa6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 21:00:47 +0200 Subject: [PATCH 10/54] Update llx_commande.sql --- htdocs/install/mysql/tables/llx_commande.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql index 3df4e89b910..553b2facad7 100644 --- a/htdocs/install/mysql/tables/llx_commande.sql +++ b/htdocs/install/mysql/tables/llx_commande.sql @@ -63,7 +63,7 @@ create table llx_commande date_livraison date default NULL, fk_shipping_method integer, -- shipping method id - fk_warehouse date default NULL, + fk_warehouse integer default NULL, fk_availability integer NULL, fk_input_reason integer, -- id coming from c_input_reason, '0' if no defined fk_delivery_address integer, -- delivery address (deprecated) From 6a524eeabb6e58a7a0a8ea2345b945f1cd5c73e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 21:04:05 +0200 Subject: [PATCH 11/54] Update 3.8.0-3.9.0.sql --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 33593e7fac5..573cadceb3d 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -67,7 +67,7 @@ ALTER TABLE llx_prelevement_lignes MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30); - +ALTER TABLE llx_commande ADD COLUMN fk_warehouse integer DEFAULT NULL after fk_shipping_method; ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(1000); From affe067ff1f6e0d39763ec700ef1ef07bb16acbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 21:09:02 +0200 Subject: [PATCH 12/54] Update commonobject.class.php --- htdocs/core/class/commonobject.class.php | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d20d5d82bde..716d705123e 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1507,6 +1507,36 @@ abstract class CommonObject } + /** + * Change the warehouse + * + * @param int $warehouse_id Id of warehouse + * @return int 1 if OK, 0 if KO + */ + function setWarehouse($warehouse_id) + { + if (! $this->table_element) { + dol_syslog(get_class($this)."::setWarehouse was called on objet with property table_element not defined",LOG_ERR); + return -1; + } + if ($warehouse_id<0) $warehouse_id='NULL'; + dol_syslog(get_class($this).'::setWarehouse('.$warehouse_id.')'); + + $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; + $sql.= " SET fk_warehouse = ".$warehouse_id; + $sql.= " WHERE rowid=".$this->id; + + if ($this->db->query($sql)) { + $this->warehouse_id = ($warehouse_id=='NULL')?null:$warehouse_id; + return 1; + } else { + dol_syslog(get_class($this).'::setWarehouse Error ', LOG_DEBUG); + $this->error=$this->db->error(); + return 0; + } + } + + /** * Set last model used by doc generator * From fe1931bba88fdebcacd520e6ce21600349a8af72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 21:21:27 +0200 Subject: [PATCH 13/54] Update commande.class.php --- htdocs/commande/class/commande.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d2f5c4d799f..40844da3d56 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -702,6 +702,7 @@ class Commande extends CommonOrder $sql.= " ref, fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note_private, note_public, ref_ext, ref_client, ref_int"; $sql.= ", model_pdf, fk_cond_reglement, fk_mode_reglement, fk_account, fk_availability, fk_input_reason, date_livraison, fk_delivery_address"; $sql.= ", fk_shipping_method"; + $sql.= ", fk_warehouse"; $sql.= ", remise_absolue, remise_percent"; $sql.= ", fk_incoterms, location_incoterms"; $sql.= ", entity"; @@ -724,6 +725,7 @@ class Commande extends CommonOrder $sql.= ", ".($this->date_livraison?"'".$this->db->idate($this->date_livraison)."'":"null"); $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:'NULL'); $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:'NULL'); + $sql.= ", ".($this->warehouse_id>0?$this->warehouse_id:'NULL'); $sql.= ", ".($this->remise_absolue>0?$this->db->escape($this->remise_absolue):'NULL'); $sql.= ", ".($this->remise_percent>0?$this->db->escape($this->remise_percent):0); $sql.= ", ".(int) $this->fk_incoterms; @@ -1063,6 +1065,7 @@ class Commande extends CommonOrder $this->demand_reason_id = $object->demand_reason_id; $this->date_livraison = $object->date_livraison; $this->shipping_method_id = $object->shipping_method_id; + $this->warehouse_id = $object->warehouse_id; $this->fk_delivery_address = $object->fk_delivery_address; $this->contact_id = $object->contactid; $this->ref_client = $object->ref_client; @@ -1432,6 +1435,7 @@ class Commande extends CommonOrder $sql.= ', c.date_commande'; $sql.= ', c.date_livraison'; $sql.= ', c.fk_shipping_method'; + $sql.= ', c.fk_warehouse'; $sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed'; $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_delivery_address, c.extraparams'; $sql.= ', c.fk_incoterms, c.location_incoterms'; @@ -1499,6 +1503,7 @@ class Commande extends CommonOrder $this->demand_reason_code = $obj->demand_reason_code; $this->date_livraison = $this->db->jdate($obj->date_livraison); $this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null; + $this->warehouse_id = ($obj->fk_warehouse>0)?$obj->fk_warehouse:null; $this->fk_delivery_address = $obj->fk_delivery_address; //Incoterms From 229fa59f6c3c749acc2c8b969fa61de4c86d32d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 21:57:26 +0200 Subject: [PATCH 14/54] Update commande.php --- htdocs/admin/commande.php | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 860e1a21772..f7e3812d74f 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -251,6 +251,23 @@ else if ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER') } } +// Activate ask for warehouse +else if ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER') +{ + $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER",$value,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + /* * View @@ -630,6 +647,36 @@ else print $langs->trans("BANK_ASK_PAYMENT_BANK_DURING_ORDER").' '.$langs->trans('NotAvailable').''; } +// Ask for warehouse during order +if ($conf->stock->enabled) +{ + $var=!$var; + print ''; + print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").' '; + if (! empty($conf->use_javascript_ajax)) + { + print ajax_constantonoff('WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER'); + } + else + { + if (empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) + { + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; + } + else + { + print ''.img_picto($langs->trans("Enabled"),'switch_on').''; + } + } + print ''; +} +else +{ + $var=!$var; + print ''; + print $langs->trans("WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER").' '.$langs->trans('NotAvailable').''; +} + print ''; print '
'; From 3e730cc9e2000f7332a59b626f1540a6a95da97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 22:01:30 +0200 Subject: [PATCH 15/54] Update admin.lang --- htdocs/langs/en_US/admin.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6f720c0a92b..453bfbc946e 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1203,6 +1203,7 @@ AskPriceSupplierPDFModules=Price requests suppliers documents models FreeLegalTextOnAskPriceSupplier=Free text on price requests suppliers WatermarkOnDraftAskPriceSupplier=Watermark on draft price requests suppliers (none if empty) BANK_ASK_PAYMENT_BANK_DURING_ASKPRICESUPPLIER=Ask for bank account destination of price request +WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER=Ask for Warehouse Source for order ##### Orders ##### OrdersSetup=Order management setup OrdersNumberingModules=Orders numbering models @@ -1692,4 +1693,4 @@ MailToSendSupplierRequestForQuotation=To send quotation request to supplier MailToSendSupplierOrder=To send supplier order MailToSendSupplierInvoice=To send supplier invoice MailToThirdparty=To send email from thirdparty page -ByDefaultInList=Show by default on list view \ No newline at end of file +ByDefaultInList=Show by default on list view From 50fe3f6ee9293589bf04e7d4c2cd3d819943605d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 22:06:46 +0200 Subject: [PATCH 16/54] Update html.formproduct.class.php --- .../product/class/html.formproduct.class.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 0215f20e3c6..f08143c443c 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -134,6 +134,40 @@ class FormProduct return $out; } + /** + * Display form to select warehouse + * + * @param string $page Page + * @param int $selected Id of warehouse + * @param string $htmlname Name of select html field + * @param int $addempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries. + * @return void + */ + function formSelectWarehouses($page, $selected='', $htmlname='warehouse_id', $addempty=0) + { + global $langs; + if ($htmlname != "none") { + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $this->selectWarehouses($selected, $htmlname, '', $addempty); + print '
'; + } else { + if ($selected) { + require_once DOL_DOCUMENT_ROOT .'/product/stock/class/entrepot.class.php'; + $warehousestatic=new Entrepot($this->db); + $warehousestatic->fetch($selected); + print $warehousestatic->getNomUrl(); + } else { + print " "; + } + } + } + /** * Output a combo box with list of units * pour l'instant on ne definit pas les unites dans la base From 22f39d2c18f0d2582aba31a53030a53dc7dc565d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Oct 2015 22:18:54 +0200 Subject: [PATCH 17/54] Output log to fix travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 54d937625ba..ec114c753ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -131,6 +131,7 @@ script: # - cat upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log - php upgrade.php 3.8.0 3.9.0 ignoredbversion > upgrade380390.log + - cat upgrade370380.log - php upgrade2.php 3.8.0 3.9.0 ignoredbversion > upgrade380390-2.log # - cat upgrade370380-2.log - cd ../.. From fcac4c6059fcee19e8cb9296ec4ee57f52dfad26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 19 Oct 2015 23:15:13 +0200 Subject: [PATCH 18/54] Output log to fix travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec114c753ae..5d613e1dfca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -131,9 +131,9 @@ script: # - cat upgrade370380.log - php upgrade2.php 3.7.0 3.8.0 ignoredbversion > upgrade370380-2.log - php upgrade.php 3.8.0 3.9.0 ignoredbversion > upgrade380390.log - - cat upgrade370380.log + - cat upgrade380390.log - php upgrade2.php 3.8.0 3.9.0 ignoredbversion > upgrade380390-2.log -# - cat upgrade370380-2.log +# - cat upgrade380390-2.log - cd ../.. - date - phpunit -d memory_limit=-1 --configuration test/phpunit/phpunittest.xml test/phpunit/AllTests.php From 23d7d60d73dbba58c0ce450fb1555a64625a4aa8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Oct 2015 00:22:00 +0200 Subject: [PATCH 19/54] Better compatibility with old versions --- htdocs/core/lib/functions.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index ec3705c825c..053c285c5de 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1689,10 +1689,10 @@ function dol_print_address($address, $htmlid, $mode, $id, $noprint=0) $showgmap=$showomap=0; // TODO Add a hook here - if ($mode=='thirdparty' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap=1; + if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS)) $showgmap=1; if ($mode=='contact' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_CONTACTS)) $showgmap=1; if ($mode=='member' && ! empty($conf->google->enabled) && ! empty($conf->global->GOOGLE_ENABLE_GMAPS_MEMBERS)) $showgmap=1; - if ($mode=='thirdparty' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap=1; + if (($mode=='thirdparty' || $mode =='societe') && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS)) $showomap=1; if ($mode=='contact' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_CONTACTS)) $showomap=1; if ($mode=='member' && ! empty($conf->openstreetmap->enabled) && ! empty($conf->global->OPENSTREETMAP_ENABLE_MAPS_MEMBERS)) $showomap=1; From 921faa04108796b19208d2e7427c562cce6b1b12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Oct 2015 00:25:31 +0200 Subject: [PATCH 20/54] Work on theme md --- htdocs/theme/md/img/filter.png | Bin 206 -> 237 bytes htdocs/theme/md/img/sort_asc.png | Bin 256 -> 248 bytes htdocs/theme/md/img/sort_desc.png | Bin 264 -> 260 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/htdocs/theme/md/img/filter.png b/htdocs/theme/md/img/filter.png index 917715107bde9b14abbe77024e805b1a03d40153..ee34a22c78e0cd31d74739b7cb8a1bda9aa6e608 100644 GIT binary patch literal 237 zcmeAS@N?(olHy`uVBq!ia0vp^d_c^_!2%@pE-d!}QcOwS?k)`f+xyS#2l6-zJR*x3 z7`TN&n2}-D90{Nxdx@v7EBk#eCSE;pf6mhzopr0Ca^+T>t<8 literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^JV4CH!VDx|PJVD7NNEN5gt!7}Mn*;v5fO25aambe zAQu7}8X6WXSaA68;iE^79y@mI&Ye5$jrD9mIrfquzhJN$Udfh)Hdld6A5Ry@5RU7m zM-2rV3vq+CoUK~H7~vtEB6V#~9mon#S3j3^P6G6?Z8qBsBm0EJ0JK~y-)?b4wQ!cY{3(Q^@ykT3;~ z88D22M5EaQ24D{qiy-j`3@PSfsA(Er+SHKrPd@kVQ7+Inu)wte)m<>_CxY!z;nh-wZQEV^ f@24HH5gTA1#Wet2_%IXM00000NkvXXu0mjf_YO-w delta 183 zcmV;o07(D%0e}LKBnkm@Qb$4nuFf3kks&dE1p^K=E9l_^c>n+afJsC_R5;7+(lHJ} zK@fo9Sp|v2DRj=DaSWwe?H lro}RMm;UG8zJi({KO)0Fg;VK~y-)?bIO-gFq04;r}7pgoIPn z^$ayV2C}-Ed(Z>)9#vcfiAU5BFoRh|rwdI;ieQpwcHew*WM-^22`kQy?bzQiNx7t6 zQs<+=u3vW|n1IIwdjk3yGYjAer~}jh=V(9n r8NfR*0L5%~0d@dNAf4-Kv&V4+V3ZPE5OdhM00000NkvXXu0mjf9C=JO delta 191 zcmV;w06_nQ0*C^TBnkm@Qb$4nuFf3kks&dE1p^K>AJ9(5jQ{`uh)G02R5;7+)G-bL zQ5Xc^Sp|v2DRj=DaSWwe?H(M!Jyb5D)GIWynoqNpJeFh=ik;+dUS_`XRY+GEq{H-B zkNpx`CaII$3Rfpt6;~+T2nXdHF)8g{VZj{NC+LF3tIa#C!tM#%H}79#!4#(kI%D=K tuHS|QYuvGE>wba_vBkKpTm9|l_yFr5ciURC7Lxz~002ovPDHLkV1mzcQkDP! From e70bb28be7fe5c6f6a362027647dce87e95fb6ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Oct 2015 00:47:35 +0200 Subject: [PATCH 21/54] If firstname not define, use lastname --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/main.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 053c285c5de..abaf5d24837 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4384,7 +4384,7 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='', $wit * * @param string $firstname Firstname * @param string $lastname Lastname - * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname + * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname * @return string Firstname + lastname or Lastname + firstname */ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 9e6869f7302..199a882d0d5 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1492,7 +1492,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a // Login name with tooltip $toprightmenu.='
'; $toprightmenu.=''; From b5e633ef42d379bd49d9aad9dc718acf0d7dddaa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Oct 2015 00:52:53 +0200 Subject: [PATCH 22/54] Size too small --- htdocs/core/class/html.formother.class.php | 2 +- htdocs/core/lib/usergroups.lib.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 437637c3bdf..7adabcf819b 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -598,7 +598,7 @@ class FormOther include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; $color = colorArrayToHex(colorStringToArray($color,array()),''); - if ($color) print ''; + if ($color) print ''; else print $textifnotdefined; } diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php index 243438b0aa6..526f6e48185 100644 --- a/htdocs/core/lib/usergroups.lib.php +++ b/htdocs/core/lib/usergroups.lib.php @@ -414,7 +414,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) { if ($conf->global->THEME_ELDY_USE_HOVER == '1') $color='edf4fb'; else $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_USE_HOVER,array()),''); - if ($color) print ''; + if ($color) print ''; else print $langs->trans("None"); } print '   ('.$langs->trans("Default").': edf4fb, '.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; @@ -440,7 +440,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''); - if ($color) print ''; + if ($color) print ''; else print ''; } if ($edit) print '
('.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; @@ -459,7 +459,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false) else { $color = colorArrayToHex(colorStringToArray($conf->global->THEME_ELDY_TOPMENU_BACK1,array()),''); - if ($color) print ''; + if ($color) print ''; else print $langs->trans("Default"); } print '   ('.$langs->trans("Default").': 6e7896, '.$langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis").')'; From fa138ca5263ec62e470b40c4d1f989999bd86dad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Oct 2015 02:31:24 +0200 Subject: [PATCH 23/54] Fix color of text --- htdocs/main.inc.php | 2 +- htdocs/theme/eldy/style.css.php | 7 +++++-- htdocs/theme/md/style.css.php | 6 +++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 199a882d0d5..7e7a057e71b 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1492,7 +1492,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a // Login name with tooltip $toprightmenu.='
'; $toprightmenu.=''; diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index e552ca75553..72a7d179f63 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1088,13 +1088,16 @@ div.login_block_other { padding-top: 3px; text-align: right; } padding: 0px 0px 0px 4px !important; height: 16px; } -.alogin, .alogin:hover { +.atoplogin, .atoplogin:hover { color: # !important; font-weight: normal !important; +} +.alogin, .alogin:hover { + font-weight: normal !important; font-size: px !important; padding-top: 2px; } -.alogin:hover { +.alogin:hover, .atoplogin:hover { text-decoration:underline !important; } img.login, img.printer, img.entity { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index c01d0198e0b..ef2bb3a93de 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1114,12 +1114,16 @@ div.login_block_other { padding-top: 3px; } .login_block_elem_name { margin-top: 5px; } +.atoplogin, .atoplogin:hover { + color: # !important; + font-weight: normal !important; +} .alogin, .alogin:hover { color: #888 !important; font-weight: normal !important; font-size: px !important; } -.alogin:hover { +.alogin:hover, .atoplogin:hover { text-decoration:underline !important; } img.login, img.printer, img.entity { From 22979523dbad10ba9843bbaef1b8f3eb7bbb6274 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Oct 2015 02:34:53 +0200 Subject: [PATCH 24/54] Try a fix for #3742 --- htdocs/compta/facture.php | 4 +-- htdocs/core/class/commonobject.class.php | 43 +++++++++++++++++------- htdocs/fourn/facture/card.php | 4 +-- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 5105f8196d1..a178abae47c 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2347,8 +2347,8 @@ if ($action == 'create') } print '' . $langs->trans($newclassname) . '' . $objectsrc->getNomUrl(1); - //We check if Origin document has already an invoice attached to it - $objectsrc->fetchObjectLinked($originid,'','','facture'); + // We check if Origin document (id and type is known) has already at least one invoice attached to it + $objectsrc->fetchObjectLinked($originid,$origin,'','facture'); $cntinvoice=count($objectsrc->linkedObjects['facture']); if ($cntinvoice>=1) { diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d20d5d82bde..1094b549fab 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2231,13 +2231,18 @@ abstract class CommonObject /** * Fetch array of objects linked to current object. Links are loaded into this->linkedObjects array and this->linkedObjectsIds - * - * @param int $sourceid Object source id - * @param string $sourcetype Object source type - * @param int $targetid Object target id - * @param string $targettype Object target type + * Possible usage for parameters: + * - all parameters empty -> we look all link to current object (current object can be source or target) + * - one couple id+type is provided -> this will set $justsource or $justtarget + * - one couple id+type is provided and other type is provided -> this will set $justsource or $justtarget + criteria on other type + * + * + * @param int $sourceid Object source id (if not defined, id of object) + * @param string $sourcetype Object source type (if not defined, element name of object) + * @param int $targetid Object target id (if not defined, id of object) + * @param string $targettype Object target type (if not defined, elemennt name of object) * @param string $clause 'OR' or 'AND' clause used when both source id and target id are provided - * @param int $alsosametype 0=Return only links to different object than source. 1=Include also link to objects of same type. + * @param int $alsosametype 0=Return only links to object that differs from source. 1=Include also link to objects of same type. * @return void * @see add_object_linked, updateObjectLinked, deleteObjectLinked */ @@ -2255,12 +2260,12 @@ abstract class CommonObject if (! empty($sourceid) && ! empty($sourcetype) && empty($targetid)) { - $justsource=true; + $justsource=true; // the source (id and type) is a search criteria if (! empty($targettype)) $withtargettype=true; } if (! empty($targetid) && ! empty($targettype) && empty($sourceid)) { - $justtarget=true; + $justtarget=true; // the target (id and type) is a search criteria if (! empty($sourcetype)) $withsourcetype=true; } @@ -2309,13 +2314,27 @@ abstract class CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - if ($obj->fk_source == $sourceid) + if ($justsource || $justtarget) { - $this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target; + if ($justsource) + { + $this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target; + } + else if ($justtarget) + { + $this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source; + } } - if ($obj->fk_target == $targetid) + else { - $this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source; + if ($obj->fk_source == $sourceid && $obj->sourcetype == $sourcetype) + { + $this->linkedObjectsIds[$obj->targettype][$obj->rowid]=$obj->fk_target; + } + if ($obj->fk_target == $targetid && $obj->targettype == $targettype) + { + $this->linkedObjectsIds[$obj->sourcetype][$obj->rowid]=$obj->fk_source; + } } $i++; } diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a8d84c7cd36..f3f9dc6afa3 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1515,8 +1515,8 @@ if ($action == 'create') $txt=$langs->trans("SupplierOrder"); } print ''.$txt.''.$objectsrc->getNomUrl(1); - //We check if Origin document has already an invoice attached to it - $objectsrc->fetchObjectLinked($originid,'','','invoice_supplier'); + // We check if Origin document (id and type is known) has already at least one invoice attached to it + $objectsrc->fetchObjectLinked($originid,$origin,'','invoice_supplier'); $cntinvoice=count($objectsrc->linkedObjects['invoice_supplier']); if ($cntinvoice>=1) { From 0d9c0b12158efa79b5ba71110e74cbb5da2c72e2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Oct 2015 02:49:34 +0200 Subject: [PATCH 25/54] Disable of image done by css, not dol_optimize_smallscreen option --- htdocs/theme/eldy/style.css.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index 72a7d179f63..cbdaf1afc10 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -671,7 +671,7 @@ $heightmenu=46; /* height of top menu, part with image */ $heightmenu2=48; /* height of top menu, part with login */ $disableimages = 0; $maxwidthloginblock = 110; -if (! empty($conf->global->THEME_ELDY_DISABLE_IMAGE) || $dol_optimize_smallscreen) { $disableimages = 1; $maxwidthloginblock = 180; } +if (! empty($conf->global->THEME_ELDY_DISABLE_IMAGE)) { $disableimages = 1; $maxwidthloginblock = 180; } ?> div#id-top { diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index ef2bb3a93de..0fa988c16e8 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -708,7 +708,7 @@ $heightmenu=48; /* height of top menu, part with image */ $heightmenu2=48; /* height of top menu, ârt with login */ $disableimages = 0; $maxwidthloginblock = 110; -if (! empty($conf->global->THEME_ELDY_DISABLE_IMAGE) || $dol_optimize_smallscreen) { $disableimages = 1; $maxwidthloginblock = 180; } +if (! empty($conf->global->THEME_ELDY_DISABLE_IMAGE)) { $disableimages = 1; $maxwidthloginblock = 180; } ?> div#tmenu_tooltip { From 72491db6b4d0d24b27c05256164ac0c4938f6e6d Mon Sep 17 00:00:00 2001 From: philippe grand Date: Tue, 20 Oct 2015 09:31:33 +0200 Subject: [PATCH 26/54] [Qual] Uniformize code --- htdocs/accountancy/admin/account.php | 4 ++-- htdocs/accountancy/admin/card.php | 2 +- htdocs/accountancy/admin/export.php | 4 ++-- htdocs/accountancy/admin/fiscalyear_card.php | 6 +++--- htdocs/accountancy/admin/importaccounts.php | 6 +++--- htdocs/accountancy/admin/index.php | 12 ++++++------ htdocs/accountancy/admin/journal.php | 4 ++-- htdocs/accountancy/admin/productaccount.php | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index a56701dada2..d1c4ef409b4 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -76,7 +76,7 @@ if ($action == 'disable') { $action = 'update'; if ($result < 0) { - setEventMessage($accounting->error, 'errors'); + setEventMessages($accounting->error, $accounting->errors, 'errors'); } } else if ($action == 'enable') { if ($accounting->fetch($id)) { @@ -84,7 +84,7 @@ if ($action == 'disable') { } $action = 'update'; if ($result < 0) { - setEventMessage($accounting->error, 'errors'); + setEventMessages($accounting->error, $accounting->errors, 'errors'); } } diff --git a/htdocs/accountancy/admin/card.php b/htdocs/accountancy/admin/card.php index 925bf818137..99eb49949e7 100644 --- a/htdocs/accountancy/admin/card.php +++ b/htdocs/accountancy/admin/card.php @@ -125,7 +125,7 @@ else if ($action == 'delete') } if ($result < 0) { - setEventMessage($accounting->error, 'errors'); + setEventMessages($accounting->error, $accounting->errors, 'errors'); } } diff --git a/htdocs/accountancy/admin/export.php b/htdocs/accountancy/admin/export.php index 9bde2d23c14..c0a987ddf82 100644 --- a/htdocs/accountancy/admin/export.php +++ b/htdocs/accountancy/admin/export.php @@ -100,9 +100,9 @@ if ($action == 'update') { } if (! $error) { - setEventMessage($langs->trans("SetupSaved")); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessage($langs->trans("Error"), 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } diff --git a/htdocs/accountancy/admin/fiscalyear_card.php b/htdocs/accountancy/admin/fiscalyear_card.php index 657d5b100e6..45e69c991de 100644 --- a/htdocs/accountancy/admin/fiscalyear_card.php +++ b/htdocs/accountancy/admin/fiscalyear_card.php @@ -66,7 +66,7 @@ if ($action == 'confirm_delete' && $confirm == "yes") } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -110,7 +110,7 @@ else if ($action == 'add') { $db->rollback(); - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action='create'; } } @@ -147,7 +147,7 @@ else if ($action == 'update') } else { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else diff --git a/htdocs/accountancy/admin/importaccounts.php b/htdocs/accountancy/admin/importaccounts.php index 61e86b7df19..7c38617d66c 100644 --- a/htdocs/accountancy/admin/importaccounts.php +++ b/htdocs/accountancy/admin/importaccounts.php @@ -76,14 +76,14 @@ if ($_POST["action"] == 'import') { $result = $accounting->create($user); if ($result > 0) { - setEventMessage($langs->trans("AccountingAccountAdd"), 'mesgs'); + setEventMessages($langs->trans("AccountingAccountAdd"), null, 'mesgs'); } else { - setEventMessage($accounting->error, 'errors'); + setEventMessages($accounting->error, $accounting->errors, 'errors'); } $cpt ++; } } else { - setEventMessage($langs->trans('AccountPlanNotFoundCheckSetting'), 'errors'); + setEventMessages($langs->trans('AccountPlanNotFoundCheckSetting'), null, 'errors'); } } else { print '
' . $langs->trans("AnyLineImport") . '
'; diff --git a/htdocs/accountancy/admin/index.php b/htdocs/accountancy/admin/index.php index af0bccdf00c..40dff028783 100644 --- a/htdocs/accountancy/admin/index.php +++ b/htdocs/accountancy/admin/index.php @@ -111,11 +111,11 @@ if ($action == 'update') if (! $error) { - setEventMessage($langs->trans("SetupSaved")); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessage($langs->trans("Error"),'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } @@ -126,9 +126,9 @@ if ($action == 'setlistsorttodo') { $error ++; if (! $error) { - setEventMessage($langs->trans("SetupSaved"), 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessage($langs->trans("Error"), 'mesgs'); + setEventMessages($langs->trans("Error"), null, 'mesgs'); } } @@ -138,9 +138,9 @@ if ($action == 'setlistsortdone') { if (! $res > 0) $error ++; if (! $error) { - setEventMessage($langs->trans("SetupSaved"), 'mesgs'); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessage($langs->trans("Error"), 'mesgs'); + setEventMessages($langs->trans("Error"), null, 'mesgs'); } } diff --git a/htdocs/accountancy/admin/journal.php b/htdocs/accountancy/admin/journal.php index b55728ee080..18f01abb082 100644 --- a/htdocs/accountancy/admin/journal.php +++ b/htdocs/accountancy/admin/journal.php @@ -68,9 +68,9 @@ if ($action == 'update') { } if (! $error) { - setEventMessage($langs->trans("SetupSaved")); + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { - setEventMessage($langs->trans("Error"), 'errors'); + setEventMessages($langs->trans("Error"), null, 'errors'); } } diff --git a/htdocs/accountancy/admin/productaccount.php b/htdocs/accountancy/admin/productaccount.php index d79d14e74d1..0bea58fd75c 100644 --- a/htdocs/accountancy/admin/productaccount.php +++ b/htdocs/accountancy/admin/productaccount.php @@ -116,7 +116,7 @@ if ($action == 'update') { $result=$accounting->fetch($accounting_account_id,null,1); if ($result<0) { - //setEventMessage(null, $accounting->errors,'errors'); + //setEventMessages(null, $accounting->errors, 'errors'); $msg .= '
' . $langs->trans("ErrorDB") . ' : ' . $langs->trans("Product") . ' ' . $productid . ' ' . $langs->trans("NotVentilatedinAccount") . ' : id=' . $accounting_account_id . '
' . $sql . '
'; } else { From 3cb2637f25da744249c8f165e6ec4e75ab5d77bd Mon Sep 17 00:00:00 2001 From: All-3kcis Date: Tue, 20 Oct 2015 09:42:02 +0200 Subject: [PATCH 27/54] Correct return value --- htdocs/fourn/class/fournisseur.product.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 490b5cf1ea3..cf580459a9c 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -229,7 +229,7 @@ class ProductFournisseur extends Product else { $this->db->rollback(); - return 1; + return -1; } } else @@ -312,7 +312,7 @@ class ProductFournisseur extends Product else { $this->db->rollback(); - return 1; + return -1; } } else From a0fe65266adebd5ac547f2cb3b89b41db267a573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 09:50:09 +0200 Subject: [PATCH 28/54] Update shipment.php --- htdocs/expedition/shipment.php | 35 ++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 82bf1d01e6a..50a231c0898 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -123,6 +123,12 @@ if ($action == 'setshippingmethod' && $user->rights->commande->creer) { $result=$commande->setShippingMethod(GETPOST('shipping_method_id', 'int')); } +// warehouse +if ($action == 'setwarehouse' && $user->rights->commande->creer) { + $commande = new Commande($db); + $commande->fetch($id); + $result = $commande->setWarehouse(GETPOST('warehouse_id', 'int')); +} /* @@ -164,8 +170,8 @@ if ($id > 0 || ! empty($ref)) } // Onglet commande - $nbrow=8; - if (! empty($conf->projet->enabled)) $nbrow++; + //$nbrow=8; + //if (! empty($conf->projet->enabled)) $nbrow++; print ''; @@ -286,6 +292,27 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; + // Warehouse + if (! empty($conf->stock->enabled) && ! empty($conf->global->WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER)) { + require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; + $formproduct=new FormProduct($db); + print ''; + print ''; + } + // Terms of payment print '"; } } + else + { + print ''; + } print "
'; + print ''; + if ($action != 'editwarehouse' && $user->rights->commande->creer) + print ''; + print '
'; + print $langs->trans('Warehouse'); + print 'id.'">'.img_edit($langs->trans('SetWarehouse'),1).'
'; + print '
'; + if ($action == 'editwarehouse') { + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->warehouse_id, 'warehouse_id', 1); + } else { + $formproduct->formSelectWarehouses($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->warehouse_id, 'none'); + } + print '
'; print ''; + print ''; // Qty already shipped $qtyProdCom=$objp->qty; @@ -677,7 +704,7 @@ if ($id > 0 || ! empty($ref)) print ''.$langs->trans("WarehouseSource").''; print ' diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 898348d047e..5551d848b5f 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -93,7 +93,7 @@ elseif (($type== 'sellist') || ($type == 'chkbxlst') || ($type == 'link') ) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 6f720c0a92b..46112d624ce 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -398,6 +398,7 @@ ExtrafieldParamHelpcheckbox=Parameters list have to be like key,value

fo ExtrafieldParamHelpradio=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpsellist=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter ExtrafieldParamHelpchkbxlst=Parameters list comes from a table
Syntax : table_name:label_field:id_field::filter
Example : c_typent:libelle:id::filter

filter can be a simple test (eg active=1) to display only active value
if you want to filter on extrafields use syntaxt extra.fieldcode=... (where field code is the code of extrafield)

In order to have the list depending on another :
c_typent:libelle:id:parent_list_code|parent_column:filter +ExtrafieldParamHelplink=Parameters must be ObjectName:Classpath
Syntax : ObjectName:Classpath
Example : Societe:societe/class/societe.class.php LibraryToBuildPDF=Library used to build PDF WarningUsingFPDF=Warning: Your conf.php contains directive dolibarr_pdf_force_fpdf=1. This means you use the FPDF library to generate PDF files. This library is old and does not support a lot of features (Unicode, image transparency, cyrillic, arab and asiatic languages, ...), so you may experience errors during PDF generation.
To solve this and have a full support of PDF generation, please download TCPDF library, then comment or remove the line $dolibarr_pdf_force_fpdf=1, and add instead $dolibarr_lib_TCPDF_PATH='path_to_TCPDF_dir' LocalTaxDesc=Some countries apply 2 or 3 taxes on each invoice line. If this is the case, choose type for second and third tax and its rate. Possible type are:
1 : local tax apply on products and services without vat (localtax is calculated on amount without tax)
2 : local tax apply on products and services including vat (localtax is calculated on amount + main tax)
3 : local tax apply on products without vat (localtax is calculated on amount without tax)
4 : local tax apply on products including vat (localtax is calculated on amount + main vat)
5 : local tax apply on services without vat (localtax is calculated on amount without tax)
6 : local tax apply on services including vat (localtax is calculated on amount + tax) From f123e11c8ee10170d84bc78aa0d5aad489b15fc5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Oct 2015 12:53:32 +0200 Subject: [PATCH 32/54] Doxygen --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 0f5070f2885..aa2f014c7ba 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -111,7 +111,7 @@ class ExtraFields * @param string $elementtype Element type ('member', 'product', 'thirdparty', ...) * @param int $unique Is field unique or not * @param int $required Is field required or not - * @param string $default_value Defaulted value + * @param string $default_value Defaulted value (Example: '', '0', 'null', 'avalue') * @param array $param Params for field * @param int $alwayseditable Is attribute always editable regardless of the document status * @param string $perms Permission to check From 6f37fef05e9222d82f1eb54ed80e2683c8e3dad0 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Morfin Date: Tue, 20 Oct 2015 14:44:20 +0200 Subject: [PATCH 33/54] fix test against empty amount on book update - amount < 1 was considered as 0 - 0.00 was not considered as empty so $book->sens was always C --- htdocs/accountancy/bookkeeping/card.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index d1bf69a8eee..d4c256dfbf2 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -51,7 +51,7 @@ if ($action == "confirm_update") { $error = 0; - if ((intval($debit) != 0) && (intval($credit) != 0)) { + if ((floatval($debit)!=0.0) && (floatval($credit)!=0.0)) { setEventMessage($langs->trans('ErrorDebitCredit'), 'errors'); $error ++; } @@ -69,11 +69,11 @@ if ($action == "confirm_update") { $book->debit = $debit; $book->credit = $credit; - if (! empty($debit)) { + if (floatval($debit)!=0.0) { $book->montant = $debit; $book->sens = 'D'; } - if (! empty($credit)) { + if (floatval($credit)!=0.0) { $book->montant = $credit; $book->sens = 'C'; } @@ -372,4 +372,4 @@ if ($action == 'create') { } llxFooter(); -$db->close(); \ No newline at end of file +$db->close(); From 8306d93286b833bbb0283828f3e35954cf8ea40a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Oct 2015 16:08:25 +0200 Subject: [PATCH 34/54] NEW Add css on column of detail lines to allow module to easily manipulate fields. --- htdocs/core/class/commonobject.class.php | 34 ++++++++--------- htdocs/core/tpl/objectline_create.tpl.php | 46 +++++++++++------------ htdocs/core/tpl/objectline_view.tpl.php | 40 ++++++++++---------- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 53c9231b19b..f555bd113d9 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3005,60 +3005,60 @@ abstract class CommonObject print ''; - if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ''; + if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) print ''; // Description - print ''; + print ''; if ($this->element == 'askpricesupplier') { - print ''; + print ''; } // VAT - print ''; + print ''; // Price HT - print ''; + print ''; if ($inputalsopricewithtax) print ''; // Qty - print ''; + print ''; if($conf->global->PRODUCT_USE_UNITS) { - print ''; + print ''; } // Reduction short - print ''; + print ''; if ($this->situation_cycle_ref) { - print ''; + print ''; } if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) { if ($conf->global->MARGIN_TYPE == "1") - print ''; + print ''; else - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) - print ''; + print ''; if (! empty($conf->global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) - print ''; + print ''; } // Total HT - print ''; + print ''; - print ''; // No width to allow autodim + print ''; // No width to allow autodim - print ''; + print ''; - print ''; + print ''; print "\n"; diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 64c49894de1..ccf63983539 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -49,36 +49,36 @@ if (in_array($object->element,array('propal', 'askpricesupplier','facture','invo - global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> + element == 'askpricesupplier') { ?> - + trans('AskPriceSupplierRefFourn'); ?> - - + + - + - + global->PRODUCT_USE_UNITS) { - print ''; } ?> - + situation_cycle_ref) { - print ''; + print ''; } if (! empty($usemargins)) { ?> - rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''; - if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) echo ''; + if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARGIN_RATES)) echo ''; + if ($user->rights->margins->creer && ! empty($conf->global->DISPLAY_MARK_RATES)) echo ''; } ?> - + > @@ -102,7 +102,7 @@ else { $coldisplay=0; } ?> - + - - - - global->PRODUCT_USE_UNITS) { - print ''; } ?> - + situation_cycle_ref) { $coldisplay++; @@ -246,7 +246,7 @@ else { if (! empty($usemargins)) { ?> - > global->MAIN_VIEW_LINE_NUMBER)) { ?> - + - element == 'askpricesupplier') { ?> - + - + - + - + - - + situation_cycle_ref) { $coldisplay++; - print ''; + print ''; } if ($usemargins && ! empty($conf->margin->enabled) && empty($user->societe_id)) { $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); ?> - + global->DISPLAY_MARGIN_RATES) && $user->rights->margins->liretous) { ?> - + global->DISPLAY_MARK_RATES) && $user->rights->margins->liretous) {?> - + special_code == 3) { ?> - + - + statut == 0 && ($object_rights->creer)) { ?> - - 1 && empty($conf->browser->phone) && ($this->situation_counter == 1 || !$this->situation_cycle_ref)) { ?> - - + From d9a56ef418e1eef8f87d317e3de7809302ce0e1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 17:00:34 +0200 Subject: [PATCH 35/54] Update index.php --- htdocs/comm/index.php | 80 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 18991f66bba..2c285903cbe 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; if (! empty($conf->contrat->enabled)) require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; if (! empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; if (! empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; +if (! empty($conf->fournisseur->enabled)) require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; if (! $user->rights->societe->lire) accessforbidden(); @@ -65,6 +66,7 @@ $formfile = new FormFile($db); $companystatic=new Societe($db); if (! empty($conf->propal->enabled)) $propalstatic=new Propal($db); if (! empty($conf->commande->enabled)) $orderstatic=new Commande($db); +if (! empty($conf->fournisseur->enabled)) $supplierorderstatic=new CommandeFournisseur($db); llxHeader(); @@ -261,6 +263,84 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) $db->free($resql); } + else + { + dol_print_error($db); + } +} + + +/* + * Draft suppliers orders + */ +if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande->lire) +{ + $langs->load("orders"); + + $sql = "SELECT cf.rowid, cf.ref, cf.ref_supplier, cf.total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; + $sql.= ", s.code_client"; + $sql.= ", s.code_fournisseur"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as cf"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE cf.fk_soc = s.rowid"; + $sql.= " AND cf.fk_statut = 0"; + $sql.= " AND cf.entity IN (".getEntity('supplier_order', 1).")"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($socid) $sql.= " AND cf.fk_soc = ".$socid; + + $resql = $db->query($sql); + if ($resql) + { + $total = 0; + $num = $db->num_rows($resql); + + print '
'; @@ -529,7 +556,7 @@ if ($id > 0 || ! empty($ref)) } // Qty ordered - print ''.$objp->qty.'' . ($objp->qty!=1?''.$objp->qty.'':$objp->qty) . ''; - print $formproduct->selectWarehouses(-1,'entrepot_id','',1); + print $formproduct->selectWarehouses(! empty($commande->warehouse_id)?$commande->warehouse_id:-1,'entrepot_id','',1); if (count($formproduct->cache_warehouses) <= 0) { print '   '.$langs->trans("WarehouseSourceNotDefined").' '.$langs->trans("AddOne").''; From f22b3cdfee24da348694b326673b324b82d19aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 10:31:45 +0200 Subject: [PATCH 29/54] Fix some action has no effect in shipment --- htdocs/expedition/shipment.php | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 82bf1d01e6a..fa2457516ae 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -88,9 +88,7 @@ if ($action == 'setdatedelivery' && $user->rights->commande->creer) $commande->fetch($id); $result=$commande->set_date_livraison($user,$datelivraison); if ($result < 0) - { - $mesg='
'.$commande->error.'
'; - } + setEventMessages($commande->error, $commande->errors, 'errors'); } if ($action == 'setdeliveryaddress' && $user->rights->commande->creer) @@ -98,6 +96,8 @@ if ($action == 'setdeliveryaddress' && $user->rights->commande->creer) $commande = new Commande($db); $commande->fetch($id); $commande->setDeliveryAddress(GETPOST('delivery_address_id','int')); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); } if ($action == 'setmode' && $user->rights->commande->creer) @@ -105,7 +105,24 @@ if ($action == 'setmode' && $user->rights->commande->creer) $commande = new Commande($db); $commande->fetch($id); $result = $commande->setPaymentMethods(GETPOST('mode_reglement_id','int')); - if ($result < 0) dol_print_error($db,$commande->error); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); +} + +if ($action == 'setavailability' && $user->rights->commande->creer) { + $commande = new Commande($db); + $commande->fetch($id); + $result=$commande->availability(GETPOST('availability_id')); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); +} + +if ($action == 'setdemandreason' && $user->rights->commande->creer) { + $commande = new Commande($db); + $commande->fetch($id); + $result=$commande->demand_reason(GETPOST('demand_reason_id')); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); } if ($action == 'setconditions' && $user->rights->commande->creer) @@ -113,7 +130,8 @@ if ($action == 'setconditions' && $user->rights->commande->creer) $commande = new Commande($db); $commande->fetch($id); $result=$commande->setPaymentTerms(GETPOST('cond_reglement_id','int')); - if ($result < 0) dol_print_error($db,$commande->error); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); } // shipping method @@ -121,6 +139,8 @@ if ($action == 'setshippingmethod' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($id); $result=$commande->setShippingMethod(GETPOST('shipping_method_id', 'int')); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); } From 2cb9dd8bf3d328d49454d7b48d2053d6b58f9941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 10:33:46 +0200 Subject: [PATCH 30/54] Update shipment.php --- htdocs/expedition/shipment.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 50a231c0898..ce42107fd79 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -128,6 +128,8 @@ if ($action == 'setwarehouse' && $user->rights->commande->creer) { $commande = new Commande($db); $commande->fetch($id); $result = $commande->setWarehouse(GETPOST('warehouse_id', 'int')); + if ($result < 0) + setEventMessages($commande->error, $commande->errors, 'errors'); } From 0c6441df74dbe2b93a20205fb913326497936957 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 20 Oct 2015 12:40:37 +0200 Subject: [PATCH 31/54] FIX Using extrafield with type "Link to object" works correctly. --- htdocs/commande/class/commande.class.php | 2 +- htdocs/core/class/commonobject.class.php | 31 +++++++++++++------ htdocs/core/class/extrafields.class.php | 31 ++++++++++++++----- htdocs/core/tpl/admin_extrafields_add.tpl.php | 9 ++++-- .../core/tpl/admin_extrafields_edit.tpl.php | 2 +- htdocs/langs/en_US/admin.lang | 1 + 6 files changed, 55 insertions(+), 21 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index d2f5c4d799f..4c2c0f3aea7 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1142,7 +1142,7 @@ class Commande extends CommonOrder * @param int $fk_fournprice Id supplier price * @param int $pa_ht Buying price (without tax) * @param string $label Label - * @param array $array_options extrafields array + * @param array $array_options extrafields array. Example array('options_codeforfield1'=>'valueforfield1', 'options_codeforfield2'=>'valueforfield2', ...) * @param string $fk_unit Code of the unit to use. Null to use the default one * @return int >0 if OK, <0 if KO * diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1094b549fab..53c9231b19b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -3801,10 +3801,10 @@ abstract class CommonObject foreach ($tab as $key => $value) { - // Test fetch_array ! is_int($key) because fetch_array seult is a mix table with Key as alpha and Key as int (depend db engine) + // Test fetch_array ! is_int($key) because fetch_array result is a mix table with Key as alpha and Key as int (depend db engine) if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key)) { - // we can add this attribute to adherent object + // we can add this attribute to object $this->array_options["options_".$key]=$value; } } @@ -3852,7 +3852,7 @@ abstract class CommonObject /** * Add/Update all extra fields values 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. + * This function delete record with all extrafields and insert them again from the array $this->array_options. * * @return int -1=error, O=did nothing, 1=OK */ @@ -3906,12 +3906,25 @@ abstract class CommonObject // 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; - } + if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) + { + $object = new $InfoFieldList[0]($this->db); + if ($value) + { + $res=$object->fetch(0,$value); + if ($res > 0) $this->array_options[$key]=$object->id; + else + { + $this->error="Ref '".$value."' for object '".$object->element."' not found"; + $this->db->rollback(); + return -1; + } + } + } + else + { + dol_syslog('Error bad setup of extrafield', LOG_WARNING); + } break; } } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 4d9fec42bf9..0f5070f2885 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1085,10 +1085,19 @@ class ExtraFields // 1 : classPath $InfoFieldList = explode(":", $param_list[0]); dol_include_once($InfoFieldList[1]); - $object = new $InfoFieldList[0]($this->db); - $object->fetch($value); - $out=''; - + if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) + { + $object = new $InfoFieldList[0]($this->db); + $object->fetch($value); + $valuetoshow=$object->ref; + if ($object->element == 'societe') $valuetoshow=$object->name; // Special case for thirdparty because ref is id because name is not unique + $out.=''; + } + else + { + dol_syslog('Error bad setup of extrafield', LOG_WARNING); + $out.='Error bad setup of extrafield'; + } } /* Add comments if ($type == 'date') $out.=' (YYYY-MM-DD)'; @@ -1326,9 +1335,17 @@ class ExtraFields // 1 : classPath $InfoFieldList = explode(":", $param_list[0]); dol_include_once($InfoFieldList[1]); - $object = new $InfoFieldList[0]($this->db); - $object->fetch($value); - $value=$object->getNomUrl(3); + if ($InfoFieldList[0] && class_exists($InfoFieldList[0])) + { + $object = new $InfoFieldList[0]($this->db); + $object->fetch($value); + $value=$object->getNomUrl(3); + } + else + { + dol_syslog('Error bad setup of extrafield', LOG_WARNING); + $out.='Error bad setup of extrafield'; + } } } elseif ($type == 'text') diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 142c0903212..174da1ae409 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -100,9 +100,12 @@ - +
-textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0)?>textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0)?> -textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0)?>
+textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0)?> +textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0)?> +textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0)?> +textwithpicto('', $langs->trans("ExtrafieldParamHelplink"),1,0)?> +
trans("Position"); ?>
  '.$langs->trans('Description').''.$langs->trans('Description').''.$langs->trans("AskPriceSupplierRefFourn").''.$langs->trans("AskPriceSupplierRefFourn").''.$langs->trans('VAT').''.$langs->trans('VAT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUHT').''.$langs->trans('PriceUTTC').''.$langs->trans('Qty').''.$langs->trans('Qty').''.$langs->trans('Unit').''.$langs->trans('Unit').''.$langs->trans('ReductionShort').''.$langs->trans('ReductionShort').'' . $langs->trans('Progress') . '' . $langs->trans('Progress') . ''.$langs->trans('BuyingPrice').''.$langs->trans('BuyingPrice').''.$langs->trans('CostPrice').''.$langs->trans('CostPrice').''.$langs->trans('MarginRate').''.$langs->trans('MarginRate').''.$langs->trans('MarkRate').''.$langs->trans('MarkRate').''.$langs->trans('TotalHTShort').''.$langs->trans('TotalHTShort').'
global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>>
trans('AddNewLine'); ?>trans("FreeZone"); ?>
trans('AskPriceSupplierRefFourn'); ?>trans('VAT'); ?>trans('PriceUHT'); ?>trans('VAT'); ?>trans('PriceUHT'); ?> trans('PriceUTTC'); ?>trans('PriceUTTC'); ?> trans('Qty'); ?>trans('Qty'); ?> '; + print ''; print ''; print $langs->trans('Unit'); print 'trans('ReductionShort'); ?>trans('ReductionShort'); ?> ' . $langs->trans('Progress') . '' . $langs->trans('Progress') . ' + global->MARGIN_TYPE == "1") echo $langs->trans('BuyingPrice'); @@ -87,11 +87,11 @@ if (in_array($object->element,array('propal', 'askpricesupplier','facture','invo ?> '.$langs->trans('MarginRate').''.$langs->trans('MarkRate').''.$langs->trans('MarginRate').''.$langs->trans('MarkRate').'  
global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> + global->MAIN_VIEW_LINE_NUMBER) ? ' colspan="2"' : ''); ?>> element == 'askpricesupplier') { ?> - tva_assuj == "0") echo ''.vatrate(0, true); else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); ?> + "> + "> "> + "> '; + print ''; print $form->selectUnits($line->fk_unit, "units"); print 'remise_percent); ?>">%remise_percent); ?>">% + product->enabled) || ! empty($conf->service->enabled)) { ?> @@ -277,7 +277,7 @@ else { } } ?> - +
+
info_bits & 2) == 2) { ?> @@ -125,17 +125,17 @@ if (empty($usemargins)) $usemargins=0; ?>
ref_fourn; ?>ref_fourn; ?> tva_tx,'%',$line->info_bits); ?>tva_tx,'%',$line->info_bits); ?>subprice); ?>subprice); ?> pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?>pu_ttc)?price($line->pu_ttc):price($line->subprice)); ?> + info_bits & 2) != 2) && $line->special_code != 3) { // I comment this because it shows info even when not required // for example always visible on invoice but must be visible only if stock module on and stock decrease option is on invoice validation and status is not validated @@ -148,7 +148,7 @@ if (empty($usemargins)) $usemargins=0; global->PRODUCT_USE_UNITS) { - print ''; + print ''; $label = $line->getLabelOfUnit('short'); if ($label !== '') { print $langs->trans($label); @@ -158,42 +158,42 @@ if (empty($usemargins)) $usemargins=0; ?> remise_percent) && $line->special_code != 3) { ?> - remise_percent,$langs); ?>    ' . $line->situation_percent . '%' . $line->situation_percent . '%pa_ht); ?>pa_ht); ?> pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?>pa_ht == 0)?'n/a':price($line->marge_tx, null, null, null, null, $rounding).'%'); ?> marque_tx, null, null, null, null, $rounding).'%'; ?>marque_tx, null, null, null, null, $rounding).'%'; ?> trans('Option'); ?>trans('Option'); ?> total_ht); ?>total_ht); ?> + info_bits & 2) == 2) { ?> id.'#line_'.$line->id; ?>"> @@ -202,7 +202,7 @@ if (empty($usemargins)) $usemargins=0; + situation_counter == 1 || !$this->situation_cycle_ref) { print 'id . '">'; @@ -213,7 +213,7 @@ if (empty($usemargins)) $usemargins=0; + 0) { ?> id; ?>"> @@ -226,7 +226,7 @@ if (empty($usemargins)) $usemargins=0; browser->phone)?' class="tdlineupdown"':''); ?>>browser->phone)?' class="linecolmove tdlineupdown"':' class="linecolmove"'); ?>>
'; + print ''; + print ''; + + if ($num) + { + $i = 0; + $var = true; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ''; + print ''; + print ''; + $i++; + $total += $obj->total_ttc; + } + if ($total>0) + { + $var=!$var; + print '"; + } + } + print "
'.$langs->trans("DraftSuppliersOrders").' '.$num.'
'; + $supplierorderstatic->id=$obj->rowid; + $supplierorderstatic->ref=$obj->ref; + $supplierorderstatic->ref_supplier=$obj->ref_suppliert; + $supplierorderstatic->total_ht = $obj->total_ht; + $supplierorderstatic->total_tva = $obj->total_tva; + $supplierorderstatic->total_ttc = $obj->total_ttc; + print $supplierorderstatic->getNomUrl(1); + print ''; + $companystatic->id=$obj->socid; + $companystatic->name=$obj->name; + $companystatic->client=$obj->client; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->canvas=$obj->canvas; + print $companystatic->getNomUrl(1,'customer',16); + print ''.price($obj->total_ttc).'
'.$langs->trans("Total").''.price($total)."

"; + + $db->free($resql); + } else { + dol_print_error($db); + } } From 506b251f24111e59981e60bb6c3fa14e24697830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 17:02:04 +0200 Subject: [PATCH 36/54] Update orders.lang --- htdocs/langs/en_US/orders.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index bd1bb09d40f..e1f84847e5d 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -105,6 +105,7 @@ ClassifyShipped=Classify delivered ClassifyBilled=Classify billed ComptaCard=Accountancy card DraftOrders=Draft orders +DraftSuppliersOrders=Draft suppliers orders RelatedOrders=Related orders RelatedCustomerOrders=Related customer orders RelatedSupplierOrders=Related supplier orders From 4062e7474ddde50e9ad1ebbbf77060a8453b7158 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 18:05:21 +0200 Subject: [PATCH 37/54] Update index.php --- htdocs/comm/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 2c285903cbe..fcb94392405 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -146,7 +146,7 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print ''; print ''; - print ''; + print ''; if ($num > 0) { @@ -221,7 +221,7 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print '
'.$langs->trans("ProposalsDraft").' '.$num.'
'.$langs->trans("ProposalsDraft").($num?' '.$num.'':'').'
'; print ''; - print ''; + print ''; if ($num) { @@ -297,7 +297,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande print '
'.$langs->trans("DraftOrders").' '.$num.'
'.$langs->trans("DraftOrders").($num?' '.$num.'':'').'
'; print ''; - print ''; + print ''; if ($num) { From 2989a9445843f86e92666ed15c4d587f94c8375f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 18:19:32 +0200 Subject: [PATCH 38/54] Update index.php --- htdocs/comm/index.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index fcb94392405..49f618a4dd5 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -184,6 +184,10 @@ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) print '"; } } + else + { + print ''; + } print "
'.$langs->trans("DraftSuppliersOrders").' '.$num.'
'.$langs->trans("DraftSuppliersOrders").($num?' '.$num.'':'').'
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoProposal").'

"; $db->free($resql); @@ -259,6 +263,10 @@ if (! empty($conf->commande->enabled) && $user->rights->commande->lire) print '
'.$langs->trans("Total").''.price($total)."
'.$langs->trans("NoOrder").'

"; $db->free($resql); @@ -335,6 +343,10 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->commande print ''.$langs->trans("Total").''.price($total).""; } } + else + { + print ''.$langs->trans("NoSupplierOrder").''; + } print "
"; $db->free($resql); From be85943d133d2d2d1095cb0141c8be81df06cfc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 18:21:28 +0200 Subject: [PATCH 39/54] Update orders.lang --- htdocs/langs/en_US/orders.lang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/langs/en_US/orders.lang b/htdocs/langs/en_US/orders.lang index e1f84847e5d..287a83afba3 100644 --- a/htdocs/langs/en_US/orders.lang +++ b/htdocs/langs/en_US/orders.lang @@ -79,6 +79,8 @@ OrdersOpened=Orders to process NoOpenedOrders=No open orders NoOtherOpenedOrders=No other open orders NoDraftOrders=No draft orders +NoOrder=No Order +NoSupplierOrder=No supplier order OtherOrders=Other orders LastOrders=Last %s customer orders LastCustomerOrders=Last %s customer orders From 15733f5ed09d8aa0d4637d7d78b745242aa05273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 18:23:30 +0200 Subject: [PATCH 40/54] Update propal.lang --- htdocs/langs/en_US/propal.lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index 168f98a2789..d12d7595f94 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -53,6 +53,7 @@ ListOfProposals=List of commercial proposals ActionsOnPropal=Events on proposal NoOpenedPropals=No open commercial proposals NoOtherOpenedPropals=No other open commercial proposals +NoPropal=No commercial proposal RefProposal=Commercial proposal ref SendPropalByMail=Send commercial proposal by mail AssociatedDocuments=Documents associated with the proposal: @@ -98,4 +99,4 @@ DocModelJauneDescription=Jaune proposal model DefaultModelPropalCreate=Default model creation DefaultModelPropalToBill=Default template when closing a business proposal (to be invoiced) DefaultModelPropalClosed=Default template when closing a business proposal (unbilled) -ProposalCustomerSignature=Written acceptance, company stamp, date and signature \ No newline at end of file +ProposalCustomerSignature=Written acceptance, company stamp, date and signature From 73f13045c13eab25a82b0f09bca3c00f81a2b100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 20 Oct 2015 18:24:14 +0200 Subject: [PATCH 41/54] Update index.php --- htdocs/comm/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/comm/index.php b/htdocs/comm/index.php index 49f618a4dd5..86f48d10817 100644 --- a/htdocs/comm/index.php +++ b/htdocs/comm/index.php @@ -127,6 +127,8 @@ if (count($listofsearchfields)) */ if (! empty($conf->propal->enabled) && $user->rights->propal->lire) { + $langs->load("propal"); + $sql = "SELECT p.rowid, p.ref, p.ref_client, p.total_ht, p.tva as total_tva, p.total as total_ttc, s.rowid as socid, s.nom as name, s.client, s.canvas"; $sql.= ", s.code_client"; $sql.= " FROM ".MAIN_DB_PREFIX."propal as p"; From 9a1ec900bdd4c4288fb024465b7f5ce5683b1d2e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Oct 2015 00:31:32 +0200 Subject: [PATCH 42/54] NEW Add into about page, a sample text to use to promote new version release (visible only if version is last stable) --- htdocs/admin/system/about.php | 82 ++++++++++++++++++++++++++++++++++- htdocs/langs/en_US/admin.lang | 8 +++- 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index 737e0712ea6..e9d3f96ad55 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -25,11 +25,15 @@ */ require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php'; $langs->load("admin"); $langs->load("help"); $langs->load("members"); +$youuselaststable = 0; + /* * View @@ -42,9 +46,54 @@ print load_fiche_titre("Dolibarr",'','title_setup'); print '
'.img_picto_common('', 'dolibarr_box.png','height="120"').'
'; + + +print '
'; + print $langs->trans("Version").' / '.$langs->trans("DolibarrLicense").':'; print '
    '; -print '
  • '.DOL_VERSION.' / GNU-GPL v3+
  • '; +print '
  • '.DOL_VERSION.''; + +$result = getURLContent('http://sourceforge.net/projects/dolibarr/rss'); +//var_dump($result['content']); +$sfurl = simplexml_load_string($result['content']); +if ($sfurl) +{ + $title=$sfurl->channel[0]->item[0]->title; + + function word_limiter($text, $limit = 30, $chars = '0123456789.') + { + if (strlen( $text ) > $limit) + { + $words = str_word_count($text, 2, $chars); + $words = array_reverse($words, TRUE); + foreach($words as $length => $word) { + if ($length + strlen( $word ) >= $limit) + { + array_shift($words); + } else { + break; + } + } + $words = array_reverse($words); + $text = implode(" ", $words) . ''; + } + return $text; + } + + $str = word_limiter($title); + $str = preg_replace('/[^0-9\.]/', '', $str); + print ' ('.$langs->trans("LastStableVersion").': '.$str.''; + if (DOL_VERSION == $str) + { + $youuselaststable=1; + print $langs->trans("YouUseLastStableVersion"); + } + print ')'; + print ' / GNU-GPL v3+
  • '; +} + + print '
'; //print "
\n"; @@ -114,6 +163,9 @@ print ''; print ''; +print '
'; + + print $langs->trans("HelpCenter").':'; print ''; +print '
'; +print '
'; +print '
'; + + +if ($youuselaststable) +{ + print '
'; + print '
'; + + $tmp=versiondolibarrarray(); + if ((empty($tmp[2]) && (strpos($tmp[1], '0') === 0)) || (strpos($tmp[2], '0') === 0)) + { + print $langs->trans("TitleExampleForMajorRelease").':
'; + print ''; + } + else + { + print $langs->trans("TitleExampleForMaintenanceRelease").':
'; + print ''; + } +} + llxFooter(); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 46112d624ce..ed2eb3cdffa 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1693,4 +1693,10 @@ MailToSendSupplierRequestForQuotation=To send quotation request to supplier MailToSendSupplierOrder=To send supplier order MailToSendSupplierInvoice=To send supplier invoice MailToThirdparty=To send email from thirdparty page -ByDefaultInList=Show by default on list view \ No newline at end of file +ByDefaultInList=Show by default on list view +YouUseLastStableVersion=You use the last stable version +TitleExampleForMajorRelease=Example of message you can use to announce this major release (feel free to use it on your web sites) +TitleExampleForMaintenanceRelease=Example of message you can use to announce this maintenance release (feel free to use it on your web sites) +ExampleOfNewsMessageForMajorRelease=Dolibarr ERP & CRM %s is available. Version %s is a major release with a lot of new features for both users and developers. You can download it from the download area of http://www.dolibarr.org portal (subdirectory Stable versions). You can read
ChangeLog for complete list of changes. +ExampleOfNewsMessageForMaintenanceRelease=Dolibarr ERP & CRM %s is available. Version %s is a maintenance version, so it contains only fixes of bugs. We recommend everybody using an older version to upgrade to this one. As any maintenance release, no new features, nor data structure change is present into this version. You can download it from the download area of http://www.dolibarr.org portal (subdirectory Stable versions). You can read ChangeLog for complete list of changes. + \ No newline at end of file From 4f519b57475ec7a88ffbdbaea61205d81040b8d8 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 21 Oct 2015 05:06:19 +0200 Subject: [PATCH 43/54] Update admin.lib.php --- htdocs/core/lib/admin.lib.php | 109 +++++----------------------------- 1 file changed, 15 insertions(+), 94 deletions(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 571e24bf38a..66823ab5d18 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -678,27 +678,7 @@ function activateModule($value,$withdeps=1) $modFile = $modName . ".class.php"; // Loop on each directory to fill $modulesdir - $modulesdir = array(); - foreach ($conf->file->dol_document_root as $type => $dirroot) - { - $modulesdir[] = $dirroot."/core/modules/"; - - $handle=@opendir(dol_osencode($dirroot)); - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') - { - if (is_dir($dirroot . '/' . $file . '/core/modules/')) - { - $modulesdir[] = $dirroot . '/' . $file . '/core/modules/'; - } - } - } - closedir($handle); - } - } + $modulesdir = dolGetModulesDirs(); // Loop on each directory $found=false; @@ -797,27 +777,7 @@ function unActivateModule($value, $requiredby=1) $modFile = $modName . ".class.php"; // Loop on each directory to fill $modulesdir - $modulesdir = array(); - foreach ($conf->file->dol_document_root as $type => $dirroot) - { - $modulesdir[] = $dirroot."/core/modules/"; - - $handle=@opendir(dol_osencode($dirroot)); - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') - { - if (is_dir($dirroot . '/' . $file . '/core/modules/')) - { - $modulesdir[] = $dirroot . '/' . $file . '/core/modules/'; - } - } - } - closedir($handle); - } - } + $modulesdir = dolGetModulesDirs(); // Loop on each directory $found=false; @@ -889,31 +849,11 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql $orders = array(); $categ = array(); $dirmod = array(); - $modulesdir = array(); + $i = 0; // is a sequencer of modules found $j = 0; // j is module number. Automatically affected if module number not defined. - foreach ($conf->file->dol_document_root as $type => $dirroot) - { - $modulesdir[$dirroot . '/core/modules/'] = $dirroot . '/core/modules/'; - - $handle=@opendir($dirroot); - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') - { - if (is_dir($dirroot . '/' . $file . '/core/modules/')) - { - $modulesdir[$dirroot . '/' . $file . '/core/modules/'] = $dirroot . '/' . $file . '/core/modules/'; - } - } - } - closedir($handle); - } - } - + $modulesdir = dolGetModulesDirs(); foreach ($modulesdir as $dir) { // Load modules attributes in arrays (name, numero, orders) from dir directory @@ -955,13 +895,13 @@ function complete_dictionary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsql if ($modulequalified) { // Load languages files of module - if (isset($objMod->langfiles) && is_array($objMod->langfiles)) - { - foreach($objMod->langfiles as $langfile) - { - $langs->load($langfile); - } - } + if (isset($objMod->langfiles) && is_array($objMod->langfiles)) + { + foreach($objMod->langfiles as $langfile) + { + $langs->load($langfile); + } + } $modules[$i] = $objMod; $filename[$i]= $modName; @@ -1035,30 +975,11 @@ function complete_elementList_with_modules(&$elementList) $orders = array(); $categ = array(); $dirmod = array(); - $modulesdir = array(); + $i = 0; // is a sequencer of modules found $j = 0; // j is module number. Automatically affected if module number not defined. - foreach ($conf->file->dol_document_root as $type => $dirroot) - { - $modulesdir[$dirroot . '/core/modules/'] = $dirroot . '/core/modules/'; - - $handle=@opendir($dirroot); - if (is_resource($handle)) - { - while (($file = readdir($handle))!==false) - { - if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes') - { - if (is_dir($dirroot . '/' . $file . '/core/modules/')) - { - $modulesdir[$dirroot . '/' . $file . '/core/modules/'] = $dirroot . '/' . $file . '/core/modules/'; - } - } - } - closedir($handle); - } - } + $modulesdir = dolGetModulesDirs(); foreach ($modulesdir as $dir) { @@ -1116,8 +1037,8 @@ function complete_elementList_with_modules(&$elementList) if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories else $categ[$objMod->special]=1; $dirmod[$i] = $dirroot; - - if (! empty($objMod->contactelement)) + $objMod->module_parts['contactelement'] + if (! empty($objMod->module_parts['contactelement'])) { $elementList[$objMod->name] = $langs->trans($objMod->name); //exit; From ec9955986ff25ae89611e4071ad0f6a3fcfc0033 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 21 Oct 2015 05:07:13 +0200 Subject: [PATCH 44/54] Update admin.lib.php --- htdocs/core/lib/admin.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 66823ab5d18..7edf33c89ee 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -1037,7 +1037,6 @@ function complete_elementList_with_modules(&$elementList) if (isset($categ[$objMod->special])) $categ[$objMod->special]++; // Array of all different modules categories else $categ[$objMod->special]=1; $dirmod[$i] = $dirroot; - $objMod->module_parts['contactelement'] if (! empty($objMod->module_parts['contactelement'])) { $elementList[$objMod->name] = $langs->trans($objMod->name); From 88ca8d2ace84f336e61466a8091552e1179b1b29 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 21 Oct 2015 05:22:33 +0200 Subject: [PATCH 45/54] Update dict.php --- htdocs/admin/dict.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 6fb9454ce58..b90514fc61c 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -34,6 +34,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/function2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("errors"); From ef79bb3b6759c339916667e684f17676ec05a2c1 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Wed, 21 Oct 2015 05:23:49 +0200 Subject: [PATCH 46/54] Update dict.php --- htdocs/admin/dict.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index b90514fc61c..889b2e8f4ce 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -34,7 +34,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/function2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("errors"); From fd72b4a400277b7e95d5b645de495c7a15256f7a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Oct 2015 20:43:11 +0200 Subject: [PATCH 47/54] Work on the new selectArrayAjax widget --- htdocs/core/ajax/selectsearchbox.php | 63 +++++++++++++++++++++++++-- htdocs/core/class/html.form.class.php | 13 ++++-- htdocs/langs/en_US/main.lang | 6 ++- htdocs/main.inc.php | 2 +- 4 files changed, 75 insertions(+), 9 deletions(-) diff --git a/htdocs/core/ajax/selectsearchbox.php b/htdocs/core/ajax/selectsearchbox.php index 1783c4794b5..bbb00e2ce29 100644 --- a/htdocs/core/ajax/selectsearchbox.php +++ b/htdocs/core/ajax/selectsearchbox.php @@ -37,12 +37,69 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php'; $search_boxvalue=GETPOST('q'); -$arrayresult=array('a'=>'aaaa', 'b'=>'bbbb'); +$arrayresult=array(); -if ($conf->projet->enabled) +// Define $searchform +if ((( ! empty($conf->societe->enabled) && (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) || empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))) || ! empty($conf->fournisseur->enabled)) && ! empty($conf->global->MAIN_SEARCHFORM_SOCIETE) && $user->rights->societe->lire) { - $arrayresult['searchintoproject']=$langs->trans("SearchIntoProject", $search_boxvalue); + $langs->load("companies"); + //$searchform.=printSearchForm(DOL_URL_ROOT.'/societe/list.php', DOL_URL_ROOT.'/societe/list.php', $langs->trans("ThirdParties"), 'soc', 'sall', 'T', 'searchleftt', img_object('','company')); + $arrayresult['searchintothirdparty']=$langs->trans("SearchIntoThirdparties", $search_boxvalue); } + +if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_CONTACT) && $user->rights->societe->lire) +{ + $langs->load("companies"); + //$searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', $langs->trans("Contacts"), 'contact', 'sall', 'A', 'searchleftc', img_object('','contact')); + $arrayresult['searchintocontact']=$langs->trans("SearchIntoContacts", $search_boxvalue); +} + +if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) +&& ! empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE)) +{ + $langs->load("products"); + //$searchform.=printSearchForm(DOL_URL_ROOT.'/product/list.php', DOL_URL_ROOT.'/product/list.php', $langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall', 'P', 'searchleftp', img_object('','product')); + $arrayresult['searchintoproduct']=$langs->trans("SearchIntoProductsOrServices", $search_boxvalue); +} + +/*if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) && ! empty($conf->fournisseur->enabled) +&& ! empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_SUPPLIER)) +{ + $langs->load("products"); + $searchform.=printSearchForm(DOL_URL_ROOT.'/fourn/product/list.php', DOL_URL_ROOT.'/fourn/product/list.php', $langs->trans("SupplierRef"), 'products', 'srefsupplier', '', 'searchlefts', img_object('','product')); +}*/ + +if (! empty($conf->adherent->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_ADHERENT) && $user->rights->adherent->lire) +{ + $langs->load("members"); + //$searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/list.php', DOL_URL_ROOT.'/adherents/list.php', $langs->trans("Members"), 'member', 'sall', 'M', 'searchleftm', img_object('','user')); + $arrayresult['searchintomember']=$langs->trans("SearchIntoMembers", $search_boxvalue); +} + +if (! empty($conf->projet->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_PROJECT) && $user->rights->projet->lire) +{ + $langs->load("projects"); + //$searchform.=printSearchForm(DOL_URL_ROOT.'/projet/list.php', DOL_URL_ROOT.'/projet/list.php', $langs->trans("Projects"), 'project', 'search_all', 'Q', 'searchleftproj', img_object('','projectpub')); + $arrayresult['searchintoprojects']=$langs->trans("SearchIntoProjects", $search_boxvalue); +} + +// Execute hook printSearchForm +$parameters=array(); +$reshook=$hookmanager->executeHooks('printSearchForm',$parameters); // Note that $action and $object may have been modified by some hooks +if (empty($reshook)) +{ + $searchform.=$hookmanager->resPrint; +} +else $searchform=$hookmanager->resPrint; + + + + + + + + + print json_encode($arrayresult); if (is_object($db)) $db->close(); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1a63cbcca29..f51401c5a38 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4501,7 +4501,7 @@ class Form /** * Return a HTML select string, built from an array of key+value but content returned into select come from an Ajax call of an URL. - * Note: Do not apply langs->trans function on returned content, content may be entity encoded twice. + * Note: Do not apply langs->trans function on returned content of Ajax service, content may be entity encoded twice. * * @param string $htmlname Name of html select area * @param string $url Url @@ -4534,9 +4534,14 @@ class Form }; }, results: function (remoteData, pageNumber, query) { - console.log(remoteData); - return {results:[{id:\'none\', text:\'aa\'}, {id:\'rrr\', text:\'Red\'},{id:\'bbb\', text:\'Search a into projects\'}], more:false} - //return {results:[remoteData], more:false} + //console.log(remoteData); + result = [] + $.each( remoteData, function( key, value ) { + result.push({id: key, text: value}); + }); + //console.log(result); + //return {results:[{id:\'none\', text:\'aa\'}, {id:\'rrr\', text:\'Red\'},{id:\'bbb\', text:\'Search a into projects\'}], more:false} + return {results: result, more:false} }, /*processResults: function (data, page) { // parse the results into the format expected by Select2. diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 7e1dc3ee929..b8c6735be80 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -752,4 +752,8 @@ ShortSaturday=S ShortSunday=S SelectMailModel=Select email template SetRef=Set ref -SearchIntoProject=Search %s into projects \ No newline at end of file +SearchIntoThirdparties=Search %s into thirdparties +SearchIntoContacts=Search %s into contacts +SearchIntoMembers=Search %s into members +SearchIntoProductsOrServices=Search %s into products or services +SearchIntoProjects=Search %s into projects \ No newline at end of file diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 7e7a057e71b..f563961ba29 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1606,7 +1606,7 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me if (! empty($conf->projet->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_PROJECT) && $user->rights->projet->lire) { - $langs->load("members"); + $langs->load("projects"); $searchform.=printSearchForm(DOL_URL_ROOT.'/projet/list.php', DOL_URL_ROOT.'/projet/list.php', $langs->trans("Projects"), 'project', 'search_all', 'Q', 'searchleftproj', img_object('','projectpub')); } From 7daf9d10afd92572207fcafb80510b8e21ffbff9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 21 Oct 2015 20:50:27 +0200 Subject: [PATCH 48/54] Work on the new selectArrayAjax widget --- htdocs/core/class/html.form.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index f51401c5a38..7b472b2a163 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4562,7 +4562,8 @@ class Form $(".'.$htmlname.'").change(function() { alert(\'eee\'); - $(".'.$htmlname.'").select2.clearSearch(); + /* $(".'.$htmlname.'").select2("search",""); */ + $(".'.$htmlname.'").select2("val",""); /* reset combo box */ } ); From 474692e71a4300d44001fb4a4f6a6ba1820728b2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Oct 2015 01:10:25 +0200 Subject: [PATCH 49/54] Remove duplicate page fourn/list.php --- htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/core/menus/standard/eldy.lib.php | 6 +- htdocs/fourn/list.php | 333 ------------------------ htdocs/index.php | 2 +- htdocs/societe/index.php | 2 +- htdocs/societe/list.php | 146 +++++++---- htdocs/theme/eldy/style.css.php | 5 +- 7 files changed, 104 insertions(+), 392 deletions(-) delete mode 100644 htdocs/fourn/list.php diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 8d3464464b2..ffcb21e6535 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -69,7 +69,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 500__+MAX_llx_menu__, 'companies', 'thirdparties', 2__+MAX_llx_menu__, '/societe/index.php?leftmenu=thirdparties', 'ThirdParty', 0, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 501__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/soc.php?action=create', 'MenuNewThirdParty', 1, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 502__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?action=create', 'List', 1, 'companies', '$user->rights->societe->lire', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 503__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/fourn/list.php?leftmenu=suppliers', 'ListSuppliersShort', 1, 'suppliers', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 5, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 503__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/societe/list.php?type=f&leftmenu=suppliers', 'ListSuppliersShort', 1, 'suppliers', '$user->rights->societe->lire && $user->rights->fournisseur->lire', '', 2, 5, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled && $conf->fournisseur->enabled', __HANDLER__, 'left', 504__+MAX_llx_menu__, 'companies', '', 503__+MAX_llx_menu__, '/societe/soc.php?leftmenu=supplier&action=create&type=f', 'NewSupplier', 2, 'suppliers', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 506__+MAX_llx_menu__, 'companies', '', 500__+MAX_llx_menu__, '/comm/prospect/list.php?leftmenu=prospects', 'ListProspectsShort', 1, 'companies', '$user->rights->societe->lire', '', 2, 3, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->societe->enabled', __HANDLER__, 'left', 507__+MAX_llx_menu__, 'companies', '', 506__+MAX_llx_menu__, '/societe/soc.php?leftmenu=prospects&action=create&type=p', 'MenuNewProspect', 2, 'companies', '$user->rights->societe->creer', '', 2, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index e4949b1d973..42701456c6e 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -616,10 +616,8 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! empty($conf->societe->enabled) && ! empty($conf->fournisseur->enabled)) { $langs->load("suppliers"); - $newmenu->add("/fourn/list.php?leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, $user->rights->fournisseur->lire, '', $mainmenu, 'suppliers'); + $newmenu->add("/societe/list.php?type=f&leftmenu=suppliers", $langs->trans("ListSuppliersShort"), 1, $user->rights->fournisseur->lire, '', $mainmenu, 'suppliers'); $newmenu->add("/societe/soc.php?leftmenu=suppliers&action=create&type=f",$langs->trans("MenuNewSupplier"), 2, $user->rights->societe->creer && $user->rights->fournisseur->lire); - //$newmenu->add("/fourn/list.php?leftmenu=suppliers", $langs->trans("List"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire); - //$newmenu->add("/contact/list.php?leftmenu=suppliers&type=f",$langs->trans("Contacts"), 2, $user->rights->societe->lire && $user->rights->fournisseur->lire && $user->rights->societe->contact->lire); } // Contacts @@ -1146,7 +1144,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Security check $newmenu->add("/societe/soc.php?leftmenu=suppliers&action=create&type=f",$langs->trans("NewSupplier"), 1, $user->rights->societe->creer && $user->rights->fournisseur->lire); - $newmenu->add("/fourn/list.php",$langs->trans("List"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire); + $newmenu->add("/societe/list.php?type=f",$langs->trans("List"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire); $newmenu->add("/contact/list.php?leftmenu=suppliers&type=f",$langs->trans("Contacts"), 1, $user->rights->societe->contact->lire && $user->rights->fournisseur->lire); $newmenu->add("/fourn/stats.php",$langs->trans("Statistics"), 1, $user->rights->societe->lire && $user->rights->fournisseur->lire); } diff --git a/htdocs/fourn/list.php b/htdocs/fourn/list.php deleted file mode 100644 index 8fb33850919..00000000000 --- a/htdocs/fourn/list.php +++ /dev/null @@ -1,333 +0,0 @@ - - * Copyright (C) 2004-2015 Laurent Destailleur - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2011 Philippe Grand - * Copyright (C) 2013 Cédric Salvador - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2015 Florian Henry - * - * 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/fourn/list.php - * \ingroup fournisseur - * \brief Home page of supplier area - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; - -$langs->load("suppliers"); -$langs->load("orders"); -$langs->load("companies"); - -$socname = GETPOST("socname"); -$search_name = GETPOST("search_name"); -$search_zipcode = GETPOST("search_zipcode"); -$search_town = GETPOST("search_town"); -$search_supplier_code = GETPOST("search_supplier_code"); -$search_supplier_accounting = GETPOST("search_supplier_accounting"); -$search_datec = GETPOST("search_datec"); -$search_categ = GETPOST('search_categ','int'); -$search_status = GETPOST("search_status",'int'); -$catid = GETPOST("catid",'int'); -$search_country = GETPOST("search_country",'int'); -$search_type_thirdparty = GETPOST("search_type_thirdparty",'int'); -$optioncss = GETPOST('optioncss','alpha'); - -// Security check -$socid = GETPOST('socid','int'); -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user,'societe',$socid,''); - -$page = GETPOST('page','int'); -$sortorder = GETPOST('sortorder','alpha'); -$sortfield = GETPOST('sortfield','alpha'); -if ($page == -1) { $page = 0 ; } -$offset = $conf->liste_limit * $page ; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="nom"; - -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('supplierlist')); -$extrafields = new ExtraFields($db); - -if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers -{ - $socname=""; - $search_name=""; - $search_zipcode=""; - $search_town=""; - $search_supplier_code=""; - $search_supplier_accounting=""; - $search_datec=""; - $search_categ=""; - $search_status=''; - $catid=""; - $search_country=""; - $search_type_thirdparty=""; -} - -if ($search_status=='') $search_status=1; // always display activ customer first - -$extrafields->fetch_name_optionals_label('thirdparty'); - - -/* - * Actions - */ - -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - -/* - * View - */ - -$form=new Form($db); -$htmlother=new FormOther($db); -$thirdpartystatic=new Societe($db); -$formcompany=new FormCompany($db); - -$help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; -llxHeader('',$langs->trans("ThirdParty"),$help_url); - -$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias, s.zip, s.town, s.datec, st.libelle as stcomm, s.prefix_comm, s.status as status, "; -$sql.= "code_fournisseur, code_compta_fournisseur"; -$sql.= ",s.fk_pays"; -$sql.= ",typent.code as typent_code"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user "; -// Add fields for extrafields -foreach ($extrafields->attribute_list as $key => $val) $sql.=",ef.".$key.' as options_'.$key; -// Add fields from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListSelect',$parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_extrafields as ef ON ef.fk_object = s.rowid"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as country on (country.rowid = s.fk_pays) "; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_typent as typent on (typent.id = s.fk_typent) "; -if (! empty($search_categ) || ! empty($catid)) $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cf ON s.rowid = cf.fk_soc"; // We need this table joined to the select in order to filter by categ -$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= " WHERE s.fk_stcomm = st.id AND s.fournisseur = 1"; -$sql.= " AND s.entity IN (".getEntity('societe', 1).")"; -if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc"; -if ($socid) $sql .= " AND s.rowid = ".$socid; -if ($socname) { - $sql .= natural_search('s.nom', $socname); - $sortfield = "s.nom"; - $sortorder = "ASC"; -} -if ($search_name) $sql .= natural_search(array('s.nom', 's.name_alias'), $search_name); -if ($search_zipcode) $sql .= " AND s.zip LIKE '".$db->escape($search_zipcode)."%'"; -if ($search_town) $sql .= natural_search('s.town', $search_town); -if ($search_supplier_code) $sql .= " AND s.code_fournisseur LIKE '%".$db->escape($search_supplier_code)."%'"; -if ($search_supplier_accounting) $sql .= " AND s.code_compta_fournisseur LIKE '%".$db->escape($search_supplier_accounting)."%'"; -if ($search_datec) $sql .= " AND s.datec LIKE '%".$db->escape($search_datec)."%'"; -if ($search_status!='') $sql.= " AND s.status = ".$db->escape($search_status); -if ($catid > 0) $sql.= " AND cf.fk_categorie = ".$catid; -if ($catid == -2) $sql.= " AND cf.fk_categorie IS NULL"; -if ($search_categ > 0) $sql.= " AND cf.fk_categorie = ".$search_categ; -if ($search_categ == -2) $sql.= " AND cf.fk_categorie IS NULL"; -if ($search_country) $sql .= " AND s.fk_pays IN (".$search_country.')'; -if ($search_type_thirdparty) $sql .= " AND s.fk_typent IN (".$search_type_thirdparty.')'; -// Add where from hooks -$parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook -$sql.=$hookmanager->resPrint; - -// Count total nb of records -$nbtotalofrecords = 0; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); -} -$sql.= $db->order($sortfield,$sortorder); -$sql.= $db->plimit($conf->liste_limit+1, $offset); -//print $sql; - -dol_syslog('fourn/list.php:', LOG_DEBUG); -$resql = $db->query($sql); -if ($resql) -{ - $num = $db->num_rows($resql); - $i = 0; - - $param = "&search_name=".htmlspecialchars($search_name); - $param.="&search_supplier_code=".htmlspecialchars($search_supplier_code); - $param.="&search_zipcode=".htmlspecialchars($search_zipcode); - $param.="&search_town=".htmlspecialchars($search_town); - if ($search_categ != '') $param.='&search_categ='.htmlspecialchars($search_categ); - if ($search_status != '') $param.='&search_status='.htmlspecialchars($search_status); - if ($search_country != '') $param.='&search_country='.htmlspecialchars($search_country); - if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.htmlspecialchars($search_type_thirdparty); - if ($optioncss != '') $param.='&optioncss='.$optioncss; - - print_barre_liste($langs->trans("ListOfSuppliers"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies'); - - print '
'."\n"; - if ($optioncss != '') print ''; - - // Filter on categories - $moreforfilter=''; - if (! empty($conf->categorie->enabled)) - { - require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(Categorie::TYPE_SUPPLIER,$search_categ,'search_categ',1); - $moreforfilter.='
'; - } - if ($moreforfilter) - { - print '
'; - print $moreforfilter; - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - print '
'; - } - - print ''; - - print ''; - print_liste_field_titre($langs->trans("Company"),$_SERVER["PHP_SELF"],"s.nom","",$param,'valign="middle"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Zip"),$_SERVER["PHP_SELF"],"s.zip","",$param,'valign="middle"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Town"),$_SERVER["PHP_SELF"],"s.town","",$param,'valign="middle"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("Country"),$_SERVER["PHP_SELF"],"country.code_iso","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ThirdPartyType"),$_SERVER["PHP_SELF"],"typent.code","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("SupplierCode"),$_SERVER["PHP_SELF"],"s.code_fournisseur","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("AccountancyCode"),$_SERVER["PHP_SELF"],"s.code_compta_fournisseur","",$param,'align="left"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("DateCreation"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="right"',$sortfield,$sortorder); - - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); - print_liste_field_titre('',$_SERVER["PHP_SELF"],"",'','','',$sortfield,$sortorder,'maxwidthsearch '); - print "\n"; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldListSearch',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print ''; - - print '\n"; - - print ''; - - $var=True; - - while ($i < min($num,$conf->liste_limit)) - { - $obj = $db->fetch_object($resql); - $var=!$var; - - $thirdpartystatic->id=$obj->socid; - $thirdpartystatic->name=$obj->name; - $thirdpartystatic->status=$obj->status; - $thirdpartystatic->name_alias=$obj->name_alias; - - print ""; - print '\n"; - print ''."\n"; - print ''."\n"; - //Country - print ''; - //Type ent - print ''; - print ''; - print ''; - print ''; - - $parameters=array('obj' => $obj); - $reshook=$hookmanager->executeHooks('printFieldListValue',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - - print ''; - - print ''; - - print "\n"; - $i++; - } - print "
'; - print $form->select_country($search_country,'search_country','',0,'maxwidth100'); - print ''; - print $form->selectarray("search_type_thirdparty", $formcompany->typent_array(0), $search_type_thirdparty, 0, 0, 0, '', 0, 0, 0, (empty($conf->global->SOCIETE_SORT_ON_TYPEENT)?'ASC':$conf->global->SOCIETE_SORT_ON_TYPEENT)); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); - print ''; - print ''; - print "
'; - print $thirdpartystatic->getNomUrl(1,'supplier'); - print "'.$obj->zip.''.$obj->town.''; - $tmparray=getCountry($obj->fk_pays,'all'); - print $tmparray['label']; - print ''; - if (count($typenArray)==0) $typenArray = $formcompany->typent_array(1); - print $typenArray[$obj->typent_code]; - print ''.$obj->code_fournisseur.' '.$obj->code_compta_fournisseur.' '.dol_print_date($db->jdate($obj->datec),'day').''.$thirdpartystatic->getLibStatut(3).'
\n"; - print "
\n"; - $db->free($resql); - - $parameters=array('sql' => $sql); - $reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; -} -else -{ - dol_print_error($db); -} - -$db->close(); - -llxFooter(); diff --git a/htdocs/index.php b/htdocs/index.php index ef87f437084..2e1d019d2e7 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -233,7 +233,7 @@ if (empty($user->societe_id)) // Dashboard Link lines $links=array(DOL_URL_ROOT.'/comm/list.php', DOL_URL_ROOT.'/comm/prospect/list.php', - DOL_URL_ROOT.'/fourn/list.php', + DOL_URL_ROOT.'/societe/list.php?type=f', DOL_URL_ROOT.'/adherents/list.php?statut=1&mainmenu=members', DOL_URL_ROOT.'/product/list.php?type=0&mainmenu=products', DOL_URL_ROOT.'/product/list.php?type=1&mainmenu=products', diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index d27d6891119..86de804c6a1 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -155,7 +155,7 @@ else if (! empty($conf->fournisseur->enabled) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) { $statstring2 = ""; - $statstring2.= ''.$langs->trans("Suppliers").''.round($third['supplier']).''; + $statstring2.= ''.$langs->trans("Suppliers").''.round($third['supplier']).''; $statstring2.= ""; } print $statstring; diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index f251274b3ad..19301efd6e0 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -57,13 +57,15 @@ $search_idprof3=trim(GETPOST('search_idprof3')); $search_idprof4=trim(GETPOST('search_idprof4')); $search_idprof5=trim(GETPOST('search_idprof5')); $search_idprof6=trim(GETPOST('search_idprof6')); -$search_sale=trim(GETPOST("search_sale")); -$search_categ=trim(GETPOST("search_categ")); +$search_sale=trim(GETPOST("search_sale",'int')); +$search_categ=trim(GETPOST("search_categ",'int')); $search_type=trim(GETPOST('search_type')); $search_country=GETPOST("search_country",'int'); $search_type_thirdparty=GETPOST("search_type_thirdparty",'int'); +$search_type=GETPOST('search_type','alpha'); $search_status=GETPOST("search_status",'int'); +$type=GETPOST('type'); $optioncss=GETPOST('optioncss','alpha'); $mode=GETPOST("mode"); @@ -79,6 +81,15 @@ $pagenext = $page + 1; // Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $contextpage='thirdpartylist'; +/*if ($search_type == '1,3') { $contextpage='customerlist'; $type='c'; } +if ($search_type == '2,3') { $contextpage='prospectlist'; $type='p'; } +if ($search_type == '4') { $contextpage='supplierlist'; $type='f'; } +*/ +if ($type == 'c') { $contextpage='customerlist'; if ($search_type=='') $search_type='1,3'; } +if ($type == 'p') { $contextpage='prospectlist'; if ($search_type=='') $search_type='2,3'; } +if ($type == 'f') { $contextpage='supplierlist'; if ($search_type=='') $search_type='4'; } + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array($contextpage)); $extrafields = new ExtraFields($db); @@ -109,10 +120,14 @@ if (!empty($conf->barcode->enabled)) $fieldstosearchall['s.barcode']='Gencod'; * Actions */ +$parameters=array(); +$reshook=$hookmanager->executeHooks('doActions',$parameters); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // special search -if ($mode == 'search') +/*if ($mode == 'search') { $sql = "SELECT s.rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -159,7 +174,7 @@ if ($mode == 'search') $db->free($result); } } - +*/ /* @@ -167,7 +182,7 @@ if ($mode == 'search') */ $form=new Form($db); -$htmlother=new FormOther($db); +$formother=new FormOther($db); $companystatic=new Societe($db); $formcompany=new FormCompany($db); @@ -216,6 +231,9 @@ if ($search_status=='') $search_status=1; // always display active thirdparty fi External user socid=x + No permission to see ALL customers => Can see only himself */ $title=$langs->trans("ListOfThirdParties"); +if ($type == 'c' && (empty($search_type) || ($search_type == '1,3'))) $title=$langs->trans("ListOfCustomers"); +if ($type == 'p' && (empty($search_type) || ($search_type == '2,3'))) $title=$langs->trans("ListOfProspects"); +if ($type == 'f' && (empty($search_type) || ($search_type == '4'))) $title=$langs->trans("ListOfSuppliers"); $sql = "SELECT s.rowid, s.nom as name, s.barcode, s.town, s.zip, s.datec, s.code_client, s.code_fournisseur, "; $sql.= " st.libelle as stcomm, s.prefix_comm, s.client, s.fournisseur, s.canvas, s.status as status,"; @@ -308,29 +326,35 @@ if ($resql) $num = $db->num_rows($resql); $i = 0; - $param = "&sall=".urlencode($sall); - $param.= "&search_nom=".urlencode($search_nom); - $param.= "&search_town=".urlencode($search_town); - $param.= "&search_zip=".urlencode($search_zip); - $param.= "&search_customer_code=".urlencode($search_customer_code); - $param.= "&search_supplier_code=".urlencode($search_supplier_code); - $param.= "&search_account_customer_code=".urlencode($search_account_customer_code); - $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code); - $param.= ($search_barcode?"&sbarcode=".urlencode($search_barcode):""); - $param.= '&search_idprof1='.urlencode($search_idprof1); - $param.= '&search_idprof2='.urlencode($search_idprof2); - $param.= '&search_idprof3='.urlencode($search_idprof3); - $param.= '&search_idprof4='.urlencode($search_idprof4); + if ($sall != '') $param = "&sall=".urlencode($sall); + if ($search_categ != '') $param.='&search_categ='.urlencode($search_categ); + if ($search_sale > 0) $param.='&search_sale='.urlencode($search_sale); + if ($search_nom != '') $param.= "&search_nom=".urlencode($search_nom); + if ($search_town != '') $param.= "&search_town=".urlencode($search_town); + if ($search_zip != '') $param.= "&search_zip=".urlencode($search_zip); + if ($search_country != '') $param.= "&search_country=".urlencode($search_country); + if ($search_customer_code != '') $param.= "&search_customer_code=".urlencode($search_customer_code); + if ($search_supplier_code != '') $param.= "&search_supplier_code=".urlencode($search_supplier_code); + if ($search_account_customer_code != '') $param.= "&search_account_customer_code=".urlencode($search_account_customer_code); + if ($search_account_supplier_code != '') $param.= "&search_account_supplier_code=".urlencode($search_account_supplier_code); + if ($search_barcode != '') $param.= "&sbarcode=".urlencode($search_barcode); + if ($search_idprof1 != '') $param.= '&search_idprof1='.urlencode($search_idprof1); + if ($search_idprof2 != '') $param.= '&search_idprof2='.urlencode($search_idprof2); + if ($search_idprof3 != '') $param.= '&search_idprof3='.urlencode($search_idprof3); + if ($search_idprof4 != '') $param.= '&search_idprof4='.urlencode($search_idprof4); + if ($search_idprof5 != '') $param.= '&search_idprof5='.urlencode($search_idprof5); + if ($search_idprof6 != '') $param.= '&search_idprof6='.urlencode($search_idprof6); if ($search_country != '') $param.='&search_country='.urlencode($search_country); if ($search_type_thirdparty != '') $param.='&search_type_thirdparty='.urlencode($search_type_thirdparty); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); - if ($search_status != '') $params.='&search_status='.urlencode($search_status); + if ($search_status != '') $param.='&search_status='.urlencode($search_status); + if ($type != '') $param.='&type='.urlencode($type); // Add $param from extra fields foreach ($search_array_options as $key => $val) { $crit=$val; $tmpkey=preg_replace('/search_options_/','',$key); - $param.='&search_options_'.$tmpkey.'='.urlencode($val); + if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val); } print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_companies'); @@ -368,39 +392,59 @@ if ($resql) } // Filter on categories - /* Not possible in this page because list is for ALL third parties type $moreforfilter=''; - if (! empty($conf->categorie->enabled)) - { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('Categories'). ': '; - $moreforfilter.=$htmlother->select_categories(Categories::TYPE_CUSTOMER,$search_categ,'search_categ'); - $moreforfilter.='
'; - } - // If the user can view prospects other than his' - if ($user->rights->societe->client->voir || $socid) - { - $moreforfilter.='
'; - $moreforfilter.=$langs->trans('SalesRepresentatives'). ': '; - $moreforfilter.=$htmlother->select_salesrepresentatives($search_sale,'search_sale',$user); - $moreforfilter.='
'; - } - */ + if ($type == 'c' || $type == 'p') + { + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$formother->select_categories(Categorie::TYPE_CUSTOMER,$search_categ,'search_categ',1); + $moreforfilter.='
'; + } + // If the user can view prospects other than his' + if ($user->rights->societe->client->voir || $socid) + { + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('SalesRepresentatives'). ': '; + $moreforfilter.=$formother->select_salesrepresentatives($search_sale,'search_sale',$user); + $moreforfilter.='
'; + } + } + if ($type == 'f') + { + if (! empty($conf->categorie->enabled)) + { + require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php'; + $moreforfilter.='
'; + $moreforfilter.=$langs->trans('Categories'). ': '; + $moreforfilter.=$formother->select_categories(Categorie::TYPE_SUPPLIER,$search_categ,'search_categ',1); + $moreforfilter.='
'; + } + } if (! empty($moreforfilter)) { print '
'; print $moreforfilter; - $parameters=array(); + $parameters=array('type'=>$type); $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; print '
'; } // Define list of fields to show into list - $checkedcustomercode=1; - $checkedsuppliercode=1; - $checkedcustomeraccountcode=0; - $checkedsupplieraccountcode=0; + $checkedcustomercode=(in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist')) ? 1 : 0); + $checkedsuppliercode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); + $checkedcustomeraccountcode=(in_array($contextpage, array('thirdpartylist', 'customerlist', 'prospectlist')) ? 1 : 0); + $checkedsupplieraccountcode=(in_array($contextpage, array('supplierlist')) ? 1 : 0); + $checkedtypetiers=1; + $checkedprofid4=0; + $checkedprofid5=0; + $checkedprofid6=0; + //$checkedprofid4=((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0); + //$checkedprofid5=((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0); + //$checkedprofid6=((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0); $arrayfields=array( 's.nom'=>array('label'=>$langs->trans("Company"), 'checked'=>1), 's.barcode'=>array('label'=>$langs->trans("Gencod"), 'checked'=>1, 'enabled'=>(! empty($conf->barcode->enabled))), @@ -411,19 +455,19 @@ if ($resql) 's.town'=>array('label'=>$langs->trans("Town"), 'checked'=>1), 's.zip'=>array('label'=>$langs->trans("Zip"), 'checked'=>1), 'country.code_iso'=>array('label'=>$langs->trans("Country"), 'checked'=>0), - 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>1), + 'typent.code'=>array('label'=>$langs->trans("ThirdPartyType"), 'checked'=>$checkedtypetiers), 's.siren'=>array('label'=>$langs->trans("ProfId1Short"), 'checked'=>1), 's.siret'=>array('label'=>$langs->trans("ProfId2Short"), 'checked'=>1), 's.ape'=>array('label'=>$langs->trans("ProfId3Short"), 'checked'=>1), - 's.idprof4'=>array('label'=>$langs->trans("ProfId4Short"), 'checked'=>((($tmp = $langs->transnoentities("ProfId4".$mysoc->country_code)) && $tmp != "ProfId4".$mysoc->country_code && $tmp != '-') ? 1 : 0)), - 's.idprof5'=>array('label'=>$langs->trans("ProfId5Short"), 'checked'=>((($tmp = $langs->transnoentities("ProfId5".$mysoc->country_code)) && $tmp != "ProfId5".$mysoc->country_code && $tmp != '-') ? 1 : 0)), - 's.idprof6'=>array('label'=>$langs->trans("ProfId6Short"), 'checked'=>((($tmp = $langs->transnoentities("ProfId6".$mysoc->country_code)) && $tmp != "ProfId6".$mysoc->country_code && $tmp != '-') ? 1 : 0)), + 's.idprof4'=>array('label'=>$langs->trans("ProfId4Short"), 'checked'=>$checkedprofid4), + 's.idprof5'=>array('label'=>$langs->trans("ProfId5Short"), 'checked'=>$checkedprofid5), + 's.idprof6'=>array('label'=>$langs->trans("ProfId6Short"), 'checked'=>$checkedprofid6), 's.status'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>200), 's.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500), 's.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500), ); $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; - $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); + $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields print ''; print ''; @@ -459,7 +503,7 @@ if ($resql) $parameters=array('arrayfields'=>$arrayfields); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['s.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"s.status","",$param,'align="center"',$sortfield,$sortorder); if (! empty($arrayfields['s.datec']['checked'])) print_liste_field_titre($langs->trans("DateCreationShort"),$_SERVER["PHP_SELF"],"s.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); if (! empty($arrayfields['s.tms']['checked'])) print_liste_field_titre($langs->trans("DateModificationShort"),$_SERVER["PHP_SELF"],"s.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="right"',$sortfield,$sortorder,'maxwidthsearch '); @@ -596,7 +640,7 @@ if ($resql) if (! empty($arrayfields['s.status']['checked'])) { // Status - print ''; } @@ -614,6 +658,7 @@ if ($resql) } // Action column print ''; @@ -744,7 +789,7 @@ if ($resql) // Status if (! empty($arrayfields['s.status']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['s.datec']['checked'])) { @@ -786,4 +831,3 @@ else llxFooter(); $db->close(); - diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index cbdaf1afc10..45ca3a5b728 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -1146,7 +1146,10 @@ div.vmenu, td.vmenu { } -.menu_contenu { padding-top: 3px; padding-top: 2px; } +.menu_contenu { + padding-top: 3px; + padding-bottom: 2px; +} #menu_contenu_logo { padding-right: 4px; } a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active { font-size:px; font-family: ; text-align: ; font-weight: bold; } From 4453ba53fde29d09fbb3f3bf108d450c2fda8530 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Oct 2015 10:28:59 +0200 Subject: [PATCH 50/54] Fix migration error --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 8 ++++---- htdocs/install/mysql/tables/llx_ecm_directories.key.sql | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 33593e7fac5..d6378a06c6d 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -69,7 +69,7 @@ ALTER TABLE llx_societe_rib MODIFY COLUMN code_banque varchar(128); ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30); -ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(1000); +ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750); CREATE TABLE llx_ecm_files ( @@ -77,8 +77,8 @@ CREATE TABLE llx_ecm_files label varchar(64) NOT NULL, entity integer DEFAULT 1 NOT NULL, -- multi company id filename varchar(255) NOT NULL, -- file name only without any directory - fullpath varchar(750) NOT NULL, -- relative to dolibarr document dir. example abc/def/myfile - fullpath_orig varchar(750), -- full path of original filename, when file is uploaded from a local computer + fullpath varchar(750) NOT NULL, -- relative to dolibarr document dir. example abc/def/myfile. restricted to 750 because of unique key index on it. + fullpath_orig varchar(2048), -- full path of original filename, when file is uploaded from a local computer description text, keywords text, -- list of keywords, separated with comma cover text, -- is this file a file to use for a cover @@ -90,8 +90,8 @@ CREATE TABLE llx_ecm_files acl text -- for future permission 'per file' ) ENGINE=innodb; -ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(1000); +ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories_fullpath(fullpath); ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); diff --git a/htdocs/install/mysql/tables/llx_ecm_directories.key.sql b/htdocs/install/mysql/tables/llx_ecm_directories.key.sql index 2da97ec974f..d11985e3be5 100644 --- a/htdocs/install/mysql/tables/llx_ecm_directories.key.sql +++ b/htdocs/install/mysql/tables/llx_ecm_directories.key.sql @@ -19,6 +19,7 @@ ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX idx_ecm_directories (label, fk_parent, entity); +ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories_fullpath(fullpath); ALTER TABLE llx_ecm_directories ADD INDEX idx_ecm_directories_fk_user_c (fk_user_c); ALTER TABLE llx_ecm_directories ADD INDEX idx_ecm_directories_fk_user_m (fk_user_m); From 40adaf716d192607ab1843b9c2802415c02ac75f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Oct 2015 10:33:42 +0200 Subject: [PATCH 51/54] Uniformize index names --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 8 ++++++-- htdocs/install/mysql/tables/llx_ecm_files.key.sql | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index d6378a06c6d..b97c9a99fe9 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -71,6 +71,11 @@ ALTER TABLE llx_contrat ADD COLUMN ref_customer varchar(30); ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750); +ALTER TABLE llx_ecm_directories DROP INDEX idx_ecm_directories; +ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories (label, fk_parent, entity); +ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories_fullpath(fullpath); + + CREATE TABLE llx_ecm_files ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -90,8 +95,7 @@ CREATE TABLE llx_ecm_files acl text -- for future permission 'per file' ) ENGINE=innodb; - -ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories_fullpath(fullpath); +ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (label, entity); ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); diff --git a/htdocs/install/mysql/tables/llx_ecm_files.key.sql b/htdocs/install/mysql/tables/llx_ecm_files.key.sql index b689bf0b0fb..81cc769d6cd 100644 --- a/htdocs/install/mysql/tables/llx_ecm_files.key.sql +++ b/htdocs/install/mysql/tables/llx_ecm_files.key.sql @@ -17,4 +17,5 @@ -- ============================================================================ +ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (label, entity); ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); From 9cbb9129c2c253d124b28080d24591426e83cebb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Oct 2015 12:29:24 +0200 Subject: [PATCH 52/54] FIX #3772 --- htdocs/install/mysql/migration/3.8.0-3.9.0.sql | 4 ++-- htdocs/install/mysql/tables/llx_ecm_directories.key.sql | 4 ++-- htdocs/install/mysql/tables/llx_ecm_files.key.sql | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index b97c9a99fe9..9bc9d7b8677 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -73,7 +73,7 @@ ALTER TABLE llx_ecm_directories MODIFY COLUMN fullpath varchar(750); ALTER TABLE llx_ecm_directories DROP INDEX idx_ecm_directories; ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories (label, fk_parent, entity); -ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories_fullpath(fullpath); +--ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories_fullpath(fullpath); CREATE TABLE llx_ecm_files @@ -96,7 +96,7 @@ CREATE TABLE llx_ecm_files ) ENGINE=innodb; ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (label, entity); -ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); +--ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); ALTER TABLE llx_product ADD COLUMN onportal tinyint DEFAULT 0 after tobuy; diff --git a/htdocs/install/mysql/tables/llx_ecm_directories.key.sql b/htdocs/install/mysql/tables/llx_ecm_directories.key.sql index d11985e3be5..2e96a5f8e95 100644 --- a/htdocs/install/mysql/tables/llx_ecm_directories.key.sql +++ b/htdocs/install/mysql/tables/llx_ecm_directories.key.sql @@ -18,8 +18,8 @@ -- ============================================================================ -ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX idx_ecm_directories (label, fk_parent, entity); -ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories_fullpath(fullpath); +ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories (label, fk_parent, entity); +--ALTER TABLE llx_ecm_directories ADD UNIQUE INDEX uk_ecm_directories_fullpath(fullpath); Disabled, mysql limits size of index ALTER TABLE llx_ecm_directories ADD INDEX idx_ecm_directories_fk_user_c (fk_user_c); ALTER TABLE llx_ecm_directories ADD INDEX idx_ecm_directories_fk_user_m (fk_user_m); diff --git a/htdocs/install/mysql/tables/llx_ecm_files.key.sql b/htdocs/install/mysql/tables/llx_ecm_files.key.sql index 81cc769d6cd..9b1f4fcf164 100644 --- a/htdocs/install/mysql/tables/llx_ecm_files.key.sql +++ b/htdocs/install/mysql/tables/llx_ecm_files.key.sql @@ -18,4 +18,4 @@ ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files (label, entity); -ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); +--ALTER TABLE llx_ecm_files ADD UNIQUE INDEX uk_ecm_files_fullpath(fullpath); Disabled, mysql limits size of index From 2615e02e1ee2318f42f38a703116a9bc091abe92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Oct 2015 13:18:51 +0200 Subject: [PATCH 53/54] Update doc --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 0e7f74b32f7..4cfc077f0be 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -74,7 +74,7 @@ function dol_decode($chain) * If constant MAIN_SECURITY_SALT is defined, we use it as a salt. * * @param string $chain String to hash - * @param int $type Type of hash (0:auto, 1:sha1, 2:sha1+md5, 3:md5) + * @param int $type Type of hash (0:auto, 1:sha1, 2:sha1+md5, 3:md5). Use 3 here, if hash is not needed for security purpose, for security need, prefer 0. * @return string Hash of string */ function dol_hash($chain,$type=0) From 77c43ebb26f279a1ad49e1b85269b57e940de215 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 22 Oct 2015 14:05:16 +0200 Subject: [PATCH 54/54] FIX #3558 --- htdocs/main.inc.php | 2 +- htdocs/user/class/user.class.php | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index f563961ba29..3a573b23f4d 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -515,7 +515,7 @@ if (! defined('NOLOGIN')) exit; } - $resultFetchUser=$user->fetch('',$login); + $resultFetchUser=$user->fetch('', $login, '', 0, ($entitytotest ? $entitytotest : -1); if ($resultFetchUser <= 0) { dol_syslog('User not found, connexion refused'); diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index afdc1fdaecd..fdc3b8577cd 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -146,9 +146,10 @@ class User extends CommonObject * @param string $login Si defini, login a utiliser pour recherche * @param string $sid Si defini, sid a utiliser pour recherche * @param int $loadpersonalconf Also load personal conf of user (in $user->conf->xxx) + * @param int $entity If a value is >= 0, we force the search on a specific entity. If -1, means search depens on default setup. * @return int <0 if KO, 0 not found, >0 if OK */ - function fetch($id='', $login='',$sid='',$loadpersonalconf=1) + function fetch($id='', $login='',$sid='',$loadpersonalconf=1, $entity=-1) { global $conf, $user; @@ -177,15 +178,22 @@ class User extends CommonObject $sql.= " u.ref_int, u.ref_ext"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u"; - if ((empty($conf->multicompany->enabled) || empty($conf->multicompany->transverse_mode)) && (! empty($user->entity))) + if ($entity < 0) { - $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + if ((empty($conf->multicompany->enabled) || empty($conf->multicompany->transverse_mode)) && (! empty($user->entity))) + { + $sql.= " WHERE u.entity IN (0,".$conf->entity.")"; + } + else + { + $sql.= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database + } } - else + else // The fetch was forced on an entity { - $sql.= " WHERE u.entity IS NOT NULL"; + $sql.= " WHERE u.entity IN (0, ".$conf->entity.")"; } - + if ($sid) // permet une recherche du user par son SID ActiveDirectory ou Samba { $sql.= " AND (u.ldap_sid = '".$this->db->escape($sid)."' OR u.login = '".$this->db->escape($login)."') LIMIT 1";
'; + print ''; print $form->selectarray('search_status', array('0'=>$langs->trans('ActivityCeased'),'1'=>$langs->trans('InActivity')),$search_status); print ''; + if ($type != '') print ''; print ''; print ''; print ''.$companystatic->getLibStatut(5).''.$companystatic->getLibStatut(3).'