<?php 
	$header_file=APPPATH.'views/include/header.php';
	require($header_file);
?>
<style>
    table{
        width: 100%!important;
    }
    table.dataTable thead th, table.dataTable thead td {
        padding: 5px 0px!important;
      /* border-bottom: 1px solid #111; */
    }
    
 /*   @media only screen and (max-width: 800px) {
      th:nth-child(1),td:nth-child(1) {
        display:none;
      }
      th:nth-child(3),td:nth-child(3) {
        display:none;
      }
      th:nth-child(5),td:nth-child(5) {
        display:none;
      }
      th:nth-child(6),td:nth-child(6) {
        display:none;
      }
      th:nth-child(7),td:nth-child(7) {
        display:none;
      }
      th:nth-child(8),td:nth-child(8) {
        display:none;
      }
      th:nth-child(10),td:nth-child(10) {
        display:none;
      }
    } */
</style>
    <!-- BEGIN: Content-->
    <div class="app-content content">
      <div class="content-overlay"></div>
      <div class="content-wrapper">
        <div class="content-header row">
          <div class="content-header-left col-md-12 col-12 mb-2 breadcrumb-new">
            <h3 class="content-header-title mb-0 d-inline-block">Request List</h3>
            <div class="row breadcrumbs-top d-inline-block">
              <div class="breadcrumb-wrapper col-12">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item"><a href="#">Home</a>
                  </li>
                  <li class="breadcrumb-item"><a href="#">Material Request</a>
                  </li>
                  <li class="breadcrumb-item active">Request List
                  </li>
                </ol>
              </div>
            </div>
          </div>
        
        </div>
        <div class="content-body"><!-- Zero configuration table -->
<section id="configuration">
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-content collapse show">
                    <div class="card-body card-dashboard">
                        <div class="table-responsive">
						  <!--  <table class="table table-bordered dataex-html5-export">-->
						  <?php
						  $isMob = is_numeric(strpos(strtolower($_SERVER["HTTP_USER_AGENT"]), "mobile"));
						  if($isMob){
						  ?>
						  <table class="table dataex-html5-export">
                                <thead>
                                    <tr>
                                    	<th>Request No</th>
										<th>Store</th>
										<th>Add Inward</th>
									</tr>
                                </thead>
                                <tbody>
								 <?php
									foreach($req_list as $rlist)
									{
								?>
                                    <tr>
                                    	<td><?php echo $rlist->mat_req_no; ?></td>
									    <td><?php echo $rlist->store; ?></td>
										<td class="uk-text-nowrap">
										<?php if($rlist->store == 'Pride Bakers' && $rlist->status == 'Approved') { ?>
										
											<a href="<?php echo site_url('MaterialRequest/prideInward/'. $rlist->request_id); ?>" class="btn btn-sm btn-success"> View</a>
										<?php } else if($rlist->store == 'Pride Bakers' && $rlist->status == 'Pending') { ?>
											<a href="#"id="view" name="view" class="btn btn-sm btn-danger disabled">View</a>
										<?php } else { ?>
											<a href="<?php echo site_url('MaterialRequest/requestIssueList/'. $rlist->request_id); ?>" class="btn btn-sm btn-warning"> View</a>
										<?php } ?>
									</td>
								</tr>
                                <?php
								}
							?>
                            </table>
                            <?php } else { ?>
                            <table class="table dataex-html5-export">
                                <thead>
                                    <tr>
                                    	
                                    	<th>Sl No</th>
                                        <th>Request No</th>
										<th>Request Date</th>
										<th>Store Name</th>
										<th>Status</th>
										<th>Approved date</th>
										<th>Edit REQ</th>
										<th style="width: 93.688px!important;">Remarks By Store</th>
										<th style="width: 93.688px!important;">View Issues/Add Receipt</th>
										<th>View REQ</th>
									</tr>
                                </thead>
                                <tbody>
								 <?php
									$count =1;
									foreach($req_list as $rlist)
									{
								?>
                                    <tr>
                                    	<td><?php echo $count; ?></td>
									<td><?php echo $rlist->mat_req_no; ?></td>
									<td><?php echo $rlist->request_date; ?></td>
									<td><?php echo $rlist->store; ?></td>
									<?php 
										$req_id = $rlist->request_id;
										$q1 = $this->db->query("SELECT *,DATE_FORMAT(M.request_date, '%d-%m-%Y') as request_date,DATE_FORMAT(I.issue_date, '%d-%m-%Y') as issue_date FROM material_request M inner join issues_order_creation I on M.request_id=I.request_id where I.request_id='$req_id'");
										$req_res = $q1->result();
										$req_count1 = 0;
										$req_count2 = 0;
										foreach($req_res as $req_row)
										{
											if(($req_row->issue_status == 'Accepted'))
											{	
												$req_count1++;	
											}
											$req_count2++;
										}
									?>
									<?php
										if($req_count1 == $req_count2) {
										?>
										<td class="pending_data"><?php echo $rlist->receipt_status; ?></td>
										<?php
											} else {
										?>	
										<td class="success_data"><?php echo $rlist->receipt_status; ?></td>
										<?php
										}
									?>
									<td><?php echo $rlist->approval_date; ?></td>
									<td>
										<?php
											if($rlist->status == 'Pending' && $rlist->store == 'Pride Bakers') {
										?>
										 	<a href="<?php echo site_url('MaterialRequest/editRequest/'. $rlist->request_id); ?>" id="view" name="view" class="btn btn-sm btn-info ">Edit</a></td>
										<?php
											} else if($rlist->status == 'Approved') {
										?>	
											<a href="#"id="view" name="view" class="btn btn-sm btn-secondary disabled">Edit</a>
										<?php
											} else if($rlist->status == 'Closed') {
										?>	
											<a href="#"id="view" name="view" class="btn btn-sm btn-secondary disabled">Edit</a>
										<?php
											} else if($rlist->status == 'Pending' && $rlist->store == 'Cakewala') {
										?>	
										<a href="#"id="view" name="view" class="btn btn-sm btn-secondary disabled">Edit</a>
										<?php
											}
										?>
									</td>
									<td><?php echo $rlist->remark; ?></td>
									<td class="uk-text-nowrap">
										<?php if($rlist->store == 'Pride Bakers' && $rlist->status == 'Approved') { ?>
										
											<a href="<?php echo site_url('MaterialRequest/prideInward/'. $rlist->request_id); ?>" class="btn btn-sm btn-success"> View</a>
										<?php } else if($rlist->store == 'Pride Bakers' && $rlist->status == 'Pending') { ?>
											<a href="#"id="view" name="view" class="btn btn-sm btn-danger disabled">View</a>
										<?php } else { ?>
											<a href="<?php echo site_url('MaterialRequest/requestIssueList/'. $rlist->request_id); ?>" class="btn btn-sm btn-warning"> View</a>
										<?php } ?>
									</td>
									<td class="uk-text-nowrap">
										<a href="<?php echo site_url('MaterialRequest/reqView/'. $rlist->request_id); ?>" class=""> <i class='ft-eye'></i></a>
									</td>
								</tr>
                                    
                                   <?php
								  $count++;
								}
							  
							?>
                            </table>
                            <?php } ?>
						</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<!--/ Zero configuration table -->



<!--/ Language - Comma decimal place table -->

        </div>
      </div>
    </div>
    <!-- END: Content-->

   <?php //require('include/theme_customizer.php');?>
 <?php 
  $footer_file=APPPATH.'views/include/footer.php';
	require($footer_file);
	?>
<script>
	$('.param_check').each(function() { $(this).on( {'click contextmenu': function() {
		//contextmenu
		var i = $(this).data('value');
		var anchor = $("a");
		var anchorTarget = $(this).parent().find('.parmetre').val();
		var submodid = $(this).parent().find('.submod_id').val();
		var link = $(this).attr('href');
		$(this).attr("href", link + submodid +'/'+anchorTarget);

		location.reload();
	}
	})
	})
</script>  
  </body>
  <!-- END: Body-->

<!-- Mirrored from pixinvent.com/modern-admin-clean-bootstrap-4-dashboard-html-template/html/ltr/vertical-modern-menu-template/form-layout-basic.html by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Apr 2020 09:38:02 GMT -->
</html>