diff --git a/ChangeLog b/ChangeLog index e70169095bec5e1c2999fdaafed3318178fc29d5..98339d3874abcc8df439a2dd20f6608ac454302a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,6 +41,7 @@ Dolibarr better: - Hooks 'printLeftBlock' and 'formConfirm' are now compliant with hook development rules. They are "addreplace" hooks, so you must return content with "->resprints='mycontent'" and not with "return 'mycontent'" - All fields "fk_societe" were renamed into "fk_soc". +- Method select_PriceBaseType and load_PriceBaseType were merged into selectPriceBaseType ***** ChangeLog for 3.7.1 compared to 3.7.* ***** FIX Bug in the new photo system diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 3abe4fc6c99bf880dceefdd0fd1f54c5dfd58532..a73a1de3607df6dca05d2d730c59e990e2536df7 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2134,7 +2134,7 @@ if ($action == 'create') print '</div></div>'; // Next situation invoice - $opt = $form->load_situation_invoices(GETPOST('originid'), $socid); + $opt = $form->selectSituationInvoices(GETPOST('originid'), $socid); print '<div class="tagtr listofinvoicetype"><div class="tagtd listofinvoicetype">'; $tmp='<input type="radio" name="type" value="5"' . (GETPOST('type') == 5 && GETPOST('originid') ? ' checked' : ''); if ($opt == ('<option value ="0" selected>' . $langs->trans('NoSituations') . '</option>') || (GETPOST('origin') && GETPOST('origin') != 'facture')) $tmp.=' disabled'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 399985c4f2f7f97637e5c0208c72edb982feaab7..be0d2656ec2772753a68146d106b3f0a1834b0e8 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -42,7 +42,7 @@ * Class to manage generation of HTML components * Only common components must be here. * - * TODO Merge all function load_cache_* into one generic function + * TODO Merge all function load_cache_* and loadCache* (except load_cache_vatrates) into one generic function loadCacheTable */ class Form { @@ -499,7 +499,7 @@ class Form $sql = "SELECT rowid, code as code_iso, code_iso as code_iso3, label, favorite"; $sql.= " FROM ".MAIN_DB_PREFIX."c_country"; - $sql.= " WHERE active = 1"; + $sql.= " WHERE active > 0"; //$sql.= " ORDER BY code ASC"; dol_syslog(get_class($this)."::select_country", LOG_DEBUG); @@ -587,7 +587,7 @@ class Form $sql = "SELECT rowid, code"; $sql.= " FROM ".MAIN_DB_PREFIX."c_incoterms"; - $sql.= " WHERE active = 1"; + $sql.= " WHERE active > 0"; $sql.= " ORDER BY code ASC"; dol_syslog(get_class($this)."::select_incoterm", LOG_DEBUG); @@ -896,7 +896,7 @@ class Form if (! empty($user->societe_id)) $sql.= " AND s.rowid = ".$user->societe_id; if ($filter) $sql.= " AND (".$filter.")"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND s.status<>0 "; + if (! empty($conf->global->COMPANY_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND s.status <> 0"; // Add criteria if ($filterkey && $filterkey != '') { @@ -1123,7 +1123,7 @@ class Form if ($showsoc > 0) $sql.= " LEFT OUTER JOIN ".MAIN_DB_PREFIX ."societe as s ON s.rowid=sp.fk_soc"; $sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")"; if ($socid > 0) $sql.= " AND sp.fk_soc=".$socid; - if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut<>0"; + if (! empty($conf->global->CONTACT_HIDE_INACTIVE_IN_COMBOBOX)) $sql.= " AND sp.statut <> 0"; $sql.= " ORDER BY sp.lastname ASC"; dol_syslog(get_class($this)."::select_contacts", LOG_DEBUG); @@ -2451,19 +2451,19 @@ class Form /** * Load into cache cache_demand_reason, array of input reasons * - * @return int Nb of lines loaded, 0 if already loaded, <0 if ko + * @return int Nb of lines loaded, <0 if KO */ function loadCacheInputReason() { global $langs; - if (count($this->cache_demand_reason)) return 0; // Cache already loaded + $num = count($this->cache_demand_reason); + if ($num > 0) return 0; // Cache already loaded $sql = "SELECT rowid, code, label"; $sql.= " FROM ".MAIN_DB_PREFIX.'c_input_reason'; - $sql.= " WHERE active=1"; - $sql.= " ORDER BY rowid"; - dol_syslog(get_class($this)."::loadCacheInputReason", LOG_DEBUG); + $sql.= " WHERE active > 0"; + $resql = $this->db->query($sql); if ($resql) { @@ -2481,12 +2481,14 @@ class Form $tmparray[$obj->rowid]['label']=$label; $i++; } + $this->cache_demand_reason=dol_sort_array($tmparray, 'label', 'asc'); unset($tmparray); - return 1; + return $num; } - else { + else + { dol_print_error($this->db); return -1; } @@ -2669,26 +2671,13 @@ class Form /** - * Selection HT or TTC - * - * @param string $selected Id pre-selectionne - * @param string $htmlname Nom de la zone select - * @return void - */ - function select_PriceBaseType($selected='',$htmlname='price_base_type') - { - print $this->load_PriceBaseType($selected,$htmlname); - } - - - /** - * Selection HT or TTC + * Selection HT or TTC * - * @param string $selected Id pre-selectionne - * @param string $htmlname Nom de la zone select - * @return void + * @param string $selected Id pre-selectionne + * @param string $htmlname Nom de la zone select + * @return string Code of HTML select to chose tax or not */ - function load_PriceBaseType($selected='',$htmlname='price_base_type') + function selectPriceBaseType($selected='',$htmlname='price_base_type') { global $langs; @@ -2733,9 +2722,9 @@ class Form $langs->load("admin"); $langs->load("deliveries"); - $sql = "SELECT rowid, code, libelle"; + $sql = "SELECT rowid, code, libelle as label"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode"; - $sql.= " WHERE active = 1"; + $sql.= " WHERE active > 0"; if ($filtre) $sql.=" AND ".$filtre; $sql.= " ORDER BY libelle ASC"; @@ -2756,7 +2745,7 @@ class Form } else { print '<option value="'.$obj->rowid.'">'; } - print $langs->trans("SendingMethod".strtoupper($obj->code)); + print ($langs->trans("SendingMethod".strtoupper($obj->code)) != "SendingMethod".strtoupper($obj->code)) ? $langs->trans("SendingMethod".strtoupper($obj->code)) : $obj->label; print '</option>'; $i++; } @@ -2808,12 +2797,12 @@ class Form /** * Creates HTML last in cycle situation invoices selector * - * @param string $selected Preselected ID - * @param int $socid Company ID + * @param string $selected Preselected ID + * @param int $socid Company ID * * @return string HTML select */ - function load_situation_invoices($selected = '', $socid = '') + function selectSituationInvoices($selected = '', $socid = 0) { global $langs; @@ -2821,7 +2810,7 @@ class Form $opt = '<option value ="" selected></option>'; $sql = 'SELECT rowid, facnumber, situation_cycle_ref, situation_counter, situation_final, fk_soc FROM ' . MAIN_DB_PREFIX . 'facture WHERE situation_counter>=1'; - $sql .= ' order by situation_cycle_ref, situation_counter desc'; + $sql.= ' ORDER by situation_cycle_ref, situation_counter desc'; $resql = $this->db->query($sql); if ($resql && $this->db->num_rows($resql) > 0) { // Last seen cycle @@ -2847,10 +2836,13 @@ class Form } } } - } else { + } + else + { dol_syslog("Error sql=" . $sql . ", error=" . $this->error, LOG_ERR); } - if ($opt == '<option value ="" selected></option>') { + if ($opt == '<option value ="" selected></option>') + { $opt = '<option value ="0" selected>' . $langs->trans('NoSituations') . '</option>'; } return $opt; @@ -2872,7 +2864,9 @@ class Form $return= '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">'; - $sql = 'select rowid, label from '.MAIN_DB_PREFIX.'c_units where active=1'; + $sql = 'SELECT rowid, label from '.MAIN_DB_PREFIX.'c_units'; + $sql.= ' WHERE active > 0'; + $resql = $this->db->query($sql); if($resql && $this->db->num_rows($resql) > 0) { @@ -3870,7 +3864,8 @@ class Form } /** - * Output an HTML select vat rate + * Output an HTML select vat rate. + * The name of this function should be selectVat. We keep bad name for compatibility purpose. * * @param string $htmlname Name of html select field * @param float $selectedrate Force preselected vat rate. Use '' for no forcing. diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index b164636ceb79583588010c36fc6c823d1f6def22..b1869491a34f1e40446486a58905228e16a63803 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4867,7 +4867,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode= * Print common footer : * conf->global->MAIN_HTML_FOOTER * conf->global->MAIN_GOOGLE_AN_ID - * DOL_TUNING + * conf->global->MAIN_SHOW_TUNING_INFO or $_SERVER["MAIN_SHOW_TUNING_INFO"] * conf->logbuffer * * @param string $zone 'private' (for private pages) or 'public' (for public pages) @@ -4904,7 +4904,7 @@ function printCommonFooter($zone='private') } // End of tuning - if (! empty($_SERVER['DOL_TUNING']) || ! empty($conf->global->MAIN_SHOW_TUNING_INFO)) + if (! empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || ! empty($conf->global->MAIN_SHOW_TUNING_INFO)) { print "\n".'<script type="text/javascript">'."\n"; print 'window.console && console.log("'; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 7a390ab7d9dbb55ab59d8249eda0ad488992c993..eb469169b1e52b48d2db781fd9df6ca7f1178526 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -34,10 +34,10 @@ //@ini_set('memory_limit', '64M'); // This may be useless if memory is hard limited by your PHP -// For optional tuning. Enabled if environment variable DOL_TUNING is defined. +// For optional tuning. Enabled if environment variable MAIN_SHOW_TUNING_INFO is defined. // A call first. Is the equivalent function dol_microtime_float not yet loaded. $micro_start_time=0; -if (! empty($_SERVER['DOL_TUNING'])) +if (! empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) { list($usec, $sec) = explode(" ", microtime()); $micro_start_time=((float) $usec + (float) $sec); diff --git a/htdocs/product/admin/product_tools.php b/htdocs/product/admin/product_tools.php index 26ad4dba807347b96c3c60545394a2051b010352..ec5f575a552435f976dd1fb6c299e784dc4a2821 100644 --- a/htdocs/product/admin/product_tools.php +++ b/htdocs/product/admin/product_tools.php @@ -292,7 +292,7 @@ else print '<tr '.$bc[$var].'>'."\n"; print '<td>'.$langs->trans("PriceBaseTypeToChange").'</td>'."\n"; print '<td width="60" align="right">'."\n"; - print $form->load_PriceBaseType($price_base_type); + print $form->selectPriceBaseType($price_base_type); print '</td>'."\n"; print '</tr>'."\n"; */ diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 260c8996fc435fb841ba7b9e1753759d9f04a16f..aba6325d234a96f608a3863bf0773de1673404c1 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -116,7 +116,7 @@ class ActionsCardProduct // Price $this->tpl['price'] = $this->price; $this->tpl['price_min'] = $this->price_min; - $this->tpl['price_base_type'] = $form->load_PriceBaseType($this->price_base_type, "price_base_type"); + $this->tpl['price_base_type'] = $form->selectPriceBaseType($this->price_base_type, "price_base_type"); // VAT $this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,''); diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index f7de783cd99428931cebafe2aec6d6f8d10e2266..7bc04ecb42a5d312d08837d86b4e0d27fc297603 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -115,7 +115,7 @@ class ActionsCardService // Price $this->tpl['price'] = $this->price; $this->tpl['price_min'] = $this->price_min; - $this->tpl['price_base_type'] = $form->load_PriceBaseType($this->price_base_type, "price_base_type"); + $this->tpl['price_base_type'] = $form->selectPriceBaseType($this->price_base_type, "price_base_type"); // VAT $this->tpl['tva_tx'] = $form->load_tva("tva_tx",-1,$mysoc,''); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 7780bb560a5c4984d5077f97f2b6ebe5f32d4e45..81a8d5131c092ac8cdaf6f88ed8f1f612015a72e 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1004,7 +1004,7 @@ else // PRIX print '<tr><td>'.$langs->trans("SellingPrice").'</td>'; print '<td><input name="price" size="10" value="'.$object->price.'">'; - print $form->select_PriceBaseType($object->price_base_type, "price_base_type"); + print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); print '</td></tr>'; // MIN PRICE diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index f23ac3d1e95a760b6bc4c5dfca4e62b5e4ceaa40..fe715801f1137bc01a8cca55c99c75527dd81299 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -450,7 +450,7 @@ if ($id || $ref) print '<tr><td class="fieldrequired">'.$langs->trans("PriceQtyMin").'</td>'; print '<td><input class="flat" name="price" size="8" value="'.(GETPOST('price')?price(GETPOST('price')):(isset($product->fourn_price)?price($product->fourn_price):'')).'">'; print ' '; - print $form->select_PriceBaseType((GETPOST('price_base_type')?GETPOST('price_base_type'):$product->price_base_type), "price_base_type"); + print $form->selectPriceBaseType((GETPOST('price_base_type')?GETPOST('price_base_type'):$product->price_base_type), "price_base_type"); print '</td></tr>'; // Discount qty min diff --git a/htdocs/product/price.php b/htdocs/product/price.php index ce8ad104a1f014a30aed4ac8597046db9c559d8b..86668d294c7de0c9dbff0a1f7fa64d132ad5dd6b 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -687,7 +687,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> print $langs->trans('PriceBase'); print '</td>'; print '<td>'; - print $form->select_PriceBaseType($object->price_base_type, "price_base_type"); + print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); print '</td>'; print '</tr>'; @@ -793,7 +793,7 @@ if ($action == 'edit_price' && ($user->rights->produit->creer || $user->rights-> } else { print '<input name="price_' . $i . '" size="10" value="' . price($object->multiprices ["$i"]) . '">'; } - print $form->select_PriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i); + print $form->selectPriceBaseType($object->multiprices_base_type ["$i"], "multiprices_base_type_" . $i); print '</td></tr>'; // Min price @@ -1010,7 +1010,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $langs->trans('PriceBase'); print '</td>'; print '<td>'; - print $form->select_PriceBaseType($object->price_base_type, "price_base_type"); + print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); print '</td>'; print '</tr>'; @@ -1094,7 +1094,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) print $langs->trans('PriceBase'); print '</td>'; print '<td>'; - print $form->select_PriceBaseType($prodcustprice->price_base_type, "price_base_type"); + print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type"); print '</td>'; print '</tr>'; diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 0932144a86059f2c2c7aa3095be054b90fd57ba3..500612d48ed137780e867e530ee6f321c77241ca 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -254,7 +254,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print $langs->trans('PriceBase'); print '</td>'; print '<td>'; - print $form->select_PriceBaseType($object->price_base_type, "price_base_type"); + print $form->selectPriceBaseType($object->price_base_type, "price_base_type"); print '</td>'; print '</tr>'; @@ -332,7 +332,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) { print $langs->trans('PriceBase'); print '</td>'; print '<td>'; - print $form->select_PriceBaseType($prodcustprice->price_base_type, "price_base_type"); + print $form->selectPriceBaseType($prodcustprice->price_base_type, "price_base_type"); print '</td>'; print '</tr>';