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

    <!-- BEGIN: Content-->
    <div class="app-content content" ng-app="prodreq" ng-controller="prrequest" >
      <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">Product Mapping</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 Mapping </a>
                  </li>
                  <li class="breadcrumb-item active">Product Mapping
                  </li>
                </ol>
              </div>
            </div>
          </div>
          
        </div>
        <div class="content-body"><!-- Basic form layout section start -->
<section id="basic-form-layouts">
	<div class="row justify-content-md-center">
		<div class="col-md-12">
			<div class="card">
				<!--<div class="card-header">
					<h4 class="card-title" id="basic-layout-form-center">Product Request</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">
					     <div class="col-md-6">
						<form class="form" autocomplete="off" action="<?php echo site_url('Master/exportProduct');?>" method="post">
							<div class="row">
								<div class="col-md-6">
									<div class="form-body">
										<div class="form-group">
										<?php $cur_date = date("d-m-Y"); 
										$branch_id = $_SESSION['branch_id'];
										$branch_name = $_SESSION['branch_name'];
										$full_name = $_SESSION['full_name']; ?>
										<input class="form-control" type="hidden" name="branchname" id="branchname" value="<?php echo $_SESSION['branch_name']?>">
											<input type="submit" name="export_stk_format" class="btn btn-primary" value="Mapping Format">
										</div>
									</div>
								</div>
							</div>
						</form>
						<form class="form" autocomplete="off" action="<?php echo site_url('Master/import_Product');?>"  method="post" enctype="multipart/form-data">
							<div class="row">
								<div class="col-md-6">
									<div class="form-group">
										<!--<label>UPLOAD</label>-->
										<input type="hidden" id="smodule_id" class="form-control"  name="smodule_id" value="<?php echo $submdid;?>">
										<input type="file" name="prstk_upload" id="prstk_upload" class="form-control" required />
										<input class="form-control" type="hidden" name="upd_type" id="upd_type" value="Finished Product" >
									</div>
								</div>
								<div class="col-md-6">
									<div class="form-group">
										<input type="submit" name="prupload" id="fstk"  class="btn btn-primary" value="Product Mapping Upload" onclick="return confirm('Are you sure you want to submit this form?')">
									</div>
								</div>
							</div>
							
						</form>
					</div>
						<form class="form" autocomplete="off" action="<?php echo site_url('Master/addMapping');?>" method="post">
						    
							<div class="row justify-content-md-center">
								<div class="col-md-3 mleft">
									<div class="form-body">
									    <?php $cur_date = date("d-m-Y"); 
										$branch_id = $_SESSION['branch_id'];
										$branch_name = $_SESSION['branch_name'];
										$full_name = $_SESSION['full_name']; ?>
										<div class="form-group">
											<label for="eventInput1">Category</label>
											<select id="category" name="category" class="form-control select2" ng-model='cat' ng-change='fetchProduct()' required >
												<option value="">Select</option>
												<option ng-repeat="cat in pr_cat" value='{{cat.pr_cat_id}}'>{{cat.cat_name}}</option>
											</select>
											<input type="hidden" id="module_id" class="form-control"  name="module_id" value="<?php echo $submdid;?>">	
											<input type="hidden" id="branch_id" class="form-control"  name="branch_id" value="<?php echo $branch_id;?>">
											
										</div>
									</div>
								</div>
							</div>
							<div class="row justify-content-md-right">
								<table class="table" >
									<thead>
										<tr>
											<th>Item Name</th>
											<th>Mapping Finished Product</th>
										</tr>
									</thead>
									<tbody>
										<tr id="found" ng-repeat="item in items">
											<td>{{item.iname}}</td>
											<td>
											    <!--k as v for (k, v) in optionList 
											    ng-options="product.rname for product in products"
											    <option ng-repeat="product in products" value='{{product.rname}}'>{{product.rname}}</option>
											    <?php /*foreach($products as $row)
    												{
    													echo '<option value="'.$row->rname.'">'.$row->rname.'</option>';
    												}*/
    											?>
											    -->
											    <select ng-model="ddlFruits" wb-select2 class="form-control"  name="pr_name[]"  select-width="350px" style="width:300px">
                                                    <option value="">SELECT PRODUCT</option>
                                                    <option ng-repeat="product in products" value='{{product.rname}}'>{{product.rname}}</option>
                                                </select>
    											
    										    <input class="form-control" type="hidden" value={{item.id}} name="item_id[]" id="item_id" readonly />
												<input class="form-control" type="hidden" value={{item.rno}} name="recipe_no[]" id="recipe_no" readonly />
										    </td>
										</tr>
										<tr id="notfound" >
										    <td colspan="3">Not Found</td>
										</tr>
									</tbody>
								</table>
							</div>

							<div class="form-actions text-center">
								<button type="reset" class="btn btn-warning mr-1">
									<i class="ft-x"></i> Cancel
								</button>
								<button type="submit" class="btn btn-primary">
									<i class="la la-check-square-o"></i> Save
								</button>
								
							</div>
						</form>	
					</div>
				</div>
			</div>
			<br/>
		</div>
	</div>
</section>
<!-- // Basic form layout section end 	<select name="pr_name[]" id="pr_name" class="form-control  select2 " required >
											<option value="">SELECT PRODUCT</option>
											<?php  /*foreach($products as $row)
												{
													echo '<option value="'.$row->rname.'">'.$row->rname.'</option>';
												} */
											?>
										</select>-->
        </div>
      </div>
    </div>
<?php //require('include/theme_customizer.php');?>
<?php 
    $footer_file=APPPATH.'views/include/footer.php';
	require($footer_file);
?>
	<script>
		var mainApp = angular.module('prodreq', ['ngStorage']);

		mainApp.controller('prrequest', ['$scope', '$http', function ($scope, $http) {
					
			$scope.dept = '0';
			$scope.cat = '0';
			var branch_id1 = angular.element(document.getElementById("branch_id"));
			$scope.branch_id = branch_id1.val();
			var module_id1 = angular.element(document.getElementById("module_id"));
			$scope.module_id = module_id1.val();
			//fetch data
			
			
			$http({
					method: 'post',
					url: '<?php echo base_url(); ?>index.php/Master/fetchCategory',
					headers: {'Content-Type': 'application/json'},
					data: JSON.stringify({md_id:$scope.module_id})
				}).then(function successCallback(response) {
					$scope.pr_cat = response.data;
					console.log(response.data);
				});
			
			$scope.fetchProduct = function() {
			    $scope.items='';
			    $scope.products='';
			    $http({
					method: 'post',
					url: '<?php echo base_url(); ?>index.php/Master/fetchProduct',
					headers: {'Content-Type': 'application/json'},
					data: JSON.stringify({cat:$scope.cat,branch_id:$scope.branch_id})
				}).then(function successCallback(response) {
				   /* *if(response.data==''){
					    
					    $("#found").hide();
				        $("#notfound").show();
				        console.log(response.data);
					    console.log('na');
					   // console.log(response.data);
				    }
				    else{
				        
				        $("#found").show();
				        $("#notfound").hide();
				        console.log('found');
				    }
				    
				    */
				    if(response.data===''){
				        alert('dd');
				    }
				    $scope.items = response.data;
					 console.log(response.data);
				});
				$http({
    				method: 'post',
    				url: '<?php echo base_url(); ?>index.php/Master/fetchPr',
    				headers: {'Content-Type': 'application/json'},
    				data: JSON.stringify({branch_id:$scope.branch_id})
    			}).then(function successCallback(response) {
    				$scope.products = response.data;
    				console.log(response.data);
    			});
			}
			
			

		}]);
		
mainApp.directive('wbSelect2', function () {
    return {
        restrict: 'A',
        scope: {
            'selectWidth': '@',
                'ngModel': '='
        },
        link: function (scope, element, attrs) {
            //Setting default values for attribute params
            scope.selectWidth = scope.selectWidth || 200;
            element.select2({
                width: scope.selectWidth,
            });

            scope.$watch('ngModel', function (newValue, oldValue) {
                element.select2({
                    width: scope.selectWidth
                }).select('val', newValue);
            });
        }
    };
});

		
	</script>
	<script>
	$(document).ready(function(){
	//$("#category").select2();

   });
    $(document).ready(function(){
		$("select.chzn-select").chosen({allow_single_deselect:true});
   });
		 $("#dept").change(function(){
			var dept = $('#dept option:selected').text();
			$('#dept1').val(dept);
		});
	
      $("#orders").change(function(){
		var ord_type = $('#orders').val();
		//alert(ord_type);
		if(ord_type == 'Regular Order' || ord_type == 'Running Order')
		{
			$('#del_date').hide();
			$('#del_time').hide();
			$('#del_rmk').hide();
			//$('#ord_rmrk').css('visibility', 'hidden');
			//$("#ord_remark").attr('disabled','disabled');
			$("#delivery_date").prop('disabled', true);
			$("#delivery_time").prop('disabled', true);
			$("#ord_remark").prop('disabled', true);
			//$("#dcacl").children().attr("disabled","disabled");
		}
		else if(ord_type == 'Special Order')
		{
			$('#del_date').show();
			$('#del_time').show();
			$('#del_rmk').show();
			//$("#ord_remark").removeAttr('disabled');
			$("#delivery_date").prop('disabled', false);
			$("#delivery_time").prop('disabled', false);
			$("#ord_remark").prop('disabled', false);
			//$('#ord_rmrk').css('visibility', 'visible');
		}
	});
	
	$( function() {
		$( "#delivery_date" ).datepicker({
			format: 'DD-MM-YYYY',
			minDate: 'true'
		});
	} );
</script>
	<script>
	/*	$(window).on('beforeunload', function () {
			//$("input[type=submit], input[type=button]").prop("disabled", "disabled");
			$("input[type=submit]").prop("disabled", "disabled");
			$("#submit").css("background-color","#dcdcdc");
		});*/
	</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>