244 $sql =
'SELECT l.rowid,';
245 $sql .=
' l.fk_facture_fourn, l.fk_parent_line, l.fk_product,';
246 $sql .=
' l.ref as ref_supplier, l.label, l.description as line_desc, l.pu_ht, l.pu_ttc, l.qty, l.remise_percent, l.fk_remise_except,';
247 $sql .=
' l.vat_src_code, l.tva_tx, l.localtax1_tx, l.localtax1_type, l.localtax2_tx, l.localtax2_type,';
248 $sql .=
' l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc,';
249 $sql .=
' l.product_type, l.date_start, l.date_end,';
250 $sql .=
' l.info_bits, l.special_code, l.rang, l.fk_unit, l.import_key, l.extraparams,';
251 $sql .=
' l.fk_user_author, l.fk_user_modif, l.fk_multicurrency,';
252 $sql .=
' l.multicurrency_code, l.multicurrency_subprice, l.multicurrency_total_ht, l.multicurrency_total_tva, l.multicurrency_total_ttc,';
253 $sql .=
' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc';
254 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture_fourn_det_rec as l';
255 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'product as p ON l.fk_product = p.rowid';
256 $sql .=
' WHERE l.rowid = '. (int) $rowid;
257 $sql .=
' ORDER BY l.rang';
260 $result = $this->db->query($sql);
262 $objp = $this->db->fetch_object($result);
264 $this->
id = $objp->rowid;
265 $this->fk_facture_fourn = $objp->fk_facture_fourn;
266 $this->fk_parent = $objp->fk_parent_line;
267 $this->fk_product = $objp->fk_product;
268 $this->ref_supplier = $objp->ref_supplier;
269 $this->label = $objp->label;
271 $this->desc = $objp->line_desc;
272 $this->pu_ht = $objp->pu_ht;
273 $this->pu_ttc = $objp->pu_ttc;
274 $this->qty = $objp->qty;
275 $this->remise_percent = $objp->remise_percent;
276 $this->fk_remise_except = $objp->fk_remise_except;
277 $this->vat_src_code = $objp->vat_src_code;
278 $this->tva_tx = $objp->tva_tx;
279 $this->localtax1_tx = $objp->localtax1_tx;
280 $this->localtax1_type = $objp->localtax1_type;
281 $this->localtax2_tx = $objp->localtax2_tx;
282 $this->localtax2_type = $objp->localtax2_type;
283 $this->total_ht = $objp->total_ht;
284 $this->total_tva = $objp->total_tva;
285 $this->total_localtax1 = $objp->total_localtax1;
286 $this->total_localtax2 = $objp->total_localtax2;
287 $this->total_ttc = $objp->total_ttc;
288 $this->product_type = $objp->product_type;
289 $this->product_label = $objp->product_label;
290 $this->date_start = $objp->date_start;
291 $this->date_end = $objp->date_end;
292 $this->info_bits = $objp->info_bits;
293 $this->special_code = $objp->special_code;
294 $this->rang = $objp->rang;
295 $this->fk_unit = $objp->fk_unit;
296 $this->import_key = $objp->import_key;
297 $this->extraparams = !empty($objp->extraparams) ? (array) json_decode($objp->extraparams,
true) : array();
298 $this->fk_user_author = $objp->fk_user_author;
299 $this->fk_user_modif = $objp->fk_user_modif;
300 $this->fk_multicurrency = $objp->fk_multicurrency;
301 $this->multicurrency_code = $objp->multicurrency_code;
302 $this->multicurrency_subprice = $objp->multicurrency_subprice;
303 $this->multicurrency_total_ht = $objp->multicurrency_total_ht;
304 $this->multicurrency_total_tva = $objp->multicurrency_total_tva;
305 $this->multicurrency_total_ttc = $objp->multicurrency_total_ttc;
307 $this->db->free($result);
310 $this->error = $this->db->lasterror();
329 include_once DOL_DOCUMENT_ROOT.
'/core/lib/price.lib.php';
331 $sql =
'UPDATE ' . MAIN_DB_PREFIX .
'facture_fourn_det_rec SET';
332 $sql .=
' fk_facture_fourn = ' . (int) $this->fk_facture_fourn;
333 $sql .=
', fk_parent_line = ' . (int) $this->fk_parent;
334 $sql .=
', fk_product = ' . (int) $this->fk_product;
335 $sql .=
', ref = ' . (!empty($this->
ref) ?
"'" . $this->db->escape($this->
ref) .
"'" :
'NULL');
336 $sql .=
", label = " . (!empty($this->label) ?
"'" . $this->db->escape($this->label) .
"'" :
'NULL');
337 $sql .=
", description = '" . $this->db->escape($this->desc ? $this->desc : $this->description) .
"'";
338 $sql .=
', pu_ht = ' .
price2num($this->pu_ht);
339 $sql .=
', pu_ttc = ' .
price2num($this->pu_ttc);
340 $sql .=
', qty = ' .
price2num($this->qty);
341 $sql .=
", remise_percent = '" .
price2num($this->remise_percent) .
"'";
342 $sql .=
', fk_remise_except = ' . (int) $this->fk_remise_except;
343 $sql .=
", vat_src_code = '" . $this->db->escape($this->vat_src_code) .
"'";
344 $sql .=
', tva_tx = ' .
price2num($this->tva_tx);
345 $sql .=
', localtax1_tx = ' .
price2num($this->localtax1_tx);
346 $sql .=
", localtax1_type = '" . $this->db->escape((
string) $this->localtax1_type) .
"'";
347 $sql .=
', localtax2_tx = ' .
price2num($this->localtax2_tx);
348 $sql .=
", localtax2_type = '" . $this->db->escape((
string) $this->localtax2_type) .
"'";
349 if (empty($this->skip_update_total)) {
350 $sql .=
', total_ht = ' .
price2num($this->total_ht);
351 $sql .=
', total_tva = ' .
price2num($this->total_tva);
352 $sql .=
', total_localtax1 = ' .
price2num($this->total_localtax1);
353 $sql .=
', total_localtax2 = ' .
price2num($this->total_localtax2);
354 $sql .=
', total_ttc = ' .
price2num($this->total_ttc);
356 $sql .=
', product_type = ' . (int) $this->product_type;
357 $sql .=
', date_start = ' . (int) $this->date_start;
358 $sql .=
', date_end = ' . (int) $this->date_end;
359 $sql .=
", info_bits = " . ((int) $this->info_bits);
360 $sql .=
', special_code =' . (int) $this->special_code;
361 $sql .=
', rang = ' . (int) $this->rang;
362 $sql .=
', fk_unit = ' .($this->fk_unit ?
"'".$this->db->escape((
string) $this->fk_unit).
"'" :
'null');
363 $sql .=
', fk_user_modif = ' . (int) $user->id;
364 $sql .=
' WHERE rowid = ' . (int) $this->
id;
368 dol_syslog(get_class($this).
'::updateline', LOG_DEBUG);
369 $resql = $this->db->query($sql);
378 if (!$error && !$notrigger) {
380 $result = $this->call_trigger(
'LINESUPPLIERBILLREC_MODIFY', $user);
388 $this->db->rollback();
395 $this->error = $this->db->lasterror();
396 $this->db->rollback();