예제 #1
0
파일: Jahanpay.php 프로젝트: aliazizi/CShop
 public function callbackGateway()
 {
     $au = $_GET['au'];
     $ref_id = $_GET['order_id'];
     if (strlen($au) > 4) {
         $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?'));
         $payment->execute(array($au));
         $payment = $payment->fetch();
         $merchantID = $this->merchant;
         $amount = round($payment['amount'] / 10);
         $client = new nusoap_client('http://jahanpay.com/webservice?wsdl', 'wsdl');
         $res = $client->call("verification", array($merchantID, $amount, $au));
         if ($payment['status'] == Application::STATUS_PENDING) {
             if (!empty($res) and $res == 1) {
                 return $payment;
             } else {
                 $message = 'پرداخت توسط جهان پی انجام نشده است .';
             }
         } else {
             $message = 'سفارش قبلا پرداخت شده است.';
         }
     } else {
         $message = 'شماره یکتا اشتباه است.';
     }
     throw new Exception($message);
 }
예제 #2
0
파일: Sibapal.php 프로젝트: aliazizi/CShop
 public function callbackGateway()
 {
     $merchantID = $this->merchantID;
     $au = preg_replace('/[^a-z0-9]/', '', $_GET['au']);
     $ref_id = $_GET['order_id'];
     if (strlen($au) > 4) {
         $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('id = ?'));
         $payment->execute(array($au));
         $payment = $payment->fetch();
         $amount = round($payment['amount'] / 10);
         $client = new nusoap_client('https://www.sibapal.com/payment/wsdl?wsdl', 'wsdl');
         $res = $client->call("verify", array($merchantID, $amount, $au));
         if ($payment['status'] == Application::STATUS_PENDING) {
             if (!empty($res) and $res == 1) {
                 return $payment;
             } else {
                 $message = 'پرداخت توسط سیباپال انجام نشده است .';
             }
         } else {
             $message = 'سفارش قبلا پرداخت شده است.';
         }
     } else {
         $message = 'شماره یکتا اشتباه است.';
     }
     throw new Exception($message);
 }
예제 #3
0
파일: Parspal.php 프로젝트: aliazizi/CShop
 public function callbackGateway()
 {
     global $db, $get;
     $Status = $_POST['status'];
     $Refnumber = $_POST['refnumber'];
     $Resnumber = $_POST['resnumber'];
     if ($Status == 100) {
         $ParspalPin = trim($this->merchant);
         $pass = $this->pass;
         $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?'));
         $payment->execute(array($Resnumber));
         $payment = $payment->fetch();
         $amount = round($payment['amount'] / 10);
         $soapclient = new nusoap_client('http://merchant.parspal.com/WebService.asmx?wsdl', 'wsdl');
         $params = array('MerchantID' => $ParspalPin, 'Password' => $pass, 'Price' => $amount, 'RefNum' => $Refnumber);
         $res = $soapclient->call('verifyPayment', $params);
         $Status = $res['verifyPaymentResult']['ResultStatus'];
         if (strtolower($Status) == 'success') {
             return $payment;
         } else {
             $message = 'پرداخت ناموفق است. خطا';
         }
     } else {
         $message = 'پرداخت ناموفق است. خطا';
     }
     throw new Exception($message);
 }
예제 #4
0
 public function callbackGateway()
 {
     $result = $_POST['Result'];
     $requestId = $_POST['RequestId'];
     $followCode = $_POST['FollowCode'];
     $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?'));
     $payment->execute(array($requestId));
     $amount = round($payment['amout']);
     if ($payment['status'] == Application::STATUS_PENDING) {
         if ($result == 0) {
             if ($_POST[Amount] != $payment['amout']) {
                 $message = 'در اطلاعات پرداختي مغايرت وجود دارد';
             } else {
                 $backResult = file("http://www.sharjiran.net/asan_pardakht/CheckPay2.php?FollowCode={$followCode}&RequestId={$requestId}");
                 if ($backResult[0] == 0 && (int) $backResult[1] == (int) $payment['amout'] && $backResult[2] == trim($this->AccountNumber)) {
                     return $payment;
                 } else {
                     $message = 'تراكنش موفقيت آميز نبود';
                 }
             }
         } else {
             if ($result == -1) {
                 $message = 'در اتصال به درگاه بانك مشكلي پيش آمده يا اينكه اطلاعات پرداختي شما نامعتبر بوده است. ';
             }
         }
     } else {
         $message = 'سفارش قبلا پرداخت شده است.';
     }
     throw new Exception($message);
 }
예제 #5
0
 public static function loadPlugin($id)
 {
     $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select('*')->from('plugin')->leftJoin('option')->on('category = `class`')->where('plugin.id = ?'));
     $sql->execute(array($id));
     $sql = $sql->fetchAll();
     $class = $sql[0]['class'];
     return new $class($sql[0]['id'], $sql);
 }
예제 #6
0
파일: SendMail.php 프로젝트: aliazizi/CShop
 public static function getParameters()
 {
     $inputs = CShop::app()->getDb()->query(QueryBuilder::getInstance()->select()->from('input')->order('`order`'))->fetchAll();
     $range = array();
     foreach ($inputs as $input) {
         $range[$input['id']] = $input['name'];
     }
     return array('input' => array('name' => 'فیلد ورودی', 'type' => 'select', 'range' => $range), 'from' => array('name' => 'ایمیل فرستنده'), 'fromname' => array('name' => 'نام فرستنده'), 'subject' => array('name' => 'موضوع ایمیل'), 'signature' => array('name' => 'امضا', 'type' => 'textarea'), 'smtpauth' => array('name' => 'ارسال با SMTP', 'type' => 'select', 'range' => array(0 => 'غیر فعال', 1 => 'فعال')), 'smtpusername' => array('name' => 'نام کاربری SMTP'), 'smtppassword' => array('name' => 'کلمه عبور SMTP', 'type' => 'password'), 'smtphost' => array('name' => 'سرور SMTP'), 'smtpport' => array('name' => 'پورت SMTP'), 'smtpsecure' => array('name' => 'امنیت SMTP'));
 }
예제 #7
0
파일: IBSng.php 프로젝트: aliazizi/CShop
 public function updateUser(&$payment, &$items)
 {
     $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select('field.name,item.id')->from('item')->leftJoin('product')->on('product.id = item.productid')->leftJoin('field')->on('field.productid = product.id')->where('paymentid = ? AND type="ibsnggroup"'));
     $sql->execute(array($payment['id']));
     $sql = $sql->fetch();
     $group = $sql['name'];
     $ibs = new IBSngHelper($this->username, $this->password, $this->server);
     $ibs->chargeUser($group, $payment['input'][$this->usernameinput]['value'], $payment['input'][$this->passwordinput]['value']);
     $items[$sql['id']][] = array('fieldname' => $payment['input'][$this->usernameinput]['name'], 'type' => 'text', 'value' => $payment['input'][$this->usernameinput]['value']);
     $items[$sql['id']][] = array('fieldname' => $payment['input'][$this->passwordinput]['name'], 'type' => 'text', 'value' => $payment['input'][$this->passwordinput]['value']);
 }
예제 #8
0
 public function callbackGateway()
 {
     if ($_POST['status'] != '1') {
         $message = 'پرداخت با موفقيت انجام نشده است.';
         throw new Exception($message);
     }
     $refID = $_POST['refnum'];
     $resCode = $_POST['resnum'];
     $id = $this->merchantID;
     $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('id = ?'));
     $payment->execute(array($resCode));
     $payment = $payment->fetch();
     if ($payment['status'] == Application::STATUS_PENDING) {
         $amount = $payment['amount'];
         $url = 'http://bazpardakht.com/webservice/verify.php';
         $fields = array('id' => urlencode($id), 'resnum' => urlencode($resCode), 'refnum' => urlencode($refID), 'amount' => urlencode($amount / 10));
         //url-ify the data for the POST
         $fields_string = "";
         foreach ($fields as $key => $value) {
             $fields_string .= $key . '=' . $value . '&';
         }
         rtrim($fields_string, '&');
         //open connection
         $ch = curl_init($url);
         //set the url, number of POST vars, POST data
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_POST, count($fields));
         curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         //execute post
         $result = curl_exec($ch);
         curl_close($ch);
         $result = intval($result);
         $pay = false;
         if ($result <= 0) {
             $pay = false;
         } elseif ($result == '1') {
             $pay = true;
         }
         ///////////////////
         if ($pay) {
             return $payment;
         } else {
             $message = 'خطا در پرداخت';
         }
     } else {
         $message = 'این سفارش قبلا پرداخت شده است.';
     }
     throw new Exception($message);
 }
예제 #9
0
파일: Payline.php 프로젝트: aliazizi/CShop
 public function callbackGateway()
 {
     $api = $this->pin;
     $url = 'http://payline.ir/payment-test/gateway-result-second';
     $trans_id = $_POST['trans_id'];
     $id_get = $_POST['id_get'];
     $result = $this->get($url, $api, $trans_id, $id_get);
     if ($result == 1) {
         $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?'));
         $payment->execute(array($id_get));
         $payment = $payment->fetch();
         if ($payment) {
             return $payment;
         } else {
             $message = 'اطلاعات پرداخت کامل نیست.';
         }
     } else {
         $message = 'پرداخت موفقيت آميز نبود';
     }
     throw new Exception($message);
 }
예제 #10
0
파일: Zarinpal.php 프로젝트: aliazizi/CShop
 public function callbackGateway()
 {
     $Authority = $_GET['Authority'];
     $ref_id = $_GET['refID'];
     if ($_GET['Status'] == 'OK') {
         $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?'));
         $payment->execute(array($Authority));
         $amount = round($payment['amout'] / 10);
         $client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl');
         $res = $client->call("PaymentVerification", array(array('MerchantID' => $this->merchant, 'Authority' => $Authority, 'Amount' => $amount)));
         if ($payment[payment_status] == Application::STATUS_PENDING) {
             if ($res['Status'] == 100) {
                 return $payment;
             } else {
                 $message = 'پرداخت توسط زرین‌پال تایید نشد‌.' . $res['Status'];
             }
         } else {
             $message = 'سفارش قبلا پرداخت شده است.';
         }
     } else {
         $message = 'شماره یکتا اشتباه است.';
     }
     throw new Exception($message);
 }
예제 #11
0
파일: Sibapalp.php 프로젝트: aliazizi/CShop
 public function callbackGateway()
 {
     $au = $_SESSION['siba_au'];
     $order_id = $_SESSION['invoice_id'];
     $pin = $this->merchantID;
     $payment = Cshop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('payment')->where('reference = ?'));
     $payment->execute(array($au));
     $payment = $payment->fetch();
     $amount = round($payment['amount'] / 10);
     $bank_return = $_POST + $_GET;
     $res = $this->verify($pin, $amount, $au, $order_id, $bank_return);
     if ($payment['status'] == Application::STATUS_PENDING) {
         if (empty($res)) {
             $message = 'خطا در اتصال به سرور !';
         } elseif ($res['result'] == 1) {
             return $payment;
         } else {
             $message = 'پرداخت  انجام نشده است . <br /> شرح خطا : ' . urldecode($res['msg']);
         }
     } else {
         $message = 'سفارش قبلا پرداخت شده است.';
     }
     throw new Exception($message);
 }
예제 #12
0
 public function actionPayment()
 {
     $message['content'] = '';
     $this->pageTitle = 'پرداخت';
     $items = array();
     try {
         if (!isset($_GET['gateway'])) {
             throw new Exception('اطلاعات پرداخت کامل نمی باشد');
         }
         $gateway = $this->db->prepare(QueryBuilder::getInstance()->select()->from('gateway')->leftJoin('option')->on('class = category')->where('gateway.id = ?'));
         $gateway->execute(array($_GET['gateway']));
         $gateway = $gateway->fetchAll();
         if (!$gateway[0]) {
             throw new Exception('اطلاعات پرداخت کامل نمی باشد');
         }
         CShop::import(Cshop::$gatewaypath . DIRECTORY_SEPARATOR . $gateway[0]['class'] . '.php');
         /* @var $plugin GatewayBase */
         $plugin = new $gateway[0]['class']($gateway[0]['id'], $gateway);
         $payment = $plugin->callbackGateway();
         if (!$payment) {
             throw new Exception('اطلاعات پرداخت کامل نمی باشد');
         }
         if ($payment['status'] == Application::STATUS_PENDING) {
             $sql = $this->db->prepare(QueryBuilder::getInstance()->update('payment')->set('status = ?,paymenttime=?')->where('id = ?'));
             $sql->execute(array($payment['status'] = Application::STATUS_COMPLETE, time(), $payment['id']));
             $sql = $this->db->prepare(QueryBuilder::getInstance()->update('item')->set('status = ?')->where('paymentid = ?'));
             $sql->execute(array(Application::STATUS_COMPLETE, $payment['id']));
             $sql = $this->db->prepare(QueryBuilder::getInstance()->select('item.*,value.fieldid,value,field.name AS fieldname,field.type,product.name,product.description')->from('item')->leftJoin('product')->on('product.id = item.productid')->leftJoin('value')->on('item.id = itemid')->leftJoin('field')->on('fieldid = field.id')->where('paymentid = ?'));
             $sql->execute(array($payment['id']));
             while ($item = $sql->fetch()) {
                 $items[$item['id']][] = $item;
             }
             $message['content'] = 'پرداخت با موفقیت انجام شد';
             $message['type'] = 'success';
             $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select('input.*,value')->from('payment_meta')->leftJoin('input')->on('inputid = input.id')->where('paymentid = ?'));
             $sql->execute(array($payment['id']));
             $payment['input'] = array();
             while ($row = $sql->fetch()) {
                 $row['data'] = unserialize($row['data']);
                 $payment['input'][$row['id']] = $row;
             }
             CShop::app()->raise(Application::EVENT_AFTER_PAYMENT, array(&$payment, &$items));
         } else {
             throw new Exception('این سفارش قبلا پرداخت شده است.');
         }
     } catch (Exception $e) {
         $message['content'] = $e->getMessage();
     }
     $this->layout = 'layout/payment';
     CShop::app()->raise(Application::EVENT_ITEM_TYPE);
     $this->render('site/payment', array('message' => $message, 'items' => $items));
 }
예제 #13
0
파일: Input.php 프로젝트: aliazizi/CShop
 public static function deleteInput($id)
 {
     $input = array();
     $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->delete('input')->where('id=?'));
     $sql->execute(array($id));
 }
예제 #14
0
 public function actionStatistic()
 {
     $message = $this->user->message();
     if (isset($_POST['update'])) {
         foreach ($_POST['order'] as $key => $value) {
             $sql = $this->db->prepare(QueryBuilder::getInstance()->update('category')->set('`order` = ?')->where('id = ?'));
             $sql->execute(array($value, $key));
         }
         $message['content'] = 'تغییرات با موفقیت ذخیره شد';
         $message['type'] = 'success';
         $this->user->message($message);
         CShop::app()->redirect('category.php');
     } elseif (isset($_POST['remove'])) {
         foreach ($_POST['delete'] as $value) {
             $sql = $this->db->prepare(QueryBuilder::getInstance()->delete('category')->where('id = ?'));
             $sql->execute(array($value));
         }
         $message['content'] = 'تغییرات با موفقیت ذخیره شد';
         $message['type'] = 'success';
         $this->user->message($message);
         CShop::app()->redirect('category.php');
     }
     $categories = new Model($this->db->query(QueryBuilder::getInstance()->select()->from('category')->order('`order`')));
     $this->render('admin/category', array('message' => $message, 'items' => $categories));
 }
예제 #15
0
파일: Freer.php 프로젝트: aliazizi/CShop
    /**
     * @param Controller $controller
     */
    public function actionImport($controller)
    {
        $content = '<div class="title">انتفال</div>';
        $db = CShop::app()->getDb();
        $lasterrormode = $db->getAttribute(PDO::ATTR_ERRMODE);
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
        if (isset($_POST['start'])) {
            try {
                $freerdb = new Database(true, $this->dbname, $this->dbserver, $this->dbusername, $this->dbpassword);
                //Payment import
                $items = $freerdb->query(QueryBuilder::getInstance('')->select()->from('payment'));
                $paymentids = array();
                while ($row = $items->fetch()) {
                    $sql = $db->prepare(QueryBuilder::getInstance()->insert('payment')->into(array('amount', 'requesttime', 'status', 'clientip', 'paymenttime', 'reference', 'gatewayid'), true, false));
                    $status = $row['payment_status'] == 1 ? Application::STATUS_PENDING : Application::STATUS_COMPLETE;
                    $sql->execute(array($row['payment_amount'], $row['payment_time'], $status, $row['payment_ip'], $row['payment_time'], $row['payment_res_num'], $this->gatewayid));
                    $paymentids[$row['payment_id']] = $db->lastInsertId();
                    if ($this->email) {
                        $sql = $db->prepare(QueryBuilder::getInstance()->insert('payment_meta')->into(array('inputid', 'paymentid', 'value'), true, false));
                        $sql->execute(array($this->email, $paymentids[$row['payment_id']], $row['payment_email']));
                    }
                    if ($this->mobile) {
                        $sql = $db->prepare(QueryBuilder::getInstance()->insert('payment_meta')->into(array('inputid', 'paymentid', 'value'), true, false));
                        $sql->execute(array($this->mobile, $paymentids[$row['payment_id']], $row['payment_mobile']));
                    }
                }
                //Category import
                $items = $freerdb->query(QueryBuilder::getInstance('')->select()->from('category'));
                $categoryids = array();
                while ($row = $items->fetch()) {
                    $sql = $db->prepare(QueryBuilder::getInstance()->insert('category')->into(array('name', 'description', '`order`'), true, false));
                    $sql->execute(array($row['category_title'], '', $row['category_order']));
                    $categoryids[$row['category_id']] = $db->lastInsertId();
                }
                //Product AND item import
                $items = $freerdb->query(QueryBuilder::getInstance('')->select()->from('product'));
                while ($row = $items->fetch()) {
                    $sql = $db->prepare(QueryBuilder::getInstance()->insert('product')->into(array('name', 'description', 'price', '`order`', 'categoryid'), true, false));
                    $sql->execute(array($row['product_title'], $row['product_body'], $row['product_price'], 0, $categoryids[$row['product_category']]));
                    $productid = $db->lastInsertId();
                    $sql = $db->prepare(QueryBuilder::getInstance()->insert('field')->into(array('productid', 'name', 'type'), true, false));
                    $sql->execute(array($productid, $row['product_first_field_title'], 'text'));
                    $field1 = $db->lastInsertId();
                    $sql = $db->prepare(QueryBuilder::getInstance()->insert('field')->into(array('productid', 'name', 'type'), true, false));
                    $sql->execute(array($productid, $row['product_second_field_title'], 'text'));
                    $field2 = $db->lastInsertId();
                    $sql = $db->prepare(QueryBuilder::getInstance()->insert('field')->into(array('productid', 'name', 'type'), true, false));
                    $sql->execute(array($productid, $row['product_third_field_title'], 'text'));
                    $field3 = $db->lastInsertId();
                    $cards = $freerdb->query(QueryBuilder::getInstance('')->select("*,DECODE(card_first_field,'{$this->salt}') AS card_first_field,DECODE(card_second_field,'{$this->salt}') AS card_second_field,DECODE(card_third_field,'{$this->salt}') AS card_third_field")->from('card')->where('card_product=' . $row['product_id']));
                    while ($card = $cards->fetch()) {
                        //pament id
                        $sql = $db->prepare(QueryBuilder::getInstance()->insert('item')->into(array('productid', 'status', 'createtime', 'paymentid'), true, false));
                        $status = $card['card_status'] == 1 ? Application::STATUS_PENDING : Application::STATUS_COMPLETE;
                        $sql->execute(array($productid, $status, $card['card_time'], $paymentids[$card['card_payment_id']]));
                        $itemid = $db->lastInsertId();
                        $sql = $db->prepare(QueryBuilder::getInstance()->insert('value')->into(array('fieldid', 'itemid', 'value'), true, false));
                        $sql->execute(array($field1, $itemid, $card['card_first_field']));
                        $sql = $db->prepare(QueryBuilder::getInstance()->insert('value')->into(array('fieldid', 'itemid', 'value'), true, false));
                        $sql->execute(array($field2, $itemid, $card['card_second_field']));
                        $sql = $db->prepare(QueryBuilder::getInstance()->insert('value')->into(array('fieldid', 'itemid', 'value'), true, false));
                        $sql->execute(array($field3, $itemid, $card['card_third_field']));
                    }
                }
                $content .= 'انتقال انجام شد';
            } catch (Exception $e) {
                $content .= 'خطا! ' . $e->getMessage();
            }
        } else {
            $content .= '<form method="post">
				<input type="submit" value="شروع" name="start">
			</form>';
        }
        $db->setAttribute(PDO::ATTR_ERRMODE, $lasterrormode);
        $controller->renderWithContent($content);
    }
예제 #16
0
파일: index.php 프로젝트: aliazizi/CShop
require '../core/CShop.php';
if (cshop::VERSION == '1.1.2') {
    header('location: ../');
    exit;
}
require '../core/class/database.php';
require '../core/class/QueryBuilder.php';
$success = false;
if (isset($_POST['upgrade'])) {
    try {
        $db = new Database(true, $config[database][database], $config[database][host], $config[database][username], $config[database][password]);
    } catch (PDOException $e) {
        throw new Exception('خطا در اتصال به دیتابیس، متن خطا : ' . $e->getMessage());
    }
    $querybuilder = new QueryBuilder();
    $querybuilder = QueryBuilder::getInstance($config[database][prefix]);
    //$query ='select class,id from '.$config[database][prefix].'plugin';
    $result = $db->query($querybuilder->select()->from('plugin'));
    $querybuilder->clear();
    while ($plugin = $result->fetch()) {
        //echo $plugin['class'];
        //echo $plugin['id'];
        //$query='select pluginid,`key`,`value` from '.$config[database][prefix].'plugin_meta'.' where pluginid='.$plugin['id'];
        $result2 = $db->query($querybuilder->select()->from('plugin_meta')->where('pluginid=' . $plugin['id']));
        while ($plugin_meta = $result2->fetch()) {
            //	var_dump($plugin_meta);
            $pluginadd = "../plugin/" . $plugin['class'] . ".php";
            $subject = file_get_contents($pluginadd);
            //      **************************************************************
            $pattern = '/public\\s*static\\s*function\\s*getParameters\\s*\\(\\s*\\).*?(return\\s*array\\s*\\(.*?\\)\\s*;)/s';
            $matches = array();
예제 #17
0
 public function loadConfig($category = self::APPLICATON_CONFIG_CATEGORY)
 {
     $sql = $this->_db->query(QueryBuilder::getInstance()->select()->from('option')->where('category="' . $category . '"'));
     $config = array();
     while ($row = $sql->fetch()) {
         $r = $row;
         unset($r['key']);
         $config[$row['key']] = $r;
     }
     return $config;
 }
예제 #18
0
파일: Voucher.php 프로젝트: aliazizi/CShop
    /**
     *
     * @param Controller $controller
     */
    public function actionVoucher($controller)
    {
        $message = $controller->getUser()->message();
        if (isset($_POST['remove'])) {
            foreach ($_POST['delete'] as $value) {
                $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->delete('voucher')->where('id = ?'));
                $sql->execute(array($value));
            }
            $message['content'] = 'تغییرات با موفقیت ذخیره شد';
            $message['type'] = 'success';
            $controller->getUser()->message($message);
            CShop::app()->redirect($_SERVER['REQUEST_URI']);
        }
        $sql = CShop::app()->getDb()->query(QueryBuilder::getInstance()->select()->from('voucher'));
        $content = '<div class="title">مدیریت کد های تخفیف</div>
						<div class="content">
						<form action="" method="post">
						<table>
						<tr>
							<th>ردیف</th>
							<th>کد</th>
							<th>ارزش</th>
							<th>زمان پایان</th>
							<th>تعداد باقی مانده</th>
							<th>مدیریت</th>
							<th><a href="#" onclick="check(this)">انتخاب</a></th>
						</tr>';
        $i = 1;
        while ($item = $sql->fetch()) {
            $content .= '<tr>';
            $content .= '<td>' . $i++ . '</td>';
            $content .= '<td>' . $item['code'] . '</td>';
            $content .= '<td>' . $item['value'] . '%</td>';
            $content .= '<td>' . jDateTime::date(CShop::app()->systemConfig()->timeformat, $item['paymenttime'] ? $item['paymenttime'] : $item['time']) . '</td>';
            $content .= '<td>' . $item['maxuse'] . '</td>';
            $content .= '<td><a href="' . self::getActionLink('editvoucher', $this->id) . '&vid=' . $item['id'] . '">ویرایش</a></td>';
            $content .= '<td><input type="checkbox" name="delete[]" value="' . $item['id'] . '"></td>';
            $content .= '</tr>';
        }
        $content .= '</table><div style="text-align: left"><input type="submit" value="ذخیره" name="update"><input type="submit" value="حذف" name="remove"></div></form></div>';
        $controller->renderWithContent($content, array('message' => $message));
    }
예제 #19
0
파일: Page.php 프로젝트: aliazizi/CShop
 public function showPage($pageid)
 {
     $page = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->select()->from('page')->where('id = ? AND (type = ? OR type = ?)'));
     $page->execute(array($pageid, self::TYPE_PAGE, self::TYPE_PAGE_CUSTOM));
     if ($page->rowCount() != 1) {
         CShop::app()->redirect(CShop::$baseurl);
     }
     $page = $page->fetch();
     if ($page['type'] == self::TYPE_PAGE_CUSTOM) {
         echo $page['content'];
     } else {
         CShop::app()->getController()->renderWithContent($page['content']);
     }
     CShop::app()->end();
 }