public function clientLogin($user = '', $pass = '') { $DbExt = new DbExt(); $stmt = "SELECT * FROM\n\t \t{{client}}\n\t \tWHERE\n\t \temail_address=" . Yii::app()->db->quoteValue($user) . "\n\t \tAND\n\t \tpassword="******"\n\t \tAND\n\t \tstatus IN ('active')\n\t \tLIMIT 0,1\n\t \t"; if ($res = $DbExt->rst($stmt)) { return $res[0]; } return false; }
public function rptAdminSalesRpt() { $and = ''; if (isset($this->data['start_date']) && isset($this->data['end_date'])) { if (!empty($this->data['start_date']) && !empty($this->data['end_date'])) { $and = " AND date_created BETWEEN '" . $this->data['start_date'] . " 00:00:00' AND \r\n\t \t\t '" . $this->data['end_date'] . " 23:59:00'\r\n\t \t\t "; } } $order_status_id = ''; $or = ''; if (isset($this->data['stats_id'])) { if (is_array($this->data['stats_id']) && count($this->data['stats_id']) >= 1) { foreach ($this->data['stats_id'] as $stats_id) { $order_status_id .= "'{$stats_id}',"; } if (!empty($order_status_id)) { $order_status_id = substr($order_status_id, 0, -1); } } } if (!empty($order_status_id)) { $and .= " AND status IN ({$order_status_id})"; } $DbExt = new DbExt(); $merchant_id = isset($this->data['merchant_id']) ? $this->data['merchant_id'] : ''; $stmt = "SELECT a.*,\r\n\t \t(\r\n\t \tselect concat(first_name,' ',last_name)\r\n\t \tfrom\r\n\t \t{{client}}\r\n\t \twhere\r\n\t \tclient_id=a.client_id\r\n\t \t) as client_name,\r\n\t \t\r\n\t \t(\r\n\t \tselect group_concat(item_name)\r\n\t \tfrom\r\n\t \t{{order_details}}\r\n\t \twhere\r\n\t \torder_id=a.order_id\r\n\t \t) as item\r\n\t \t\r\n\t \tFROM\r\n\t \t{{order}} a\r\n\t \tWHERE\r\n\t \tmerchant_id='{$merchant_id}'\r\n\t \tAND status NOT IN ('" . initialStatus() . "')\t \t\r\n\t \t{$and}\r\n\t \tORDER BY order_id DESC\r\n\t \tLIMIT 0,2000\r\n\t \t"; /*dump($this->data); dump($stmt);*/ $_SESSION['kr_export_stmt'] = $stmt; if ($res = $DbExt->rst($stmt)) { foreach ($res as $val) { $action = "<a data-id=\"" . $val['order_id'] . "\" class=\"edit-order\" href=\"javascript:\">" . Yii::t("default", "Edit") . "</a>"; $action .= "<a data-id=\"" . $val['order_id'] . "\" class=\"view-receipt\" href=\"javascript:\">" . Yii::t("default", "View") . "</a>"; /*$date=prettyDate($val['date_created'],true); $date=Yii::app()->functions->translateDate($date);*/ $date = FormatDateTime($val['date_created']); $feed_data['aaData'][] = array($val['order_id'], ucwords($val['client_name']), $val['item'], ucwords(Yii::t("default", $val['trans_type'])), strtoupper(Yii::t("default", $val['payment_type'])), prettyFormat($val['sub_total'], $merchant_id), prettyFormat($val['tax'], $merchant_id), prettyFormat($val['total_w_tax'], $merchant_id), ucwords($val['status']), $date); } $this->otableOutput($feed_data); } $this->otableNodata(); }
public function actionFax() { $msg = ''; $send_fax_link = 'https://www.faxage.com/httpsfax.php'; $db_ext = new DbExt(); $stmt = "SELECT * FROM\n\t\t{{fax_broadcast}}\n\t\tWHERE\n\t\tstatus='pending'\n\t\tLIMIT 0,5\n\t\t"; $fax_company = yii::app()->functions->getOptionAdmin("fax_company"); $fax_username = yii::app()->functions->getOptionAdmin("fax_username"); $fax_password = yii::app()->functions->getOptionAdmin("fax_password"); dump("company: " . $fax_company); dump("username: "******"password: "******"/cron/faxpostback/"; if ($res = $db_ext->rst($stmt)) { foreach ($res as $val) { dump($val); $jobid = ''; $record_id = $val['id']; $credit = Yii::app()->functions->getMerchantFaxCredit($val['merchant_id']); dump($credit); if ($credit >= 1) { $params = "username="******"&company=" . $fax_company; $params .= "&password="******"&recipname=" . $val['recipname']; $params .= "&faxno=" . $val['faxno']; $params .= "&operation=sendfax"; $params .= "&faxurl=" . $val['faxurl']; $params .= "&url_notify={$notify_url}"; dump($params); if ($response = Yii::app()->functions->Curl($send_fax_link, $params)) { $msg = $response; if (preg_match("/JOBID/i", $response)) { $jobid = str_replace("JOBID:", '', $response); $jobid = trim($jobid); } else { $jobid = ''; } } else { $msg = "Invalid response"; } } else { $msg = t("Zero credits"); } $params_update = array('status' => "process", 'api_raw_response' => $msg, 'date_process' => date('c'), 'jobid' => $jobid); $db_ext->updateData("{{fax_broadcast}}", $params_update, 'id', $record_id); } /*end foreach*/ } else { $msg = "NO records to process"; } dump("Result: " . $msg); }
} } else { if (isset($_GET["trxid"])) { if ($data_get['status'] == "Success") { if (isset($_GET['renew'])) { if ($new_info = Yii::app()->functions->getPackagesById($package_id)) { $res['package_name'] = $new_info['title']; $res['package_price'] = $new_info['price']; if ($new_info['promo_price'] > 0) { $res['package_price'] = $new_info['promo_price']; } } $membership_info = Yii::app()->functions->upgradeMembership($res['merchant_id'], $package_id); $params = array('package_id' => $package_id, 'merchant_id' => $res['merchant_id'], 'price' => $res['package_price'], 'payment_type' => Yii::app()->functions->paymentCode('sisow'), 'membership_expired' => $membership_info['membership_expired'], 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'PAYPALFULLRESPONSE' => json_encode($data_get), 'TRANSACTIONID' => $data_get['trxid'], 'TOKEN' => $data_get['ec']); $stmt = "SELECT * FROM\n\t\t\t {{package_trans}} \t\t\t \n\t\t\t WHERE\n\t\t\t TRANSACTIONID='" . $data_get['trxid'] . "'\n\t\t\t AND\n\t\t\t TOKEN='" . $data_get['ec'] . "'\n\t\t\t AND\n\t\t\t payment_type='" . Yii::app()->functions->paymentCode('sisow') . "'\n\t\t\t "; if ($check_res = $check = $db_ext->rst($stmt)) { } else { $db_ext->insertData("{{package_trans}}", $params); } //$db_ext->insertData("{{package_trans}}",$params); $params_update = array('package_id' => $package_id, 'package_price' => $membership_info['package_price'], 'membership_expired' => $membership_info['membership_expired'], 'status' => 'active'); $db_ext->updateData("{{merchant}}", $params_update, 'merchant_id', $res['merchant_id']); } else { $params = array('package_id' => $res['package_id'], 'merchant_id' => $res['merchant_id'], 'price' => $res['package_price'], 'payment_type' => Yii::app()->functions->paymentCode('sisow'), 'membership_expired' => $res['membership_expired'], 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'PAYPALFULLRESPONSE' => json_encode($data_get), 'TRANSACTIONID' => $data_get['trxid'], 'TOKEN' => $data_get['ec']); $stmt = "SELECT * FROM\n\t\t\t {{package_trans}} \t\t\t \n\t\t\t WHERE\n\t\t\t TRANSACTIONID='" . $data_get['trxid'] . "'\n\t\t\t AND\n\t\t\t TOKEN='" . $data_get['ec'] . "'\n\t\t\t AND\n\t\t\t payment_type='" . Yii::app()->functions->paymentCode('sisow') . "'\n\t\t\t "; if ($check_res = $check = $db_ext->rst($stmt)) { } else { $db_ext->insertData("{{package_trans}}", $params); } //$db_ext->insertData("{{package_trans}}",$params); $db_ext->updateData("{{merchant}}", array('payment_steps' => 3, 'membership_purchase_date' => date('c')), 'merchant_id', $res['merchant_id']);
public function actionIndex() { $db_ext = new DbExt(); $error = ''; $package_id = isset($_GET['package_id']) ? $_GET['package_id'] : ''; $amount_to_pay = 0; $back_url = Yii::app()->request->baseUrl . "/merchant/purchasesms"; $payment_ref = Yii::app()->functions->generateCode() . "TT" . Yii::app()->functions->getLastIncrement('{{sms_package_trans}}'); $package_id = isset($_GET['package_id']) ? $_GET['package_id'] : ''; $merchant_id = Yii::app()->functions->getMerchantID(); if ($res = Yii::app()->functions->getSMSPackagesById($package_id)) { $amount_to_pay = $res['price']; if ($res['promo_price'] > 0) { $amount_to_pay = $res['promo_price']; } $amount_to_pay = is_numeric($amount_to_pay) ? normalPrettyPrice($amount_to_pay) : ''; $payment_description .= isset($res['title']) ? $res['title'] : ''; /*dump($payment_description); dump($amount_to_pay); dump($payment_ref);*/ $amount_to_pay = number_format($amount_to_pay, 2, '.', ''); $cancel_url = Yii::app()->getBaseUrl(true) . "/merchant/purchasesms"; $accepturl = Yii::app()->getBaseUrl(true) . "/merchant/pysinit/?type=purchaseSMScredit&package_id=" . $package_id . "&mode=accept&mtid={$merchant_id}"; $callback = Yii::app()->getBaseUrl(true) . "/paysera/?type=purchaseSMScredit&package_id=" . $package_id . "&mode=callback&mtid={$merchant_id}"; $country = Yii::app()->functions->getOptionAdmin('admin_paysera_country'); $mode = Yii::app()->functions->getOptionAdmin('admin_paysera_mode'); $lang = Yii::app()->functions->getOptionAdmin('admin_paysera_lang'); $currency = Yii::app()->functions->adminCurrencyCode(); $projectid = Yii::app()->functions->getOptionAdmin('admin_paysera_project_id'); $password = Yii::app()->functions->getOptionAdmin('admin_paysera_password'); if (isset($_GET['mode'])) { if ($_GET['mode'] == "accept") { $payment_code = Yii::app()->functions->paymentCode("paysera"); $params = array('merchant_id' => $_GET['mtid'], 'sms_package_id' => $package_id, 'payment_type' => $payment_code, 'package_price' => $amount_to_pay, 'sms_limit' => isset($res['sms_limit']) ? $res['sms_limit'] : '', 'date_created' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'payment_gateway_response' => json_encode($_GET)); $db_ext->insertData("{{sms_package_trans}}", $params); header('Location: ' . Yii::app()->request->baseUrl . "/merchant/smsReceipt/id/" . Yii::app()->db->getLastInsertID()); die; } try { $response = WebToPay::checkResponse($_GET, array('projectid' => $projectid, 'sign_password' => $password)); if (is_array($response) && count($response) >= 1) { if ($response['status'] == 0) { die("payment has no been executed"); } if ($response['status'] == 3) { die("additional payment information"); } $stmt = "SELECT * FROM\r\n\t\t \t{{sms_package_trans}}\r\n\t\t \tWHERE\r\n\t\t \tmerchant_id ='" . $_GET['mtid'] . "'\r\n\t\t \tAND\r\n\t\t \tsms_package_id='" . $_GET['package_id'] . "'\r\n\t\t \tORDER BY id DESC\r\n\t\t \tLIMIT 0,1\r\n\t\t \t"; if ($res2 = $db_ext->rst($stmt)) { $current_id = $res2[0]['id']; $params_update = array('status' => "paid"); $db_ext->updateData("{{sms_package_trans}}", $params_update, 'id', $current_id); } echo 'OK'; die; } else { $error = t("ERROR: api returns empty"); } } catch (WebToPayException $e) { $error = t("ERROR: Something went wrong") . ". " . $e; } } else { echo 'init'; } } else { $error = Yii::t("default", "Failed. Cannot process payment"); } if (!empty($error)) { //$this->render('error',array('message'=>$error)); echo $error; } //$this->createLogs(''); }
public function actionConfirmorder() { $data = $_GET; if (isset($data['id']) && isset($data['token'])) { $db_ext = new DbExt(); $stmt = "SELECT a.*,\r\n\t\t\t\t(\r\n\t\t\t\tselect activation_token\r\n\t\t\t\tfrom\r\n\t\t\t\t{{merchant}}\r\n\t\t\t\twhere\r\n\t\t\t\tmerchant_id=a.merchant_id\r\n\t\t\t\t) as activation_token\r\n\t\t\t FROM\r\n\t\t\t{{order}} a\r\n\t\t\tWHERE\r\n\t\t\torder_id=" . Yii::app()->functions->q($data['id']) . "\r\n\t\t\t"; if ($res = $db_ext->rst($stmt)) { if ($res[0]['activation_token'] == $data['token']) { $params = array('status' => "received", 'date_modified' => date('c'), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'viewed' => 2); if ($res[0]['status'] == "paid") { unset($params['status']); } if ($db_ext->updateData("{{order}}", $params, 'order_id', $data['id'])) { $msg = t("Order Status has been change to received, Thank you!"); } else { $msg = t("Failed cannot update order"); } } else { $msg = t("Token is invalid or not belong to the merchant"); } } } else { $msg = t("Missing parameters"); } $this->render('confirm-order', array('data' => $msg)); }
public function getCookingTranslation($name = '', $mt_id = '') { $DbExt = new DbExt(); $stmt = "SELECT * FROM\r\n\t\t\t{{cooking_ref}}\r\n\t\t\tWHERE\r\n\t\t\tcooking_name=" . $this->q($name) . "\r\n\t\t\tAND \r\n\t\t\tmerchant_id=" . $this->q($mt_id) . "\r\n\t\t\tLIMIT 0,1\t\t\t\r\n\t\t"; if ($res = $DbExt->rst($stmt)) { $res = $res[0]; $t['cooking_name_trans'] = !empty($res['cooking_name_trans']) ? json_decode($res['cooking_name_trans'], true) : ''; return $t; } return false; }
public function addIndex($table = '', $index_name = '') { $DbExt = new DbExt(); $prefix = Yii::app()->db->tablePrefix; $table = $prefix . $table; $stmt = "\n\t\tSHOW INDEX FROM {$table}\n\t\t"; $found = false; if ($res = $DbExt->rst($stmt)) { foreach ($res as $val) { if ($val['Key_name'] == $index_name) { $found = true; break; } } } if ($found == false) { echo "create index<br>"; $stmt_index = "ALTER TABLE {$table} ADD INDEX ( {$index_name} ) "; dump($stmt_index); $DbExt->qry($stmt_index); echo "Creating Index {$index_name} on {$table} <br/>"; echo "(Done)<br/>"; } else { echo 'index exist<br>'; } }
public function wdPayoutNotification() { $DbExt = new DbExt(); $stmt = "SELECT count(*) as total\n\t\t FROM\n\t\t{{withdrawal}}\n\t\tWHERE\n\t\tstatus ='pending'\n\t\tAND\n\t\tviewed='1'\n\t\t"; if ($res = $DbExt->rst($stmt)) { if ($res[0]['total'] >= 1) { $this->code = 1; $msg = t("There are") . " (" . $res[0]['total'] . ") " . t("withdrawals waiting for your approval"); $this->msg = $msg . "<br/><a class=\"white-link\" href=\"" . websiteUrl() . "/admin/incomingwithdrawal\">" . t("Click here to view") . "</a>"; $this->details = $res[0]['total']; } else { $this->msg = "no results"; } } else { $this->msg = "no results"; } }