<?php 
	$header_file=APPPATH.'views/include/header.php';
	require($header_file);
	
	?>

    <!-- 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">Issue 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="#">Product Request</a>
                  </li>
                  <li class="breadcrumb-item active">Issue 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-header">
                    <h4 class="card-title">Request List</h4>
                    <a class="heading-elements-toggle"><i class="la la-ellipsis-v font-medium-3"></i></a>
                    <div class="heading-elements">
                        <ul class="list-inline mb-0">
                            <li><a data-action="collapse"><i class="ft-minus"></i></a></li>
                            <li><a data-action="reload"><i class="ft-rotate-cw"></i></a></li>
                            <li><a data-action="expand"><i class="ft-maximize"></i></a></li>
                            <li><a data-action="close"><i class="ft-x"></i></a></li>
                        </ul>
                    </div>
                </div>-->
                <div class="card-content collapse show">
                    <div class="card-body card-dashboard">
                        <form method="post" autocomplete="off" action="<?php echo site_url('ProductRequest/searchAccissueList/');?>" method="POST">
                          <div class="row justify-content-md-center">
              
                            <div class="col-md-3">
                              <div class="form-group">
                                <input class="form-control pickadate datepicker picker__input picker__input--active" type="text" name="from_date"  id="uk_dp_1" required data-uk-datepicker="{format:'DD-MM-YYYY'}" placeholder="From Date">
                              </div>
                            </div>
                            
                            <div class="col-md-3">
                              <div class="form-group">
                                <input class="form-control pickadate datepicker picker__input picker__input--active" type="text" name="to_date"  id="uk_dp_1" required data-uk-datepicker="{format:'DD-MM-YYYY'}" placeholder="To Date">
                                </div>
                            </div>  
                            <div class="col-md-2">
                              <div class="form-group">
                                <select id="kitchen" name="kitchen" class="form-control select2" >
                                  <option value="">Kitchen</option>
                                  <?php  /* foreach($kitchen as $row)
                                    {*/
                                  ?>
                                  <!--  <option value="<?php //echo $row->branch_name; ?>"><?php //echo $row->username; ?></option>-->
                                  <?php
                                 /*   } */
                                  ?>
                                  <?php
                                    $branch_name = $_SESSION['branch_name'];
                                    if($branch_name == 'CW4_ACC'){ ?>
                                        <option value="CMS">Commissary</option>
    									<option value="CW3-CK">CK_CW3</option>
    									<option value="CW-SK">Specialty Kitchen</option>
    									<option value="CW-DCK">Dry Cake Kitchen</option>
    									<option value="CW4-SK">CW4-SK</option>
    									<option value="CW4-CLD">Cold Kitchen</option>
    								    <option value="CW4-SK">CW4-Specialty Kitchen</option>
                                    <?php     
                                    }else if($branch_name == 'CW5-ACC'){ ?>
                                        <option value="CMS">Commissary</option>
    									<option value="CW3-CK">CK_CW3</option>
    									<option value="CW-SK">Specialty Kitchen</option>
    									<option value="CW-DCK">Dry Cake Kitchen</option>
    									<option value="CW4-SK">CW4-SK</option>
    									<option value="CW4-CLD">Cold Kitchen</option>
								        <option value="CW4-SK">CW4-Specialty Kitchen</option>
                                    <?php
                                    }else{
                                        ?>
                                        <option value="CMS">Commissary</option>
    									<option value="CW3-CK">CK_CW3</option>
    									<option value="CW-SVR">Savories Kitchen</option>
    									<option value="CW-FFK">First Floor Kitchen</option>
    								    <option value="CW-SK">Specialty Kitchen</option>
    								    <option value="CW-DCK">Dry Cake Kitchen</option>
                                    <?php    
                                    }
                                  ?>
                                </select>
                              </div>
                            </div>
                            <div class="col-md-2">
                              <div class="form-group">
                                <select id="counter" name="counter" class="form-control select2" >
                                  <option value="">Counter</option>
                                  <?php  /*foreach($counter as $crow)
                                    {
                                  ?>
                                    <option value="<?php echo $crow->username; ?>"><?php echo $crow->username; ?></option>
                                  <?php
                                    } */
                                  ?>
                                  <?php
                                  $branch_name = $_SESSION['branch_name'];
                                    if($branch_name == 'CW4_ACC'){ ?>
                                       
    									<option value="CW4-Counter">CW4-Counter</option>
    									
                                    <?php     
                                    }else if($branch_name == 'CW5-ACC'){ ?>
                                        <option value="CW5-Counter">CW5-Counter</option>
    									
                                    <?php
                                    }else{
                                        ?>
                                          <option value="">Select Counter</option>
        									<option value="counter">Counter</option>
        									<option value="CW2-Counter">CW2-Counter</option>
        									<option value="cw3-counter">Counter3</option>
        									<option value="Store">Store</option>
        									<option value="Namma Bakery">Namma Bakery</option>
        									<option value="CW4-Counter">CW4-Counter</option>
        									<option value="CW5-Counter">CW5-Counter</option>
        						<?php    
                                    }
                                  ?>
                                </select>
                              </div>
                            </div>
                            <div class="col-md-2">
                              <div class="form-group">
                                <input type="submit" name="submit" class="btn btn-primary" value="Issue Report">
                              </div>
                            </div>
                          
                        </div>
                        </form>
                        
                        <div class="table-responsive">
                            <?php 
          if(isset($_POST['submit'])) {
            if($_POST['from_date']!="" && $_POST['to_date']!="" && $_POST['kitchen']!=""){
            ?>
						    <table class="table table-striped table-bordered dataex-html5-export">
                                <thead>
                                    <tr>
                                        <th>Sl No</th>
                                        <th>Request No</th>
                                     	<th>Request Date</th>
    									<th>Issues No</th>
    									<th>Issues Date</th>
    									<th>Issues Time</th>
    									<th>Outlet</th>
    									<th>Basic</th>
    									<th>Tax</th>
    									<th>Total</th>
    									<th>View</th>
									</tr>
                                </thead>
                                <tbody>
                    <?php if(isset($result_display) && is_array($result_display) && count($result_display)) : $i=1;
                        foreach($result_display as $data){ ?>
                        <tr>
                            <td><?php echo $i; ?></td>
                          <td><?php echo $data->pr_req_no; ?></td>
                          <td><?php echo $data->request_date; ?></td>
                          <td><?php echo $data->issue_no; ?></td>
                          <td><?php echo $data->issue_date; ?></td>
                          <td><?php echo $data->issue_time; ?></td>
                          <td><?php echo $data->outlet; ?></td>
                          <?php
                            $iss_id = $data->issue_id;
						    $q1 = $this->db->query("SELECT * FROM product_request R inner join product_request_item RI on R.request_id=RI.request_id inner join product_issues_item PI on RI.request_item_id=PI.request_item_id where PI.issue_id='$iss_id' and PI.issued_qty !=''");
						    $rs3 = $q1->result();
						    $tot_amt = 0;
						    $tot_tax_amt = 0;
						    $tot_basic = 0;
    						foreach($rs3 as $row3)
    						{
    							$tot_amt = $tot_amt + $row3->total_price;
								$tot_tax_amt = $tot_tax_amt + $row3->tax_amount;
								$tot_basic = $tot_basic + $row3->basic_price;
    						}
                          ?>
                          <td><?php echo round($tot_basic,2); ?></td>
                          <td><?php echo round($tot_tax_amt,2); ?></td>
                          <td><?php echo round($tot_amt); ?></td>
                          <td class="uk-text-nowrap">
                            <a target="_blank" href="<?php echo site_url('ProductRequest/accissueView/'. $data->issue_id); ?>" class="btn btn-sm btn-info">View</a>
                           
                          </td>
                        </tr>
                        <?php
                        }
                      
                    ?>
                    <?php else:
                ?>
                <tr>
                  <td colspan="3" align="center" >No Records Found..</td>
                </tr>
                <?php
                  endif;
                ?>
                  </tbody>    
                                 
                            </table>
                            <?php 
            }
            else{
              echo "Please Enter the Data";
            }
          }
          else
          {
          ?>
          <table class="table table-striped table-bordered dataex-html5-export">
                <thead>
                    <tr>
                        <th>Sl No</th>
                        <th>Request No</th>
						<th>Request Date</th>
						<th>Issues No</th>
						<th>Issues Date</th>
						<th>Issues Time</th>
						<th>Outlet</th>
						<th>Total</th>
						<th>View</th>
					</tr>
                </thead>
                <tbody>
				<?php 
				$i=1;
				foreach($issues_list as $islist)
					{
					?>
                <tr>
                    <td><?php echo $i; ?></td>
                    <td><?php echo $islist->pr_req_no; ?></td>
					<td><?php echo $islist->request_date; ?></td>
					<td><?php echo $islist->issue_no; ?></td>
					<td><?php echo $islist->issue_date; ?></td>
					<td><?php echo $islist->issue_time; ?></td>
					<td><?php echo $islist->outlet; ?></td>
					<td><?php echo $islist->total_amount; ?></td>
					<td class="uk-text-nowrap">
						<a target="_blank" href="<?php echo site_url('ProductRequest/accissueView/'. $islist->issue_id); ?>" class="btn btn-sm btn-info">View</a>
					</td>
				</tr>
					<?php 
					$i++;
					} ?>     
                 
            </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>