diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php
index 451522e20ea..a741a0e5bbd 100644
--- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php
+++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php
@@ -27,7 +27,7 @@
/**
* Class to manage cash fence
*/
-class CashControl // extends CommonObject
+class CashControl extends CommonObject
{
/**
* @var string ID to identify managed object
@@ -55,18 +55,20 @@ class CashControl // extends CommonObject
public $picto = 'bank';
public $fields=array(
- 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>10),
- 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15),
- 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>1, 'position'=>20),
+ 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>10),
+ 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>15),
+ 'ref' =>array('type'=>'varchar(64)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>18),
+ 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>0, 'position'=>20),
'opening' =>array('type'=>'double(24,8)', 'label'=>'Opening', 'enabled'=>1, 'visible'=>1, 'position'=>25),
'cash' =>array('type'=>'double(24,8)', 'label'=>'Cash', 'enabled'=>1, 'visible'=>1, 'position'=>30),
//'card' =>array('type'=>'double(24,8)', 'label'=>'Card', 'enabled'=>1, 'visible'=>1, 'position'=>35),
+ 'cheque' =>array('type'=>'double(24,8)', 'label'=>'Cheque', 'enabled'=>1, 'visible'=>1, 'position'=>35),
'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>50),
'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55),
- 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'position'=>60),
- 'posmodule' =>array('type'=>'varchar(30)', 'label'=>'Module', 'enabled'=>1, 'visible'=>1, 'position'=>65),
- 'posnumber' =>array('type'=>'varchar(30)', 'label'=>'CashDesk', 'enabled'=>1, 'visible'=>1, 'position'=>70),
- //'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>40),
+ 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>60),
+ 'posmodule' =>array('type'=>'varchar(30)', 'label'=>'Module', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>65),
+ 'posnumber' =>array('type'=>'varchar(30)', 'label'=>'CashDesk', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>70),
+ 'status' =>array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>80),
'date_creation' =>array('type'=>'datetime', 'label'=>'Date creation', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>500),
'tms' =>array('type'=>'timestamp', 'label'=>'Tms', 'enabled'=>1, 'visible'=>0, 'notnull'=>1, 'position'=>505),
'import_key' =>array('type'=>'varchar(14)', 'label'=>'Import key', 'enabled'=>1, 'visible'=>0, 'position'=>510),
@@ -111,16 +113,18 @@ class CashControl // extends CommonObject
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."pos_cash_fence (";
$sql .= "entity";
+ //$sql .= ", ref";
$sql .= ", opening";
$sql .= ", status";
$sql .= ", date_creation";
$sql .= ", posmodule";
$sql .= ", posnumber";
$sql .= ") VALUES (";
+ //$sql .= "'(PROV)', ";
$sql .= $conf->entity;
$sql .= ", ".$this->opening;
$sql .= ",1";
- $sql .= ", now()";
+ $sql .= ", '".$this->db->idate(dol_now())."'";
$sql .= ", '".$this->posmodule."'";
$sql .= ", '".$this->posnumber."'";
$sql .= ")";
@@ -167,12 +171,12 @@ class CashControl // extends CommonObject
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."pos_cash_fence ";
- $sql .= "SET";
- $sql .= " day_close=DAYOFMONTH(NOW())";
- $sql .= ", month_close=MONTH(NOW())";
- $sql .= ", year_close=YEAR(NOW())";
- $sql .= ", status=2";
- $sql .= " where rowid=".$this->id;
+ $sql.= "SET";
+ $sql.= " day_close=DAYOFMONTH(NOW())";
+ $sql.= ", month_close=MONTH(NOW())";
+ $sql.= ", year_close=YEAR(NOW())";
+ $sql.= ", status=2";
+ $sql.= " where rowid=".$this->id;
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@@ -222,14 +226,17 @@ class CashControl // extends CommonObject
if ($resql) {
if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
+ $this->ref = $obj->id;
+ $this->label = $obj->label;
$this->opening = $obj->opening;
$this->status = $obj->status;
- $this->date_creation = $obj->date_creation;
$this->year_close = $obj->year_close;
$this->month_close = $obj->month_close;
$this->day_close = $obj->day_close;
$this->posmodule = $obj->posmodule;
$this->posnumber = $obj->posnumber;
+ $this->date_creation = $obj->date_creation;
+ $this->tms = $obj->tms;
$this->id=$id;
}
$this->db->free($resql);
@@ -240,4 +247,78 @@ class CashControl // extends CommonObject
return -1;
}
}
+
+
+ /**
+ * Return clicable link of object (with eventually picto)
+ *
+ * @param int $withpicto Add picto into link
+ * @param string $option Where point the link ('stock', 'composition', 'category', 'supplier', '')
+ * @param int $maxlength Maxlength of ref
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @param int $notooltip No tooltip
+ * @return string String with URL
+ */
+ public function getNomUrl($withpicto=0, $option='', $maxlength=0, $save_lastsearch_value=-1, $notooltip=0)
+ {
+ global $conf, $langs, $hookmanager;
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
+
+ $result='';
+ $newref=($this->ref?$this->ref:$this->id);
+ if ($maxlength) { $newref=dol_trunc($newref, $maxlength, 'middle'); }
+
+ $label = '' . $langs->trans("ShowCashFence") . '';
+ $label .= '
' . $langs->trans('ProductRef') . ': ' . ($this->ref?$this->ref:$this->id);
+
+ $linkclose='';
+ if (empty($notooltip)) {
+ if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
+ $label=$langs->trans("ShowCashFence");
+ $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+
+ $linkclose.= ' title="'.dol_escape_htmltag($label, 1, 1).'"';
+ $linkclose.= ' class="classfortooltip"';
+
+ /*
+ $hookmanager->initHooks(array('productdao'));
+ $parameters=array('id'=>$this->id);
+ $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) $linkclose = $hookmanager->resPrint;
+ */
+ }
+
+ $url = DOL_URL_ROOT.'/compta/cashcontrol/cashcontrol_card.php?id='.$this->id;
+
+ if ($option !== 'nolink') {
+ // Add param to save lastsearch_values or not
+ $add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values=1;
+ }
+ if ($add_save_lastsearch_values) { $url.='&save_lastsearch_values=1';
+ }
+ }
+
+ $linkstart = '';
+ $linkend='';
+
+ $result.=$linkstart;
+ if ($withpicto) {
+ $result.=(img_object(($notooltip?'':$label), 'bank', ($notooltip?'class="paddingright"':'class="paddingright classfortooltip"'), 0, 0, $notooltip?0:1));
+ }
+ $result.= $newref;
+ $result.= $linkend;
+
+ global $action;
+ $hookmanager->initHooks(array('cashfencedao'));
+ $parameters=array('id'=>$this->id, 'getnomurl'=>$result);
+ $reshook=$hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
+ if ($reshook > 0) { $result = $hookmanager->resPrint;
+ } else { $result .= $hookmanager->resPrint;
+ }
+
+ return $result;
+ }
}
\ No newline at end of file
diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php
index 00bcda7607b..c1748134444 100644
--- a/htdocs/compta/cashcontrol/report.php
+++ b/htdocs/compta/cashcontrol/report.php
@@ -88,8 +88,8 @@ if ($resql)
$i = 0;
print "