Uniformize code
This commit is contained in:
parent
1880ed701f
commit
89f77f5e2b
@ -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
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -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
|
||||
* 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 select_PriceBaseType($selected='',$htmlname='price_base_type')
|
||||
{
|
||||
print $this->load_PriceBaseType($selected,$htmlname);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selection HT or TTC
|
||||
*
|
||||
* @param string $selected Id pre-selectionne
|
||||
* @param string $htmlname Nom de la zone select
|
||||
* @return void
|
||||
*/
|
||||
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.
|
||||
|
||||
@ -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("';
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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";
|
||||
*/
|
||||
|
||||
@ -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,'');
|
||||
|
||||
@ -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,'');
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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>';
|
||||
|
||||
|
||||
@ -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>';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user