<?php
include('accesscheck2.php');
require_once('Connections/courier.php');
require_once 'functions/functions.php';
mysql_select_db($database_courier, $courier);

if (!function_exists("GetSQLValueString")) {

    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") {
        if (PHP_VERSION < 6) {
            $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
        }

        $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

        switch ($theType) {
            case "text":
                $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                break;
            case "long":
            case "int":
                $theValue = ($theValue != "") ? intval($theValue) : "NULL";
                break;
            case "double":
                $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
                break;
            case "date":
                $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
                break;
            case "defined":
                $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
                break;
        }
        return $theValue;
    }

}

if(empty($id)){
    $id = $_POST['id'];
}
$sql = mysql_query("SELECT *, date_format(date_of_order,'%a, %e %M %Y') as purchase_order_date, date_format(expected_date,'%e %M %Y') as purchase_expected_date FROM requisition_orders WHERE purchase_order_no = '$id'", $courier) or die(mysql_error());
$patient_row = mysql_fetch_assoc($sql);?>


<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <i class="icon-home"></i>
            <a href="index.html">Home</a>
            <i class="fa fa-angle-right"></i>
        </li>
        <li>
            <span>Dashboard</span>
        </li>
    </ul>
    <div class="page-toolbar">
        <div class="btn-group pull-right">
            <button type="button" class="btn btn-fit-height grey-salt dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true"> Actions
                <i class="fa fa-angle-down"></i>
            </button>
            <ul class="dropdown-menu pull-right" role="menu">
                <li onclick="getstep('<?php echo $action; ?>','<?php echo $id; ?>');">
                    <a href="#">
                        <i class="icon-refresh"></i> Refresh
                    </a>
                </li>
            </ul>
        </div>
    </div>
</div>

<form name="form" id="" action="">
<div class="row">
    <div class="col-lg-12 col-md-12 col-xs-12 col-sm-12">
        <div class="col-md-5">
            <div class="row">
                <div class="portlet light">
                    <div class="portlet-title">
                        <div class="caption">
                            <input type="text" name="searchtext_query_item_name" onkeyup="MainsearchItemsName('search_items_special_orders','#view_items_response_wrapper',this.value);" class="form-control input-circle" placeholder="Item Name">
                            <input type="hidden" name="purchase_order_id" value="<?php echo $id; ?>">
                        </div>
                        <div class="actions">
                            <select name="search_by" id="search_by" class="form-control input-circle">
                                <option value="contains">Contains</option>
                                <option value="begins">Begins</option>
                            </select>
                        </div>
                    </div>
                    <div class="portlet-body" id="">
                        <div style="height: 500px;overflow-y: scroll;overflow-x: hidden;">
                            <div class="" id="view_items_response_wrapper"> 
                                <?php include 'special_order_search_items.php'; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-7" id="view_items_response_wrapper_2">
            <?php include 'special_orders_items_added.php'; ?>
        </div>
    </div>
</div>
</form>