';
@@ -326,15 +336,26 @@ if (empty($action) || $action=="view")
print '';
print '';
- print '| ';
+ print ' | | ';
print $langs->trans("DateCreationShort");
print ' | ';
print dol_print_date($object->date_creation, 'dayhour');
print ' | ';
- print '| '.$langs->trans("CashDesk").' ID | ';
- print $object->posnumber;
+ print ' | | '.$langs->trans("InitialBankBalance").' | ';
+ print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency);
+ print " | ";
+
+ print '| '.$langs->trans("Cash").' | ';
+ print price($object->cash, 0, $langs, 1, -1, -1, $conf->currency);
print " | ";
+ print '| '.$langs->trans("Cheque").' | ';
+ print price($object->cheque, 0, $langs, 1, -1, -1, $conf->currency);
+ print " | ";
+ print '| '.$langs->trans("Card").' | ';
+ print price($object->card, 0, $langs, 1, -1, -1, $conf->currency);
+ print " | ";
+
print " \n";
print '';
diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php
index fc83239ea70..0acb9c0dd82 100644
--- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php
+++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php
@@ -32,7 +32,7 @@ class CashControl extends CommonObject
/**
* @var string ID to identify managed object
*/
- public $element = 'CashControl';
+ public $element = 'cashcontrol';
/**
* @var string Name of table without prefix where object is stored
@@ -55,29 +55,29 @@ class CashControl extends CommonObject
public $picto = 'bank';
public $fields=array(
- 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>1, '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),
- 'posmodule' =>array('type'=>'varchar(30)', 'label'=>'Module', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>19),
- 'posnumber' =>array('type'=>'varchar(30)', 'label'=>'CashDesk', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>20),
- 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>0, 'position'=>24),
- '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),
- 'cheque' =>array('type'=>'double(24,8)', 'label'=>'Cheque', 'enabled'=>1, 'visible'=>1, 'position'=>33),
- 'card' =>array('type'=>'double(24,8)', 'label'=>'CreditCard', 'enabled'=>1, 'visible'=>1, 'position'=>36),
- 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>50),
- 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55),
- 'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>60),
- '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),
- 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated')),
+ 'rowid' =>array('type'=>'integer', 'label'=>'ID', 'enabled'=>1, 'visible'=>1, '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),
+ 'posmodule' =>array('type'=>'varchar(30)', 'label'=>'Module', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>19),
+ 'posnumber' =>array('type'=>'varchar(30)', 'label'=>'CashDesk', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>20),
+ 'label' =>array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>1, 'visible'=>0, 'position'=>24),
+ '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),
+ 'cheque' =>array('type'=>'double(24,8)', 'label'=>'Cheque', 'enabled'=>1, 'visible'=>1, 'position'=>33),
+ 'card' =>array('type'=>'double(24,8)', 'label'=>'CreditCard', 'enabled'=>1, 'visible'=>1, 'position'=>36),
+ 'year_close' =>array('type'=>'integer', 'label'=>'Year close', 'enabled'=>1, 'visible'=>1, 'notnul'=>1, 'position'=>50),
+ 'month_close' =>array('type'=>'integer', 'label'=>'Month close', 'enabled'=>1, 'visible'=>1, 'position'=>55),
+ 'day_close' =>array('type'=>'integer', 'label'=>'Day close', 'enabled'=>1, 'visible'=>1, 'position'=>60),
+ 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValid', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>490),
+ 'date_creation' =>array('type'=>'datetime', 'label'=>'DateCreation', '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),
+ 'status' => array('type'=>'integer', 'label'=>'Status', 'enabled'=>1, 'visible'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Validated')),
);
public $id;
public $opening;
public $status;
- public $date_creation;
public $year_close;
public $month_close;
public $day_close;
@@ -86,6 +86,9 @@ class CashControl extends CommonObject
public $cash;
public $cheque;
public $card;
+ public $date_valid;
+ public $date_creation;
+ public $date_modification;
const STATUS_DRAFT = 0;
const STATUS_VALIDATED = 1;
@@ -125,7 +128,7 @@ class CashControl extends CommonObject
$sql .= "entity";
//$sql .= ", ref";
$sql .= ", opening";
- $sql .= ", status";
+ $sql .= ", status";
$sql .= ", date_creation";
$sql .= ", posmodule";
$sql .= ", posnumber";
@@ -139,7 +142,7 @@ class CashControl extends CommonObject
//$sql .= "'(PROV)', ";
$sql .= $conf->entity;
$sql .= ", ".($this->opening > 0 ? $this->opening : 0);
- $sql .= ", 0"; // Draft by default
+ $sql .= ", 0"; // Draft by default
$sql .= ", '".$this->db->idate(dol_now())."'";
$sql .= ", '".$this->db->escape($this->posmodule)."'";
$sql .= ", '".$this->db->escape($this->posnumber)."'";
@@ -203,14 +206,14 @@ class CashControl extends CommonObject
}
/*
- $posmodule = $this->posmodule;
- if (! empty($user->rights->$posmodule->use))
- {
- $this->error='NotEnoughPermissions';
- dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
- return -1;
- }
- */
+ $posmodule = $this->posmodule;
+ if (! empty($user->rights->$posmodule->use))
+ {
+ $this->error='NotEnoughPermissions';
+ dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
+ return -1;
+ }
+ */
$now=dol_now();
@@ -231,13 +234,13 @@ class CashControl extends CommonObject
}
if (!$error) {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."pos_cash_fence");
+ $this->status = self::STATUS_VALIDATED;
+ $this->date_valid = $now;
+ $this->fk_user_valid = $user->id;
}
if (! $error && ! $notrigger)
{
- $this->context=array('date_valid'=>$now);
-
// Call trigger
$result=$this->call_trigger('CASHCONTROL_VALIDATE', $user);
if ($result < 0) $error++;
@@ -260,48 +263,20 @@ class CashControl extends CommonObject
/**
- * Load object in memory from database
+ * Load object in memory from the database
*
- * @param int $id Id object
- * @return int <0 if KO, >0 if OK
+ * @param int $id Id object
+ * @param string $ref Ref
+ * @return int <0 if KO, 0 if not found, >0 if OK
*/
- public function fetch($id)
+ public function fetch($id, $ref = null)
{
- global $conf;
-
- $sql = "SELECT";
- $sql .= " *";
- $sql .= " FROM ".MAIN_DB_PREFIX."pos_cash_fence";
- $sql .= " WHERE rowid = ".$id;
- $sql .= " AND entity = ".$conf->entity;
-
- dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
- $resql = $this->db->query($sql);
- 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->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);
-
- return 1;
- } else {
- $this->error = "Error ".$this->db->lasterror();
- return -1;
- }
+ $result = $this->fetchCommon($id, $ref);
+ if ($result > 0 && ! empty($this->table_element_line)) $this->fetchLines();
+ return $result;
}
+
/**
* Return label of the status
*
@@ -374,7 +349,7 @@ class CashControl extends CommonObject
* @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
+ * @param int $notooltip No tooltip
* @return string String with URL
*/
public function getNomUrl($withpicto=0, $option='', $maxlength=0, $save_lastsearch_value=-1, $notooltip=0)
diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
index f2c19394df9..b3eee673198 100644
--- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
+++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
@@ -56,10 +56,10 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
*/
public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
{
- if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing
+ if (empty($conf->blockedlog->enabled)) return 0; // Module not active, we do nothing
// Test if event/record is qualified
- $listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription','payment_various');
+ $listofqualifiedelement = array('facture', 'don', 'payment', 'payment_donation', 'subscription', 'payment_various', 'cashcontrol');
if (! in_array($object->element, $listofqualifiedelement)) return 1;
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
@@ -80,6 +80,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
|| $action==='BILL_SUPPLIER_VALIDATE' || $action==='BILL_SUPPLIER_DELETE' || $action === 'BILL_SUPPLIER_SENTBYMAIL'
|| $action==='MEMBER_SUBSCRIPTION_CREATE' || $action==='MEMBER_SUBSCRIPTION_MODIFY' || $action==='MEMBER_SUBSCRIPTION_DELETE'
|| $action==='DON_VALIDATE' || $action==='DON_MODIFY' || $action==='DON_DELETE'
+ || $action==='CASHCONTROL_VALIDATE'
|| (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_DOWNLOAD') || (in_array($object->element, array('facture','suplier_invoice')) && $action === 'DOC_PREVIEW')
)
{
@@ -88,6 +89,10 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
if (in_array($action, array(
'MEMBER_SUBSCRIPTION_CREATE','MEMBER_SUBSCRIPTION_MODIFY','MEMBER_SUBSCRIPTION_DELETE',
'DON_VALIDATE','DON_MODIFY','DON_DELETE'))) $amounts = (double) $object->amount;
+ elseif ($action == 'CASHCONTROL_VALIDATE')
+ {
+ $amounts = (double) $object->cash + (double) $object->cheque + (double) $object->card;
+ }
else $amounts = (double) $object->total_ttc;
}
/*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
@@ -103,7 +108,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
$amounts = 0;
if(!empty($object->amounts)) {
foreach($object->amounts as $amount) {
- $amounts+= price2num($amount);
+ $amounts += price2num($amount);
}
}
}
|