32require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
98 public $element =
'fichinterdet';
103 public $table_element =
'fichinterdet';
108 public $fk_element =
'fk_fichinter';
130 dol_syslog(
"FichinterLigne::fetch", LOG_DEBUG);
132 $sql =
'SELECT ft.rowid, ft.fk_fichinter, ft.description, ft.duree, ft.rang, ft.date, ft.product_type, ft.special_code, ft.extraparams';
133 $sql .=
' FROM '.MAIN_DB_PREFIX.
'fichinterdet as ft';
134 $sql .=
' WHERE ft.rowid = '.((int) $rowid);
136 $resql = $this->db->query($sql);
138 if ($this->db->num_rows($resql)) {
139 $objp = $this->db->fetch_object($resql);
141 $this->rowid = $objp->rowid;
142 $this->
id = $objp->rowid;
143 $this->fk_fichinter = $objp->fk_fichinter;
144 $this->
date = $this->db->jdate($objp->date);
145 $this->datei = $this->db->jdate($objp->date);
146 $this->desc = $objp->description;
147 $this->product_type = $objp->product_type;
148 $this->duration = $objp->duree;
149 $this->rang = $objp->rang;
150 $this->special_code = $objp->special_code;
152 $this->extraparams = !empty($objp->extraparams) ? (array) json_decode($objp->extraparams,
true) : array();
154 $this->db->free($resql);
163 $this->error = $this->db->error().
' sql='.$sql;
175 public function insert($user, $notrigger = 0)
179 dol_syslog(
"FichinterLigne::insert rang=".$this->rang);
181 if (empty($this->
date) && !empty($this->datei)) {
182 $this->
date = $this->datei;
186 if ($this->product_type < 0) {
192 $rangToUse = $this->rang;
193 if ($rangToUse == -1) {
195 $sql =
'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.
'fichinterdet';
196 $sql .=
' WHERE fk_fichinter = '.((int) $this->fk_fichinter);
197 $resql = $this->db->query($sql);
199 $obj = $this->db->fetch_object($resql);
200 $rangToUse = (int) $obj->max + 1;
203 $this->db->rollback();
209 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'fichinterdet';
210 $sql .=
' (fk_fichinter, description, date, duree, rang, product_type, special_code)';
211 $sql .=
" VALUES (".((int) $this->fk_fichinter).
",";
212 $sql .=
" '".$this->db->escape($this->desc).
"',";
213 $sql .=
" '".$this->db->idate($this->
date).
"',";
214 $sql .=
" ".((int) $this->duration).
",";
215 $sql .=
' '.((int) $rangToUse).
",";
216 $sql .=
" ".((int) $this->product_type).
",";
217 $sql .=
" ".((int) $this->special_code);
220 dol_syslog(
"FichinterLigne::insert", LOG_DEBUG);
221 $resql = $this->db->query($sql);
223 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
'fichinterdet');
224 $this->rowid = $this->id;
235 $this->rang = $rangToUse;
239 $result = $this->call_trigger(
'LINEFICHINTER_CREATE', $user);
251 $this->db->rollback();
255 $this->error = $this->db->error().
" sql=".$sql;
256 $this->db->rollback();
269 public function update($user, $notrigger = 0)
273 if (empty($this->
date) && !empty($this->datei)) {
274 $this->
date = $this->datei;
280 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"fichinterdet SET";
281 $sql .=
" description = '".$this->db->escape($this->desc).
"',";
282 $sql .=
" date = '".$this->db->idate($this->
date).
"',";
283 $sql .=
" duree = ".((int) $this->duration).
",";
284 $sql .=
" rang = ".((int) $this->rang).
",";
285 $sql .=
" product_type = ".((int) $this->product_type);
286 $sql .=
" WHERE rowid = ".((int) $this->
id);
288 dol_syslog(
"FichinterLigne::update", LOG_DEBUG);
289 $resql = $this->db->query($sql);
300 $result = $this->call_trigger(
'LINEFICHINTER_MODIFY', $user);
312 $this->error = $this->db->lasterror();
313 $this->db->rollback();
317 $this->error = $this->db->lasterror();
318 $this->db->rollback();
336 $sql =
"SELECT SUM(duree) as total_duration, min(date) as dateo, max(date) as datee ";
337 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinterdet";
338 $sql .=
" WHERE fk_fichinter=".((int) $this->fk_fichinter);
339 $sql .=
" AND product_type <> 9";
341 dol_syslog(
"FichinterLigne::update_total", LOG_DEBUG);
342 $resql = $this->db->query($sql);
344 $obj = $this->db->fetch_object($resql);
346 if (!empty($obj->total_duration)) {
347 $total_duration = $obj->total_duration;
350 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"fichinter";
351 $sql .=
" SET duree = ".((int) $total_duration);
352 $sql .=
" , dateo = ".(!empty($obj->dateo) ?
"'".$this->db->escape($obj->dateo).
"'" :
"null");
353 $sql .=
" , datee = ".(!empty($obj->datee) ?
"'".$this->db->escape($obj->datee).
"'" :
"null");
354 $sql .=
" WHERE rowid = ".((int) $this->fk_fichinter);
356 dol_syslog(
"FichinterLigne::update_total", LOG_DEBUG);
357 $resql = $this->db->query($sql);
362 $this->error = $this->db->error();
363 $this->db->rollback();
367 $this->error = $this->db->error();
368 $this->db->rollback();
384 dol_syslog(get_class($this).
"::deleteline lineid=".$this->
id);
391 $this->db->rollback();
395 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"fichinterdet WHERE rowid = ".((int) $this->
id);
396 $resql = $this->db->query($sql);
403 $result = $this->call_trigger(
'LINEFICHINTER_DELETE', $user);
406 $this->db->rollback();
415 $this->db->rollback();
419 $this->error = $this->db->error().
" sql=".$sql;
420 $this->db->rollback();
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteExtraFields()
Delete all extra fields values for the current object.
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage intervention lines.
deleteLine($user, $notrigger=0)
Delete a intervention line.
fetch($rowid)
Retrieve the line of intervention.
update_total()
Update total duration into llx_fichinter.
update($user, $notrigger=0)
Update intervention into database.
__construct($db)
Constructor.
insert($user, $notrigger=0)
Insert the line into database.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
print $langs trans('Date')." left Ref Label right Qty right Price right TotalHT right TotalTTC right right right right right right right right right centpercent right TotalHT right n right VAT right n right TotalVAT right n No sujeto a RE IRPF right TotalLT1 right n right TotalLT2 right n right TotalTTC right n takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency takeposcustomercurrency right TotalTTC takeposcustomercurrency right takeposcustomercurrency n right Paid right PaymentTypeShortLIQ right SELECT p pos_change as p datep as date