28require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
38 public $element =
'deplacement';
43 public $table_element =
'deplacement';
48 public $table_element_line =
'';
53 public $fk_element =
'';
76 public $fk_user_author;
97 public $extraparams = array();
124 $this->ismultientitymanaged = 0;
139 if (empty($this->
type) || $this->
type < 0) {
140 $this->error =
'ErrorBadParameter';
143 if (empty($this->fk_user) || $this->fk_user < 0) {
144 $this->error =
'ErrorBadParameter';
152 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"deplacement (";
156 $sql .=
", fk_user_author";
159 $sql .=
", note_private";
160 $sql .=
", note_public";
161 $sql .=
", fk_projet";
163 $sql .=
") VALUES (";
164 $sql .=
" '".$this->db->idate($now).
"'";
165 $sql .=
", ".((int) $conf->entity);
166 $sql .=
", ".((int) $user->id);
167 $sql .=
", ".((int) $this->fk_user);
168 $sql .=
", '".$this->db->escape($this->
type).
"'";
169 $sql .=
", ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
170 $sql .=
", ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
171 $sql .=
", ".($this->fk_project > 0 ? ((int) $this->fk_project) : 0);
172 $sql .=
", ".($this->fk_soc > 0 ? ((int) $this->fk_soc) :
"null");
175 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
176 $result = $this->db->query($sql);
178 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"deplacement");
181 $result = $this->
call_trigger(
'DEPLACEMENT_CREATE', $user);
183 $this->db->rollback();
188 $result = $this->
update($user);
193 $this->error = $this->db->error();
194 $this->db->rollback();
198 $this->error = $this->db->error().
" sql=".$sql;
199 $this->db->rollback();
213 $this->km = (float)
price2num($this->km);
216 if (!is_numeric($this->km)) {
219 if (empty($this->date)) {
220 $this->error =
'ErrorBadParameter';
223 if (empty($this->
type) || $this->
type < 0) {
224 $this->error =
'ErrorBadParameter';
227 if (empty($this->fk_user) || $this->fk_user < 0) {
228 $this->error =
'ErrorBadParameter';
234 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"deplacement ";
235 $sql .=
" SET km = ".((float) $this->km);
236 $sql .=
" , dated = '".$this->db->idate($this->date).
"'";
237 $sql .=
" , type = '".$this->db->escape($this->
type).
"'";
238 $sql .=
" , fk_statut = '".$this->db->escape($this->
statut).
"'";
239 $sql .=
" , fk_user = ".((int) $this->fk_user);
240 $sql .=
" , fk_user_modif = ".((int) $user->id);
241 $sql .=
" , fk_soc = ".($this->socid > 0 ? $this->socid :
'null');
242 $sql .=
" , note_private = ".($this->note_private ?
"'".$this->db->escape($this->note_private).
"'" :
"null");
243 $sql .=
" , note_public = ".($this->note_public ?
"'".$this->db->escape($this->note_public).
"'" :
"null");
244 $sql .=
" , fk_projet = ".($this->fk_project > 0 ? $this->fk_project : 0);
245 $sql .=
" WHERE rowid = ".((int) $this->
id);
247 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
248 $result = $this->db->query($sql);
253 $this->error = $this->db->lasterror();
254 $this->db->rollback();
266 public function fetch($id, $ref =
'')
268 $sql =
"SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet as fk_project, extraparams";
269 $sql .=
" FROM ".MAIN_DB_PREFIX.
"deplacement";
270 $sql .=
" WHERE entity IN (".getEntity(
'deplacement').
")";
272 $sql .=
" AND ref ='".$this->db->escape($ref).
"'";
274 $sql .=
" AND rowid = ".((int) $id);
277 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
278 $result = $this->db->query($sql);
280 $obj = $this->db->fetch_object($result);
282 $this->
id = $obj->rowid;
283 $this->
ref = $obj->rowid;
284 $this->date = $this->db->jdate($obj->dated);
285 $this->fk_user = $obj->fk_user;
286 $this->socid = $obj->fk_soc;
287 $this->km = $obj->km;
288 $this->
type = $obj->type;
289 $this->
statut = $obj->fk_statut;
290 $this->note_private = $obj->note_private;
291 $this->note_public = $obj->note_public;
292 $this->fk_project = $obj->fk_project;
294 $this->extraparams = (array) json_decode($obj->extraparams,
true);
298 $this->error = $this->db->error();
309 public function delete($user)
315 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"deplacement WHERE rowid = ".((int) $id);
317 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
318 $result = $this->db->query($sql);
323 $this->error = $this->db->error();
324 $this->db->rollback();
354 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
365 $status_logo = array(0 =>
'status0', 1=>
'status4', 2 =>
'status1', 4 =>
'status6', 5 =>
'status4', 6 =>
'status6', 99 =>
'status5');
366 $statusType = $status_logo[$status];
368 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
382 $label = $langs->trans(
"Show").
': '.$this->ref;
384 $link =
'<a href="'.DOL_URL_ROOT.
'/compta/deplacement/card.php?id='.$this->
id.
'" title="'.
dol_escape_htmltag($label, 1).
'" class="classfortooltip">';
391 $result .= ($link.img_object($label, $picto,
'class="classfortooltip"').$linkend);
393 if ($withpicto && $withpicto != 2) {
396 if ($withpicto != 2) {
397 $result .= $link.$this->ref.$linkend;
415 $sql =
"SELECT id, code, label";
416 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_type_fees";
417 $sql .=
" WHERE active = ".((int) $active);
419 dol_syslog(get_class($this).
"::listOfTypes", LOG_DEBUG);
420 $result = $this->db->query($sql);
422 $num = $this->db->num_rows($result);
425 $obj = $this->db->fetch_object($result);
426 $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label);
444 $sql =
'SELECT c.rowid, c.datec, c.fk_user_author, c.fk_user_modif,';
445 $sql .=
' c.tms as datem';
446 $sql .=
' FROM '.MAIN_DB_PREFIX.
'deplacement as c';
447 $sql .=
' WHERE c.rowid = '.((int) $id);
449 dol_syslog(get_class($this).
'::info', LOG_DEBUG);
450 $result = $this->db->query($sql);
453 if ($this->db->num_rows($result)) {
454 $obj = $this->db->fetch_object($result);
456 $this->
id = $obj->rowid;
458 $this->user_creation_id = $obj->fk_user_author;
459 $this->user_modification_id = $obj->fk_user_modif;
460 $this->date_creation = $this->db->jdate($obj->datec);
461 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
463 $this->db->free($result);
Parent class of all other business classes (invoices, contracts, proposals, orders,...
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage trips and working credit notes.
listOfTypes($active=1)
List of types.
const STATUS_DRAFT
Draft status.
getNomUrl($withpicto=0)
Return clicable name (with picto eventually)
info($id)
Information on record.
update($user)
Update record.
create($user)
Create object in database TODO Add ref number.
const STATUS_REFUNDED
Refunded status.
fetch($id, $ref='')
Load an object from database.
__construct(DoliDB $db)
Constructor.
LibStatut($status, $mode=0)
Return the label of a given status.
getLibStatut($mode=0)
Return the label of the status.
const STATUS_VALIDATED
Validated status.
Class to manage Dolibarr database access.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_now($mode='auto')
Return date for now.
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut