From 01ba32efbcc5d1db25f218279b8f077fd17bea2d Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Mon, 4 Feb 2019 17:52:15 +0100 Subject: [PATCH 01/40] Update main.inc.php Set current modulepart --- htdocs/main.inc.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2f5e53ecbf5..4e585cc6778 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -421,6 +421,19 @@ if (! empty($_SESSION["disablemodules"])) } } +// Set current modulepart +$modulepart = explode("/",$_SERVER["PHP_SELF"]); +if(is_array($modulepart) && count($modulepart)>0) +{ + foreach($conf->modules as $module) + { + if(in_array($module, $modulepart)) + { + $conf->modulepart=$module; + } + } +} + /* * Phase authentication / login */ From f1ffae3ac5524037fdd20d61623db9029253d032 Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Mon, 4 Feb 2019 18:27:47 +0100 Subject: [PATCH 02/40] Update main.inc.php fix travis --- htdocs/main.inc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 4e585cc6778..34480729623 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -422,14 +422,14 @@ if (! empty($_SESSION["disablemodules"])) } // Set current modulepart -$modulepart = explode("/",$_SERVER["PHP_SELF"]); +$modulepart = explode("/", $_SERVER["PHP_SELF"]); if(is_array($modulepart) && count($modulepart)>0) { foreach($conf->modules as $module) { if(in_array($module, $modulepart)) { - $conf->modulepart=$module; + $conf->modulepart = $module; } } } From 828e561c86e31b865d292c790f97667e6aed5c40 Mon Sep 17 00:00:00 2001 From: Laurent De Coninck Date: Tue, 12 Feb 2019 15:09:55 +0100 Subject: [PATCH 03/40] fix the ref vs facnumber --- htdocs/accountancy/journal/purchasesjournal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index caaf0b24d37..7c5a567cbf2 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -93,7 +93,7 @@ if (! GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end) $idpays = $mysoc->country_id; -$sql = "SELECT f.rowid, f.facnumber as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, f.close_code,"; +$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlf, f.close_code,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code,"; $sql .= " s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,"; $sql .= " p.accountancy_code_buy , aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte"; From f311d5020185130c255403261e353b0876e20976 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 15:43:24 +0100 Subject: [PATCH 04/40] Fix unique key in accounting_account Conflicts: htdocs/install/mysql/migration/8.0.0-9.0.0.sql --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 9b97f7c1918..f2a8ca9f380 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -260,3 +260,12 @@ CREATE TABLE llx_pos_cash_fence( -- VMYSQL4.3 ALTER TABLE llx_accounting_account MODIFY COLUMN account_number varchar(32) NOT NULL; -- VPGSQL8.2 ALTER TABLE llx_accounting_account ALTER COLUMN account_number SET NOT NULL; + + +-- Withdrawals / Prelevements +UPDATE llx_const set name = 'PRELEVEMENT_END_TO_END' where name = 'END_TO_END'; +UPDATE llx_const set name = 'PRELEVEMENT_USTRD' where name = 'USTRD'; + + +ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; +ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version); From 5b5f96bafb6ca31e8c15c0a2aa023c51c8860404 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 12 Feb 2019 16:58:11 +0100 Subject: [PATCH 05/40] NEW : measuring unit dictionnary and product size/unit import --- htdocs/admin/dict.php | 19 ++- htdocs/core/lib/product.lib.php | 55 ++----- .../modules/import/import_csv.modules.php | 37 +++++ .../modules/import/import_xlsx.modules.php | 37 +++++ htdocs/core/modules/modProduct.class.php | 89 ++++++++++- .../install/mysql/migration/9.0.0-10.0.0.sql | 139 +++++++++++++++++- htdocs/langs/en_US/admin.lang | 1 + htdocs/langs/en_US/products.lang | 1 + .../product/class/html.formproduct.class.php | 20 ++- 9 files changed, 342 insertions(+), 56 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 2a4ee7c7bd6..4eef174c191 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -88,7 +88,7 @@ $hookmanager->initHooks(array('admin')); // Put here declaration of dictionaries properties // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this. -$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,0,25,0); +$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,24,28,17,35,36,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,26,37,0,25,0); // Name of SQL tables of dictionaries $tabname=array(); @@ -128,6 +128,7 @@ $tabname[33]= MAIN_DB_PREFIX."c_hrm_department"; $tabname[34]= MAIN_DB_PREFIX."c_hrm_function"; $tabname[35]= MAIN_DB_PREFIX."c_exp_tax_cat"; $tabname[36]= MAIN_DB_PREFIX."c_exp_tax_range"; +$tabname[37]= MAIN_DB_PREFIX."c_measuring_units"; // Dictionary labels $tablib=array(); @@ -167,6 +168,7 @@ $tablib[33]= "DictionaryDepartment"; $tablib[34]= "DictionaryFunction"; $tablib[35]= "DictionaryExpenseTaxCat"; $tablib[36]= "DictionaryExpenseTaxRange"; +$tablib[37]= "DictionaryMeasuringUnits"; // Requests to extract data $tabsql=array(); @@ -206,6 +208,7 @@ $tabsql[33]= "SELECT rowid, pos, code, label, active FROM ".MAIN_DB_PREFIX."c_hr $tabsql[34]= "SELECT rowid, pos, code, label, c_level, active FROM ".MAIN_DB_PREFIX."c_hrm_function"; $tabsql[35]= "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_cat c"; $tabsql[36]= "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r"; +$tabsql[37]= "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.active FROM ".MAIN_DB_PREFIX."c_measuring_units r"; // Criteria to sort dictionaries $tabsqlsort=array(); @@ -245,6 +248,7 @@ $tabsqlsort[33]="code ASC"; $tabsqlsort[34]="code ASC"; $tabsqlsort[35]="c.label ASC"; $tabsqlsort[36]="r.fk_c_exp_tax_cat ASC, r.range_ik ASC"; +$tabsqlsort[37]="r.unit_type ASC, r.code ASC"; // Nom des champs en resultat de select pour affichage du dictionnaire $tabfield=array(); @@ -284,6 +288,7 @@ $tabfield[33]= "code,label"; $tabfield[34]= "code,label"; $tabfield[35]= "label"; $tabfield[36]= "range_ik,fk_c_exp_tax_cat"; +$tabfield[37]= "code,label,short_label,unit_type"; // Nom des champs d'edition pour modification d'un enregistrement $tabfieldvalue=array(); @@ -323,6 +328,7 @@ $tabfieldvalue[33]= "code,label"; $tabfieldvalue[34]= "code,label"; $tabfieldvalue[35]= "label"; $tabfieldvalue[36]= "range_ik,fk_c_exp_tax_cat"; +$tabfieldvalue[37]= "code,label,short_label,unit_type"; // Nom des champs dans la table pour insertion d'un enregistrement $tabfieldinsert=array(); @@ -362,6 +368,7 @@ $tabfieldinsert[33]= "code,label"; $tabfieldinsert[34]= "code,label"; $tabfieldinsert[35]= "label"; $tabfieldinsert[36]= "range_ik,fk_c_exp_tax_cat"; +$tabfieldinsert[37]= "code,label,short_label,unit_type"; // Nom du rowid si le champ n'est pas de type autoincrement // Example: "" if id field is "rowid" and has autoincrement on @@ -403,6 +410,7 @@ $tabrowid[33]= "rowid"; $tabrowid[34]= "rowid"; $tabrowid[35]= ""; $tabrowid[36]= ""; +$tabrowid[37]= ""; // Condition to show dictionary in setup page $tabcond=array(); @@ -442,6 +450,7 @@ $tabcond[33]= ! empty($conf->hrm->enabled); $tabcond[34]= ! empty($conf->hrm->enabled); $tabcond[35]= ! empty($conf->expensereport->enabled); $tabcond[36]= ! empty($conf->expensereport->enabled); +$tabcond[37]= ! empty($conf->product->enabled); // List of help for fields $tabhelp=array(); @@ -481,6 +490,7 @@ $tabhelp[33] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[34] = array('code'=>$langs->trans("EnterAnyCode")); $tabhelp[35]= array(); $tabhelp[36]= array('range_ik'=>$langs->trans('PrevRangeToThisRange')); +$tabhelp[37]= array('short_label'=>$langs->trans("EnterAnyCode")); // List of check for fields (NOT USED YET) $tabfieldcheck=array(); @@ -520,6 +530,7 @@ $tabfieldcheck[33] = array(); $tabfieldcheck[34] = array(); $tabfieldcheck[35]= array(); $tabfieldcheck[36]= array(); +$tabfieldcheck[37]= array(); // Complete all arrays with entries found into modules complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck); @@ -1583,6 +1594,12 @@ if ($id) { $valuetoshow = $langs->trans($valuetoshow); } + elseif ($fieldlist[$field] == 'label' && $tabname[$id] == MAIN_DB_PREFIX.'c_measuring_units') + { + $langs->load('other'); + $key = $langs->trans($obj->label); + $valuetoshow = ($obj->label && $key != strtoupper($obj->label) ? $key : $obj->{$fieldlist[$field]}); + } $class='tddict'; if ($fieldlist[$field] == 'note' && $id == 10) $class.=' tdoverflowmax200'; diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 4baba0bc197..10107b37a01 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -472,50 +472,19 @@ function show_stats_for_company($product, $socid) */ function measuring_units_string($unit, $measuring_style = '') { - global $langs; - - $measuring_units=array(); - if ($measuring_style == 'weight') - { - $measuring_units[3] = $langs->transnoentitiesnoconv("WeightUnitton"); - $measuring_units[0] = $langs->transnoentitiesnoconv("WeightUnitkg"); - $measuring_units[-3] = $langs->transnoentitiesnoconv("WeightUnitg"); - $measuring_units[-6] = $langs->transnoentitiesnoconv("WeightUnitmg"); - $measuring_units[98] = $langs->transnoentitiesnoconv("WeightUnitounce"); - $measuring_units[99] = $langs->transnoentitiesnoconv("WeightUnitpound"); + global $langs, $db; + require_once DOL_DOCUMENT_ROOT.'/core/class/cmeasuringunits.class.php'; + $measuringUnits= new CMeasuringUnits($db); + $result=$measuringUnits->fetchAll('','', 0, 0, array('t.code'=> $unit,'t.unit_type'=>$measuring_style,'t.active'=>1)); + if ($result<0) { + return -1; + } else { + if (is_array($measuringUnits->records) && count($measuringUnits->records)>0) { + return $langs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label); + } else { + return ''; + } } - elseif ($measuring_style == 'size') - { - $measuring_units[0] = $langs->transnoentitiesnoconv("SizeUnitm"); - $measuring_units[-1] = $langs->transnoentitiesnoconv("SizeUnitdm"); - $measuring_units[-2] = $langs->transnoentitiesnoconv("SizeUnitcm"); - $measuring_units[-3] = $langs->transnoentitiesnoconv("SizeUnitmm"); - $measuring_units[98] = $langs->transnoentitiesnoconv("SizeUnitfoot"); - $measuring_units[99] = $langs->transnoentitiesnoconv("SizeUnitinch"); - } - elseif ($measuring_style == 'surface') - { - $measuring_units[0] = $langs->transnoentitiesnoconv("SurfaceUnitm2"); - $measuring_units[-2] = $langs->transnoentitiesnoconv("SurfaceUnitdm2"); - $measuring_units[-4] = $langs->transnoentitiesnoconv("SurfaceUnitcm2"); - $measuring_units[-6] = $langs->transnoentitiesnoconv("SurfaceUnitmm2"); - $measuring_units[98] = $langs->transnoentitiesnoconv("SurfaceUnitfoot2"); - $measuring_units[99] = $langs->transnoentitiesnoconv("SurfaceUnitinch2"); - } - elseif ($measuring_style == 'volume') - { - $measuring_units[0] = $langs->transnoentitiesnoconv("VolumeUnitm3"); - $measuring_units[-3] = $langs->transnoentitiesnoconv("VolumeUnitdm3"); - $measuring_units[-6] = $langs->transnoentitiesnoconv("VolumeUnitcm3"); - $measuring_units[-9] = $langs->transnoentitiesnoconv("VolumeUnitmm3"); - $measuring_units[88] = $langs->transnoentitiesnoconv("VolumeUnitfoot3"); - $measuring_units[89] = $langs->transnoentitiesnoconv("VolumeUnitinch3"); - $measuring_units[97] = $langs->transnoentitiesnoconv("VolumeUnitounce"); - $measuring_units[98] = $langs->transnoentitiesnoconv("VolumeUnitlitre"); - $measuring_units[99] = $langs->transnoentitiesnoconv("VolumeUnitgallon"); - } - - return $measuring_units[$unit]; } /** diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index 7d32da52f54..17b6e556908 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -471,6 +471,43 @@ class ImportCsv extends ModeleImports { if (empty($newval)) $newval='0'; } + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') + { + $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); + $class=$objimport->array_import_convertvalue[0][$val]['class']; + $method=$objimport->array_import_convertvalue[0][$val]['method']; + $units=$objimport->array_import_convertvalue[0][$val]['units']; + if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] != '') + { + $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]; + } + else + { + $resultload = dol_include_once($file); + if (empty($resultload)) + { + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units); + break; + } + $classinstance=new $class($this->db); + // Try the fetch from code or ref + call_user_func_array(array($classinstance, $method), array('', $units, $newval)); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; + //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; + if ($classinstance->code != '') // id may be 0, it is a found value + { + $newval=$classinstance->code; + } + else + { + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; + $this->errors[$error]['type']='FOREIGNKEY'; + $errorforthistable++; + $error++; + } + } + } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') { if (strtolower($newval) == 'auto') diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index da5e227f550..3cdd100068e 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -498,6 +498,43 @@ class ImportXlsx extends ModeleImports { if (empty($newval)) $newval='0'; } + elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='fetchidfromcodeunits') + { + $file=(empty($objimport->array_import_convertvalue[0][$val]['classfile'])?$objimport->array_import_convertvalue[0][$val]['file']:$objimport->array_import_convertvalue[0][$val]['classfile']); + $class=$objimport->array_import_convertvalue[0][$val]['class']; + $method=$objimport->array_import_convertvalue[0][$val]['method']; + $units=$objimport->array_import_convertvalue[0][$val]['units']; + if ($this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval] != '') + { + $newval=$this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]; + } + else + { + $resultload = dol_include_once($file); + if (empty($resultload)) + { + dol_print_error('', 'Error trying to call file='.$file.', class='.$class.', method='.$method.', units='.$units); + break; + } + $classinstance=new $class($this->db); + // Try the fetch from code or ref + call_user_func_array(array($classinstance, $method), array('', $units, '', $newval)); + $this->cacheconvert[$file.'_'.$class.'_'.$method.'_'.$units][$newval]=$classinstance->code; + //print 'We have made a '.$class.'->'.$method.' to get id from code '.$newval.'. '; + if ($classinstance->code != '') // id may be 0, it is a found value + { + $newval=$classinstance->code; + } + else + { + if (!empty($objimport->array_import_convertvalue[0][$val]['dict'])) $this->errors[$error]['lib']=$langs->trans('ErrorFieldValueNotIn', $key, $newval, 'code', $langs->transnoentitiesnoconv($objimport->array_import_convertvalue[0][$val]['dict'])); + else $this->errors[$error]['lib']='ErrorFieldValueNotIn'; + $this->errors[$error]['type']='FOREIGNKEY'; + $errorforthistable++; + $error++; + } + } + } elseif ($objimport->array_import_convertvalue[0][$val]['rule']=='getcustomercodeifauto') { if (strtolower($newval) == 'auto') diff --git a/htdocs/core/modules/modProduct.class.php b/htdocs/core/modules/modProduct.class.php index aa64d7222a2..2cc82d5f654 100644 --- a/htdocs/core/modules/modProduct.class.php +++ b/htdocs/core/modules/modProduct.class.php @@ -313,8 +313,11 @@ class modProduct extends DolibarrModules 'p.note' => "PrivateNote",//private note 'p.customcode' => 'CustomCode', 'p.price' => "SellingPriceHT",//without tax + 'p.price_min' => "MinPrice", 'p.price_ttc' => "SellingPriceTTC",//with tax + 'p.price_min_ttc' => "SellingMinPriceTTC", 'p.price_base_type' => "PriceBaseType",//price base: with-tax (TTC) or without (HT) tax. Displays accordingly in Product card + 'p.cost_price' => "CostPrice", 'p.tva_tx' => 'VATRate', 'p.tosell' => "OnSell*", 'p.tobuy' => "OnBuy*", @@ -324,12 +327,18 @@ class modProduct extends DolibarrModules 'p.accountancy_code_sell' => "ProductAccountancySellCode", 'p.accountancy_code_buy' => "ProductAccountancyBuyCode", 'p.weight' => "Weight", + 'p.weight_units' => "WeightUnits", 'p.length' => "Length", + 'p.length_units' => "LengthUnit", 'p.width' => "Width", + 'p.width_units' => "VolumeUnits", 'p.height' => "Height", + 'p.height_units' => "HeightUnit", 'p.surface' => "Surface", + 'p.surface_units' => "SurfaceUnit", 'p.volume' => "Volume", - 'p.finished' => 'Nature' + 'p.volume_units' => "VolumeUnits", + 'p.finished' => 'Nature', ); if (!empty($conf->stock->enabled)) {//if Stock module enabled $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array( @@ -338,6 +347,58 @@ class modProduct extends DolibarrModules 'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature )); } + + $this->import_convertvalue_array[$r] = array( + 'p.weight_units' => array( + 'rule' => 'fetchidfromcodeunits', + 'classfile' => '/core/class/cmeasuringunits.class.php', + 'class' => 'CMeasuringUnits', + 'method' => 'fetch', + 'units' => 'weight', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.length_units' => array( + 'rule' => 'fetchidfromcodeunits', + 'classfile' => '/core/class/cmeasuringunits.class.php', + 'class' => 'CMeasuringUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.width_units' => array( + 'rule' => 'fetchidfromcodeunits', + 'classfile' => '/core/class/cmeasuringunits.class.php', + 'class' => 'CMeasuringUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.height_units' => array( + 'rule' => 'fetchidfromcodeunits', + 'classfile' => '/core/class/cmeasuringunits.class.php', + 'class' => 'CMeasuringUnits', + 'method' => 'fetch', + 'units' => 'size', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.surface_units' => array( + 'rule' => 'fetchidfromcodeunits', + 'classfile' => '/core/class/cmeasuringunits.class.php', + 'class' => 'CMeasuringUnits', + 'method' => 'fetch', + 'units' => 'surface', + 'dict' => 'DictionaryMeasuringUnits' + ), + 'p.volume_units' => array( + 'rule' => 'fetchidfromcodeunits', + 'classfile' => '/core/class/cmeasuringunits.class.php', + 'class' => 'CMeasuringUnits', + 'method' => 'fetch', + 'units' => 'volume', + 'dict' => 'DictionaryMeasuringUnits' + ) + ); + if (! empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice')); if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR')); if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r]=array_merge($this->import_fields_array[$r], array('p.localtax1_tx'=>'LT1', 'p.localtax1_type'=>'LT1Type')); @@ -371,7 +432,8 @@ class modProduct extends DolibarrModules 'p.finished' => '^[0|1]$' ); - $import_sample = array(//field order as per structure of table llx_product + // field order as per structure of table llx_product + $import_sample = array( 'p.ref' => "PREF123456", 'p.datec' => 'formatted as '.dol_print_date(dol_now(), '%Y-%m-%d'), 'p.label' => "Product name in default language", @@ -380,7 +442,9 @@ class modProduct extends DolibarrModules 'p.note' => "a private note (free text)", 'p.customcode' => 'customs code', 'p.price' => "price ex-vat eg. 100", + 'p.price_min' => "price ex-vat eg. 100", 'p.price_ttc' => "price inc-vat eg. 110", + 'p.price_min_ttc' => "price inc-vat eg. 110", 'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)", 'p.tva_tx' => 'tax rate eg: 10. Must match numerically one of the tax rates defined for your country', 'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)", @@ -391,11 +455,17 @@ class modProduct extends DolibarrModules 'p.accountancy_code_sell' => "", 'p.accountancy_code_buy' => "", 'p.weight' => "", + 'p.weight_units' => 'use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short Label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_measuring_units', 'p.length' => "", + 'p.length_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short Label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_measuring_units', 'p.width' => "", + 'p.width_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short Label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_measuring_units', 'p.height' => "", + 'p.height_units' => 'use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short Label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_measuring_units', 'p.surface' => "", + 'p.surface_units' => 'use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short Label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_measuring_units', 'p.volume' => "", + 'p.volume_units' => 'use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short Label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_measuring_units', 'p.finished' => '0 (raw material) / 1 (finished goods)' ); //clauses copied from import_fields_array @@ -409,8 +479,21 @@ class modProduct extends DolibarrModules if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample=array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>'')); if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample=array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>'')); if (! empty($conf->barcode->enabled)) $import_sample=array_merge($import_sample, array('p.barcode'=>'')); - if (! empty($conf->global->PRODUCT_USE_UNITS)) $import_sample=array_merge($import_sample, array('p.fk_unit'=>'use a unit of measure from the dictionary. 1/2/3 etc....matches field "rowid" in table "'.MAIN_DB_PREFIX.'c_units"')); + if (! empty($conf->global->PRODUCT_USE_UNITS)) { + $import_sample = array_merge($import_sample, array( + 'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "' . MAIN_DB_PREFIX . 'c_units"' + )); + $this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array( + 'p.fk_unit' => array( + 'rule' => 'fetchidfromcodeorlabel', + 'classfile' => '/core/class/cunits.class.php', + 'class' => 'CUnits', + 'method' => 'fetch', + 'dict' => 'DictionaryUnits' + ) + )); + } $this->import_examplevalues_array[$r]=array_merge($import_sample, $import_extrafield_sample); $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref'); if (! empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r]=array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode'));//only show/allow barcode as update key if Barcode module enabled diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 1bac8ec18e6..280f98ac62c 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -94,4 +94,141 @@ ALTER TABLE llx_actioncomm ADD COLUMN calling_duration integer; ALTER TABLE llx_don ADD COLUMN fk_soc integer NULL; -ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32); \ No newline at end of file +ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32); + +-- +-- Be carefull to requests order. +-- This file must be loaded by calling /install/index.php page +-- when current version is 10.0.0 or higher. +-- +-- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y +-- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y +-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; +-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; +-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); +-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; +-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); +-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; +-- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); +-- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table +-- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex +-- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; +-- To make pk to be auto increment (postgres): +-- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; +-- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); +-- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); +-- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; +-- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; +-- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; +-- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; +-- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; +-- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; +-- Note: fields with type BLOB/TEXT can't have default value. + +-- Missing in 9.0 + +DROP TABLE llx_ticket_logs; + +CREATE TABLE llx_pos_cash_fence( + rowid INTEGER AUTO_INCREMENT PRIMARY KEY, + entity INTEGER DEFAULT 1 NOT NULL, + ref VARCHAR(64), + label VARCHAR(255), + opening double(24,8) default 0, + cash double(24,8) default 0, + card double(24,8) default 0, + cheque double(24,8) default 0, + status INTEGER, + date_creation DATETIME NOT NULL, + date_valid DATETIME, + day_close INTEGER, + month_close INTEGER, + year_close INTEGER, + posmodule VARCHAR(30), + posnumber VARCHAR(30), + fk_user_creat integer, + fk_user_valid integer, + tms TIMESTAMP NOT NULL, + import_key VARCHAR(14) +) ENGINE=innodb; + + +-- For 10.0 + +ALTER TABLE llx_loan ADD COLUMN insurance_amount double(24,8) DEFAULT 0; + +ALTER TABLE llx_facture DROP INDEX idx_facture_uk_facnumber; +ALTER TABLE llx_facture CHANGE facnumber ref VARCHAR(30) NOT NULL; +ALTER TABLE llx_facture ADD UNIQUE INDEX uk_facture_ref (ref, entity); + +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CREATE','Ticket created','Executed when a ticket is created','ticket',161); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_MODIFY','Ticket modified','Executed when a ticket is modified','ticket',163); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',164); + +create table llx_mailing_unsubscribe +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + entity integer DEFAULT 1 NOT NULL, -- multi company id + email varchar(255), + unsubscribegroup varchar(128) DEFAULT '', + ip varchar(128), + date_creat datetime, -- creation date + tms timestamp +)ENGINE=innodb; + +ALTER TABLE llx_mailing_unsubscribe ADD UNIQUE uk_mailing_unsubscribe(email, entity, unsubscribegroup); + +ALTER TABLE llx_adherent ADD gender VARCHAR(10); +ALTER TABLE llx_subscription ADD fk_type integer(11); + +-- Add url_id into unique index of bank_url +ALTER TABLE llx_bank_url DROP INDEX uk_bank_url; +ALTER TABLE llx_bank_url ADD UNIQUE INDEX uk_bank_url (fk_bank, url_id, type); + +ALTER TABLE llx_actioncomm ADD COLUMN calling_duration integer; + +ALTER TABLE llx_don ADD COLUMN fk_soc integer NULL; + +ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32); + +CREATE TABLE llx_c_measuring_units( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(3), + label varchar(50), + short_label varchar(5), + unit_type varchar(10), + active tinyint DEFAULT 1 NOT NULL +) ENGINE=innodb; + +ALTER TABLE llx_c_measuring_units ADD UNIQUE uk_c_measuring_units_code(code,unit_type); + +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('3','WeightUnitton','T', 'weight', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','WeightUnitkg','Kg', 'weight', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','WeightUnitg','g', 'weight', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','WeightUnitmg','g', 'weight', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','WeightUnitounce','Oz', 'weight', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','WeightUnitpound','lb', 'weight', 1); + +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','SizeUnitm','m', 'size', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-1','SizeUnitdm','dm', 'size', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-2','SizeUnitcm','cm', 'size', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','SizeUnitmm','mm', 'size', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','SizeUnitfoot','ft', 'size', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','SizeUnitinch','in', 'size', 1); + +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','SurfaceUnitm2','m2', 'surface', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-2','SurfaceUnitdm2','dm2', 'surface', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-4','SurfaceUnitcm2','cm2', 'surface', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','SurfaceUnitmm2','mm2', 'surface', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','SurfaceUnitfoot2','ft2', 'surface', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','SurfaceUnitinch2','in2', 'surface', 1); + +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','VolumeUnitm3','m3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','VolumeUnitdm3','dm3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','VolumeUnitcm3','cm3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-9','VolumeUnitmm3','mm3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('88','VolumeUnitfoot3','ft3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('89','VolumeUnitinch3','in3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('97','VolumeUnitounce','Oz', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','VolumeUnitlitre','L', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','VolumeUnitgallon','gal', 'volume', 1); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 0c83492c816..87766554735 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -919,6 +919,7 @@ DictionaryAccountancysystem=Models for chart of accounts DictionaryAccountancyJournal=Accounting journals DictionaryEMailTemplates=Email Templates DictionaryUnits=Units +DictionaryMeasuringUnits=Measuring Units DictionaryProspectStatus=Prospect status DictionaryHolidayTypes=Types of leave DictionaryOpportunityStatus=Lead status for project/lead diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index 18a3fc43149..bf1d6ae5812 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -64,6 +64,7 @@ AppliedPricesFrom=Applied from SellingPrice=Selling price SellingPriceHT=Selling price (excl. tax) SellingPriceTTC=Selling price (inc. tax) +SellingMinPriceTTC=Minimum Selling price (inc. tax) CostPriceDescription=This price field (excl. tax) can be used to store the average amount this product costs to your company. It may be any price you calculate yourself, for example from the average buying price plus average production and distribution cost. CostPriceUsage=This value could be used for margin calculation. SoldAmount=Sold amount diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 773a3124740..67a2431dea1 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -311,31 +311,35 @@ class FormProduct function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) { //phpcs:enable - global $langs,$conf,$mysoc; + global $langs,$conf,$mysoc, $db; $langs->load("other"); $return=''; $measuring_units=array(); - if ($measuring_style == 'weight') $measuring_units=array(-6=>1,-3=>1,0=>1,3=>1,98=>1,99=>1); - elseif ($measuring_style == 'size') $measuring_units=array(-3=>1,-2=>1,-1=>1,0=>1,98=>1,99=>1); - elseif ($measuring_style == 'surface') $measuring_units=array(-6=>1,-4=>1,-2=>1,0=>1,98=>1,99=>1); - elseif ($measuring_style == 'volume') $measuring_units=array(-9=>1,-6=>1,-3=>1,0=>1,88=>1,89=>1,97=>1,99=>1,/* 98=>1 */); // Liter is not used as already available with dm3 + require_once DOL_DOCUMENT_ROOT.'/core/class/cmeasuringunits.class.php'; + $measuringUnits= new CMeasuringUnits($db); + $result=$measuringUnits->fetchAll('','', 0, 0, array('t.unit_type'=>$measuring_style,'t.active'=>1)); + if ($result<0) { + dol_print_error($db); + return -1; + } else { $return.= ''; + } return $return; } From eba4be2335c67880d93193f8e01c0cbd74bb6da2 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 12 Feb 2019 17:03:47 +0100 Subject: [PATCH 06/40] ad missing files --- htdocs/core/class/cmeasuringunits.class.php | 431 ++++++++++++++++++ htdocs/core/class/cunits.class.php | 330 ++++++++++++++ .../mysql/data/llx_c_measuring_units.sql | 51 +++ .../tables/llx_c_measuring_units.key.sql | 21 + .../mysql/tables/llx_c_measuring_units.sql | 28 ++ 5 files changed, 861 insertions(+) create mode 100644 htdocs/core/class/cmeasuringunits.class.php create mode 100644 htdocs/core/class/cunits.class.php create mode 100644 htdocs/install/mysql/data/llx_c_measuring_units.sql create mode 100644 htdocs/install/mysql/tables/llx_c_measuring_units.key.sql create mode 100644 htdocs/install/mysql/tables/llx_c_measuring_units.sql diff --git a/htdocs/core/class/cmeasuringunits.class.php b/htdocs/core/class/cmeasuringunits.class.php new file mode 100644 index 00000000000..e801969954b --- /dev/null +++ b/htdocs/core/class/cmeasuringunits.class.php @@ -0,0 +1,431 @@ + + * + * 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/core/class/cmeasuringunits.class.php + * \ingroup core + * \brief This file is CRUD class file (Create/Read/Update/Delete) for c_measuring_units dictionary + */ + + +/** + * Class of dictionary type of thirdparty (used by imports) + */ +class CMeasuringUnits // extends CommonObject +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); + public $records = array(); + + //var $element='ctypent'; //!< Id that identify managed objects + //var $table_element='ctypent'; //!< Name of table without prefix where object is stored + + /** + * @var int ID + */ + public $id; + + public $code; + public $label; + public $short_label; + public $unit_type; + public $active; + + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } + + + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + function create($user, $notrigger = 0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + + if (isset($this->id)) $this->id=trim($this->id); + if (isset($this->code)) $this->code=trim($this->code); + if (isset($this->label)) $this->libelle=trim($this->label); + if (isset($this->short_label)) $this->libelle=trim($this->short_label); + if (isset($this->unit_type)) $this->active=trim($this->unit_type); + if (isset($this->active)) $this->active=trim($this->active); + + + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_measuring_units("; + + $sql.= "rowid,"; + $sql.= "code,"; + $sql.= "label,"; + $sql.= "short_label,"; + $sql.= "unit_type"; + + + $sql.= ") VALUES ("; + + $sql.= " ".(! isset($this->id)?'NULL':"'".$this->db->escape($this->id)."'").","; + $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; + $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; + $sql.= " ".(! isset($this->short_label)?'NULL':"'".$this->db->active($this->short_label)."'").","; + $sql.= " ".(! isset($this->unit_type)?'NULL':"'".$this->db->active($this->unit_type)."'"); + + $sql.= ")"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_measuring_units"); + + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return $this->id; + } + } + + + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @param string $label Label + * @return int <0 if KO, >0 if OK + */ + function fetch($id, $unit_type='', $code = '', $short_label = '') + { + global $langs; + + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.code,"; + $sql.= " t.label,"; + $sql.= " t.short_label,"; + $sql.= " t.unit_type,"; + $sql.= " t.active"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_measuring_units as t"; + $sql_where=array(); + if ($id) $sql_where[]= " t.id = ".$id; + if ($unit_type) $sql_where[]= " t.unit_type = '".$this->db->escape($unit_type)."'"; + if ($code) $sql_where[]= " t.code = '".$this->db->escape($code)."'"; + if ($short_label) $sql_where[]= " t.short_label = '".$this->db->escape($short_label)."'"; + + if (count($sql_where)>0) { + $sql.=' WHERE '. implode(' AND ', $sql_where); + } + + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->code = $obj->code; + $this->label = $obj->label; + $this->short_label = $obj->short_label; + $this->unit_type = $obj->unit_type; + $this->active = $obj->active; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records=array(); + + $sql = 'SELECT'; + $sql.= " t.rowid,"; + $sql.= " t.code,"; + $sql.= " t.label,"; + $sql.= " t.short_label,"; + $sql.= " t.unit_type,"; + $sql.= " t.active"; + $sql .= ' FROM ' . MAIN_DB_PREFIX . 'c_measuring_units as t'; + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key=='t.rowid' || $key=='t.active') { + $sqlwhere[] = $key . '='. $value; + } + elseif (strpos($key, 'date') !== false) { + $sqlwhere[] = $key.' = \''.$this->db->idate($value).'\''; + } + elseif ($key=='t.unit_type' || $key=='t.code' || $key=='t.short_label') { + $sqlwhere[] = $key.' = \''.$this->db->escape($value).'\''; + } + else { + $sqlwhere[] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\''; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= ' WHERE (' . implode(' '.$filtermode.' ', $sqlwhere).')'; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= ' ' . $this->db->plimit($limit, $offset); + } + $resql = $this->db->query($sql); + if ($resql) { + $this->records=array(); + $num = $this->db->num_rows($resql); + if ($num>0) { + while ($obj = $this->db->fetch_object($resql)) + { + $record = new self($this->db); + + $record->id = $obj->rowid; + $record->code = $obj->code; + $record->label = $obj->label; + $record->short_label = $obj->short_label; + $record->unit_type = $obj->unit_type; + $record->active = $obj->active; + $this->records[$record->id] = $record; + } + } + $this->db->free($resql); + + return $this->records; + } else { + $this->errors[] = 'Error ' . $this->db->lasterror(); + dol_syslog(__METHOD__ . ' ' . join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user = null, $notrigger = 0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + if (isset($this->code)) $this->code=trim($this->code); + if (isset($this->label)) $this->libelle=trim($this->label); + if (isset($this->short_label)) $this->libelle=trim($this->short_label); + if (isset($this->unit_type)) $this->libelle=trim($this->unit_type); + if (isset($this->active)) $this->active=trim($this->active); + + + // Check parameters + // Put here code to add control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_measuring_units SET"; + $sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").","; + $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; + $sql.= " short_label=".(isset($this->short_label)?"'".$this->db->escape($this->short_label)."'":"null").","; + $sql.= " unit_type=".(isset($this->unit_type)?"'".$this->db->escape($this->unit_type)."'":"null").","; + $sql.= " active=".(isset($this->active)?$this->active:"null"); + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger = 0) + { + global $conf, $langs; + $error=0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_measuring_units"; + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } +} diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php new file mode 100644 index 00000000000..7afcb5ba8d2 --- /dev/null +++ b/htdocs/core/class/cunits.class.php @@ -0,0 +1,330 @@ + + * + * 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/core/class/cunits.class.php + * \ingroup core + * \brief This file is CRUD class file (Create/Read/Update/Delete) for c_units dictionary + */ + + +/** + * Class of dictionary type of thirdparty (used by imports) + */ +class CUnits // extends CommonObject +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Error code (or message) + */ + public $error=''; + + /** + * @var string[] Error codes (or messages) + */ + public $errors = array(); + + //var $element='ctypent'; //!< Id that identify managed objects + //var $table_element='ctypent'; //!< Name of table without prefix where object is stored + + /** + * @var int ID + */ + public $id; + + public $code; + public $label; + public $short_label; + public $active; + + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + function __construct($db) + { + $this->db = $db; + } + + + /** + * Create object into database + * + * @param User $user User that create + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + function create($user, $notrigger = 0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + + if (isset($this->id)) $this->id=trim($this->id); + if (isset($this->code)) $this->code=trim($this->code); + if (isset($this->label)) $this->libelle=trim($this->label); + if (isset($this->short_label)) $this->libelle=trim($this->short_label); + if (isset($this->active)) $this->active=trim($this->active); + + + + // Check parameters + // Put here code to add control on parameters values + + // Insert request + $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_units("; + + $sql.= "rowid,"; + $sql.= "code,"; + $sql.= "label,"; + $sql.= "short_label"; + + + $sql.= ") VALUES ("; + + $sql.= " ".(! isset($this->id)?'NULL':"'".$this->db->escape($this->id)."'").","; + $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; + $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; + $sql.= " ".(! isset($this->short_label)?'NULL':"'".$this->db->active($this->short_label)."'"); + + $sql.= ")"; + + $this->db->begin(); + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + $resql=$this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."c_units"); + + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return $this->id; + } + } + + + /** + * Load object in memory from database + * + * @param int $id Id object + * @param string $code Code + * @param string $label Label + * @return int <0 if KO, >0 if OK + */ + function fetch($id, $code = '', $short_label = '') + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.code,"; + $sql.= " t.label,"; + $sql.= " t.short_label,"; + $sql.= " t.active"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_units as t"; + if ($id) $sql.= " WHERE t.rowid = ".$id; + elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; + elseif ($short_label) $sql.= " WHERE t.short_label = '".$this->db->escape($short_label)."'"; + + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->code = $obj->code; + $this->label = $obj->label; + $this->short_label = $obj->short_label; + $this->active = $obj->active; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Update object into database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function update($user = null, $notrigger = 0) + { + global $conf, $langs; + $error=0; + + // Clean parameters + if (isset($this->code)) $this->code=trim($this->code); + if (isset($this->label)) $this->libelle=trim($this->label); + if (isset($this->short_label)) $this->libelle=trim($this->short_label); + if (isset($this->active)) $this->active=trim($this->active); + + + // Check parameters + // Put here code to add control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."c_units SET"; + $sql.= " code=".(isset($this->code)?"'".$this->db->escape($this->code)."'":"null").","; + $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; + $sql.= " short_label=".(isset($this->short_label)?"'".$this->db->escape($this->short_label)."'":"null").","; + $sql.= " active=".(isset($this->active)?$this->active:"null"); + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + function delete($user, $notrigger = 0) + { + global $conf, $langs; + $error=0; + + $sql = "DELETE FROM ".MAIN_DB_PREFIX."c_units"; + $sql.= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } + + if (! $error) + { + if (! $notrigger) + { + // Uncomment this and change MYOBJECT to your own tag if you + // want this action call a trigger. + + //// Call triggers + //include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + //$interface=new Interfaces($this->db); + //$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf); + //if ($result < 0) { $error++; $this->errors=$interface->errors; } + //// End call triggers + } + } + + // Commit or rollback + if ($error) + { + foreach($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error.=($this->error?', '.$errmsg:$errmsg); + } + $this->db->rollback(); + return -1*$error; + } + else + { + $this->db->commit(); + return 1; + } + } +} diff --git a/htdocs/install/mysql/data/llx_c_measuring_units.sql b/htdocs/install/mysql/data/llx_c_measuring_units.sql new file mode 100644 index 00000000000..a9982eb27f5 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_measuring_units.sql @@ -0,0 +1,51 @@ +-- ======================================================================== +-- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville +-- Copyright (C) 2004 Laurent Destailleur +-- Copyright (C) 2019 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 2 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 . +-- +-- ======================================================================== + +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('3','WeightUnitton','T', 'weight', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','WeightUnitkg','Kg', 'weight', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','WeightUnitg','g', 'weight', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','WeightUnitmg','g', 'weight', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','WeightUnitounce','Oz', 'weight', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','WeightUnitpound','lb', 'weight', 1); + +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','SizeUnitm','m', 'size', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-1','SizeUnitdm','dm', 'size', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-2','SizeUnitcm','cm', 'size', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','SizeUnitmm','mm', 'size', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','SizeUnitfoot','ft', 'size', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','SizeUnitinch','in', 'size', 1); + +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','SurfaceUnitm2','m2', 'surface', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-2','SurfaceUnitdm2','dm2', 'surface', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-4','SurfaceUnitcm2','cm2', 'surface', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','SurfaceUnitmm2','mm2', 'surface', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','SurfaceUnitfoot2','ft2', 'surface', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','SurfaceUnitinch2','in2', 'surface', 1); + + +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('0','VolumeUnitm3','m3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-3','VolumeUnitdm3','dm3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-6','VolumeUnitcm3','cm3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('-9','VolumeUnitmm3','mm3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('88','VolumeUnitfoot3','ft3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('89','VolumeUnitinch3','in3', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('97','VolumeUnitounce','Oz', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('98','VolumeUnitlitre','L', 'volume', 1); +INSERT INTO llx_c_measuring_units (code, label, short_label, unit_type, active) VALUES ('99','VolumeUnitgallon','gal', 'volume', 1); + diff --git a/htdocs/install/mysql/tables/llx_c_measuring_units.key.sql b/htdocs/install/mysql/tables/llx_c_measuring_units.key.sql new file mode 100644 index 00000000000..6c4bf619184 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_measuring_units.key.sql @@ -0,0 +1,21 @@ +-- ======================================================================== +-- Copyright (C) 2005 Laurent Destailleur +-- Copyright (C) 2012 Cédric Salvador +-- +-- 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 2 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 . +-- +-- ======================================================================== + + +ALTER TABLE llx_c_measuring_units ADD UNIQUE uk_c_measuring_units_code(code,unit_type); diff --git a/htdocs/install/mysql/tables/llx_c_measuring_units.sql b/htdocs/install/mysql/tables/llx_c_measuring_units.sql new file mode 100644 index 00000000000..74126556896 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_measuring_units.sql @@ -0,0 +1,28 @@ +-- ======================================================================== +-- Copyright (C) 2001-2002,2004 Rodolphe Quiedeville +-- Copyright (C) 2004 Laurent Destailleur +-- Copyright (C) 2012 Cédric Salvador +-- +-- 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 2 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 . +-- +-- ======================================================================== + +create table llx_c_measuring_units( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(3), + label varchar(50), + short_label varchar(5), + unit_type varchar(10), + active tinyint DEFAULT 1 NOT NULL +) ENGINE=innodb; From f7d183f3ef6b11140e122d9a25d6cc2893703e5e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 17:43:38 +0100 Subject: [PATCH 07/40] Add Kosovo country --- htdocs/install/mysql/data/llx_00_c_country.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/data/llx_00_c_country.sql b/htdocs/install/mysql/data/llx_00_c_country.sql index 0ea1a55d3d3..b97ce386eab 100644 --- a/htdocs/install/mysql/data/llx_00_c_country.sql +++ b/htdocs/install/mysql/data/llx_00_c_country.sql @@ -274,4 +274,5 @@ INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (24 INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (244,'ME','MNE','Monténégro',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (245,'BL','BLM','Saint-Barthélemy',1,0); INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (246,'MF','MAF','Saint-Martin',1,0); +INSERT INTO llx_c_country (rowid,code,code_iso,label,active,favorite) VALUES (247,'XK','XKX','Kosovo',1,0); From a172ea00a49811ed421e597eb549cd5fc44f05aa Mon Sep 17 00:00:00 2001 From: Jimmy L Date: Tue, 12 Feb 2019 17:54:59 +0100 Subject: [PATCH 08/40] Rest API: Proposal, Orders, Invoices: Add contact details --- .../comm/propal/class/api_proposals.class.php | 90 +++++++++++++++++-- htdocs/commande/class/api_orders.class.php | 7 +- .../facture/class/api_invoices.class.php | 7 +- 3 files changed, 93 insertions(+), 11 deletions(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 59d294f19ef..415a5ae6e78 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -57,12 +57,13 @@ class Proposals extends DolibarrApi * * Return an array with commercial proposal informations * - * @param int $id ID of commercial proposal + * @param int $id ID of commercial proposal + * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id * @return array|mixed data without useless information * * @throws RestException */ - function get($id) + function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->propal->lire) { throw new RestException(401); @@ -77,9 +78,8 @@ class Proposals extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - // Add external contacts ids - $this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', 1); - + // Add external contacts ids. + $this->propal->contacts_ids = $this->propal->liste_contact(-1, 'external', $contact_list); $this->propal->fetchObjectLinked(); return $this->_cleanObjectDatas($this->propal); } @@ -409,6 +409,86 @@ class Proposals extends DolibarrApi } } + /** + * Add a contact type of given commercial proposal + * + * @param int $id Id of commercial proposal to update + * @param int $contactid Id of contact to add + * @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER) + * + * @url POST {id}/contact/{contactid}/{type} + * + * @return int + * @throws 401 + * @throws 404 + */ + function postContact($id, $contactid, $type) + { + if(!DolibarrApiAccess::$user->rights->propal->creer) { + throw new RestException(401); + } + + $result = $this->propal->fetch($id); + + if(!$result) { + throw new RestException(404, 'Proposal not found'); + } + + if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) { + throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER'); + } + + if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->propal->add_contact($contactid, $type, 'external'); + + if (!$result) { + throw new RestException(500, 'Error when added the contact'); + } + + return $this->propal; + } + + /** + * Delete a contact type of given commercial proposal + * + * @param int $id Id of commercial proposal to update + * @param int $rowid Row key of the contact in the array contact_ids. + * + * @url DELETE {id}/contact/{lineid} + * + * @return int + * @throws 401 + * @throws 404 + * @throws 500 + */ + function deleteContact($id, $rowid) + { + if(!DolibarrApiAccess::$user->rights->propal->creer) { + throw new RestException(401); + } + + $result = $this->propal->fetch($id); + + if(!$result) { + throw new RestException(404, 'Proposal not found'); + } + + if(!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + + $result = $this->propal->delete_contact($rowid); + + if (!$result) { + throw new RestException(500, 'Error when deleted the contact'); + } + + return $this->propal; + } + /** * Update commercial proposal general fields (won't touch lines of commercial proposal) * diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index dc0c645183a..00e635856b7 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -56,12 +56,13 @@ class Orders extends DolibarrApi * * Return an array with order informations * - * @param int $id ID of order + * @param int $id ID of order + * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id * @return array|mixed data without useless information * * @throws RestException */ - function get($id) + function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->commande->lire) { throw new RestException(401); @@ -77,7 +78,7 @@ class Orders extends DolibarrApi } // Add external contacts ids - $this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', 1); + $this->commande->contacts_ids = $this->commande->liste_contact(-1, 'external', $contact_list); $this->commande->fetchObjectLinked(); return $this->_cleanObjectDatas($this->commande); } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 62b89ea213b..ec098bca224 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -55,12 +55,13 @@ class Invoices extends DolibarrApi * * Return an array with invoice informations * - * @param int $id ID of invoice + * @param int $id ID of invoice + * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id * @return array|mixed data without useless information * * @throws RestException */ - function get($id) + function get($id, $contact_list = 1) { if(! DolibarrApiAccess::$user->rights->facture->lire) { throw new RestException(401); @@ -82,7 +83,7 @@ class Invoices extends DolibarrApi } // Add external contacts ids - $this->invoice->contacts_ids = $this->invoice->liste_contact(-1, 'external', 1); + $this->invoice->contacts_ids = $this->invoice->liste_contact(-1, 'external', $contact_list); $this->invoice->fetchObjectLinked(); return $this->_cleanObjectDatas($this->invoice); From 914de5e08981d7f9f0e7819e39eb55b87c8775f5 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Tue, 12 Feb 2019 18:08:21 +0100 Subject: [PATCH 09/40] =?UTF-8?q?fix=20m=C3=B9igration=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../install/mysql/migration/9.0.0-10.0.0.sql | 95 ------------------- 1 file changed, 95 deletions(-) diff --git a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql index 280f98ac62c..6fc4bb08b4b 100644 --- a/htdocs/install/mysql/migration/9.0.0-10.0.0.sql +++ b/htdocs/install/mysql/migration/9.0.0-10.0.0.sql @@ -92,101 +92,6 @@ ALTER TABLE llx_bank_url ADD UNIQUE INDEX uk_bank_url (fk_bank, url_id, type); ALTER TABLE llx_actioncomm ADD COLUMN calling_duration integer; -ALTER TABLE llx_don ADD COLUMN fk_soc integer NULL; - -ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32); - --- --- Be carefull to requests order. --- This file must be loaded by calling /install/index.php page --- when current version is 10.0.0 or higher. --- --- To restrict request to Mysql version x.y minimum use -- VMYSQLx.y --- To restrict request to Pgsql version x.y minimum use -- VPGSQLx.y --- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new; --- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol; --- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60); --- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname; --- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60); --- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name; --- To create a unique index ALTER TABLE llx_table ADD UNIQUE INDEX uk_table_field (field); --- To drop an index: -- VMYSQL4.1 DROP INDEX nomindex on llx_table --- To drop an index: -- VPGSQL8.2 DROP INDEX nomindex --- To make pk to be auto increment (mysql): -- VMYSQL4.3 ALTER TABLE llx_table CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT; --- To make pk to be auto increment (postgres): --- -- VPGSQL8.2 CREATE SEQUENCE llx_table_rowid_seq OWNED BY llx_table.rowid; --- -- VPGSQL8.2 ALTER TABLE llx_table ADD PRIMARY KEY (rowid); --- -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN rowid SET DEFAULT nextval('llx_table_rowid_seq'); --- -- VPGSQL8.2 SELECT setval('llx_table_rowid_seq', MAX(rowid)) FROM llx_table; --- To set a field as NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NULL; --- To set a field as NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL; --- To set a field as NOT NULL: -- VMYSQL4.3 ALTER TABLE llx_table MODIFY COLUMN name varchar(60) NOT NULL; --- To set a field as NOT NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET NOT NULL; --- To set a field as default NULL: -- VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL; --- Note: fields with type BLOB/TEXT can't have default value. - --- Missing in 9.0 - -DROP TABLE llx_ticket_logs; - -CREATE TABLE llx_pos_cash_fence( - rowid INTEGER AUTO_INCREMENT PRIMARY KEY, - entity INTEGER DEFAULT 1 NOT NULL, - ref VARCHAR(64), - label VARCHAR(255), - opening double(24,8) default 0, - cash double(24,8) default 0, - card double(24,8) default 0, - cheque double(24,8) default 0, - status INTEGER, - date_creation DATETIME NOT NULL, - date_valid DATETIME, - day_close INTEGER, - month_close INTEGER, - year_close INTEGER, - posmodule VARCHAR(30), - posnumber VARCHAR(30), - fk_user_creat integer, - fk_user_valid integer, - tms TIMESTAMP NOT NULL, - import_key VARCHAR(14) -) ENGINE=innodb; - - --- For 10.0 - -ALTER TABLE llx_loan ADD COLUMN insurance_amount double(24,8) DEFAULT 0; - -ALTER TABLE llx_facture DROP INDEX idx_facture_uk_facnumber; -ALTER TABLE llx_facture CHANGE facnumber ref VARCHAR(30) NOT NULL; -ALTER TABLE llx_facture ADD UNIQUE INDEX uk_facture_ref (ref, entity); - -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_CREATE','Ticket created','Executed when a ticket is created','ticket',161); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_MODIFY','Ticket modified','Executed when a ticket is modified','ticket',163); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TICKET_DELETE','Ticket deleted','Executed when a ticket is deleted','ticket',164); - -create table llx_mailing_unsubscribe -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - entity integer DEFAULT 1 NOT NULL, -- multi company id - email varchar(255), - unsubscribegroup varchar(128) DEFAULT '', - ip varchar(128), - date_creat datetime, -- creation date - tms timestamp -)ENGINE=innodb; - -ALTER TABLE llx_mailing_unsubscribe ADD UNIQUE uk_mailing_unsubscribe(email, entity, unsubscribegroup); - -ALTER TABLE llx_adherent ADD gender VARCHAR(10); -ALTER TABLE llx_subscription ADD fk_type integer(11); - --- Add url_id into unique index of bank_url -ALTER TABLE llx_bank_url DROP INDEX uk_bank_url; -ALTER TABLE llx_bank_url ADD UNIQUE INDEX uk_bank_url (fk_bank, url_id, type); - -ALTER TABLE llx_actioncomm ADD COLUMN calling_duration integer; - ALTER TABLE llx_don ADD COLUMN fk_soc integer NULL; ALTER TABLE llx_payment_various ADD COLUMN subledger_account varchar(32); From affbd20cdb5018cd788712bcc26917d82a3d0135 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 18:56:32 +0100 Subject: [PATCH 10/40] FIX Bad link in menu manager --- htdocs/core/lib/treeview.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/treeview.lib.php b/htdocs/core/lib/treeview.lib.php index 6c66079090a..11f6e2652c1 100644 --- a/htdocs/core/lib/treeview.lib.php +++ b/htdocs/core/lib/treeview.lib.php @@ -115,7 +115,7 @@ function tree_showpad(&$fulltree,$key,$silent=0) */ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetalreadyloaded=0, $showfk=0) { - global $tree_recur_alreadyadded; + global $tree_recur_alreadyadded, $menu_handler_to_search; if ($rang == 0 && empty($donoresetalreadyloaded)) $tree_recur_alreadyadded=array(); @@ -203,7 +203,7 @@ function tree_recur($tab, $pere, $rang, $iddivjstree='iddivjstree', $donoresetal if ($showfk) { print '"; } diff --git a/htdocs/webservices/server_category.php b/htdocs/webservices/server_category.php index 74d175ac2c9..4495de9917f 100644 --- a/htdocs/webservices/server_category.php +++ b/htdocs/webservices/server_category.php @@ -190,6 +190,8 @@ function getCategory($authentication, $id) { global $db,$conf,$langs; + $nbmax = 10; + dol_syslog("Function: getCategory login=".$authentication['login']." id=".$id); if ($authentication['entity']) $conf->entity=$authentication['entity']; @@ -228,7 +230,7 @@ function getCategory($authentication, $id) //'visible'=>$categorie->visible, 'type' => $categorie->type, 'dir' => $pdir, - 'photos' => $categorie->liste_photos($dir, $nbmax=10) + 'photos' => $categorie->liste_photos($dir, $nbmax) ); $cats = $categorie->get_filles(); @@ -248,7 +250,7 @@ function getCategory($authentication, $id) //'visible'=>$fille->visible, 'type'=>$fille->type, 'dir' => $pdir, - 'photos' => $fille->liste_photos($dir, $nbmax=10) + 'photos' => $fille->liste_photos($dir, $nbmax) ); } } diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index d49a76af117..32f25fa2ca8 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -337,6 +337,8 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '' { global $db,$conf,$langs; + $nbmax = 10; + dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); $langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT)); @@ -417,7 +419,7 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '' 'pmp' => $product->pmp, 'import_key' => $product->import_key, 'dir' => $pdir, - 'images' => $product->liste_photos($dir, $nbmax=10) + 'images' => $product->liste_photos($dir, $nbmax) ); //Retreive all extrafield for thirdsparty @@ -1001,6 +1003,8 @@ function getProductsForCategory($authentication, $id, $lang = '') { global $db,$conf,$langs; + $nbmax = 10; + $langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT)); $langs->setDefaultLang($langcode); @@ -1086,7 +1090,7 @@ function getProductsForCategory($authentication, $id, $lang = '') 'pmp' => $obj->pmp, 'import_key' => $obj->import_key, 'dir' => $pdir, - 'images' => $obj->liste_photos($dir, $nbmax=10) + 'images' => $obj->liste_photos($dir, $nbmax) ); //Retreive all extrafield for thirdsparty From 986fb2ae38cfeb9a10cc8df150ec83a1d71ffd85 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 19:09:27 +0100 Subject: [PATCH 12/40] FIX creation of menu entry with parent id not int --- htdocs/admin/menus/edit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index 9e9d5cad8f1..9e5bcd9ca72 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -144,9 +144,9 @@ if ($action == 'add') } $leftmenu=''; $mainmenu=''; - if (GETPOST('menuId', 'int') && ! is_numeric(GETPOST('menuId', 'int'))) + if (GETPOST('menuId', 'alpha') && ! is_numeric(GETPOST('menuId', 'alpha'))) { - $tmp=explode('&', GETPOST('menuId', 'int')); + $tmp=explode('&', GETPOST('menuId', 'alpha')); foreach($tmp as $s) { if (preg_match('/fk_mainmenu=/', $s)) From 1f9f335e44371fc33399d8dfb1af98cfd8c86574 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 19:09:27 +0100 Subject: [PATCH 13/40] FIX creation of menu entry with parent id not int Conflicts: htdocs/admin/menus/edit.php --- htdocs/admin/menus/edit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index b16e9047b26..33a73147251 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -144,9 +144,9 @@ if ($action == 'add') } $leftmenu=''; $mainmenu=''; - if (GETPOST('menuId','int') && ! is_numeric(GETPOST('menuId','int'))) + if (GETPOST('menuId', 'alpha') && ! is_numeric(GETPOST('menuId', 'alpha'))) { - $tmp=explode('&',GETPOST('menuId','int')); + $tmp=explode('&', GETPOST('menuId', 'alpha')); foreach($tmp as $s) { if (preg_match('/fk_mainmenu=/',$s)) From 6a8504e1f812dee73075fac8407679a0242775b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 19:44:12 +0100 Subject: [PATCH 14/40] Fix missing constant --- htdocs/don/class/don.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index c3941059e64..e7296e2e157 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -91,6 +91,11 @@ class Don extends CommonObject public $labelstatut; public $labelstatutshort; + /** + * Draft + */ + const STATUS_DRAFT = 0; + /** * Constructor From 5a2161ad09de371fa6a1b36a27a1396b6ce656be Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 19:47:46 +0100 Subject: [PATCH 15/40] Debug export of zip --- htdocs/compta/compta-files.php | 525 ++++++++++++++++++++------------- 1 file changed, 322 insertions(+), 203 deletions(-) diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index d8f4885a3b2..61b05f81e37 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -25,166 +25,207 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -restrictedArea($user,'banque'); +$langs->loadLangs(array("accountancy","bills")); -$langs->load("companies"); -if (! empty($conf->facture->enabled)) $langs->load("bills"); -$date_start =GETPOST('date_start','alpha'); -$date_startDay= GETPOST('date_startday','int'); -$date_startMonth= GETPOST('date_startmonth','int'); -$date_startYear= GETPOST('date_startyear','int'); -$date_start=($date_startDay)?dol_mktime(0,0,0,$date_startMonth,$date_startDay,$date_startYear):strtotime($date_start); -$date_stop =GETPOST('date_stop','alpha'); -$date_stopDay= GETPOST('date_stopday','int'); -$date_stopMonth= GETPOST('date_stopmonth','int'); -$date_stopYear= GETPOST('date_stopyear','int'); +$date_start =GETPOST('date_start', 'alpha'); +$date_startDay= GETPOST('date_startday', 'int'); +$date_startMonth= GETPOST('date_startmonth', 'int'); +$date_startYear= GETPOST('date_startyear', 'int'); +$date_start=($date_startDay)?dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear):strtotime($date_start); +$date_stop =GETPOST('date_stop', 'alpha'); +$date_stopDay= GETPOST('date_stopday', 'int'); +$date_stopMonth= GETPOST('date_stopmonth', 'int'); +$date_stopYear= GETPOST('date_stopyear', 'int'); //FIXME doldate -$date_stop=($date_stopDay)?dol_mktime(0,0,0,$date_stopMonth,$date_stopDay,$date_stopYear):strtotime($date_stop); -$action =GETPOST('action','alpha'); -// Security check -//if ($user->societe_id) $id=$user->societe_id; -//$result = restrictedArea($user, 'societe', $id, '&societe'); -//$object = new Societe($db); -//if ($id > 0) $object->fetch($id); +$date_stop=($date_stopDay)?dol_mktime(0, 0, 0, $date_stopMonth, $date_stopDay, $date_stopYear):strtotime($date_stop); +$action =GETPOST('action', 'alpha'); + // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('comptafilescard','globalcard')); +$hookmanager->initHooks(array('comptafileslist','globallist')); + // Load variable for pagination -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page','int'); +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); +$page = GETPOST('page', 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield="f.datef,f.rowid"; // Set here default search field +if (! $sortfield) $sortfield="date,item"; // Set here default search field if (! $sortorder) $sortorder="DESC"; + + $arrayfields=array( 'date'=>array('label'=>"Date", 'checked'=>1), //... ); +// Security check +if (empty($conf->compta->enabled) && empty($conf->accounting->enabled)) { + accessforbidden(); +} +if ($user->societe_id > 0) + accessforbidden(); + + /* * Actions */ +$entity = GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity; + //$parameters = array('socid' => $id); //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks //if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); - - -/* - * View - */ - $filesarray=array(); $result=false; if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){ $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; - $sql="SELECT rowid as id, facnumber as ref,paye as paid,total_ttc,fk_soc,datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; + $sql="SELECT rowid as id, facnumber as ref,paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; $sql.=" WHERE datef between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND fk_statut <> ".Facture::STATUS_DRAFT; $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id,ref, paye as paid, total_ttc, fk_soc,datef as date, 'InvoiceSupplier' as item FROM ".MAIN_DB_PREFIX."facture_fourn"; - $sql.=" WHERE datef between ".$wheretail; + $sql.=" SELECT rowid as id, ref, paye as paid, total_ttc, fk_soc, datef as date, 'SupplierInvoice' as item FROM ".MAIN_DB_PREFIX."facture_fourn"; + $sql.=" WHERE datef between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND fk_statut <> ".FactureFournisseur::STATUS_DRAFT; $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id,ref,paid,total_ttc,fk_user_author as fk_soc,date_fin as date,'Expense' as item FROM ".MAIN_DB_PREFIX."expensereport"; + $sql.=" SELECT rowid as id, ref, paid, total_ttc, fk_user_author as fk_soc, date_fin as date,'ExpenseReport' as item FROM ".MAIN_DB_PREFIX."expensereport"; $sql.=" WHERE date_fin between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND fk_statut <> ".ExpenseReport::STATUS_DRAFT; $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id,ref,paid,amount as total_ttc,CONCAT(firstname,' ',lastname) as fk_soc,datedon as date,'Donation' as item FROM ".MAIN_DB_PREFIX."don"; - $sql.=" WHERE datedon between ".$wheretail; + $sql.=" SELECT rowid as id, ref,paid,amount as total_ttc, '0' as fk_soc, datedon as date,'Donation' as item FROM ".MAIN_DB_PREFIX."don"; + $sql.=" WHERE datedon between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + $sql.=" AND fk_statut <> ".Don::STATUS_DRAFT; $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id,label as ref,1 as paid,amount as total_ttc,fk_user as fk_soc,datep as date,'Salary' as item FROM ".MAIN_DB_PREFIX."payment_salary"; - $sql.=" WHERE datep between ".$wheretail; + $sql.=" SELECT rowid as id, label as ref, 1 as paid, amount as total_ttc, fk_user as fk_soc,datep as date,'SalaryPayment' as item FROM ".MAIN_DB_PREFIX."payment_salary"; + $sql.=" WHERE datep between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + //$sql.=" AND fk_statut <> ".PaymentSalary::STATUS_DRAFT; $sql.=" UNION ALL"; - $sql.=" SELECT rowid as id,num_paiement as ref,1 as paid,amount as total_ttc,fk_charge as fk_soc,datep as date,'Charge' as item FROM ".MAIN_DB_PREFIX."paiementcharge"; - $sql.=" WHERE datep between ".$wheretail; + $sql.=" SELECT rowid as id, libelle as ref, paye as paid, amount as total_ttc, 0 as fk_soc, date_creation as date, 'SocialContributions' as item FROM ".MAIN_DB_PREFIX."chargesociales"; + $sql.=" WHERE date_creation between ".$wheretail; + $sql.=" AND entity IN (".($entity==1?'0,1':$entity).')'; + //$sql.=" AND fk_statut <> ".ChargeSociales::STATUS_DRAFT; + $sql.= $db->order($sortfield, $sortorder); + $resd = $db->query($sql); $files=array(); $link=''; if ($resd) - { - $numd = $db->num_rows($resd); + { + $numd = $db->num_rows($resd); + + $tmpinvoice=new Facture($db); + $tmpinvoicesupplier=new FactureFournisseur($db); + $tmpdonation=new Don($db); $upload_dir =''; - $i=0; - while($i<$numd) - { - - + $i=0; + while ($i < $numd) + { $objd = $db->fetch_object($resd); - switch($objd->item){ - case "Invoice": - $subdir=dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->facture->dir_output.'/'.$subdir; - $link="../../document.php?modulepart=facture&file=".str_replace('/','%2F',$subdir).'%2F'; - break; - case "InvoiceSupplier": - $subdir=get_exdir($objd->id,2,0,0,$objd,'invoice_supplier').dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; - $link="../../document.php?modulepart=facture_fournisseur&file=".str_replace('/','%2F',$subdir).'%2F'; - break; - case "Expense": - $subdir=dol_sanitizeFileName($objd->ref); - $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; - $link="../../document.php?modulepart=expensereport&file=".str_replace('/','%2F',$subdir).'%2F'; - break; - case "Salary": - $subdir=dol_sanitizeFileName($objd->id); - $upload_dir = $conf->salaries->dir_output.'/'.$subdir; - $link="../../document.php?modulepart=salaries&file=".str_replace('/','%2F',$subdir).'%2F'; - break; - case "Donation": - $subdir=get_exdir(null,2,0,1,$objd,'donation'). '/'. dol_sanitizeFileName($objd->id); - $upload_dir = $conf->don->dir_output . '/' . $subdir; - $link="../../document.php?modulepart=don&file=".str_replace('/','%2F',$subdir).'%2F'; - break; - case "Charge": - $subdir=dol_sanitizeFileName($objd->id); - $upload_dir = $conf->tax->dir_output . '/' . $subdir; - $link="../../document.php?modulepart=tax&file=".str_replace('/','%2F',$subdir).'%2F'; - break; - default: - break; + switch($objd->item) + { + case "Invoice": + $subdir=dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->facture->dir_output.'/'.$subdir; + $link="document.php?modulepart=facture&file=".str_replace('/', '%2F', $subdir).'%2F'; + break; + case "SupplierInvoice": + $tmpinvoicesupplier->fetch($objd->id); + $subdir=get_exdir($tmpinvoicesupplier->id, 2, 0, 0, $tmpinvoicesupplier, 'invoice_supplier').'/'.dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->fournisseur->facture->dir_output.'/'.$subdir; + $link="document.php?modulepart=facture_fournisseur&file=".str_replace('/', '%2F', $subdir).'%2F'; + break; + case "ExpenseReport": + $subdir=dol_sanitizeFileName($objd->ref); + $upload_dir = $conf->expensereport->dir_output.'/'.$subdir; + $link="document.php?modulepart=expensereport&file=".str_replace('/', '%2F', $subdir).'%2F'; + break; + case "SalaryPayment": + $subdir=dol_sanitizeFileName($objd->id); + $upload_dir = $conf->salaries->dir_output.'/'.$subdir; + $link="document.php?modulepart=salaries&file=".str_replace('/', '%2F', $subdir).'%2F'; + break; + case "Donation": + $tmpdonation->fetch($objp->id); + $subdir=get_exdir(0, 0, 0, 1, $tmpdonation, 'donation'). '/'. dol_sanitizeFileName($objd->id); + $upload_dir = $conf->don->dir_output . '/' . $subdir; + $link="document.php?modulepart=don&file=".str_replace('/', '%2F', $subdir).'%2F'; + break; + case "SocialContributions": + $subdir=dol_sanitizeFileName($objd->id); + $upload_dir = $conf->tax->dir_output . '/' . $subdir; + $link="document.php?modulepart=tax&file=".str_replace('/', '%2F', $subdir).'%2F'; + break; + default: + $subdir=''; + $upload_dir=''; + $link=''; + break; } - if(!empty($upload_dir)){ + if (!empty($upload_dir)) + { $result=true; - $files=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$','',SORT_ASC,1); - foreach ($files as $key => $file){ - $file['date']=$db->idate($objd->date); - $file['paid']=$objd->paid; - $file['amount']=$objd->total_ttc; - $file['ref']=$objd->ref; - $file['fk']=$objd->fk_soc; - $file['item']=$objd->item; - $file['link']=$link.$file['name']; - $out.= '
'.$file['name'].''; - $filesarray[]=$file; - } - if(count($files)<1){ + $files=dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview\.png)$', '', SORT_ASC, 1); + //var_dump($upload_dir); + if (count($files) < 1) + { $nofile['date']=$db->idate($objd->date); $nofile['paid']=$objd->paid; $nofile['amount']=$objd->total_ttc; $nofile['ref']=$objd->ref; $nofile['fk']=$objd->fk_soc; $nofile['item']=$objd->item; - $filesarray[]=$nofile; + + $filesarray[]=$nofile; + } + else + { + foreach ($files as $key => $file) + { + $file['date']=$db->idate($objd->date); + $file['paid']=$objd->paid; + $file['amount']=$objd->total_ttc; + $file['ref']=$objd->ref; + $file['fk']=$objd->fk_soc; + $file['item']=$objd->item; + $file['link']=$link.$file['name']; + $file['relpathnamelang'] = $langs->trans($file['item']).'/'.$file['name']; + + $filesarray[]=$file; + } } } - $i++; - } - } - $db->free($resd); + $i++; + } + } + else + { + dol_print_error($db); + } + + $db->free($resd); } + /* * cleanup of old ZIP */ @@ -192,124 +233,202 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){ /* *ZIP creation */ -if($result & $action=="dl"){ - unset($zip); - $log='date,type,ref,total,paid,filename,item_id'."\n"; - $zipname = ($date_start)."-".($date_stop).'_export.zip'; - $zip = new ZipArchive; - $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE); - if ($res){ - foreach ($filesarray as $key=> $file) { - if(file_exists($file["fullname"])) $zip->addFile($file["fullname"],$file["name"]);// - $log.=$file['date'].','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; - } - $zip->addFromString('log.csv', $log); - $zip->close(); - ///Then download the zipped file. - header('Content-Type: application/zip'); - header('Content-disposition: attachment; filename='.$zipname); - header('Content-Length: ' . filesize($zipname)); - readfile($zipname); - unlink($zipname); - exit(); + +if ($result && $action == "dl") +{ + dol_delete_file($zip); + + $log='date,type,ref,total,paid,filename,item_id'."\n"; + $zipname = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp).'/'.($date_start)."-".($date_stop).'_export.zip'; + + $zip = new ZipArchive; + $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE); + if ($res) + { + foreach ($filesarray as $key=> $file) + { + if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); // + $log.=$file['date'].','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; } + $zip->addFromString('transactions.csv', $log); + $zip->close(); + + ///Then download the zipped file. + header('Content-Type: application/zip'); + header('Content-disposition: attachment; filename='.basename($zipname)); + header('Content-Length: ' . filesize($zipname)); + readfile($zipname); + + dol_delete_file($zipname); + + exit(); + } } -// None + + /* - * View + * View */ + $form = new Form($db); $userstatic=new User($db); + $title=$langs->trans("ComptaFiles").' - '.$langs->trans("List"); -//if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->name.' - '.$langs->trans("Symmary"); -$help_url='EN:Module_Accounting|FR:Module_Compatibilite'; //FIXME -llxHeader('',$title,$help_url); -print ''."\n\t\t"; -if (!empty($date_start) && !empty($date_stop))echo dol_print_date($date_start)." - ".dol_print_date($date_stop); -print '
'; - print '   '; + print '   '; print $tab[$x]['title']; print ''; print '  (mainmenu='.$tab[$x]['mainmenu'].' leftmenu='.$tab[$x]['leftmenu'].' - fk_mainmenu='.$tab[$x]['fk_mainmenu'].' fk_leftmenu='.$tab[$x]['fk_leftmenu'].')'; From f1500281efb6b36895ed59606e9126b1b6d99ff9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 19:00:50 +0100 Subject: [PATCH 11/40] Fix phpcs --- htdocs/contact/consumption.php | 3 ++- htdocs/user/card.php | 3 +-- htdocs/webservices/server_category.php | 6 ++++-- htdocs/webservices/server_productorservice.php | 8 ++++++-- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 4191563eaec..ebbe7332236 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -488,7 +488,8 @@ if ($sql_select) $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); } - if (($objp->info_bits & 2) == 2) { + if (($objp->info_bits & 2) == 2) + { print ''; $txt=''; print img_object($langs->trans("ShowReduc"), 'reduc').' '; diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 859b2220b28..63a2a598d41 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1104,8 +1104,7 @@ if ($action == 'create' || $action == 'adduserldap') { print '
' . $form->editfieldkey('Categories', 'usercats', '', $object, 0) . ''; $cate_arbo = $form->select_all_categories('user', null, 'parent', null, null, 1); -print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, - null, '90%' ); + print $form->multiselectarray('usercats', $cate_arbo, GETPOST('usercats', 'array'), null, null, null, null, '90%'); print "
'; -print ''; -//if (! empty($arrayfields['f.datef']['checked'])) -print_liste_field_titre($arrayfields['date']['label'],$_SERVER["PHP_SELF"],"date","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -print ''; -if ($result) + +llxHeader('', $title, $help_url); + +$h=0; +$head[$h][0] = $_SERVER["PHP_SELF"].$varlink; +$head[$h][1] = $langs->trans("AccountancyFiles"); +$head[$h][2] = 'AccountancyFiles'; + +dol_fiche_head($head, 'AccountancyFiles'); + + +print ''."\n"; +print ''; +print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0); +print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n"; +// Multicompany +if (! empty($conf->multicompany->enabled) && is_object($mc)) { - $TData = dol_sort_array($filesarray, 'date', 'ASC'); - if(empty($TData)) { - print ''; - } else { - // Sort array by date ASC to calucalte balance - - $totalDebit = 0; - $totalCredit = 0; - // Balance calculation - $balance = 0; - foreach($TData as &$data1) { - if($data1['item']!='Invoice'&& $data1['item']!='Donation' ){ - $data1['amount']=-$data1['amount']; - } - if ($data1['amount']>0){ - }else{ - } - $balance += $data1['amount']; - $data1['balance'] = $balance; - } - // Display array - foreach($TData as $data) { - $html_class = ''; - //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; - //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; - print ''; - print "\n"; - print ''; - print ''; - print '\n"; - print ''; - print '\n"; - $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0; - print '\n"; - $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); - // Balance - print '\n"; - print "\n"; - } - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } + print '
'; + // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module + if (method_exists($mc, 'formObjectOptions')) + { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode + { + print "".''; + print "\n"; } -print "
'.$langs->trans("Type").''.$langs->trans("Ref").''.$langs->trans("File").''.$langs->trans("Paid").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").'
'.$langs->trans("NoItem").'
"; - print dol_print_date($data['date'],'day'); - print "'.$data['item'].''.$data['ref'].' ".$data['name']."'.$data['paid'].''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."'.price($data['balance'])."
 '.price($totalDebit).''.price($totalCredit).''.price(price2num($totalDebit - $totalCredit, 'MT')).'
'.$langs->trans("Entity").'".$mc->select_entities($entity); + print "
"; -print ''."\n\t\t\t"; + else + { + print ''; + } + } -print ''; -print ''; + /*$object = new stdClass(); + // Other attributes + $parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit'); + }*/ +} +print ''."\n"; -//print ''; -//print ''; -//print ''; +dol_fiche_end(); -//print ''; -//print ''; -//print ''; +if (!empty($date_start) && !empty($date_stop)) +{ + $param='action=searchfiles'; + $param.='&date_startday='.GETPOST('date_startday', 'int'); + $param.='&date_startmonth='.GETPOST('date_startmonth', 'int'); + $param.='&date_startyear='.GETPOST('date_startyear', 'int'); + $param.='&date_stopday='.GETPOST('date_stopday', 'int'); + $param.='&date_stopmonth='.GETPOST('date_stopmonth', 'int'); + $param.='&date_stopyear='.GETPOST('date_stopyear', 'int'); + print '
'."\n"; + print ''; -print '
'."\n\t\t\n\t\t\n\t\t\t"; + echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); + print ''; + print ''; + + //print ''; + //print ''; + //print ''; + + //print ''; + //print ''; + //print ''; + + print ''; + print ''."\n"; + + print '
'; + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print ''; + print ''; + print_liste_field_titre($arrayfields['date']['label'], $_SERVER["PHP_SELF"], "date", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + if ($result) + { + $TData = dol_sort_array($filesarray, 'date', 'ASC'); + + if (empty($TData)) + { + print ''; + } + else + { + // Sort array by date ASC to calculate balance + + $totalDebit = 0; + $totalCredit = 0; + // Balance calculation + $balance = 0; + foreach($TData as &$data1) { + if ($data1['item']!='Invoice'&& $data1['item']!='Donation' ){ + $data1['amount']=-$data1['amount']; + } + if ($data1['amount']>0){ + }else{ + } + $balance += $data1['amount']; + $data1['balance'] = $balance; + } + + // Display array + foreach($TData as $data) + { + $html_class = ''; + //if (!empty($data['fk_facture'])) $html_class = 'facid-'.$data['fk_facture']; + //elseif (!empty($data['fk_paiement'])) $html_class = 'payid-'.$data['fk_paiement']; + print ''; + print "\n"; + print ''; + print ''; + + // File link + print '\n"; + + print ''; + print '\n"; + $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0; + print '\n"; + $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); + // Balance + print '\n"; + print "\n"; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + } + print "
'.$langs->trans("Type").''.$langs->trans("Ref").''.$langs->trans("Link").''.$langs->trans("Paid").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").'
'.$langs->trans("NoItem").'
"; + print dol_print_date($data['date'], 'day'); + print "'.$langs->trans($data['item']).''.$data['ref'].'".$data['name']."'.$data['paid'].''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."'.price($data['balance'])."
 '.price($totalDebit).''.price($totalCredit).''.price(price2num($totalDebit - $totalCredit, 'MT')).'
"; + print '
'; +} llxFooter(); From 036dc52170f96f892baaaa488076ef2bb82a213a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 19:55:54 +0100 Subject: [PATCH 16/40] Fix test --- htdocs/compta/compta-files.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index 61b05f81e37..1411c52591e 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -70,7 +70,7 @@ $arrayfields=array( ); // Security check -if (empty($conf->compta->enabled) && empty($conf->accounting->enabled)) { +if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled)) { accessforbidden(); } if ($user->societe_id > 0) @@ -231,8 +231,8 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){ */ //FIXME /* -*ZIP creation -*/ + *ZIP creation + */ if ($result && $action == "dl") { @@ -247,8 +247,8 @@ if ($result && $action == "dl") { foreach ($filesarray as $key=> $file) { - if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); // - $log.=$file['date'].','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; + if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); // + $log.=$file['date'].','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; } $zip->addFromString('transactions.csv', $log); $zip->close(); @@ -309,14 +309,14 @@ if (! empty($conf->multicompany->enabled) && is_object($mc)) } /*$object = new stdClass(); - // Other attributes - $parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit'); - }*/ + // Other attributes + $parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit'); + }*/ } print ''."\n"; From 32c48f0fa2f7b577c65236f1ea00e10b3e9d028d Mon Sep 17 00:00:00 2001 From: wdammak <26695620+wdammak@users.noreply.github.com> Date: Tue, 12 Feb 2019 19:56:55 +0100 Subject: [PATCH 17/40] Update main.inc.php break ;) --- htdocs/main.inc.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 34480729623..7f7c6126c58 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -430,6 +430,7 @@ if(is_array($modulepart) && count($modulepart)>0) if(in_array($module, $modulepart)) { $conf->modulepart = $module; + break; } } } From 484acc2e009b359b19e3c047332f9889a9f973f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Feb 2019 20:55:55 +0100 Subject: [PATCH 18/40] fix phpcs --- htdocs/compta/compta-files.php | 2 +- .../core/class/commondocgenerator.class.php | 2 +- htdocs/margin/agentMargins.php | 10 +- htdocs/product/stock/movement_card.php | 166 +++++++++--------- htdocs/projet/tasks/time.php | 2 +- .../class/html.formresource.class.php | 2 +- 6 files changed, 92 insertions(+), 92 deletions(-) diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index 7fa3e8fb251..f61ee1a2330 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -81,7 +81,7 @@ if ($user->societe_id > 0) * Actions */ -$entity = GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity; +$entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; //$parameters = array('socid' => $id); //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 235dde63096..2d4bcb3a167 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -585,7 +585,7 @@ abstract class CommonDocGenerator $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true); $line->fetch_optionals(); - $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key=$array_key, $outputlangs); + $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key= $array_key, $outputlangs); // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" if (isset($line->fk_product) && $line->fk_product > 0) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 8bdbaac5861..43fc3ccda89 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -212,13 +212,13 @@ if ($result) else print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("SellingPrice",$_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice,$_SERVER["PHP_SELF"], "buying_price", "", $param,' align="right"', $sortfield, $sortorder); - print_liste_field_titre("Margin",$_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, ' align="right"', $sortfield, $sortorder); + print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder); if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); if (! empty($conf->global->DISPLAY_MARK_RATES)) - print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); print "\n"; $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index abf7d21284b..22596f20bef 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -47,17 +47,17 @@ $langs->loadLangs(array('products', 'stocks', 'orders')); if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); // Security check -$result=restrictedArea($user,'stock'); +$result=restrictedArea($user, 'stock'); -$id=GETPOST('id','int'); -$ref = GETPOST('ref','alpha'); -$msid=GETPOST('msid','int'); +$id=GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$msid=GETPOST('msid', 'int'); $product_id=GETPOST("product_id"); -$action=GETPOST('action','aZ09'); -$cancel=GETPOST('cancel','alpha'); -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist'; +$action=GETPOST('action', 'aZ09'); +$cancel=GETPOST('cancel', 'alpha'); +$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist'; -$idproduct = GETPOST('idproduct','int'); +$idproduct = GETPOST('idproduct', 'int'); $year = GETPOST("year"); $month = GETPOST("month"); $search_ref = GETPOST('search_ref', 'alpha'); @@ -69,18 +69,18 @@ $search_inventorycode = trim(GETPOST("search_inventorycode")); $search_user = trim(GETPOST("search_user")); $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); -$search_type_mouvement=GETPOST('search_type_mouvement','int'); +$search_type_mouvement=GETPOST('search_type_mouvement', 'int'); -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; -$page = GETPOST("page",'int'); -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$page = GETPOST("page", 'int'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; if (! $sortfield) $sortfield="m.datem"; if (! $sortorder) $sortorder="DESC"; -$pdluoid=GETPOST('pdluoid','int'); +$pdluoid=GETPOST('pdluoid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new MouvementStock($db); @@ -90,7 +90,7 @@ $formfile = new FormFile($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('movement'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $arrayfields=array( 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), @@ -122,17 +122,17 @@ $usercanread = (($user->rights->stock->mouvement->lire)); $usercancreate = (($user->rights->stock->mouvement->creer)); $usercandelete = (($user->rights->stock->mouvement->supprimer)); -if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } $parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // 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'; // Do we click on purge search criteria ? -if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { $year=''; $month=''; @@ -195,11 +195,11 @@ if ($action == "correct_stock") $result=$product->correct_stock_batch( $user, $id, - GETPOST("nbpiece",'int'), + GETPOST("nbpiece", 'int'), GETPOST("mouvement"), - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), GETPOST('unitprice'), - $eatby,$sellby,$batch, + $eatby, $sellby, $batch, GETPOST('inventorycode'), $origin_element, $origin_id @@ -210,9 +210,9 @@ if ($action == "correct_stock") $result=$product->correct_stock( $user, $id, - GETPOST("nbpiece",'int'), + GETPOST("nbpiece", 'int'), GETPOST("mouvement"), - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), GETPOST('unitprice'), GETPOST('inventorycode'), $origin_element, @@ -226,11 +226,11 @@ if ($action == "correct_stock") exit; } else - { - $error++; - setEventMessages($product->error, $product->errors, 'errors'); - $action='correction'; - } + { + $error++; + setEventMessages($product->error, $product->errors, 'errors'); + $action='correction'; + } } if (! $error) $action=''; @@ -242,7 +242,7 @@ if ($action == "transfert_stock" && ! $cancel) $product = new Product($db); if (! empty($product_id)) $result=$product->fetch($product_id); - if (! (GETPOST("id_entrepot_destination",'int') > 0)) + if (! (GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; @@ -254,13 +254,13 @@ if ($action == "transfert_stock" && ! $cancel) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action='transfert'; } - if (! GETPOST("nbpiece",'int')) + if (! GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; $action='transfert'; } - if ($id == GETPOST("id_entrepot_destination",'int')) + if ($id == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; @@ -330,22 +330,22 @@ if ($action == "transfert_stock" && ! $cancel) $result1=$product->correct_stock_batch( $user, $srcwarehouseid, - GETPOST("nbpiece",'int'), + GETPOST("nbpiece", 'int'), 1, - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), $pricesrc, - $eatby,$sellby,$batch, + $eatby, $sellby, $batch, GETPOST('inventorycode') ); // Add stock $result2=$product->correct_stock_batch( $user, - GETPOST("id_entrepot_destination",'int'), - GETPOST("nbpiece",'int'), + GETPOST("id_entrepot_destination", 'int'), + GETPOST("nbpiece", 'int'), 0, - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), $pricedest, - $eatby,$sellby,$batch, + $eatby, $sellby, $batch, GETPOST('inventorycode') ); } @@ -447,7 +447,7 @@ $sql.= " u.login, u.photo, u.lastname, u.firstname"; foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",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 +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product as p,"; @@ -464,13 +464,13 @@ if ($id > 0) $sql.= " AND e.rowid ='".$id."'"; if ($month > 0) { if ($year > 0) - $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, $month, false))."' AND '".$db->idate(dol_get_last_day($year, $month, false))."'"; else $sql.= " AND date_format(m.datem, '%m') = '$month'"; } elseif ($year > 0) { - $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'"; if (! empty($search_ref)) $sql.= natural_search('m.rowid', $search_ref, 1); @@ -487,9 +487,9 @@ if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql.= natur include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -549,7 +549,7 @@ if ($resql) $texte = $langs->trans("ListOfStockMovements"); if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')'; } - llxHeader("",$texte,$help_url); + llxHeader("", $texte, $help_url); /* * Show tab only if we ask a particular warehouse @@ -568,7 +568,7 @@ if ($resql) $morehtmlref.=''; $shownav = 1; - if ($user->societe_id && ! in_array('stock', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->societe_id && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); @@ -609,7 +609,7 @@ if ($resql) // Value print ''.$langs->trans("EstimatedStockValueShort").''; - print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); print ""; // Last movement @@ -630,7 +630,7 @@ if ($resql) print ''.$langs->trans("LastMovement").''; if ($lastmovementdate) { - print dol_print_date($lastmovementdate,'dayhour'); + print dol_print_date($lastmovementdate, 'dayhour'); } else { @@ -731,19 +731,19 @@ if ($resql) print ''; if ($id > 0) print ''; - if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,$massactionbutton,$num, $nbtotalofrecords, '', 0, '', '', $limit); - else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,$massactionbutton,$num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); + if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); + else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; } $moreforfilter=''; $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -883,7 +883,7 @@ if ($resql) // Fields from hook $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['m.datec']['checked'])) @@ -905,38 +905,38 @@ if ($resql) print "\n"; print ''; - if (! empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'],$_SERVER["PHP_SELF"],'m.rowid','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'],$_SERVER["PHP_SELF"],'m.datem','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'],$_SERVER["PHP_SELF"],'p.label','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'],$_SERVER["PHP_SELF"],'m.batch','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'],$_SERVER["PHP_SELF"],'pl.eatby','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'],$_SERVER["PHP_SELF"],'pl.sellby','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'],$_SERVER["PHP_SELF"], "e.ref","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible - if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'],$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'],$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'],$_SERVER["PHP_SELF"], "m.type_mouvement","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); // We are on a specific warehouse card, no filter on other should be possible + if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, 'align="right"', $sortfield, $sortorder); + if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, 'align="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['m.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['m.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + if (! empty($arrayfields['m.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (! empty($arrayfields['m.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; $arrayofuniqueproduct=array(); - while ($i < min($num,$limit)) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); @@ -978,13 +978,13 @@ if ($resql) if (! empty($arrayfields['m.datem']['checked'])) { // Date - print ''.dol_print_date($db->jdate($objp->datem),'dayhour').''; + print ''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; } if (! empty($arrayfields['p.ref']['checked'])) { // Product ref print ''; - print $productstatic->getNomUrl(1,'stock',16); + print $productstatic->getNomUrl(1, 'stock', 16); print "\n"; } if (! empty($arrayfields['p.label']['checked'])) @@ -1007,11 +1007,11 @@ if ($resql) } if (! empty($arrayfields['pl.eatby']['checked'])) { - print ''. dol_print_date($objp->eatby,'day') .''; + print ''. dol_print_date($objp->eatby, 'day') .''; } if (! empty($arrayfields['pl.sellby']['checked'])) { - print ''. dol_print_date($objp->sellby,'day') .''; + print ''. dol_print_date($objp->sellby, 'day') .''; } // Warehouse if (! empty($arrayfields['e.ref']['checked'])) @@ -1048,7 +1048,7 @@ if ($resql) if (! empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement - switch($objp->type_mouvement){ + switch($objp->type_mouvement) { case "0": print ''.$langs->trans('StockIncreaseAfterCorrectTransfer').''; break; @@ -1114,20 +1114,20 @@ if ($resql) $productidselected=$key; $productlabelselected=$val; } - $datebefore=dol_get_first_day($year?$year:strftime("%Y",time()), $month?$month:1, true); - $dateafter=dol_get_last_day($year?$year:strftime("%Y",time()), $month?$month:12, true); + $datebefore=dol_get_first_day($year?$year:strftime("%Y", time()), $month?$month:1, true); + $dateafter=dol_get_last_day($year?$year:strftime("%Y", time()), $month?$month:12, true); $balancebefore=$movement->calculateBalanceForProductBefore($productidselected, $datebefore); $balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter); //print ''; - print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore,'day','gmt')); + print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); //print ''; //print ''; print ': '.$balancebefore; print "
\n"; //print ''; //print ''; - print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter,'day','gmt')); + print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter, 'day', 'gmt')); //print ''; //print ''; print ': '.$balanceafter; @@ -1169,7 +1169,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) $genallowed=$user->rights->stock->lire; $delallowed=$user->rights->stock->creer; - print $formfile->showdocuments($modulepart,$objectref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); + print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); $somethingshown=$formfile->numoffiles; print '
'; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index be87a52fcd9..1ec5ced0abf 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1045,7 +1045,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $contactsofproject=$projectstatic->getListContactId('internal'); if (count($contactsofproject)>0) { - if (in_array($user->id, $userid=$contactsofproject)) $userid = $user->id; + if (in_array($user->id, $userid= $contactsofproject)) $userid = $user->id; else $userid=$contactsofproject[0]; if ($projectstatic->public) $contactsofproject = array(); print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 39b789c2b7d..507e7f6a6dc 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -85,7 +85,7 @@ class FormResource $resourcestat = new Dolresource($this->db); - $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, $filter=''); + $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, $filter= ''); if ($outputmode != 2) { From d42bf54436a082992044e7edb798873d143e510b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 23:12:33 +0100 Subject: [PATCH 19/40] Fix export zip --- htdocs/compta/compta-files.php | 69 ++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index 1411c52591e..33f8b2dcb96 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -236,10 +236,14 @@ if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){ if ($result && $action == "dl") { - dol_delete_file($zip); + $dirfortmpfile = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp); + + dol_mkdir($dirfortmpfile); $log='date,type,ref,total,paid,filename,item_id'."\n"; - $zipname = ($conf->accounting->dir_temp ? $conf->accounting->dir_temp : $conf->compta->dir_temp).'/'.($date_start)."-".($date_stop).'_export.zip'; + $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; + + dol_delete_file(name); $zip = new ZipArchive; $res = $zip->open($zipname, ZipArchive::OVERWRITE|ZipArchive::CREATE); @@ -248,7 +252,7 @@ if ($result && $action == "dl") foreach ($filesarray as $key=> $file) { if (file_exists($file["fullname"])) $zip->addFile($file["fullname"], $file["relpathnamelang"]); // - $log.=$file['date'].','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; + $log.=dol_print_date($file['date'], 'dayrfc').','.$file['item'].','.$file['ref'].','.$file['amount'].','.$file['paid'].','.$file["name"].','.$file['fk']."\n"; } $zip->addFromString('transactions.csv', $log); $zip->close(); @@ -290,34 +294,43 @@ print ''; print $langs->trans("ReportPeriod").': '.$form->selectDate($date_start, 'date_start', 0, 0, 0, "", 1, 1, 0); print ' - '.$form->selectDate($date_stop, 'date_stop', 0, 0, 0, "", 1, 1, 0)."\n"; // Multicompany +/*if (! empty($conf->multicompany->enabled) && is_object($mc)) + { + print '
'; + // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module + if (method_exists($mc, 'formObjectOptions')) + { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode + { + print "".''.$langs->trans("Entity").''; + print "".$mc->select_entities($entity); + print "\n"; + } + else + { + print ''; + } + } + + $object = new stdClass(); + // Other attributes + $parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (empty($reshook)) + { + print $object->showOptionals($extrafields, 'edit'); + } + }*/ if (! empty($conf->multicompany->enabled) && is_object($mc)) { - print '
'; - // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module - if (method_exists($mc, 'formObjectOptions')) - { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode - { - print "".''.$langs->trans("Entity").''; - print "".$mc->select_entities($entity); - print "\n"; - } - else - { - print ''; - } - } - - /*$object = new stdClass(); - // Other attributes - $parameters=array('objectsrc' => null, 'colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit'); - }*/ + print '   -   '.$langs->trans("Entity").' : '; + $mc->dao->getEntities(); + $mc->dao->fetch($conf->entity); + print $mc->dao->label; + print "
\n"; } + print ''."\n"; dol_fiche_end(); From 639dfa09aa6e7c743685b55e7244dddd345511a6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 23:17:40 +0100 Subject: [PATCH 20/40] Fix creation of left menu --- htdocs/admin/menus/edit.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index 33a73147251..35707360e60 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -214,9 +214,9 @@ if ($action == 'add') $menu->target=GETPOST('target','alpha'); $menu->user=GETPOST('user','alpha'); $menu->mainmenu=GETPOST('propertymainmenu','alpha'); - if (is_numeric(GETPOST('menuId','int'))) + if (is_numeric(GETPOST('menuId','alpha'))) { - $menu->fk_menu=GETPOST('menuId','int'); + $menu->fk_menu=GETPOST('menuId','alpha'); } else { From d86017b8ff55c09d5c932c229b413e6acae43774 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 23:21:53 +0100 Subject: [PATCH 21/40] Fix create left menu entry --- htdocs/admin/menus/edit.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index 35707360e60..fde40ecdca5 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -144,6 +144,22 @@ if ($action == 'add') } $leftmenu=''; $mainmenu=''; + if (! empty($_POST['menuId']) && ! is_numeric($_POST['menuId'])) + { + $tmp=explode('&',$_POST['menuId']); + foreach($tmp as $s) + { + if (preg_match('/fk_mainmenu=/',$s)) + { + $mainmenu=preg_replace('/fk_mainmenu=/','',$s); + } + if (preg_match('/fk_leftmenu=/',$s)) + { + $leftmenu=preg_replace('/fk_leftmenu=/','',$s); + } + } + } + if (GETPOST('menuId', 'alpha') && ! is_numeric(GETPOST('menuId', 'alpha'))) { $tmp=explode('&', GETPOST('menuId', 'alpha')); From 2aae9527603a01a85ff6c0ae65a9abd7d7a48d3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Feb 2019 23:25:26 +0100 Subject: [PATCH 22/40] fix doc in tax.lib.php --- htdocs/core/lib/tax.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index 399983dbd16..884ff4fc922 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -86,7 +86,7 @@ function tax_prepare_head(ChargeSociales $object) * @param string $direction 'sell' or 'buy' * @param int $m Month * @param int $q Quarter - * @return array Array with details of VATs (per third parties), -1 if no accountancy module, -2 if not yet developped, -3 if error + * @return array|int Array with details of VATs (per third parties), -1 if no accountancy module, -2 if not yet developped, -3 if error */ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $direction, $m = 0, $q = 0) { @@ -111,7 +111,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di $paymentfacturetable='paiement_facture'; $invoicefieldref='ref'; } - if ($direction == 'buy') + elseif ($direction == 'buy') { $invoicetable='facture_fourn'; $invoicedettable='facture_fourn_det'; @@ -554,7 +554,7 @@ function tax_by_thirdparty($type, $db, $y, $date_start, $date_end, $modetax, $di * @param int $modetax Not used * @param int $direction 'sell' (customer invoice) or 'buy' (supplier invoices) * @param int $m Month - * @return array Array with details of VATs (per rate), -1 if no accountancy module, -2 if not yet developped, -3 if error + * @return array|int Array with details of VATs (per rate), -1 if no accountancy module, -2 if not yet developped, -3 if error */ function tax_by_rate($type, $db, $y, $q, $date_start, $date_end, $modetax, $direction, $m = 0) { From 11f48460b2c3912acfd2c0cbc7b6ace47ed39460 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 12 Feb 2019 23:26:25 +0100 Subject: [PATCH 23/40] Fix --- htdocs/admin/menus/edit.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/htdocs/admin/menus/edit.php b/htdocs/admin/menus/edit.php index fde40ecdca5..35707360e60 100644 --- a/htdocs/admin/menus/edit.php +++ b/htdocs/admin/menus/edit.php @@ -144,22 +144,6 @@ if ($action == 'add') } $leftmenu=''; $mainmenu=''; - if (! empty($_POST['menuId']) && ! is_numeric($_POST['menuId'])) - { - $tmp=explode('&',$_POST['menuId']); - foreach($tmp as $s) - { - if (preg_match('/fk_mainmenu=/',$s)) - { - $mainmenu=preg_replace('/fk_mainmenu=/','',$s); - } - if (preg_match('/fk_leftmenu=/',$s)) - { - $leftmenu=preg_replace('/fk_leftmenu=/','',$s); - } - } - } - if (GETPOST('menuId', 'alpha') && ! is_numeric(GETPOST('menuId', 'alpha'))) { $tmp=explode('&', GETPOST('menuId', 'alpha')); From fa31f95356e4bf168e5c7fa462886eccd7b19bbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Feb 2019 23:31:21 +0100 Subject: [PATCH 24/40] Update rssparser.class.php --- htdocs/core/class/rssparser.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/rssparser.class.php b/htdocs/core/class/rssparser.class.php index 155082f63f9..7683137767b 100644 --- a/htdocs/core/class/rssparser.class.php +++ b/htdocs/core/class/rssparser.class.php @@ -50,8 +50,8 @@ class RssParser private $_rssarray=array(); // For parsing with xmlparser - var $stack = array(); // parser stack - var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright'); + public $stack = array(); // parser stack + private $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright'); /** @@ -246,7 +246,7 @@ class RssParser $str = file_get_contents($this->_urlRSS, false, $context); } catch (Exception $e) { - print 'Error retrieving URL '.$this->urlRSS.' - '.$e->getMessage(); + print 'Error retrieving URL '.$this->_urlRSS.' - '.$e->getMessage(); } } From e4b73e827395ababd8c6d12a9c69d63b8e25b5af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Feb 2019 23:39:59 +0100 Subject: [PATCH 25/40] Update images.lib.php --- htdocs/core/lib/images.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php index a427cfd92e2..583167750eb 100644 --- a/htdocs/core/lib/images.lib.php +++ b/htdocs/core/lib/images.lib.php @@ -104,7 +104,7 @@ function dol_getImageSize($file, $url = false) * @param int $newHeight Hauteur maximum que dois faire l'image destination (0=keep ratio) * @param int $src_x Position of croping image in source image (not use if mode=0) * @param int $src_y Position of croping image in source image (not use if mode=0) - * @return int File name if OK, error message if KO + * @return string File name if OK, error message if KO */ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0, $src_y = 0) { From 56bbe41917e29255a37ed6cc922a1f88b18597ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 12 Feb 2019 23:54:38 +0100 Subject: [PATCH 26/40] Update facture-rec.class.php --- htdocs/compta/facture/class/facture-rec.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 8707b73262f..488fdaf21e8 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -960,7 +960,7 @@ class FactureRec extends CommonInvoice /** * Return the next date of * - * @return timestamp false if KO, timestamp if OK + * @return int|false false if KO, timestamp if OK */ function getNextDate() { From 26a77b0cbc4572da7787ebd2bdb62d1599b793e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 13 Feb 2019 00:06:51 +0100 Subject: [PATCH 27/40] Update supplier_proposal.class.php --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 388df5de61d..a5c6ee84e86 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -13,6 +13,7 @@ * Copyright (C) 2014 Marcos García * Copyright (C) 2016 Ferran Marcet * Copyright (C) 2018 Nicolas ZABOURI + * Copyright (C) 2019 Frédéric France * * 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 @@ -1814,7 +1815,7 @@ class SupplierProposal extends CommonObject * Upate ProductFournisseur * * @param int $idProductFournPrice id of llx_product_fournisseur_price - * @param int $product contain informations to update + * @param Product $product contain informations to update * @param User $user Object user * @return int <0 if KO, >0 if OK */ From 3de192364bd5081d8ab588339adc408c2d8b9f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 13 Feb 2019 00:12:20 +0100 Subject: [PATCH 28/40] Update ical.class.php --- htdocs/comm/action/class/ical.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index d005549636c..0cfb04b79a6 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -3,6 +3,7 @@ * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2013-2014 Laurent Destailleur * Copyright (C) 2012 Regis Houssin + * Copyright (C) 2019 Frédéric France * * 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 @@ -96,7 +97,7 @@ class ICal * Translate Calendar * * @param string $uri Url - * @return array + * @return array|string */ function parse($uri) { @@ -365,7 +366,7 @@ class ICal /** * Return sorted eventlist as array or false if calenar is empty * - * @return array + * @return array|false */ function get_sort_event_list() { From 95212e9cc129a6356668af5a048ff46c96db3512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 13 Feb 2019 00:44:34 +0100 Subject: [PATCH 29/40] Update ical.class.php --- htdocs/comm/action/class/ical.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/class/ical.class.php b/htdocs/comm/action/class/ical.class.php index 0cfb04b79a6..00efd44a1a7 100644 --- a/htdocs/comm/action/class/ical.class.php +++ b/htdocs/comm/action/class/ical.class.php @@ -364,7 +364,7 @@ class ICal // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Return sorted eventlist as array or false if calenar is empty + * Return sorted eventlist as array or false if calendar is empty * * @return array|false */ @@ -399,7 +399,7 @@ class ICal // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Return eventlist array (not sort eventlist array) + * Return eventlist array (not sorted eventlist array) * * @return array */ @@ -423,7 +423,7 @@ class ICal // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps /** - * Return to do array (not sort to do array) + * Return to do array (not sorted todo array) * * @return array */ From 5c059c897d6aad8483869d81239ff8e084ea354f Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 13 Feb 2019 09:21:14 +0100 Subject: [PATCH 30/40] fix travis (mosty for dev no conerne by my changes) --- htdocs/compta/compta-files.php | 2 +- htdocs/contact/consumption.php | 2 +- htdocs/core/class/cmeasuringunits.class.php | 4 +- .../core/class/commondocgenerator.class.php | 10 +- htdocs/core/class/cunits.class.php | 2 +- htdocs/core/lib/product.lib.php | 2 +- htdocs/margin/agentMargins.php | 22 +-- htdocs/product/stock/movement_card.php | 126 +++++++++--------- htdocs/projet/tasks/time.php | 2 +- .../class/html.formresource.class.php | 2 +- htdocs/webservices/server_category.php | 5 +- .../webservices/server_productorservice.php | 6 +- 12 files changed, 98 insertions(+), 87 deletions(-) diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index 23eff46da51..fa1aa068283 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -87,7 +87,7 @@ if ($user->societe_id > 0) $filesarray=array(); $result=false; -if(($action=="searchfiles"||$action=="dl" ) && $date_start && $date_stop){ +if(($action=="searchfiles" || $action=="dl" ) && $date_start && $date_stop) { $wheretail=" '".$db->idate($date_start)."' AND '".$db->idate($date_stop)."'"; $sql="SELECT rowid as id, ref as ref,paye as paid, total_ttc, fk_soc, datef as date, 'Invoice' as item FROM ".MAIN_DB_PREFIX."facture"; $sql.=" WHERE datef between ".$wheretail; diff --git a/htdocs/contact/consumption.php b/htdocs/contact/consumption.php index 4191563eaec..c39a23246e8 100644 --- a/htdocs/contact/consumption.php +++ b/htdocs/contact/consumption.php @@ -488,7 +488,7 @@ if ($sql_select) $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); } - if (($objp->info_bits & 2) == 2) { + if (($objp->info_bits & 2) == 2) { print ''; $txt=''; print img_object($langs->trans("ShowReduc"), 'reduc').' '; diff --git a/htdocs/core/class/cmeasuringunits.class.php b/htdocs/core/class/cmeasuringunits.class.php index e801969954b..718db8dab11 100644 --- a/htdocs/core/class/cmeasuringunits.class.php +++ b/htdocs/core/class/cmeasuringunits.class.php @@ -164,9 +164,11 @@ class CMeasuringUnits // extends CommonObject * Load object in memory from database * * @param int $id Id object + * @param string $unit_type unit type * @param string $code Code * @param string $label Label - * @return int <0 if KO, >0 if OK + * @param string $short_label Short Label + * @return int <0 if KO, >0 if OK */ function fetch($id, $unit_type='', $code = '', $short_label = '') { diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 235dde63096..98d7e720628 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -488,10 +488,10 @@ abstract class CommonDocGenerator if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); - + $totalUp += $line->subprice * $line->qty; } - + // @GS: Calculate total up and total discount percentage // Note that this added fields correspond to nothing in Dolibarr (Dolibarr manage discount on lines not globally) $resarray['object_total_up'] = $totalUp; @@ -501,7 +501,7 @@ abstract class CommonDocGenerator $resarray['object_total_discount_locale'] = price($resarray['object_total_discount'], 0, $outputlangs); } } - + // Retrieve extrafields if (is_array($object->array_options) && count($object->array_options)) { @@ -514,7 +514,7 @@ abstract class CommonDocGenerator $resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs); } - + return $resarray; } @@ -585,7 +585,7 @@ abstract class CommonDocGenerator $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true); $line->fetch_optionals(); - $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key=$array_key, $outputlangs); + $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs); // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" if (isset($line->fk_product) && $line->fk_product > 0) diff --git a/htdocs/core/class/cunits.class.php b/htdocs/core/class/cunits.class.php index 7afcb5ba8d2..351de8b7970 100644 --- a/htdocs/core/class/cunits.class.php +++ b/htdocs/core/class/cunits.class.php @@ -160,7 +160,7 @@ class CUnits // extends CommonObject * * @param int $id Id object * @param string $code Code - * @param string $label Label + * @param string $short_label Label * @return int <0 if KO, >0 if OK */ function fetch($id, $code = '', $short_label = '') diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 10107b37a01..1d4ca11c4d3 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -461,7 +461,6 @@ function show_stats_for_company($product, $socid) return $nblines++; } - /** * Return translation label of a unit key * @@ -476,6 +475,7 @@ function measuring_units_string($unit, $measuring_style = '') require_once DOL_DOCUMENT_ROOT.'/core/class/cmeasuringunits.class.php'; $measuringUnits= new CMeasuringUnits($db); $result=$measuringUnits->fetchAll('','', 0, 0, array('t.code'=> $unit,'t.unit_type'=>$measuring_style,'t.active'=>1)); + if ($result<0) { return -1; } else { diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 8bdbaac5861..8e5d0dc2b90 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -207,18 +207,18 @@ if ($result) print ""; print ''; - if ($agentid > 0) - print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); - else - print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); + if ($agentid > 0) + print_liste_field_titre("Customer", $_SERVER["PHP_SELF"], "s.nom", "", $param, '', $sortfield, $sortorder); + else + print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("SellingPrice",$_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice,$_SERVER["PHP_SELF"], "buying_price", "", $param,' align="right"', $sortfield, $sortorder); - print_liste_field_titre("Margin",$_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder); - if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); - if (! empty($conf->global->DISPLAY_MARK_RATES)) - print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, ' align="right"', $sortfield, $sortorder); + print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder); + if (! empty($conf->global->DISPLAY_MARGIN_RATES)) + print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); + if (! empty($conf->global->DISPLAY_MARK_RATES)) + print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); print "\n"; $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index abf7d21284b..c1c8842af08 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -47,17 +47,17 @@ $langs->loadLangs(array('products', 'stocks', 'orders')); if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); // Security check -$result=restrictedArea($user,'stock'); +$result = restrictedArea($user, 'stock'); -$id=GETPOST('id','int'); -$ref = GETPOST('ref','alpha'); -$msid=GETPOST('msid','int'); -$product_id=GETPOST("product_id"); -$action=GETPOST('action','aZ09'); -$cancel=GETPOST('cancel','alpha'); -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist'; +$id = GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$msid = GETPOST('msid', 'int'); +$product_id = GETPOST("product_id"); +$action = GETPOST('action', 'aZ09'); +$cancel = GETPOST('cancel', 'alpha'); +$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'movementlist'; -$idproduct = GETPOST('idproduct','int'); +$idproduct = GETPOST('idproduct', 'int'); $year = GETPOST("year"); $month = GETPOST("month"); $search_ref = GETPOST('search_ref', 'alpha'); @@ -69,16 +69,20 @@ $search_inventorycode = trim(GETPOST("search_inventorycode")); $search_user = trim(GETPOST("search_user")); $search_batch = trim(GETPOST("search_batch")); $search_qty = trim(GETPOST("search_qty")); -$search_type_mouvement=GETPOST('search_type_mouvement','int'); +$search_type_mouvement = GETPOST('search_type_mouvement', 'int'); -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; -$page = GETPOST("page",'int'); -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; +$page = GETPOST("page", 'int'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +if (empty($page) || $page == - 1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; -if (! $sortfield) $sortfield="m.datem"; -if (! $sortorder) $sortorder="DESC"; +if (! $sortfield) + $sortfield = "m.datem"; +if (! $sortorder) + $sortorder = "DESC"; $pdluoid=GETPOST('pdluoid','int'); @@ -118,12 +122,12 @@ $arrayfields=array( * Actions */ -$usercanread = (($user->rights->stock->mouvement->lire)); -$usercancreate = (($user->rights->stock->mouvement->creer)); -$usercandelete = (($user->rights->stock->mouvement->supprimer)); +$usercanread = $user->rights->stock->mouvement->lire; +$usercancreate = $user->rights->stock->mouvement->creer; +$usercandelete = $user->rights->stock->mouvement->supprimer; -if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -187,17 +191,17 @@ if ($action == "correct_stock") { $batch=GETPOST('batch_number'); - //$eatby=GETPOST('eatby'); - //$sellby=GETPOST('sellby'); - $eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); - $sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); + // $eatby=GETPOST('eatby'); + // $sellby=GETPOST('sellby'); + $eatby = dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); + $sellby = dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); $result=$product->correct_stock_batch( $user, $id, - GETPOST("nbpiece",'int'), + GETPOST("nbpiece", 'int'), GETPOST("mouvement"), - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), GETPOST('unitprice'), $eatby,$sellby,$batch, GETPOST('inventorycode'), @@ -210,9 +214,9 @@ if ($action == "correct_stock") $result=$product->correct_stock( $user, $id, - GETPOST("nbpiece",'int'), + GETPOST("nbpiece", 'int'), GETPOST("mouvement"), - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), GETPOST('unitprice'), GETPOST('inventorycode'), $origin_element, @@ -242,7 +246,7 @@ if ($action == "transfert_stock" && ! $cancel) $product = new Product($db); if (! empty($product_id)) $result=$product->fetch($product_id); - if (! (GETPOST("id_entrepot_destination",'int') > 0)) + if (! (GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; @@ -260,7 +264,7 @@ if ($action == "transfert_stock" && ! $cancel) $error++; $action='transfert'; } - if ($id == GETPOST("id_entrepot_destination",'int')) + if ($id == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; @@ -330,9 +334,9 @@ if ($action == "transfert_stock" && ! $cancel) $result1=$product->correct_stock_batch( $user, $srcwarehouseid, - GETPOST("nbpiece",'int'), + GETPOST("nbpiece", 'int'), 1, - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), $pricesrc, $eatby,$sellby,$batch, GETPOST('inventorycode') @@ -340,10 +344,10 @@ if ($action == "transfert_stock" && ! $cancel) // Add stock $result2=$product->correct_stock_batch( $user, - GETPOST("id_entrepot_destination",'int'), - GETPOST("nbpiece",'int'), + GETPOST("id_entrepot_destination", 'int'), + GETPOST("nbpiece", 'int'), 0, - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), $pricedest, $eatby,$sellby,$batch, GETPOST('inventorycode') @@ -447,7 +451,7 @@ $sql.= " u.login, u.photo, u.lastname, u.firstname"; foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",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 +$reshook=$hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product as p,"; @@ -464,13 +468,13 @@ if ($id > 0) $sql.= " AND e.rowid ='".$id."'"; if ($month > 0) { if ($year > 0) - $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, $month, false))."' AND '".$db->idate(dol_get_last_day($year, $month, false))."'"; else $sql.= " AND date_format(m.datem, '%m') = '$month'"; } elseif ($year > 0) { - $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'"; if (! empty($search_ref)) $sql.= natural_search('m.rowid', $search_ref, 1); @@ -487,9 +491,9 @@ if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql.= natur include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -568,7 +572,7 @@ if ($resql) $morehtmlref.=''; $shownav = 1; - if ($user->societe_id && ! in_array('stock', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->societe_id && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); @@ -609,7 +613,7 @@ if ($resql) // Value print '"; // Last movement @@ -743,7 +747,7 @@ if ($resql) $moreforfilter=''; $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -883,7 +887,7 @@ if ($resql) // Fields from hook $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['m.datec']['checked'])) @@ -925,12 +929,14 @@ if ($resql) include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook + $parameters=array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); + $reshook=$hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['m.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['m.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + if (! empty($arrayfields['m.datec']['checked'])) + print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (! empty($arrayfields['m.tms']['checked'])) + print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -978,13 +984,13 @@ if ($resql) if (! empty($arrayfields['m.datem']['checked'])) { // Date - print ''; + print ''; } if (! empty($arrayfields['p.ref']['checked'])) { // Product ref print '\n"; } if (! empty($arrayfields['p.label']['checked'])) @@ -1007,11 +1013,11 @@ if ($resql) } if (! empty($arrayfields['pl.eatby']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['pl.sellby']['checked'])) { - print ''; + print ''; } // Warehouse if (! empty($arrayfields['e.ref']['checked'])) @@ -1114,20 +1120,20 @@ if ($resql) $productidselected=$key; $productlabelselected=$val; } - $datebefore=dol_get_first_day($year?$year:strftime("%Y",time()), $month?$month:1, true); - $dateafter=dol_get_last_day($year?$year:strftime("%Y",time()), $month?$month:12, true); + $datebefore=dol_get_first_day($year?$year:strftime("%Y", time()), $month?$month:1, true); + $dateafter=dol_get_last_day($year?$year:strftime("%Y", time()), $month?$month:12, true); $balancebefore=$movement->calculateBalanceForProductBefore($productidselected, $datebefore); $balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter); //print ''; //print ''; //print ''; //print '\n"; print ''; - if (! empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'],$_SERVER["PHP_SELF"],'m.rowid','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'],$_SERVER["PHP_SELF"],'m.datem','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'],$_SERVER["PHP_SELF"],'p.label','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'],$_SERVER["PHP_SELF"],'m.batch','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'],$_SERVER["PHP_SELF"],'pl.eatby','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'],$_SERVER["PHP_SELF"],'pl.sellby','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'],$_SERVER["PHP_SELF"], "e.ref","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible - if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'],$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'],$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'],$_SERVER["PHP_SELF"], "m.type_mouvement","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['m.rowid']['checked'])) + print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['m.datem']['checked'])) + print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['p.ref']['checked'])) + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['p.label']['checked'])) + print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['m.batch']['checked'])) + print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['pl.eatby']['checked'])) + print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['pl.sellby']['checked'])) + print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['e.ref']['checked'])) + print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); // We are on a specific warehouse card, no filter on other should be possible + if (! empty($arrayfields['m.fk_user_author']['checked'])) + print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.inventorycode']['checked'])) + print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.label']['checked'])) + print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.type_mouvement']['checked'])) + print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['origin']['checked'])) + print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.value']['checked'])) + print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, 'align="right"', $sortfield, $sortorder); + if (! empty($arrayfields['m.price']['checked'])) + print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, 'align="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -942,7 +960,7 @@ if ($resql) $arrayofuniqueproduct=array(); - while ($i < min($num,$limit)) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); @@ -1054,20 +1072,21 @@ if ($resql) if (! empty($arrayfields['m.type_mouvement']['checked'])) { // Type of movement - switch($objp->type_mouvement){ - case "0": - print ''; - break; - case "1": - print ''; - break; - case "2": - print ''; - break; - case "3": - print ''; - break; - } + switch($objp->type_mouvement) + { + case "0": + print ''; + break; + case "1": + print ''; + break; + case "2": + print ''; + break; + case "3": + print ''; + break; + } } if (! empty($arrayfields['origin']['checked'])) { From ced386fdca5f7e84f2c9b174d4e77bd8b463fe14 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Feb 2019 11:32:00 +0100 Subject: [PATCH 32/40] Fix phpcs --- .../core/class/commondocgenerator.class.php | 10 +- htdocs/margin/agentMargins.php | 10 +- htdocs/product/stock/movement_card.php | 136 +++++++++--------- htdocs/projet/tasks/time.php | 4 +- .../class/html.formresource.class.php | 2 +- 5 files changed, 81 insertions(+), 81 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 235dde63096..98d7e720628 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -488,10 +488,10 @@ abstract class CommonDocGenerator if (empty($resarray[$array_key.'_total_vat_'.$vatformated])) $resarray[$array_key.'_total_vat_'.$vatformated]=0; $resarray[$array_key.'_total_vat_'.$vatformated]+=$line->total_tva; $resarray[$array_key.'_total_vat_locale_'.$vatformated]=price($resarray[$array_key.'_total_vat_'.$vatformated]); - + $totalUp += $line->subprice * $line->qty; } - + // @GS: Calculate total up and total discount percentage // Note that this added fields correspond to nothing in Dolibarr (Dolibarr manage discount on lines not globally) $resarray['object_total_up'] = $totalUp; @@ -501,7 +501,7 @@ abstract class CommonDocGenerator $resarray['object_total_discount_locale'] = price($resarray['object_total_discount'], 0, $outputlangs); } } - + // Retrieve extrafields if (is_array($object->array_options) && count($object->array_options)) { @@ -514,7 +514,7 @@ abstract class CommonDocGenerator $resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs); } - + return $resarray; } @@ -585,7 +585,7 @@ abstract class CommonDocGenerator $extralabels = $extrafields->fetch_name_optionals_label($extrafieldkey, true); $line->fetch_optionals(); - $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key=$array_key, $outputlangs); + $resarray = $this->fill_substitutionarray_with_extrafields($line, $resarray, $extrafields, $array_key, $outputlangs); // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" if (isset($line->fk_product) && $line->fk_product > 0) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 8bdbaac5861..197c912494a 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -212,13 +212,13 @@ if ($result) else print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("SellingPrice",$_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice,$_SERVER["PHP_SELF"], "buying_price", "", $param,' align="right"', $sortfield, $sortorder); - print_liste_field_titre("Margin",$_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param,' align="right"', $sortfield, $sortorder); + print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder); if (! empty($conf->global->DISPLAY_MARGIN_RATES)) - print_liste_field_titre("MarginRate",$_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); if (! empty($conf->global->DISPLAY_MARK_RATES)) - print_liste_field_titre("MarkRate",$_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); + print_liste_field_titre("MarkRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); print "\n"; $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT, $conf->global->MAIN_MAX_DECIMALS_TOT); diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index abf7d21284b..fcfa26bb832 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -49,38 +49,38 @@ if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); // Security check $result=restrictedArea($user,'stock'); -$id=GETPOST('id','int'); -$ref = GETPOST('ref','alpha'); -$msid=GETPOST('msid','int'); -$product_id=GETPOST("product_id"); -$action=GETPOST('action','aZ09'); -$cancel=GETPOST('cancel','alpha'); -$contextpage=GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'movementlist'; +$id=GETPOST('id', 'int'); +$ref = GETPOST('ref', 'alpha'); +$msid=GETPOST('msid', 'int'); +$product_id=GETPOST("product_id", 'int'); +$action=GETPOST('action', 'aZ09'); +$cancel=GETPOST('cancel', 'alpha'); +$contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'movementlist'; -$idproduct = GETPOST('idproduct','int'); -$year = GETPOST("year"); -$month = GETPOST("month"); +$idproduct = GETPOST('idproduct', 'int'); +$year = GETPOST("year", 'int'); +$month = GETPOST("month", 'int'); $search_ref = GETPOST('search_ref', 'alpha'); -$search_movement = GETPOST("search_movement"); -$search_product_ref = trim(GETPOST("search_product_ref")); -$search_product = trim(GETPOST("search_product")); -$search_warehouse = trim(GETPOST("search_warehouse")); -$search_inventorycode = trim(GETPOST("search_inventorycode")); -$search_user = trim(GETPOST("search_user")); -$search_batch = trim(GETPOST("search_batch")); -$search_qty = trim(GETPOST("search_qty")); +$search_movement = GETPOST("search_movement", 'alpha'); +$search_product_ref = trim(GETPOST("search_product_ref", 'alpha')); +$search_product = trim(GETPOST("search_product", 'alpha')); +$search_warehouse = trim(GETPOST("search_warehouse", 'alpha')); +$search_inventorycode = trim(GETPOST("search_inventorycode", 'alpha')); +$search_user = trim(GETPOST("search_user", 'alpha')); +$search_batch = trim(GETPOST("search_batch", 'alpha')); +$search_qty = trim(GETPOST("search_qty", 'alpha')); $search_type_mouvement=GETPOST('search_type_mouvement','int'); -$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; -$page = GETPOST("page",'int'); -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); +$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$page = GETPOST("page", 'int'); +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 $offset = $limit * $page; if (! $sortfield) $sortfield="m.datem"; if (! $sortorder) $sortorder="DESC"; -$pdluoid=GETPOST('pdluoid','int'); +$pdluoid=GETPOST('pdluoid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new MouvementStock($db); @@ -90,7 +90,7 @@ $formfile = new FormFile($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('movement'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); +$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $arrayfields=array( 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), @@ -132,7 +132,7 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Do we click on purge search criteria ? -if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { $year=''; $month=''; @@ -185,22 +185,22 @@ if ($action == "correct_stock") if ($product->hasbatch()) { - $batch=GETPOST('batch_number'); + $batch=GETPOST('batch_number', 'alpha'); //$eatby=GETPOST('eatby'); //$sellby=GETPOST('sellby'); - $eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth'), GETPOST('eatbyday'), GETPOST('eatbyyear')); - $sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth'), GETPOST('sellbyday'), GETPOST('sellbyyear')); + $eatby=dol_mktime(0, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); + $sellby=dol_mktime(0, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); $result=$product->correct_stock_batch( $user, $id, - GETPOST("nbpiece",'int'), - GETPOST("mouvement"), - GETPOST("label",'san_alpha'), - GETPOST('unitprice'), + GETPOST("nbpiece", 'int'), + GETPOST("mouvement", 'int'), + GETPOST("label", 'san_alpha'), + GETPOST('unitprice', 'alpha'), $eatby,$sellby,$batch, - GETPOST('inventorycode'), + GETPOST('inventorycode', 'alpha'), $origin_element, $origin_id ); // We do not change value of stock for a correction @@ -210,11 +210,11 @@ if ($action == "correct_stock") $result=$product->correct_stock( $user, $id, - GETPOST("nbpiece",'int'), - GETPOST("mouvement"), + GETPOST("nbpiece", 'int'), + GETPOST("mouvement", 'alpha'), GETPOST("label",'san_alpha'), - GETPOST('unitprice'), - GETPOST('inventorycode'), + GETPOST('unitprice', 'alpha'), + GETPOST('inventorycode', 'alpha'), $origin_element, $origin_id ); // We do not change value of stock for a correction @@ -242,7 +242,7 @@ if ($action == "transfert_stock" && ! $cancel) $product = new Product($db); if (! empty($product_id)) $result=$product->fetch($product_id); - if (! (GETPOST("id_entrepot_destination",'int') > 0)) + if (! (GETPOST("id_entrepot_destination", 'int') > 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Warehouse")), null, 'errors'); $error++; @@ -272,7 +272,7 @@ if ($action == "transfert_stock" && ! $cancel) $product = new Product($db); $result=$product->fetch($product_id); - if ($product->hasbatch() && ! GETPOST("batch_number")) + if ($product->hasbatch() && ! GETPOST("batch_number", 'alpha')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("batch_number")), null, 'errors'); $error++; @@ -319,7 +319,7 @@ if ($action == "transfert_stock" && ! $cancel) else { $srcwarehouseid=$id; - $batch=GETPOST('batch_number'); + $batch=GETPOST('batch_number', 'alpha'); $eatby=$d_eatby; $sellby=$d_sellby; } @@ -330,23 +330,23 @@ if ($action == "transfert_stock" && ! $cancel) $result1=$product->correct_stock_batch( $user, $srcwarehouseid, - GETPOST("nbpiece",'int'), + GETPOST("nbpiece", 'int'), 1, - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), $pricesrc, $eatby,$sellby,$batch, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alpha') ); // Add stock $result2=$product->correct_stock_batch( $user, - GETPOST("id_entrepot_destination",'int'), - GETPOST("nbpiece",'int'), + GETPOST("id_entrepot_destination", 'int'), + GETPOST("nbpiece", 'int'), 0, - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), $pricedest, $eatby,$sellby,$batch, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alpha') ); } } @@ -356,22 +356,22 @@ if ($action == "transfert_stock" && ! $cancel) $result1=$product->correct_stock( $user, $id, - GETPOST("nbpiece"), + GETPOST("nbpiece", 'int'), 1, - GETPOST("label"), + GETPOST("label", 'alpha'), $pricesrc, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alpha') ); // Add stock $result2=$product->correct_stock( $user, GETPOST("id_entrepot_destination"), - GETPOST("nbpiece"), + GETPOST("nbpiece", 'int'), 0, - GETPOST("label"), + GETPOST("label", 'alpha'), $pricedest, - GETPOST('inventorycode') + GETPOST('inventorycode', 'alpha') ); } if (! $error && $result1 >= 0 && $result2 >= 0) @@ -568,7 +568,7 @@ if ($resql) $morehtmlref.=''; $shownav = 1; - if ($user->societe_id && ! in_array('stock', explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; + if ($user->societe_id && ! in_array('stock', explode(',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav=0; dol_banner_tab($object, 'ref', $linkback, $shownav, 'ref', 'ref', $morehtmlref); @@ -693,9 +693,9 @@ if ($resql) } $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; - if ($id > 0) $param.='&id='.$id; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); + if ($id > 0) $param.='&id='.urlencode($id); if ($search_movement) $param.='&search_movement='.urlencode($search_movement); if ($search_inventorycode) $param.='&search_inventorycode='.urlencode($search_inventorycode); if ($search_type_mouvement) $param.='&search_type_mouvement='.urlencode($search_type_mouvement); @@ -706,7 +706,7 @@ if ($resql) if (!empty($sref)) $param.='&sref='.urlencode($sref); // FIXME $sref is not defined if (!empty($snom)) $param.='&snom='.urlencode($snom); // FIXME $snom is not defined if ($search_user) $param.='&search_user='.urlencode($search_user); - if ($idproduct > 0) $param.='&idproduct='.$idproduct; + if ($idproduct > 0) $param.='&idproduct='.urlencode($idproduct); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -737,7 +737,7 @@ if ($resql) if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; } $moreforfilter=''; @@ -928,9 +928,9 @@ if ($resql) $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['m.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'],$_SERVER["PHP_SELF"],"p.datec","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - if (! empty($arrayfields['m.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'],$_SERVER["PHP_SELF"],"p.tms","",$param,'align="center" class="nowrap"',$sortfield,$sortorder); - print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"],"",'','','align="center"',$sortfield,$sortorder,'maxwidthsearch '); + if (! empty($arrayfields['m.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'] ,$_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (! empty($arrayfields['m.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -978,7 +978,7 @@ if ($resql) if (! empty($arrayfields['m.datem']['checked'])) { // Date - print ''; + print ''; } if (! empty($arrayfields['p.ref']['checked'])) { @@ -1007,11 +1007,11 @@ if ($resql) } if (! empty($arrayfields['pl.eatby']['checked'])) { - print ''; + print ''; } if (! empty($arrayfields['pl.sellby']['checked'])) { - print ''; + print ''; } // Warehouse if (! empty($arrayfields['e.ref']['checked'])) @@ -1120,14 +1120,14 @@ if ($resql) $balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter); //print ''; //print ''; //print ''; //print '\n"; print ''; - if (! empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'],$_SERVER["PHP_SELF"],'m.rowid','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'],$_SERVER["PHP_SELF"],'m.datem','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'],$_SERVER["PHP_SELF"],'p.label','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'],$_SERVER["PHP_SELF"],'m.batch','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'],$_SERVER["PHP_SELF"],'pl.eatby','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'],$_SERVER["PHP_SELF"],'pl.sellby','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'],$_SERVER["PHP_SELF"], "e.ref","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible - if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'],$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'],$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'],$_SERVER["PHP_SELF"], "m.type_mouvement","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param,'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", '', $param, "", $sortfield, $sortorder); // We are on a specific warehouse card, no filter on other should be possible + if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, 'align="right"', $sortfield, $sortorder); + if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, 'align="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -928,12 +934,11 @@ if ($resql) $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; - if (! empty($arrayfields['m.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'] ,$_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (! empty($arrayfields['m.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); if (! empty($arrayfields['m.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; - $arrayofuniqueproduct=array(); while ($i < min($num,$limit)) @@ -984,7 +989,7 @@ if ($resql) { // Product ref print '\n"; } if (! empty($arrayfields['p.label']['checked'])) From 9caefc9483ac8ad99c5233d6c429382516a04b43 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 13 Feb 2019 13:50:57 +0100 Subject: [PATCH 36/40] fix travis --- htdocs/product/stock/movement_card.php | 122 ++++++++++++++----------- 1 file changed, 71 insertions(+), 51 deletions(-) diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index fcfa26bb832..feea4ceb121 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -125,9 +125,10 @@ $usercandelete = (($user->rights->stock->mouvement->supprimer)); if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // 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'; @@ -219,19 +220,16 @@ if ($action == "correct_stock") $origin_id ); // We do not change value of stock for a correction } - - if ($result > 0) - { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); - exit; - } - else - { - $error++; - setEventMessages($product->error, $product->errors, 'errors'); - $action='correction'; - } - } + if ($result > 0) + { + header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id); + exit(); + } else { + $error ++; + setEventMessages($product->error, $product->errors, 'errors'); + $action = 'correction'; + } + } if (! $error) $action=''; } @@ -260,7 +258,7 @@ if ($action == "transfert_stock" && ! $cancel) $error++; $action='transfert'; } - if ($id == GETPOST("id_entrepot_destination",'int')) + if ($id == GETPOST("id_entrepot_destination", 'int')) { setEventMessages($langs->trans("ErrorSrcAndTargetWarehouseMustDiffers"), null, 'errors'); $error++; @@ -446,8 +444,8 @@ $sql.= " u.login, u.photo, u.lastname, u.firstname"; // Add fields from extrafields foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",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 +$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."entrepot as e,"; $sql.= " ".MAIN_DB_PREFIX."product as p,"; @@ -464,13 +462,13 @@ if ($id > 0) $sql.= " AND e.rowid ='".$id."'"; if ($month > 0) { if ($year > 0) - $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, $month, false))."' AND '".$db->idate(dol_get_last_day($year, $month, false))."'"; else $sql.= " AND date_format(m.datem, '%m') = '$month'"; } elseif ($year > 0) { - $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'"; if (! empty($search_ref)) $sql.= natural_search('m.rowid', $search_ref, 1); @@ -487,7 +485,7 @@ if ($search_type_mouvement != '' && $search_type_mouvement != '-1') $sql.= natur include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks $parameters=array(); -$reshook=$hookmanager->executeHooks('printFieldListWhere',$parameters); // Note that $action and $object may have been modified by hook +$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; $sql.= $db->order($sortfield,$sortorder); @@ -549,7 +547,7 @@ if ($resql) $texte = $langs->trans("ListOfStockMovements"); if ($id) $texte.=' ('.$langs->trans("ForThisWarehouse").')'; } - llxHeader("",$texte,$help_url); + llxHeader("", $texte, $help_url); /* * Show tab only if we ask a particular warehouse @@ -609,7 +607,7 @@ if ($resql) // Value print '"; // Last movement @@ -731,8 +729,8 @@ if ($resql) print ''; if ($id > 0) print ''; - if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,$massactionbutton,$num, $nbtotalofrecords, '', 0, '', '', $limit); - else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,$massactionbutton,$num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); + if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,$massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); + else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,$massactionbutton, $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); if ($sall) { @@ -743,7 +741,7 @@ if ($resql) $moreforfilter=''; $parameters=array(); - $reshook=$hookmanager->executeHooks('printFieldPreListTitle',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; else $moreforfilter = $hookmanager->resPrint; @@ -905,31 +903,53 @@ if ($resql) print "\n"; print ''; - if (! empty($arrayfields['m.rowid']['checked'])) print_liste_field_titre($arrayfields['m.rowid']['label'],$_SERVER["PHP_SELF"],'m.rowid','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['m.datem']['checked'])) print_liste_field_titre($arrayfields['m.datem']['label'],$_SERVER["PHP_SELF"],'m.datem','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.ref']['checked'])) print_liste_field_titre($arrayfields['p.ref']['label'],$_SERVER["PHP_SELF"],'p.ref','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['p.label']['checked'])) print_liste_field_titre($arrayfields['p.label']['label'],$_SERVER["PHP_SELF"],'p.label','',$param,'',$sortfield,$sortorder); - if (! empty($arrayfields['m.batch']['checked'])) print_liste_field_titre($arrayfields['m.batch']['label'],$_SERVER["PHP_SELF"],'m.batch','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['pl.eatby']['checked'])) print_liste_field_titre($arrayfields['pl.eatby']['label'],$_SERVER["PHP_SELF"],'pl.eatby','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['pl.sellby']['checked'])) print_liste_field_titre($arrayfields['pl.sellby']['label'],$_SERVER["PHP_SELF"],'pl.sellby','',$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['e.ref']['checked'])) print_liste_field_titre($arrayfields['e.ref']['label'],$_SERVER["PHP_SELF"], "e.ref","",$param,"",$sortfield,$sortorder); // We are on a specific warehouse card, no filter on other should be possible - if (! empty($arrayfields['m.fk_user_author']['checked'])) print_liste_field_titre($arrayfields['m.fk_user_author']['label'],$_SERVER["PHP_SELF"], "m.fk_user_author","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.inventorycode']['checked'])) print_liste_field_titre($arrayfields['m.inventorycode']['label'],$_SERVER["PHP_SELF"], "m.inventorycode","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.label']['checked'])) print_liste_field_titre($arrayfields['m.label']['label'],$_SERVER["PHP_SELF"], "m.label","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.type_mouvement']['checked'])) print_liste_field_titre($arrayfields['m.type_mouvement']['label'],$_SERVER["PHP_SELF"], "m.type_mouvement","",$param,'align="center"',$sortfield,$sortorder); - if (! empty($arrayfields['origin']['checked'])) print_liste_field_titre($arrayfields['origin']['label'],$_SERVER["PHP_SELF"], "","",$param,"",$sortfield,$sortorder); - if (! empty($arrayfields['m.value']['checked'])) print_liste_field_titre($arrayfields['m.value']['label'],$_SERVER["PHP_SELF"], "m.value","",$param,'align="right"',$sortfield,$sortorder); - if (! empty($arrayfields['m.price']['checked'])) print_liste_field_titre($arrayfields['m.price']['label'],$_SERVER["PHP_SELF"], "m.price","",$param,'align="right"',$sortfield,$sortorder); + if (! empty($arrayfields['m.rowid']['checked'])) + print_liste_field_titre($arrayfields['m.rowid']['label'], $_SERVER["PHP_SELF"], 'm.rowid', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['m.datem']['checked'])) + print_liste_field_titre($arrayfields['m.datem']['label'], $_SERVER["PHP_SELF"], 'm.datem', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['p.ref']['checked'])) + print_liste_field_titre($arrayfields['p.ref']['label'], $_SERVER["PHP_SELF"], 'p.ref', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['p.label']['checked'])) + print_liste_field_titre($arrayfields['p.label']['label'], $_SERVER["PHP_SELF"], 'p.label', '', $param, '', $sortfield, $sortorder); + if (! empty($arrayfields['m.batch']['checked'])) + print_liste_field_titre($arrayfields['m.batch']['label'], $_SERVER["PHP_SELF"], 'm.batch', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['pl.eatby']['checked'])) + print_liste_field_titre($arrayfields['pl.eatby']['label'], $_SERVER["PHP_SELF"], 'pl.eatby', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['pl.sellby']['checked'])) + print_liste_field_titre($arrayfields['pl.sellby']['label'], $_SERVER["PHP_SELF"], 'pl.sellby', '', $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['e.ref']['checked'])) + print_liste_field_titre($arrayfields['e.ref']['label'], $_SERVER["PHP_SELF"], "e.ref", "", $param, "", $sortfield, $sortorder); // We are on a specific warehouse card, no filter on other should be possible + if (! empty($arrayfields['m.fk_user_author']['checked'])) + print_liste_field_titre($arrayfields['m.fk_user_author']['label'], $_SERVER["PHP_SELF"], "m.fk_user_author", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.inventorycode']['checked'])) + print_liste_field_titre($arrayfields['m.inventorycode']['label'], $_SERVER["PHP_SELF"], "m.inventorycode", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.label']['checked'])) + print_liste_field_titre($arrayfields['m.label']['label'], $_SERVER["PHP_SELF"], "m.label", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.type_mouvement']['checked'])) + print_liste_field_titre($arrayfields['m.type_mouvement']['label'], $_SERVER["PHP_SELF"], "m.type_mouvement", "", $param, 'align="center"', $sortfield, $sortorder); + if (! empty($arrayfields['origin']['checked'])) + print_liste_field_titre($arrayfields['origin']['label'], $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['m.value']['checked'])) + print_liste_field_titre($arrayfields['m.value']['label'], $_SERVER["PHP_SELF"], "m.value", "", $param, 'align="right"', $sortfield, $sortorder); + if (! empty($arrayfields['m.price']['checked'])) + print_liste_field_titre($arrayfields['m.price']['label'], $_SERVER["PHP_SELF"], "m.price", "", $param, 'align="right"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; - // Hook fields - $parameters=array('arrayfields'=>$arrayfields,'param'=>$param,'sortfield'=>$sortfield,'sortorder'=>$sortorder); - $reshook=$hookmanager->executeHooks('printFieldListTitle',$parameters); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (! empty($arrayfields['m.datec']['checked'])) print_liste_field_titre($arrayfields['p.datec']['label'] ,$_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); - if (! empty($arrayfields['m.tms']['checked'])) print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + // Hook fields + $parameters = array( + 'arrayfields' => $arrayfields, + 'param' => $param, + 'sortfield' => $sortfield, + 'sortorder' => $sortorder + ); + $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; + if (! empty($arrayfields['m.datec']['checked'])) + print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); + if (! empty($arrayfields['m.tms']['checked'])) + print_liste_field_titre($arrayfields['p.tms']['label'], $_SERVER["PHP_SELF"], "p.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -984,7 +1004,7 @@ if ($resql) { // Product ref print '\n"; } if (! empty($arrayfields['p.label']['checked'])) @@ -1114,8 +1134,8 @@ if ($resql) $productidselected=$key; $productlabelselected=$val; } - $datebefore=dol_get_first_day($year?$year:strftime("%Y",time()), $month?$month:1, true); - $dateafter=dol_get_last_day($year?$year:strftime("%Y",time()), $month?$month:12, true); + $datebefore=dol_get_first_day($year?$year:strftime("%Y", time()), $month?$month:1, true); + $dateafter=dol_get_last_day($year?$year:strftime("%Y", time()), $month?$month:12, true); $balancebefore=$movement->calculateBalanceForProductBefore($productidselected, $datebefore); $balanceafter=$movement->calculateBalanceForProductBefore($productidselected, $dateafter); From 020fa52507e73c84f2cfaad4848127bdf5a3e4bc Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 13 Feb 2019 15:30:20 +0100 Subject: [PATCH 37/40] travis --- htdocs/product/stock/movement_card.php | 54 +++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index 919e8b01315..3dd9b7f8920 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -47,7 +47,7 @@ $langs->loadLangs(array('products', 'stocks', 'orders')); if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); // Security check -$result=restrictedArea($user,'stock'); +$result=restrictedArea($user, 'stock'); $id=GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -69,7 +69,7 @@ $search_inventorycode = trim(GETPOST("search_inventorycode", 'alpha')); $search_user = trim(GETPOST("search_user", 'alpha')); $search_batch = trim(GETPOST("search_batch", 'alpha')); $search_qty = trim(GETPOST("search_qty", 'alpha')); -$search_type_mouvement=GETPOST('search_type_mouvement','int'); +$search_type_mouvement=GETPOST('search_type_mouvement', 'int'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $page = GETPOST("page", 'int'); @@ -122,8 +122,8 @@ $usercanread = (($user->rights->stock->mouvement->lire)); $usercancreate = (($user->rights->stock->mouvement->creer)); $usercandelete = (($user->rights->stock->mouvement->supprimer)); -if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks @@ -214,7 +214,7 @@ if ($action == "correct_stock") $id, GETPOST("nbpiece", 'int'), GETPOST("mouvement", 'alpha'), - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), GETPOST('unitprice', 'alpha'), GETPOST('inventorycode', 'alpha'), $origin_element, @@ -253,7 +253,7 @@ if ($action == "transfert_stock" && ! $cancel) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action='transfert'; } - if (! GETPOST("nbpiece",'int')) + if (! GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; @@ -492,7 +492,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; $parameters=array(); $reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook $sql.=$hookmanager->resPrint; -$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) @@ -633,7 +633,7 @@ if ($resql) print ''; - break; - case "1": - print ''; - break; - case "2": - print ''; - break; - case "3": - print ''; - break; - } + // Type of movement + switch ($objp->type_mouvement) { + case "0" : + print ''; + break; + case "1" : + print ''; + break; + case "2" : + print ''; + break; + case "3" : + print ''; + break; + } } if (! empty($arrayfields['origin']['checked'])) { From c2ab85aaf8d42b4bf81e42b713aca7cae5d234a7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Feb 2019 16:39:17 +0100 Subject: [PATCH 38/40] Update api_proposals.class.php --- htdocs/comm/propal/class/api_proposals.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/class/api_proposals.class.php b/htdocs/comm/propal/class/api_proposals.class.php index 415a5ae6e78..a9bc15ef088 100644 --- a/htdocs/comm/propal/class/api_proposals.class.php +++ b/htdocs/comm/propal/class/api_proposals.class.php @@ -58,7 +58,7 @@ class Proposals extends DolibarrApi * Return an array with commercial proposal informations * * @param int $id ID of commercial proposal - * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @return array|mixed data without useless information * * @throws RestException From a39b4bcb7d812d211221845703d11ff4e96ed881 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Feb 2019 16:39:45 +0100 Subject: [PATCH 39/40] Update api_orders.class.php --- htdocs/commande/class/api_orders.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 00e635856b7..acb2106065c 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -57,7 +57,7 @@ class Orders extends DolibarrApi * Return an array with order informations * * @param int $id ID of order - * @param int $contact_list 0:Return array contains all properties, 1:Return array contains just id + * @param int $contact_list 0: Returned array of contacts/addresses contains all properties, 1: Return array contains just id * @return array|mixed data without useless information * * @throws RestException From 23a52b54e7f9dee78b934ebcfe8167caef2baa3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Feb 2019 22:46:24 +0100 Subject: [PATCH 40/40] Fix php 7.3 --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b473254d231..9fcd300e224 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,7 +60,6 @@ matrix: fast_finish: true allow_failures: - php: nightly - - php: '7.3' # We exclude some combinations not usefull to save Travis CPU exclude: - php: '5.5' @@ -71,6 +70,8 @@ matrix: env: DB=mariadb - php: '7.1' env: DB=mariadb + - php: '7.2' + env: DB=mariadb - php: '5.5' env: DB=postgresql - php: '5.6' @@ -79,7 +80,7 @@ matrix: env: DB=postgresql - php: '7.1' env: DB=postgresql - - php: '7.3' + - php: '7.2' env: DB=postgresql - php: nightly env: DB=postgresql
'.$langs->trans("EstimatedStockValueShort").''; - print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); print "
'.dol_print_date($db->jdate($objp->datem),'dayhour').''.dol_print_date($db->jdate($objp->datem), 'dayhour').''; - print $productstatic->getNomUrl(1,'stock',16); + print $productstatic->getNomUrl(1, 'stock', 16); print "'. dol_print_date($objp->eatby,'day') .''. dol_print_date($objp->eatby, 'day') .''. dol_print_date($objp->sellby,'day') .''. dol_print_date($objp->sellby, 'day') .'
'; - print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore,'day','gmt')); + print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); //print ''; print ': '.$balancebefore; print "
\n"; //print '
'; - print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter,'day','gmt')); + print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter, 'day', 'gmt')); //print ''; print ': '.$balanceafter; @@ -1169,7 +1175,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) $genallowed=$user->rights->stock->lire; $delallowed=$user->rights->stock->creer; - print $formfile->showdocuments($modulepart,$objectref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); + print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); $somethingshown=$formfile->numoffiles; print '
'; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index be87a52fcd9..e67545bbc3d 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1045,7 +1045,7 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $contactsofproject=$projectstatic->getListContactId('internal'); if (count($contactsofproject)>0) { - if (in_array($user->id, $userid=$contactsofproject)) $userid = $user->id; + if (in_array($user->id, $contactsofproject)) $userid = $user->id; else $userid=$contactsofproject[0]; if ($projectstatic->public) $contactsofproject = array(); print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 39b789c2b7d..054a85211f7 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -85,7 +85,7 @@ class FormResource $resourcestat = new Dolresource($this->db); - $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, $filter=''); + $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, ''); if ($outputmode != 2) { diff --git a/htdocs/webservices/server_category.php b/htdocs/webservices/server_category.php index 74d175ac2c9..b670c0bf09d 100644 --- a/htdocs/webservices/server_category.php +++ b/htdocs/webservices/server_category.php @@ -209,6 +209,7 @@ function getCategory($authentication, $id) { $fuser->getrights(); + $nbmax = 10; if ($fuser->rights->categorie->lire) { $categorie=new Categorie($db); @@ -228,7 +229,7 @@ function getCategory($authentication, $id) //'visible'=>$categorie->visible, 'type' => $categorie->type, 'dir' => $pdir, - 'photos' => $categorie->liste_photos($dir, $nbmax=10) + 'photos' => $categorie->liste_photos($dir, $nbmax) ); $cats = $categorie->get_filles(); @@ -248,7 +249,7 @@ function getCategory($authentication, $id) //'visible'=>$fille->visible, 'type'=>$fille->type, 'dir' => $pdir, - 'photos' => $fille->liste_photos($dir, $nbmax=10) + 'photos' => $fille->liste_photos($dir, $nbmax) ); } } diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index d49a76af117..05b05424b4f 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -364,6 +364,7 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '' $fuser->getrights(); + $nbmax = 10; if ($fuser->rights->produit->lire || $fuser->rights->service->lire) { $product=new Product($db); @@ -417,7 +418,7 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = '' 'pmp' => $product->pmp, 'import_key' => $product->import_key, 'dir' => $pdir, - 'images' => $product->liste_photos($dir, $nbmax=10) + 'images' => $product->liste_photos($dir, $nbmax) ); //Retreive all extrafield for thirdsparty @@ -1029,6 +1030,7 @@ function getProductsForCategory($authentication, $id, $lang = '') $fuser->getrights(); + $nbmax = 10; if ($fuser->rights->produit->lire) { $categorie=new Categorie($db); @@ -1086,7 +1088,7 @@ function getProductsForCategory($authentication, $id, $lang = '') 'pmp' => $obj->pmp, 'import_key' => $obj->import_key, 'dir' => $pdir, - 'images' => $obj->liste_photos($dir, $nbmax=10) + 'images' => $obj->liste_photos($dir, $nbmax) ); //Retreive all extrafield for thirdsparty From de87321c15ebc3771abfe214946d54a71ec44757 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 13 Feb 2019 10:28:08 +0100 Subject: [PATCH 31/40] fix travcis --- htdocs/compta/compta-files.php | 2 +- htdocs/core/class/cmeasuringunits.class.php | 3 +- htdocs/core/lib/product.lib.php | 6 +- .../product/class/html.formproduct.class.php | 42 ++++---- htdocs/product/stock/movement_card.php | 95 +++++++++++-------- 5 files changed, 86 insertions(+), 62 deletions(-) diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index f67160c698e..7a18c642741 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -81,7 +81,7 @@ if ($user->societe_id > 0) * Actions */ -$entity = GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity; +$entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; //$parameters = array('socid' => $id); //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks diff --git a/htdocs/core/class/cmeasuringunits.class.php b/htdocs/core/class/cmeasuringunits.class.php index 718db8dab11..03923733178 100644 --- a/htdocs/core/class/cmeasuringunits.class.php +++ b/htdocs/core/class/cmeasuringunits.class.php @@ -166,11 +166,10 @@ class CMeasuringUnits // extends CommonObject * @param int $id Id object * @param string $unit_type unit type * @param string $code Code - * @param string $label Label * @param string $short_label Short Label * @return int <0 if KO, >0 if OK */ - function fetch($id, $unit_type='', $code = '', $short_label = '') + function fetch($id, $unit_type = '', $code = '', $short_label = '') { global $langs; diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 1d4ca11c4d3..478c69d4fe5 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -474,7 +474,11 @@ function measuring_units_string($unit, $measuring_style = '') global $langs, $db; require_once DOL_DOCUMENT_ROOT.'/core/class/cmeasuringunits.class.php'; $measuringUnits= new CMeasuringUnits($db); - $result=$measuringUnits->fetchAll('','', 0, 0, array('t.code'=> $unit,'t.unit_type'=>$measuring_style,'t.active'=>1)); + $result = $measuringUnits->fetchAll('', '', 0, 0, array( + 't.code' => $unit, + 't.unit_type' => $measuring_style, + 't.active' => 1 + )); if ($result<0) { return -1; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 67a2431dea1..03c3ac47179 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -311,34 +311,36 @@ class FormProduct function load_measuring_units($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0) { //phpcs:enable - global $langs,$conf,$mysoc, $db; + global $langs, $conf, $mysoc, $db; $langs->load("other"); - $return=''; + $return = ''; - $measuring_units=array(); + $measuring_units = array(); - require_once DOL_DOCUMENT_ROOT.'/core/class/cmeasuringunits.class.php'; - $measuringUnits= new CMeasuringUnits($db); - $result=$measuringUnits->fetchAll('','', 0, 0, array('t.unit_type'=>$measuring_style,'t.active'=>1)); - if ($result<0) { + require_once DOL_DOCUMENT_ROOT . '/core/class/cmeasuringunits.class.php'; + $measuringUnits = new CMeasuringUnits($db); + $result = $measuringUnits->fetchAll('', '', 0, 0, array( + 't.unit_type' => $measuring_style, + 't.active' => 1 + )); + if ($result < 0) { dol_print_error($db); - return -1; + return - 1; } else { - $return.= ''; + if ($adddefault) + $return .= ''; - foreach ($measuringUnits->records as $lines) - { - $return.= ''; } - //$return.= '>'.$value.''; - $return.= '>'.$langs->transnoentitiesnoconv($lines->label).''; - } - $return.= ''; + $return .= ''; } return $return; diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index c1c8842af08..7989ea9c125 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -84,7 +84,7 @@ if (! $sortfield) if (! $sortorder) $sortorder = "DESC"; -$pdluoid=GETPOST('pdluoid','int'); +$pdluoid=GETPOST('pdluoid', 'int'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $object = new MouvementStock($db); @@ -94,7 +94,7 @@ $formfile = new FormFile($db); // fetch optionals attributes and labels $extralabels = $extrafields->fetch_name_optionals_label('movement'); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element,'','search_'); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); $arrayfields=array( 'm.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1), @@ -129,14 +129,15 @@ $usercandelete = $user->rights->stock->mouvement->supprimer; if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } -$parameters=array(); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +$parameters = array(); +$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // 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'; // Do we click on purge search criteria ? -if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // Both test are required to be compatible with all browsers +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { $year=''; $month=''; @@ -203,7 +204,9 @@ if ($action == "correct_stock") GETPOST("mouvement"), GETPOST("label", 'san_alpha'), GETPOST('unitprice'), - $eatby,$sellby,$batch, + $eatby, + $sellby, + $batch, GETPOST('inventorycode'), $origin_element, $origin_id @@ -258,7 +261,7 @@ if ($action == "transfert_stock" && ! $cancel) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Product")), null, 'errors'); $action='transfert'; } - if (! GETPOST("nbpiece",'int')) + if (! GETPOST("nbpiece", 'int')) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $error++; @@ -909,21 +912,36 @@ if ($resql) print "
'.$langs->trans('StockIncreaseAfterCorrectTransfer').''.$langs->trans('StockDecreaseAfterCorrectTransfer').''.$langs->trans('StockDecrease').''.$langs->trans('StockIncrease').''.$langs->trans('StockIncreaseAfterCorrectTransfer').''.$langs->trans('StockDecreaseAfterCorrectTransfer').''.$langs->trans('StockDecrease').''.$langs->trans('StockIncrease').'
'.dol_print_date($db->jdate($objp->datem),'dayhour').''.dol_print_date($db->jdate($objp->datem), 'dayhour').''. dol_print_date($objp->eatby,'day') .''. dol_print_date($objp->eatby, 'day') .''. dol_print_date($objp->sellby,'day') .''. dol_print_date($objp->sellby, 'day') .'
'; - print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore,'day','gmt')); + print $langs->trans("NbOfProductBeforePeriod", $productlabelselected, dol_print_date($datebefore, 'day', 'gmt')); //print ''; print ': '.$balancebefore; print "
\n"; //print '
'; - print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter,'day','gmt')); + print $langs->trans("NbOfProductAfterPeriod", $productlabelselected, dol_print_date($dateafter, 'day', 'gmt')); //print ''; print ': '.$balanceafter; @@ -1169,7 +1169,7 @@ if ($action != 'create' && $action != 'edit' && $action != 'delete' && $id>0) $genallowed=$user->rights->stock->lire; $delallowed=$user->rights->stock->creer; - print $formfile->showdocuments($modulepart,$objectref,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,28,0,'',0,'',$object->default_lang, '', $object); + print $formfile->showdocuments($modulepart, $objectref, $filedir, $urlsource, $genallowed, $delallowed, '', 0, 0, 0, 28, 0, '', 0, '', $object->default_lang, '', $object); $somethingshown=$formfile->numoffiles; print '
'; diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index be87a52fcd9..1f09d7e9a77 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -1045,8 +1045,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0) $contactsofproject=$projectstatic->getListContactId('internal'); if (count($contactsofproject)>0) { - if (in_array($user->id, $userid=$contactsofproject)) $userid = $user->id; - else $userid=$contactsofproject[0]; + if (in_array($user->id, $contactsofproject)) $userid = $user->id; + else $userid = $contactsofproject[0]; if ($projectstatic->public) $contactsofproject = array(); print $form->select_dolusers((GETPOST('userid')?GETPOST('userid'):$userid), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 0, $langs->trans("ResourceNotAssignedToProject"), 'maxwidth200'); } diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 39b789c2b7d..e4cc5a64ab7 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -85,7 +85,7 @@ class FormResource $resourcestat = new Dolresource($this->db); - $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, $filter=''); + $resources_used = $resourcestat->fetch_all('ASC', 't.rowid', $limit, $offset, $filter); if ($outputmode != 2) { From 04e3f2347606f9fd0b33c01c20822ba32694b641 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Feb 2019 11:52:45 +0100 Subject: [PATCH 33/40] Fix phpcs --- htdocs/compta/compta-files.php | 2 +- htdocs/margin/agentMargins.php | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/compta-files.php b/htdocs/compta/compta-files.php index cb49b35d242..665b9ba63de 100644 --- a/htdocs/compta/compta-files.php +++ b/htdocs/compta/compta-files.php @@ -82,7 +82,7 @@ if ($user->societe_id > 0) * Actions */ -$entity = GETPOST('entity','int')?GETPOST('entity','int'):$conf->entity; +$entity = GETPOST('entity', 'int')?GETPOST('entity', 'int'):$conf->entity; //$parameters = array('socid' => $id); //$reshook = $hookmanager->executeHooks('doActions', $parameters, $object); // Note that $object may have been modified by some hooks diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 197c912494a..8f6c03d5623 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -213,7 +213,7 @@ if ($result) print_liste_field_titre("SalesRepresentative", $_SERVER["PHP_SELF"], "u.lastname", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("SellingPrice", $_SERVER["PHP_SELF"], "selling_price", "", $param, 'align="right"', $sortfield, $sortorder); - print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param,' align="right"', $sortfield, $sortorder); + print_liste_field_titre($labelcostprice, $_SERVER["PHP_SELF"], "buying_price", "", $param, 'align="right"', $sortfield, $sortorder); print_liste_field_titre("Margin", $_SERVER["PHP_SELF"], "marge", "", $param, 'align="right"', $sortfield, $sortorder); if (! empty($conf->global->DISPLAY_MARGIN_RATES)) print_liste_field_titre("MarginRate", $_SERVER["PHP_SELF"], "", "", $param, 'align="right"', $sortfield, $sortorder); @@ -225,8 +225,6 @@ if ($result) if ($num > 0) { - $var=true; - $group_list = array(); while ($objp = $db->fetch_object($result)) { if ($agentid > 0) { From 37c66c2ece2777e483d07d63c8be75813df20285 Mon Sep 17 00:00:00 2001 From: florian HENRY Date: Wed, 13 Feb 2019 12:32:06 +0100 Subject: [PATCH 34/40] travis --- .../product/class/html.formproduct.class.php | 3 +- htdocs/product/stock/movement_card.php | 33 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 03c3ac47179..afd62525135 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -332,7 +332,8 @@ class FormProduct if ($adddefault) $return .= ''; - foreach ( $measuringUnits->records as $lines ) { + foreach ($measuringUnits->records as $lines) + { $return .= '
'.$langs->trans("LastMovement").''; if ($lastmovementdate) { - print dol_print_date($lastmovementdate,'dayhour'); + print dol_print_date($lastmovementdate, 'dayhour'); } else { @@ -744,7 +741,7 @@ if ($resql) if ($sall) { foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall).'
'; + print '
'.$langs->trans("FilterOnInto", $sall) . join(', ', $fieldstosearchall).'
'; } $moreforfilter=''; From 44fd36b15ced9c30a5c3425485423a86afd223d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Feb 2019 12:39:26 +0100 Subject: [PATCH 35/40] Fix phpcs --- htdocs/product/stock/movement_card.php | 67 ++++++++++++++------------ 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/htdocs/product/stock/movement_card.php b/htdocs/product/stock/movement_card.php index fcfa26bb832..3b396a16fe3 100644 --- a/htdocs/product/stock/movement_card.php +++ b/htdocs/product/stock/movement_card.php @@ -47,7 +47,7 @@ $langs->loadLangs(array('products', 'stocks', 'orders')); if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); // Security check -$result=restrictedArea($user,'stock'); +$result=restrictedArea($user, 'stock'); $id=GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -69,7 +69,7 @@ $search_inventorycode = trim(GETPOST("search_inventorycode", 'alpha')); $search_user = trim(GETPOST("search_user", 'alpha')); $search_batch = trim(GETPOST("search_batch", 'alpha')); $search_qty = trim(GETPOST("search_qty", 'alpha')); -$search_type_mouvement=GETPOST('search_type_mouvement','int'); +$search_type_mouvement=GETPOST('search_type_mouvement', 'int'); $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; $page = GETPOST("page", 'int'); @@ -122,8 +122,8 @@ $usercanread = (($user->rights->stock->mouvement->lire)); $usercancreate = (($user->rights->stock->mouvement->creer)); $usercandelete = (($user->rights->stock->mouvement->supprimer)); -if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; } -if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } +if (GETPOST('cancel', 'alpha')) { $action='list'; $massaction=''; } +if (! GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; } $parameters=array(); $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks @@ -199,7 +199,9 @@ if ($action == "correct_stock") GETPOST("mouvement", 'int'), GETPOST("label", 'san_alpha'), GETPOST('unitprice', 'alpha'), - $eatby,$sellby,$batch, + $eatby, + $sellby, + $batch, GETPOST('inventorycode', 'alpha'), $origin_element, $origin_id @@ -212,7 +214,7 @@ if ($action == "correct_stock") $id, GETPOST("nbpiece", 'int'), GETPOST("mouvement", 'alpha'), - GETPOST("label",'san_alpha'), + GETPOST("label", 'san_alpha'), GETPOST('unitprice', 'alpha'), GETPOST('inventorycode', 'alpha'), $origin_element, @@ -334,7 +336,9 @@ if ($action == "transfert_stock" && ! $cancel) 1, GETPOST("label", 'san_alpha'), $pricesrc, - $eatby,$sellby,$batch, + $eatby, + $sellby, + $batch, GETPOST('inventorycode', 'alpha') ); // Add stock @@ -345,7 +349,9 @@ if ($action == "transfert_stock" && ! $cancel) 0, GETPOST("label", 'san_alpha'), $pricedest, - $eatby,$sellby,$batch, + $eatby, + $sellby, + $batch, GETPOST('inventorycode', 'alpha') ); } @@ -464,13 +470,13 @@ if ($id > 0) $sql.= " AND e.rowid ='".$id."'"; if ($month > 0) { if ($year > 0) - $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'"; + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, $month, false))."' AND '".$db->idate(dol_get_last_day($year, $month, false))."'"; else $sql.= " AND date_format(m.datem, '%m') = '$month'"; } elseif ($year > 0) { - $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; + $sql.= " AND m.datem BETWEEN '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; } if ($idproduct > 0) $sql.= " AND p.rowid = '".$idproduct."'"; if (! empty($search_ref)) $sql.= natural_search('m.rowid', $search_ref, 1); @@ -615,7 +621,7 @@ if ($resql) // Last movement $sql = "SELECT MAX(m.datem) as datem"; $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m"; - $sql .= " WHERE m.fk_entrepot = '".$object->id."'"; + $sql .= " WHERE m.fk_entrepot = ".(int) $object->id; $resqlbis = $db->query($sql); if ($resqlbis) { @@ -630,7 +636,7 @@ if ($resql) print '
'.$langs->trans("LastMovement").''; if ($lastmovementdate) { - print dol_print_date($lastmovementdate,'dayhour'); + print dol_print_date($lastmovementdate, 'dayhour'); } else { @@ -883,7 +889,7 @@ if ($resql) // Fields from hook $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['m.datec']['checked'])) @@ -905,21 +911,21 @@ if ($resql) print "
'; - print $productstatic->getNomUrl(1,'stock',16); + print $productstatic->getNomUrl(1, 'stock', 16); print "
'.$langs->trans("EstimatedStockValueShort").''; - print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'],'MT')), 0, $langs, 0, -1, -1, $conf->currency); + print price((empty($calcproducts['value'])?'0':price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency); print "
'; - print $productstatic->getNomUrl(1,'stock',16); + print $productstatic->getNomUrl(1, 'stock', 16); print "
'.$langs->trans("LastMovement").''; if ($lastmovementdate) { - print dol_print_date($lastmovementdate,'dayhour'); + print dol_print_date($lastmovementdate, 'dayhour'); } else { @@ -734,8 +734,8 @@ if ($resql) print ''; if ($id > 0) print ''; - if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,$massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); - else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,$massactionbutton, $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); + if ($id > 0) print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, '', 0, '', '', $limit); + else print_barre_liste($texte, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_generic', 0, '', '', $limit); if ($sall) { @@ -886,7 +886,7 @@ if ($resql) // Fields from hook $parameters=array('arrayfields'=>$arrayfields); - $reshook=$hookmanager->executeHooks('printFieldListOption',$parameters); // Note that $action and $object may have been modified by hook + $reshook=$hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; // Date creation if (! empty($arrayfields['m.datec']['checked'])) @@ -961,7 +961,7 @@ if ($resql) $arrayofuniqueproduct=array(); - while ($i < min($num,$limit)) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($resql); @@ -1072,21 +1072,21 @@ if ($resql) } if (! empty($arrayfields['m.type_mouvement']['checked'])) { - // Type of movement - switch($objp->type_mouvement){ - case "0": - print ''.$langs->trans('StockIncreaseAfterCorrectTransfer').''.$langs->trans('StockDecreaseAfterCorrectTransfer').''.$langs->trans('StockDecrease').''.$langs->trans('StockIncrease').'' . $langs->trans('StockIncreaseAfterCorrectTransfer') . '' . $langs->trans('StockDecreaseAfterCorrectTransfer') . '' . $langs->trans('StockDecrease') . '' . $langs->trans('StockIncrease') . '