35 public $element =
'cashcontrol';
40 public $table_element =
'pos_cash_fence';
45 public $ismultientitymanaged = 1;
50 public $isextrafieldmanaged = 0;
55 public $picto =
'cash-register';
83 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>10),
84 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>1,
'visible'=>0,
'notnull'=>1,
'position'=>15),
85 'ref' =>array(
'type'=>
'varchar(64)',
'label'=>
'Ref',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>18),
86 'posmodule' =>array(
'type'=>
'varchar(30)',
'label'=>
'Module',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>19),
87 'posnumber' =>array(
'type'=>
'varchar(30)',
'label'=>
'Terminal',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>20,
'css'=>
'center'),
88 'label' =>array(
'type'=>
'varchar(255)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>0,
'position'=>24),
89 'opening' =>array(
'type'=>
'price',
'label'=>
'Opening',
'enabled'=>1,
'visible'=>1,
'position'=>25,
'csslist'=>
'amount'),
90 'cash' =>array(
'type'=>
'price',
'label'=>
'Cash',
'enabled'=>1,
'visible'=>1,
'position'=>30,
'csslist'=>
'amount'),
91 'cheque' =>array(
'type'=>
'price',
'label'=>
'Cheque',
'enabled'=>1,
'visible'=>1,
'position'=>33,
'csslist'=>
'amount'),
92 'card' =>array(
'type'=>
'price',
'label'=>
'CreditCard',
'enabled'=>1,
'visible'=>1,
'position'=>36,
'csslist'=>
'amount'),
93 'year_close' =>array(
'type'=>
'integer',
'label'=>
'Year close',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>50,
'css'=>
'center'),
94 'month_close' =>array(
'type'=>
'integer',
'label'=>
'Month close',
'enabled'=>1,
'visible'=>1,
'position'=>55,
'css'=>
'center'),
95 'day_close' =>array(
'type'=>
'integer',
'label'=>
'Day close',
'enabled'=>1,
'visible'=>1,
'position'=>60,
'css'=>
'center'),
96 'date_creation' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>500),
97 'date_valid' =>array(
'type'=>
'datetime',
'label'=>
'DateValidation',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>502),
98 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'Tms',
'enabled'=>1,
'visible'=>0,
'notnull'=>1,
'position'=>505),
99 'fk_user_creat' =>array(
'type'=>
'integer:User',
'label'=>
'UserCreation',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>600),
100 'fk_user_valid' =>array(
'type'=>
'integer:User',
'label'=>
'UserValidation',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>602),
101 'import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'Import key',
'enabled'=>1,
'visible'=>0,
'position'=>700),
102 'status' => array(
'type'=>
'integer',
'label'=>
'Status',
'enabled'=>1,
'visible'=>1,
'position'=>1000,
'notnull'=>1,
'index'=>1,
'arrayofkeyval'=>array(
'0'=>
'Draft',
'1'=>
'Validated')),
123 public $date_creation;
124 public $fk_user_creat;
129 public $date_modification;
135 public $fk_user_valid;
138 const STATUS_DRAFT = 0;
139 const STATUS_VALIDATED = 1;
140 const STATUS_CLOSED = 1;
168 if (empty($this->cash)) {
171 if (empty($this->cheque)) {
174 if (empty($this->card)) {
179 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"pos_cash_fence (";
184 $sql .=
", date_creation";
185 $sql .=
", posmodule";
186 $sql .=
", posnumber";
187 $sql .=
", day_close";
188 $sql .=
", month_close";
189 $sql .=
", year_close";
193 $sql .=
") VALUES (";
195 $sql .= ((int) $conf->entity);
196 $sql .=
", ".(is_numeric($this->opening) ?
price2num($this->opening,
'MT') : 0);
198 $sql .=
", '".$this->db->idate(
dol_now()).
"'";
199 $sql .=
", '".$this->db->escape($this->posmodule).
"'";
200 $sql .=
", '".$this->db->escape($this->posnumber).
"'";
201 $sql .=
", ".($this->day_close > 0 ? $this->day_close :
"null");
202 $sql .=
", ".($this->month_close > 0 ? $this->month_close :
"null");
203 $sql .=
", ".((int) $this->year_close);
204 $sql .=
", ".price2num($this->cash,
'MT');
205 $sql .=
", ".price2num($this->cheque,
'MT');
206 $sql .=
", ".price2num($this->card,
'MT');
211 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
215 $this->errors[] =
"Error ".$this->db->lasterror();
219 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"pos_cash_fence");
221 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'pos_cash_fence SET ref = rowid where rowid = '.((int) $this->
id);
222 $this->
db->query($sql);
227 foreach ($this->errors as $errmsg) {
228 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
229 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
231 $this->
db->rollback();
248 global $conf, $langs;
249 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
254 if ($this->status == self::STATUS_VALIDATED) {
255 dol_syslog(get_class($this).
"::valid action abandonned: already validated", LOG_WARNING);
272 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"pos_cash_fence";
273 $sql .=
" SET status = ".self::STATUS_VALIDATED.
",";
274 $sql .=
" date_valid='".$this->db->idate($now).
"',";
275 $sql .=
" fk_user_valid = ".$user->id;
276 $sql .=
" WHERE rowid=".((int) $this->
id);
280 dol_syslog(get_class($this).
"::close", LOG_DEBUG);
284 $this->errors[] =
"Error ".$this->db->lasterror();
288 $this->status = self::STATUS_VALIDATED;
289 $this->date_valid = $now;
290 $this->fk_user_valid = $user->id;
293 if (!$error && !$notrigger) {
295 $result = $this->
call_trigger(
'CASHCONTROL_VALIDATE', $user);
304 foreach ($this->errors as $errmsg) {
305 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
306 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
308 $this->
db->rollback();
324 public function fetch($id, $ref =
null)
350 public function delete(
User $user, $notrigger =
false)
364 return $this->
LibStatut($this->status, $mode);
378 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
381 $this->labelStatus[0] = $langs->transnoentitiesnoconv(
'Draft');
382 $this->labelStatus[1] = $langs->transnoentitiesnoconv(
'Closed');
383 $this->labelStatusShort[0] = $langs->transnoentitiesnoconv(
'Draft');
384 $this->labelStatusShort[1] = $langs->transnoentitiesnoconv(
'Closed');
387 $statusType =
'status0';
388 if ($status == self::STATUS_VALIDATED) {
389 $statusType =
'status6';
392 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
405 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
407 global $conf, $langs, $hookmanager;
409 if (!empty($conf->dol_no_mouse_hover)) {
415 $newref = ($this->
ref ? $this->
ref : $this->id);
417 $label =
'<u>'.$langs->trans(
"CashControl").
'</u>';
419 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.($this->
ref ? $this->
ref : $this->id);
421 $url = DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_card.php?id='.$this->id;
423 if ($option !=
'nolink') {
425 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
426 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
427 $add_save_lastsearch_values = 1;
429 if ($add_save_lastsearch_values) {
430 $url .=
'&save_lastsearch_values=1';
435 if (empty($notooltip)) {
436 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
437 $label = $langs->trans(
"ShowMyObject");
438 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
440 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
441 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
443 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
446 $linkstart =
'<a href="'.$url.
'"';
447 $linkstart .= $linkclose.
'>';
450 $result .= $linkstart;
452 $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);
454 if ($withpicto != 2) {
455 $result .= $this->ref;
461 $hookmanager->initHooks(array(
'cashfencedao'));
462 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
463 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
465 $result = $hookmanager->resPrint;
467 $result .= $hookmanager->resPrint;
Class to manage cash fence.
LibStatut($status, $mode=0)
Return the status.
valid(User $user, $notrigger=0)
Validate cash fence.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return clicable link of object (with eventually picto)
$fields
'type' field format ('integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter]]',...
create(User $user, $notrigger=0)
Create in database.
update(User $user, $notrigger=false)
Update object into 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,...
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
updateCommon(User $user, $notrigger=false)
Update object into database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.