<h1 class="page-title"> Order Details </h1>
<div class="row">
	<div class="col-md-12">
		<div class="portlet box blue-hoki">
			<div class="portlet-title">
				<div class="caption">
					<i class="fa fa-cogs"></i><strong>Order : <?php echo getPOData($po_id, "order_no"); ?></strong> 
				</div>
			</div>
			<div class="portlet-body">
				<div class="tabbable-line">
					<ul class="nav nav-tabs nav-tabs-lg">
						<li class="active">
							<a href="#buyer" data-toggle="tab" aria-expanded="true"> Buyer & Forwarder </a>
						</li>
						<li>
							<a href="#seller" data-toggle="tab" aria-expanded="false"> Seller </a>
						</li>
						<li>
							<a href="#items" data-toggle="tab" aria-expanded="false"> Items </a>
						</li>
					</ul>
					<div class="tab-content form">
						<div class="tab-pane fade active in" id="buyer">
							<div class="form-horizontal">
								<div class="form-body">
									<h3 class="form-section">Buyer Details</h3>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Order No :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "order_no"); ?> </p>
												</div>
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Marking :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "marking"); ?> </p>
												</div>
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Company Name :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "company_name"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Purchase No :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "purchase_no"); ?> </p>
												</div>
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Company Address :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "company_address"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Tax No :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "company_tax_no"); ?> </p>
												</div>
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Company City :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "company_city"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Order Type :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo (checkSOExist($po_id) ? "PO & SO"  : "PO"); ?> </p>
												</div>
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Company Zip :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "company_zip"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Order Created :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "created_on"); ?> </p>
												</div>
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Company State :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "company_zip"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Contact Person :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "company_contact_person"); ?> </p>
												</div>
											</div>
										</div>
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Contact Person No :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "company_contact_person_no"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<h3 class="form-section">Forwarder Details</h3>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Company Name :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getCompanyData(getPOData($po_id, "forwarder_id"),"company_id", "name"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Office No :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getCompanyData(getPOData($po_id, "forwarder_id"),"company_id", "company_no"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Office Fax :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getCompanyData(getPOData($po_id, "forwarder_id"),"company_id", "company_fax"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Contact Person :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getCompanyData(getPOData($po_id, "forwarder_id"),"company_id", "contact_person"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Contact Person No :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getCompanyData(getPOData($po_id, "forwarder_id"),"company_id", "contact_person_no"); ?> </p>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="tab-pane fade" id="seller">
							<div class="form-horizontal">
								<div class="form-body">
									<h3 class="form-section">Supplier Details</h3>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Supplier Company Name :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "supplier_company_name"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Supplier Contact Person :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "supplier_contact_person"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Supplier Contact Person No :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "supplier_contact_person_no"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<h3 class="form-section">Bank Details</h3>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Bank Name :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "bank_name"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Bank Address :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "bank_address"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Account Number :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "bank_acc_no"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Swift Code :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "bank_swiftcode"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4">Currency :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo getPOData($po_id, "order_currency"); ?> </p>
												</div>
											</div>
										</div>
									</div>
									<?php $order_remarks = json_decode(getPOData($po_id, "order_remark"), true); ?>
									<?php foreach($order_remarks as $key => $order_remark){ ?>
									<div class="row">
										<div class="col-md-6">
											<div class="form-group">
												<label class="control-label col-md-4"><?php echo $order_remark['form_name']; ?> :</label>
												<div class="col-md-8">
													<p class="form-control-static"> <?php echo $order_remark['form_value']; ?> </p>
												</div>
											</div>
										</div>
									</div>
									<?php } ?>
								</div>
							</div>
							<!--<p class="form-control-static"> <?php echo  number_format((float)getPOTotal($po_id), 2, '.', '') ." (".getPOData($po_id,"order_currency") . ")" ; ?> </p>-->
						</div>
						<div class="tab-pane fade" id="items">
							<h3 class="form-section">Purchase Order Items</h3>
							<div class="form-horizontal">
								<table class="table table-striped table-hover table-bordered dataTable">
									<thead>
										<th> No   		 </th>
										<th> Product Name</th>
										<th> Item Code   </th>
										<th> Model No    </th>
										<th> Description </th>
										<th> Quantity    </th>
										<th> UOM         </th>
										<th> Unit Price  </th>
										<th> Sub Total   </th>
									</thead>
									<tbody>
										<?php $POItems = getPOItems($po_id); $x = 1;?>
										<?php foreach($POItems as $key => $POItem){ ?>
										<tr>
											<td><?php echo $x; ?></td>
											<td><?php echo $POItem['product_name']; ?></td>
											<td><?php echo $POItem['item_code']; ?></td>
											<td><?php echo $POItem['model_no']; ?></td>
											<td><?php echo $POItem['description']; ?></td>
											<td><?php echo $POItem['quantity']; ?></td>
											<td><?php echo $POItem['uom']; ?></td>
											<td><?php echo $POItem['unit_price']; ?></td>
											<td><?php echo  number_format((float)$POItem['subtotal'], 2, '.', '') ." (".getPOData($po_id,"order_currency") . ")"; ?></td>
										</tr>
										<?php $x++; ?>
										<?php } ?>
									</tbody>
								</table>
								<div class="row">
									<div class="col-md-6">
										<div class="form-group">
											<label class="control-label col-md-3">Remark :</label>
											<div class="col-md-9">
												<p class="form-control-static"> <?php echo getPOData($po_id, "item_remark"); ?> </p>
											</div>
										</div>
									</div>
									<div class="col-md-6">
										<div class="well">
											<div class="row static-info align-reverse">
												<div class="col-md-3 name"> Total : </div>
												<div class="col-md-8 value"> <?php echo  number_format((float)getPOTotal($po_id), 2, '.', '') ." (".getPOData($po_id,"order_currency") . ")" ; ?> </div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>