| '.$langs->trans('MoreActions');
+ print ' | ';
+ print '';
+ print ' '.$langs->trans("None").' ';
+ // Add entry into bank accoun
+ if (!empty($conf->banque->enabled)) {
+ print ' '.$langs->trans("MoreActionBankDirect").' ';
+ }
+ // Add invoice with no payments
+ if (!empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
+ print 'fk_soc)) print ' disabled';
+ print '> '.$langs->trans("MoreActionInvoiceOnly");
+ if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
+ else {
+ print ' (';
+ if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
+ print $langs->trans("NoThirdPartyAssociatedToMember");
+ print ' - id.'&action=create_thirdparty">';
+ print $langs->trans("CreateDolibarrThirdParty");
+ print ')';
+ }
+ if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).'';
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
$prodtmp = new Product($db);
$result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
@@ -896,23 +896,23 @@ if ($rowid > 0) {
}
print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
}
- print ' ';
- }
- // Add invoice with payments
- if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
- print 'fk_soc)) print ' disabled';
- print '> '.$langs->trans("MoreActionBankViaInvoice");
- if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
- else {
- print ' (';
- if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
- print $langs->trans("NoThirdPartyAssociatedToMember");
- print ' - id.'&action=create_thirdparty">';
- print $langs->trans("CreateDolibarrThirdParty");
- print ')';
- }
- if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).'';
+ print ' ';
+ }
+ // Add invoice with payments
+ if (!empty($conf->banque->enabled) && !empty($conf->societe->enabled) && !empty($conf->facture->enabled)) {
+ print 'fk_soc)) print ' disabled';
+ print '> '.$langs->trans("MoreActionBankViaInvoice");
+ if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')';
+ else {
+ print ' (';
+ if (empty($object->fk_soc)) print img_warning($langs->trans("NoThirdPartyAssociatedToMember"));
+ print $langs->trans("NoThirdPartyAssociatedToMember");
+ print ' - id.'&action=create_thirdparty">';
+ print $langs->trans("CreateDolibarrThirdParty");
+ print ')';
+ }
+ if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription", 0).'';
if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
$prodtmp = new Product($db);
$result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php
index 2eb2c0edad1..2705ede5540 100644
--- a/htdocs/admin/company.php
+++ b/htdocs/admin/company.php
@@ -88,9 +88,9 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
dolibarr_del_const($db, "MAIN_INFO_SOCIETE_STATE", $conf->entity);
}
- $db->begin();
+ $db->begin();
- dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADDRESS", GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_TOWN", GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml'), 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ZIP", GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alphanohtml'), 'chaine', 0, '', $conf->entity);
@@ -141,8 +141,8 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
// Create thumbs of logo (Note that PDF use original file and not thumbs)
if ($isimage > 0)
{
- // Create thumbs
- //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
+ // Create thumbs
+ //$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
// Create small thumb, Used on logon for example
$imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
@@ -269,7 +269,7 @@ if ($action == 'addthumb' || $action == 'addthumbsquarred') // Regenerate thumb
$reg = array();
- // Create thumbs
+ // Create thumbs
//$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
// Create small thumb. Used on logon for example
@@ -777,8 +777,8 @@ if ($mysoc->useLocalTax(2))
$tooltiphelp = ($tooltiphelp != "LocalTax2IsUsedExample" ? "".$langs->trans("Example").': '.$langs->transcountry("LocalTax2IsUsedExample", $mysoc->country_code)."\n" : "");
if (!isOnlyOneLocalTax(2))
{
- print ' : ';
- $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
+ print ' : ';
+ $formcompany->select_localtax(2, $conf->global->MAIN_INFO_VALUE_LOCALTAX2, "lt2");
}
print ' : ';
print $form->selectarray("clt2", $opcions, $conf->global->MAIN_INFO_LOCALTAX_CALC2);
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index 987d7a256af..43ce69f6e02 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -881,7 +881,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if (in_array($rowidcol, array('code', 'code_iso'))) {
$sql .= " WHERE ".$rowidcol." = '".$db->escape($rowid)."'";
} else {
- $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
+ $sql .= " WHERE ".$rowidcol." = ".((int) $rowid);
}
if (in_array('entity', $listfieldmodify)) $sql .= " AND entity = '".getEntity($tabname[$id])."'";
diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php
index 036f31a99d7..05782b8ec67 100644
--- a/htdocs/asset/class/asset.class.php
+++ b/htdocs/asset/class/asset.class.php
@@ -113,17 +113,17 @@ class Asset extends CommonObject
*/
public $entity;
- /**
- * @var string Asset label
- */
- public $label;
+ /**
+ * @var string Asset label
+ */
+ public $label;
public $amount;
/**
* @var int Thirdparty ID
*/
- public $fk_soc;
+ public $fk_soc;
/**
* @var string description
@@ -134,21 +134,21 @@ class Asset extends CommonObject
public $note_private;
/**
- * @var integer|string date_creation
- */
+ * @var integer|string date_creation
+ */
public $date_creation;
public $tms;
/**
- * @var int ID
- */
+ * @var int ID
+ */
public $fk_user_creat;
/**
- * @var int ID
- */
+ * @var int ID
+ */
public $fk_user_modif;
public $import_key;
@@ -381,7 +381,7 @@ class Asset extends CommonObject
return $this->LibStatut($this->status, $mode);
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return the status
*
@@ -391,14 +391,14 @@ class Asset extends CommonObject
*/
public static function LibStatut($status, $mode = 0)
{
- // phpcs:enable
+ // phpcs:enable
global $langs;
$langs->load("contracts");
- $labelStatus = array();
+ $labelStatus = array();
$labelStatus[self::STATUS_DRAFT] = $langs->trans('Disabled');
$labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
- $labelStatusShort = array();
+ $labelStatusShort = array();
$labelStatusShort[self::STATUS_DRAFT] = $langs->trans('Disabled');
$labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled');
diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php
index 8aeaa2a9fe8..5771ead70f1 100644
--- a/htdocs/compta/facture/class/facture-rec.class.php
+++ b/htdocs/compta/facture/class/facture-rec.class.php
@@ -97,7 +97,7 @@ class FactureRec extends CommonInvoice
*/
public $frequency;
- /**
+ /**
* @var string Unit frequency
*/
public $unit_frequency;
@@ -317,46 +317,46 @@ class FactureRec extends CommonInvoice
$tva_tx = $facsrc->lines[$i]->tva_tx;
if (!empty($facsrc->lines[$i]->vat_src_code) && !preg_match('/\(/', $tva_tx)) $tva_tx .= ' ('.$facsrc->lines[$i]->vat_src_code.')';
- $result_insert = $this->addline(
- $facsrc->lines[$i]->desc,
- $facsrc->lines[$i]->subprice,
- $facsrc->lines[$i]->qty,
+ $result_insert = $this->addline(
+ $facsrc->lines[$i]->desc,
+ $facsrc->lines[$i]->subprice,
+ $facsrc->lines[$i]->qty,
$tva_tx,
- $facsrc->lines[$i]->localtax1_tx,
- $facsrc->lines[$i]->localtax2_tx,
- $facsrc->lines[$i]->fk_product,
- $facsrc->lines[$i]->remise_percent,
- 'HT',
+ $facsrc->lines[$i]->localtax1_tx,
+ $facsrc->lines[$i]->localtax2_tx,
+ $facsrc->lines[$i]->fk_product,
+ $facsrc->lines[$i]->remise_percent,
+ 'HT',
$facsrc->lines[$i]->info_bits,
- '',
- 0,
- $facsrc->lines[$i]->product_type,
- $facsrc->lines[$i]->rang,
- $facsrc->lines[$i]->special_code,
- $facsrc->lines[$i]->label,
+ '',
+ 0,
+ $facsrc->lines[$i]->product_type,
+ $facsrc->lines[$i]->rang,
+ $facsrc->lines[$i]->special_code,
+ $facsrc->lines[$i]->label,
$facsrc->lines[$i]->fk_unit,
$facsrc->lines[$i]->multicurrency_subprice
- );
+ );
if ($result_insert < 0)
{
$error++;
} else {
- $objectline = new FactureLigneRec($this->db);
- if ($objectline->fetch($result_insert))
- {
- // Extrafields
- if (method_exists($facsrc->lines[$i], 'fetch_optionals')) {
- $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->rowid);
- $objectline->array_options = $facsrc->lines[$i]->array_options;
- }
+ $objectline = new FactureLigneRec($this->db);
+ if ($objectline->fetch($result_insert))
+ {
+ // Extrafields
+ if (method_exists($facsrc->lines[$i], 'fetch_optionals')) {
+ $facsrc->lines[$i]->fetch_optionals($facsrc->lines[$i]->rowid);
+ $objectline->array_options = $facsrc->lines[$i]->array_options;
+ }
- $result = $objectline->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
+ $result = $objectline->insertExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ }
+ }
}
}
@@ -370,27 +370,27 @@ class FactureRec extends CommonInvoice
{
foreach ($this->linked_objects as $origin => $tmp_origin_id)
{
- if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
- {
- foreach ($tmp_origin_id as $origin_id)
- {
- $ret = $this->add_object_linked($origin, $origin_id);
- if (!$ret)
- {
- $this->error = $this->db->lasterror();
- $error++;
- }
- }
- } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
- {
- $origin_id = $tmp_origin_id;
- $ret = $this->add_object_linked($origin, $origin_id);
- if (!$ret)
- {
- $this->error = $this->db->lasterror();
- $error++;
- }
- }
+ if (is_array($tmp_origin_id)) // New behaviour, if linked_object can have several links per type, so is something like array('contract'=>array(id1, id2, ...))
+ {
+ foreach ($tmp_origin_id as $origin_id)
+ {
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (!$ret)
+ {
+ $this->error = $this->db->lasterror();
+ $error++;
+ }
+ }
+ } else // Old behaviour, if linked_object has only one link per type, so is something like array('contract'=>id1))
+ {
+ $origin_id = $tmp_origin_id;
+ $ret = $this->add_object_linked($origin, $origin_id);
+ if (!$ret)
+ {
+ $this->error = $this->db->lasterror();
+ $error++;
+ }
+ }
}
}
@@ -422,7 +422,7 @@ class FactureRec extends CommonInvoice
return $this->id;
}
} else {
- $this->error = $this->db->lasterror();
+ $this->error = $this->db->lasterror();
$this->db->rollback();
return -2;
}
@@ -442,46 +442,46 @@ class FactureRec extends CommonInvoice
*/
public function update(User $user, $notrigger = 0)
{
- global $conf;
+ global $conf;
- $error = 0;
+ $error = 0;
- $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET";
- $sql .= " fk_soc = ".$this->fk_soc;
- // TODO Add missing fields
- $sql .= " WHERE rowid = ".$this->id;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facture_rec SET";
+ $sql .= " fk_soc = ".$this->fk_soc;
+ // TODO Add missing fields
+ $sql .= " WHERE rowid = ".$this->id;
- dol_syslog(get_class($this)."::update", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- if (!$error)
- {
- $result = $this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
+ dol_syslog(get_class($this)."::update", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ if (!$error)
+ {
+ $result = $this->insertExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ }
+ }
- if (!$error && !$notrigger)
- {
- // Call trigger
- $result = $this->call_trigger('BILLREC_UPDATE', $user);
- if ($result < 0)
- {
- $this->db->rollback();
- return -2;
- }
- // End call triggers
- }
- $this->db->commit();
- return 1;
- } else {
- $this->error = $this->db->lasterror();
- $this->db->rollback();
- return -2;
- }
+ if (!$error && !$notrigger)
+ {
+ // Call trigger
+ $result = $this->call_trigger('BILLREC_UPDATE', $user);
+ if ($result < 0)
+ {
+ $this->db->rollback();
+ return -2;
+ }
+ // End call triggers
+ }
+ $this->db->commit();
+ return 1;
+ } else {
+ $this->error = $this->db->lasterror();
+ $this->db->rollback();
+ return -2;
+ }
}
/**
@@ -498,13 +498,13 @@ class FactureRec extends CommonInvoice
$sql .= ', f.remise_percent, f.remise_absolue, f.remise';
$sql .= ', f.date_lim_reglement as dlr';
$sql .= ', f.note_private, f.note_public, f.fk_user_author';
- $sql .= ', f.modelpdf';
+ $sql .= ', f.modelpdf';
$sql .= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet as fk_project';
$sql .= ', f.fk_account';
$sql .= ', f.frequency, f.unit_frequency, f.date_when, f.date_last_gen, f.nb_gen_done, f.nb_gen_max, f.usenewprice, f.auto_validate';
- $sql .= ', f.generate_pdf';
- $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc";
- $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
+ $sql .= ', f.generate_pdf';
+ $sql .= ", f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc";
+ $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle';
$sql .= ', c.code as cond_reglement_code, c.libelle as cond_reglement_libelle, c.libelle_facture as cond_reglement_libelle_doc';
//$sql.= ', el.fk_source';
$sql .= ' FROM '.MAIN_DB_PREFIX.'facture_rec as f';
@@ -618,21 +618,21 @@ class FactureRec extends CommonInvoice
*/
public function getLinesArray()
{
- return $this->fetch_lines();
+ return $this->fetch_lines();
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Get lines of template invoices into this->lines
*
* @return int 1 if OK, < 0 if KO
- */
+ */
public function fetch_lines()
{
global $extrafields;
- // phpcs:enable
+ // phpcs:enable
$this->lines = array();
// Retrieve all extrafield for line
@@ -710,7 +710,7 @@ class FactureRec extends CommonInvoice
$line->rang = $objp->rang;
$line->special_code = $objp->special_code;
$line->fk_unit = $objp->fk_unit;
- $line->fk_contract_line = $objp->fk_contract_line;
+ $line->fk_contract_line = $objp->fk_contract_line;
// Ne plus utiliser
$line->price = $objp->price;
@@ -750,17 +750,17 @@ class FactureRec extends CommonInvoice
*/
public function delete(User $user, $notrigger = 0, $idwarehouse = -1)
{
- $rowid = $this->id;
+ $rowid = $this->id;
- dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
+ dol_syslog(get_class($this)."::delete rowid=".$rowid, LOG_DEBUG);
- $error = 0;
+ $error = 0;
$this->db->begin();
$main = MAIN_DB_PREFIX.'facturedet_rec';
- $ef = $main."_extrafields";
- $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)";
- dol_syslog($sqlef);
+ $ef = $main."_extrafields";
+ $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_facture = $rowid)";
+ dol_syslog($sqlef);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet_rec WHERE fk_facture = ".$rowid;
dol_syslog($sql);
if ($this->db->query($sqlef) && $this->db->query($sql))
@@ -773,8 +773,8 @@ class FactureRec extends CommonInvoice
$res = $this->deleteObjectLinked();
if ($res < 0) $error = -3;
// Delete extrafields
- $res = $this->deleteExtraFields();
- if ($res < 0) $error = -4;
+ $res = $this->deleteExtraFields();
+ if ($res < 0) $error = -4;
} else {
$this->error = $this->db->lasterror();
$error = -1;
@@ -786,11 +786,11 @@ class FactureRec extends CommonInvoice
if (!$error)
{
- $this->db->commit();
- return 1;
+ $this->db->commit();
+ return 1;
} else {
- $this->db->rollback();
- return $error;
+ $this->db->rollback();
+ return $error;
}
}
@@ -798,33 +798,33 @@ class FactureRec extends CommonInvoice
/**
* Add a line to invoice
*
- * @param string $desc Description de la ligne
- * @param double $pu_ht Prix unitaire HT (> 0 even for credit note)
- * @param double $qty Quantite
- * @param double $txtva Taux de tva force, sinon -1
+ * @param string $desc Description de la ligne
+ * @param double $pu_ht Prix unitaire HT (> 0 even for credit note)
+ * @param double $qty Quantite
+ * @param double $txtva Taux de tva force, sinon -1
* @param double $txlocaltax1 Local tax 1 rate (deprecated)
* @param double $txlocaltax2 Local tax 2 rate (deprecated)
- * @param int $fk_product Product/Service ID predefined
- * @param double $remise_percent Percentage discount of the line
- * @param string $price_base_type HT or TTC
- * @param int $info_bits VAT npr or not ?
- * @param int $fk_remise_except Id remise
- * @param double $pu_ttc Prix unitaire TTC (> 0 even for credit note)
- * @param int $type Type of line (0=product, 1=service)
- * @param int $rang Position of line
- * @param int $special_code Special code
- * @param string $label Label of the line
- * @param string $fk_unit Unit
+ * @param int $fk_product Product/Service ID predefined
+ * @param double $remise_percent Percentage discount of the line
+ * @param string $price_base_type HT or TTC
+ * @param int $info_bits VAT npr or not ?
+ * @param int $fk_remise_except Id remise
+ * @param double $pu_ttc Prix unitaire TTC (> 0 even for credit note)
+ * @param int $type Type of line (0=product, 1=service)
+ * @param int $rang Position of line
+ * @param int $special_code Special code
+ * @param string $label Label of the line
+ * @param string $fk_unit Unit
* @param double $pu_ht_devise Unit price in currency
* @param int $date_start_fill 1=Flag to fill start date when generating invoice
* @param int $date_end_fill 1=Flag to fill end date when generating invoice
* @param int $fk_fournprice Supplier price id (to calculate margin) or ''
* @param int $pa_ht Buying price of line (to calculate margin) or ''
- * @return int <0 if KO, Id of line if OK
+ * @return int <0 if KO, Id of line if OK
*/
public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0)
{
- global $mysoc;
+ global $mysoc;
$facid = $this->id;
@@ -1008,131 +1008,131 @@ class FactureRec extends CommonInvoice
*/
public function updateline($rowid, $desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocaltax2 = 0, $fk_product = 0, $remise_percent = 0, $price_base_type = 'HT', $info_bits = 0, $fk_remise_except = '', $pu_ttc = 0, $type = 0, $rang = -1, $special_code = 0, $label = '', $fk_unit = null, $pu_ht_devise = 0, $notrigger = 0, $date_start_fill = 0, $date_end_fill = 0, $fk_fournprice = null, $pa_ht = 0)
{
- global $mysoc;
+ global $mysoc;
- $facid = $this->id;
+ $facid = $this->id;
- dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG);
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+ dol_syslog(get_class($this)."::updateline facid=".$facid." rowid=$rowid, desc=$desc, pu_ht=$pu_ht, qty=$qty, txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product, remise_percent=$remise_percent, info_bits=$info_bits, fk_remise_except=$fk_remise_except, price_base_type=$price_base_type, pu_ttc=$pu_ttc, type=$type, fk_unit=$fk_unit, pu_ht_devise=$pu_ht_devise", LOG_DEBUG);
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- // Clean parameters
- if (empty($remise_percent)) $remise_percent = 0;
+ // Clean parameters
+ if (empty($remise_percent)) $remise_percent = 0;
- // Check parameters
- if ($type < 0) return -1;
+ // Check parameters
+ if ($type < 0) return -1;
- if ($this->brouillon)
- {
- // Clean parameters
- $remise_percent = price2num($remise_percent);
- $qty = price2num($qty);
- if (empty($info_bits)) $info_bits = 0;
- $pu_ht = price2num($pu_ht);
- $pu_ttc = price2num($pu_ttc);
- $pu_ht_devise = price2num($pu_ht_devise);
- $txtva = price2num($txtva);
- $txlocaltax1 = price2num($txlocaltax1);
- $txlocaltax2 = price2num($txlocaltax2);
- if (empty($txlocaltax1)) $txlocaltax1 = 0;
- if (empty($txlocaltax2)) $txlocaltax2 = 0;
+ if ($this->brouillon)
+ {
+ // Clean parameters
+ $remise_percent = price2num($remise_percent);
+ $qty = price2num($qty);
+ if (empty($info_bits)) $info_bits = 0;
+ $pu_ht = price2num($pu_ht);
+ $pu_ttc = price2num($pu_ttc);
+ $pu_ht_devise = price2num($pu_ht_devise);
+ $txtva = price2num($txtva);
+ $txlocaltax1 = price2num($txlocaltax1);
+ $txlocaltax2 = price2num($txlocaltax2);
+ if (empty($txlocaltax1)) $txlocaltax1 = 0;
+ if (empty($txlocaltax2)) $txlocaltax2 = 0;
- if (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0;
- 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 (empty($this->multicurrency_subprice)) $this->multicurrency_subprice = 0;
+ 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 ($price_base_type == 'HT')
- {
- $pu = $pu_ht;
- } else {
- $pu = $pu_ttc;
- }
+ if ($price_base_type == 'HT')
+ {
+ $pu = $pu_ht;
+ } else {
+ $pu = $pu_ttc;
+ }
- // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva
- // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
- // la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
+ // Calculate total with, without tax and tax from qty, pu, remise_percent and txtva
+ // TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
+ // 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);
+ $localtaxes_type = getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
- // Clean vat code
- $vat_src_code = '';
- if (preg_match('/\((.*)\)/', $txtva, $reg))
- {
- $vat_src_code = $reg[1];
- $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
- }
+ // Clean vat code
+ $vat_src_code = '';
+ if (preg_match('/\((.*)\)/', $txtva, $reg))
+ {
+ $vat_src_code = $reg[1];
+ $txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
+ }
- $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
+ $tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
- $total_ht = $tabprice[0];
- $total_tva = $tabprice[1];
- $total_ttc = $tabprice[2];
- $total_localtax1 = $tabprice[9];
- $total_localtax2 = $tabprice[10];
- $pu_ht = $tabprice[3];
- $pu_tva = $tabprice[4];
- $pu_ttc = $tabprice[5];
+ $total_ht = $tabprice[0];
+ $total_tva = $tabprice[1];
+ $total_ttc = $tabprice[2];
+ $total_localtax1 = $tabprice[9];
+ $total_localtax2 = $tabprice[10];
+ $pu_ht = $tabprice[3];
+ $pu_tva = $tabprice[4];
+ $pu_ttc = $tabprice[5];
- // MultiCurrency
- $multicurrency_total_ht = $tabprice[16];
- $multicurrency_total_tva = $tabprice[17];
- $multicurrency_total_ttc = $tabprice[18];
- $pu_ht_devise = $tabprice[19];
+ // MultiCurrency
+ $multicurrency_total_ht = $tabprice[16];
+ $multicurrency_total_tva = $tabprice[17];
+ $multicurrency_total_ttc = $tabprice[18];
+ $pu_ht_devise = $tabprice[19];
- $product_type = $type;
- if ($fk_product)
- {
- $product = new Product($this->db);
- $result = $product->fetch($fk_product);
- $product_type = $product->type;
- }
+ $product_type = $type;
+ if ($fk_product)
+ {
+ $product = new Product($this->db);
+ $result = $product->fetch($fk_product);
+ $product_type = $product->type;
+ }
- $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET ";
- $sql .= "fk_facture = ".((int) $facid);
- $sql .= ", label=".(!empty($label) ? "'".$this->db->escape($label)."'" : "null");
- $sql .= ", description='".$this->db->escape($desc)."'";
- $sql .= ", price=".price2num($pu_ht);
- $sql .= ", qty=".price2num($qty);
- $sql .= ", tva_tx=".price2num($txtva);
- $sql .= ", vat_src_code='".$this->db->escape($vat_src_code)."'";
- $sql .= ", localtax1_tx=".$txlocaltax1;
- $sql .= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'";
- $sql .= ", localtax2_tx=".$txlocaltax2;
- $sql .= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'";
- $sql .= ", fk_product=".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null");
- $sql .= ", product_type=".$product_type;
- $sql .= ", remise_percent='".price2num($remise_percent)."'";
- $sql .= ", subprice='".price2num($pu_ht)."'";
- $sql .= ", total_ht='".price2num($total_ht)."'";
- $sql .= ", total_tva='".price2num($total_tva)."'";
- $sql .= ", total_localtax1='".price2num($total_localtax1)."'";
- $sql .= ", total_localtax2='".price2num($total_localtax2)."'";
- $sql .= ", total_ttc='".price2num($total_ttc)."'";
- $sql .= ", date_start_fill=".((int) $date_start_fill);
- $sql .= ", date_end_fill=".((int) $date_end_fill);
- $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null');
- $sql .= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0);
- $sql .= ", info_bits=".$info_bits;
- $sql .= ", rang=".$rang;
- $sql .= ", special_code=".$special_code;
- $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null");
- $sql .= ', multicurrency_subprice = '.$pu_ht_devise;
- $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht;
- $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva;
- $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc;
- $sql .= " WHERE rowid = ".$rowid;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET ";
+ $sql .= "fk_facture = ".((int) $facid);
+ $sql .= ", label=".(!empty($label) ? "'".$this->db->escape($label)."'" : "null");
+ $sql .= ", description='".$this->db->escape($desc)."'";
+ $sql .= ", price=".price2num($pu_ht);
+ $sql .= ", qty=".price2num($qty);
+ $sql .= ", tva_tx=".price2num($txtva);
+ $sql .= ", vat_src_code='".$this->db->escape($vat_src_code)."'";
+ $sql .= ", localtax1_tx=".$txlocaltax1;
+ $sql .= ", localtax1_type='".$this->db->escape($localtaxes_type[0])."'";
+ $sql .= ", localtax2_tx=".$txlocaltax2;
+ $sql .= ", localtax2_type='".$this->db->escape($localtaxes_type[2])."'";
+ $sql .= ", fk_product=".(!empty($fk_product) ? "'".$this->db->escape($fk_product)."'" : "null");
+ $sql .= ", product_type=".$product_type;
+ $sql .= ", remise_percent='".price2num($remise_percent)."'";
+ $sql .= ", subprice='".price2num($pu_ht)."'";
+ $sql .= ", total_ht='".price2num($total_ht)."'";
+ $sql .= ", total_tva='".price2num($total_tva)."'";
+ $sql .= ", total_localtax1='".price2num($total_localtax1)."'";
+ $sql .= ", total_localtax2='".price2num($total_localtax2)."'";
+ $sql .= ", total_ttc='".price2num($total_ttc)."'";
+ $sql .= ", date_start_fill=".((int) $date_start_fill);
+ $sql .= ", date_end_fill=".((int) $date_end_fill);
+ $sql .= ", fk_product_fournisseur_price=".($fk_fournprice > 0 ? $fk_fournprice : 'null');
+ $sql .= ", buy_price_ht=".($pa_ht ? price2num($pa_ht) : 0);
+ $sql .= ", info_bits=".$info_bits;
+ $sql .= ", rang=".$rang;
+ $sql .= ", special_code=".$special_code;
+ $sql .= ", fk_unit=".($fk_unit ? "'".$this->db->escape($fk_unit)."'" : "null");
+ $sql .= ', multicurrency_subprice = '.$pu_ht_devise;
+ $sql .= ', multicurrency_total_ht = '.$multicurrency_total_ht;
+ $sql .= ', multicurrency_total_tva = '.$multicurrency_total_tva;
+ $sql .= ', multicurrency_total_ttc = '.$multicurrency_total_ttc;
+ $sql .= " WHERE rowid = ".$rowid;
- dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- $this->id = $facid;
- $this->update_price();
- return 1;
- } else {
- $this->error = $this->db->lasterror();
- return -1;
- }
- }
+ dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->id = $facid;
+ $this->update_price();
+ return 1;
+ } else {
+ $this->error = $this->db->lasterror();
+ return -1;
+ }
+ }
}
@@ -1328,8 +1328,8 @@ class FactureRec extends CommonInvoice
* @param int $max Maxlength of ref
* @param int $short 1=Return just URL
* @param string $moretitle Add more text to title tooltip
- * @param int $notooltip 1=Disable tooltip
- * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @param int $notooltip 1=Disable tooltip
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
* @return string String with URL
*/
public function getNomUrl($withpicto = 0, $option = '', $max = 0, $short = 0, $moretitle = '', $notooltip = '', $save_lastsearch_value = -1)
@@ -1356,17 +1356,17 @@ class FactureRec extends CommonInvoice
}
}
- $url = DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$this->id;
+ $url = DOL_URL_ROOT.'/compta/facture/card-rec.php?facid='.$this->id;
- if ($short) return $url;
+ if ($short) return $url;
- if ($option != 'nolink')
- {
- // Add param to save lastsearch_values or not
- $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
- if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
- }
+ if ($option != 'nolink')
+ {
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
+ if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ }
$linkstart = '';
$linkend = '';
@@ -1391,7 +1391,7 @@ class FactureRec extends CommonInvoice
return $this->LibStatut($this->frequency ? 1 : 0, $this->suspended, $mode, $alreadypaid, empty($this->type) ? 0 : $this->type);
}
- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+ // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Return label of a status
*
@@ -1404,7 +1404,7 @@ class FactureRec extends CommonInvoice
*/
public function LibStatut($recur, $status, $mode = 0, $alreadypaid = -1, $type = 0)
{
- // phpcs:enable
+ // phpcs:enable
global $langs;
$langs->load('bills');
@@ -1553,7 +1553,7 @@ class FactureRec extends CommonInvoice
$arraynow = dol_getdate($now);
$nownotime = dol_mktime(0, 0, 0, $arraynow['mon'], $arraynow['mday'], $arraynow['year']);
- // Load array of products prodids
+ // Load array of products prodids
$num_prods = 0;
$prodids = array();
@@ -1690,190 +1690,190 @@ class FactureRec extends CommonInvoice
}
/**
- * Update frequency and unit
- *
- * @param int $frequency value of frequency
- * @param string $unit unit of frequency (d, m, y)
- * @return int <0 if KO, >0 if OK
- */
- public function setFrequencyAndUnit($frequency, $unit)
- {
- if (!$this->table_element) {
- dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR);
- return -1;
- }
-
- if (!empty($frequency) && empty($unit)) {
- dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined", LOG_ERR);
- return -2;
- }
-
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null');
- if (!empty($unit)) {
- $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\'';
+ * Update frequency and unit
+ *
+ * @param int $frequency value of frequency
+ * @param string $unit unit of frequency (d, m, y)
+ * @return int <0 if KO, >0 if OK
+ */
+ public function setFrequencyAndUnit($frequency, $unit)
+ {
+ if (!$this->table_element) {
+ dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with property table_element not defined", LOG_ERR);
+ return -1;
}
- $sql .= ' WHERE rowid = '.$this->id;
- dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG);
- if ($this->db->query($sql)) {
- $this->frequency = $frequency;
- if (!empty($unit)) $this->unit_frequency = $unit;
- return 1;
- } else {
- dol_print_error($this->db);
- return -1;
- }
- }
+ if (!empty($frequency) && empty($unit)) {
+ dol_syslog(get_class($this)."::setFrequencyAndUnit was called on objet with params frequency defined but unit not defined", LOG_ERR);
+ return -2;
+ }
+
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' SET frequency = '.($frequency ? $this->db->escape($frequency) : 'null');
+ if (!empty($unit)) {
+ $sql .= ', unit_frequency = \''.$this->db->escape($unit).'\'';
+ }
+ $sql .= ' WHERE rowid = '.$this->id;
+
+ dol_syslog(get_class($this)."::setFrequencyAndUnit", LOG_DEBUG);
+ if ($this->db->query($sql)) {
+ $this->frequency = $frequency;
+ if (!empty($unit)) $this->unit_frequency = $unit;
+ return 1;
+ } else {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
/**
- * Update the next date of execution
- *
- * @param datetime $date date of execution
- * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done
- * @return int <0 if KO, >0 if OK
- */
- public function setNextDate($date, $increment_nb_gen_done = 0)
- {
- if (!$this->table_element)
- {
- dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR);
- return -1;
- }
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null");
- if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1';
- $sql .= ' WHERE rowid = '.$this->id;
+ * Update the next date of execution
+ *
+ * @param datetime $date date of execution
+ * @param int $increment_nb_gen_done 0 do nothing more, >0 increment nb_gen_done
+ * @return int <0 if KO, >0 if OK
+ */
+ public function setNextDate($date, $increment_nb_gen_done = 0)
+ {
+ if (!$this->table_element)
+ {
+ dol_syslog(get_class($this)."::setNextDate was called on objet with property table_element not defined", LOG_ERR);
+ return -1;
+ }
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= " SET date_when = ".($date ? "'".$this->db->idate($date)."'" : "null");
+ if ($increment_nb_gen_done > 0) $sql .= ', nb_gen_done = nb_gen_done + 1';
+ $sql .= ' WHERE rowid = '.$this->id;
- dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- $this->date_when = $date;
- if ($increment_nb_gen_done > 0) $this->nb_gen_done++;
- return 1;
- } else {
- dol_print_error($this->db);
- return -1;
- }
- }
+ dol_syslog(get_class($this)."::setNextDate", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->date_when = $date;
+ if ($increment_nb_gen_done > 0) $this->nb_gen_done++;
+ return 1;
+ } else {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
/**
- * Update the maximum period
- *
- * @param int $nb number of maximum period
- * @return int <0 if KO, >0 if OK
- */
- public function setMaxPeriod($nb)
- {
- if (!$this->table_element)
- {
- dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR);
- return -1;
- }
+ * Update the maximum period
+ *
+ * @param int $nb number of maximum period
+ * @return int <0 if KO, >0 if OK
+ */
+ public function setMaxPeriod($nb)
+ {
+ if (!$this->table_element)
+ {
+ dol_syslog(get_class($this)."::setMaxPeriod was called on objet with property table_element not defined", LOG_ERR);
+ return -1;
+ }
- if (empty($nb)) $nb = 0;
+ if (empty($nb)) $nb = 0;
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET nb_gen_max = '.$nb;
- $sql .= ' WHERE rowid = '.$this->id;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' SET nb_gen_max = '.$nb;
+ $sql .= ' WHERE rowid = '.$this->id;
- dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- $this->nb_gen_max = $nb;
- return 1;
- } else {
- dol_print_error($this->db);
- return -1;
- }
- }
+ dol_syslog(get_class($this)."::setMaxPeriod", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->nb_gen_max = $nb;
+ return 1;
+ } else {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
/**
- * Update the auto validate flag of invoice
- *
- * @param int $validate 0 to create in draft, 1 to create and validate invoice
- * @return int <0 if KO, >0 if OK
- */
- public function setAutoValidate($validate)
- {
- if (!$this->table_element)
- {
- dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR);
- return -1;
- }
+ * Update the auto validate flag of invoice
+ *
+ * @param int $validate 0 to create in draft, 1 to create and validate invoice
+ * @return int <0 if KO, >0 if OK
+ */
+ public function setAutoValidate($validate)
+ {
+ if (!$this->table_element)
+ {
+ dol_syslog(get_class($this)."::setAutoValidate was called on objet with property table_element not defined", LOG_ERR);
+ return -1;
+ }
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET auto_validate = '.$validate;
- $sql .= ' WHERE rowid = '.$this->id;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' SET auto_validate = '.$validate;
+ $sql .= ' WHERE rowid = '.$this->id;
- dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- $this->auto_validate = $validate;
- return 1;
- } else {
- dol_print_error($this->db);
- return -1;
- }
- }
+ dol_syslog(get_class($this)."::setAutoValidate", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->auto_validate = $validate;
+ return 1;
+ } else {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
- /**
- * Update the auto generate documents
- *
- * @param int $validate 0 no document, 1 to generate document
- * @return int <0 if KO, >0 if OK
- */
- public function setGeneratePdf($validate)
- {
- if (!$this->table_element)
- {
- dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR);
- return -1;
- }
+ /**
+ * Update the auto generate documents
+ *
+ * @param int $validate 0 no document, 1 to generate document
+ * @return int <0 if KO, >0 if OK
+ */
+ public function setGeneratePdf($validate)
+ {
+ if (!$this->table_element)
+ {
+ dol_syslog(get_class($this)."::setGeneratePdf was called on objet with property table_element not defined", LOG_ERR);
+ return -1;
+ }
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET generate_pdf = '.$validate;
- $sql .= ' WHERE rowid = '.$this->id;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' SET generate_pdf = '.$validate;
+ $sql .= ' WHERE rowid = '.$this->id;
- dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- $this->generate_pdf = $validate;
- return 1;
- } else {
- dol_print_error($this->db);
- return -1;
- }
- }
+ dol_syslog(get_class($this)."::setGeneratePdf", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->generate_pdf = $validate;
+ return 1;
+ } else {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
- /**
- * Update the model for documents
- *
- * @param string $model model of document generator
- * @return int <0 if KO, >0 if OK
- */
- public function setModelPdf($model)
- {
- if (!$this->table_element)
- {
- dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR);
- return -1;
- }
+ /**
+ * Update the model for documents
+ *
+ * @param string $model model of document generator
+ * @return int <0 if KO, >0 if OK
+ */
+ public function setModelPdf($model)
+ {
+ if (!$this->table_element)
+ {
+ dol_syslog(get_class($this)."::setModelPdf was called on objet with property table_element not defined", LOG_ERR);
+ return -1;
+ }
- $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
- $sql .= ' SET modelpdf = "'.$model.'"';
- $sql .= ' WHERE rowid = '.$this->id;
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element;
+ $sql .= ' SET modelpdf = "'.$model.'"';
+ $sql .= ' WHERE rowid = '.$this->id;
- dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG);
- if ($this->db->query($sql))
- {
- $this->modelpdf = $model;
- return 1;
- } else {
- dol_print_error($this->db);
- return -1;
- }
- }
+ dol_syslog(get_class($this)."::setModelPdf", LOG_DEBUG);
+ if ($this->db->query($sql))
+ {
+ $this->modelpdf = $model;
+ return 1;
+ } else {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
}
@@ -1898,206 +1898,206 @@ class FactureLigneRec extends CommonInvoiceLine
public $date_end_fill;
- /**
- * Delete line in database
- *
- * @param User $user Object user
- * @param int $notrigger Disable triggers
- * @return int <0 if KO, >0 if OK
- */
- public function delete(User $user, $notrigger = false)
- {
- $error = 0;
+ /**
+ * Delete line in database
+ *
+ * @param User $user Object user
+ * @param int $notrigger Disable triggers
+ * @return int <0 if KO, >0 if OK
+ */
+ public function delete(User $user, $notrigger = false)
+ {
+ $error = 0;
- $this->db->begin();
+ $this->db->begin();
- if (!$error) {
- if (!$notrigger) {
- // Call triggers
- $result = $this->call_trigger('LINEBILLREC_DELETE', $user);
- if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
- // End call triggers
- }
- }
+ if (!$error) {
+ if (!$notrigger) {
+ // Call triggers
+ $result = $this->call_trigger('LINEBILLREC_DELETE', $user);
+ if ($result < 0) { $error++; } // Do also here what you must do to rollback action if trigger fail
+ // End call triggers
+ }
+ }
if (!$error)
- {
- $result = $this->deleteExtraFields();
- if ($result < 0) {
- $error++;
- }
- }
-
- if (!$error)
- {
- $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id;
-
- $res = $this->db->query($sql);
- if ($res === false) {
- $error++;
- $this->errors[] = $this->db->lasterror();
- }
- }
-
- // Commit or rollback
- if ($error) {
- $this->db->rollback();
- return -1;
- } else {
- $this->db->commit();
- return 1;
+ {
+ $result = $this->deleteExtraFields();
+ if ($result < 0) {
+ $error++;
+ }
}
- }
+
+ if (!$error)
+ {
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element.' WHERE rowid='.$this->id;
+
+ $res = $this->db->query($sql);
+ if ($res === false) {
+ $error++;
+ $this->errors[] = $this->db->lasterror();
+ }
+ }
+
+ // Commit or rollback
+ if ($error) {
+ $this->db->rollback();
+ return -1;
+ } else {
+ $this->db->commit();
+ return 1;
+ }
+ }
- /**
- * Get line of template invoice
- *
- * @param int $rowid Id of invoice
- * @return int 1 if OK, < 0 if KO
- */
- public function fetch($rowid)
- {
- $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
- $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,';
- $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
- $sql .= ' l.rang, l.special_code,';
- $sql .= ' l.fk_unit, l.fk_contract_line,';
- $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l';
- $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
- $sql .= ' WHERE l.rowid = '.$rowid;
- $sql .= ' ORDER BY l.rang';
+ /**
+ * Get line of template invoice
+ *
+ * @param int $rowid Id of invoice
+ * @return int 1 if OK, < 0 if KO
+ */
+ public function fetch($rowid)
+ {
+ $sql = 'SELECT l.rowid, l.fk_facture ,l.fk_product, l.product_type, l.label as custom_label, l.description, l.product_type, l.price, l.qty, l.vat_src_code, l.tva_tx,';
+ $sql .= ' l.localtax1_tx, l.localtax2_tx, l.localtax1_type, l.localtax2_type, l.remise, l.remise_percent, l.subprice,';
+ $sql .= ' l.date_start_fill, l.date_end_fill, l.info_bits, l.total_ht, l.total_tva, l.total_ttc,';
+ $sql .= ' l.rang, l.special_code,';
+ $sql .= ' l.fk_unit, l.fk_contract_line,';
+ $sql .= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'facturedet_rec as l';
+ $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid';
+ $sql .= ' WHERE l.rowid = '.$rowid;
+ $sql .= ' ORDER BY l.rang';
- dol_syslog('FactureRec::fetch', LOG_DEBUG);
- $result = $this->db->query($sql);
- if ($result)
- {
- $objp = $this->db->fetch_object($result);
+ dol_syslog('FactureRec::fetch', LOG_DEBUG);
+ $result = $this->db->query($sql);
+ if ($result)
+ {
+ $objp = $this->db->fetch_object($result);
- $this->id = $objp->rowid;
- $this->label = $objp->custom_label; // Label line
- $this->desc = $objp->description; // Description line
- $this->description = $objp->description; // Description line
- $this->product_type = $objp->product_type; // Type of line
- $this->ref = $objp->product_ref; // Ref product
- $this->product_ref = $objp->product_ref; // Ref product
- $this->libelle = $objp->product_label; // deprecated
- $this->product_label = $objp->product_label; // Label product
- $this->product_desc = $objp->product_desc; // Description product
- $this->fk_product_type = $objp->fk_product_type; // Type of product
- $this->qty = $objp->qty;
- $this->price = $objp->price;
- $this->subprice = $objp->subprice;
- $this->fk_facture = $objp->fk_facture;
- $this->vat_src_code = $objp->vat_src_code;
- $this->tva_tx = $objp->tva_tx;
- $this->localtax1_tx = $objp->localtax1_tx;
- $this->localtax2_tx = $objp->localtax2_tx;
- $this->localtax1_type = $objp->localtax1_type;
- $this->localtax2_type = $objp->localtax2_type;
- $this->remise_percent = $objp->remise_percent;
- $this->fk_remise_except = $objp->fk_remise_except;
- $this->fk_product = $objp->fk_product;
- $this->date_start_fill = $objp->date_start_fill;
- $this->date_end_fill = $objp->date_end_fill;
- $this->info_bits = $objp->info_bits;
- $this->total_ht = $objp->total_ht;
- $this->total_tva = $objp->total_tva;
- $this->total_ttc = $objp->total_ttc;
- $this->code_ventilation = $objp->fk_code_ventilation;
- $this->rang = $objp->rang;
- $this->special_code = $objp->special_code;
- $this->fk_unit = $objp->fk_unit;
- $this->fk_contract_line = $objp->fk_contract_line;
+ $this->id = $objp->rowid;
+ $this->label = $objp->custom_label; // Label line
+ $this->desc = $objp->description; // Description line
+ $this->description = $objp->description; // Description line
+ $this->product_type = $objp->product_type; // Type of line
+ $this->ref = $objp->product_ref; // Ref product
+ $this->product_ref = $objp->product_ref; // Ref product
+ $this->libelle = $objp->product_label; // deprecated
+ $this->product_label = $objp->product_label; // Label product
+ $this->product_desc = $objp->product_desc; // Description product
+ $this->fk_product_type = $objp->fk_product_type; // Type of product
+ $this->qty = $objp->qty;
+ $this->price = $objp->price;
+ $this->subprice = $objp->subprice;
+ $this->fk_facture = $objp->fk_facture;
+ $this->vat_src_code = $objp->vat_src_code;
+ $this->tva_tx = $objp->tva_tx;
+ $this->localtax1_tx = $objp->localtax1_tx;
+ $this->localtax2_tx = $objp->localtax2_tx;
+ $this->localtax1_type = $objp->localtax1_type;
+ $this->localtax2_type = $objp->localtax2_type;
+ $this->remise_percent = $objp->remise_percent;
+ $this->fk_remise_except = $objp->fk_remise_except;
+ $this->fk_product = $objp->fk_product;
+ $this->date_start_fill = $objp->date_start_fill;
+ $this->date_end_fill = $objp->date_end_fill;
+ $this->info_bits = $objp->info_bits;
+ $this->total_ht = $objp->total_ht;
+ $this->total_tva = $objp->total_tva;
+ $this->total_ttc = $objp->total_ttc;
+ $this->code_ventilation = $objp->fk_code_ventilation;
+ $this->rang = $objp->rang;
+ $this->special_code = $objp->special_code;
+ $this->fk_unit = $objp->fk_unit;
+ $this->fk_contract_line = $objp->fk_contract_line;
- $this->db->free($result);
- return 1;
- } else {
- $this->error = $this->db->lasterror();
- return -3;
- }
- }
+ $this->db->free($result);
+ return 1;
+ } else {
+ $this->error = $this->db->lasterror();
+ return -3;
+ }
+ }
- /**
- * Update a line to invoice_rec.
- *
- * @param User $user User
- * @param int $notrigger No trigger
- * @return int <0 if KO, Id of line if OK
- */
- public function update(User $user, $notrigger = 0)
- {
- global $conf;
+ /**
+ * Update a line to invoice_rec.
+ *
+ * @param User $user User
+ * @param int $notrigger No trigger
+ * @return int <0 if KO, Id of line if OK
+ */
+ public function update(User $user, $notrigger = 0)
+ {
+ global $conf;
- $error = 0;
+ $error = 0;
- include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
- $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET";
- $sql .= " fk_facture = ".$this->fk_facture;
- $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null");
- $sql .= ", description='".$this->db->escape($this->desc)."'";
- $sql .= ", price=".price2num($this->price);
- $sql .= ", qty=".price2num($this->qty);
- $sql .= ", tva_tx=".price2num($this->tva_tx);
- $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'";
- $sql .= ", localtax1_tx=".price2num($this->localtax1_tx);
- $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'";
- $sql .= ", localtax2_tx=".price2num($this->localtax2_tx);
- $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'";
- $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null");
- $sql .= ", product_type=".$this->product_type;
- $sql .= ", remise_percent='".price2num($this->remise_percent)."'";
- $sql .= ", subprice='".price2num($this->subprice)."'";
- $sql .= ", info_bits='".price2num($this->info_bits)."'";
- $sql .= ", date_start_fill=".(int) $this->date_start_fill;
- $sql .= ", date_end_fill=".(int) $this->date_end_fill;
- if (empty($this->skip_update_total)) {
- $sql .= ", total_ht=".price2num($this->total_ht);
- $sql .= ", total_tva=".price2num($this->total_tva);
- $sql .= ", total_localtax1=".price2num($this->total_localtax1);
- $sql .= ", total_localtax2=".price2num($this->total_localtax2);
- $sql .= ", total_ttc=".price2num($this->total_ttc);
- }
- $sql .= ", rang=".$this->rang;
- $sql .= ", special_code=".$this->special_code;
- $sql .= ", fk_unit=".($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null");
- $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null");
- $sql .= " WHERE rowid = ".$this->id;
+ $sql = "UPDATE ".MAIN_DB_PREFIX."facturedet_rec SET";
+ $sql .= " fk_facture = ".$this->fk_facture;
+ $sql .= ", label=".(!empty($this->label) ? "'".$this->db->escape($this->label)."'" : "null");
+ $sql .= ", description='".$this->db->escape($this->desc)."'";
+ $sql .= ", price=".price2num($this->price);
+ $sql .= ", qty=".price2num($this->qty);
+ $sql .= ", tva_tx=".price2num($this->tva_tx);
+ $sql .= ", vat_src_code='".$this->db->escape($this->vat_src_code)."'";
+ $sql .= ", localtax1_tx=".price2num($this->localtax1_tx);
+ $sql .= ", localtax1_type='".$this->db->escape($this->localtax1_type)."'";
+ $sql .= ", localtax2_tx=".price2num($this->localtax2_tx);
+ $sql .= ", localtax2_type='".$this->db->escape($this->localtax2_type)."'";
+ $sql .= ", fk_product=".($this->fk_product > 0 ? $this->fk_product : "null");
+ $sql .= ", product_type=".$this->product_type;
+ $sql .= ", remise_percent='".price2num($this->remise_percent)."'";
+ $sql .= ", subprice='".price2num($this->subprice)."'";
+ $sql .= ", info_bits='".price2num($this->info_bits)."'";
+ $sql .= ", date_start_fill=".(int) $this->date_start_fill;
+ $sql .= ", date_end_fill=".(int) $this->date_end_fill;
+ if (empty($this->skip_update_total)) {
+ $sql .= ", total_ht=".price2num($this->total_ht);
+ $sql .= ", total_tva=".price2num($this->total_tva);
+ $sql .= ", total_localtax1=".price2num($this->total_localtax1);
+ $sql .= ", total_localtax2=".price2num($this->total_localtax2);
+ $sql .= ", total_ttc=".price2num($this->total_ttc);
+ }
+ $sql .= ", rang=".$this->rang;
+ $sql .= ", special_code=".$this->special_code;
+ $sql .= ", fk_unit=".($this->fk_unit ? "'".$this->db->escape($this->fk_unit)."'" : "null");
+ $sql .= ", fk_contract_line=".($this->fk_contract_line ? $this->fk_contract_line : "null");
+ $sql .= " WHERE rowid = ".$this->id;
- dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- if (!$error)
- {
- $result = $this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
+ dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if ($resql)
+ {
+ if (!$error)
+ {
+ $result = $this->insertExtraFields();
+ if ($result < 0)
+ {
+ $error++;
+ }
+ }
- if (!$error && !$notrigger)
- {
- // Call trigger
- $result = $this->call_trigger('LINEBILLREC_UPDATE', $user);
- if ($result < 0)
- {
- $this->db->rollback();
- return -2;
- }
- // End call triggers
- }
- $this->db->commit();
- return 1;
- } else {
- $this->error = $this->db->lasterror();
- $this->db->rollback();
- return -2;
- }
- }
+ if (!$error && !$notrigger)
+ {
+ // Call trigger
+ $result = $this->call_trigger('LINEBILLREC_UPDATE', $user);
+ if ($result < 0)
+ {
+ $this->db->rollback();
+ return -2;
+ }
+ // End call triggers
+ }
+ $this->db->commit();
+ return 1;
+ } else {
+ $this->error = $this->db->lasterror();
+ $this->db->rollback();
+ return -2;
+ }
+ }
}
diff --git a/htdocs/compta/localtax/card.php b/htdocs/compta/localtax/card.php
index b99e4c35d1c..c3700d9e994 100644
--- a/htdocs/compta/localtax/card.php
+++ b/htdocs/compta/localtax/card.php
@@ -61,44 +61,44 @@ if ($_POST["cancel"] == $langs->trans("Cancel") && !$id)
if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
- $db->begin();
+ $db->begin();
- $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
- $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
+ $datev = dol_mktime(12, 0, 0, $_POST["datevmonth"], $_POST["datevday"], $_POST["datevyear"]);
+ $datep = dol_mktime(12, 0, 0, $_POST["datepmonth"], $_POST["datepday"], $_POST["datepyear"]);
- $object->accountid = GETPOST("accountid");
- $object->paymenttype = GETPOST("paiementtype");
- $object->datev = $datev;
- $object->datep = $datep;
- $object->amount = price2num(GETPOST("amount"));
+ $object->accountid = GETPOST("accountid");
+ $object->paymenttype = GETPOST("paiementtype");
+ $object->datev = $datev;
+ $object->datep = $datep;
+ $object->amount = price2num(GETPOST("amount"));
$object->label = GETPOST("label");
$object->ltt = $lttype;
- $ret = $object->addPayment($user);
- if ($ret > 0)
- {
- $db->commit();
- header("Location: list.php?localTaxType=".$lttype);
- exit;
- } else {
- $db->rollback();
- setEventMessages($object->error, $object->errors, 'errors');
- $_GET["action"] = "create";
- }
+ $ret = $object->addPayment($user);
+ if ($ret > 0)
+ {
+ $db->commit();
+ header("Location: list.php?localTaxType=".$lttype);
+ exit;
+ } else {
+ $db->rollback();
+ setEventMessages($object->error, $object->errors, 'errors');
+ $_GET["action"] = "create";
+ }
}
//delete payment of localtax
if ($action == 'delete')
{
- $result = $object->fetch($id);
+ $result = $object->fetch($id);
if ($object->rappro == 0)
{
- $db->begin();
+ $db->begin();
- $ret = $object->delete($user);
- if ($ret > 0)
- {
+ $ret = $object->delete($user);
+ if ($ret > 0)
+ {
if ($object->fk_bank)
{
$accountline = new AccountLine($db);
@@ -116,13 +116,13 @@ if ($action == 'delete')
$db->rollback();
setEventMessages($object->error, $object->errors, 'errors');
}
- } else {
- $db->rollback();
- setEventMessages($object->error, $object->errors, 'errors');
- }
+ } else {
+ $db->rollback();
+ setEventMessages($object->error, $object->errors, 'errors');
+ }
} else {
- $mesg = 'Error try do delete a line linked to a conciliated bank transaction';
- setEventMessages($mesg, null, 'errors');
+ $mesg = 'Error try do delete a line linked to a conciliated bank transaction';
+ setEventMessages($mesg, null, 'errors');
}
}
@@ -149,25 +149,25 @@ llxHeader("", $title, $helpurl);
if ($action == 'create')
{
- print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code));
+ print load_fiche_titre($langs->transcountry($lttype == 2 ? "newLT2Payment" : "newLT1Payment", $mysoc->country_code));
- print ' |