<?php
	include('common/header.php');
?>
	<div class="">
		<div class="col-xm-12">
			<div class="widget-box light-border">
				
				<div class="widget-body">
					<div class="widget-main">
						<div class="row">
							<div class="col-sm-12">
								<form class="form-horizontal" method="post" role="form" name="module_form" id="module_form" action="<?php echo base_url();?>index.php/gc/master_sale_data_report/search_sale_report">
								<div class="">
									<!-- PAGE CONTENT BEGINS -->


									<div class="form-group">  
										<label class="col-sm-5 control-label" for="form-field-2" ><?php echo $lable_sales_report_branch;?></label>
										<div class="col-sm-7">	
											<select name="branch_id" id="branch_id" onchange="get_sale_person(this.value);"  style="width:262px">
												<option value="0">Select Branch Name</option>
												<?php foreach ($branch as  $value) {?>
													<option value="<?php echo $value['company_branch_id'];?>"><?php echo $value['company_branch_name']; ?></option>
												<?php } ?>
											</select>
										</div>
									</div>

                           <div class="form-group">
                            <label for="client_code" class="col-sm-5 control-label required"><?php echo 'Customer Name'?>:</label>
                              <div class="col-sm-7">
									
									<select class="select2 select2-multiple form-control" name="customer_id" multiple="multiple" id="customer_id" style="width: 250px;">
										<option value="">Select Customer</option>
								    </select>
										
									<span class="red" id="customer_name_error"></span>
                              </div>	
                            </div>
							<div class="form-group" id="qc_name">							   <label for="client_code" class="col-sm-5 control-label required"><?php echo 'Product Category'?>:</label>							 							  <div class="col-sm-7">                             								<select name="product_category_id" id="product_category_id"  style="width: 250px;">								 <option value="0">Select Product Category</option>						   									  <?php  										  foreach ($product_category as  $pc) {?>													  										   <option value="<?php echo $pc['product_category_id'];?>"><?php echo $pc['product_category_name'] ; ?>										   <?php  }										?>												  								</select>  								<span id="product_category_error" class="text-danger font-weight-bold"></span>							  </div>							</div>
							    	 
									<div class="form-group">  
									  <label class="col-sm-5 control-label" for="form-field-2" ><?php echo $lable_sales_report_date_from;?></label>
										<div class="col-sm-7">	
										   <div class="input-group" style="width:262px">
											    <input class="form-control date-picker" id="id-date-picker-1" name="from" autocomplete="off" type="text" data-date-format="dd-mm-yyyy">
													<span class="input-group-addon">
														<i class="fa fa-calendar bigger-110"></i>
													</span>
										    </div>
										</div>	
									</div>

									<div class="form-group">  
									  <label class="col-sm-5 control-label" for="form-field-2" ><?php echo $lable_sales_report_date_to;?></label>
										<div class="col-sm-7">	
										   <div class="input-group" style="width:262px">
											    <input class="form-control date-picker" id="id-date-picker-2" name="to" autocomplete="off" type="text" data-date-format="dd-mm-yyyy">
													<span class="input-group-addon">
														<i class="fa fa-calendar bigger-110"></i>
													</span>
										    </div>
										</div>	
									</div>


														
									<div class="form-group">  
										<label class="col-sm-5 control-label" for="form-field-2" ><?php echo $lable_sales_report_sales_by;?></label>
										<div class="col-sm-7">	
											<select name="sale" id="branch_wise" onchange="get_dispenser(this.value);" style="width:262px">
												<option value="0">Sales By</option>
												

											</select>
										</div>
									</div>
									
									<div class="form-group">  
										<label class="col-sm-5 control-label" for="form-field-2" ><?php echo $lable_sales_report_dispenser_name;?></label>
										<div class="col-sm-7">	
											<select name="product_name_dispenser" id="product_name_dispenser" style="width:262px">
												<option value="0"> Select Dispenser Name</option>
											</select>
										</div>
									</div>

								</div>
								
							</div>
						</div>
					</div>	
				</div>
			</div>
		</div>
		<!-- /.col -->
	</div>
	<div class="clearfix form-actions">
		<div class="col-md-offset-5 col-md-5">
			
			<button class="btn btn-info" type="submit">
				 Submit
			</button>
		</div>
	</div>
	</form>	
	<div class="space-4"></div>
		<!-- /.page-row -->
        <!-- /.page-content --> 
    </div>
    <!-- /.main-content --> 
	</div>
    <!-- /#ace-settings-container --> 
	</div>
	<!-- /.main-container-inner --> 
<?php
	include('common/footer.php');
?>
<script type="text/javascript">
 $('.date-picker').datepicker({
 	                dateFormat: 'dd-mm-yy',
                    autoclose: true,
                    todayHighlight: true,
                    changeYear: true,
                    changeMonth: true
                })
</script>
<script type="text/javascript">
 $('#id-date-picker-2').datepicker({
 					dateFormat: 'dd-mm-yy',
                    autoclose: true,
                    todayHighlight: true,
                    changeYear: true,
                    changeMonth: true
                })
</script>
<script>
function get_sale_person(){
  var branch_id = $('#branch_id').val();
  $.ajax({
    url:"<?php echo base_url();?>index.php/gc/master_sale_data_report/get_sale_person",
    method:"POST",
    data:{
      branch_id:branch_id
    },
    success:function(data)
    {
     $('#branch_wise').html(data);
    }
   });
  
}
function get_dispenser(){
  var branch_wise = $('#branch_wise').val();
  $.ajax({
    url:"<?php echo base_url();?>index.php/gc/master_sale_data_report/get_dispenser",
    method:"POST",
    data:{
      user_id:branch_wise
    },
    success:function(data)
    {
     $('#product_name_dispenser').html(data);
    }
   });
}
$(document).ready(function(){

	$("#contract_div").hide();
	$("#del").hide();
	$(".js-example-tags").select2({
	tags: true
	});

	 $(".select2").select2();  
	 $(".select2").prop("multiple", "");

	$("#customer_id").select2({
		 tags: true,
		multiple: false,
		//tokenSeparators: [',', ' '],
		minimumInputLength: 3,
		minimumResultsForSearch: 10, 
		ajax: {
			url: '<?php echo base_url();?>index.php/gc/refill_sale_data/customer',
			dataType: "json",
			type: "POST",
			data: function (params) {

				var queryParameters = {
					customer_id: params.term
				}
				return queryParameters;
			},
			processResults: function (data) {
				return {
				  results: data
				};
			}
		}
	});


});


</script>
