        <div class="breadcrumbs">
            <div class="breadcrumbs-inner">
                <div class="row m-0">
                    <div class="col-sm-4">
                        <div class="page-header float-left">
                            <div class="page-title">
                                <h1>Create Invoice </h1>
                            </div>
                        </div>
                    </div>
                    <!--div class="col-sm-8">
                        <div class="page-header float-right">
                            <div class="page-title">
                                <ol class="breadcrumb text-right">
                                    <li><a href="#">Dashboard</a></li> 
                                    <li><a href="#">Forms</a></li>
                                    <li class="active">Basic</li>
                                </ol>
                            </div>
                        </div>
                    </div-->
                </div>
            </div>
        </div>
        <style>
.content{position: relative;}
.overlay{position: absolute;left: 0; top: 0; right: 0; bottom: 0;z-index: 2;background-color: rgba(255,255,255,0.8);position: fixed;   overflow-y: scroll;}
.overlay-content {
    position: absolute;
    transform: translateY(-50%);
     -webkit-transform: translateY(-50%);
     -ms-transform: translateY(-50%);
    top: 50%;
    left: 15%;
    right: 0;
    text-align: center;
    color: #555; 
    position: fixed; 
   overflow-y: scroll;
}

.tableFixHead          { overflow: auto; }
.tableFixHead thead th { position: sticky; top: 0; z-index: 1; }
</style>  
                                                                
    <div class="overlay" style="display:block" id="load"><div class="overlay-content"><img src="<?php echo base_url(); ?>assets/images/loader.gif" alt="Loading..." style="width: 60px;"/></div></div>
                    
      
          <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/lib/chosen/chosen.min.css">
  
                <div class="content">
            <div class="animated fadeIn">

                <div class="form-group">
                    <input type="hidden" id="temp_id"  name="temp_id" placeholder="" value="<?php echo $temp_id;?> "class="col-xs-12 col-sm-12" />
                                                                
                                   <div class="row">
                                                   
                                                    
                                                     <!--div class="col-sm-3">
                                                           MES Ref. No.
                                                           <input type="text" id="mes_ref"  name="mes_ref" placeholder="" value=""class="col-xs-12 col-sm-12 input-sm form-control-sm form-control" /> 
                                                    </div-->
                                                    
                                                    <div class="col-sm-3">
                                                        Sales Rep
                                                            <select class="form-control standardSelect choosen-select" id="saleselect" data-placeholder="Choose a Supplier..." name="sales">
    							                                                                                     
                                                            </select>   
                                                    </div>
                                                    
                                                     <div class="col-sm-5">  
                                                        Customer
                                                            <select class="form-control standardSelect choosen-select" id="supselect" data-placeholder="Choose a Supplier..." name="sup">
    							                                <option value="0"> Select Customer </option>
                                                                                                                       
                                                            </select> 
                                                                                 
                                                    </div>
                                                    
                                                    
                                                    <div class="col-sm-4">   
                                                        Products
                                                        <select class="form-control standardSelect" id="itemselect" data-placeholder="Type to Choose..." name="itemselect" autofocus>
							                                <option value="">  </option>                                                          
                                                        </select>                          
                                                    </div>
                                                    
                                                    <!--div class="col-sm-1" style="text-align: center;">Add New<br>
                                                          
                                                            <!--button class="btn btn-secondary btn-sm" name="Ser" id="add_services" onclick ="add_data(this.id);" data-backdrop='static' data-keyboard='false'>Services</button-->
                                                            <!--button class="btn btn-secondary btn-sm" name="Ser" id="new_customer" onclick ="add_data(this.id);" data-backdrop='static' data-keyboard='false'>Customer</button>
                                                    </div-->
                                                    
                                               </div>
                                               
                                               <div class="row">
                                                    <!--div class="col-sm-4">  
                                                        Catagory
                                                        <select class="standardSelect form-control" id="catselect" data-placeholder="Choose a cat..." name="cat">
							<option value="0"> Select Category </option>
                                                         <?php 
                                                         foreach ($category as $cat) {            
                                                          ?>
							<option value="<?php echo $cat->cat_id; ?>"><?php echo $cat->cat_name; ?></option>
                                                          <?php }?>                                                           
                                                        </select>                          
                                                    </div-->
                                                  
                                                    
                                                    <!--div class="col-sm-3">
                                                            Part Number
                                                            <select class="form-control standardSelect" id="partselect" data-placeholder="Choose a part..." name="partselect">
							                                    <option value="">Select</option>                    
                                                        </select>
                                                              </div-->
                                                    <!--div class="col-sm-3">   
                                                        Spec
                                                            <select class="form-control standardSelect" id="specselect" data-placeholder="Choose a spec..." name="specselect">
							                                    <option value="">  </option>                    
                                                        </select>                         
                                                    </div>
                                                   
                                                     
                                               
                                                   <div class="col-sm-6">   
                                                        Products
                                                        <select class="form-control standardSelect" id="itemselect" data-placeholder="Type to Choose..." name="itemselect">
							                                <option value="">  </option>                                                          
                                                        </select>                          
                                                    </div-->
                                                   </div>
                                               
                                               <div class="row">
                                                   
                                                    <div class="col-sm-2">
                                                            Price
                                                        <input type="text" id="price"  name="price" placeholder="" value="<?php  ?> "class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" />
                                                        
                                                    </div><br><div class="" style="display:none" id="loader"> &nbsp; <div class=""><img src="<?php echo base_url(); ?>assets/images/loader.gif" alt="Loading..." style="width: 30px;"/></div></div>
    
                                                    <div style="display:none">
                                                    <div class="col-sm-1" >
                                                            Currency
                                                        <select class="form-control-sm form-control" id="curid" data-placeholder="Choose a currency" name="curselect">
							                                
                                                         <?php 
                                                         foreach ($curren as $cat) {            
                                                          ?>
							                                <option value="<?php echo $cat->curr_id; ?>"><?php echo $cat->curr_symble; ?></option>
                                                          <?php }?>                                                         
                                                        </select>      
                                                    </div>
                                                    
                                                    
                                                        <div class="col-sm-2" id="">
                                                           Cur. Rate
                                                        <input type="text" id="cur_rt"  name="cur_rt" placeholder="" value="1"class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onkeyup="cur_cal()"/>
                                                    </div>
                                                    </div>
                                                    
                                                    <div class="col-sm-2" style="display:none;" id="for_foreign1">
                                                            Price
                                                        <input type="text" id="pricelkr"  name="pricelkr" placeholder="" value="<?php  ?> "class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onkeyup="cur_cal()"/>
                                                        
                                                    </div>
                                                    <div class="col-sm-2">
                                                            Quantity
                                                        <input type="text" id="qty"  name="qty" placeholder="" value=""class="col-xs-12 col-sm-12 form-control input-sm form-control-sm"/ >
                                                                <?php echo form_error('productqty'); ?>
                                                    </div>
                                                     
                                                    <div class="col-sm-2">
                                                            Available Stock
                                                        <input type="text" id="avstk"  name="avstk" placeholder="" value=""class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" readonly/>
                                                               
                                                    </div>
                                                    
                                                    <!--div class="col-sm-1">
                                                            Unit
                                                            <select class="form-control-sm form-control" id="unitid" data-placeholder="Choose a currency" name="unitid" disabled >
							                                <option selected value='0002'>EA</option>
                                                                                                                 
                                                        </select> 
                                                        
                                                                
                                                    </div-->
                                                    
                                                    
                                                    <div class="col-sm-2">
                                                            Total
                                                        <input type="text" id="total"  name="total" placeholder="" value="<?php  ?> "class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" readonly/>
                                                                <?php echo form_error('productqty'); ?>
                                                    </div>
                                                    
                                                    <div class="col-sm-1">
                                                            Free
                                                        <input type="text" id="free"  name="free" placeholder="" value="<?php  ?> "class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" />
                                                        <input type="hidden" id="freeqty"  name="freeqty" placeholder="" value=""class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" />
                                                    </div><div class="" style="display:none" id="loader2"> &nbsp; <div class=""><img src="<?php echo base_url(); ?>assets/images/loader.gif" alt="Loading..." style="width: 30px;"/></div></div>
    
                                                    
                                                   <div class="col-sm-1"><br>
                                                        
                                                       <button type="button" class="btn btn-secondary btn-sm" name="add" id="addrow" onclick="addrow();">
                                                                                <i class="ace-icon fa fa-pencil-square-o bigger-150 middle orange2"></i>
                                                                                <span class="bigger-110">Add</span></button>
                                                                                
                                                                                

							</button>
                                                                  </div> 
                                                                  
                                                                  <div id="dis_er" style="align:center;color:red"></div>
                                                </div>    
                                               
                                         <div class="space"></div>
                                        
                                         <div class="row" id="agent" style="display: none">
                                            <div class="col-sm-3">
                                                            Contact
                                                        <input type="text" id="ag_cont"  name="ag_cont" placeholder="Contact Detail" value="" class="col-xs-12 col-sm-12" />
                                                                
                                                    </div>
                                            <div class="col-sm-3">
                                                            Credit Limit
                                                        <input type="text" id="ag_limit"  name="ag_limit" placeholder="" value=""class="col-xs-12 col-sm-12" />
                                                              
                                                    </div>
                                            <div class="col-sm-3">
                                                            Credit Time
                                                        <input type="text" id="ag_time"  name="ag_time" placeholder="" value="" class="col-xs-12 col-sm-12" />
                                                               
                                                    </div>
                                            <div class="col-sm-3">
                                                            Balance
                                                        <input type="text" id="ag_bal"  name="ag_bal" placeholder="" value="" class="col-xs-12 col-sm-12" />
                                                                
                                                    </div>
                                            
                                        </div>
                                        
                                        
        

                                      <div class="space"></div>
                                      
                                                <div class="row">
                                                        
                                                </div>
                                      
                                      
                                       <div class="space" style="padding-bottom: 10px;"></div>
                                      
                                      <div class="row">
                                    									<div class="col-lg-12" style="padding-bottom: 10px;overflow:scroll;height:250px;width:100%;overflow:auto">
                                    										<table id="simple-table" class="table table-bordered tableFixHead">
                                    											<thead class="thead-dark">
                                    												<tr>
                                    													
                                    													<th scope="col">ID</th>
                                    													<th>Item Code</th>
                                    													<th>Item Description</th>
                                    													<th style="text-align:right">Unit</th>
                                    													<th style="text-align:right"><span id="cr_chng">Rate</span> </th>
                                    													<th style="text-align:right">Quantity </th>
                                                                                        <th style="text-align:right"><span id="cr2_chng">Total</span>  </th>
                                                                                        <th style="text-align:right">Free Item</th>                
                                    													<th>Action</th>
                                    												</tr>
                                    											</thead>
                                            
                                    											<tbody id="show_data" >
                                    									
                                    								
                                    											</tbody>
                                    										</table>
                                    									</div><!-- /.span -->
                                                                                                            
                                                                                                            
                                    								</div><!-- /.row -->
                                    								
                                    								<div class="row">
                                    								    <div class="col-lg-6">
                                    								        
                                    								       <div class="row">
                                    								           
                                    							        
                                    						<!--div class="col-lg-6">   
                                    						<form id="calc">
                                                     
                                                        T & C Catagory 
                                                            <select class="form-control standardSelect choosen-select" id="tccat" data-placeholder="" name="tccat">
    							                                <option value="0"> Select T & C Catagory </option>
                                                             <?php 
                                                             foreach ($tccatdetails as $dbagent) {            
                                                              ?>
    							                            <option value="<?php echo $dbagent->tcat_id; ?>"><?php echo $dbagent->tcat_name; ?></option>
                                                              <?php }?>                                                           
                                                            </select>                        
                                                    
                                                                </div-->
                                                    
                                                    		 <!--div class="col-lg-6">       
                                                     
                                                       TC Description
                                                            <select class="form-control standardSelect choosen-select" id="tcdes" data-placeholder="Choose..." name="tcdes">
    							                                <option value="0"> Select Conditions</option>
    							                                                                                    
                                                            </select>                         
                                                    
                                                    
                                                                
                                                            </div-->
                                                            
                                                            <!--div class="col-lg-12"> Terms & Conditions
                                                            
                                                              <table  id="data">
                                                          <thead>
                                                        
                                                          <tr id="finalrow">
                                                            <td></td>
                                                            <td></td>
                                                           
                                                            <td id="total"></td>
                                                          </tr>
                                                          </thead>
                                                          
                                                          <tbody></tbody>
                                                        
                                                        </table></div>
                                                            
                                                          
                                                             </form -->   
                                                             
                                                            <div class="col-lg-12">
                                                                 Remarks<br>
                                                                 <textarea id="remark" name="remark" rows="2" cols="60"></textarea>
                                                            </div> 
                                                    
                                                    </div>
                                                   </div>
                                    								    
                                    								    
                                    								    
                                    								    <div class="col-lg-6">
                                    								        <div class="row">
                                    									<div class="col-lg-12" style="padding-bottom: 2px;">
                                    									     <div class="row" style="float: right;">
                                    									         <div class="col-lg-6 d-inline">
                                                                              Total Quantity
                                                                            <input type="text" id="inv_tot_item"  name="inv_tot_item" placeholder="Total" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" style="text-align: right;"/>
                                                                        </div>
                                                                       <div class="col-lg-6 float-end">
                                                                              Sub Total
                                                                            <input type="text" id="inv_total"  name="inv_total" placeholder="Total" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" style="text-align: right;"/>
                                                                        </div>
                                                                        
                                                                </div> 
                                    									    
                                                                         </div>
                                                                         </div>
                                                                         
                                                                       
                                                                         
                                                                         <div class="row">
                                            									<div class="col-lg-12" style="padding-bottom: 2px;">
                                            									     <div class="row" style="float: right;">
                                                                                
                                                                                 <div class="col-lg-6 d-inline">
                                                                              Discount
                                                                              <input type="text" id="dis_total"  name="dis_total" placeholder="Dis_amount" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onclick="this.select();" onkeyup="cal_dis_amt();" style="text-align: right;" readonly/>
                                                                         <div class="help-block" id="input-span-slider"></div>
                                                                        </div>
                                                                                
                                                                                <div class="col-lg-6 col-lg-6  float-end">
                                                                                      Discount %
                                                                                 <input type="text" id="dis_pc"  name="dis_pc" placeholder="%" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onclick="this.select();" onkeyup="cal_dis_pc();" style="text-align: right;"/>
                                                                         </div>
                                                                         
                                                                        
                                                                                </div>
                                            									    
                                            									    </div>
                                                                         </div>
                                                                         
                                                                         
                                                                         <div class="row">
                                    									<div class="col-lg-12" style="padding-bottom: 2px;">
                                    									     <div class="row" style="float: right;">
                                                                        
                                                                        <div class="col-lg-12 float-end">
                                                                              Net Total
                                                                              <input type="text" id="net"  name="net" placeholder="Net Total" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onclick="this.select();" onkeyup="cal_dis_pc();" style="text-align: right;"/>
                                                                        <div class="help-block" id="input-span-slider"></div>
                                                                        </div>
                                                                </div>
                                    									    
                                    									    </div>
                                                                         </div>
                                                                         
                                                                           <div id="tx" style="display: none;">
                                                                             <div class="row">
                                    									<div class="col-lg-12" style="padding-bottom: 2px;">
                                                                        
                                                                         <div class="row" style="float: right;">
                                                                        
                                                                       <div class="col-lg-6 d-inline">
                                                                                 Tax amount
                                                                            <input type="text" id="tax_total"  name="tax_total" placeholder="Dis_amount" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onclick="this.select();" onkeyup="cal_tax_amt();" style="text-align: right;"/>
                                                                        </div>
                                                                        <div class="col-lg-6 float-end">
                                                                              Tax %
                                                                              <input type="text" id="tax_pc"  name="tax_pc" placeholder="%" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onclick="this.select();" onkeyup="cal_tax_pc();" style="text-align: right;"/>
                                                                        <div class="help-block" id="input-span-slider"></div>
                                                                        </div>
                                                                </div>
                                                                        
                                                                         </div>
                                                                         </div>
                                                                         
                                                                         <div class="row">
                                    									<div class="col-lg-12" style="padding-bottom: 2px;">
                                    									     <div class="row" style="float: right;">
                                                                        
                                                                        <div class="col-lg-12 float-end">
                                                                              Total
                                                                              <input type="text" id="ttot"  name="ttot" placeholder="Total" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onclick="this.select();" onkeyup="cal_dis_pc();" style="text-align: right;"/>
                                                                        <div class="help-block" id="input-span-slider"></div>
                                                                        </div>
                                                                </div>
                                    									    
                                    									    </div>
                                                                         </div>
                                                                         
                                                                         </div>
                                                                      
                                                                         <div id="for_tax" style="display: none;">
                                                                         
                                                                         <div class="row" >
                                                                         <div class="col-lg-12" style="padding-bottom: 2px;">
                                    									        <div class="row" style="float: right;">
                                    									    <div class="col-lg-12 d-inline">
                                    									        NBT <?php echo $tax[1]->tax_value  ?>% <input type="checkbox" id="chk_nbt" name="chk_nbt" value="10"  onclick="mynbt()">
                                                                                  <input type="text" id="nbt"  name="nbt" placeholder="nbt" value="0.00" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onkeyup="cal_total();" style="text-align: right;"/>
                                                                            <div class="help-block" id="input-span-slider"></div>
                                    									         </div>
                                    									         </div>
                                    									    
                                    									    </div>     
                                                                             
                                    									<div class="col-lg-12" style="padding-bottom: 2px;">
                                    									    <div class="row" style="float: right;">
                                    									    
                                    									    
                                    									    <div class="col-lg-12 d-inline">
                                    									        VAT <?php echo $tax[0]->tax_value  ?>% <input type="checkbox" id="chk_vat" name="chk_vat" value="10" onclick="myvat()">
                                                                                  <input type="text" id="vat"  name="vat" placeholder="vat" value="0.00" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onkeyup="cal_total();" style="text-align: right;"/>
                                                                            <div class="help-block" id="input-span-slider"></div>
                                    									         </div>
                                    									    </div>
                                    									    </div>
                                    									   
                                    									    
                                                                         </div>
                                                                         
                                                                         <div class="row">
                                    									<div class="col-lg-12" style="padding-bottom: 2px;">
                                    									     <div class="row" style="float: right;">
                                                                        
                                                                        <div class="col-lg-12 float-end">
                                                                              Total
                                                                              <input type="text" id="txtot"  name="txtot" placeholder="Total" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onkeyup="cal_dis_pc();" style="text-align: right;"/>
                                                                        <div class="help-block" id="input-span-slider"></div>
                                                                        </div>
                                                                </div>
                                    									    
                                    									    </div>
                                                                         </div>
                                                                         
                                                                         </div>   
                                                                         
                                                                         
                                                                         
                                                                        
                                                                       <div id="trafee" style="display: block;">  
                                                                          <div class="row">
                                    									<div class="col-lg-12" style="padding-bottom: 2px;">
                                    									     <div class="row" style="float: right;">
                                                                        
                                                                        <!--div class="col-lg-12 float-end">
                                                                              Transport Fee
                                                                              <input type="text" id="trfee"  name="trfee" placeholder="Transport Fee" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onclick="this.select();" onkeyup="cal_total();" style="text-align: right;"/>
                                                                        <div class="help-block" id="input-span-slider"></div>
                                                                        </div-->
                                                                </div>
                                    									    
                                    									    </div>
                                                                         </div>
                                                                         </div>
                                                                         
                                                                         
                                                                         
                                                                          <div id="for_foreign2" style="display: none;">
                                                                              
                                                                              
                                                                         <div class="row">
                                                                             
                                                                              <div class="col-lg-12" style="padding-bottom: 2px;">
                                    									         <div class="row" style="float: right;">
                                    									    <div class="col-lg-12 float-end">
                                                                                 Shipping Fee 
                                                                                  <input type="text" id="ship"  name="ship" placeholder="ship" value="0.00" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onclick="this.select();" onkeyup="cal_total();" style="text-align: right;"/>
                                                                            <div class="help-block" id="input-span-slider"></div>
                                                                            </div>
                                                                            </div>
                                                                            
                                    									     </div>
                                    									<div class="col-lg-12" style="padding-bottom: 2px;">
                                    									    <div class="row" style="float: right;">
                                    									    <div class="col-lg-12 float-end">
                                                                                 Bank Fee
                                                                                  <input type="text" id="bank_fee"  name="bank_fee" placeholder="bank_fee" value="0.00" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onclick="this.select();" onkeyup="cal_total();" style="text-align: right;"/>
                                                                            <div class="help-block" id="input-span-slider"></div>
                                                                            </div>
                                                                           </div>
                                                                            
                                    									     </div>
                                    									    
                                                                         </div>
                                                                         </div>
                                                                       
                                                                        
                                                                         <div class="row">
                                    									<div class="col-lg-12" style="padding-bottom: 2px;">
                                    									    <div class="row" style="float: right;">
                                                                        

                                                                        <!--div class="col-lg-6 float-end">
                                                                              Other - Reason
                                                                              <input type="text" id="other_reason"  name="other_reason" placeholder="Total" value="Other" class="col-xs-12 col-sm-12 form-control" />
                                                                        <div class="help-block" id="input-span-slider"></div>
                                                                        </div-->
                                                                                                                                               <div class="col-lg-12 d-inline">
                                                                              Other Fee
                                                                            <input type="text" id="other_amnt"  name="other_amnt" placeholder="Other" value="0.00" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onclick="this.select();" onkeyup="cal_total();" style="text-align: right;"/>
                                                                        </div>
                                                                </div>
                                    									    </div>
                                                                         </div>
                                                                         
                                                                          
                                                                         
                                                                         
                                                                         
                                                                         <div class="row">
                                    									<div class="col-lg-12" style="padding-bottom: 15px;padding-top: 15px;">
                                    									    <div class="row" style="float: right;">
                                    									    <div class="col-lg-12 d-inline">
                                                                            Grand Total
                                                                            <input type="text" id="final"  name="final" placeholder="Total" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" style="text-align: right;"/>
                                                                        </div>
                                                                        </div>
                                                                         </div>
                                                                         </div>
                                    								        
                                    								    </div>
                                    								    
                                    								</div>
                                                                
                                                                
                                                                         
                                                         <input type="hidden" value="0" id="auth" name="auth">     
                                                          <div class="row">
                                    									<div class="col-lg-12" style="padding-bottom: 10px;">      
                                    
                                                                <div class="row" style="float: right; text-align: right;">
                                                                        
                                        <div class="col-md-12 center-block">
                                            <button class="btn btn-outline-secondary btn-sm" id="btn_save">
                                                    <i class="ace-icon fa fa-floppy-o bigger-120 blue"></i>
                                                   Create Invoice
                                            </button>
                                             <!--button class="btn btn-outline-secondary btn-sm" id="btn_draft">
                                                    <i class="ace-icon fa fa-floppy-o bigger-120 blue"></i>
                                                    Save for Later
                                            </button>
                                            <button class="btn btn-outline-secondary btn-sm" id="btn_cancel">
                                                    <i class="ace-icon fa fa-times red2"></i>
                                                    Cancel invoice
                                            </button-->
                                        </div>
                                        
                                    </div>
                                     </div>
                                    </div>
                                    
                    
                </div>
                                    
            </div>
            
            </div>
            
           
            
            <div class="clearfix"></div>
            
             <!--MODAL add-->
          <form id="frm_add_data">
              <div class="modal fade" id="addmodel" tabindex="-1" role="dialog" aria-labelledby="scrollmodalLabel" aria-hidden="true" data-backdrop='static' data-keyboard='false'>
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="scrollmodalLabel">Add</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body" id="Modal_Add">
                            
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                            <button type="button" class="btn btn-primary" id="save_data">Confirm</button>
                        </div>
                    </div>
                </div>
            </div>
          </form>
            <!--END MODAL add-->
            
            
            <!--MODAL edit-->
          <form id="frm_edit_data">
              <div class="modal fade" id="editmodel" tabindex="-1" role="dialog" aria-labelledby="scrollmodalLabel" aria-hidden="true" data-backdrop='static' data-keyboard='false'>
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title" id="scrollmodalLabel">Edit</h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body" id="modal_edit">
                            
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
                            <button type="button" class="btn btn-primary" id="update_data">Confirm</button>
                        </div>
                    </div>
                </div>
            </div>
          </form>
            <!--END MODAL edit-->
            
             <!--MODAL DELETE-->
         <form>
            <div class="modal fade" id="Modal_Delete" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" data-backdrop='static' data-keyboard='false'>
              <div class="modal-dialog" role="document">
                <div class="modal-content">
                  <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Delete Product</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                      <span aria-hidden="true">&times;</span>
                    </button>
                  </div>
                  <div class="modal-body">
                       <strong>Are you sure to delete this record?</strong>
                  </div>
                  <div class="modal-footer">
                    <input type="hidden" name="product_code_delete" id="product_code_delete" class="form-control">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">No</button>
                    <button type="button" type="submit" id="btn_delete" class="btn btn-primary">Yes</button>
                  </div>
                </div>
              </div>
            </div>
            </form>
        <!--END MODAL DELETE-->
            
                    

                    
    
            
            
<script src="<?php echo base_url(); ?>assets/js/jquery.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/bootstrap.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script src="<?php echo base_url(); ?>assets/js/lib/chosen/chosen.jquery.min.js"></script>

<script>

//var input = document.getElementById("qty");



var input = document.getElementById("price");

input.addEventListener("keyup", function(event) {
  // Number 13 is the "Enter" key on the keyboard
  if (event.keyCode === 13) {
    event.preventDefault();
    document.getElementById('qty').focus(); document.getElementById("qty").select();
  }
});

$(document).ready(function() {
    document.getElementById("load").style.display = "none";
    cal_ttot(); 
     get_sup();
    show_product();
   
   
   $('#qty').keyup(function(e){
         if(e.keyCode == 13)
            {
               document.getElementById('addrow').focus();
               const myButton = document.getElementById("addrow");
               myButton.style.backgroundColor = "red";
            }else{
                var price = $('#price').val();
                var qty = $('#qty').val();
                var totl = price * qty;
                $('#total').val(totl.toFixed(2));
            }
           
    });

});

$(document).ready(function() {
  $("#data").on('click', '.removeBtn', function() {

    $(this).closest('tr').remove();

    let tr = $("").appendTo("#data tbody");
    $('#calc input, #calc select').each(function(index) {
      var input = $(this);
      $(tr).insertBefore("#finalrow").append('' + $(input).val() + '');
    });

    const componentFactor = $(tr).children(".row-component").text();
    const units = $(tr).children(".row-units").text();
    const total = componentFactor * units;
    $("#total").html(sumColumn(5));


    function sumColumn(index) {
      var total = 0;
      $("td:nth-child(" + index + ")").each(function() {
        if (this.id !== 'total') {
          total += parseInt($(this).text(), 10) || 0;
        }
      });
      return total;

    }


  });
});

//cusromer select

    $('#saleselect').change(function(){ 
       
                $('#itemselect option').remove();
                $('#supselect option').remove();
               
                
                $('[name="price"]').val("");
                    $('[name="pricelkr"]').val("");
            var part_id = $(this).val();
             document.getElementById("load").style.display = "block";
             
         
          
             $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('cust_data')?>',
                dataType : 'json',
                data : {part_id:part_id},
                success : function(data){
                    
                     $('#supselect').append($('<option>', {
                                                            value: "0",
                                                            text: "select"
                                                        }));
                                                        
                            for (var i = 0; i < data['customer'].length; i++) {
                                
                                  
                                                        
                               $('#supselect').append($('<option>', {
                                                            value: data['customer'][i].custmid,
                                                            text: data['customer'][i].cusname+" - "+data['customer'][i].cusadrs
                                                        }));
                            }
                            
                            
                                $('#itemselect').append($('<option>', {
                                                            value: "",
                                                            text: "select"
                                                        }));
                     
                 var i;
                            for (var i = 0; i < data['item'].length; i++) {
                               $('#itemselect').append($('<option>', {
                                                            value: data['item'][i].item_id,
                                                            text: data['item'][i].itm_name
                                                        }));
                            }
                            
                    $("#supselect").trigger("chosen:updated");
                    $("#itemselect").trigger("chosen:updated");
                       // $('[name="price"]').val(data['item'][0].sel_price);
                  //$('[name="pricelkr"]').val(data['item'][0].sel_price);
                 // $("#unitid").val(data['item'][0].uid);
                  document.getElementById("load").style.display = "none";
                  document.getElementById("supselect").focus();
                 // $('select[name^="supselect"]').eq(0).focus();
					
                }
 
            }); 
      });  

    $('#supselect').change(function(){
         var sup_id = $(this).val();
             document.getElementById("load").style.display = "block";
          
          if(sup_id!=0){
              $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('custom_data')?>',
                dataType : 'json',
                data : {sup_id:sup_id},
                success : function(data){
                    
				$('[name="dis_pc"]').val(data[0].cust_discount);
				
				if(data[0].cust_discount!=0.00){
				    //document.getElementById("dis_pc").readonly = true;
				    //$('#dis_pc').attr('readonly', true);
				}else{
				    //$('#dis_pc').attr('readonly', false);document.getElementById("load").style.display = "none";
				    
				}
				
					cal_dis_pc();
					document.getElementById("load").style.display = "none";
                }
 
            });
          }
             
    });

    var timer = null;
   
    /*$('#price').keydown(function(){
        document.getElementById("loader").style.display = "block"; 
           clearTimeout(timer); 
           timer = setTimeout(cur_cal, 1000)
    }); */
    
    $('#price').keyup(function(e){
        if(e.keyCode == 13)
            {
                document.getElementById("loader").style.display = "block";
                cur_cal();
            }
           
    });
    
    function cur_cal(){
        var act_val = $('#pricelkr').val();
        var price = $('#price').val();
        var cal = (act_val/100)*90;

        document.getElementById("loader").style.display = "none"; 
            
       
        sin_item_tot();
        cal_ttot();
        
    }
    
     $('#qtyx').keyup(function(e){
         
        if(e.keyCode == 13)
            {
                clearTimeout(timer); 
           timer = setTimeout(sin_item_tot, 100)
                
            }else{
              // setInterval(sin_item_tot(), 3000);
            }
           
    });
    
    function sin_item_tot(){
 
        var total = $('#price').val() * $('#qty').val();
        $('[name="total"]').val(total.toFixed(2));
            var oriqty = $('#qty').val(); var avlqty = $('#avstk').val();
    
            var fr = Math.floor($('#qty').val() / $('#freeqty').val());
           
            if(+oriqty > +avlqty){
                document.getElementById('dis_er').innerHTML = 'No Available Stock';
                document.getElementById("loader2").style.display = "none";document.getElementById('qty').focus(); document.getElementById("qty").select();
                
            }
        
        
        cal_ttot();
    }
    
    var timer = null;
    $('#free').keydown(function(){
        document.getElementById("loader2").style.display = "block"; 
           clearTimeout(timer); 
           timer = setTimeout(cal_free, 1000)
    });
    
    function cal_free(){
        if($('#freeqty').val()!=0){
            
            var fr = $('#qty').val() / $('#freeqty').val();
            
            if($('#free').val() > (fr*3)){
                swal({title: "Need Approval!",  text: "Free Quantity exceeded",showConfirmButton:true, showCancelButton: true, confirmButtonText: 'Ok',
              focusConfirm:true}).then(function() {
                    document.getElementById('addrow').focus();
                    document.getElementById('addrow').style.backgroundColor = '#1e2124'; 
                  });
                $('[name="auth"]').val(1);
               document.querySelector('#btn_save').innerHTML = 'Request Approval';
             document.getElementById("loader2").style.display = "none";
                return;
            }else{
                $('[name="auth"]').val(0);
                    document.getElementById('addrow').focus();
                    document.getElementById('addrow').style.backgroundColor = '#1e2124'; 
               document.querySelector('#btn_save').innerHTML = 'Create Invoice';
               document.getElementById("loader2").style.display = "none";
            }
        }else{ $('[name="free"]').val(0);
    
            document.getElementById("loader2").style.display = "none";
            document.getElementById('free').focus(); document.getElementById("free").select();
            return;
        }
        
    }

    function cal_dis_amt(){
      $('#dis_pc').val("");
      cal_total();
      cal_ttot();
    }

    function cal_dis_pc(){
        var pc = $('#dis_pc').val();
        var dis = ($('#inv_total').val() * pc)/100;
      $('#dis_total').val(dis.toFixed(2));
      var nett = parseFloat($('#inv_total').val()) - dis;
      $('#net').val(nett.toFixed(2));
      cal_ttot();
      cal_total();
    }
   
    function cal_ttot(){
        
        var ttot = parseFloat($('#tax_total').val())+parseFloat($('#net').val());
        $('#ttot').val(ttot.toFixed(2));
        
        var txtot = parseFloat($('#net').val())+parseFloat($('#vat').val())+parseFloat($('#nbt').val());
        $('#txtot').val(txtot.toFixed(2));
    }

    function cal_total(){
    
      if($('#dis_total').val()!=""){
        var dis =  $('#dis_total').val();
      }else{ var dis = 0;}
      
        var other = $('#other_amnt').val();
        var vat = $('#vat').val();
        var nbt = $('#nbt').val();
        var ship = $('#ship').val();
        var bank = $('#bank_fee').val();
        var tax_total = $('#tax_total').val();
        var trfee = $('#trfee').val();

        var total = parseFloat($('#inv_total').val()) - parseFloat(dis) + parseFloat(other);
        $('[name="final"]').val(total.toFixed(2));
        cal_ttot();
    }

        //function show all product
        function show_product(){
            document.getElementById("load").style.display = "block";
        var tempid = $('#temp_id').val();
            $.ajax({
                type  : 'ajax',
                url   : '<?php echo base_url(); ?>getinvprod/'+tempid+'',
                async : true,
                method:'POST',
                dataType : 'json',
                success : function(data){
                  console.log(data);
                    var html = '';
                    var i;
                    var tot = 0;
                    var tot_item = 0;
                    for(i=0; i<data.length; i++){
                        var tot = tot + parseFloat(data[i][4] * data[i][5]);
                        var tot_item = tot_item + parseFloat(data[i][5]);
                        html += '<tr>'+
                                //'<td>'+(i+1)+'</td>'+
                                '<td>'+(i+1)+'</td>'+
                                '<td>'+data[i][8]+"-"+data[i][0]+"-"+data[i][1]+'</td>'+
                                '<td>'+data[i][2]+'</td>'+
                                '<td style="text-align:right">'+data[i][3]+'</td>'+
                                '<td style="text-align:right">'+data[i][4]+'</td>'+
                                '<td style="text-align:right">'+data[i][5]+'</td>'+
                                '<td style="text-align:right">'+parseFloat(data[i][4] * data[i][5]).toFixed(2)+'</td>'+
                                '<td style="text-align:right">'+data[i][7]+'</td>'+
                                '<td style="text-align:right;">'+
                                '<div class="hidden-sm hidden-xs btn-group">'+
                                ' <button class="btn btn-outline-danger btn-sm" name="tax" id="'+data[i][6]+'" onclick ="del_data(this.id);">X</button>'+
                                    //'<a href="javascript:void(0);" class="btn btn-xs btn-success item_edit" data-product_code="'+data[i].inv_pro_id+'" data-product_price="'+data[i].product_name+'" data-product_prc="'+data[i].unit_price+'" data-qty="'+data[i].qty+'"><i class="ace-icon fa fa-pencil bigger-120"></i></a>'+' '+
                                   // '<a href="javascript:void(0);" class="btn btn-xs btn-danger item_delete" data-product_code="'+data[i].po_itm_id+'"><i class="ace-icon fa fa-trash-o bigger-120"></i></a>'+
                               '</div>'+
                                '</td>'+
                                '</tr>';
                    }
                    $('#show_data').html(html);
                    $('[name="inv_total"]').val(tot.toFixed(2));
                    $('[name="net"]').val(tot.toFixed(2));
                    $('[name="inv_tot_item"]').val(tot_item);
                    cal_total(); cal_dis_pc();
                    document.getElementById("load").style.display = "none";
               
                 
            }
 
            });
        }

        //$('#addrow').on('click',function(){
        function addrow(){
          
            var price = $('#price').val();
            var qty = $('#qty').val();
            var free = $('#free').val();
            var pricelkr = $('#pricelkr').val();
            
            var f = document.getElementById("supselect");
            var sup_id = f.options[f.selectedIndex].value;
            
            
            var dis_price = 1;
            //var unt = document.getElementById("unitid");
                var unit = 2;
                
            var itm = document.getElementById("itemselect");
                var item = itm.options[itm.selectedIndex].value;    
        
            var h = document.getElementById("saleselect");
                var sls = h.options[h.selectedIndex].value;
         
            var tempid = $('#temp_id').val();
                   var tot = price * qty; 
             
            if((price==0.00)||(price=="")||(qty=="")||(qty=="0")){
                alert("Please enter Price and Quantity");
               swal("Please enter Price and Quantity"); 
            }else{
                        $.ajax({
                        type : "POST",
                        url  : "<?php echo site_url('addinvoice_data')?>",
                        dataType : "JSON",
                        method:'POST',
                        data : {temp_id:tempid, price:price ,pricelkr:pricelkr, qty:qty, item:item, sup:sup_id,unit:unit,free:free,sls:sls},
                        success: function(data){
                            document.getElementById("supselect").disabled = true;
                            if(data!="Added"){
                                swal(data);
                                
                            }
                          
                            show_product();
                           $('[name="price"]').val("");
                            $('[name="qty"]').val("");
                            $('[name="free"]').val("");
                            $('[name="pricelkr"]').val("");
                            $('[name="total"]').val("");
                            $('[name="avstk"]').val("");
                           document.getElementById('dis_er').innerHTML = '';
                           document.getElementById('addrow').style.backgroundColor = '#6c757d'; 
                           document.getElementById('itemselect').focus();
                            $("#itemselect").trigger("chosen:updated");
                        }
                    });
                    return false;
                    
                    
            }    
           
           
           const myButton = document.getElementById("addrow");
               myButton.style.backgroundColor = "rgb(108, 117, 125)";
        };
      
 
    
    $('#partselect').change(function(){ 
       
                $('#itemselect option').remove();
                $('#specselect option').remove();
                $('#specselect').append($('<option>', {value: "",text: "select" }));
                
                $('[name="price"]').val("");
                    $('[name="pricelkr"]').val("");
                
          //var id = $(this).val();
          //var f = document.getElementById("partselect");
            var part_id = $(this).val();
             document.getElementById("load").style.display = "block";
          
             $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('product_data')?>',
                dataType : 'json',
                data : {part_id:part_id},
                success : function(data){
                            for (var i = 0; i < data['item'].length; i++) {
                               $('#itemselect').append($('<option>', {
                                                            value: data['item'][i].itmid,
                                                            text: data['item'][i].brname+"|"+data['item'][i].moname+"|"+data['item'][i].itmname
                                                        }));
                            }
                   
                        $('[name="price"]').val(data['item'][0].sel_price);
                  //$('[name="pricelkr"]').val(data['item'][0].sel_price);
                  //$("#unitid").val(data['item'][0].uid);
                  document.getElementById("load").style.display = "none";
					cur_cal();
                }
 
            }); 
      });  
      
    $('#itemselect').change(function(){ 
       document.getElementById("load").style.display = "block";
                $('#partselect option').remove();
                $('#partselect').append($('<option>', {value: "",text: "select" }));
                $('#specselect option').remove();
                $('#specselect').append($('<option>', {value: "",text: "select" }));
                document.getElementById('dis_er').innerHTML = '';
                
                //var f = document.getElementById("catselect");
                //var cat = f.options[f.selectedIndex].value;
                
                var g = document.getElementById("itemselect");
                var id = g.options[g.selectedIndex].value;
                
                var sl = document.getElementById("saleselect");
                var sale = sl.options[sl.selectedIndex].value;
                
          //var id = $(this).val();
          
          if(id!=0){
             
                  
                  var g = document.getElementById("itemselect");
                var id = g.options[g.selectedIndex].value;
                  $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('partnum_data')?>',
                dataType : 'json',
                data : {itm_id:id,sale:sale},
                success : function(data){
                    document.getElementById("load").style.display = "none";
                    if(data=="error"){swal("No stock Available"); return;}
                    
                   if(data['item'][2]=="0.00"){
                       swal("No price Given");return;
                   }else{
                        $('[name="price"]').val(data['item'][2]);
                   $('[name="pricelkr"]').val(data['item'][2]);
                   $('[name="free"]').val(0);
                   $('[name="qty"]').val(0);
                   $('[name="total"]').val(0);
                 
                   if((data['item'][0].item_freqty!="")||(data['item'][0].item_freqty!="0")){
                       $('[name="freeqty"]').val(data['item'][0].item_freqty/data['item'][0].item_freeitm);
                   }else{
                       $('[name="freeqty"]').val(0);
                   }
                   
                   //$("#unitid").val(data['item'][0].unit_id);
                   document.getElementById("price").focus(); 
				   document.getElementById("price").select();
				   $('[name="avstk"]').val(data['item'][1]);
                   }
                   
					
                }
 
            }); 
              
                  
              
          }
      }); 
     
    $('#specselect').change(function(){ 
       
                $('#itemselect option').remove(); 
                $('#itemselect').append($('<option>', { value: "", text: "select" }));
                
                
                $('#partselect option').remove(); $('#partselect').append($('<option>', { value: "", text: "select" }));
                
                $('[name="price"]').val("");
                    $('[name="pricelkr"]').val("");
                
          //var id = $(this).val();
          //var f = document.getElementById("partselect");
            var part_id = $(this).val();
            alert(part_id);
          
             $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('prospec_data')?>',
                dataType : 'json',
                data : {part_id:part_id},
                success : function(data){
                            for (var i = 0; i < data['item'].length; i++) {
                               $('#itemselect').append($('<option>', {
                                                            value: data['item'][i].item_id,
                                                            text: data['item'][i].brand_name+"|"+data['item'][i].model_name+"|"+data['item'][i].itm_name
                                                        }));
                            }
                   
                     //   $('[name="price"]').val(data['item'][0].item_selling_price);
                   // $('[name="pricelkr"]').val(data['item'][0].item_selling_price);
					//$("#unitid").val(data['item'][0].unit_id);
					cur_cal();
                }
                
            }); 
      }); 
    
      
                //Save data to invoice
        $('#btn_save').on('click',function(){
            var e = document.getElementById("supselect");
            var sup_id = e.options[e.selectedIndex].value;
            
                var f = document.getElementById("saleselect");
                var sales = f.options[f.selectedIndex].value;
            
            var temp_id = $('#temp_id').val();
            var qty = $('#inv_tot_item').val();
            var total = $('#inv_total').val();
            var dis = $('#dis_pc').val();
            var final = $('#final').val();
            
            
            var other = $('#other_amnt').val();
                var curn = document.getElementById("curid");
                var cur = curn.options[curn.selectedIndex].value;
           // var unt = document.getElementById("unitid");
                var unit = 2;
       
            var remark = $('#remark').val();
          
                if((sup_id=="")||(sales=="")||(sup_id=="0")){
                   swal({title: "Cannot Save!",  text: "Please Select Sales Rep and Customer",showConfirmButton:true, showCancelButton: true, confirmButtonText: 'Ok',
              focusConfirm:true});
              return;
                }else if((qty=='0')||(total=='0')||(final=='0')){
                    
                    swal({title: "Cannot Save!",  text: "Please Add Items",showConfirmButton:true, showCancelButton: true, confirmButtonText: 'Ok',
              focusConfirm:true});  return;
                
                    
                }else{
                    
                   // if(5<dis){
                   // swal({title: "Need Approval!",  text: "Please authorize for the discount",showConfirmButton:true, showCancelButton: true, confirmButtonText: 'Ok',
                   //  focusConfirm:true});  return;
                   //     }
                    
                    document.getElementById("load").style.display = "block";
                    $.ajax({
                            type : "POST",
                            url  : "<?php echo site_url('save_inv_data')?>",
                            dataType : "JSON",
                            method:'POST',
                            data : {sup_id:sup_id,sales:sales,temp_id:temp_id,qty:qty, total:total, dis:dis, final:final,other:other,cur:cur,unit:unit,remark:remark},
                            success: function(data){
                                if(data==0){ swal("Invoice Need Approval"); }else{ swal("Invoice Created"); }
                                
                               
                                location.href = "<?php echo site_url('allqtn')?>/";
                            }
                        });
                      
               
                }
               
            return false;
            
          });
          

          
          
          //get data for delete record
        function del_data(clickedID){
            var product_code = clickedID;
            // alert(product_code);
            $('#Modal_Delete').modal('show');
            $('[name="product_code_delete"]').val(product_code);
        };
        
          //delete record to database
        $('#btn_delete').on('click',function(){
            var f = document.getElementById("saleselect");
                var sales = f.options[f.selectedIndex].value;
            var product_code = $('#product_code_delete').val();
            $.ajax({
                type : "POST",
                url  : "<?php echo site_url('prodelete_data')?>",
                dataType : "JSON",
                data : {product_code:product_code,sales:sales},
                success: function(data){
                    $('[name="product_code_delete"]').val("");
                    $('#Modal_Delete').modal('hide');
                    show_product();
                }
            });
            return false;
        });
        
    
        // save new data
    $('#save_data').on('click',function(){
     
             var rt = document.getElementById('table').value;
           
            swal({
                  title: "Are you sure?",
                  text: "Save, Ente#1e2124 Details will be Saved",
                  icon: "warning",
                  buttons: true,
                  dangerMode: true,
                })
                .then((willDelete) => {
                  if (willDelete) {
                               $.ajax({
                                type  : 'ajax',
                                method : "POST",
                                url   : "<?php echo site_url('')?>"+rt,
                                async : true,
                                dataType : 'json',
                                data: $("#frm_add_data").serialize(),
                                success : function(data){
                                    if(data[2]=="error"){
                                        swal(data[0]);
                                    }else{
                                        swal(data[0]);
                                        $("#addmodel").modal('hide');
                                        $('#tb_bdy').html("");
                                        show_servicedata();
                                        if(data[1].includes("supplier")){
                                            get_cus();
                                        }else{
                                           get_cat(); 
                                        }
                                        
                                    }
                                    
                                }
                 
                            });
                  } else {
                    swal("No Changes");
                    document.getElementById("load").style.display = "none";
                  }
                });
            
           
            
        });
        
   
       //show add new
    function add_data(clickedID){
     var rt = clickedID;
           $.ajax({
                        type  : 'ajax',
                        method : "POST",
                        url   : "<?php echo site_url('')?>"+rt,
                        async : true,
                        dataType : 'json',
                        success : function(data){
                              $('#addmodel').modal('show')
                            $('#Modal_Add').html(data);
                        }
         
                    });
           
     
    }


    function get_sup(){
        $('#supselect option').remove();
        $("#supselect").trigger("chosen:updated");
        $.ajax({
                        type  : 'ajax',
                        method : "POST",
                        url   : "<?php echo site_url('customer_list')?>",
                        async : true,
                        dataType : 'json',
                        success : function(data){
                            
                              $('#saleselect').append($('<option>', {
                                                            value: "",
                                                            text: "select"
                                                        }));
                                               
               
                    
                             var i;
                    for(i=0; i<data[1].length; i++){
                            $('#saleselect').append($('<option>', {
                                                            value: data[1][i].user_id,
                                                            text: data[1][i].user_fname+" "+data[1][i].user_lname
                                                        }));
                        
                                                
                    }  
                                                
                    
                       $("#supselect").trigger("chosen:updated");
                       $("#saleselect").trigger("chosen:updated");
                        }
         
                    });
                    
                    
    }
   
</script>

<script>
    jQuery(document).ready(function() {
        jQuery(".standardSelect").chosen({
            disable_search_threshold: 5,
            no_results_text: "Oops, nothing found!",
            width: "100%"
        });
    });
</script>