/** * * Enter description here ... * @param $aryClose */ public static function setControlCash($aryClose) { global $db, $user; $function = "closeCash"; $error = 0; $terminalid = $_SESSION['TERMINAL_ID']; $userpos = new User($db); $userpos->fetch($aryClose['employeeId']); $userpos->getrights('pos'); if ($userpos->rights->pos->closecash || !$aryClose['type']) { $cash = new ControlCash($db, $terminalid); $data['userid'] = $aryClose['employeeId']; $data['amount_reel'] = $aryClose['moneyincash']; $data['amount_teoric'] = $cash->getMoneyCash(); $data['amount_diff'] = $data['amount_reel'] - $data['amount_teoric']; $data['type_control'] = $aryClose['type']; $data['print'] = $aryClose['print']; $res = $cash->create($data); if ($res > 0) { $terminal = new Cash($db); $userstatic = new User($db); $userstatic->fetch($id); $terminal->fetch($terminalid); if ($aryClose['type'] == 1) { if (!$terminal->set_closed($userstatic)) { $error++; } } elseif ($aryClose['type'] == 2) { if (!$terminal->set_open($userstatic)) { $error++; } } } else { $error++; } } else { $error = 2; } if ($error == 0) { $error = $res; } else { $error = $error * -1; } return ErrorControl($error, $function); }
require_once DOL_DOCUMENT_ROOT . "/core/class/html.formcompany.class.php"; dol_include_once('/pos/class/cash.class.php'); dol_include_once('/pos/class/pos.class.php'); global $db, $conf, $langs; $langs->load("pos@pos"); $langs->load('bills'); $action = GETPOST('action', 'alpha'); $terminalid = GETPOST('terminalid', 'int'); $amountreel = GETPOST('amountreel'); if ($user->societe_id) { $socid = $user->societe_id; } //$result=restrictedArea($user,'pos',$id,'pos_cash','','','rowid'); $control = new ControlCash($db, $terminalid); $terminal = new Cash($db); $amountteo = $control->getMoneyCash(); /* * Actions */ if (GETPOST('action', 'alpha') == 'add') { $error = 0; $data['userid'] = $user->id; $data['amount_reel'] = $amountreel; $data['amount_teoric'] = $amountteo; $data['amount_diff'] = $amountreel - $amountteo; $data['type_control'] = 1; $control->Create($data); //controlar error if ($control->error) { setEventMessage("ErrCloseCash", "errors"); } else {