	<?php $this->load->view("common/header"); ?>
	<!-- end: HEAD -->
       
		<!-- start: CSS REQUIRED FOR THIS PAGE ONLY -->
		<link rel="stylesheet" type="text/css" href="<?php echo asset_url(); ?>plugins/select2/select2.css" />
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/DataTables/media/css/DT_bootstrap.css" />
		<link href="<?php echo asset_url(); ?>plugins/bootstrap-modal/css/bootstrap-modal-bs3patch.css" rel="stylesheet" type="text/css"/>
		<link href="<?php echo asset_url(); ?>plugins/bootstrap-modal/css/bootstrap-modal.css" rel="stylesheet" type="text/css"/>
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-fileupload/bootstrap-fileupload.min.css">
		
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/datepicker/css/datepicker.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-timepicker/css/bootstrap-timepicker.min.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-daterangepicker/daterangepicker-bs3.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-colorpicker/css/bootstrap-colorpicker.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/jQuery-Tags-Input/jquery.tagsinput.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/bootstrap-fileupload/bootstrap-fileupload.min.css">
		<link rel="stylesheet" href="<?php echo asset_url(); ?>plugins/summernote/build/summernote.css">

		<style type="text/css">
			.table > thead:first-child > tr:first-child > th, .table > thead:first-child > tr:first-child > td, .table-striped thead tr.primary:nth-child(2n+1) th {
			    background-color: #428bca;
			    border-color: #357ebd;
			    border-top: 1px solid #357ebd;
			    color: white;
			    text-align: center;
			}
#s2id_srh_customer_id{
	border: 0 none;
padding: 0;
}

.dataTables_processing{position:absolute;top:50%;left:50%;width:100%;height:40px;margin-left:-50%;margin-top:-25px;padding-top:0px;text-align:center;font-size:2em;background-color:white;background:-webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255,255,255,0)), color-stop(25%, rgba(255,255,255,0.9)), color-stop(75%, rgba(255,255,255,0.9)), color-stop(100%, rgba(255,255,255,0)));background:-webkit-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-moz-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-ms-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:-o-linear-gradient(left, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);background:linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.9) 25%, rgba(255,255,255,0.9) 75%, rgba(255,255,255,0) 100%);
				}
.ml12 {
  font-weight: 200;
  font-size: 1.8em;
  text-transform: uppercase;
  letter-spacing: 0.5em;
}

.ml12 .letter {
  display: inline-block;
  line-height: 1em;
}
td{
	vertical-align:top !important;
}
.col-sm-3 {
  height: 79px;
}


		</style>
        
		<!-- end: CSS REQUIRED FOR THIS PAGE ONLY -->
	<!-- end: HEAD -->
	<!-- start: BODY -->
	<body>
		<!-- start: HEADER -->
		<div class="navbar navbar-inverse navbar-fixed-top">
			<!-- start: TOP NAVIGATION CONTAINER -->
			<div class="container">
				<div class="navbar-header">
					<!-- start: RESPONSIVE MENU TOGGLER -->
					<button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button">
						<span class="fa fa-list"></span>
					</button>
					<!-- end: RESPONSIVE MENU TOGGLER -->
					<!-- start: LOGO -->
					<?php $this->load->view("common/logo"); ?>
					<!-- end: LOGO -->
				</div>
				<div class="navbar-tools">
					<!-- start: TOP NAVIGATION MENU -->
				<?php $this->load->view("common/notifications.php"); ?>
					<!-- end: TOP NAVIGATION MENU -->
				</div>
			</div>
			<!-- end: TOP NAVIGATION CONTAINER -->
		</div>
		<!-- end: HEADER -->
		<!-- start: MAIN CONTAINER -->
		<div class="main-container">
			<div class="navbar-content">
				<!-- start: SIDEBAR -->
				<?php $this->load->view("common/navigation"); ?>
				<!-- end: SIDEBAR -->
			</div>
			<!-- start: PAGE -->
			<div class="main-content">
				<!-- end: SPANEL CONFIGURATION MODAL FORM -->
				<div class="container">
					<!-- start: PAGE HEADER -->
					<div class="row">
						<div class="col-sm-12">
							<!-- start: PAGE TITLE & BREADCRUMB -->
							<ol class="breadcrumb">
								<li>
									<a href="<?php echo base_url('dashboard'); ?>">
										 Dashboard 
									</a>
								</li>
                                <li>
									<a href="#">
										 Reports 
									</a>
								</li>
                                                                
								<li class="active">
									 Sales Assistant Wise Department Sales Summary
							  </li>
								<li class="search-box">
									<form class="sidebar-search">
										<div class="form-group">
											<input type="text" placeholder="Start Searching...">
											<button class="submit">

												<i class="fa fa-search"></i>
											</button>
										</div>
									</form>
								</li>
							</ol>
							<div class="page-header">
								<h1>Sales Assistant Wise Department Sales Summary</h1>
							</div>

                            <p>Please use the table below to navigate or filter the results. </p>
						</div>
					</div>
					<!-- end: PAGE HEADER -->
					<!-- start: PAGE CONTENT 
                    <!-- start grid -->
                   <!-- <div class="row">
						<div class="col-md-12">-->
							<!-- start: DYNAMIC TABLE PANEL -->
							
							  <div class="panel-body">
							    <div id="error"></div>
                                <!-- class="col-md-12"-->
                              <div >
											<div class="panel panel-default">
												<div style="font-weight: 700;" class="panel-heading">Use below filters</div>
													<div class="panel-body">
<?php
$hide_warehouse='';
 if ($this->session->userdata('ss_group_id')==1 || $this->session->userdata('ss_group_id')==2)
 { 
  $hide_warehouse='';
 }else{
	  $hide_warehouse='style="display:none;"';
 }
  $hide_warehouse='';
 
  ?>														
                                                      <div class="col-sm-3" <?php echo $hide_warehouse ?>>
                                                      	<div class="form-group">
															<label>Warehouse </label>
                                                       <select id="srh_warehouse_id" class="form-control" name="srh_warehouse_id">
                                                                   
																  <?php 
																 $ss_warehouse_id=$this->session->userdata('ss_warehouse_id'); 
                                                              foreach ($warehouse_list as $row)
                                                              {
																  $sel='';
																  if($ss_warehouse_id==$row->id)
																  {
																	  $sel=' selected="selected"';
																  }
                                                              ?>  
                                                                        
															<option value="<?php echo $row->id; ?>" <?php echo $sel; ?>>
																		<?php echo $row->name; ?>
                                                                        </option>
                                                              <?php }?>
                                                              
                                                              <option value="">-All-</option>
																		
																	</select>                                          
														</div>
														</div>
														
														 <div class="col-sm-3">
                                                      	<div class="form-group">

															<label>Sales Rep. </label>

                                                            <?php //print_r($rep_list);?>
                                                            <br/>

                                                       <select id="srh_sales_rep_id" class=" select2_box" name="srh_sales_rep_id" style="width:200px;">

                                                               

																 <option value="">-All-</option>

									                            <?php 

															

															foreach ($rep_list as $row)

															{

																

															?> 

 <option value="<?php echo $row->user_id;?>"><?php echo $row->user_first_name; if($row->user_phone) echo " / ".$row->user_phone;?>  </option>

															 <?php }  ?>

							                              </select>                                       

														</div>

													  </div>
                                                        
                                                      <div class="col-sm-3" style="display:none">
                                                      	<div class="form-group">
															<label>Department </label>
                                                            <?php
															$cat_id=1;
															 //print_r($supplier_list);?>
                                                         <select id="cat_srh" name="cat_srh" class="form-control search-select">
                                                         
								                               
						<option value="">-All-</option>	
						<?php foreach ($category_list as $key => $sup) {
								if($sup->cat_name!=''){
																	 ?>
								                             <option value="<?php echo $sup->cat_id; ?>"><?php echo $sup->cat_name; ?></option>
                                                                    <?php
                                                                    }
																	$cat_id=$sup->cat_id;
									                             } ?>  
                                                                
								                             </select>                                                           
														</div>
														</div>
														
														
														
						<div class="col-sm-3" style="display:none">                                                       
  <div class="form-group">
      
      <label class=" control-label" for="form-field-3">
												Brand
											</label>
											
											<?php
											
											 //print_r($department_list);
											 ?>
											
											<select id="dep_id" class="form-control search-select" name="dep_id">
											         
											         <?php
											         
											         $sel_s='';
											         $sel_ser='';
											        
											        
											         ?>
											        
											        <option value=""<?php //echo $sel_0; ?>>-Select-</option> 
											        
											          <?php 
											     //department_list
											
											foreach ($department_list as $key => $item)
											{
											$sel_com='';
											 if($product_details->dep_id==$item->department_id){
											             $sel_com='selected';
											         }
											?>
											         <option value="<?php echo $item->department_id;?>" <?php echo $sel_com;?>><?php echo $item->department_name;?></option>
											         <?php } ?>
											         <!-- 
											         <option value="1"<?php echo $sel_s; ?>>Mobile Phone</option>
                        
                        <option value="2"<?php echo $sel_ser; ?>>Service Repair</option>
                        
                        <option value="3"<?php echo $sel_com; ?>>Computer</option> -->
                       
                      </select>
      </div>
      </div>
      
      
  <div class="col-sm-3" style="display:none">                                                       
  <div class="form-group">
											<label class=" control-label" for="form-field-3" >
												Type 
											</label>
											
											
											
											
                                           <!--  <div id="subcat_data">
											<select onChange="" data-placeholder="Select Category to load Subcategories" id="subcategory" class="form-control search-select" name="subcategory">
											<option selected="selected" value=""></option>
											</select>
                                            </div>
                                            -->
                                            
                                            <select id="subcategory" class="form-control search-select" name="subcategory">
                                                <option value="">-Select-</option>
											         
											         <?php
											         foreach ($type_list as $key => $item)
											{
											$sel_com='';
											
											?>
                    <option value="<?php echo $item->ptype_id;?>" <?php echo $sel_com;?>><?php echo $item->ptype_name;?></option>
                    <?php } ?>
											         
                       
                      </select>
											</div>
										</div>   
                                        
                                        <div class="col-md-3" style="display:none">
<div class="form-group">
<label>Item  </label><?php //print_r($suppliers);?>

<input type="hidden" id="product_id"  name="product_id" class="js-data-product-sn-ajax form-control" style="padding:0px 0px; border: none; box-shadow: none" placeholder="-Select Item-" onChange="setitemselect()"/>

</div>
</div>                                                   


<div class="col-md-3 pull-left" style="display:none">
<div class="form-group">
<label>Item Name  </label><?php //print_r($suppliers);?>

<input type="text" id="product_name"  name="product_name" class=" form-control" style="" placeholder=""/>

</div>
</div>                              
                                                        
                                                        
                                                      <div class="col-sm-3" style="display:;">
                                                      	<div class="form-group">
															<label>From Date  </label>
                                                         <input id="srh_from_date" name="srh_from_date" type='text' class="form-control date-picker" value="<?php echo date("m/d/Y");?>" data-bv-field="date"/>                
                                                         
                                                                                                   
														</div>
														</div>
                                                        
                                                      <div class="col-sm-3" style="display:;">
                                                      	<div class="form-group">
															<label for="s2id_autogen1">To Date </label>
                                                          
															 <input id="srh_to_date" name="srh_to_date" type='text' class="form-control date-picker" value="<?php echo date("m/d/Y");?>" data-bv-field="date"/>        
														</div>
													</div>
                                                    
                                                     <div class="col-sm-3" style="display:none">
                                                      	<div class="form-group">
                                                        	<label for="s2id_autogen1">Show All  : <input id="show_all" name="show_all" type="checkbox" value="1">  </label>
                                                        	
                                                        	 <br/>
                                                            
															<label for="s2id_autogen1">Search with IMEI Number : <input id="with_emi_no" name="with_emi_no" type="checkbox" value="1">      </label>
                                                            
														
                                                      

															
														</div>
													</div>
                                                        
                                                       
                                                        
                                                        
                                                    
                                                    <div class="col-sm-3 pull-right">
                                                      	<div class="form-group pull-right">
															<label for="s2id_autogen1">&nbsp;<br><br>
</label>
                                                          
															 <input type="submit" name="add_category" value="Search" class="btn btn-primary" onClick="searchDetails()">   
															 
															 <button  onClick="window.location.reload()" id="reset" class="btn btn-danger" type="button">Reset</button>
														</div>
													</div>
   
   
                                                  
                                                   

                                                   
                                                    
												</div>
											</div>  
<div class="panel panel-default">
				<!--								<div style="font-weight: 700;" class="panel-heading"></div>
													<div class="panel-body">
														
                                                        
                                                        </div>
                                                        </div>-->                                
                                
                                        <table class="table table-bordered table-condensed table-hover table-striped dataTable" id="products_table" style="width:100%;">
                                            <thead>
                                                <tr>
                                                    <th>#</th>
                                                    <th class="col-md-">Department</th>
                                                    <th class="col-md-" style="text-align:left;">QTY</th>
                                                   <th>Sales Value</th>
                                                    <th>Cost Value</th>
                                                     <th></th>
                                                     <th></th></th>
                                                </tr>
                                            </thead>
                                           <tfoot>
                                               <tr style="background-color:#428bca">
                                                    <th>&nbsp;</th>
                                                    <th>&nbsp;</th>
                                                    <th>&nbsp;</th>
                                                    <th>&nbsp;</th>
                                                     <th>&nbsp;</th>
                                                 
                                                    <th>&nbsp;</th>
                                                 <th>&nbsp;</th>
                                                
                                                </tr>
                                            </tfoot>
                                        </table>
								</div>
							</div>
                            
                            <div style="display:none">
                            <center><h1 class="ml12">Processing</h1></center>
 <table id="" class="table table-bordered table-condensed table-hover table-striped dataTable">
   <tbody><!--<tr>
    <td></td>
    <td class="text-right">From Date:  <span id="f-date-txt"></span>, To Date: <span id="t-date-txt"></span></td>
  </tr>-->
  <tr>
    <th width="50%">Sold</th>
    <td width="50%"><span id="sold">0.00</span></td>
  </tr>
  <tr>
    <th width="50%">Sales Return</th>
    <td width="50%"><span id="s_returned">0.00</span></td>
  </tr>
  
  <tr style="">
    <th width="50%">Purchased </th>
    <td width="50%"><span id="purchased">0.00</span></td>
  </tr>
    <tr style="">
    <th width="50%">Purchase Rerurn</th>
    <td width="50%"><span id="p_returned">0.00</span></td>
  </tr>
  
  <tr style="">
    <th width="50%">Sale Price</th>
    <td width="50%"><span id="s_price">0.00</span></td>
  </tr>
  <tr style="">
    <th width="50%">Cost</th>
    <td width="50%"><span id="c_price">0.00</span></td>
  </tr>
  <tr style="">
    <th width="50%"> Balance</th>
    <td width="50%"><span id="p_balance">0.00</span></td>
  </tr>
<!--<tr>
    <th>Sales Return </th>
    <td><div id="sales_return_tbl">0.00</div><input id="sales_return_fld" type="text" value=""></td>
</tr>-->

     
</tbody></table>

<div class="col-sm-4 pull-right">
                                                      	<div class="form-group pull-right">
															<label for="s2id_autogen1">&nbsp;<br><br>
</label>
                                                          
															 <input type="submit" name="add_category" value="Search" class="btn btn-primary" onClick="load_sum()">          
														</div>
													</div>
   
</div>
                                       
                           <!-- <div class="col-sm-4">
                                                      	<div class="form-group">
                                                        <table class="table table-bordered table-condensed table-hover table-striped dataTable">
                                                        <thead>
                                                        <tr>
                                                        <th>Title</th>
                                                        <th>Values</th>
                                                        </tr>
                                                        <tr>
                                                        <th>Purchased</th>
                                                        <th><div id="purchased">0.00</div></th>
                                                        </tr>
                                                        <tr>
                                                        <th>P Returned</th>
                                                        <th><div id="p_returned">0.00</div></th>
                                                        </tr>
                                                        <tr>
                                                        <th>Sold</th>
                                                        <th><div id="sold">0.00</div></th>
                                                        </tr>
                                                        <tr>
                                                        <th>S Returned</th>
                                                        <th><div id="s_returned">0.00</div></th>
                                                        </tr>
                                                        <tr>
                                                        <th>Balance</th>
                                                        <th><div id="Balance">0.00</div></th>
                                                        </tr>
                                                        <tr>
                                                        <th>Sale Price</th>
                                                        <th><div id="s_price">0.00</div></th>
                                                        </tr>
                                                        <tr>
                                                        <th>Total</th>
                                                        <th><div id="c_price">0.00</div></th>
                                                        </tr>
                                                        </thead>
                                                        </table>
                                                        </div>
                                                        </div>-->
							<!-- end: DYNAMIC TABLE PANEL -->
						<!--</div>
					</div>-->

                    <!-- end grid -->
                    
					
			</div>
			<!-- end: PAGE -->
		</div>
        </div>
		<!-- end: MAIN CONTAINER -->
		<!-- start: FOOTER -->
		
		<!-- end: FOOTER -->
		<!-- start: RIGHT SIDEBAR -->
		<!-- end: RIGHT SIDEBAR -->
		<div id="event-management" class="modal fade" tabindex="-1" data-width="760" style="display: none;">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
						<h4 class="modal-title">Event Management</h4>
					</div>
					<div class="modal-body"></div>
					<div class="modal-footer">
						<button type="button" data-dismiss="modal" class="btn btn-light-grey">
							Close
						</button>
						<button type="button" class="btn btn-danger remove-event no-display">
							<i class='fa fa-trash-o'></i> Delete Event
						</button>
						<button type='submit' class='btn btn-success save-event'>
							<i class='fa fa-check'></i> Save
						</button>
					</div>
				</div>
			</div>
		</div>

		<!-- start ajax model -->
		<div id="ajax-modal" class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" style="display: none;"></div>
		<!-- end ajax model -->

		<!-- start: MAIN JAVASCRIPTS -->
		<?php $this->load->view("common/footer"); ?>
        <script src="<?php echo asset_url(); ?>js/jquery-ui.js" ></script>		
		<?php /*?><script src="<?php echo asset_url(); ?>js/moment-with-locales.js"></script>
		<script type="text/javascript" src="<?php echo asset_url(); ?>js/bootstrap-datetimepicker.js"></script>
		
		<script type="text/javascript" src="<?php echo asset_url(); ?>js/bootbox.min.js"></script><?php */?>
    
    <script type="text/javascript" src="<?php echo asset_url(); ?>js/accounting.js"></script>
    <script type="text/javascript" src="<?php echo asset_url(); ?>js/accounting.min.js"></script>
    <!-- end: MAIN JAVASCRIPTS -->
    <script type="text/javascript" src="<?php echo asset_url(); ?>js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="<?php echo asset_url(); ?>js/dataTables.bootstrap.min.js"></script>       
    <script type="text/javascript" language="javascript" src="<?php echo asset_url(); ?>js/dataTables.buttons.min.js">
	</script>
	<script type="text/javascript" language="javascript" src="<?php echo asset_url(); ?>js/buttons.print.min.js">
	</script>
	<script type="text/javascript" language="javascript" src="<?php echo asset_url(); ?>js/buttons.flash.min.js">
	</script>
	<script type="text/javascript" language="javascript" src="<?php echo asset_url(); ?>js/jszip.min.js">
	</script>
	<script type="text/javascript" language="javascript" src="<?php echo asset_url(); ?>js/pdfmake.min.js">
	</script>
	<script type="text/javascript" language="javascript" src="<?php echo asset_url(); ?>js/vfs_fonts.js">
	</script>
	<script type="text/javascript" language="javascript" src="<?php echo asset_url(); ?>js/buttons.html5.min.js">
	</script>
	<script type="text/javascript" language="javascript" src="<?php echo asset_url(); ?>js/buttons.print.min.js"></script>
	
    
     	<script src="<?php echo asset_url(); ?>/plugins/jquery-inputlimiter/jquery.inputlimiter.1.3.1.min.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/autosize/jquery.autosize.min.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/select2/select2.min.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/jquery.maskedinput/src/jquery.maskedinput.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/jquery-maskmoney/jquery.maskMoney.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/bootstrap-timepicker/js/bootstrap-timepicker.min.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/bootstrap-daterangepicker/moment.min.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/bootstrap-daterangepicker/daterangepicker.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/bootstrap-colorpicker/js/commits.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/jQuery-Tags-Input/jquery.tagsinput.js"></script>
		<?php /*?><script src="<?php echo asset_url(); ?>/plugins/bootstrap-fileupload/bootstrap-fileupload.min.js"></script><?php */?>
		<script src="<?php echo asset_url(); ?>/plugins/summernote/build/summernote.min.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/ckeditor/ckeditor.js"></script>
		<script src="<?php echo asset_url(); ?>/plugins/ckeditor/adapters/jquery.js"></script>
		<script src="<?php echo asset_url(); ?>/js/form-elements.js"></script> 
         <script src="<?php echo asset_url(); ?>js/anime.min.js"></script> 
  <a id="modal_pop_up_serial_no" data-toggle="modal" href="#"></a> 
  <input name="product_id" id="product_id" type="hidden" value="0">
		<script>
		
function pop_up_serial_no(product_id){
	$("#product_id").val(product_id);
	document.getElementById("modal_pop_up_serial_no").click();
}	

function create_product_name(){
	
}


$('select#cat_srh').on('change', function(){
	//alert();

			   		var v = $(this).val();

					$.ajax({
					  type: "get",
					  async: false,
					  url: "<?php echo base_url('products/get_sub_category_by_id'); ?>",
					  data: { category_id: v },
					  dataType: "html",
					  success: function(data) {
						if(data != "") {
							$('#subcat_data').empty();
							$('#subcat_data').html(data);
							$("#subcategory").select2({allowClear: true});
						} else {
							$('#subcat_data').empty();
							var default_data = '<select name="subcategory" id="subcategory" class="form-control search-select" data-placeholder="Select Category to load Subcategories"></select>';
							$('#subcat_data').html(default_data);
							$("#subcategory").select2({allowClear: true});
							set_message("Product Info","No Subcategory found for the select category.");
						}},
					  error: function(){
       					alert('Error occured while getting data from server.');
    				  }
					  
					});
			});
			
			
$('a#modal_pop_up_serial_no').on('click', function () {

	var product_id=$("#product_id").val();
	var warehouse_id=$("#srh_warehouse_id").val();

	
	//alert(each_price);

	//alert(curr_row_no);

	// create the backdrop and wait for next modal to be triggered

	$('body').modalmanager('loading');

	setTimeout(function () {

		var url="<?php echo base_url("reports/view_serial_by_product_id/");?>/"+product_id+'/'+warehouse_id;

		$modal.load(url, '', function () {

			$modal.modal();

		});

	}, 1000);

});	
		
		
		function searchDetailsReset(){
			$('#srh_to_date').val('');
			$('#srh_from_date').val('');
		}
		function searchDetails(){
					
					loadGrid();
					//load_sum();
		}
				
				
			jQuery(document).ready(function() {
			    
			  //  $("#products_table_filter").hide();
				FormElements.init();
					$("#srh_customer_id").select2();
					$('.ml12').fadeOut();
				//TableData.init();
				//loadGrid();
				
				/*var currentDate = new Date();
				$('#srh_to_date').datetimepicker({
					defaultDate: new Date()
				});
				$('#srh_from_date').datetimepicker({
					defaultDate: new Date()
				});*/
			});


			function loadGrid() {
				//vat tbl = $('#products_table');
			//$("#products_table tfoot").empty();
				
			var srh_warehouse_id=$('#srh_warehouse_id').val();;
			//var cat_srh=$('#cat_srh option:selected').text();
			var cat_srh=$('#cat_srh').val();
			var srh_from_date=$('#srh_from_date').val();
			var srh_to_date=$('#srh_to_date').val();
			var subcategory=$('#subcategory').val();
			var with_emi_no=$( "#with_emi_no:checked" ).val()
			var warehouse_name=$( "#srh_warehouse_id option:selected" ).text();
			var cat_name=$( "#cat_srh option:selected" ).text();
			var sub_cat_name=$( "#subcategory option:selected" ).text();
			var product_id=$('#product_id').val();
			var product_name=$('#product_name').val();
			var show_all=$( "#show_all:checked" ).val();
			var dep_id=$('#dep_id').val();
			var brand_name=$( "#dep_id option:selected" ).text();
				var type_name=$( "#dep_id option:selected" ).text();
					var category_corr_name=$( "#dep_id option:selected" ).text();
				
					var srh_sales_rep_id=$('#srh_sales_rep_id').val();;
			
			var d = new Date($.now());
var now_datetime=(d.getDate()+"-"+(d.getMonth() + 1)+"-"+d.getFullYear()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds());

			var message="<div  style='text-align:center'>  <h2>Sales Assistant Wise Department Sales Summary</h2><h5> Warehouse : "+warehouse_name+"</h5><h5>From Date: "+srh_from_date +" , To Date: "+ srh_to_date+ "  , Created Date Time:"+now_datetime+ "</h5></div>";
			
				var message_pdf="";//Product Cost Report  \n  Warehouse:"+warehouse_name+" \n Department: "+cat_name +" , Brand: "+ brand_name+ "  , Type: "+sub_cat_name+" , Created Date Time:"+now_datetime;
			
			if(with_emi_no!=1) with_emi_no=0
			//alert(with_emi_no);
			
			
// 5-Purchased	6-Sold	7-Sales Return	8-Purchase Return	9-Damage Products	10-Sale Price	11-Cost	 12-Balance

			var col_5 = 0;
			var col_6 = 0;
			var col_7 = 0;
			var col_8 = 0;
			var col_9 = 0;
			var col_10 = 0;
			var col_11 = 0;
			var col_12 = 0;
			
				//buttons: ['copy', 'csv', 'excel', 'pdf','print'],

					    $('#products_table').DataTable({
					        "searching": false,
							dom: 'Blfrtip',
							lengthMenu: [[-1, 25,100, 3000,1000], ["All", 25,100, 3000,1000]],
							buttons: [
									   { extend: 'print', text: '<i class="fa fa-print fa-2x"></i>',footer: true, message: message,title: ''},
									// { extend: 'print', text: 'Print',footer: true, message: message,title: '',
										{ extend: 'excel', text: '<i class="fa fa-file-excel-o fa-2x"></i>',footer: true, message: message,title: ''},
										 { extend: 'pdf', text: '<i class="fa fa-file-pdf-o fa-2x"></i>',footer: true, message: message_pdf,title: ''}
										
									],
					        "ajax": {
									'type': 'POST',
									'url': '<?php echo base_url('reports/get_sales_assistant_wise_department_sales_summary');?>',
									'data': {
									   srh_warehouse_id: srh_warehouse_id,
									   cat_srh: cat_srh,
									   srh_from_date: srh_from_date,
									   srh_to_date: srh_to_date,
									   with_emi_no:with_emi_no,
									  subcategory:subcategory,
									  product_id:product_id,
									   show_all:show_all,
									     product_name:product_name,
									     dep_id:dep_id,
									     srh_sales_rep_id:srh_sales_rep_id
											},
									'beforeSend': function(e){/*alert(srh_from_date);*/},
									"complete": function(e){
										 //console.log(e.responseJSON); 
// 5-Purchased	6-Sold	7-Sales Return	8-Purchase Return	9-Damage Products	10-Sale Price	11-Cost	 12-Balance
										
									//	col_5 = e.responseJSON.purchased_qty;
										//col_6 = e.responseJSON.sold_qty;
										/*
										col_7 = e.responseJSON.sales_return_qty;
										col_8 = e.responseJSON.purchases_return_qty;
										col_9 = e.responseJSON.damadge_qty;
										col_10 = e.responseJSON.sale_price_tot;
										col_11 = e.responseJSON.cost_price_tot;
										col_12 = e.responseJSON.product_balance;
										*/
										
										 /*$('#sold').text(e.responseJSON.sold_qty);
										 $('#s_returned').text(e.responseJSON.sales_return_qty);
										 $('#purchased').text(e.responseJSON.purchased_qty);
										 $('#p_returned').text(e.responseJSON.purchases_return_qty);
										 $('#p_balance').text(e.responseJSON.product_balance);
										 $('#s_price').text(accounting.formatMoney(e.responseJSON.sale_price_tot, "", 2, ",", "."));
										 $('#c_price').text(accounting.formatMoney(e.responseJSON.cost_price_tot, "", 2, ",", "."));*/
										// alert(e.responseJSON.cost_price_tot);
										 }
									},
							
							"bProcessing": true,
							"serverSide" : true,
					        "bDestroy": true,
					        "iDisplayLength": -1,
							//"ordering": false,
						"order": [[ 1, "asc" ]],
							 "fnFooterCallback": function (nRow, aaData, iStart, iEnd, aiDisplay) {
				
               var pq = 0, sq = 0, bq = 0, pa = 0, grand_tot = 0, tech_tot = 0, parts_tot=0 , ser_tot=0;
				var ser_cost_tot=0
				var ser_price_tot=0
				col_3=0;
				col_4=0;
				col_2=0;
				col_5=0;
				//col_14=0;
				//alert(aaData.length);
                for (var i = 0; i < aaData.length; i++) {
					//alert(aaData[[i]][5]);
                   // p = (aaData[aiDisplay[i]][2]).split('__');
				//	ser_tot += parseFloat(aaData[[i]][11]);
				//	ser_price_tot += parseFloat(aaData[[i]][9]);
					col_3 += parseFloat(aaData[[i]][3]);
					col_4 += parseFloat(aaData[[i]][4]);
					col_2 += parseFloat(aaData[[i]][2]);
					col_5 += parseFloat(aaData[[i]][5]);
					
					
                }
				
// 5-Purchased	6-Sold	7-Sales Return	8-Purchase Return	9-Damage Products	10-Sale Price	11-Cost	 12-Balance

                var nCells = nRow.getElementsByTagName('th');

				nCells[3].innerHTML = '<div class="text-right">'+accounting.formatMoney(col_3, "", 2, ",", ".")+' </div>';
				nCells[4].innerHTML = '<div class="text-right">'+accounting.formatMoney(col_4, "", 2, ",", ".")+' </div>';
				nCells[2].innerHTML = '<div class="text-right">'+accounting.formatMoney(col_2, "", 2, ",", ".")+' </div>';
				nCells[5].innerHTML = '<div class="text-right">'+accounting.formatMoney(col_5, "", 2, ",", ".")+' </div>';
							/*
				nCells[8].innerHTML = '<div class="text-right">'+col_14+' 
				
			
				</div>';	*/
            }
					    
					    });

					}
					
function load_sum(){
$('.ml12').fadeIn();
var cat_srh=$('#cat_srh').val();
//alert(cat_srh);
var srh_from_date=$('#srh_from_date').val();
var srh_to_date=$('#srh_to_date').val();


$.get("<?php echo base_url('reports/get_list_product_for_print_summary');?>?cat_srh="+cat_srh+"&srh_from_date="+srh_from_date+"&srh_to_date="+srh_to_date).done(function( data ) {
					//console.log(data);
					var obj = jQuery.parseJSON(data);
					console.log(obj);
							$('#sold').text(obj.sold_qty);
 $('#s_returned').text(obj.sales_return_qty);
 $('#purchased').text(obj.purchased_qty);
 $('#p_returned').text(obj.purchases_return_qty);
 $('#p_balance').text(obj.product_balance);
 $('#s_price').text(accounting.formatMoney(obj.sale_price_tot, "", 2, ",", "."));
 $('#c_price').text(accounting.formatMoney(obj.cost_price_tot, "", 2, ",", "."));
	$('.ml12').fadeOut();
	});

}


$('.ml12').each(function(){
  $(this).html($(this).text().replace(/([^\x00-\x80]|\w)/g, "<span class='letter'>$&</span>"));
});

anime.timeline({loop: true})
  .add({
    targets: '.ml12 .letter',
    translateX: [40,0],
    translateZ: 0,
    opacity: [0,1],
    easing: "easeOutExpo",
    duration: 1200,
    delay: function(el, i) {
      return 500 + 30 * i;
    }
  }).add({
    targets: '.ml12 .letter',
    translateX: [0,-30],
    opacity: [1,0],
    easing: "easeInExpo",
    duration: 1100,
    delay: function(el, i) {
      return 100 + 30 * i;
    }
  });
  
  
  
   $(".js-data-product-sn-ajax").select2({
	   
	  // var cat_srh=$("#cat_srh").val();
	 //  var subcategory=$("#subcategory").val();
        ajax: {
			'type': 'POST',
				'url': '<?php echo base_url('reports/get_product_sn?srh_warehouse_id=');?>'+$("#warehouse_id").val(),
                dataType: 'json',
                delay: 0,
			
                data: function (query) {
							//alert(1);
                if (!query)
                        query = '';
                return {
                search_string: query,
				 cat_srh: $("#cat_srh").val(),
				  subcategory: $("#subcategory").val(),
				service_item_avalable: $("#service_item_avalable").val(),
                        format: 'json'
                };
                },
                results: function (data) {
                return {
                results: $.map(data, function (item) {
                return {
					//alert();
                text: item.product_name+' ('+item.product_code+')',
                        slug: item.product_id,
                        id: item.product_id
                };
                })
                };
                },
                cache: true
         }
        });

</script>

     
	</body>
	<!-- end: BODY -->
</html>