diff --git a/htdocs/compta/cashcontrol/cashcontrol.php b/htdocs/compta/cashcontrol/cashcontrol.php
index 6671b0562ee..9dd082bb5dd 100644
--- a/htdocs/compta/cashcontrol/cashcontrol.php
+++ b/htdocs/compta/cashcontrol/cashcontrol.php
@@ -27,9 +27,8 @@
* \brief Page ajout de categories bancaires
*/
-$res=@include("../main.inc.php");
-if (! $res) $res=@include("../../main.inc.php");
-include_once 'class/cashcontrol.class.php';
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
$langs->loadLangs(array("cashcontrol","install","cashdesk","admin"));
@@ -97,7 +96,7 @@ llxHeader();
print '
';
print '| '.$langs->trans("Ref").' | '.$langs->trans("DateCreationShort").' | '.$langs->trans("DateEnd").' | '.$langs->trans("Cash").' | '.$langs->trans("PaymentTypeCB").' | '.$langs->trans("Status").' | ';
print "
\n";
-
+
$sql = "SELECT *";
$sql.= " FROM ";
$sql.= MAIN_DB_PREFIX."pos_cash_fence order by rowid DESC";
@@ -126,7 +125,7 @@ llxHeader();
} else {
//no hay
}
-
+
print '';
}
@@ -142,25 +141,25 @@ if ($action=="view")
print '';
print '
';
print '
';
-
+
print '| ';
print $langs->trans("Code");
print ' | ';
print $id;
print ' |
';
-
+
print '| ';
print $langs->trans("DateCreationShort");
print ' | ';
print dol_print_date($cashcontrol->date_creation, 'dayhour');
print ' |
';
-
+
print '| ';
print $langs->trans("DateEnd");
print ' | ';
print dol_print_date(strtotime($cashcontrol->year_close."-".$cashcontrol->month_close."-".$cashcontrol->day_close), 'day');
print ' |
';
-
+
print '| ';
print $langs->trans("Status");
print ' | ';
@@ -177,11 +176,11 @@ if ($action=="view")
print ' |
| '.$langs->trans("InitialBankBalance").' | ';
print price($cashcontrol->opening);
print " |
";
-
+
print '| '.$langs->trans("CashDesk").' ID | ';
print $cashcontrol->posnumber;
print " |
";
-
+
print '| '.$langs->trans("Module").' | ';
print $cashcontrol->posmodule;
print " |
";
@@ -192,13 +191,15 @@ if ($action=="view")
print '';
dol_fiche_end();
-
+
print '';
print '
';
if ($cashcontrol->status==1) print '
';
print '
';
-
+
print '';
}
+// End of page
llxFooter();
+$db->close();
diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php
index fcf80e093d8..9a9006c4c45 100644
--- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php
+++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2008 Laurent Destailleur
* Copyright (C) 2009 Regis Houssin
* Copyright (C) 2016 Marcos García
- * Copyright (C) 2018 Andreu Bisquerra
+ * Copyright (C) 2018 Andreu Bisquerra
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@ class CashControl // extends CommonObject
public $day_close;
public $posmodule;
public $posnumber;
-
+
/**
* Constructor
@@ -71,14 +71,14 @@ class CashControl // extends CommonObject
$sql .= ", status";
$sql .= ", date_creation";
$sql .= ", posmodule";
- $sql .= ", posnumber";
+ $sql .= ", posnumber";
$sql .= ") VALUES (";
$sql .= $conf->entity;
$sql .= ", ".$this->opening;
$sql .= ",1";
$sql .= ", now()";
$sql .= ", '".$this->posmodule."'";
- $sql .= ", '".$this->posnumber."'";
+ $sql .= ", '".$this->posnumber."'";
$sql .= ")";
$this->db->begin();
@@ -108,10 +108,13 @@ class CashControl // extends CommonObject
}
}
-
-
-
-
+ /**
+ * close
+ *
+ * @param User $user User
+ * @param number $notrigger No trigger
+ * @return int <0 if KO, >0 if OK
+ */
public function close(User $user, $notrigger = 0)
{
global $conf;
@@ -123,7 +126,7 @@ class CashControl // extends CommonObject
$sql .= "SET";
$sql .= " day_close=DAYOFMONTH(NOW())";
$sql .= ", month_close=MONTH(NOW())";
- $sql .= ", year_close=YEAR(NOW())";
+ $sql .= ", year_close=YEAR(NOW())";
$sql .= ", status=2";
$sql .= " where rowid=".$this->id;
$this->db->begin();
@@ -152,16 +155,13 @@ class CashControl // extends CommonObject
return $this->id;
}
}
-
-
-
-
+
/**
* Load object in memory from database
*
- * @param int $id Id object
- * @return int <0 if KO, >0 if OK
+ * @param int $id Id object
+ * @return int <0 if KO, >0 if OK
*/
public function fetch($id)
{
@@ -172,7 +172,7 @@ class CashControl // extends CommonObject
$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) {
@@ -196,4 +196,4 @@ class CashControl // extends CommonObject
return -1;
}
}
-}
+}
\ No newline at end of file
diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php
index 8dd3075d8c7..c85b35c7c2e 100644
--- a/htdocs/compta/cashcontrol/report.php
+++ b/htdocs/compta/cashcontrol/report.php
@@ -7,7 +7,7 @@
* Copyright (C) 2015 Jean-François Ferry
* Copyright (C) 2016 Juanjo Menent
* Copyright (C) 2017 Alexandre Spangaro
- * Copyright (C) 2018 Andreu Bisquerra
+ * Copyright (C) 2018 Andreu Bisquerra
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,8 +29,8 @@
* \brief List of bank transactions
*/
-$res=@include("../main.inc.php");
-if (! $res) $res=@include("../../main.inc.php");
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$id = GETPOST('id','int');
@@ -48,7 +48,7 @@ $arrayfields=array(
'b.rowid'=>array('label'=>$langs->trans("Ref"), 'checked'=>1),
'b.dateo'=>array('label'=>$langs->trans("DateOperationShort"), 'checked'=>1),
'b.num_chq'=>array('label'=>$langs->trans("Number"), 'checked'=>1),
- 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1),
+ 'ba.ref'=>array('label'=>$langs->trans("BankAccount"), 'checked'=>1),
'b.debit'=>array('label'=>$langs->trans("Debit"), 'checked'=>1, 'position'=>600),
'b.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1, 'position'=>605),
);
@@ -56,7 +56,7 @@ $arrayfields=array(
/*
* View
*/
-
+
llxHeader('', $langs->trans("CashControl"), '', '', 0, 0, array(), array(), $param);
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro as conciliated, b.num_releve, b.num_chq,";
@@ -86,7 +86,7 @@ if ($resql)
{
$num = $db->num_rows($resql);
$i = 0;
-
+
print "";
if ($cashcontrol->status==2) print "Cashcontrol ".$cashcontrol->id;
else print $langs->trans("Cashcontrol")." - ".$langs->trans("Draft");
@@ -199,7 +199,7 @@ if ($resql)
$bankaccount = $cachebankaccount[$objp->bankid];
}
print '';
-
+
if ($first==""){
print '| '.$langs->trans("InitialBankBalance").' | | | | '.price($cashcontrol->opening).' |
';
print '';
@@ -275,22 +275,23 @@ if ($resql)
}
print "
";
-
+
$cash=$cash+$cashcontrol->opening;
print "
".$langs->trans("Cash").": ".price($cash)."
".$langs->trans("PaymentTypeCB").": ".price($bank)."
";
-
-
+
+
//save totals to DB
$sql = "UPDATE ".MAIN_DB_PREFIX."pos_cash_fence ";
$sql .= "SET";
$sql .= " cash='".$cash."'";
$sql .= ", card='".$bank."'";
- $sql .= " where rowid=".$id;
+ $sql .= " where rowid=".$id;
$db->query($sql);
print "
";
print '';
+
$db->free($resql);
}
else