function createOrder($items, $order, $parent = 0, $path = '') { ksort($order[$parent]); $listings .= '<ul>'; $middle = '</span></a>'; $close = '</li>'; foreach ($order[$parent] as $k => $v) { foreach ($items as $l => $w) { // now we can create the listings if ($w['id'] == $v) { $open = '<li><a href="./' . $path . $w['slug'] . '.html"><span>'; // check for children in this branch if (array_key_exists($w['id'], $order)) { $new_path = $path . $w['slug'] . '/'; $children = createOrder($items, $order, $w['id'], $new_path); } else { $children = ''; } $listings .= $open . $w['title'] . $middle . $children . $close; } } } $listings .= '</ul>'; return $listings; }
error_reporting(-1); require_once 'connect.php'; //recieve the phone number $phone = $_POST['phone_number']; //Recieve the amount $amount = $_POST['amount']; //appending 254 to the phone number $phone = '+254' . substr($phone, -9); //appending KES to the amount //$amount='KES '.$amount; /*check whether the user exists, if the user exits get the user_id, if not create the user and get the user id */ $user_id = createUser($phone); //we need to store the order of the airtime //create order createOrder($user_id, $amount); //building the recipients array $recipients = array(); $data['phoneNumber'] = $phone; $data['amount'] = $amount; array_push($recipients, $data); //sending the airtime sendAirtime($recipients); function createUser($phone) { //check if the user exists $query = mysql_query("SELECT id,phone FROM users WHERE phone='{$phone}'"); if (mysql_num_rows($query) > 0) { $row = mysql_fetch_array($query); $id = $row['id']; return $id;
setOrderCustomer($order, $customer); $order = createOrder(124, '1990-07-12', '1990-10-12', 'United Package', 100, 3, 200.44); $orders[] = $order; setCustomerOrder($customer, $order); setOrderCustomer($order, $customer); $customer = createCustomer('DUMON', '15b242e7-52eb-46bd-8f0e-6568b72cd9a6', 'Janine Labrune', null, 'France', 4); $customers[] = $customer; $order = createOrder(125, '1995-05-05', '1995-05-09', 'Federal Shipping', 100, 1, 800); $orders[] = $order; setCustomerOrder($customer, $order); setOrderCustomer($order, $customer); $order = createOrder(126, '1999-07-16', '1999-08-20', 'Speedy Express', 80, 2, 150); $orders[] = $order; setCustomerOrder($customer, $order); setOrderCustomer($order, $customer); $order = createOrder(126, '2008-08-16', '2009-08-22', 'United Package', 88, 6, 50); $orders[] = $order; setCustomerOrder($customer, $order); setOrderCustomer($order, $customer); $customer = createCustomer('EASTC', '15b242e7-52eb-46bd-8f0e-6568b72cd9a7', 'Ann Devon', createAddress('FF45', 15, 16, '35 King George', true, false), 'Germany', 3); $customers[] = $customer; print_r($customers); function createAddress($houseNumber, $lineNumber, $lineNumber2, $streetName, $isValid, $isPrimary) { $address = new Address4(); $address->Address2 = new Address2(); $address->Address2->IsPrimary = $isPrimary; $address->HouseNumber = $houseNumber; $address->IsValid = $isValid; $address->LineNumber = $lineNumber; $address->LineNumber2 = $lineNumber2;
function submitOrderToDB($iAmSeller = false) { global $db; $orderid = createOrder($iAmSeller); foreach (@$_SESSION['catering']['order']['products'] as $product) { if (checkAvailability($product['quantity'], $product['productid'], @$product['ingredients'])) { $product_DB = $db->selectOneRow("catering_products", '*', "`productid`=" . $product['productid']); $db->insert('catering_items', array('orderid', 'productid', 'amount', 'state', 'price'), array($orderid, $product['productid'], $product['quantity'], 0, $product_DB['price'])); $itemid = mysql_insert_id(); if (isset($product['ingredients'])) { foreach ($product['ingredients'] as $ingredientid) { $ingredient_DB = $db->selectOneRow("catering_ingredients", '*', "`ingredientid`=" . $ingredientid); $db->insert('catering_items_ingredients', array('itemid', 'ingredientid', 'price'), array($itemid, (int) $ingredientid, $ingredient_DB['price'])); } } } } unset($_SESSION['catering']); }
<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/Config/db.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/Config/settings.php'; switch ($_GET['act']) { case "create": echo createOrder(); break; } function createOrder() { $query = mysql_query("SELECT * FROM agent_sessions WHERE session = '" . $_POST['uid'] . "'"); $res = mysql_fetch_array($query); if ($res['session'] == null) { return 0; } $agentID = $res['user_id']; file_put_contents("./logs/orders/orders" . date('Ymdhis') . ".txt", $_POST['data']); $orders = json_decode($_POST['data']); foreach ($orders as $order) { if ($order->Photo != "") { $photo = uniqid() . '.png'; base64_to_jpeg(str_replace(" ", "+", str_replace("\n", "", $order->Photo)), $_SERVER['DOCUMENT_ROOT'] . '/Agents/Photos/' . $photo); } mysql_query("INSERT INTO agent_orders (customer_id, user_id, comment, photo, lat, lng) VALUES ('" . $order->CustomerID . "', '" . $agentID . "', '" . $order->Comment . "', '" . $photo . "', '" . $order->Lat . "', '" . $order->Lng . "')"); $orderID = mysql_insert_id(); foreach ($order->Cart as $cLine) { mysql_query("INSERT INTO agent_cart (order_id, product_id, quantity, price) VALUES ('" . $orderID . "', '" . $cLine->ProductID . "', '" . $cLine->Quant . "', '" . $cLine->Price . "') "); } } echo '1';
} //} if ($_GET['do'] == 1) { if ($istitle == 1) { $uptitle = ",goods_name='{$goods_name}'"; } $db->query("update {$ecs->table('goods')} set \r\n\t\t\t\tgoods_desc='{$content}',goods_thumb='{$imgArr[0]['thumb']}',goods_img='{$imgArr[0]['goods']}',original_img='{$imgArr[0]['source']}'{$uptitle} \r\n\t\t\t\twhere goods_id={$gid}"); foreach ($imgArr as $v) { $db->query("insert into {$ecs->table('goods_gallery')} (goods_id,img_url,thumb_url,img_original) value ({$gid},'{$v[goods]}','{$v[thumb]}','{$v[source]}')"); } if ($iscomment == 1 && $comment_list) { $t = time(); foreach ($comment_list as $k => $c) { $t = $t - 832 * $k; $db->query("insert into {$ecs->table('comment')} (id_value,content,comment_rank,add_time,user_name,status) \r\n\t\t\t\t\tvalue ({$gid},'{$c['feedback']}',5,'{$t}','{$c['nick']}',1)"); createOrder($gid, $t, $c['nick']); } } $link[] = array('href' => 'goods.php?act=edit&goods_id=' . $gid, 'text' => '继续编辑'); sys_msg('提取成功', 0, $link); } else { include_once ROOT_PATH . 'includes/fckeditor/fckeditor.php'; $smarty->assign('content', $content); $smarty->assign('img_list', $imgArr); $smarty->assign('id', $id); $smarty->assign('gid', $gid); $smarty->assign('istitle', $istitle); $smarty->assign('iscomment', $iscomment); $smarty->assign('goods_name', $goods_name); $smarty->assign('comment_list', $comment_list); $smarty->display('gettaobaogoodsview.html');
*/ // And we're away require_once "../app/Mage.php"; Mage::app(); // How many orders are we creating $num_orders = (int) $_GET["orders"]; // Get some random customer information $customers = getCustomers($num_orders); // Create a few orders for ($i = 1; $i <= $num_orders; $i++) { // Get random products $products = getProducts(); // Get a customer $customer = getCustomer(array_pop($customers)); // Order some mofo products for some mofo customer $order = createOrder($products, $customer); printf("Created order %s\n", $order->getIncrementId()); } /* * Get random customer information from fakester.biz * * @return array */ function getCustomers($num_customers) { $url = "http://fakester.biz/json?n={$num_customers}"; $json = file_get_contents($url); $data = json_decode($json); /* * Fakester return these fields for customers: *
<?php require 'bakery_tasks.php'; require 'AltoRouter.php'; $router = new AltoRouter(); $router->setBasePath('/assets/web'); $router->map('GET', '/ajax/orders', function () { getOrders(); }); $router->map('PUT', '/ajax/orders/edit/[i:id]', function () { $request_body = file_get_contents('php://input'); $data = json_decode($request_body, true); editOrders($data); }); $router->map('POST', '/ajax/orders/create', function () { $request_body = file_get_contents('php://input'); $data = json_decode($request_body, true); createOrder($data); }); $match = $router->match(); if ($match && is_callable($match['target'])) { call_user_func_array($match['target'], $match['params']); } else { echo 'hi'; }
return $result; } } return function (array $request) { $form = createCreateForm(); formHandleRequest($form, $request); $errors = []; $form['fields']['name']['value'] = trim(preg_replace('/(?|( )+|(\\n)+|(\\r\\n)+)/', '$1', $form['fields']['name']['value'])); $form['fields']['description']['value'] = trim(preg_replace('/(?|( )+|(\\n)+|(\\r\\n)+)/', '$1', $form['fields']['description']['value'])); if (formIsValid($form)) { $vars = extractValues($form); $name = htmlspecialchars($vars['name']); $description = htmlspecialchars($vars['description']); $userId = currentUser()['id']; $price = (int) ((double) $vars['price'] * 100); if ($id = createOrder($name, $description, $price, $userId)) { $user = currentUser(); queueNotify('order_top', ['id' => $id, 'title' => $name, 'description' => nl2br($description), 'price' => $price / 100, 'created_by' => ['id' => $user['id'], 'name' => $user['name']]]); return createResponse(json_encode(['id' => $id]), 200, ['content-type' => 'application/json']); } else { $errors = [['name' => 'price', 'errors' => ['Недостаточно средств на счете.']]]; } } else { foreach ($form['fields'] as $field) { if ($field['errors']) { $errors[] = ['name' => $field['name'], 'errors' => $field['errors']]; } } } return createResponse(json_encode($errors), 400, ['content-type' => 'application/json']); };
createProduct($app); } createProduct($app, '規格なし商品', 0); } $Customers = $app['orm.em']->getRepository('Eccube\\Entity\\Customer')->findAll(); $Products = $app['orm.em']->getRepository('Eccube\\Entity\\Product')->findAll(); $Deliveries = $app['orm.em']->getRepository('Eccube\\Entity\\Delivery')->findAll(); foreach ($Customers as $Customer) { $Delivery = $Deliveries[$faker->numberBetween(0, count($Deliveries) - 1)]; $Product = $Products[$faker->numberBetween(0, count($Products) - 1)]; $charge = $faker->randomNumber(4); $discount = $faker->randomNumber(4); for ($i = 0; $i < $config['fixture_order_num']; $i++) { $Status = $app['eccube.repository.order_status']->find($faker->numberBetween(1, 8)); $OrderDate = $faker->dateTimeThisYear(); createOrder($app, $Customer, $Product->getProductClasses()->toArray(), $Delivery, $charge, $discount, $Status, $OrderDate); } } function createCustomer($app, $email = null, $active = true) { $Customer = $app['eccube.fixture.generator']->createCustomer($email); if ($active) { $Status = $app['orm.em']->getRepository('Eccube\\Entity\\Master\\CustomerStatus')->find(CustomerStatus::ACTIVE); } else { $Status = $app['orm.em']->getRepository('Eccube\\Entity\\Master\\CustomerStatus')->find(CustomerStatus::NONACTIVE); } $Customer->setStatus($Status); $app['orm.em']->flush($Customer); return $Customer; } function createProduct($app, $product_name = null, $product_class_num = 3)