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