Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added extrafields when inserting a line of facturerec #503

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions htdocs/compta/facture/class/facture-rec.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,10 @@ public function delete(User $user, $notrigger = 0, $idwarehouse = -1)
* @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 ''
* @param array $array_options Extrafields array
* @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)
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, $array_options = [])
{
global $mysoc;

Expand Down Expand Up @@ -1019,16 +1020,28 @@ public function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1 = 0, $txlocalt
$sql .= ", ".price2num($multicurrency_total_ttc, 'CT');
$sql .= ")";

dol_syslog(get_class($this)."::addline", LOG_DEBUG);
if ($this->db->query($sql)) {
$lineId = $this->db->last_insert_id(MAIN_DB_PREFIX."facturedet_rec");
$this->id = $facid;
$this->update_price(1);
return $lineId;
} else {
$this->error = $this->db->lasterror();
return -1;
}
dol_syslog(get_class($this) . "::addline", LOG_DEBUG);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Les prochaines fois tu peux utiliser la magic constant __METHOD__ directement - t'embête pas pour cette fois

if ($this->db->query($sql)) {
$lineId = $this->db->last_insert_id(MAIN_DB_PREFIX . "facturedet_rec");
$this->id = $facid;
$this->update_price(1);

/**
* Backported from contract
*/
$factureRecLine = new FactureLigneRec($this->db);
$factureRecLine->array_options = $array_options;
$factureRecLine->id = $lineId;
$result = $factureRecLine->insertExtraFields();
if ($result < 0) {
$this->error[] = $factureRecLine->error;
}

return $lineId;
} else {
$this->error = $this->db->lasterror();
return -1;
}
}
}

Expand Down
Loading