<?php 
	$header_file=APPPATH.'views/include/header.php';
	require($header_file);
?>
<style>
    .col-md-3 {
    flex: 0 0 22%!important;
    /* max-width: 25%; */
}
</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">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="#">Issue</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-content collapse show">
                    <div class="card-body card-dashboard">
                        <form method="post" autocomplete="off" action="<?php echo site_url('MaterialRequest/search_issue_report_byOutlet/');?>" method="POST">
                          <div class="row justify-content-md-center">
              
                            <div class="col-md-3" style="margin-left: -87px;">
                              <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" style="margin-left: -17px;">
                              <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">
                                <input class="form-control" type="hidden" name="submod_id"  id="submod_id"   value="<?php  if(isset($_POST['submod_id'])) { echo $_POST['submod_id']; }else { echo $submod_id; }?>">
                              </div>
                            </div>  
                            <div class="col-md-1">
            					<div class="form-group" style="margin-right: -40px;">
            					    <?php
            					    $branch_name = $_SESSION['branch_name'];
                                    if($branch_name=='CW4_ACC')
                                    {
                                    ?>
                                    <select id="br_name" name="br_name" class="select2"  required >
            							<option value="">Branch Issued</option>
            							<option value="CW4">CW4</option>
            						</select>
            						<?php
                                    } else if($branch_name=='CW5-ACC') {
            					    ?>
            						<select id="br_name" name="br_name" class="select2"  required >
            							<option value="">Branch Issued</option>
            							<option value="CW5">CW5</option>
            						</select>
            						<?php } else { ?>
            						<select id="br_name" name="br_name" class="select2"  required >
            							<option value="">Branch Issued</option>
            							<option value="CW">CW</option>
            							<option value="CW3">CW3</option>
            						</select>
            						<?php } ?>
            					</div>
            				</div>
				            <div class="col-md-2">
    							<div class="form-group" style="margin-left: 21px;">
    								<select id="outlet_name" name="outlet_name" class="select2"  required >
    									<option value="">Select Outlet...</option>
    									<option value="All">All</option>
    									<?php  foreach($outlet as $olt)
                                            {
                                          ?>
                                            <option value="<?php echo $olt->username; ?>"><?php echo $olt->username; ?></option>
                                          <?php
                                            } 
                                          ?>
    								</select>
    							</div>
    						</div>
    						<div class="col-md-2">
    							<div class="form-group" style="margin-left: -21px;margin-right: -51px;">
    								<select id="item_name" name="item_name" class="select2"  >
    									<option value="">Select Item...</option>
    									<option value="All">All</option>
    									<?php  foreach($item as $itm)
                                            {
                                          ?>
                                            <option value="<?php echo $itm->item_name; ?>"><?php echo $itm->item_name; ?></option>
                                          <?php
                                            } 
                                          ?>
    								</select>
    							</div>
                            </div>
                            <div class="col-md-1">
                              <div class="form-group" style="margin-right: -118px;">
                                <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 (isset($result_display)) {
						//echo "<p><u>Result</u></p>";
						if ($result_display == 'No record found !') {
							echo $result_display;
							} else {
						?>
		<?php 
			
				if($_POST['from_date']!="" && $_POST['to_date']!="" && $_POST['outlet_name']!="" && $_POST['item_name']==""){
				?>
				<div class="card">
					<div class="card-content">
						
						<div class="row justify-content-md-left">
							<div class="col-md-3">
								<div class="form-group">
									<input class="form-control" type="text" name="fdate"  id="fdate" value="<?php echo $_POST['from_date']?>" readonly>
								</div>
							</div>
							<div class="col-md-3">
								<div class="form-group">
									<input class="form-control" type="text" name="tdate"  id="tdate" value="<?php echo $_POST['to_date']?>" readonly>
								</div>
							</div>
							<div class="col-md-3">
								<div class="form-group">
									<input class="form-control" type="text" name="outlet"  id="outlet" value="<?php echo $_POST['outlet_name']?>" readonly>
								</div>
							</div>
							<form method="post" action="<?php echo site_url('MaterialRequest/export_issue/');?>">
    							<div class="col-md-3">
    								<div class="form-group">
    									<input class="form-control" type="hidden" name="from_date1" value="<?php echo $_POST['from_date']; ?>">
    									<input class="form-control" type="hidden" name="to_date1" value="<?php echo $_POST['to_date']; ?>">
    									<input class="form-control" type="hidden" name="outlet_name" value="<?php echo $_POST['outlet_name']; ?>">
    									<input class="form-control" type="hidden" name="branchname" value="CW">
    									<input type="submit" name="export_stock" class="btn btn-primary" value="Export">
    								</div>
    							</div>
							</form>
						</div>
						<table class="table table-striped table-bordered dataex-html5-export">
							<thead>
								<tr>
									<th>Issues No</th>
									<th>Issues Date</th>
									<th>Outlet Name</th>
									<th>Total</th>
									<th>View</th>
									<!--<th>Rejection</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 $data['issue_no']; ?></td>
											<td><?php echo $data['issue_date']; ?></td>
											<td><?php echo $data['outlet_name']; ?></td>
											<td><?php echo $data['total']; ?></td>
											<td class="uk-text-nowrap">
											    <a href="<?php echo site_url('MaterialRequest/issueView/'.$data['issue_id'].''); ?>" id="view" class="btn btn-primary btn-sm" name="view">View</a>
												
										
											</td>
										</tr>
											<?php
									$i++;
									} ?>
									<?php else:
								?>
								<tr>
									<td colspan="8" align="center" >No Records Found..</td>
								</tr>
								<?php
									endif;
								?>
								</tbody>
							</table>
							<div>
							</div>
							
							
						<?php }
						else if($_POST['from_date']!="" && $_POST['to_date']!="" && $_POST['outlet_name']!="" && $_POST['item_name']!=""){
						?>
						<?php if($_POST['outlet_name'] != 'All' && $_POST['item_name'] == 'All'){?>
							<div class="card">
								<div class="card-content">
									<div class="row justify-content-md-left">
            							<div class="col-md-3">
            								<div class="form-group">
            									<input class="form-control" type="text" name="fdate"  id="fdate" value="<?php echo $_POST['from_date']?>" readonly>
            								</div>
            							</div>
            							<div class="col-md-3">
            								<div class="form-group">
            									<input class="form-control" type="text" name="tdate"  id="tdate" value="<?php echo $_POST['to_date']?>" readonly>
            								</div>
            							</div>
            							<div class="col-md-3">
            								<div class="form-group">
            									<input class="form-control" type="text" name="outlet"  id="outlet" value="<?php echo $_POST['outlet_name']?>" readonly>
            								</div>
            							</div>
            						<form method="post" action="<?php echo site_url('MaterialRequest/export_outlet_all_item/');?>" >	
        								<div class="col-md-3">
        								    
        										<div class="form-group">
        											<input class="form-control" type="hidden" name="from_date1" value="<?php echo $_POST['from_date']; ?>">
        											<input class="form-control" type="hidden" name="to_date1" value="<?php echo $_POST['to_date']; ?>">
        											<input class="form-control" type="hidden" name="outlet_name" value="<?php echo $_POST['outlet_name']; ?>">
        											<input class="form-control" type="hidden" name="branchname" value="CW">
        											<input type="submit" name="export_stock" class="btn btn-primary" value="Export">
        										</div>
        									
        									</div>
									</form>	
									</div>
									<table  class="table table-striped table-bordered dataex-html5-export" >
										<thead>
											<tr>
												<th>Product Name</th>
												<th>Quantity</th>
												<th>Total</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 $data['indent_item_name']; ?></td>
														<td><?php echo $data['qty']; ?></td>
														<td><?php echo $data['total']; ?></td>
													</tr>
									<?php
									$i++;
									} ?>
									<?php else:
								?>
								<tr>
									<td colspan="8" align="center" >No Records Found..</td>
								</tr>
								<?php
									endif;
								?>
											</tbody>
										</table>
									</div>
								</div>
							
								<?php
								}
							?>
							<?php }
							else if($_POST['outlet_name'] == 'All' && $_POST['item_name'] != 'All'){
							?>
							<div class="card">
								<div class="card-content">
									<div class="row justify-content-md-center">
            							<div class="col-md-3">
            							    <div class="form-group">
										    	<input class="md-input" type="text" name="from_date"  id="uk_dp_1" value="<?php echo $_POST['from_date']; ?>" readonly >
										    </div>
										</div>
										<div class="col-md-3">
            							    <div class="form-group">
											    <input class="md-input" type="text" name="from_date"  id="uk_dp_1" value="<?php echo $_POST['to_date']; ?>" readonly >
										    </div>
										</div>
										<div class="col-md-3">
            							    <div class="form-group">
											<input class="md-input" type="text" name="item"  id="item" value="<?php echo $_POST['item_name']; ?>" readonly >
										    </div>
									    </div>
									    <div class="col-md-3">
									        <form method="post" action="<?php echo site_url('MaterialRequest/export_all_outlet_item/');?>">
            							    <div class="form-group">
											<input class="form-control" type="hidden" name="from_date1" value="<?php echo $_POST['from_date']; ?>">
											<input class="form-control" type="hidden" name="to_date1" value="<?php echo $_POST['to_date']; ?>">
											<input class="form-control" type="hidden" name="branchname" value="CW">
											<input class="form-control" type="hidden" name="item_name" value="<?php echo $_POST['item_name']; ?>">
											<input type="submit" name="export_stock" class="md-btn md-btn-primary" value="Export">
											
										</div>
											</form>	
									</div>
							
										    </div>
									    </div>
									</div>
									<table id="dt_colVis" class="uk-table" cellspacing="0" width="100%">
										<thead>
											<tr>
												<th>Outlet Name</th>
												<th>Quantity</th>
												<th>Total</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 $row['outlet_name']; ?></td>
														<td><?php echo $row['qty']; ?></td>
														<td><?php echo $row['total']; ?></td>
													</tr>
												<?php
									$i++;
									} ?>
									<?php else:
								?>
								<tr>
									<td colspan="8" align="center" >No Records Found..</td>
								</tr>
								<?php
									endif;
								?>
											</tbody>
										</table>
									</div>
								</div>
								<br/>
								
								
							<?php }
							else if($_POST['outlet_name'] != 'All' && $_POST['item_name'] != 'All'){?>
							<div class="card">
								<div class="card-content">
									<div class="row justify-content-md-center">
            							<div class="col-md-3">
            								<div class="form-group">
    											<input class="md-input" type="text" name="from_date"  id="uk_dp_1" value="<?php echo $_POST['from_date']; ?>" readonly >
    										</div>
    									</div>
										<div class="col-md-3">
            							    <div class="form-group">
    											<input class="md-input" type="text" name="from_date"  id="uk_dp_1" value="<?php echo $_POST['to_date']; ?>" readonly >
    										</div>
    									</div>
										<div class="col-md-3">
            							    <div class="form-group">
    											<input class="md-input" type="text" name="outlet"  id="outlet" value="<?php echo $_POST['outlet_name']; ?>" readonly> 										</div>
    									</div>
										<div class="col-md-3">
            							    <div class="form-group">
											<input class="md-input" type="text" name="item"  id="item" value="<?php echo $_POST['item_name']; ?>" readonly >
										</div>
										</div>
										<div class="col-md-3">
										<form method="post" action="<?php echo site_url('MaterialRequest/export_outlet_item/');?>">
									<div class="form-group">
											<input class="form-control" type="hidden" name="from_date1" value="<?php echo $_POST['from_date']; ?>">
											<input class="form-control" type="hidden" name="to_date1" value="<?php echo $_POST['to_date']; ?>">
											<input class="form-control" type="hidden" name="outlet_name" value="<?php echo $_POST['outlet_name']; ?>">
											<input class="form-control" type="hidden" name="item_name" value="<?php echo $_POST['item_name']; ?>">
											<input class="form-control" type="hidden" name="branchname" value="CW">
											<input type="submit" name="export_stock" class="btn btn-primary" value="Export">
										</div>
											</form>	
									</div>
							
									</div>
									<table id="dt_colVis" class="uk-table" cellspacing="0" width="100%">
										<thead>
											<tr>
												<th>Quantity</th>
												<th>Total</th>
												<!--<th>Rejection</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 $data['qty']; ?></td>
														<td><?php echo $data['total']; ?></td>
													</tr>
													<?php
									$i++;
									} ?>
									<?php else:
								?>
								<tr>
									<td colspan="8" align="center" >No Records Found..</td>
								</tr>
								<?php
									endif;
								?>
											</tbody>
										</table>
									</div>
								</div>
								<br/>
								
								<?php
								
							} 
							else if($_POST['outlet_name'] == 'All' && $_POST['item_name'] == 'All') { 
								echo "No Data Exists";
							}
						?>
						<?php 
							} 
					}
				}else{
					?>
          <div ng-app="anglist" ng-controller="anglistctlr" class="md-card">
            <div class="md-card-content">
              <div infinite-scroll="getResults()">
                <div class="col-md-2" style="float:right;">
                      <div class="form-group">
                                <input type="text" class="form-control" ng-model="search" placeholder="Search Here" >
                                <input type="hidden" name="branch" id="branch" class="form-control" value="('<?php echo $_SESSION['branch_name']?>')"/>
                             </div>
                        </div>
                        <table class="table table-striped table-bordered dataex-html5-export" >
                            <thead>
                                <tr>
                                    <th>Request No</th>
									<th>Request Date</th>
									<th>Issues No</th>
									<th>Issues Date</th>
									<th>Outlet Name</th>
									<th>Total</th>
									<th>View</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ng-repeat='res in results | filter : search'>
                                  <td>{{res.mat_req_no}}</td>
        							<td>{{res.request_date}}</td>
        							<td>{{res.issue_no}}</td>
        							<td>{{res.issue_date}}</td>
        							<td>{{res.outlet_name}}</td>
        							<td>{{res.total}}</td>
        							<td>
                                     <a href="<?php echo site_url('MaterialRequest/issueView/{{res.mid}}'); ?>" id="view" class="btn btn-primary btn-sm" name="view">View</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <div ng-show='loading' class='loading'>Loading...</div>
            </div>
            </br>
              
            </div>
          </div>
        <?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>  
<script type="text/javascript">
   var fetch = angular.module('anglist', ['infinite-scroll']);
  
  fetch.controller('anglistctlr', ['$scope', '$http', function ($scope, $http) {
  
    // Variables
    $scope.row = 0;
    $scope.rowperpage = 12;
    $scope.results = [];
    $scope.busy = false;
    $scope.loading = false;
  
    // Fetch data
    $scope.getResults = function(){
  
    if ($scope.busy) return;
  
      $scope.busy = true;
  
      // Fetch data
      $http({
        method: 'post',
        url: '<?php echo base_url() ?>index.php/MaterialRequest/getAccIssueList',
        data: {row:$scope.row,rowperpage:$scope.rowperpage}
      }).then(function successCallback(response) {
  
        if(response.data !='' ){
           // New row value 
           $scope.row+=$scope.rowperpage;
  
           $scope.loading = true;
           setTimeout(function() {
              $scope.$apply(function(){
  
                // Assign response to results Array 
                angular.forEach(response.data,function(item) {
                   $scope.results.push(item);
                  console.log($scope.results);
                });
                $scope.busy = false;
                $scope.loading = false;
              });
  
           },500);
        }
      });
    }
  
    // Call function
    $scope.getResults();
  
  }]);
  </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>