diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 6701a82b31b..f54f39b20f3 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -509,36 +509,46 @@ function measuring_units_string($scale = '', $measuring_style = '', $unit = 0, $ function measuringUnitString($unit, $measuring_style = '', $scale = '', $use_short_label = 0) { global $langs, $db; - require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; - $measuringUnits= new CUnits($db); + global $measuring_unit_cache; - if ($scale !== '') + if (empty($measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label])) { - $arrayforfilter = array( - 't.scale' => $scale, - 't.unit_type' => $measuring_style, - 't.active' => 1 - ); - } - else - { - $arrayforfilter = array( - 't.rowid' => $unit, - 't.unit_type' => $measuring_style, - 't.active' => 1 - ); - } - $result = $measuringUnits->fetchAll('', '', 0, 0, $arrayforfilter); + require_once DOL_DOCUMENT_ROOT.'/core/class/cunits.class.php'; + $measuringUnits= new CUnits($db); - if ($result<0) { - return -1; - } else { - if (is_array($measuringUnits->records) && count($measuringUnits->records)>0) { - if ($use_short_label) return $measuringUnits->records[key($measuringUnits->records)]->short_label; - else return $langs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label); - } else { - return ''; + if ($scale !== '') + { + $arrayforfilter = array( + 't.scale' => $scale, + 't.unit_type' => $measuring_style, + 't.active' => 1 + ); } + else + { + $arrayforfilter = array( + 't.rowid' => $unit, + 't.unit_type' => $measuring_style, + 't.active' => 1 + ); + } + $result = $measuringUnits->fetchAll('', '', 0, 0, $arrayforfilter); + + if ($result < 0) { + return -1; + } else { + if (is_array($measuringUnits->records) && count($measuringUnits->records)>0) { + if ($use_short_label) $labeltoreturn = $measuringUnits->records[key($measuringUnits->records)]->short_label; + else $labeltoreturn = $langs->transnoentitiesnoconv($measuringUnits->records[key($measuringUnits->records)]->label); + } else { + $labeltoreturn = ''; + } + $measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label] = $labeltoreturn; + return $labeltoreturn; + } + } + else { + return $measuring_unit_cache[$unit.'_'.$measuring_style.'_'.$scale.'_'.$use_short_label]; } } diff --git a/htdocs/loan/calcmens.php b/htdocs/loan/calcmens.php index 7e3d1f83a8f..c741dfa13c9 100644 --- a/htdocs/loan/calcmens.php +++ b/htdocs/loan/calcmens.php @@ -44,7 +44,7 @@ $object = new LoanSchedule($db); $int = ($capital*($rate/12)); $int = round($int, 2, PHP_ROUND_HALF_UP); $cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP); -$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens); +$output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest, 0, '', 1, -1, -1, $conf->currency),'interet'=>$int,'interet_str'=>price($int, 0, '', 1, -1, -1, $conf->currency),'mens'=>$mens); $echance++; $capital=$cap_rest; @@ -56,7 +56,7 @@ while ($echance<=$nbterm) { $int = round($int, 2, PHP_ROUND_HALF_UP); $cap_rest = round($capital - ($mens-$int), 2, PHP_ROUND_HALF_UP); - $output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest),'interet'=>$int,'interet_str'=>price($int, 0, '', 1),'mens'=>$mens); + $output[$echance]=array('cap_rest'=>$cap_rest,'cap_rest_str'=>price($cap_rest, 0, '', 1, -1, -1, $conf->currency),'interet'=>$int,'interet_str'=>price($int, 0, '', 1, -1, -1, $conf->currency),'mens'=>$mens); $capital=$cap_rest; $echance++; diff --git a/htdocs/loan/schedule.php b/htdocs/loan/schedule.php index 1c9cb9d8c3f..d4e7dec9feb 100644 --- a/htdocs/loan/schedule.php +++ b/htdocs/loan/schedule.php @@ -44,6 +44,47 @@ llxHeader("", $title, $help_url); $head=loan_prepare_head($object); dol_fiche_head($head, 'FinancialCommitment', $langs->trans("Loan"), -1, 'bill'); +$linkback = '' . $langs->trans("BackToList") . ''; + +$morehtmlref='
'; +// Ref loan +$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1); +$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1); +// Project +if (! empty($conf->projet->enabled)) +{ + $langs->loadLangs(array("projects")); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->loan->write) + { + if ($action != 'classify') + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } +} +$morehtmlref.='
'; +dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); + if ($action == 'createecheancier') { $i=1; @@ -128,9 +169,9 @@ $(document).ready(function() { var interet_res_str='#interets'+index; var men_res='#mens'+index; $(idcap_res).val(element.cap_rest); - $(idcap_res_srt).text(element.cap_rest_str+' €'); + $(idcap_res_srt).text(element.cap_rest_str); $(interet_res).val(element.interet); - $(interet_res_str).text(element.interet_str+' €'); + $(interet_res_str).text(element.interet_str); $(men_res).val(element.mens); }); } @@ -166,7 +207,7 @@ print ''.$langs->trans("Insurance"); print ''.$langs->trans("InterestAmount").''; print ''.$langs->trans("Amount").''; print ''.$langs->trans("CapitalRemain"); -print ' ('.price2num($object->capital).')'; +print '
('.price($object->capital, 0, '', 1, -1, -1, $conf->currency).')'; print ''; print ''; if (count($echeance->lines)>0) print ''.$langs->trans('DoPayment').''; @@ -189,10 +230,10 @@ if ($object->nbterm > 0 && count($echeance->lines)==0) print ''; print '' . $i .''; print '' . dol_print_date(dol_time_plus_duree($object->datestart, $i-1, 'm'), 'day') . ''; - print ''.price($insurance+(($i == 1) ? $regulInsurance : 0), 0, '', 1).' €'; - print ''.price($int, 0, '', 1).' €'; - print ' €'; - print ''.price($cap_rest).' €'; + print ''.price($insurance+(($i == 1) ? $regulInsurance : 0), 0, '', 1, -1, -1, $conf->currency).''; + print ''.price($int, 0, '', 1, -1, -1, $conf->currency).''; + print ''; + print ''.price($cap_rest).''; print ''."\n"; $i++; $capital = $cap_rest; @@ -215,15 +256,15 @@ elseif(count($echeance->lines)>0) print ''; print '' . $i .''; print '' . dol_print_date($line->datep, 'day') . ''; - print ''.price($insu, 0, '', 1).' €'; - print ''.price($int, 0, '', 1).' €'; + print ''.price($insu, 0, '', 1, -1, -1, $conf->currency).''; + print ''.price($int, 0, '', 1, -1, -1, $conf->currency).''; if($line->datep > dol_now() && empty($line->fk_bank)){ - print ' €'; + print ''; }else{ - print '' . price($mens) . ' €'; + print '' . price($mens, 0, '', 1, -1, -1, $conf->currency) . ''; } - print ''.price($cap_rest).' €'; + print ''.price($cap_rest, 0, '', 1, -1, -1, $conf->currency).''; print ''; if (!empty($line->fk_bank)) print $langs->trans('Paid'); elseif (!$printed) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index ac987d49845..d00cba86e6a 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4010,7 +4010,7 @@ class Product extends CommonObject if ($this->type == Product::TYPE_PRODUCT || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) { if (! empty($conf->productbatch->enabled)) { - $langs->load("productbatch"); + $langs->load("productbatch"); $label.="
".$langs->trans("ManageLotSerial").': '.$this->getLibStatut(0, 2); } } @@ -4361,12 +4361,12 @@ class Product extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) - * This function need a lot of load. If you use it on list, use a cache to execute it once for each product id. - * If ENTREPOT_EXTRA_STATUS set, filtering on warehouse status possible. + * Load information about stock of a product into ->stock_reel, ->stock_warehouse[] (including stock_warehouse[idwarehouse]->detail_batch for batch products) + * This function need a lot of load. If you use it on list, use a cache to execute it once for each product id. + * If ENTREPOT_EXTRA_STATUS set, filtering on warehouse status possible. * - * @param string $option '' = Load all stock info, also from closed and internal warehouses, - * @return int < 0 if KO, > 0 if OK + * @param string $option '' = Load all stock info, also from closed and internal warehouses, 'nobatch', 'novirtual' + * @return int < 0 if KO, > 0 if OK * @see load_virtual_stock(), loadBatchInfo() */ public function load_stock($option = '') @@ -4396,7 +4396,8 @@ class Product extends CommonObject $sql.= " WHERE w.entity IN (".getEntity('stock').")"; $sql.= " AND w.rowid = ps.fk_entrepot"; $sql.= " AND ps.fk_product = ".$this->id; - if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) { $sql.= " AND w.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")"; + if ($conf->global->ENTREPOT_EXTRA_STATUS && count($warehouseStatus)) { + $sql.= " AND w.statut IN (".$this->db->escape(implode(',', $warehouseStatus)).")"; } dol_syslog(get_class($this)."::load_stock", LOG_DEBUG); @@ -4411,7 +4412,8 @@ class Product extends CommonObject $this->stock_warehouse[$row->fk_entrepot] = new stdClass(); $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; $this->stock_warehouse[$row->fk_entrepot]->id = $row->rowid; - if ((! preg_match('/nobatch/', $option)) && $this->hasbatch()) { $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db, $row->rowid, 1, $this->id); + if ((! preg_match('/nobatch/', $option)) && $this->hasbatch()) { + $this->stock_warehouse[$row->fk_entrepot]->detail_batch=Productbatch::findAll($this->db, $row->rowid, 1, $this->id); } $this->stock_reel+=$row->reel; $i++; diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 6e870c05740..cfa330196d9 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -783,7 +783,7 @@ if ($resql) $obj = $db->fetch_object($resql); // Multilangs - if (! empty($conf->global->MAIN_MULTILANGS)) // si l'option est active + if (! empty($conf->global->MAIN_MULTILANGS)) // If multilang is enabled { $sql = "SELECT label"; $sql.= " FROM ".MAIN_DB_PREFIX."product_lang"; @@ -801,7 +801,8 @@ if ($resql) $product_static->id = $obj->rowid; $product_static->ref = $obj->ref; - $product_static->ref_fourn = $obj->ref_supplier; + $product_static->ref_fourn = $obj->ref_supplier; // deprecated + $product_static->ref_supplier = $obj->ref_supplier; $product_static->label = $obj->label; $product_static->type = $obj->fk_product_type; $product_static->status_buy = $obj->tobuy; @@ -826,15 +827,17 @@ if ($resql) $product_static->surface = $obj->surface; $product_static->surface_units = $obj->surface_units; + // STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock. if ((! empty($conf->stock->enabled) && $user->rights->stock->lire && $search_type != 1) || ! empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) // To optimize call of load_stock { if ($obj->fk_product_type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) // Not a service { - $product_static->load_stock('nobatch'); // Load stock_reel + stock_warehouse. This also call load_virtual_stock() + $option = 'nobatch'; + if (empty($arrayfields['stock_virtual']['checked'])) $option .= ',novirtual'; + $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() } } - print ''; // Ref @@ -845,6 +848,7 @@ if ($resql) print "\n"; if (! $i) $totalarray['nbfield']++; } + // Ref supplier if (! empty($arrayfields['pfp.ref_fourn']['checked'])) { @@ -853,6 +857,7 @@ if ($resql) print "\n"; if (! $i) $totalarray['nbfield']++; } + // Label if (! empty($arrayfields['p.label']['checked'])) { @@ -1120,6 +1125,7 @@ if ($resql) print ''; if (! $i) $totalarray['nbfield']++; } + // Action print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined