function OrderManagement($config, $jsonResult, $action) { $conn = new connection($config); switch ($action) { case 'takeOrder': $res = takeOrder($conn); $jsonResult->json_data['result_code'] = $res['code']; $jsonResult->json_data['result_data'] = $res['data']; break; case 'sendOrder': $jsonResult->json_data['result_code'] = sendOrder($conn); break; default: $jsonResult->json_data['result_code'] = JSON::$resultCodes['no_order_action']; break; } }
function order_process() { sendOrder($_POST['form']); }
if ($stmt = $conn->prepare("UPDATE `orders` SET `orde_status`=1 WHERE `orde_id`=?")) { $stmt->bind_param("i", $id); $stmt->execute(); $stmt->store_result(); if ($stmt->affected_rows != 1) { echo ' <div class="alert alert-warning alert-modal" role="alert"> <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">× </button> Falha ao tentar enviar pedido.</div>'; return false; } else { echo ' <div class="alert alert-success alert-modal" role="alert"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">× </button> Pedido (' . $id . ') enviado com sucesso! </div>'; return true; } } else { echo ' <div class="alert alert-danger alert-modal" role="alert"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">× </button> Falha na conexão: ' . $conn->error . ' </div>'; } } $check = alreadySent($_GET['order']); if ($check === false) { sendOrder($_GET['order']); }
//08.25.2015 ghh - added getinventory request RestLog("Getting Order Status"); require_once "getorderstatus.php"; getOrderStatus($requestvars, $responsetype); break; default: die(RestUtils::sendResponse(400, 'Error 16542: Bad Request')); //Bad Request break; } break; //08.20.2015 ghh - send requests enter here //08.20.2015 ghh - send requests enter here case 'post': switch ($requesttype) { case 'sendorder': RestLog("Send Order Called"); require_once "sendorder.php"; sendOrder($requestvars, $responsetype); break; default: die(RestUtils::sendResponse(400, 'Error 16543 Bad Request')); //Bad Request break; } break; default: die(RestUtils::sendResponse(400, 'Error 16544 Bad Post/Get Request')); //Bad Request break; }
/** * sets up the sales container */ function sendContainer($sales, $deletePDF) { // loops through all selected sales foreach ($sales as $sale) { // skips "non existent" sales (dev issue: was: deprecated) if (null === ($customer = Mage::getModel("customer/customer")->load($sale->getCustomerId()))) { continue; } // skips "premium" orders $cgid = $customer->getGroupId(); $code = Mage::getSingleton("customer/group")->load($cgid)->getCustomerGroupCode(); if ("General" != $code) { print $code . PHP_EOL; print $cgid . PHP_EOL; continue; } // Gerdt Vladimir @ Karli (and fills) // $shipaddr = $sale->getShippingAddress(); // $firstName = $shipaddr->getFirstname(); $lastName = $shipaddr->getLastname(); $email = $shipaddr->getEmail(); $telephone = $shipaddr->getTelephone(); $street = implode(" ", $shipaddr->getStreet()); $country = $shipaddr->getCountry(); $city = $shipaddr->getCity(); $postcode = $shipaddr->getPostcode(); /////// $kvg_arr_order = array(); $kvg_lfdnr = getTransactionId($customer, $sale); // Eindeutige Auftragsnummer /////// Kopfdaten $kvg_arr_order[$kvg_lfdnr]['key'] = $kvg_lfdnr; // Eindeutige Auftragsnummer $kvg_arr_order[$kvg_lfdnr]['order_number'] = $sale->getIncrementId(); // Bestellnummer, optional $kvg_arr_order[$kvg_lfdnr]['customer_note'] = $sale->getCustomerNote(); // Kommentar zum Auftrag max. 200 Zeichen, optional $d = DateTime::createFromFormat("Y-m-d H:i:s", $sale->getCreatedAt()); $createdAt = $d->format("Y-m-d H:i"); $createdAtDate = $d->format("Y-m-d"); $createdAtTime = $d->format("H:i"); $kvg_arr_order[$kvg_lfdnr]['order_date'] = $createdAtDate; // Auftragsdatum $kvg_arr_order[$kvg_lfdnr]['order_time'] = $createdAtTime; // Auftragszeit /////// Kundendaten $kvg_arr_order[$kvg_lfdnr]['customer_first_name'] = $firstName; // Vorname $kvg_arr_order[$kvg_lfdnr]['customer_last_name'] = $lastName; // Nachname $kvg_arr_order[$kvg_lfdnr]['customer_county'] = $country; // Land $kvg_arr_order[$kvg_lfdnr]['customer_city'] = $city; // Stadt $kvg_arr_order[$kvg_lfdnr]['customer_postal_code'] = $postcode; // Postleitzahl $kvg_arr_order[$kvg_lfdnr]['customer_street'] = $street; // Strasse $kvg_arr_order[$kvg_lfdnr]['customer_phone'] = $telephone; // Telefon $kvg_arr_order[$kvg_lfdnr]['customer_mobile'] = $mobile; // Mobile Telefon $kvg_arr_order[$kvg_lfdnr]['customer_fax'] = $fax; // Fax $kvg_arr_order[$kvg_lfdnr]['customer_email'] = $email; // Email /////// Produkte foreach ($sale->getAllItems() as $item) { $articleID = $item->getSku(); $kvg_arr_order[$kvg_lfdnr]['position'][$articleID]['article_number'] = $articleID; // Artikelnummer $kvg_arr_order[$kvg_lfdnr]['position'][$articleID]['amount'] = $item->getQtyOrdered(); // Menge $kvg_arr_order[$kvg_lfdnr]['position'][$articleID]['price'] = $item->getPrice(); // Preis $i++; } // --> ////// // writes the invoice PDF document exec(ExportInvoiceCommand . $sale->getIncrementId()); // writes the retoure PDF document exec(ExportRetoureCommand . $sale->getIncrementId()); // $invoicePDF = PDFPath . $kvg_lfdnr . "_invoice.pdf"; $retourePDF = PDFPath . $kvg_lfdnr . "_retoure.pdf"; // checks invoice PDF; skips the sale without an invoice if (!file_exists($invoicePDF)) { // logs the fail logger("No Invoice. Will not send the order: " . $kvg_lfdnr); // fills up CRON notification email (administrative issue) EmailNotification::add("<span style='color:red'>Bestellung {$kvg_lfdnr} konnte wegen der fehlenden Quittung nicht zu Karlie gesandt werden.</span>"); // skips the sale continue; } // sends the order to karlie if ("true" === sendOrder($kvg_arr_order, $invoicePDF, $retourePDF)) { // writes DB record (order is referred to karlie) $sale->setKarlieOrderId($kvg_lfdnr); $sale->setState("processing", true, "Die Bestellung ist zu Karlie weitergeleitet. " . $sale->getKarlieOrderId()); $sale->setStatus("referred_to_karlie"); $sale->save(); // logs the CRON success logger("Order sent to Karlie"); // fills up CRON notification email (administrative issue) EmailNotification::add("<span class='green'>Bestellung {$kvg_lfdnr} ist zu Karlie gesandt worden.</span>"); // sends customer notification email foreach ($sale->getInvoiceCollection() as $invoice) { try { $invoice->sendEmail(); } catch (Exception $e) { logger("Could not sent Customer Notification Email: " . $e); } } } else { // logs send fail logger("Could not send the order"); // fills up CRON notification email (administrative issue) EmailNotification::add("<span class='red'>Bestellung {$kvg_lfdnr} konnte nicht zu Karlie gesandt werden.</span>"); } } }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/Config/db.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/Actions/users.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/Actions/cart.php'; $action = $_GET['act']; switch ($action) { case "sendorder": sendOrder(); break; } function sendOrder() { $oid = getorderID(); mysql_query("UPDATE orders SET status = 1, comment = '" . $_POST['comment'] . "' WHERE id = '" . $oid . "'"); $querys = mysql_query("SELECT * FROM cart WHERE order_id = '" . $oid . "'"); while ($do = mysql_fetch_array($querys)) { mysql_query("UPDATE products SET rest = (rest - '" . $do['quantity'] . "') WHERE id = '" . $do['product_id'] . "'"); } $user = getUser(); $zagolovok = 'Поступил новый заказ'; $text = "\n <table>\n <tr>\n <td>\n Номер заказа:\n </td>\n <td>\n " . $oid . "\n </td>\n </tr>\n <tr>\n <td>\n Компания:\n </td>\n <td>\n " . $user['company'] . "\n </td>\n </tr>\n <tr>\n <td>\n E-Mail:\n </td>\n <td>\n " . $user['email'] . "\n </td>\n </tr>\n <tr>\n <td>\n Телефон:\n </td>\n <td>\n " . $user['phone'] . "\n </td>\n </tr>"; $from = '*****@*****.**'; $headers = 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= 'From: buelo@mail.ru' . "\r\n" . 'Reply-To: buelo@mail.ru' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $to = '*****@*****.**'; mail($to, '=?UTF-8?B?' . base64_encode($zagolovok) . '?=', $text, $headers); header('Location: /load.php?p=cart&act=successsent'); }
header("refresh:2"); exit; } else { $name = clean($_POST['name']); $mail = clean($_POST['mail']); $mail_validate = filter_var($mail, FILTER_VALIDATE_EMAIL); if (empty($mail_validate)) { echo "<h3 class='error'>Введите корректный email!</h3>"; header("refresh:2"); exit; } else { $phone = clean(preg_replace('/[^0-9]/', '', $_POST['phone'])); //@TODO: сделать проверку телефона $adres = clean($_POST['adres']); $tk = clean($_POST['tk1']); $product = serialize($_SESSION['cart']); $total_sum = $_SESSION['total_price']; $date = date('d-m-Y'); $time = date('H:i'); sendOrder($name, $mail_validate, $phone, $adres, $tk, $product, $total_sum, $date, $time); unset($_SESSION['cart']); echo "<h3 class='error'>Спасибо за Ваш заказ!</h3><br><a href='index.php'>Вернуться в магазин</a>"; header("refresh: 5; url=index.php"); } } } ?> </div> </body> </html>