37 public $element =
'cashcontrol';
42 public $table_element =
'pos_cash_fence';
47 public $picto =
'cash-register';
75 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 10),
76 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'enabled' => 1,
'visible' => 0,
'notnull' => 1,
'position' => 15),
77 'ref' => array(
'type' =>
'varchar(64)',
'label' =>
'Ref',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 18),
78 'posmodule' => array(
'type' =>
'varchar(30)',
'label' =>
'Module',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 19),
79 'posnumber' => array(
'type' =>
'varchar(30)',
'label' =>
'Terminal',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 20,
'csslist' =>
'width50 center'),
80 'label' => array(
'type' =>
'varchar(255)',
'label' =>
'Label',
'enabled' => 1,
'visible' => 0,
'position' => 24),
81 'opening' => array(
'type' =>
'price',
'label' =>
'Opening',
'enabled' => 1,
'visible' => 1,
'position' => 25,
'csslist' =>
'amount'),
82 'cash' => array(
'type' =>
'price',
'label' =>
'Cash',
'enabled' => 1,
'visible' => 1,
'position' => 30,
'csslist' =>
'amount'),
83 'cheque' => array(
'type' =>
'price',
'label' =>
'Cheque',
'enabled' => 1,
'visible' => 1,
'position' => 33,
'csslist' =>
'amount'),
84 'card' => array(
'type' =>
'price',
'label' =>
'CreditCard',
'enabled' => 1,
'visible' => 1,
'position' => 36,
'csslist' =>
'amount'),
85 'year_close' => array(
'type' =>
'integer',
'label' =>
'Year',
'enabled' => 1,
'visible' => 1,
'notnull' => 1,
'position' => 50,
'css' =>
'center'),
86 'month_close' => array(
'type' =>
'integer',
'label' =>
'Month',
'enabled' => 1,
'visible' => 1,
'position' => 55,
'css' =>
'center'),
87 'day_close' => array(
'type' =>
'integer',
'label' =>
'Day',
'enabled' => 1,
'visible' => 1,
'position' => 60,
'css' =>
'center'),
88 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 500),
89 'date_valid' => array(
'type' =>
'datetime',
'label' =>
'DateValidation',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 502),
90 'tms' => array(
'type' =>
'timestamp',
'label' =>
'Tms',
'enabled' => 1,
'visible' => 0,
'notnull' => 1,
'position' => 505),
91 'fk_user_creat' => array(
'type' =>
'integer:User',
'label' =>
'UserCreation',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 600),
92 'fk_user_valid' => array(
'type' =>
'integer:User',
'label' =>
'UserValidation',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 602),
93 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'Import key',
'enabled' => 1,
'visible' => 0,
'position' => 700),
94 'status' => array(
'type' =>
'integer',
'label' =>
'Status',
'enabled' => 1,
'visible' => 1,
'position' => 1000,
'notnull' => 1,
'index' => 1,
'arrayofkeyval' => array(
'0' =>
'Draft',
'1' =>
'Validated')),
160 public $fk_user_creat;
170 public $fk_user_valid;
173 const STATUS_DRAFT = 0;
174 const STATUS_VALIDATED = 1;
175 const STATUS_CLOSED = 1;
187 $this->ismultientitymanaged = 1;
188 $this->isextrafieldmanaged = 0;
206 if (empty($this->cash)) {
209 if (empty($this->cheque)) {
212 if (empty($this->card)) {
217 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"pos_cash_fence (";
222 $sql .=
", date_creation";
223 $sql .=
", posmodule";
224 $sql .=
", posnumber";
225 $sql .=
", day_close";
226 $sql .=
", month_close";
227 $sql .=
", year_close";
231 $sql .=
") VALUES (";
233 $sql .= ((int)
$conf->entity);
234 $sql .=
", ".(is_numeric($this->opening) ?
price2num($this->opening,
'MT') : 0);
236 $sql .=
", '".$this->db->idate(
dol_now()).
"'";
237 $sql .=
", '".$this->db->escape($this->posmodule).
"'";
238 $sql .=
", '".$this->db->escape($this->posnumber).
"'";
239 $sql .=
", ".($this->day_close > 0 ? $this->day_close :
"null");
240 $sql .=
", ".($this->month_close > 0 ? $this->month_close :
"null");
241 $sql .=
", ".((int) $this->year_close);
242 $sql .=
", ".price2num($this->cash,
'MT');
243 $sql .=
", ".price2num($this->cheque,
'MT');
244 $sql .=
", ".price2num($this->card,
'MT');
249 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
250 $resql = $this->db->query($sql);
253 $this->errors[] =
"Error ".$this->db->lasterror();
257 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"pos_cash_fence");
259 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'pos_cash_fence SET ref = rowid where rowid = '.((int) $this->
id);
260 $this->db->query($sql);
265 foreach ($this->errors as $errmsg) {
266 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
267 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
269 $this->db->rollback();
286 global
$conf, $langs;
287 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
292 if ($this->
status == self::STATUS_VALIDATED) {
293 dol_syslog(get_class($this).
"::valid action abandoned: already validated", LOG_WARNING);
300 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"pos_cash_fence";
301 $sql .=
" SET status = ".self::STATUS_VALIDATED.
",";
302 $sql .=
" date_valid='".$this->db->idate($now).
"',";
303 $sql .=
" fk_user_valid = ".((int) $user->id);
304 $sql .=
" WHERE rowid=".((int) $this->
id);
308 dol_syslog(get_class($this).
"::close", LOG_DEBUG);
309 $resql = $this->db->query($sql);
312 $this->errors[] =
"Error ".$this->db->lasterror();
316 $this->
status = self::STATUS_VALIDATED;
317 $this->date_valid = $now;
318 $this->fk_user_valid = $user->id;
321 if (!$error && !$notrigger) {
323 $result = $this->
call_trigger(
'CASHCONTROL_VALIDATE', $user);
332 foreach ($this->errors as $errmsg) {
333 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
334 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
336 $this->db->rollback();
352 public function fetch($id, $ref =
null)
378 public function delete(
User $user, $notrigger = 0)
406 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
409 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
'Draft');
410 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
'Closed');
411 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
'Draft');
412 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
'Closed');
415 $statusType =
'status0';
416 if ($status == self::STATUS_VALIDATED) {
417 $statusType =
'status6';
420 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
433 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
435 global
$conf, $langs, $hookmanager;
437 if (!empty(
$conf->dol_no_mouse_hover)) {
443 $newref = ($this->
ref ? $this->
ref : $this->id);
445 $label =
'<u>'.$langs->trans(
"CashControl").
'</u>';
447 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.($this->
ref ? $this->
ref : $this->id);
449 $url = DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_card.php?id='.$this->id;
451 if ($option !=
'nolink') {
453 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
454 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
455 $add_save_lastsearch_values = 1;
457 if ($add_save_lastsearch_values) {
458 $url .=
'&save_lastsearch_values=1';
463 if (empty($notooltip)) {
465 $label = $langs->trans(
"ShowMyObject");
466 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
468 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
469 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
471 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
474 $linkstart =
'<a href="'.$url.
'"';
475 $linkstart .= $linkclose.
'>';
478 $result .= $linkstart;
480 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
482 if ($withpicto != 2) {
483 $result .= $this->ref;
489 $hookmanager->initHooks(array(
'cashfencedao'));
490 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
491 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
493 $result = $hookmanager->resPrint;
495 $result .= $hookmanager->resPrint;
512 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
514 $return =
'<div class="box-flex-item box-flex-grow-zero">';
515 $return .=
'<div class="info-box info-box-sm">';
516 $return .=
'<span class="info-box-icon bg-infobox-action">';
519 $return .=
'</span>';
520 $return .=
'<div class="info-box-content">';
521 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl(1,
'', 1) : $this->ref).
'</span>';
522 if ($selected >= 0) {
523 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
525 if (property_exists($this,
'posmodule')) {
526 $return .=
'<br><span class="opacitymedium">'.substr($langs->trans(
"Module/Application"), 0, 12).
'</span> : <span class="info-box-label">'.$this->posmodule.
'</span>';
528 if (property_exists($this,
'year_close')) {
529 $return .=
'<br><span class="info-box-label opacitymedium" >'.$langs->trans(
"Year").
'</span> : <span>'.$this->year_close.
'</span>';
531 if (method_exists($this,
'getLibStatut')) {
532 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
Class to manage cash fence.
getKanbanView($option='', $arraydata=null)
Return clickable link of object (with eventually picto)
LibStatut($status, $mode=0)
Return the status.
valid(User $user, $notrigger=0)
Validate cash fence.
update(User $user, $notrigger=0)
Update object into database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return clickable link of object (with eventually picto)
$fields
'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]',...
create(User $user, $notrigger=0)
Create in database.
getLibStatut($mode=0)
Return label of the status.
__construct(DoliDB $db)
Constructor.
fetch($id, $ref=null)
Load object in memory from the database.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
updateCommon(User $user, $notrigger=0)
Update object into database.
fetchCommon($id, $ref=null, $morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...