/**
  * 
  * 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);
 }
     foreach ($tab as $key => $value) {
         $return[$key] = $value;
     }
     $_SESSION['uid'] = $tab['rowid'];
     $_SESSION['uname'] = $username;
     $_SESSION['nom'] = $tab['lastname'];
     $_SESSION['prenom'] = $tab['firstname'];
     $_SESSION['TERMINAL_ID'] = $terminalid;
     dol_include_once('/pos/class/cash.class.php');
     $terminal = new Cash($db);
     $terminal->fetch($terminalid);
     $userstatic = new User($db);
     $userstatic->fetch($_SESSION['uid']);
     $terminal->set_used($userstatic);
     if ($terminal->is_closed) {
         $terminal->set_open($userstatic);
     }
     //var_dump($_SESSION);exit;
     if ($terminal->tactil == 2) {
         if (file_exists(dol_buildpath('/pos/frontend/movil.php'))) {
             header('Location: ' . dol_buildpath('/pos/frontend/movil.php', 1));
         } else {
             header('Location: ' . dol_buildpath('/pos/frontend/tpv.php', 1));
         }
     } else {
         header('Location: ' . dol_buildpath('/pos/frontend/tpv.php', 1));
     }
     exit;
 } else {
     dol_print_error($db);
 }