<?php require view('theme/header'); 

        $extra_sql = "";

		$status_list = [

			"completed" => "Completed",

			"canceled" => "Canceled",

			"partial" => "Partial",

			"pending" => "Pending",

			"inprogress" => "In progress",

			"processing" => "Processing"

		];

		if(isset($_url[1]) && url(1) != null) {

			if(array_key_exists(url(1), $status_list)) {

				$extra_sql = "AND order_status = '".$status_list[url(1)]."'";

			}

		}

		$title = "{ORDERS_PAGE_TITLE}";



		$orders = $db->from('orders')

		->join('services', 'services.service_id = orders.service_id')

		->where('orders.user_id', session('user_id'))

		->orderby('order_id', 'DESC')

		->all();
		
		$service_name2 = json_decode($order["service_name"], true);

			foreach($service_name as $details) {

				if($details["lang"] == 1) {

					$name2 = $details["name"];

				}

				if($details["lang"] == $lang) {

					$name2 = $details["name"];

					break;

				}

			}
		
?>
<link rel="stylesheet" href="//cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css">
<div class="container-fluid">
	<div class="row">
		<div class="col-md-12">
		 
			
			<div class="well do" style="overflow-x:scroll;">
				<table id="datable" class="table table-hover">
					<thead>
						<tr>
							<th>#</th>
							<th>{ORDERS_DATE}</th>
							<th>{ORDERS_LINK}</th>
							<th>{ORDERS_AMOUNT}</th>
							<th>{ORDERS_START_COUNT}</th>
							<th>{ORDERS_QUANTITY}</th>
							<th>{ORDERS_SERVICE}</th>
							<th>{ORDERS_STATUS}</th>
							<th>{ORDERS_REMAINS}</th>
							<th></th>
						</tr>
					</thead>
					<tbody>
						{ORDERS_LIST}
					</tbody>
				</table>
			</div>
			
		</div>
	</div>
</div>
<div id="serviceModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-body text-center" style="color:crimson;font-weight:bold;" id="modalContent"></div>
      <div class="modal-footer">
        <button type="button" style="width:100%;" class="btn btn-default" data-dismiss="modal">Kapat</button>
      </div>
    </div>

  </div>
</div>

<div id="linkModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-body text-center" style="color:crimson;font-weight:bold;" id="modalContent2"></div>
      <div class="modal-footer">
        <button type="button" style="width:100%;" class="btn btn-default" data-dismiss="modal">Kapat</button>
      </div>
    </div>

  </div>
</div>

<?php require view('theme/footer'); ?>
	<script src="//cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script>
	<script>
		$(document).ready( function () {
    $('#datable').DataTable({

          "order": [[ 0, "desc" ]],
          "bInfo": false,
              createdRow: function (row, data, index) {

        if (data[1] == "") {
            console.dir(row);
            $(row).addClass('app-block');
        }
    }
    });
} );
	</script>