35 public $element =
'cashcontrol';
40 public $table_element =
'pos_cash_fence';
45 public $ismultientitymanaged = 1;
50 public $isextrafieldmanaged = 0;
55 public $picto =
'cash-register';
58 public $fields = array(
59 'rowid' =>array(
'type'=>
'integer',
'label'=>
'ID',
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>10),
60 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>1,
'visible'=>0,
'notnull'=>1,
'position'=>15),
61 'ref' =>array(
'type'=>
'varchar(64)',
'label'=>
'Ref',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>18),
62 'posmodule' =>array(
'type'=>
'varchar(30)',
'label'=>
'Module',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>19),
63 'posnumber' =>array(
'type'=>
'varchar(30)',
'label'=>
'Terminal',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>20,
'css'=>
'center'),
64 'label' =>array(
'type'=>
'varchar(255)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>0,
'position'=>24),
65 'opening' =>array(
'type'=>
'price',
'label'=>
'Opening',
'enabled'=>1,
'visible'=>1,
'position'=>25),
66 'cash' =>array(
'type'=>
'price',
'label'=>
'Cash',
'enabled'=>1,
'visible'=>1,
'position'=>30),
67 'cheque' =>array(
'type'=>
'price',
'label'=>
'Cheque',
'enabled'=>1,
'visible'=>1,
'position'=>33),
68 'card' =>array(
'type'=>
'price',
'label'=>
'CreditCard',
'enabled'=>1,
'visible'=>1,
'position'=>36),
69 'year_close' =>array(
'type'=>
'integer',
'label'=>
'Year close',
'enabled'=>1,
'visible'=>1,
'notnull'=>1,
'position'=>50,
'css'=>
'center'),
70 'month_close' =>array(
'type'=>
'integer',
'label'=>
'Month close',
'enabled'=>1,
'visible'=>1,
'position'=>55,
'css'=>
'center'),
71 'day_close' =>array(
'type'=>
'integer',
'label'=>
'Day close',
'enabled'=>1,
'visible'=>1,
'position'=>60,
'css'=>
'center'),
72 'date_valid' =>array(
'type'=>
'datetime',
'label'=>
'DateValidation',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>490),
73 'date_creation' =>array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>500),
74 'tms' =>array(
'type'=>
'timestamp',
'label'=>
'Tms',
'enabled'=>1,
'visible'=>0,
'notnull'=>1,
'position'=>505),
75 'import_key' =>array(
'type'=>
'varchar(14)',
'label'=>
'Import key',
'enabled'=>1,
'visible'=>0,
'position'=>510),
76 'status' => array(
'type'=>
'integer',
'label'=>
'Status',
'enabled'=>1,
'visible'=>1,
'position'=>1000,
'notnull'=>1,
'index'=>1,
'arrayofkeyval'=>array(
'0'=>
'Brouillon',
'1'=>
'Validated')),
102 public $date_creation;
107 public $date_modification;
109 const STATUS_DRAFT = 0;
110 const STATUS_VALIDATED = 1;
111 const STATUS_CLOSED = 1;
139 if (empty($this->cash)) $this->cash = 0;
140 if (empty($this->cheque)) $this->cheque = 0;
141 if (empty($this->card)) $this->card = 0;
144 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"pos_cash_fence (";
149 $sql .=
", date_creation";
150 $sql .=
", posmodule";
151 $sql .=
", posnumber";
152 $sql .=
", day_close";
153 $sql .=
", month_close";
154 $sql .=
", year_close";
158 $sql .=
") VALUES (";
160 $sql .= $conf->entity;
161 $sql .=
", ".(is_numeric($this->opening) ? $this->opening : 0);
163 $sql .=
", '".$this->db->idate(
dol_now()).
"'";
164 $sql .=
", '".$this->db->escape($this->posmodule).
"'";
165 $sql .=
", '".$this->db->escape($this->posnumber).
"'";
166 $sql .=
", ".($this->day_close > 0 ? $this->day_close :
"null");
167 $sql .=
", ".($this->month_close > 0 ? $this->month_close :
"null");
168 $sql .=
", ".$this->year_close;
169 $sql .=
", ".$this->cash;
170 $sql .=
", ".$this->cheque;
171 $sql .=
", ".$this->card;
176 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
180 $this->errors[] =
"Error ".$this->db->lasterror();
184 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"pos_cash_fence");
186 $sql =
'UPDATE '.MAIN_DB_PREFIX.
'pos_cash_fence SET ref = rowid where rowid = '.$this->id;
187 $this->
db->query($sql);
192 foreach ($this->errors as $errmsg) {
193 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
194 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
196 $this->
db->rollback();
213 global $conf, $langs;
214 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
219 if ($this->status == self::STATUS_VALIDATED)
221 dol_syslog(get_class($this).
"::valid action abandonned: already validated", LOG_WARNING);
238 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"pos_cash_fence";
239 $sql .=
" SET status = ".self::STATUS_VALIDATED.
",";
240 $sql .=
" date_valid='".$this->db->idate($now).
"',";
241 $sql .=
" fk_user_valid = ".$user->id;
242 $sql .=
" WHERE rowid=".$this->id;
246 dol_syslog(get_class($this).
"::close", LOG_DEBUG);
250 $this->errors[] =
"Error ".$this->db->lasterror();
254 $this->status = self::STATUS_VALIDATED;
255 $this->date_valid = $now;
256 $this->fk_user_valid = $user->id;
259 if (!$error && !$notrigger)
262 $result = $this->
call_trigger(
'CASHCONTROL_VALIDATE', $user);
263 if ($result < 0) $error++;
269 foreach ($this->errors as $errmsg) {
270 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
271 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
273 $this->
db->rollback();
289 public function fetch($id, $ref = null)
315 public function delete(
User $user, $notrigger =
false)
329 return $this->
LibStatut($this->status, $mode);
343 if (empty($this->labelStatus) || empty($this->labelStatusShort))
347 $this->labelStatus[0] = $langs->trans(
'Draft');
348 $this->labelStatus[1] = $langs->trans(
'Closed');
349 $this->labelStatusShort[0] = $langs->trans(
'Draft');
350 $this->labelStatusShort[1] = $langs->trans(
'Closed');
353 $statusType =
'status0';
354 if ($status == self::STATUS_VALIDATED) $statusType =
'status6';
356 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
369 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
371 global $conf, $langs, $hookmanager;
373 if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1;
377 $newref = ($this->ref ? $this->ref : $this->id);
379 $label =
'<u>'.$langs->trans(
"CashFence").
'</u>';
381 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.($this->ref ? $this->ref : $this->id);
383 $url = DOL_URL_ROOT.
'/compta/cashcontrol/cashcontrol_card.php?id='.$this->id;
385 if ($option !=
'nolink')
388 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
389 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/',
$_SERVER[
"PHP_SELF"])) $add_save_lastsearch_values = 1;
390 if ($add_save_lastsearch_values) $url .=
'&save_lastsearch_values=1';
394 if (empty($notooltip))
396 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
398 $label = $langs->trans(
"ShowMyObject");
399 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
401 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
402 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
410 }
else $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
412 $linkstart =
'<a href="'.$url.
'"';
413 $linkstart .= $linkclose.
'>';
416 $result .= $linkstart;
417 if ($withpicto) $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);
418 if ($withpicto != 2) $result .= $this->ref;
423 $hookmanager->initHooks(array(
'cashfencedao'));
424 $parameters = array(
'id'=>$this->
id,
'getnomurl'=>$result);
425 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
427 $result = $hookmanager->resPrint;
429 $result .= $hookmanager->resPrint;
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
dol_now($mode= 'auto')
Return date for now.
Class to manage cash fence.
Class to manage Dolibarr users.
Class to manage Dolibarr database access.
LibStatut($status, $mode=0)
Return the status.
create(User $user, $notrigger=0)
Create in database.
$conf db
API class for accounts.
valid(User $user, $notrigger=0)
Validate cash fence.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
update(User $user, $notrigger=false)
Update object into database.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
getNomUrl($withpicto=0, $option= '', $notooltip=0, $morecss= '', $save_lastsearch_value=-1)
Return clicable link of object (with eventually picto)
updateCommon(User $user, $notrigger=false)
Update object into database.
__construct(DoliDB $db)
Constructor.
fetch($id, $ref=null)
Load object in memory from the database.
print $_SERVER["PHP_SELF"]
Edit parameters.
call_trigger($triggerName, $user)
Call trigger based on this instance.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dolGetStatus($statusLabel= '', $statusLabelShort= '', $html= '', $statusType= 'status0', $displayMode=0, $url= '', $params=array())
Output the badge of a status.
getLibStatut($mode=0)
Return label of the status.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
fetchCommon($id, $ref=null, $morewhere= '')
Load object in memory from the database.