Example #1
0
 /**
   Finish the current transaction
   @param $incomplete [boolean] optional, default false
 
   This method:
   1) Adds tax and discount lines if transaction is complete
      (i.e., $incomplete == false)
   2) Rotates data out of localtemptrans
   3) Advances trans_no variable to next available value
 
   This method replaces older ajax-end.php / end.php operations
   where the receipt was printed first and then steps 1-3
   above happened. This method should be called BEFORE printing
   a receipt. Receipts are now always printed via localtranstoday.
 */
 public static function finalizeTransaction($incomplete = false)
 {
     if (!$incomplete) {
         self::addtransDiscount();
         self::addTax();
         $taxes = Database::LineItemTaxes();
         foreach ($taxes as $tax) {
             if (CoreLocal::get('TaxExempt') == 1) {
                 $tax['amount'] = 0.0;
             }
             self::addLogRecord(array('upc' => 'TAXLINEITEM', 'description' => $tax['description'], 'numflag' => $tax['rate_id'], 'amount2' => $tax['amount']));
         }
         DiscountModule::lineItems();
     }
     if (Database::rotateTempData()) {
         // rotate data
         Database::clearTempTables();
     }
     // advance trans_no value
     Database::loadglobalvalues();
     $nextTransNo = Database::gettransno(CoreLocal::get('CashierNo'));
     CoreLocal::set('transno', $nextTransNo);
     Database::setglobalvalue('TransNo', $nextTransNo);
 }
Example #2
0
 function check($str)
 {
     $my_url = MiscLib::base_url();
     $this->dest_input_page = "";
     $this->dest_main_page = "";
     $this->dest_scale = False;
     $this->ret = $this->default_json();
     // Argument to PV, either before or after.
     if (substr($str, -2, 2) == "PV") {
         $pvsearch = substr($str, 0, -2);
         $str = "PV";
     } elseif (substr($str, 0, 2) == "PV") {
         $pvsearch = substr($str, 2);
         $str = "PV";
     }
     // common error message
     $repeat = CoreLocal::get('msgrepeat');
     $in_progress_msg = DisplayLib::boxMsg(_("transaction in progress"), '', true, DisplayLib::standardClearButton());
     CoreLocal::set('msgrepeat', $repeat);
     switch ($str) {
         case 'CAB':
             if (CoreLocal::get("LastID") != "0") {
                 $this->ret['output'] = $in_progress_msg;
             } else {
                 $this->ret['main_frame'] = $my_url . "gui-modules/cablist.php";
             }
             return true;
         case "PV":
             CoreLocal::set("pvsearch", "{$pvsearch}");
             $this->ret['main_frame'] = $my_url . "gui-modules/productlist.php";
             return true;
         case "MSTG":
             if (CoreLocal::get('memType') == 1 || CoreLocal::get('memType') == 2) {
                 // could this be CoreLocal::get('isMember') == 1
                 // to avoid relying on specific memTypes?
                 $this->ret['output'] = DisplayLib::boxMsg(_("Cannot UNset a member status"), '', true, DisplayLib::standardClearButton());
             } elseif (CoreLocal::get("SecuritySR") > 20) {
                 $this->ret['main_frame'] = $my_url . "gui-modules/adminlogin.php?class=MemStatusAdminLogin";
             } else {
                 $this->ret['output'] = DisplayLib::boxMsg(_("You must be an admin to do this."), _('Access Denied'), true, DisplayLib::standardClearButton());
             }
             return true;
         case "UNDO":
             if (CoreLocal::get("LastID") != "0") {
                 $this->ret['output'] = $in_progress_msg;
             } else {
                 $this->ret['main_frame'] = $my_url . "gui-modules/adminlogin.php?class=UndoAdminLogin";
             }
             return true;
         case 'SK':
         case "DDD":
             $this->ret['main_frame'] = $my_url . "gui-modules/DDDReason.php";
             return true;
         case 'MG':
             if (CoreLocal::get("SecuritySR") > 20) {
                 $this->ret['main_frame'] = $my_url . "gui-modules/adminlogin.php?class=SusResAdminLogin";
             } else {
                 $this->ret['main_frame'] = $my_url . "gui-modules/adminlist.php";
             }
             return true;
         case 'RP':
             if (CoreLocal::get("LastID") != "0") {
                 $tr = CoreLocal::get("receiptToggle");
                 if ($tr == 1) {
                     CoreLocal::set("receiptToggle", 0);
                 } else {
                     CoreLocal::set("receiptToggle", 1);
                 }
                 $this->ret['main_frame'] = $my_url . "gui-modules/pos2.php";
             } else {
                 $db = Database::tDataConnect();
                 $query = "select register_no, emp_no, trans_no, " . "sum((case when trans_type = 'T' then -1 * total else 0 end)) as total " . "from localtranstoday where register_no = " . CoreLocal::get("laneno") . " and emp_no = " . CoreLocal::get("CashierNo") . " AND datetime >= " . $db->curdate() . " group by register_no, emp_no, trans_no order by 1000 - trans_no";
                 $result = $db->query($query);
                 $num_rows = $db->num_rows($result);
                 if ($num_rows == 0) {
                     $this->ret['output'] = DisplayLib::boxMsg(_("no receipt found"), '', true, DisplayLib::standardClearButton());
                 } else {
                     $this->ret['main_frame'] = $my_url . "gui-modules/rplist.php";
                 }
             }
             return true;
         case 'ID':
             $this->ret['main_frame'] = $my_url . "gui-modules/memlist.php";
             return true;
         case 'DDM':
             $this->ret['main_frame'] = $my_url . 'gui-modules/drawerPage.php';
             return true;
         case 'SS':
         case 'SO':
             // sign off and suspend shift are identical except for
             // drawer behavior
             if (CoreLocal::get("LastID") != 0) {
                 $this->ret['output'] = $in_progress_msg;
             } else {
                 TransRecord::addLogRecord(array('upc' => 'SIGNOUT', 'description' => 'Sign Out Emp#' . CoreLocal::get('CashierNo')));
                 Database::setglobalvalue("LoggedIn", 0);
                 CoreLocal::set("LoggedIn", 0);
                 CoreLocal::set("training", 0);
                 CoreLocal::set("gui-scale", "no");
                 /**
                   An empty transaction may still contain
                   invisible, logging records. Rotate those
                   out of localtemptrans to ensure sequential
                   trans_id values
                 */
                 if (Database::rotateTempData()) {
                     Database::clearTempTables();
                 }
                 if ($str == 'SO') {
                     if (session_id() != '') {
                         session_write_close();
                     }
                     $kicker_class = CoreLocal::get("kickerModule") == "" ? 'Kicker' : CoreLocal::get('kickerModule');
                     $kicker_object = new $kicker_class();
                     if ($kicker_object->kickOnSignOut()) {
                         ReceiptLib::drawerKick();
                     }
                     ReceiptLib::freeDrawer(ReceiptLib::currentDrawer());
                 }
                 $this->ret['main_frame'] = $my_url . "login.php";
             }
             return true;
         case 'NS':
             if (CoreLocal::get("LastID") != 0) {
                 $this->ret['output'] = $in_progress_msg;
             } else {
                 $this->ret['main_frame'] = $my_url . "gui-modules/nslogin.php";
             }
             return true;
         case 'GD':
             CoreLocal::set("msgrepeat", 0);
             $this->ret['main_frame'] = $my_url . "gui-modules/giftcardlist.php";
             return true;
         case 'IC':
             CoreLocal::set("msgrepeat", 0);
             $this->ret['main_frame'] = $my_url . "gui-modules/HouseCouponList.php";
             return true;
         case "CN":
             $this->ret['main_frame'] = $my_url . "gui-modules/mgrlogin.php";
             return true;
         case "PO":
             $this->ret['main_frame'] = $my_url . "gui-modules/adminlogin.php?class=PriceOverrideAdminLogin";
             return true;
     }
     return false;
 }