Example #1
0
 function preprocess()
 {
     if (isset($_REQUEST['doLookup'])) {
         $ref = $_REQUEST['id'];
         $local = $_REQUEST['local'];
         $mode = $_REQUEST['mode'];
         $obj = null;
         $resp = array();
         foreach (CoreLocal::get('RegisteredPaycardClasses') as $rpc) {
             $obj = new $rpc();
             if ($obj->myRefNum($ref)) {
                 break;
             } else {
                 $obj = null;
             }
         }
         if ($obj === null) {
             $resp['output'] = DisplayLib::boxMsg('Invalid Transaction ID' . '<br />Local System Error', '', true);
             $resp['confirm_dest'] = MiscLib::base_url() . 'gui-modules/pos2.php';
             $resp['cancel_dest'] = MiscLib::base_url() . 'gui-modules/pos2.php';
         } else {
             if ($local == 0 && $mode == 'verify') {
                 $resp['output'] = DisplayLib::boxMsg('Cannot Verify - Already Complete' . '<br />Local System Error', '', true);
                 $resp['confirm_dest'] = MiscLib::base_url() . 'gui-modules/pos2.php';
                 $resp['cancel_dest'] = MiscLib::base_url() . 'gui-modules/pos2.php';
             } else {
                 $resp = $obj->lookupTransaction($ref, $local, $mode);
             }
         }
         echo JsonLib::array_to_json($resp);
         return false;
     }
     return true;
 }
Example #2
0
 function ReadFromScale()
 {
     $rel = MiscLib::base_url();
     $input = "";
     $readdir = $rel . 'scale-drivers/drivers/NewMagellan/cc-output';
     $dh = opendir($readdir);
     while (false !== ($fn = readdir($dh))) {
         if (is_dir($readdir . "/" . $fn)) {
             continue;
         }
         $data = file_get_contents($readdir . "/" . $fn);
         unlink($readdir . "/" . $fn);
         $line = rtrim($data, "\r\n");
         if (empty($line)) {
             continue;
         }
         $input = $line;
         break;
     }
     $output = array();
     if (!empty($input)) {
         $output['scans'] = $input;
     }
     if (!empty($output)) {
         echo JsonLib::array_to_json($output);
     } else {
         echo "{}";
     }
 }
Example #3
0
 function preprocess()
 {
     if (FormLib::get('input') !== '') {
         $arr = $this->mgrauthenticate(FormLib::get('input'));
         echo JsonLib::array_to_json($arr);
         return False;
     } else {
         // beep on initial page load
         if (CoreLocal::get('LoudLogins') == 1) {
             UdpComm::udpSend('twoPairs');
         }
     }
     return True;
 }
Example #4
0
 public static function run()
 {
     $callback_class = get_called_class();
     if (basename($_SERVER['PHP_SELF']) === $callback_class . '.php') {
         ini_set('display_errors', 'off');
         $obj = new $callback_class();
         $output = $obj->ajax();
         switch ($obj->getEncoding()) {
             case 'json':
                 echo JsonLib::array_to_json($output);
                 break;
             case 'plain':
             default:
                 echo $output;
                 break;
         }
     }
 }
Example #5
0
  - ddd  => shrink items
  - none => don't print a receipt, just flush localtemptrans

  Note: none is currently only used by the RRR parser which
  could probably be refactored into a plugin providing its
  own receipt type implementation via a ReceiptMessage
*/
$transFinished = false;
if ($receiptType == 'full' || $receiptType == 'cancelled' || $receiptType == 'suspended' || $receiptType == 'none' || $receiptType == 'ddd') {
    $transFinished = true;
}
if (!preg_match('/^\\d+-\\d+-\\d+$/', $receiptNum)) {
    $receiptNum = ReceiptLib::mostRecentReceipt();
}
$yesSync = JsonLib::array_to_json(array('sync' => true));
$noSync = JsonLib::array_to_json(array('sync' => false));
$output = $noSync;
ob_start();
if (strlen($receiptType) > 0) {
    register_shutdown_function(array('ReceiptLib', 'shutdownFunction'));
    $receiptContent = array();
    if ($transFinished) {
        $kicker_class = CoreLocal::get("kickerModule") == "" ? 'Kicker' : CoreLocal::get('kickerModule');
        $kicker_object = new $kicker_class();
        if (!is_object($kicker_object)) {
            $kicker_object = new Kicker();
        }
        $dokick = $kicker_object->doKick($receiptNum);
    }
    $print_class = CoreLocal::get('ReceiptDriver');
    if ($print_class === '' || !class_exists($print_class)) {
Example #6
0
 /**
   Read the settings from ini.php and return
   an equivalent JSON string
 */
 public static function convertIniPhpToJson()
 {
     $php = dirname(__FILE__) . '/../../ini.php';
     $php = self::readIniPhp();
     $json = array();
     foreach ($php as $key => $val) {
         $json[$key] = $val;
     }
     return JsonLib::prettyJSON(json_encode($json));
 }
Example #7
0
 /**
   Remove a value from ini.json
   Called by confRemove() if ini.json exists.
   Should not be called directly.
   @param $key string key
   @return boolean success
 */
 private static function jsonConfRemove($key)
 {
     $ini_json = dirname(__FILE__) . '/../ini.json';
     if (!is_writable($ini_json)) {
         return false;
     }
     $json = json_decode(file_get_contents($ini_json), true);
     if (!is_array($json)) {
         return false;
     }
     unset($json[$key]);
     $saved = file_put_contents($ini_json, JsonLib::prettyJSON(json_encode($json)));
     return $saved === false ? false : true;
 }
Example #8
0
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    in the file license.txt along with IT CORE; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*********************************************************************************/
ini_set('display_errors', 'Off');
include_once dirname(__FILE__) . '/../lib/AutoLoader.php';
$decision = isset($_REQUEST['input']) ? strtoupper(trim($_REQUEST["input"])) : 'CL';
$ret = array('dest_page' => MiscLib::base_url() . 'gui-modules/pos2.php', 'endorse' => False, 'cleared' => False);
$repeat_cmd = CoreLocal::get('strEntered');
if (isset($_REQUEST['cmd']) && !empty($_REQUEST['cmd'])) {
    $repeat_cmd = $_REQUEST['cmd'];
}
if ($decision == "CL") {
    CoreLocal::set("msgrepeat", 0);
    CoreLocal::set("lastRepeat", '');
    CoreLocal::set("toggletax", 0);
    CoreLocal::set("togglefoodstamp", 0);
    CoreLocal::set("RepeatAgain", false);
    $ret['cleared'] = true;
} elseif (strlen($decision) > 0) {
    CoreLocal::set("msgrepeat", 1);
    CoreLocal::set("strRemembered", $repeat_cmd);
} else {
    CoreLocal::set("msgrepeat", 1);
    CoreLocal::set("strRemembered", $repeat_cmd);
}
echo JsonLib::array_to_json($ret);
Example #9
0
foreach (CoreLocal::get("RegisteredPaycardClasses") as $rpc) {
    $myObj = new $rpc();
    if ($myObj->handlesType(CoreLocal::get("paycard_type"))) {
        break;
    }
}
$result = $myObj->doSend(CoreLocal::get("paycard_mode"));
if ($result === PaycardLib::PAYCARD_ERR_OK) {
    PaycardLib::paycard_wipe_pan();
    $json = $myObj->cleanup($json);
    CoreLocal::set("strRemembered", "");
    CoreLocal::set("msgrepeat", 0);
} else {
    if ($result === PaycardLib::PAYCARD_ERR_NSF_RETRY) {
        // card shows balance < requested amount
        // try again with lesser amount
        $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/paycardboxMsgAuth.php';
    } else {
        if ($result === PaycardLib::PAYCARD_ERR_TRY_VERIFY) {
            // communication error. query processor about
            // transaction status.
            $json['main_frame'] = $plugin_info->pluginUrl() . '/gui/PaycardTransLookupPage.php?mode=verify&id=_l' . $myObj->last_ref_num;
        } else {
            PaycardLib::paycard_reset();
            CoreLocal::set("msgrepeat", 0);
            $json['main_frame'] = MiscLib::base_url() . 'gui-modules/boxMsg2.php';
        }
    }
}
echo JsonLib::array_to_json($json);
Example #10
0
 function ReadFromScale()
 {
     $rel = MiscLib::base_url();
     $readfile = $rel . 'scale-drivers/drivers/NewMagellan/scanner-scale';
     $readdir = $rel . 'scale-drivers/drivers/NewMagellan/ss-output';
     $scale_display = "";
     $scans = array();
     /*
     if (file_exists($readfile.".data") && !file_exists($readfile.".lock")){
     
         $fp = fopen($readfile.".lock","w");
         fclose($fp);
     
         $data = file_get_contents($readfile.".data");
     
         unlink($readfile.".data");
         unlink($readfile.".lock");
     
         foreach(explode("\n",$data) as $line){
             $line = rtrim($line,"\r"); // in case OS adds it
             if (empty($line)) continue;
             if ($line[0] == 'S'){
                 $scale_display = scaledisplaymsg($line);
             }
             else {
                 $scans[] = $line;
             }
         }
     }
     */
     $files = scandir($readdir);
     foreach ($files as $fn) {
         if (is_dir($readdir . "/" . $fn)) {
             continue;
         }
         $data = file_get_contents($readdir . "/" . $fn);
         unlink($readdir . "/" . $fn);
         $line = rtrim($data, "\r\n");
         if (empty($line)) {
             continue;
         }
         if ($line[0] == 'S') {
             $scale_display = DisplayLib::scaledisplaymsg($line);
             if (is_array($scale_display)) {
                 if (isset($scale_display['upc'])) {
                     $scans[] = $scale_display['upc'];
                 }
                 $scale_display = $scale_display['display'];
             }
         } else {
             $scans[] = $line;
         }
         break;
     }
     $output = array();
     if (!empty($scale_display)) {
         $output['scale'] = $scale_display;
     }
     if (!empty($scans)) {
         $output['scans'] = ltrim($scans[0], '0');
     }
     if (!empty($output)) {
         echo JsonLib::array_to_json($output);
     } else {
         echo "{}";
     }
 }
Example #11
0
 function ReadFromScale()
 {
     $rel = MiscLib::base_url();
     $scale_data = file_get_contents($rel . 'scale-drivers/drivers/rs232/scale');
     $fp = fopen($rel . 'scale-drivers/drivers/rs232/scale', 'w');
     fclose($fp);
     $scan_data = file_get_contents($rel . 'scale-drivers/drivers/rs232/scanner');
     $fp = fopen($rel . 'scale-drivers/drivers/rs232/scanner', 'w');
     fclose($fp);
     $scale_display = '';
     $scans = array();
     if ($scale_data !== False && !empty($scale_data)) {
         $scale_display = DisplayLib::scaledisplaymsg($scale_data);
         if (is_array($scale_display)) {
             if (isset($scale_display['upc'])) {
                 $scans[] = $scale_display['upc'];
             }
             $scale_display = $scale_display['display'];
         }
     }
     if ($scan_data !== False && !empty($scan_data)) {
         $scans[] = $scan_data;
     }
     $output = array();
     if (!empty($scale_display)) {
         $output['scale'] = $scale_display;
     }
     if (!empty($scans)) {
         $output['scans'] = ltrim($scans[0], '0');
     }
     if (!empty($output)) {
         echo JsonLib::array_to_json($output);
     } else {
         echo "{}";
     }
 }
Example #12
0
 public function testJsonLib()
 {
     $test = array(0 => array(1, 2, 3), 1 => 'test string', 2 => 5, 3 => '0006', 4 => 9.699999999999999, 5 => True, 6 => "bad\\char\tacters");
     $json = JsonLib::array_to_json($test);
     $good = "[[1,2,3],\"test string\",5,6,9.7,true,\"bad\\\\char\\tacters\"]";
     $this->assertInternalType('string', $json);
     $this->assertEquals($good, $json);
 }