function check($str) { $this->ret = $this->default_json(); if (substr($str, -2) == "SD") { $strl = substr($str, 0, strlen($str) - 2); if (!is_numeric($strl)) { return False; } elseif (CoreLocal::get("tenderTotal") != 0) { $this->ret['output'] = DisplayLib::boxMsg(_("discount not applicable after tender"), '', false, DisplayLib::standardClearButton()); } elseif ($strl > 50) { $this->ret['output'] = DisplayLib::boxMsg(_("discount exceeds maximum"), '', false, DisplayLib::standardClearButton()); } elseif ($strl <= 0) { $this->ret['output'] = DisplayLib::boxMsg(_("discount must be greater than zero"), '', false, DisplayLib::standardClearButton()); } elseif ($strl <= 50 and $strl > 0) { $existingPD = CoreLocal::get("percentDiscount"); $stackablePD = $strl; $equivalentPD = $existingPD + $stackablePD; // sum discounts $this->ret = PrehLib::percentDiscount($equivalentPD, $this->ret); } else { return false; } return true; } return false; }
/** React to missing item @param $upc [string] UPC value @param $json [keyed array] formatted return value @return [keyed array] formatted return value The $json parameter and return value have the same format as Parser since this module interacts with input parsing. */ public function handle($upc, $json) { $opts = array('upc' => $upc, 'description' => 'BADSCAN'); TransRecord::add_log_record($opts); $json['output'] = DisplayLib::boxMsg(_('not a valid item'), _('UPC: ') . $upc, false, DisplayLib::standardClearButton()); return $json; }
function check($str) { $this->ret = $this->default_json(); if (substr($str, -2) == "DA") { $strl = substr($str, 0, strlen($str) - 2); if (substr($str, 0, 2) == "VD") { $this->ret = PrehLib::percentDiscount(0, $this->ret); } elseif (!is_numeric($strl)) { return false; } elseif (CoreLocal::get("tenderTotal") != 0) { $this->ret['output'] = DisplayLib::boxMsg(_("discount not applicable after tender"), '', false, DisplayLib::standardClearButton()); } elseif ($strl > 50) { $this->ret['output'] = DisplayLib::boxMsg(_("discount exceeds maximum"), '', false, DisplayLib::standardClearButton()); } elseif ($strl <= 0) { $this->ret['output'] = DisplayLib::boxMsg(_("discount must be greater than zero"), '', false, DisplayLib::standardClearButton()); } elseif ($strl <= 50 and $strl > 0) { $this->ret = PrehLib::percentDiscount($strl, $this->ret); $this->ret['redraw_footer'] = true; } else { return false; } return true; } return false; }
public function parse($str) { $ret = $this->default_json(); if (CoreLocal::get('memberID') == '0') { $ret['output'] = DisplayLib::boxMsg(_("Apply member number first"), _('No member selected'), false, array_merge(array('Member Search [ID]' => 'parseWrapper(\'ID\');'), DisplayLib::standardClearButton())); return $ret; } if ($str == 'ACCESS') { if (CoreLocal::get('AccessQuickMenu') != '' && class_exists('QuickMenuLauncher')) { $qm = new QuickMenuLauncher(); return $qm->parse('QM' . CoreLocal::get('AccessQuickMenu')); } else { $str = 'ACCESS0'; } } if ($str !== 'ACCESS6' && CoreLocal::get('AccessSelection') === '') { CoreLocal::set('AccessSelection', $str); $ret['main_frame'] = MiscLib::baseURL() . 'gui-modules/adminlogin.php?class=AccessProgramParser'; return $ret; } else { CoreLocal::set('AccessSelection', ''); } $selection = substr($str, 6); TransRecord::addRecord(array('upc' => 'ACCESS', 'description' => 'ACCESS SIGNUP', 'quantity' => 1, 'ItemQtty' => 1, 'numflag' => $selection)); $ret['output'] = DisplayLib::lastpage(); $ret['receipt'] = 'accessSignupSlip'; return $ret; }
function parse($str) { $ret = $this->default_json(); if ($str == "FNTL") { $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/fsTotalConfirm.php'; } elseif ($str == "TETL") { $ret['main_frame'] = MiscLib::base_url() . 'gui-modules/requestInfo.php?class=Totals'; } elseif ($str == "FTTL") { PrehLib::finalttl(); } elseif ($str == "TL") { CoreLocal::set('End', 0); $chk = PrehLib::ttl(); if ($chk !== True) { $ret['main_frame'] = $chk; } } elseif ($str == "MTL") { $chk = PrehLib::omtr_ttl(); if ($chk !== True) { $ret['main_frame'] = $chk; } } elseif ($str == "WICTL") { $ttl = PrehLib::wicableTotal(); $ret['output'] = DisplayLib::boxMsg(_('WIC Total') . sprintf(': $%.2f', $ttl), '', true, DisplayLib::standardClearButton()); // return early since output has been set return $ret; } if (!$ret['main_frame']) { $ret['output'] = DisplayLib::lastpage(); $ret['redraw_footer'] = True; } return $ret; }
public function errorCheck() { if ($this->amount - CoreLocal::get('amtdue') > 0 && CoreLocal::get('amtdue') > 0) { return DisplayLib::boxMsg(_('max tender is ') . CoreLocal::get('amtdue'), _('no change allowed'), false, DisplayLib::standardClearButton()); } return true; }
/** Check for errors @return True or an error message string */ public function errorCheck() { $clearButton = array('OK [clear]' => 'parseWrapper(\'CL\');'); if (CoreLocal::get("isMember") != 0 && $this->amount - CoreLocal::get("amtdue") - 0.005 > CoreLocal::get("dollarOver") && CoreLocal::get("cashOverLimit") == 1) { return DisplayLib::boxMsg(_("member check tender cannot exceed total purchase by over \$") . CoreLocal::get("dollarOver"), '', false, $clearButton); } elseif (CoreLocal::get("store") == "wfc" && CoreLocal::get("isMember") != 0 && $this->amount - CoreLocal::get("amtdue") - 0.005 > 0) { // This should really be a separate tender // module for store-specific behavior $db = Database::pDataConnect(); $q = sprintf("SELECT card_no FROM custReceiptMessage\n WHERE card_no=%d AND modifier_module='WfcEquityMessage'", CoreLocal::get('memberID')); $r = $db->query($q); if ($db->num_rows($r) > 0) { return DisplayLib::xboxMsg(_("member check tender cannot exceed total purchase if equity is owed"), $clearButton); } // multi use if (CoreLocal::get('standalone') == 0) { $chkQ = "select trans_num from dlog \n where trans_type='T' and trans_subtype in ('CA','CK') \n and card_no=" . (int) CoreLocal::get('memberID') . "\n group by trans_num \n having sum(case when trans_subtype='CK' then total else 0 end) < 0 \n and sum(Case when trans_subtype='CA' then total else 0 end) > 0"; $db = Database::mDataConnect(); $chkR = $db->query($chkQ); if ($db->num_rows($chkR) > 0) { return DisplayLib::xboxMsg(_("already used check over benefit today"), $clearButton); } } } elseif (CoreLocal::get("isMember") == 0 && $this->amount - CoreLocal::get("amtdue") - 0.005 > 0) { $msg = _('Non-members may not write checks for more than the total purchase.'); return DisplayLib::xboxMsg($msg, $clearButton); } return true; }
public function handle($upc, $json) { $my_url = MiscLib::base_url(); switch (ltrim($upc, '0')) { case '8006': if (CoreLocal::get("memberID") == 0) { $json['main_frame'] = $my_url . 'gui-modules/memlist.php'; } else { if (CoreLocal::get("msgrepeat") == 0) { CoreLocal::set("boxMsg", "<B>" . $total . " stock payment</B><BR>insert form<BR>press [enter] to endorse<P><FONT size='-1'>[clear] to cancel</FONT>"); $ret["main_frame"] = $my_url . "gui-modules/boxMsg2.php?endorse=stock&endorseAmt=" . $total; } } break; case '8005': if (CoreLocal::get("memberID") == 0) { $json['main_frame'] = $my_url . 'gui-modules/memlist.php'; } elseif (CoreLocal::get("isMember") == 0) { $json['output'] = DisplayLib::boxMsg(_("member discount not applicable"), '', false, DisplayLib::standardClearButton()); } elseif (CoreLocal::get("percentDiscount") > 0) { $json['output'] = DisplayLib::boxMsg(CoreLocal::get("percentDiscount") . "% discount already applied", '', false, DisplayLib::standardClearButton()); } break; } // magic plu, but other conditions not matched if ($json['main_frame'] === false && empty($json['output'])) { $json['output'] = DisplayLib::boxMsg($upc . "<br />is not a valid item", '', false, DisplayLib::standardClearButton()); } return $json; }
function body_content() { $this->input_header('onsubmit="lookupFormCallback();return false;"'); echo '<div class="baseHeight">'; $id = $_REQUEST['id']; $local = false; if (substr($id, 0, 2) == '_l') { $local = true; $id = substr($id, 2); } $mode = $_REQUEST['mode']; $msg = 'Looking up transaction'; if ($mode == 'verify') { $msg = 'Verifying transaction'; } echo DisplayLib::boxMsg($msg . '<br />Please wait', '', true); echo '</div>'; // baseHeight printf('<input type="hidden" id="refNum" value="%s" />', $id); printf('<input type="hidden" id="local" value="%d" />', $local ? 1 : 0); printf('<input type="hidden" id="lookupMode" value="%s" />', $mode); echo "<div id=\"footer\">"; echo DisplayLib::printfooter(); echo "</div>\n"; $this->add_onload_command('performLookup();'); }
function body_content() { $this->input_header(); echo '<div class="baseHeight">'; echo DisplayLib::boxMsg('<b>Hello World!</b><br /> Enter anything to continue'); echo '</div>'; $this->footer(); }
/** Check for errors @return True or an error message string */ public function errorCheck() { global $CORE_LOCAL; $this->conn = CoopCredLib::ccDataConnect(); if ($this->conn === False) { return "Error: ccDataConnect() failed."; } $programOK = CoopCredLib::programOK($this->tender_code, $this->conn); if ($programOK !== True) { return DisplayLib::boxMsg("{$programOK}"); } $subtotals = CoopCredLib::getCCredSubtotals($this->tender_code, $this->conn); if ($subtotals !== True) { return DisplayLib::boxMsg("{$subtotals}"); } $pc = $CORE_LOCAL->get("CCredProgramCode"); //$pc = $CORE_LOCAL->get("programCode"); /* For Refunding the total without entering the exact amount * i.e. with QA alone. */ if ($this->amount == '' && $this->DefaultTotal() < 0) { $this->amount = $this->DefaultTotal(); } /* No Available Balance. */ if ($CORE_LOCAL->get("{$pc}availBal") < 0) { return DisplayLib::boxMsg(_("Member") . " #" . $CORE_LOCAL->get("memberID") . ' ' . _("does not have enough Coop Cred in ") . '<b>' . $CORE_LOCAL->get("{$pc}programName") . '</b>' . _(" to cover this purchase.")); } /* Tender more than Available Balance * the amount remaining less the amount of this type already tendered * in the current transaction. * I think availBal already includes memChargeTotal. */ if (abs($CORE_LOCAL->get("{$pc}memChargeTotal")) + $this->amount >= $CORE_LOCAL->get("{$pc}availBal") + 0.005) { $memChargeCommitted = $CORE_LOCAL->get("{$pc}availBal") + $CORE_LOCAL->get("{$pc}memChargeTotal"); return DisplayLib::xboxMsg(_("The amount of Coop Cred you have in ") . '<b>' . $CORE_LOCAL->get("{$pc}programName") . '</b>' . _(" is only \$") . number_format($memChargeCommitted, 2) . '.'); } /* Tender more than Amount Due. */ if (MiscLib::truncate2($CORE_LOCAL->get("amtdue")) < MiscLib::truncate2($this->amount)) { return DisplayLib::xboxMsg(_("The amount of Coop Cred tendered may not exceed the Amount Due.")); } /* Add the tender to those used in this transaction. */ if ($CORE_LOCAL->get('CCredTendersUsed') == '') { $CORE_LOCAL->set('CCredTendersUsed', array("{$this->tender_code}" => $CORE_LOCAL->get("CCredProgramID"))); } else { $tu = $CORE_LOCAL->get('CCredTendersUsed'); if (!array_key_exists("{$this->tender_code}", $tu)) { $tu["{$this->tender_code}"] = $CORE_LOCAL->get("CCredProgramID"); $CORE_LOCAL->set('CCredTendersUsed', $tu); } } return true; // errorCheck() }
function parse($str) { $ret = $this->default_json(); PrehLib::chargeOk(); $memChargeCommitted = CoreLocal::get("availBal") - CoreLocal::get("memChargeTotal"); $title = _('Member #') . CoreLocal::get('memberID'); $msg = _("Current AR balance is ") . CoreLocal::get("balance") . "<br />" . _("Available AR balance is ") . CoreLocal::get("availBal"); $ret['output'] = DisplayLib::boxMsg($msg, $title, true, array_merge(array('Tender [Store Credit]' => 'parseWrapper(\'MI\');'), DisplayLib::standardClearButton())); return $ret; }
function parse($str) { if (CoreLocal::get("LastID") == 0) { $ret = $this->default_json(); $ret['output'] = DisplayLib::boxMsg(_("no transaction in progress"), '', false, DisplayLib::standardClearButton()); return $ret; } else { return $this->tender_out(""); } }
function parse($str) { $ret = $this->default_json(); if (CoreLocal::get("memberID") == 0) { $ret['output'] = DisplayLib::boxMsg(_("Apply member number first"), _('No member selected'), false, array_merge(array('Member Search [ID]' => 'parseWrapper(\'ID\');'), DisplayLib::standardClearButton())); } else { $plugin_info = new VirtualCoupon(); $ret['main_frame'] = $plugin_info->pluginUrl() . '/VirtCoupDisplay.php'; } return $ret; }
/** Check for errors @return True or an error message string */ public function errorCheck() { if (CoreLocal::get("fntlflag") == 0) { return DisplayLib::boxMsg(_("eligible amount must be totaled before foodstamp tender can be accepted"), '', false, array('Total [FS Total]' => 'parseWrapper(\'FNTL\');$(\'#reginput\').focus();', 'Dimiss [clear]' => 'parseWrapper(\'CL\');')); } elseif ($this->amount !== false && $this->amount > 0 && $this->amount > CoreLocal::get("fsEligible") + 0.005) { return DisplayLib::xboxMsg(_('Foodstamp tender cannot exceed eligible amount'), DisplayLib::standardClearButton()); } elseif ($this->amount !== false && $this->amount <= 0 && $this->amount < CoreLocal::get("fsEligible") - 0.005) { return DisplayLib::xboxMsg(_('Foodstamp return cannot exceed eligible amount' . $info), DisplayLib::standardClearButton()); } return true; }
function parse($str) { global $CORE_LOCAL; $return_value = $this->default_json(); if ($CORE_LOCAL->get("LastID") != "0") { $return_value['output'] = DisplayLib::boxMsg("transaction in progress"); } else { $return_value['main_frame'] = MiscLib::base_url() . 'gui-modules/HelloWorld.php'; } return $return_value; }
private function overlayKeys($number) { $db = Database::pDataConnect(); $my_keys = array(); if ($db->table_exists('QuickLookups')) { $prep = $db->prepare(' SELECT label, action FROM QuickLookups WHERE lookupSet = ? ORDER BY sequence'); $res = $db->execute($prep, array($number)); while ($row = $db->fetch_row($res)) { $my_keys[] = new quickkey($row['label'], $row['action']); } } if (count($my_keys) == 0) { include dirname(__FILE__) . '/quickkeys/keys/' . $number . '.php'; } if (count($my_keys) == 0) { return DisplayLib::boxMsg('Menu not found', '', false, DisplayLib::standardClearButton()); } $clearButton = false; $ret = ''; for ($i = 0; $i < count($my_keys); $i++) { if ($i % 3 == 0) { if ($i != 0) { $ret .= ' </div>'; } $ret .= '<div class="qkRow">'; } $ret .= sprintf(' <div class="qkBox"> <div id="qkDiv%d"> <button type="button" class="quick_button pos-button coloredBorder" onclick="$(\'#reginput\').val($(\'#reginput\').val()+\'%s\');submitWrapper();"> %s </button> </div> </div>', $i, $my_keys[$i]->output_text, $my_keys[$i]->title); } if (!$clearButton) { $ret .= '<div class="qkBox"> <div> <button type="button" class="quick_button pos-button errorColoredArea" onclick="$(\'#reginput\').val(\'CL\');submitWrapper();"> Clear <span class="smaller">[clear]</span> </button> </div> </div>'; } $ret .= '</div>'; return $ret; }
function parse($str) { $ret = $this->default_json(); if ($str == "cdInvalid") { $ret['output'] = DisplayLib::boxMsg(CoreLocal::get("casediscount") . _("% case discount invalid"), '', false, DisplayLib::standardClearButton()); } elseif ($str == "cdStaffNA") { $ret['output'] = DisplayLib::boxMsg(_("case discount not applicable to staff"), '', false, DisplayLib::standardClearButton()); } elseif ($str == "cdSSINA") { $ret['output'] = DisplayLib::boxMsg(_("hit 10% key to apply case discount for member") . " " . CoreLocal::get("memberID"), '', false, DisplayLib::standardClearButton()); } return $ret; }
/** Check for errors @return True or an error message string */ public function errorCheck() { $clearButton = array('OK [clear]' => 'parseWrapper(\'CL\');'); if (CoreLocal::get("isMember") != 0 && $this->amount - CoreLocal::get("amtdue") - 0.005 > CoreLocal::get("dollarOver") && CoreLocal::get("cashOverLimit") == 1) { return DisplayLib::boxMsg(_("member check tender cannot exceed total purchase by over \$") . CoreLocal::get("dollarOver"), '', false, $clearButton); } else { if (CoreLocal::get("isMember") == 0 && $this->amount - CoreLocal::get("amtdue") - 0.005 > 0) { return DisplayLib::xboxMsg(_('non-member check tender cannot exceed total purchase'), $clearButton); } } return true; }
function parse($str) { $ret = $this->default_json(); $query = "select upc,description,VolSpecial,quantity,\n total,discount,memDiscount,discountable,\n unitPrice,scale,foodstamp,voided,discounttype,\n trans_type,trans_status,department,regPrice,\n tax,volume,volDiscType\n from localtemptrans where \n trans_id = " . CoreLocal::get("currentid"); $connection = Database::tDataConnect(); $result = $connection->query($query); $num_rows = $connection->num_rows($result); if ($num_rows > 0) { $row = $connection->fetch_array($result); $strUPC = $row["upc"]; $strDescription = $row["description"]; $dblVolSpecial = $row["VolSpecial"]; $dblquantity = -0.5 * $row["quantity"]; $dblTotal = MiscLib::truncate2(-1 * 0.5 * $row["total"]); // invoked truncate2 rounding function to fix half-penny errors apbw 3/7/05 $strCardNo = CoreLocal::get("memberID"); $dblDiscount = $row["discount"]; $dblmemDiscount = $row["memDiscount"]; $intDiscountable = $row["discountable"]; $dblUnitPrice = $row["unitPrice"]; $intScale = MiscLib::nullwrap($row["scale"]); if ($row["foodstamp"] != 0) { $intFoodStamp = 1; } else { $intFoodStamp = 0; } $intdiscounttype = MiscLib::nullwrap($row["discounttype"]); if ($row["voided"] == 20) { $ret['output'] = DisplayLib::boxMsg(_("Discount already taken"), '', false, DisplayLib::standardClearButton()); } elseif ($row["trans_type"] == "T" or $row["trans_status"] == "D" or $row["trans_status"] == "V" or $row["trans_status"] == "C") { $ret['output'] = DisplayLib::boxMsg(_("Item cannot be discounted"), '', false, DisplayLib::standardClearButton()); } elseif (strncasecmp($strDescription, "Club Card", 9) == 0) { //----- edited by abpw 2/15/05 ----- $ret['output'] = DisplayLib::boxMsg(_("Item cannot be discounted"), '', false, DisplayLib::standardClearButton()); } elseif (CoreLocal::get("tenderTotal") < 0 and $intFoodStamp == 1 and -1 * $dblTotal > CoreLocal::get("fsEligible")) { $ret['output'] = DisplayLib::boxMsg(_("Item already paid for"), '', false, DisplayLib::standardClearButton()); } elseif (CoreLocal::get("tenderTotal") < 0 and -1 * $dblTotal > CoreLocal::get("runningTotal") - CoreLocal::get("taxTotal")) { $ret['output'] = DisplayLib::boxMsg(_("Item already paid for"), '', false, DisplayLib::standardClearButton()); } else { // --- added partial item desc to club card description - apbw 2/15/05 --- TransRecord::addRecord(array('upc' => $strUPC, 'description' => "Club Card: " . substr($strDescription, 0, 19), 'trans_type' => "I", 'trans_status' => "J", 'department' => $row["department"], 'quantity' => $dblquantity, 'unitPrice' => $dblUnitPrice, 'total' => $dblTotal, 'regPrice' => 0.5 * $row["regPrice"], 'scale' => $intScale, 'tax' => $row["tax"], 'foodstamp' => $intFoodStamp, 'discount' => $dblDiscount, 'memDiscount' => $dblmemDiscount, 'discountable' => $intDiscountable, 'discounttype' => $intdiscounttype, 'ItemQtty' => $dblquantity, 'volDiscType' => $row["volDiscType"], 'volume' => $row["volume"], 'VolSpecial' => $dblVolSpecial)); $update = "update localtemptrans set voided = 20 where trans_id = " . CoreLocal::get("currentid"); $connection = Database::tDataConnect(); $connection->query($update); CoreLocal::set("TTLflag", 0); CoreLocal::set("TTLRequested", 0); $ret['output'] = DisplayLib::lastpage(); } } return $ret; }
public function handle($upc, $json) { $db = Database::pDataConnect(); $query = "select card_no from memberCards where upc='{$upc}'"; $result = $db->query($query); if ($db->num_rows($result) < 1) { $json['output'] = DisplayLib::boxMsg(_("Card not assigned"), '', false, DisplayLib::standardClearButton()); return $json; } $row = $db->fetch_array($result); CoreLocal::set("memberCardUsed", 1); $json = PrehLib::memberID($row[0]); return $json; }
public function parse($str) { $multiplier = strlen($str) > 1 ? substr($str, 1) : 1; $peek = PrehLib::peekItem(true, CoreLocal::get('currentid')); $fp = fopen('/tmp/peek', 'a'); if ($peek && $peek['trans_type'] == 'I' && $peek['trans_status'] == '') { $upcP = new UPC(); CoreLocal::set('quantity', $multiplier); CoreLocal::set('multiple', 1); $ret = $upcP->parse($peek['upc']); return $ret; } else { $json = $this->default_json(); $json['output'] = DisplayLib::boxMsg(_('product cannot be repeated'), _('Ineligible line'), false, DisplayLib::standardClearButton()); return $json; } }
function parse($str) { $ret = $this->default_json(); $left = substr($str, 0, strlen($str) - 2); if ($left == "") { $left = 1; } if (strlen($left) > 4) { $ret['output'] = DisplayLib::boxMsg(MiscLib::truncate2($left / 100) . _(" tare not supported"), _('Invalid Tare'), false, DisplayLib::standardClearButton()); } elseif ($left / 100 > CoreLocal::get("weight") && CoreLocal::get("weight") > 0) { $ret['output'] = DisplayLib::boxMsg(_("Tare cannot be") . "<br />" . _("greater than item weight"), _('Excess Tare'), false, DisplayLib::standardClearButton()); } else { TransRecord::addTare($left); $ret['output'] = DisplayLib::lastpage(); } return $ret; }
function parse($str) { $ret = $this->default_json(); // Sets $balance and $availBal. $chargeOk = PrehLib::chargeOk(); // $memChargeCommitted isn't used here. $memChargeCommitted = CoreLocal::get("availBal") - CoreLocal::get("memChargeTotal"); $message = "<p style='font-weight:bold; text-align:center; margin: 0em 0em 0em -1.0em;'>" . _("Member") . " #" . CoreLocal::get("memberID") . "<br />"; if ($chargeOk) { $message .= _("Available Coop Cred") . "<br />" . _("Balance is:") . "<br />" . "<span style='font-size:1.4em;'>" . " " . CoreLocal::get("availBal") . "</span>"; } else { $message .= _("Is not authorized to use") . "<br />" . _("Coop Cred"); } $message .= "</p>"; $ret['output'] = DisplayLib::boxMsg("{$message}", "", True); return $ret; }
public function parse($str) { $year = '20' . substr($str, 2, 2); $month = substr($str, 4, 2); $couponID = substr($str, -3); $expireTS = mktime(0, 0, 0, $month, 1, $year); $expireTS = strtotime(date('Y-m-t', $expireTS)); $ret = $this->default_json(); if (time() > $expireTS) { $ret['output'] = DisplayLib::boxMsg('Coupon is expired'); return $ret; } else { $upc = '004' . '99999' . str_pad($couponID, 5, '0', STR_PAD_LEFT); $hc = new HouseCoupon(); return $hc->handle($upc, $ret); } }
function parse($str) { $ret = $this->default_json(); if (CoreLocal::get('isMember') !== 1) { $ret['output'] = DisplayLib::boxMsg(_("Apply member number first"), _('No member selected'), false, array_merge(array('Member Search [ID]' => 'parseWrapper(\'ID\');'), DisplayLib::standardClearButton())); return $ret; } elseif (CoreLocal::get('NeedDiscountFlag') == 1) { $ret['output'] = DisplayLib::boxMsg(_("discount already applied"), '', false, DisplayLib::standardClearButton()); return $ret; } else { CoreLocal::set('NeedDiscountFlag', 1); $NBDisc = CoreLocal::get('needBasedPercent') * 100; DiscountModule::updateDiscount(new DiscountModule($NBDisc, 'NeedBasedDiscount')); $ret['output'] = DisplayLib::lastpage(); $ret['redraw_footer'] = true; return $ret; } }
/** Check for errors @return True or an error message string */ public function errorCheck() { $charge_ok = PrehLib::chargeOk(); $buttons = array('[clear]' => 'parseWrapper(\'CL\');'); if ($charge_ok == 0) { return DisplayLib::boxMsg(_("member") . ' ' . CoreLocal::get("memberID") . '<br />' . _("is not authorized") . '<br />' . _("to make charges"), 'Not Allowed', false, $buttons); } else { if (CoreLocal::get("availBal") < 0) { return DisplayLib::boxMsg(_("member") . ' ' . CoreLocal::get("memberID") . '<br />' . _("is over limit"), 'Over Limit', false, $buttons); } elseif (abs(CoreLocal::get("memChargeTotal")) + $this->amount >= CoreLocal::get("availBal") + 0.005) { $memChargeRemain = CoreLocal::get("availBal"); $memChargeCommitted = $memChargeRemain + CoreLocal::get("memChargeTotal"); return DisplayLib::xboxMsg(_("available balance for charge") . '<br />' . _("is only \$") . $memChargeCommitted, $buttons); } elseif (MiscLib::truncate2(CoreLocal::get("amtdue")) < MiscLib::truncate2($this->amount)) { return DisplayLib::xboxMsg(_("charge tender exceeds purchase amount"), $buttons); } } return true; }
function body_content() { $amt = CoreLocal::get("old_ar_balance"); $this->input_header(); ?> <div class="baseHeight"> <?php if ($amt == CoreLocal::get("balance")) { echo DisplayLib::boxMsg(sprintf("Old A/R Balance: \$%.2f<br />\n [Enter] to pay balance now<br />\n [Clear] to leave balance", $amt)); } else { echo DisplayLib::boxMsg(sprintf("Old A/R Balance: \$%.2f<br />\n Total A/R Balance: \$%.2f<br />\n [Enter] to pay old balance<br />\n [Balance] to pay the entire balance<br />\n [Clear] to leave the balance", $amt, CoreLocal::get("balance"))); } echo "</div>"; echo "<div id=\"footer\">"; echo DisplayLib::printfooter(); echo "</div>"; CoreLocal::set("msgrepeat", 2); }
function parse($str) { $ret = $this->default_json(); // this is the currently selected item $transID = CoreLocal::get("currentid"); $row = PrehLib::peekItem(true, $transID); if ($row === false) { // this shouldn't happen unless there's some weird session problem $ret['output'] = DisplayLib::boxMsg(_("Item not found"), '', false, DisplayLib::standardClearButton()); } else { if ($row['trans_type'] != 'I' && $row['trans_type'] != 'D') { // only items & open rings are discountable $ret['output'] = DisplayLib::boxMsg(_("Line is not discountable"), '', false, DisplayLib::standardClearButton()); } elseif ($row['discounttype'] != 0) { // for simplicity, sale items cannot be discounted // this also prevents using this function more than // once on a single item $ret['output'] = DisplayLib::boxMsg(_("Item already discounted"), '', false, DisplayLib::standardClearButton()); } else { // discount is simply the total times the // non-member discount percentage // total is discounted immediately using // the non-member percentage // memDiscount is the difference between total // member discount and the non-member discount // since the non-member discount is applied // immediately // setting discounttype=2 makes the member discount // apply when a [valid] member number is entered $discQ = sprintf("UPDATE localtemptrans SET\n discount=(regPrice * quantity * %f), \n total=(total-(regPrice*quantity*%f)),\n memDiscount=((regPrice*quantity*%f) - (regPrice*quantity*%f)),\n discounttype=2\n WHERE trans_id=%d", CoreLocal::get("LineItemDiscountNonMem"), CoreLocal::get("LineItemDiscountNonMem"), CoreLocal::get("LineItemDiscountMem"), CoreLocal::get("LineItemDiscountNonMem"), $transID); $dbc = Database::tDataConnect(); $discR = $dbc->query($discQ); // add notification line for nonMem discount TransRecord::adddiscount($row['regPrice'] * $row['quantity'] * CoreLocal::get("LineItemDiscountNonMem"), $row['department']); // footer should be redrawn since savings and totals // have changed. Output is the list of items $ret['redraw_footer'] = true; $ret['output'] = DisplayLib::lastpage(); } } return $ret; }
function parse($str) { global $CORE_LOCAL; $ret = $this->default_json(); $pStyle = "<p style='font-weight:bold; text-align:center; margin: 0em 0em 0em -1.0em;'>"; if (!in_array('CoopCred', $CORE_LOCAL->get('PluginList'))) { $message = "{$pStyle}" . _("Coop Cred is not currently in use at this co-op.") . "</p>"; $ret['output'] = DisplayLib::boxMsg("{$message}", "", True); return $ret; } $conn = CoopCredLib::ccDataConnect(); if ($conn === False) { return "Error: ccDataConnect() failed."; } $ccQ = "SELECT p.programID AS ppID, p.programName, p.tenderType,\n p.active, p.startDate, p.endDate,\n p.bankID, p.creditOK, p.inputOK, p.transferOK,\n m.creditBalance, m.creditLimit, m.creditOK, m.inputOK,\n m.transferOK, m.isBank\n ,(m.creditLimit - m.creditBalance) as availCreditBalance\n ,c.FirstNAme, c.LastName\n FROM CCredMemberships m\n JOIN CCredPrograms p\n ON p.programID = m.programID\n JOIN {$CORE_LOCAL->get('pDatabase')}.custdata c\n ON m.cardNo = c.CardNo\n WHERE m.cardNo =" . $CORE_LOCAL->get("memberID") . " AND c.personNum=1 " . "ORDER BY ppID"; $ccS = $conn->prepare_statement("{$ccQ}"); if ($ccS === False) { $ret['output'] = DisplayLib::boxMsg("<p>Prep Failed: {$ccQ}</p>", "", True); return $ret; } $args = array(); $ccR = $conn->exec_statement($ccS, $args); if ($ccR === False) { $ret['output'] = DisplayLib::boxMsg("<p>Query Failed: {$ccQ}</p>", "", True); return $ret; } if ($conn->num_rows($ccR) == 0) { $message = "{$pStyle}Member " . $CORE_LOCAL->get("memberID") . _(" is not registered for any Coop Cred Programs.") . "</p>"; $ret['output'] = DisplayLib::boxMsg("{$message}", "", True); return $ret; } $pStyle2 = "style='" . "font-weight:bold; " . "text-align:center; " . "margin: 0em 0em 0em -1.0em; " . "'"; $message = "<p {$pStyle2}>"; $message .= _("Member") . " #" . $CORE_LOCAL->get("memberID"); $message .= "<br />" . _("Can spend these amounts of Coop Cred:"); $message .= "</p>"; $bStyle3 = "style='" . "margin: 0.25em 0em 0em -3.0em; " . "'"; $message .= "<div {$bStyle3}>"; $tableStyle1 = "style='" . "width: 16em; " . "'"; $rowStyle = "style='vertical-align:top;' "; $keyStyle = "style='font-size:0.8em;' "; $nameStyle = "style='font-size:0.8em;' "; $narrowAmountStyle = "style='text-align:right; font-size:1.2em;' "; $wideAmountStyle = "style='text-align:right; font-size:1.1em;' "; $notOkStyle = "style='font-size:0.8em;' "; $noteStyle = "style='font-size:0.7em;' "; $message .= "<table {$tableStyle1} cellpadding=2 cellspacing=0 border=0>"; while ($row = $conn->fetch_array($ccR)) { $programOK = CoopCredLib::programOK($row['tenderType'], $conn); if ($programOK === True) { $programCode = 'CCred' . $CORE_LOCAL->get("CCredProgramID"); $subtotals = CoopCredLib::getCCredSubtotals($row['tenderType'], $conn); $tenderKeyCap = $CORE_LOCAL->get("{$programCode}tenderKeyCap") != "" ? $CORE_LOCAL->get("{$programCode}tenderKeyCap") : 'CCr' . $CORE_LOCAL->get("CCredProgramID"); $programBalance = $CORE_LOCAL->get("{$programCode}availBal") ? $CORE_LOCAL->get("{$programCode}availBal") : $CORE_LOCAL->get("{$programCode}availCreditBalance"); $programBalanceString = sprintf("\$%s", number_format($programBalance, 2)); $amountStyle = strlen($programBalanceString) <= 9 ? $narrowAmountStyle : $wideAmountStyle; $message .= sprintf("%s%s%s%s%s%s%s", "<tr {$rowStyle}><td {$keyStyle}>", "[{$tenderKeyCap}]", "</td><td {$nameStyle}>", $CORE_LOCAL->get("{$programCode}programName"), "</td><td {$amountStyle}>", $programBalanceString, "</td></tr>"); } else { $message .= "<tr><td colspan=99 {$notOkStyle}>" . $programOK . "</td></tr>"; } } $note = _("The amounts reflect any tenders of, or inputs to, " . "Coop Cred in the current transaction."); $message .= "<tr><td colspan=99 {$noteStyle}>" . $note . "</td></tr>"; /* Want: self, mode=Print */ $printButton = "<button type='submit' value='" . $CORE_LOCAL->get('memberID') . "' onClick='' " . " title='Not implemented yet' " . ">" . "Print" . "</button>"; $message .= "<tr><td colspan=99 >" . $printButton . "</td></tr>"; $message .= "</table>"; $message .= "</div>"; $ret['output'] = DisplayLib::boxMsg("{$message}", "", True); return $ret; }