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 $objp = $this->db->fetch_object($resql);
139 $this->rowid = $objp->rowid;
140 $this->
id = $objp->rowid;
141 $this->fk_fichinter = $objp->fk_fichinter;
142 $this->
date = $this->db->jdate($objp->date);
143 $this->datei = $this->db->jdate($objp->date);
144 $this->desc = $objp->description;
145 $this->product_type = $objp->product_type;
146 $this->duration = $objp->duree;
147 $this->rang = $objp->rang;
148 $this->special_code = $objp->special_code;
150 $this->extraparams = !empty($objp->extraparams) ? (array) json_decode($objp->extraparams,
true) : array();
152 $this->db->free($resql);
158 $this->error = $this->db->error().
' sql='.$sql;
170 public function insert($user, $notrigger = 0)
174 dol_syslog(
"FichinterLigne::insert rang=".$this->rang);
176 if (empty($this->
date) && !empty($this->datei)) {
177 $this->
date = $this->datei;
181 if ($this->product_type < 0) {
187 $rangToUse = $this->rang;
188 if ($rangToUse == -1) {
190 $sql =
'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.
'fichinterdet';
191 $sql .=
' WHERE fk_fichinter = '.((int) $this->fk_fichinter);
192 $resql = $this->db->query($sql);
194 $obj = $this->db->fetch_object($resql);
195 $rangToUse = $obj->max + 1;
198 $this->db->rollback();
204 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'fichinterdet';
205 $sql .=
' (fk_fichinter, description, date, duree, rang, product_type, special_code)';
206 $sql .=
" VALUES (".((int) $this->fk_fichinter).
",";
207 $sql .=
" '".$this->db->escape($this->desc).
"',";
208 $sql .=
" '".$this->db->idate($this->
date).
"',";
209 $sql .=
" ".((int) $this->duration).
",";
210 $sql .=
' '.((int) $rangToUse).
",";
211 $sql .=
" ".((int) $this->product_type).
",";
212 $sql .=
" ".((int) $this->special_code);
215 dol_syslog(
"FichinterLigne::insert", LOG_DEBUG);
216 $resql = $this->db->query($sql);
218 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
'fichinterdet');
219 $this->rowid = $this->id;
230 $this->rang = $rangToUse;
234 $result = $this->call_trigger(
'LINEFICHINTER_CREATE', $user);
246 $this->db->rollback();
250 $this->error = $this->db->error().
" sql=".$sql;
251 $this->db->rollback();
264 public function update($user, $notrigger = 0)
268 if (empty($this->
date) && !empty($this->datei)) {
269 $this->
date = $this->datei;
275 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"fichinterdet SET";
276 $sql .=
" description = '".$this->db->escape($this->desc).
"',";
277 $sql .=
" date = '".$this->db->idate($this->
date).
"',";
278 $sql .=
" duree = ".((int) $this->duration).
",";
279 $sql .=
" rang = ".((int) $this->rang).
",";
280 $sql .=
" product_type = ".((int) $this->product_type);
281 $sql .=
" WHERE rowid = ".((int) $this->
id);
283 dol_syslog(
"FichinterLigne::update", LOG_DEBUG);
284 $resql = $this->db->query($sql);
295 $result = $this->call_trigger(
'LINEFICHINTER_MODIFY', $user);
307 $this->error = $this->db->lasterror();
308 $this->db->rollback();
312 $this->error = $this->db->lasterror();
313 $this->db->rollback();
331 $sql =
"SELECT SUM(duree) as total_duration, min(date) as dateo, max(date) as datee ";
332 $sql .=
" FROM ".MAIN_DB_PREFIX.
"fichinterdet";
333 $sql .=
" WHERE fk_fichinter=".((int) $this->fk_fichinter);
334 $sql .=
" AND product_type <> 9";
336 dol_syslog(
"FichinterLigne::update_total", LOG_DEBUG);
337 $resql = $this->db->query($sql);
339 $obj = $this->db->fetch_object($resql);
341 if (!empty($obj->total_duration)) {
342 $total_duration = $obj->total_duration;
345 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"fichinter";
346 $sql .=
" SET duree = ".((int) $total_duration);
347 $sql .=
" , dateo = ".(!empty($obj->dateo) ?
"'".$this->db->escape($obj->dateo).
"'" :
"null");
348 $sql .=
" , datee = ".(!empty($obj->datee) ?
"'".$this->db->escape($obj->datee).
"'" :
"null");
349 $sql .=
" WHERE rowid = ".((int) $this->fk_fichinter);
351 dol_syslog(
"FichinterLigne::update_total", LOG_DEBUG);
352 $resql = $this->db->query($sql);
357 $this->error = $this->db->error();
358 $this->db->rollback();
362 $this->error = $this->db->error();
363 $this->db->rollback();
379 dol_syslog(get_class($this).
"::deleteline lineid=".$this->
id);
386 $this->db->rollback();
390 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"fichinterdet WHERE rowid = ".((int) $this->
id);
391 $resql = $this->db->query($sql);
398 $result = $this->call_trigger(
'LINEFICHINTER_DELETE', $user);
401 $this->db->rollback();
410 $this->db->rollback();
414 $this->error = $this->db->error().
" sql=".$sql;
415 $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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(getDolGlobalString( 'TAKEPOS_SHOW_CUSTOMER')) print $langs trans('Date')." left 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 PaymentTypeShortLIQ right SELECT p pos_change as p datep as date