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; }