<?php

$preload_files = 'modules/products/classes/products.class.php';
require_once '../../Group-Office.php';
require_once 'classes/products.class.php';
$pro = new products();
$order_id = $_REQUEST['order_id'];
$pro->get_entire_order($order_id, $order);
$to = $order['company'];
$attn = $order['attn'];
$cc = '';
$fax = $order['fax'];
$tel = $order['phone'];
$subj = '';
$effective = $order['sale_date'];
$quotation = $order['valid_date'];
$row_count = 0;
// initial value
while ($pro->next_record()) {
    $apid = $pro->f('product_id');
    $acate = $pro->f('attach_cate_id');
    $order_attach_arr[$apid . $acate] = $pro->f('attach_id');
    $order_price_arr[$apid . $acate] = $pro->f('price');
    $order_quantity_arr[$apid . $acate] = $pro->f('quantity');
}
$pro_order = new products();
$list_id = $pro_order->get_order_productid_list($order_id);
$pro_order->get_buy_products($list_id);
$i = 0;
$ptotal = 0;
$attach_cate = new products();
     if ($_SESSION['cart']->itemcount() == 0) {
         goURL('index.php');
     }
     $pitems = $_SESSION['cart']->items;
     $pro->get_buy_products($_SESSION['cart']->get_productid_list());
     require 'templates/edit_order.tmp.php';
     break;
 case 'delete_detail':
     if ($pro->delete_product_from_order($_POST['order_number'], $_POST['txt_id'])) {
         $pro->get_orders();
         require 'templates/list_order.tmp.php';
         break;
     }
     $_POST['id'] = $_POST['order_number'];
 case 'edit':
     $pro->get_entire_order($_POST['id'], $order);
     while ($pro->next_record()) {
         $apid = $pro->f('product_id');
         $acate = $pro->f('attach_cate_id');
         $order_attach_arr[$apid . $acate] = $pro->f('attach_id');
         $order_price_arr[$apid . $acate] = $pro->f('price');
         $order_quantity_arr[$apid . $acate] = $pro->f('quantity');
         $order_discount_arr[$apid . $acate] = $pro->f('discount');
         $order_VAT_arr[$apid . $acate] = $pro->f('VAT');
     }
     $pro_order = new products();
     $list_id = $pro_order->get_order_productid_list($_POST['id']);
     $pro_order->get_buy_products($list_id);
     require 'templates/edit_update_order.tmp.php';
     break;
 case 'search':