Fix cash fence feature
This commit is contained in:
parent
7c1ed5b913
commit
1b19f5153b
@ -383,12 +383,24 @@ class BlockedLog
|
|||||||
|
|
||||||
// Set object_data
|
// Set object_data
|
||||||
$this->object_data=new stdClass();
|
$this->object_data=new stdClass();
|
||||||
|
// Add fields to exclude
|
||||||
$arrayoffieldstoexclude = array(
|
$arrayoffieldstoexclude = array(
|
||||||
'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf',
|
'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf','civility_id','contact','contact_id',
|
||||||
'table_element_line','ismultientitymanaged','isextrafieldmanaged',
|
'table_element_line','ismultientitymanaged','isextrafieldmanaged',
|
||||||
'linkedObjectsIds','linkedObjects','fk_delivery_address',
|
'linkedObjectsIds','linkedObjects','fk_delivery_address',
|
||||||
'context'
|
'context',
|
||||||
|
'projet' // There is already ->fk_project
|
||||||
);
|
);
|
||||||
|
// Add more fields to exclude depending on object type
|
||||||
|
if ($this->element == 'cashcontrol')
|
||||||
|
{
|
||||||
|
$arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array(
|
||||||
|
'name','lastname','firstname','region','region_id','region_code','state','state_id','state_code','country','country_id','country_code',
|
||||||
|
'total_ht','total_tva','total_ttc','total_localtax1','total_localtax2',
|
||||||
|
'barcode_type','barcode_type_code','barcode_type_label','barcode_type_coder','mode_reglement_id','cond_reglement_id','mode_reglement','cond_reglement','shipping_method_id',
|
||||||
|
'fk_incoterms','libelle_incoterms','location_incoterms','lines')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Add thirdparty info
|
// Add thirdparty info
|
||||||
if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty();
|
if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty();
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
use Stripe\BankAccount;
|
|
||||||
|
|
||||||
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
@ -33,7 +31,7 @@ require '../../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php';
|
||||||
|
|
||||||
$langs->loadLangs(array("cashcontrol","install","cashdesk","admin","banks"));
|
$langs->loadLangs(array("install","cashdesk","admin","banks"));
|
||||||
|
|
||||||
$id=GETPOST('id','int');
|
$id=GETPOST('id','int');
|
||||||
$ref = GETPOST('ref', 'alpha');
|
$ref = GETPOST('ref', 'alpha');
|
||||||
@ -84,16 +82,23 @@ $hookmanager->initHooks(array('cashcontrolcard','globalcard'));
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$permissiontoadd = ($user->rights->cashdesk->use || $user->rights->takepos->use);
|
||||||
|
$permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use) || ($permissiontoadd && $object->status == 0);
|
||||||
|
if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcontrol_card.php',1).'?id='.($id > 0 ? $id : '__ID__');
|
||||||
|
$backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php',1);
|
||||||
|
$triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||||
|
|
||||||
if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH))
|
if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH))
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("CashDesk")." - ".$langs->trans("NotConfigured"), null, 'errors');
|
setEventMessages($langs->trans("CashDesk")." - ".$langs->trans("NotConfigured"), null, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (GETPOST('cancel'))
|
if (GETPOST('cancel','alpha'))
|
||||||
{
|
{
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action=="start")
|
if ($action=="start")
|
||||||
{
|
{
|
||||||
$error=0;
|
$error=0;
|
||||||
@ -127,7 +132,7 @@ elseif ($action=="add")
|
|||||||
$error=0;
|
$error=0;
|
||||||
foreach($arrayofpaymentmode as $key=>$val)
|
foreach($arrayofpaymentmode as $key=>$val)
|
||||||
{
|
{
|
||||||
if (GETPOST($key,'alpha') == '')
|
if (GETPOST($key.'_amount','alpha') == '')
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors');
|
||||||
$action='start';
|
$action='start';
|
||||||
@ -135,7 +140,7 @@ elseif ($action=="add")
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$object->$key = price2num(GETPOST($key,'alpha'));
|
$object->$key = price2num(GETPOST($key.'_amount','alpha'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +188,32 @@ if ($action=="close")
|
|||||||
$action="view";
|
$action="view";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Action to delete
|
||||||
|
if ($action == 'confirm_delete' && ! empty($permissiontodelete))
|
||||||
|
{
|
||||||
|
$object->fetch($id);
|
||||||
|
|
||||||
|
if (! ($object->id > 0))
|
||||||
|
{
|
||||||
|
dol_print_error('', 'Error, object must be fetched before being deleted');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result=$object->delete($user);
|
||||||
|
var_dump($result);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
// Delete OK
|
||||||
|
setEventMessages("RecordDeleted", null, 'mesgs');
|
||||||
|
header("Location: ".$backurlforlist);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
|
||||||
|
else setEventMessages($object->error, null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -414,7 +445,7 @@ if ($action=="create" || $action=="start")
|
|||||||
foreach($arrayofpaymentmode as $key => $val)
|
foreach($arrayofpaymentmode as $key => $val)
|
||||||
{
|
{
|
||||||
print '<td align="center"'.($i == 0 ? ' class="hide0"':'').'>';
|
print '<td align="center"'.($i == 0 ? ' class="hide0"':'').'>';
|
||||||
print '<input name="'.$key.'" type="text"'.($key == 'cash'?' autofocus':'').' class="maxwidth100 center" value="'.GETPOST($key,'alpha').'">';
|
print '<input name="'.$key.'_amount" type="text"'.($key == 'cash'?' autofocus':'').' class="maxwidth100 center" value="'.GETPOST($key.'_amount','alpha').'">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -493,16 +524,12 @@ if (empty($action) || $action=="view")
|
|||||||
print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency);
|
print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency);
|
||||||
print "</td></tr>";
|
print "</td></tr>";
|
||||||
|
|
||||||
print '<tr><td valign="middle">'.$langs->trans("Cash").'</td><td>';
|
foreach($arrayofpaymentmode as $key => $val)
|
||||||
print price($object->cash, 0, $langs, 1, -1, -1, $conf->currency);
|
{
|
||||||
print "</td></tr>";
|
print '<tr><td valign="middle">'.$langs->trans($val).'</td><td>';
|
||||||
print '<tr><td valign="middle">'.$langs->trans("Cheque").'</td><td>';
|
print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency);
|
||||||
print price($object->cheque, 0, $langs, 1, -1, -1, $conf->currency);
|
print "</td></tr>";
|
||||||
print "</td></tr>";
|
}
|
||||||
print '<tr><td valign="middle">'.$langs->trans("Card").'</td><td>';
|
|
||||||
print price($object->card, 0, $langs, 1, -1, -1, $conf->currency);
|
|
||||||
print "</td></tr>";
|
|
||||||
|
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
print '</div>';
|
print '</div>';
|
||||||
@ -516,6 +543,8 @@ if (empty($action) || $action=="view")
|
|||||||
if ($object->status == CashControl::STATUS_DRAFT)
|
if ($object->status == CashControl::STATUS_DRAFT)
|
||||||
{
|
{
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '&action=close">' . $langs->trans('Close') . '</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '&action=close">' . $langs->trans('Close') . '</a></div>';
|
||||||
|
|
||||||
|
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $id . '&action=confirm_delete">' . $langs->trans('Delete') . '</a></div>';
|
||||||
}
|
}
|
||||||
print '</div>';
|
print '</div>';
|
||||||
|
|
||||||
|
|||||||
@ -276,6 +276,18 @@ class CashControl extends CommonObject
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete object in database
|
||||||
|
*
|
||||||
|
* @param User $user User that deletes
|
||||||
|
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||||
|
* @return int <0 if KO, >0 if OK
|
||||||
|
*/
|
||||||
|
public function delete(User $user, $notrigger = false)
|
||||||
|
{
|
||||||
|
return $this->deleteCommon($user, $notrigger);
|
||||||
|
//return $this->deleteCommon($user, $notrigger, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return label of the status
|
* Return label of the status
|
||||||
|
|||||||
@ -286,7 +286,7 @@ if ($resql)
|
|||||||
print "<div style='text-align: right'><h2>";
|
print "<div style='text-align: right'><h2>";
|
||||||
print $langs->trans("Cash").": ".price($cash)."<br><br>";
|
print $langs->trans("Cash").": ".price($cash)."<br><br>";
|
||||||
print $langs->trans("PaymentTypeCB").": ".price($bank)."<br><br>";
|
print $langs->trans("PaymentTypeCB").": ".price($bank)."<br><br>";
|
||||||
print $langs->trans("PaymentTypeCheque").": ".price($cheque)."<br><br>";
|
print $langs->trans("PaymentTypeCHQ").": ".price($cheque)."<br><br>";
|
||||||
print "</h2></div>";
|
print "</h2></div>";
|
||||||
|
|
||||||
//save totals to DB
|
//save totals to DB
|
||||||
|
|||||||
@ -149,6 +149,7 @@ if ($action == 'update' && ! empty($permissiontoadd))
|
|||||||
if ($action == "update_extras" && ! empty($permissiontoadd))
|
if ($action == "update_extras" && ! empty($permissiontoadd))
|
||||||
{
|
{
|
||||||
$object->fetch(GETPOST('id','int'));
|
$object->fetch(GETPOST('id','int'));
|
||||||
|
|
||||||
$attributekey = GETPOST('attribute','alpha');
|
$attributekey = GETPOST('attribute','alpha');
|
||||||
$attributekeylong = 'options_'.$attributekey;
|
$attributekeylong = 'options_'.$attributekey;
|
||||||
$object->array_options['options_'.$attributekey] = GETPOST($attributekeylong,' alpha');
|
$object->array_options['options_'.$attributekey] = GETPOST($attributekeylong,' alpha');
|
||||||
@ -169,6 +170,12 @@ if ($action == "update_extras" && ! empty($permissiontoadd))
|
|||||||
// Action to delete
|
// Action to delete
|
||||||
if ($action == 'confirm_delete' && ! empty($permissiontodelete))
|
if ($action == 'confirm_delete' && ! empty($permissiontodelete))
|
||||||
{
|
{
|
||||||
|
if (! ($object->id > 0))
|
||||||
|
{
|
||||||
|
dol_print_error('', 'Error, object must be fetched before being deleted');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$result=$object->delete($user);
|
$result=$object->delete($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -42,4 +42,7 @@ Place=Place
|
|||||||
TakeposConnectorNecesary='TakePOS Connector' required
|
TakeposConnectorNecesary='TakePOS Connector' required
|
||||||
OrderPrinters=Order printers
|
OrderPrinters=Order printers
|
||||||
SearchProduct=Search product
|
SearchProduct=Search product
|
||||||
AmountAtEndOfPeriod=Amount at end of period (day, month or year)
|
AmountAtEndOfPeriod=Amount at end of period (day, month or year)
|
||||||
|
TheoricalAmount=Theorical amount
|
||||||
|
RealAmount=Real amount
|
||||||
|
CashFenceDone=Cash fence done for the period
|
||||||
@ -118,7 +118,7 @@ if (empty($reshook))
|
|||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$permissiontoadd = $user->rights->mymodule->write;
|
$permissiontoadd = $user->rights->mymodule->write;
|
||||||
$permissiontodelete = $user->rights->mymodule->delete;
|
$permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0);
|
||||||
if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id='.($id > 0 ? $id : '__ID__');
|
if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id='.($id > 0 ? $id : '__ID__');
|
||||||
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1);
|
$backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1);
|
||||||
$triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record
|
$triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user