';
// Define value if value is before
@@ -629,8 +601,7 @@ class Form
if (empty($conf->use_javascript_ajax))
{
if ($type == 'info' || $type == 'infoclickable' || $type == 'help' || $type == 'helpclickable') return $text;
- else
- {
+ else {
$alt = $htmltext;
$htmltext = '';
}
@@ -676,7 +647,7 @@ class Form
$disabled = 0;
$ret = '
';
- $ret .= '
'."\n";
- }
- else
- {
+ } else {
dol_print_error($this->db);
}
@@ -1455,9 +1407,7 @@ class Form
}
print '';
return $qualifiedlines;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -1587,9 +1537,7 @@ class Form
if ($showfunction && $obj->poste) $out .= ' ('.$obj->poste.')';
if (($showsoc > 0) && $obj->company) $out .= ' - ('.$obj->company.')';
$out .= '';
- }
- else
- {
+ } else {
$out .= '
';
}
- }
- else
- {
+ } else {
if (in_array($obj->rowid, $selected))
{
$out .= $contactstatic->getFullName($langs);
@@ -1611,9 +1557,7 @@ class Form
}
$i++;
}
- }
- else
- {
+ } else {
$out .= '
';
@@ -1637,9 +1581,7 @@ class Form
$this->num = $num;
return $out;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -1713,8 +1655,7 @@ class Form
{
// Build list includeUsers to have only hierarchy
$includeUsers = implode(",", $user->getAllChildIds(0));
- }
- elseif ($include == 'hierarchyme')
+ } elseif ($include == 'hierarchyme')
{
// Build list includeUsers to have only hierarchy and current user
$includeUsers = implode(",", $user->getAllChildIds(1));
@@ -1735,17 +1676,13 @@ class Form
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."entity as e ON e.rowid=u.entity";
if ($force_entity) $sql .= " WHERE u.entity IN (0,".$force_entity.")";
else $sql .= " WHERE u.entity IS NOT NULL";
- }
- else
- {
+ } else {
if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE))
{
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " ON ug.fk_user = u.rowid";
$sql .= " WHERE ug.entity = ".$conf->entity;
- }
- else
- {
+ } else {
$sql .= " WHERE u.entity IN (0,".$conf->entity.")";
}
}
@@ -1762,9 +1699,7 @@ class Form
if (empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) // MAIN_FIRSTNAME_NAME_POSITION is 0 means firstname+lastname
{
$sql .= " ORDER BY u.firstname ASC";
- }
- else
- {
+ } else {
$sql .= " ORDER BY u.lastname ASC";
}
@@ -1803,9 +1738,7 @@ class Form
$out .= '
'.$textifempty.'';
@@ -2431,9 +2343,7 @@ class Form
array_push($outarray, $optJson);
}
}
- }
- else
- {
+ } else {
if (!empty($conf->dynamicprices->enabled) && !empty($objp->fk_price_expression)) {
$price_product = new Product($this->db);
$price_product->fetch($objp->rowid, '', '', 1);
@@ -2465,9 +2375,7 @@ class Form
if (empty($outputmode)) return $out;
return $outarray;
- }
- else
- {
+ } else {
dol_print_error($db);
}
}
@@ -2612,65 +2520,21 @@ class Form
$objp2 = $this->db->fetch_object($result2);
if ($objp2)
{
- if ($price_level != 1 && $objp2->price == 0 && !empty($conf->global->PRODUIT_MULTIPRICES_USELEVEL1_IFLEVELVALISNUL)){
- $sql = "SELECT price, price_ttc, price_base_type, tva_tx";
- $sql .= " FROM ".MAIN_DB_PREFIX."product_price";
- $sql .= " WHERE fk_product='".$objp->rowid."'";
- $sql .= " AND entity IN (".getEntity('productprice').")";
- $sql .= " AND price_level=1";
- $sql .= " ORDER BY date_price DESC, rowid DESC"; // Warning DESC must be both on date_price and rowid.
- $sql .= " LIMIT 1";
- dol_syslog(get_class($this).'::constructProductListOption search price for product '.$objp->rowid.' AND level '.$price_level.'', LOG_DEBUG);
- $result2 = $this->db->query($sql);
- if ($result2)
- {
- $objp2 = $this->db->fetch_object($result2);
- if ($objp2)
- {
- $found = 1;
- if ($objp2->price_base_type == 'HT')
- {
- //$opt .= ' - '.price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
- //$outval .= ' - '.price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
- }
- else
- {
- $opt .= ' - '.price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
- $outval .= ' - '.price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
- }
- $outprice_ht = price($objp2->price);
- $outprice_ttc = price($objp2->price_ttc);
- $outpricebasetype = $objp2->price_base_type;
- $outtva_tx = $objp2->tva_tx;
- }
- }
- else
- {
- dol_print_error($this->db);
- }
- }
- else
+ $found = 1;
+ if ($objp2->price_base_type == 'HT')
{
- $found = 1;
- if ($objp2->price_base_type == 'HT')
- {
- $opt .= ' - '.price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
- $outval .= ' - '.price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
- }
- else
- {
- $opt .= ' - '.price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
- $outval .= ' - '.price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
- }
- $outprice_ht = price($objp2->price);
- $outprice_ttc = price($objp2->price_ttc);
- $outpricebasetype = $objp2->price_base_type;
- $outtva_tx = $objp2->tva_tx;
+ $opt .= ' - '.price($objp2->price, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
+ $outval .= ' - '.price($objp2->price, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
+ } else {
+ $opt .= ' - '.price($objp2->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
+ $outval .= ' - '.price($objp2->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
}
+ $outprice_ht = price($objp2->price);
+ $outprice_ttc = price($objp2->price_ttc);
+ $outpricebasetype = $objp2->price_base_type;
+ $outtva_tx = $objp2->tva_tx;
}
- }
- else
- {
+ } else {
dol_print_error($this->db);
}
}
@@ -2687,9 +2551,7 @@ class Form
$outval .= ' - '.price($objp->unitprice, 0, $langs, 0, 0, -1, $conf->currency)."/";
$opt .= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding
$outval .= $langs->transnoentities("Unit");
- }
- else
- {
+ } else {
$opt .= ' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
$outval .= ' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
$opt .= $langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
@@ -2723,9 +2585,7 @@ class Form
{
$opt .= ' - '.price($objp->custprice, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
$outval .= ' - '.price($objp->custprice, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
- }
- else
- {
+ } else {
$opt .= ' - '.price($objp->custprice_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
$outval .= ' - '.price($objp->custprice_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
}
@@ -2744,9 +2604,7 @@ class Form
{
$opt .= ' - '.price($objp->price, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT");
$outval .= ' - '.price($objp->price, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("HT");
- }
- else
- {
+ } else {
$opt .= ' - '.price($objp->price_ttc, 1, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC");
$outval .= ' - '.price($objp->price_ttc, 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->transnoentities("TTC");
}
@@ -2763,7 +2621,7 @@ class Form
if ($objp->stock > 0) {
$outval .= ' -
';
- }elseif ($objp->stock <= 0) {
+ } elseif ($objp->stock <= 0) {
$outval .= ' - ';
}
$outval .= $langs->transnoentities("Stock").':'.$objp->stock;
@@ -2782,7 +2640,7 @@ class Form
$outval .= ' - '.$langs->transnoentities("VirtualStock").':';
if ($virtualstock > 0) {
$outval .= ' - ';
- }elseif ($virtualstock <= 0) {
+ } elseif ($virtualstock <= 0) {
$outval .= ' - ';
}
$outval .= $virtualstock;
@@ -2834,9 +2692,7 @@ class Form
$urloption = ($socid > 0 ? 'socid='.$socid.'&' : '').'htmlname='.$htmlname.'&outjson=1&price_level='.$price_level.'&type='.$filtertype.'&mode=2&status='.$status.'&finished='.$finished.'&alsoproductwithnosupplierprice='.$alsoproductwithnosupplierprice;
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, $ajaxoptions);
print ($hidelabel ? '' : $langs->trans("RefOrLabel").' : ').'';
- }
- else
- {
+ } else {
print $this->select_produits_fournisseurs_list($socid, $selected, $htmlname, $filtertype, $filtre, '', -1, 0, 0, $alsoproductwithnosupplierprice, $morecss);
}
}
@@ -3045,9 +2901,7 @@ class Form
$outvallabel .= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency)."/";
$optlabel .= $langs->trans("Unit"); // Do not use strtolower because it breaks utf8 encoding
$outvallabel .= $langs->transnoentities("Unit");
- }
- else
- {
+ } else {
$optlabel .= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 1, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
$outvallabel .= ' - '.price($objp->fprice * (!empty($conf->global->DISPLAY_DISCOUNTED_SUPPLIER_PRICE) ? (1 - $objp->remise_percent / 100) : 1), 0, $langs, 0, 0, -1, $conf->currency)."/".$objp->quantity;
$optlabel .= ' '.$langs->trans("Units"); // Do not use strtolower because it breaks utf8 encoding
@@ -3082,15 +2936,12 @@ class Form
$optlabel .= " - ".$reputations[$objp->supplier_reputation];
$outvallabel .= " - ".$reputations[$objp->supplier_reputation];
}
- }
- else
- {
+ } else {
if (empty($alsoproductwithnosupplierprice)) // No supplier price defined for couple product/supplier
{
$optlabel .= " - ".$langs->trans("NoPriceDefinedForThisSupplier").'';
$outvallabel .= ' - '.$langs->transnoentities("NoPriceDefinedForThisSupplier");
- }
- else // No supplier price defined for product, even on other suppliers
+ } else // No supplier price defined for product, even on other suppliers
{
$optlabel .= " - ".$langs->trans("NoPriceDefinedForThisSupplier").'';
$outvallabel .= ' - '.$langs->transnoentities("NoPriceDefinedForThisSupplier");
@@ -3138,9 +2989,7 @@ class Form
if (empty($outputmode)) return $out;
return $outarray;
- }
- else
- {
+ } else {
dol_print_error($this->db);
}
}
@@ -3185,9 +3034,7 @@ class Form
if (!$num)
{
$form .= '-- '.$langs->trans("NoSupplierPriceDefinedForThisProduct").' --';
- }
- else
- {
+ } else {
require_once DOL_DOCUMENT_ROOT.'/product/dynamic_price/class/price_parser.class.php';
$form .= ' ';
@@ -3230,9 +3077,7 @@ class Form
if ($objp->quantity == 1)
{
$opt .= $langs->trans("Unit");
- }
- else
- {
+ } else {
$opt .= $langs->trans("Units");
}
if ($objp->quantity > 1)
@@ -3251,9 +3096,7 @@ class Form
$form .= '';
$this->db->free($result);
return $form;
- }
- else
- {
+ } else {
dol_print_error($this->db);
}
}
@@ -3294,9 +3137,7 @@ class Form
if ($selected && $selected == $obj->rowid)
{
print ''.$obj->label.'';
- }
- else
- {
+ } else {
print ''.$obj->label.'';
}
$i++;
@@ -3304,9 +3145,7 @@ class Form
}
print '';
return $num;
- }
- else
- {
+ } else {
dol_print_error($this->db);
}
}
@@ -3353,9 +3192,7 @@ class Form
//$this->cache_conditions_paiements=dol_sort_array($this->cache_conditions_paiements, 'label', 'asc', 0, 0, 1); // We use the field sortorder of table
return $num;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -3402,9 +3239,7 @@ class Form
$this->cache_availability = dol_sort_array($this->cache_availability, 'label', 'asc', 0, 0, 1);
return $num;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -3434,9 +3269,7 @@ class Form
if ($selected == $id)
{
print '';
- }
- else
- {
+ } else {
print '';
}
print $arrayavailability['label'];
@@ -3487,9 +3320,7 @@ class Form
unset($tmparray);
return $num;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -3520,9 +3351,7 @@ class Form
if ($selected && ($selected == $arraydemandreason['id'] || $selected == $arraydemandreason['code']))
{
print '';
- }
- else
- {
+ } else {
print '';
}
$label = $arraydemandreason['label']; // Translation of label was already done into the ->loadCacheInputReason
@@ -3578,9 +3407,7 @@ class Form
$this->cache_types_paiements = dol_sort_array($this->cache_types_paiements, 'label', 'asc', 0, 0, 1);
return $num;
- }
- else
- {
+ } else {
dol_print_error($this->db);
return -1;
}
@@ -3620,9 +3447,7 @@ class Form
if ($selected == $id)
{
print '';
- }
- else
- {
+ } else {
print '';
}
print $arrayconditions['label'];
@@ -3725,9 +3550,7 @@ class Form
if ($selected == $id)
{
$return .= ''.$value;
- }
- else
- {
+ } else {
$return .= ''.$value;
}
$return .= '';
@@ -3842,35 +3665,33 @@ class Form
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture';
$sql .= ' WHERE entity IN ('.getEntity('invoice').')';
$sql .= ' AND situation_counter>=1';
+ $sql .= ' AND fk_soc = '.(int) $socid;
+ $sql .= ' AND type <> 2';
$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
$ref = 0;
while ($obj = $this->db->fetch_object($resql)) {
- //Same company ?
- if ($socid == $obj->fk_soc) {
- //Same cycle ?
- if ($obj->situation_cycle_ref != $ref) {
- // Just seen this cycle
- $ref = $obj->situation_cycle_ref;
- //not final ?
- if ($obj->situation_final != 1) {
- //Not prov?
- if (substr($obj->ref, 1, 4) != 'PROV') {
- if ($selected == $obj->rowid) {
- $opt .= ''.$obj->ref.'';
- } else {
- $opt .= ''.$obj->ref.'';
- }
+ //Same cycle ?
+ if ($obj->situation_cycle_ref != $ref) {
+ // Just seen this cycle
+ $ref = $obj->situation_cycle_ref;
+ //not final ?
+ if ($obj->situation_final != 1) {
+ //Not prov?
+ if (substr($obj->ref, 1, 4) != 'PROV') {
+ if ($selected == $obj->rowid) {
+ $opt .= ''.$obj->ref.'';
+ } else {
+ $opt .= ''.$obj->ref.'';
}
}
}
}
}
- }
- else
- {
+ } else {
dol_syslog("Error sql=".$sql.", error=".$this->error, LOG_ERR);
}
if ($opt == '')
@@ -3915,9 +3736,7 @@ class Form
if ($selected == $res->rowid)
{
$return .= ''.$unitLabel.'';
- }
- else
- {
+ } else {
$return .= ''.$unitLabel.'';
}
}
@@ -3975,9 +3794,7 @@ class Form
if ($selected == $obj->rowid)
{
print '';
- }
- else
- {
+ } else {
print '';
}
print trim($obj->label);
@@ -3987,14 +3804,11 @@ class Form
$i++;
}
print "";
- }
- else
- {
+ } else {
if ($status == 0) print ''.$langs->trans("NoActiveBankAccountDefined").'';
else print ''.$langs->trans("NoBankAccountFound").'';
}
- }
- else {
+ } else {
dol_print_error($this->db);
}
@@ -4047,9 +3861,7 @@ class Form
if ($selected == $obj->rowid)
{
print '';
- }
- else
- {
+ } else {
print '';
}
print trim($obj->name);
@@ -4058,14 +3870,11 @@ class Form
$i++;
}
print "";
- }
- else
- {
+ } else {
if ($status == 0) print ''.$langs->trans("NoActiveEstablishmentDefined").'';
else print ''.$langs->trans("NoEstablishmentFound").'';
}
- }
- else {
+ } else {
dol_print_error($this->db);
}
}
@@ -4108,7 +3917,7 @@ class Form
* Return list of categories having choosed type
*
* @param string|int $type Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated.
- * @param string $selected Id of category preselected or 'auto' (autoselect category if there is only one element)
+ * @param string $selected Id of category preselected or 'auto' (autoselect category if there is only one element). Not used if $outputmode = 1.
* @param string $htmlname HTML field name
* @param int $maxlength Maximum length for labels
* @param int|string|array $markafterid Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id.
@@ -4156,11 +3965,8 @@ class Form
$i++;
}
$this->db->free($result);
- }
- else dol_print_error($this->db);
- }
- else
- {
+ } else dol_print_error($this->db);
+ } else {
$cat = new Categorie($this->db);
$cate_arbo = $cat->get_full_arbo($type, $markafterid, $include);
}
@@ -4170,17 +3976,14 @@ class Form
if (is_array($cate_arbo))
{
if (!count($cate_arbo)) $output .= ''.$langs->trans("NoCategoriesDefined").'';
- else
- {
+ else {
$output .= ' ';
foreach ($cate_arbo as $key => $value)
{
if ($cate_arbo[$key]['id'] == $selected || ($selected == 'auto' && count($cate_arbo) == 1))
{
$add = 'selected ';
- }
- else
- {
+ } else {
$add = '';
}
$output .= ''.dol_trunc($cate_arbo[$key]['fulllabel'], $maxlength, 'middle').'';
@@ -4247,7 +4050,6 @@ class Form
public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0)
{
global $langs, $conf;
- global $useglobalvars;
$more = '';
$formconfirm = '';
@@ -4294,19 +4096,16 @@ class Form
if ($input['type'] == 'text')
{
$more .= ''."\n";
- }
- elseif ($input['type'] == 'password')
+ } elseif ($input['type'] == 'password')
{
$more .= ''."\n";
- }
- elseif ($input['type'] == 'select')
+ } elseif ($input['type'] == 'select')
{
$more .= '';
if (!empty($input['label'])) $more .= $input['label'].'
';
$more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss);
$more .= '
'."\n";
- }
- elseif ($input['type'] == 'checkbox')
+ } elseif ($input['type'] == 'checkbox')
{
$more .= '';
$more .= '
'.$input['label'].'
';
@@ -4316,8 +4115,7 @@ class Form
if (isset($input['disabled'])) $more .= ' disabled';
$more .= ' />
';
$more .= '
'."\n";
- }
- elseif ($input['type'] == 'radio')
+ } elseif ($input['type'] == 'radio')
{
$i = 0;
foreach ($input['values'] as $selkey => $selval)
@@ -4332,8 +4130,7 @@ class Form
$more .= '