diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 46766277669..aeb71fc6e95 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -172,6 +172,10 @@ class BlockedLog if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_CREATE']='logPAYMENT_VARIOUS_CREATE'; if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_MODIFY']='logPAYMENT_VARIOUS_MODIFY'; if ($conf->banque->enabled) $this->trackedevents['PAYMENT_VARIOUS_DELETE']='logPAYMENT_VARIOUS_DELETE'; + + // $conf->global->BANK_ENABLE_POS_CASHCONTROL must be set to 1 by all POS modules + $moduleposenabled = ($conf->cashdesk->enabled || $conf->takepos->enabled || ! empty($conf->global->BANK_ENABLE_POS_CASHCONTROL)); + if ($moduleposenabled) $this->trackedevents['CASHCONTROL_VALIDATE']='logCASHCONTROL_VALIDATE'; } /** diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index e212f8ff75b..8a122a3f939 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php' $langs->loadLangs(array("cashcontrol","install","cashdesk","admin","banks")); -$action=GETPOST('action','aZ09'); $id=GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action=GETPOST('action','aZ09'); $categid = GETPOST('categid'); $label = GETPOST("label"); @@ -47,9 +48,10 @@ if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (! $sortfield) $sortfield='b.label'; +if (! $sortfield) $sortfield='rowid'; if (! $sortorder) $sortorder='ASC'; +// Security check if (! $user->rights->cashdesk->use && ! $user->rights->takepos->use) { accessforbidden(); @@ -62,8 +64,14 @@ if (! empty($conf->cashdesk->enabled)) $arrayofposavailable['cashdesk']=$langs-> if (! empty($conf->takepos->enabled)) $arrayofposavailable['takepos']=$langs->trans('TakePOS').' (takepos)'; // TODO Add hook here to allow other POS to add themself -$cashcontrol= new CashControl($db); +$object= new CashControl($db); +$extrafields = new ExtraFields($db); +// fetch optionals attributes and labels +$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); + +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('cashcontrolcard','globalcard')); /* @@ -111,21 +119,21 @@ elseif ($action=="add") } else { - $cashcontrol->$key = price2num(GETPOST($key,'alpha')); + $object->$key = price2num(GETPOST($key,'alpha')); } } if (! $error) { - $cashcontrol->day_close = GETPOST('closeday', 'int'); - $cashcontrol->month_close = GETPOST('closemonth', 'int'); - $cashcontrol->year_close = GETPOST('closeyear', 'int'); + $object->day_close = GETPOST('closeday', 'int'); + $object->month_close = GETPOST('closemonth', 'int'); + $object->year_close = GETPOST('closeyear', 'int'); - $cashcontrol->opening=price2num(GETPOST('opening','alpha')); - $cashcontrol->posmodule=GETPOST('posmodule','alpha'); - $cashcontrol->posnumber=GETPOST('posnumber','alpha'); + $object->opening=price2num(GETPOST('opening','alpha')); + $object->posmodule=GETPOST('posmodule','alpha'); + $object->posnumber=GETPOST('posnumber','alpha'); - $id=$cashcontrol->create($user); + $id=$object->create($user); $action="view"; } @@ -133,12 +141,24 @@ elseif ($action=="add") if ($action=="close") { - $cashcontrol= new CashControl($db); - $cashcontrol->id=$id; - $cashcontrol->valid($user); - $action="view"; + $object->id=$id; + $result = $object->valid($user); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + + $action="view"; } + + +/* + * View + */ + +$form=new Form($db); + if ($action=="create" || $action=="start") { llxHeader(); @@ -260,10 +280,20 @@ if ($action=="create" || $action=="start") if (empty($action) || $action=="view") { - $cashcontrol= new CashControl($db); - $cashcontrol->fetch($id); - llxHeader(); - print load_fiche_titre($langs->trans("CashControl"), '', 'title_bank.png'); + $object->fetch($id); + + llxHeader('', $langs->trans("CashControl")); + + dol_fiche_head($head, 'cashcontrol', $langs->trans("CashControl"), -1, 'cashcontrol'); + + $linkback = '' . $langs->trans("BackToList") . ''; + + $morehtmlref='