';
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index f03242a8868..b9f5e3be6eb 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -50,7 +50,7 @@ class Propal extends CommonObject
public $fk_element='fk_propal';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
public $picto='propal';
-
+
/**
* {@inheritdoc}
*/
@@ -503,7 +503,7 @@ class Propal extends CommonObject
$this->line->label=$label;
$this->line->desc=$desc;
$this->line->qty=$qty;
-
+
$this->line->vat_src_code=$vat_src_code;
$this->line->tva_tx=$txtva;
$this->line->localtax1_tx=$txlocaltax1;
@@ -638,7 +638,7 @@ class Propal extends CommonObject
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$this->thirdparty,$mysoc);
-
+
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $txtva, $reg))
@@ -1180,7 +1180,7 @@ class Propal extends CommonObject
$clonedObj->ref = $modPropale->getNextValue($objsoc,$clonedObj);
// Create clone
-
+
$result=$clonedObj->create($user);
if ($result < 0) $error++;
else
@@ -1541,7 +1541,7 @@ class Propal extends CommonObject
dol_syslog(get_class($this)."::valid action abandonned: already validated", LOG_WARNING);
return 0;
}
-
+
if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->creer))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->propal->propal_advance->validate))))
{
@@ -1551,7 +1551,7 @@ class Propal extends CommonObject
}
$now=dol_now();
-
+
$this->db->begin();
// Numbering module definition
@@ -1839,7 +1839,7 @@ class Propal extends CommonObject
*/
function set_availability($user, $id, $notrigger=0)
{
- if (! empty($user->rights->propal->creer))
+ if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
{
$error=0;
@@ -1849,7 +1849,7 @@ class Propal extends CommonObject
$sql.= " SET fk_availability = '".$id."'";
$sql.= " WHERE rowid = ".$this->id;
- dol_syslog(__METHOD__, LOG_DEBUG);
+ dol_syslog(__METHOD__.' availability('.$availability_id.')', LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql)
{
@@ -1861,6 +1861,7 @@ class Propal extends CommonObject
{
$this->oldcopy= clone $this;
$this->fk_availability = $id;
+ $this->availability_id = $availability_id;
}
if (! $notrigger && empty($error))
@@ -1887,6 +1888,14 @@ class Propal extends CommonObject
return -1*$error;
}
}
+ else
+ {
+ $error_str='Propal status do not meet requirement '.$this->statut;
+ dol_syslog(__METHOD__.$error_str, LOG_ERR);
+ $this->error=$error_str;
+ $this->errors[]= $this->error;
+ return -2;
+ }
}
/**
@@ -1899,14 +1908,14 @@ class Propal extends CommonObject
*/
function set_demand_reason($user, $id, $notrigger=0)
{
- if (! empty($user->rights->propal->creer))
+ if (! empty($user->rights->propal->creer) && $this->statut >= self::STATUS_DRAFT)
{
$error=0;
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
- $sql.= " SET fk_input_reason = '".$id."'";
+ $sql.= " SET fk_input_reason = ".$id;
$sql.= " WHERE rowid = ".$this->id;
dol_syslog(__METHOD__, LOG_DEBUG);
@@ -1922,6 +1931,7 @@ class Propal extends CommonObject
{
$this->oldcopy= clone $this;
$this->fk_input_reason = $id;
+ $this->demand_reason_id = $id;
}
@@ -1949,6 +1959,14 @@ class Propal extends CommonObject
return -1*$error;
}
}
+ else
+ {
+ $error_str='Propal status do not meet requirement '.$this->statut;
+ dol_syslog(__METHOD__.$error_str, LOG_ERR);
+ $this->error=$error_str;
+ $this->errors[]= $this->error;
+ return -2;
+ }
}
/**
@@ -2406,7 +2424,7 @@ class Propal extends CommonObject
$this->statut = self::STATUS_DRAFT;
$this->brouillon = 1;
}
-
+
if (! $notrigger && empty($error))
{
// Call trigger
@@ -2733,6 +2751,7 @@ class Propal extends CommonObject
* @param int $availability_id Id of new delivery time
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int >0 if OK, <0 if KO
+ * @deprecated use set_availability
*/
function availability($availability_id, $notrigger=0)
{
@@ -2753,7 +2772,7 @@ class Propal extends CommonObject
$this->errors[]=$this->db->error();
$error++;
}
-
+
if (! $error)
{
$this->oldcopy= clone $this;
@@ -2800,6 +2819,7 @@ class Propal extends CommonObject
* @param int $demand_reason_id Id of new source demand
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
* @return int >0 si ok, <0 si ko
+ * @deprecated use set_demand_reason
*/
function demand_reason($demand_reason_id, $notrigger=0)
{
@@ -2820,7 +2840,7 @@ class Propal extends CommonObject
$this->errors[]=$this->db->error();
$error++;
}
-
+
if (! $error)
{
$this->oldcopy= clone $this;
@@ -3241,7 +3261,7 @@ class Propal extends CommonObject
global $langs, $conf, $user;
if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
-
+
$result='';
$label='';
$url='';
@@ -3272,7 +3292,7 @@ class Propal extends CommonObject
$url = DOL_URL_ROOT.'/comm/propal/document.php?id='.$this->id. $get_params;
}
}
-
+
$linkclose='';
if (empty($notooltip) && $user->rights->propal->lire)
{
@@ -3284,9 +3304,9 @@ class Propal extends CommonObject
$linkclose.= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose.=' class="classfortooltip"';
}
-
+
$linkstart = '
';
+ $linkstart.=$linkclose.'>';
$linkend='';
if ($withpicto)
@@ -3350,7 +3370,7 @@ class Propal extends CommonObject
$this->lines[$i]->fk_remise_except = $obj->fk_remise_except;
$this->lines[$i]->remise_percent = $obj->remise_percent;
- $this->lines[$i]->vat_src_code = $obj->vat_src_code;
+ $this->lines[$i]->vat_src_code = $obj->vat_src_code;
$this->lines[$i]->tva_tx = $obj->tva_tx;
$this->lines[$i]->info_bits = $obj->info_bits;
$this->lines[$i]->total_ht = $obj->total_ht;
@@ -3684,7 +3704,7 @@ class PropaleLigne extends CommonObjectLine
if (empty($this->multicurrency_total_ht)) $this->multicurrency_total_ht=0;
if (empty($this->multicurrency_total_tva)) $this->multicurrency_total_tva=0;
if (empty($this->multicurrency_total_ttc)) $this->multicurrency_total_ttc=0;
-
+
// if buy price not defined, define buyprice as configured in margin admin
if ($this->pa_ht == 0 && $pa_ht_isemptystring)
{
diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php
index 83d4535660d..17627964362 100644
--- a/htdocs/compta/facture/fiche-rec.php
+++ b/htdocs/compta/facture/fiche-rec.php
@@ -135,14 +135,14 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
if (empty($reshook))
{
if (GETPOST('cancel')) $action='';
-
+
// Set note
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
-
+
include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once
-
+
include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once
-
+
// Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers
{
@@ -160,7 +160,7 @@ if (empty($reshook))
$search_frequency='';
$search_array_options=array();
}
-
+
// Create predefined invoice
if ($action == 'add')
{
@@ -170,7 +170,7 @@ if (empty($reshook))
$action = "create";
$error++;
}
-
+
$frequency=GETPOST('frequency', 'int');
$reyear=GETPOST('reyear');
$remonth=GETPOST('remonth');
@@ -179,14 +179,14 @@ if (empty($reshook))
$remin=GETPOST('remin');
$nb_gen_max=GETPOST('nb_gen_max', 'int');
//if (empty($nb_gen_max)) $nb_gen_max =0;
-
+
if (GETPOST('frequency'))
{
- if (empty($reyear) || empty($remonth) || empty($reday))
+ if (empty($reyear) || empty($remonth) || empty($reday))
{
setEventMessages($langs->transnoentities("ErrorFieldRequired",$langs->trans("Date")), null, 'errors');
$action = "create";
- $error++;
+ $error++;
}
if ($nb_gen_max === '')
{
@@ -195,47 +195,47 @@ if (empty($reshook))
$error++;
}
}
-
+
if (! $error)
{
$object->titre = GETPOST('titre', 'alpha');
$object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public');
$object->usenewprice = GETPOST('usenewprice');
-
+
$object->frequency = $frequency;
$object->unit_frequency = GETPOST('unit_frequency', 'alpha');
$object->nb_gen_max = $nb_gen_max;
$object->auto_validate = GETPOST('auto_validate', 'int');
-
+
$object->fk_project = $projectid;
-
+
$date_next_execution = dol_mktime($rehour, $remin, 0, $remonth, $reday, $reyear);
$object->date_when = $date_next_execution;
-
+
// Get first contract linked to invoice used to generate template
if ($id > 0)
{
$srcObject = new Facture($db);
$srcObject->fetch(GETPOST('facid','int'));
-
+
$srcObject->fetchObjectLinked();
-
+
if (! empty($srcObject->linkedObjectsIds['contrat']))
{
$contractidid = reset($srcObject->linkedObjectsIds['contrat']);
-
+
$object->origin = 'contrat';
$object->origin_id = $contractidid;
$object->linked_objects[$object->origin] = $object->origin_id;
}
}
-
+
$db->begin();
-
+
$oldinvoice = new Facture($db);
$oldinvoice->fetch($id);
-
+
$result = $object->create($user, $oldinvoice->id);
if ($result > 0)
{
@@ -253,25 +253,25 @@ if (empty($reshook))
setEventMessages($object->error, $object->errors, 'errors');
$action = "create";
}
-
+
if (! $error)
{
$db->commit();
-
+
header("Location: " . $_SERVER['PHP_SELF'] . '?facid=' . $object->id);
exit;
}
else
{
$db->rollback();
-
+
$error++;
setEventMessages($object->error, $object->errors, 'errors');
$action = "create";
}
}
}
-
+
// Delete
if ($action == 'confirm_deleteinvoice' && $confirm == 'yes' && $user->rights->facture->supprimer)
{
@@ -279,14 +279,14 @@ if (empty($reshook))
header("Location: " . $_SERVER['PHP_SELF'] );
exit;
}
-
-
+
+
// Update field
// Set condition
if ($action == 'setconditions' && $user->rights->facture->creer)
{
$result=$object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'));
-
+
}
// Set mode
elseif ($action == 'setmode' && $user->rights->facture->creer)
@@ -336,24 +336,24 @@ if (empty($reshook))
{
$object->setAutoValidate(GETPOST('auto_validate', 'int'));
}
-
+
// Delete line
if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->facture->creer)
{
$object->fetch($id);
$object->fetch_thirdparty();
-
+
$db->begin();
-
+
$line=new FactureLigneRec($db);
-
+
// For triggers
$line->id = $lineid;
-
+
if ($line->delete() > 0)
{
$result=$object->update_price(1);
-
+
if ($result > 0)
{
$db->commit();
@@ -371,13 +371,13 @@ if (empty($reshook))
setEventMessages($line->error, $line->errors, 'errors');
}
}
-
+
// Add a new line
if ($action == 'addline' && $user->rights->facture->creer)
{
$langs->load('errors');
$error = 0;
-
+
// Set if we used free entry or predefined product
$predef='';
$product_desc=(GETPOST('dp_desc')?GETPOST('dp_desc'):'');
@@ -392,10 +392,10 @@ if (empty($reshook))
$idprod=GETPOST('idprod', 'int');
$tva_tx = '';
}
-
+
$qty = GETPOST('qty' . $predef);
$remise_percent = GETPOST('remise_percent' . $predef);
-
+
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
@@ -408,7 +408,7 @@ if (empty($reshook))
unset($_POST["options_" . $key . $predef]);
}
}
-
+
if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) {
setEventMessages($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), null, 'errors');
$error ++;
@@ -435,7 +435,7 @@ if (empty($reshook))
setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
$error ++;
}
-
+
if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod)))
{
$ret = $object->fetch($id);
@@ -444,16 +444,16 @@ if (empty($reshook))
exit();
}
$ret = $object->fetch_thirdparty();
-
+
// Clean parameters
$date_start = dol_mktime(GETPOST('date_start' . $predef . 'hour'), GETPOST('date_start' . $predef . 'min'), GETPOST('date_start' . $predef . 'sec'), GETPOST('date_start' . $predef . 'month'), GETPOST('date_start' . $predef . 'day'), GETPOST('date_start' . $predef . 'year'));
$date_end = dol_mktime(GETPOST('date_end' . $predef . 'hour'), GETPOST('date_end' . $predef . 'min'), GETPOST('date_end' . $predef . 'sec'), GETPOST('date_end' . $predef . 'month'), GETPOST('date_end' . $predef . 'day'), GETPOST('date_end' . $predef . 'year'));
$price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
-
+
// Define special_code for special lines
$special_code = 0;
// if (empty($_POST['qty'])) $special_code=3; // Options should not exists on invoices
-
+
// Ecrase $pu par celui du produit
// Ecrase $desc par celui du produit
// Ecrase $txtva par celui du produit
@@ -463,19 +463,19 @@ if (empty($reshook))
{
$prod = new Product($db);
$prod->fetch($idprod);
-
+
$label = ((GETPOST('product_label') && GETPOST('product_label') != $prod->label) ? GETPOST('product_label') : '');
-
+
// Update if prices fields are defined
$tva_tx = get_default_tva($mysoc, $object->thirdparty, $prod->id);
$tva_npr = get_default_npr($mysoc, $object->thirdparty, $prod->id);
if (empty($tva_tx)) $tva_npr=0;
-
+
$pu_ht = $prod->price;
$pu_ttc = $prod->price_ttc;
$price_min = $prod->price_min;
$price_base_type = $prod->price_base_type;
-
+
// We define price for product
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
{
@@ -493,11 +493,11 @@ if (empty($reshook))
elseif (! empty($conf->global->PRODUIT_CUSTOMER_PRICES))
{
require_once DOL_DOCUMENT_ROOT . '/product/class/productcustomerprice.class.php';
-
+
$prodcustprice = new Productcustomerprice($db);
-
+
$filter = array('t.fk_product' => $prod->id,'t.fk_soc' => $object->thirdparty->id);
-
+
$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
if ($result)
{
@@ -510,7 +510,7 @@ if (empty($reshook))
}
}
}
-
+
// if price ht was forced (ie: from gui when calculated by margin rate and cost price)
if (! empty($price_ht))
{
@@ -530,11 +530,11 @@ if (empty($reshook))
$pu_ttc = price2num($pu_ht * (1 + ($tva_tx / 100)), 'MU');
}
}
-
+
$desc = '';
-
+
// Define output language
- if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
+ if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE))
{
$outputlangs = $langs;
$newlang = '';
@@ -547,16 +547,16 @@ if (empty($reshook))
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
-
+
$desc = (! empty($prod->multilangs [$outputlangs->defaultlang] ["description"])) ? $prod->multilangs [$outputlangs->defaultlang] ["description"] : $prod->description;
}
else
{
$desc = $prod->description;
}
-
+
$desc = dol_concatdesc($desc, $product_desc);
-
+
// Add custom code and origin country into description
if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code)))
{
@@ -569,13 +569,13 @@ if (empty($reshook))
$tmptxt .= $langs->transnoentitiesnoconv("CountryOrigin") . ': ' . getCountry($prod->country_code, 0, $db, $langs, 0);
$tmptxt .= ')';
$desc = dol_concatdesc($desc, $tmptxt);
-
+
}
-
+
$type = $prod->type;
$fk_unit = $prod->fk_unit;
-
- }
+
+ }
else
{
$pu_ht = price2num($price_ht, 'MU');
@@ -586,21 +586,21 @@ if (empty($reshook))
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
$desc = $product_desc;
$type = GETPOST('type');
- $fk_unit= GETPOST('units', 'alpha');
+ $fk_unit= GETPOST('units', 'alpha');
}
-
+
// Margin
$fournprice = price2num(GETPOST('fournprice' . $predef) ? GETPOST('fournprice' . $predef) : '');
$buyingprice = price2num(GETPOST('buying_price' . $predef) != '' ? GETPOST('buying_price' . $predef) : ''); // If buying_price is '0', we must keep this value
-
+
// Local Taxes
$localtax1_tx = get_localtax($tva_tx, 1, $object->thirdparty, $mysoc, $tva_npr);
$localtax2_tx = get_localtax($tva_tx, 2, $object->thirdparty, $mysoc, $tva_npr);
-
+
$info_bits = 0;
if ($tva_npr)
$info_bits |= 0x01;
-
+
if (! empty($price_min) && (price2num($pu_ht) * (1 - price2num($remise_percent) / 100) < price2num($price_min)))
{
$mesg = $langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency));
@@ -610,7 +610,7 @@ if (empty($reshook))
{
// Insert line
$result = $object->addline($desc, $pu_ht, $qty, $tva_tx, $idprod, $remise_percent, $price_base_type, $info_bits, '', $pu_ttc, $type, - 1, $special_code, $label, $fk_unit);
-
+
if ($result > 0)
{
/*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
@@ -626,14 +626,14 @@ if (empty($reshook))
}
$model=$object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records
-
+
$result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
}*/
$object->fetch($object->id); // Reload lines
-
+
unset($_POST['prod_entry_mode']);
-
+
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['remise_percent']);
@@ -651,7 +651,7 @@ if (empty($reshook))
unset($_POST['dp_desc']);
unset($_POST['idprod']);
unset($_POST['units']);
-
+
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
unset($_POST['date_startsec']);
@@ -664,7 +664,7 @@ if (empty($reshook))
unset($_POST['date_endday']);
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
-
+
unset($_POST['situations']);
unset($_POST['progress']);
}
@@ -672,17 +672,17 @@ if (empty($reshook))
{
setEventMessages($object->error, $object->errors, 'errors');
}
-
- $action = '';
+
+ $action = '';
}
}
}
-
+
elseif ($action == 'updateligne' && $user->rights->facture->creer && ! GETPOST('cancel'))
{
if (! $object->fetch($id) > 0) dol_print_error($db);
$object->fetch_thirdparty();
-
+
// Clean parameters
$date_start = '';
$date_end = '';
@@ -692,27 +692,27 @@ if (empty($reshook))
$pu_ht = GETPOST('price_ht');
$vat_rate = (GETPOST('tva_tx') ? GETPOST('tva_tx') : 0);
$qty = GETPOST('qty');
-
+
// Define info_bits
$info_bits = 0;
if (preg_match('/\*/', $vat_rate))
$info_bits |= 0x01;
-
+
// Define vat_rate
$vat_rate = str_replace('*', '', $vat_rate);
$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty);
$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty);
-
+
// Add buying price
$fournprice = price2num(GETPOST('fournprice') ? GETPOST('fournprice') : '');
$buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value
-
+
// Extrafields
$extrafieldsline = new ExtraFields($db);
$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
$array_options = $extrafieldsline->getOptionalsFromPost($extralabelsline);
// Unset extrafield
- if (is_array($extralabelsline))
+ if (is_array($extralabelsline))
{
// Get extra fields
foreach ($extralabelsline as $key => $value)
@@ -720,15 +720,15 @@ if (empty($reshook))
unset($_POST["options_" . $key]);
}
}
-
+
// Define special_code for special lines
$special_code=GETPOST('special_code');
if (! GETPOST('qty')) $special_code=3;
-
+
/*$line = new FactureLigne($db);
$line->fetch(GETPOST('lineid'));
$percent = $line->get_prev_progress($object->id);
-
+
if (GETPOST('progress') < $percent)
{
$mesg = '
' . $langs->trans("CantBeLessThanMinPercent") . '
';
@@ -736,22 +736,22 @@ if (empty($reshook))
$error++;
$result = -1;
}*/
-
+
// Check minimum price
$productid = GETPOST('productid', 'int');
if (! empty($productid))
{
$product = new Product($db);
$product->fetch($productid);
-
+
$type = $product->type;
-
+
$price_min = $product->price_min;
if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->thirdparty->price_level))
$price_min = $product->multiprices_min [$object->thirdparty->price_level];
-
+
$label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label') : '');
-
+
// Check price is not lower than minimum (check is done only for standard or replacement invoices)
if (($object->type == Facture::TYPE_STANDARD || $object->type == Facture::TYPE_REPLACEMENT) && $price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) {
setEventMessages($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), null, 'errors');
@@ -760,7 +760,7 @@ if (empty($reshook))
} else {
$type = GETPOST('type');
$label = (GETPOST('product_label') ? GETPOST('product_label') : '');
-
+
// Check parameters
if (GETPOST('type') < 0) {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
@@ -772,14 +772,14 @@ if (empty($reshook))
setEventMessages($langs->trans('ErrorQtyForCustomerInvoiceCantBeNegative'), null, 'errors');
$error ++;
}
-
+
// Update line
if (! $error)
{
$result = $object->updateline(
GETPOST('lineid'),
$description,
- $pu_ht,
+ $pu_ht,
$qty,
$vat_rate,
GETPOST('productid'),
@@ -787,14 +787,14 @@ if (empty($reshook))
'HT',
$info_bits,
0,
- 0,
+ 0,
$type,
0,
- $special_code,
+ $special_code,
$label,
GETPOST('units')
);
-
+
if ($result >= 0)
{
/*if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
@@ -809,13 +809,13 @@ if (empty($reshook))
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
-
+
$ret = $object->fetch($id); // Reload to get new records
$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
}*/
-
+
$object->fetch($object->id); // Reload lines
-
+
unset($_POST['qty']);
unset($_POST['type']);
unset($_POST['productid']);
@@ -831,11 +831,11 @@ if (empty($reshook))
unset($_POST['buying_price']);
unset($_POST['np_marginRate']);
unset($_POST['np_markRate']);
-
+
unset($_POST['dp_desc']);
unset($_POST['idprod']);
unset($_POST['units']);
-
+
unset($_POST['date_starthour']);
unset($_POST['date_startmin']);
unset($_POST['date_startsec']);
@@ -848,7 +848,7 @@ if (empty($reshook))
unset($_POST['date_endday']);
unset($_POST['date_endmonth']);
unset($_POST['date_endyear']);
-
+
unset($_POST['situations']);
unset($_POST['progress']);
}
@@ -875,7 +875,7 @@ $companystatic = new Societe($db);
$now = dol_now();
$tmparray=dol_getdate($now);
$today = dol_mktime(23,59,59,$tmparray['mon'],$tmparray['mday'],$tmparray['year']); // Today is last second of current day
-
+
/*
* Create mode
@@ -887,11 +887,11 @@ if ($action == 'create')
$object = new Facture($db); // Source invoice
$product_static = new Product($db);
$formproject = new FormProjets($db);
-
+
if ($object->fetch($id, $ref) > 0)
{
$result = $object->getLinesArray();
-
+
print '
\n";
dol_fiche_end();
-
+
/**
* Barre d'actions
@@ -1513,19 +1513,19 @@ else
}
print '
';
}
@@ -1547,7 +1547,7 @@ else
if ($search_montant_ttc != '') $sql.= natural_search('f.total_ttc', $search_montant_ttc, 1);
if ($search_frequency == '1') $sql.= ' AND f.frequency > 0';
if ($search_frequency == '0') $sql.= ' AND (f.frequency IS NULL or f.frequency = 0)';
-
+
if ($month > 0)
{
if ($year > 0 && empty($day))
@@ -1573,7 +1573,7 @@ else
else if ($year_date_when > 0)
{
$sql.= " AND f.date_when BETWEEN '".$db->idate(dol_get_first_day($year_date_when,1,false))."' AND '".$db->idate(dol_get_last_day($year_date_when,12,false))."'";
- }
+ }
$nbtotalofrecords = -1;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -1581,15 +1581,15 @@ else
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
-
+
$sql.= $db->order($sortfield, $sortorder);
$sql.= $db->plimit($limit+1,$offset);
-
+
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
-
+
$param='&socid='.$socid;
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
@@ -1614,9 +1614,9 @@ else
$tmpkey=preg_replace('/search_options_/','',$key);
if ($val != '') $param.='&search_options_'.$tmpkey.'='.urlencode($val);
}
-
+
$massactionbutton=$form->selectMassAction('', $massaction == 'presend' ? array() : array('presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge")));
-
+
print '