<?php
$this->load->view ( $left );
$this->load->view ( $header );
?>
<?php //  echo "<pre>";  print_r($order_list); //echo $order_data->item_id; // 0000-00-00 // print_r($order_data); ?>

<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-sm-4">
        <h2>Order List</h2>
    </div>
    <div class="col-sm-8">
        <div class="title-action">
            <a href="<?php echo site_url("order/neworder");?>" class="btn btn-primary addNewUser">
                <i class="fa fa-plus-square-o"></i>
                <span class="m-l-xs">New Order</span>
            </a>
        </div>
    </div>
</div>
<div class="wrapper wrapper-content">
    <div class="row text-center animated fadeInRightBig">
        <table class="table" id="myTable">
        	<thead>
        		<tr>
        			<th>Order Id</th>
                    <th>Parent Order Id</th>
        			<th>Worker Name</th>
                    <th>Item</th>
                    <th>Metal</th>
                    <th>Qty</th>
                    <th>Status</th>
                    <th>Date Assign</th>
        			<th>Action</th>
        		</tr>
        	</thead>
            <tbody>
                <?php if (count($order_list) > 0) {
                    foreach ($order_list as $key_user => $order_d) {?>
                        <tr>
                           <td><?php echo !empty($order_d->order_id) ? $order_d->order_id : '';?></td>
                           <td><?php echo !empty($order_d->parent_order_id) ? $order_d->parent_order_id : '';?></td>
                           <td><?php echo !empty($order_d->name) ? $order_d->name : ''; ?></td>
                           <td><?php echo !empty($order_d->item_name) ? $order_d->item_name : '';?></td>
                           <td><?php echo !empty($order_d->metal) ? $order_d->metal : '';?></td>
                           <td><?php echo !empty($order_d->qty) ? $order_d->qty : '';?></td>
                           <td><?php echo !empty($order_d->status_name) ? $order_d->status_name : '';?></td>
                           <td><?php echo !empty($order_d->date_added) ? $order_d->date_added : '';?></td>
                           <td><?php if($order_d->status_name=="Complete"){ ?><a href="<?php echo site_url('order/neworder/'.$order_d->order_id);?>"><i class="fa fa-edit"></i> <span class="nav-label">View</span></a><?php }else{ ?><a href="<?php echo site_url('order/neworder/'.$order_d->order_id);?>"><i class="fa fa-edit"></i> <span class="nav-label">Update</span></a> <?php } ?></td>
                        </tr>
                <?php }
                }?>
            </tbody>
        </table>
    </div>
</div>
<?php $this->load->view($footer); ?>
<script type="text/javascript" language="javascript" src="//code.jquery.com/jquery-1.12.4.js"></script>
    <script src="//cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
    <script src="//cdn.datatables.net/buttons/1.5.1/js/dataTables.buttons.min.js"></script> 	
	<script src="//cdn.datatables.net/buttons/1.5.1/js/buttons.flash.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script> 
	<script src="//cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
	<script src="//cdn.datatables.net/buttons/1.5.1/js/buttons.html5.min.js"></script> 
    <script src="//cdn.datatables.net/buttons/1.5.1/js/buttons.print.min.js"></script>

<script type="text/javascript">
	var jq = jQuery.noConflict();

	jq(document).ready(function() {
	jq('#myTable').DataTable( {
			dom: 'Bfrtip',
			buttons: [
				'copy', 'csv', 'excel', 'pdf', 'print'
			]
		} );
	} );

</script>	