/** * * 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); }