<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

class Customer_Itembuy_Cashier_Cardrec
{
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Customer_Itembuy_Cashier_Cardrec", "remise rec");

        $carier_type = isset($_POST["CARIER_TYPE"]);
        $sdbkdata_status = "800";
        if ($carier_type) $sdbkdata_status = "900";

        if (empty($_POST['X-S_TORIHIKI_NO'])) {
            exit;
        }
        $log->debug("Customer_Itembuy_Cashier_Cardrec", "remise rec");
        if ($_POST['X-ERRORLEVEL']!=0) {
            print ("<SDBKDATA>STATUS=". $sdbkdata_status ."</SDBKDATA>");
            exit;
        }
        $log->debug("Customer_Itembuy_Cashier_Cardrec", "remise rec");
        if ($_POST['X-ERRORLEVEL']!=0 && $_POST['X-R_CODE']!='0:0000') {
            print ("<SDBKDATA>STATUS=". $sdbkdata_status ."</SDBKDATA>");
            exit;
        }
        $log->debug("Customer_Itembuy_Cashier_Cardrec", "remise rec");

        $file = $_POST['X-S_TORIHIKI_NO'].".txt";

        $str =  $_POST['X-TRANID'] .','.
                $_POST['X-S_TORIHIKI_NO'].','.
                $_POST['X-AMOUNT'].','.
                $_POST['X-TAX'].','.
                $_POST['X-TOTAL'].','.
                $_POST['X-REFAPPROVED'].','.
                $_POST['X-REFFORWARDED'].','.
                $_POST['X-ERRCODE'].','.
                $_POST['X-ERRLEVEL'].','.
                $_POST['X-R_CODE'].','.
                $_POST['X-PAYQUICKID'].','.
                $_POST['X-PARTOFCARD'].','.
                $_POST['X-EXPIRE'].','.
                $_POST['X-NAME'];

        $fh = fopen(R_REMISE_DIR . $file, "w");
        fwrite($fh, $str);
        fclose($fh);

        print "<SDBKDATA>STATUS=". $sdbkdata_status ."</SDBKDATA>";
        $log->debug("<SDBKDATA>STATUS=". $sdbkdata_status ."</SDBKDATA>", "remise rec");
        exit;
    }
}
?>
