$hn_product = 'Product';
$hn_article = 'Articles';
$hn_custock = 'Current<br />Stock';
$hn_cbooked = 'Total Booked<br />in Active Orders';
$hn_cbohere = 'Already Booked<br />in This Order';
$hn_bookqty = 'Add / Remove (-)<br />Book Quantity';
$product_table_header = array();
$product_table_header['0 w080 tac'] = $hn_product;
$product_table_header['1 w150 tac'] = $hn_article;
$product_table_header['2 w150 tac'] = $hn_custock;
$product_table_header['3 w150 tac'] = $hn_cbooked;
$product_table_header['4 w150 tac'] = $hn_cbohere;
$product_table_header['5 w150 tac'] = $hn_bookqty;
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'LOADEXISTINGORDERS') {
        $existingorders = stock_booking::getOpenBookingOrders('NAME');
        if (count($existingorders) == 0) {
            $result = 'NONE';
        } else {
            $result = '<h3>Use Existing Order</h3>';
            $result .= '<div><select id="booking_existing" class="input2">' . loadComboListFromArray($existingorders) . '</select></div>';
            $result .= '<div><input id="btn-selectorder" type="button" value="Use Selected Order" /></div>';
        }
        echo utf8_encode($result);
        exit;
    } elseif ($_POST['me_action'] == 'CREATENEWORDER') {
        $name = tep_db_prepare_input($_POST['booking_name']);
        $status = tep_db_prepare_input($_POST['booking_status']);
        $booking = new stock_booking();
        $booking->create($name, $status);
        echo utf8_encode($booking->id);
$hn_name = 'Order Name';
$hn_date = 'Date<br />Created';
$hn_prod = 'Total<br />Articles';
$hn_qtys = 'Total<br />Quantity';
$hn_stat = 'Status';
$product_table_header = array();
$product_table_header['0 id'] = $hn_no;
$product_table_header['1 date'] = $hn_date;
$product_table_header['2 desc'] = $hn_name;
$product_table_header['3 countpro'] = $hn_prod;
$product_table_header['4 countpro'] = $hn_qtys;
$product_table_header['5 countpro'] = $hn_stat;
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'LOADTABLE') {
        $result = '';
        $booking_orders = stock_booking::getOpenBookingOrders('OBJECT');
        $table_data = array();
        $table_data[] = $product_table_header;
        $counter = 0;
        foreach ($booking_orders as $bo) {
            $counter++;
            $td = array();
            foreach ($product_table_header as $k => $v) {
                switch ($v) {
                    case $hn_no:
                        $value = $counter;
                        break;
                    case $hn_name:
                        $value = '<a href="?open=products-stock-booking-detail&amp;id=' . $bo->id . '&amp;hidemenu=true" class="view_webpage">' . $bo->name . '</a>';
                        break;
                    case $hn_date: