  <link rel="stylesheet" href="<?php echo base_url(); ?>assets/css/jquery-datepicker.css">
        <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 Direct Job Card</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>  
    <link rel="stylesheet" href="//code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css">                                                            
    <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">
  <form id="save_jobnew">
                <div class="content">
            <div class="animated fadeIn">

                <div class="form-group">
        
                    <input type="hidden" id="temp_id"  name="temp_id" placeholder="" value=" "class="col-xs-12 col-sm-12" />
                                                                
                                   <div class="row">
                                       <div class="col-sm-1">  
                                                        Title
                                                            <select class="form-control-sm form-control" id="title" data-placeholder="Choose a currency" name="title"  >
							                            
							                                <option value="0" >Company</option>
							                                <option value="Mr." >Mr. </option>
							                                <option value="Mrs." >Mrs. </option>
							                                <option value="Miss." >Miss. </option>
							                                <option value="Thero." >Thero. </option>
                                                                                                                  
                                                        </select>                          
                                                    </div>
                                                    <div class="col-sm-4">  
                                                        Customer / Company
                                                           <input type="text" id="job_cus"  name="job_cus" placeholder="" value=""class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" /> 
                                                        <input type="hidden" name="sup_type" value="" id="sup_type">                          
                                                    </div>
                                                    
                                                     <!--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-4">
                                                           Address
                                                           <input type="text" id="job_addrs"  name="job_addrs" placeholder="" value=""class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" /> 
                                                    </div>
                                                    
                                                    
                                                    <div class="col-sm-2" >Contact Number<br>
                                                         
                                                            <input type="text" id="job_cont"  name="job_cont" placeholder="" value=""class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" /> 
                                                    </div>
                                                    
                                                    <div class="col-sm-1" >Product<br>
                                                         
                                                            <button onclick="shopro()" type="button" class="btn btn-secondary btn-sm">Add</button>
                                                    </div>
                                                    
                                               </div>
                                             
                                              <div style="display:none" id="view_product">
                                                  
                                                  <div class="row">
                                               
                                                    <div class="col-sm-3">  
                                                        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">   
                                                        Product/Service
                                                        <select class="form-control standardSelect" id="itemselect" data-placeholder="Type to Choose..." name="itemselect">
							                                <option value="">  </option>                                                          
                                                        </select>                          
                                                    </div>
                                                    
                                                    </div>
                                                  
                                               </div>
                                               <div class="row">
                                                   
                                                   <div class="col-sm-5">  
                                                        Description
                                                       <input type="text" id="desc"  name="desc" placeholder="" value=""class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" /> 
                                                       <input type="hidden" id="descid"  name="descid" placeholder="" value=""class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" />  
                                                    </div>
                                                   
                                                    <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" onkeyup="cur_cal()" />
                                                        
                                                    </div>
                                                    
                                                    <!--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 class="col-sm-1">
                                                            Quantity
                                                        <input type="text" id="qty"  name="qty" placeholder="" value="<?php  ?> "class="col-xs-12 col-sm-12 form-control input-sm form-control-sm" onkeyup="sin_item_tot()"/>
                                                                <?php echo form_error('productqty'); ?>
                                                    </div>
                                                    
                                                    <div class="col-sm-1">
                                                            Unit
                                                            <select class="form-control-sm form-control" id="unitid" data-placeholder="Choose a currency" name="unitid"  >
							                                
                                                         <?php 
                                                         foreach ($unit as $cat) {            
                                                          ?>
							                                <option value="<?php echo $cat->unit_id; ?>" ><?php echo $cat->unit_symble; ?></option>
                                                          <?php }?>                                                         
                                                        </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" />
                                                                <?php echo form_error('productqty'); ?>
                                                    </div>
                                                    
                                                   <div class="col-sm-1"><br>
                                                        
                                                       <button type="button" class="btn btn-secondary btn-sm" name="add" id="add" 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>    
                                               
                                         <div class="space"></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 Description</th>
                                    													<th style="text-align:right">Unit</th>
                                    													<th style="text-align:right">Quantity </th>
                                    													<th style="text-align:right"><span id="cr_chng">Rate</span> </th>
                                                                                        <th style="text-align:right"><span id="cr2_chng">Total</span>  </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-12">   
                                    						<form id="calc">
                                                     
                                                        Technician 
                                                            <select class="form-control standardSelect choosen-select" id="tccat" data-placeholder="" name="tccat">
    							                                <option value="0"> Select </option>
                                                             <?php 
                                                             foreach ($tccatdetailst as $dbagent) {            
                                                              ?>
    							                            <option value="<?php echo $dbagent->tech_id; ?>"><?php echo $dbagent->tect_fname.' '.$dbagent->tech_lname; ?></option>
                                                              <?php }?>                                                           
                                                            </select>                        
                                                    
                                                                </div>
                                                    
                                                    		
                                                            
                                                            <div class="col-lg-12"> 
                                                            
                                                              <table  id="data">
                                                          <thead>
                                                        
                                                          <tr id="finalrow">
                                                            <td></td>
                                                            <td></td>
                                                           
                                                            <td id="total"></td>
                                                          </tr>
                                                          </thead>
                                                          
                                                          <tbody></tbody>
                                                        
                                                        </table></div>
                                                            
                                                          
                                                             </form >   
                                                               <div class="space" style="padding-bottom: 10px;"></div>
                                                                     <div class="col-lg-6 d-inline" >
                                                                              Start Date
                                                                            <input type="text" id="sdate"  name="sdate" placeholder="" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm datepicker" style="text-align: right;"/>
                                                                        
                                                                        </div>
                                                                       <div class="col-lg-6 float-end">
                                                                              End Date
                                                                            <input type="text" id="edste"  name="edste" placeholder="" value="0" class="col-xs-12 col-sm-12 form-control input-sm form-control-sm datepicker" style="text-align: right;"/>
                                                                            
                                                                        </div>
                                                           <div class="space" style="padding-bottom: 10px;"></div>
                                                            <div class="col-lg-12">
                                                                 Remarks
                                                                 <textarea id="remark" name="remark" rows="2" cols="60" style="width: 100%;"></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(Amount)
                                                                            <input type="text" id="dis_total"  name="dis_total" placeholder="%" 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;"/>
                                                                        </div>
                                                                        <div class="col-lg-6 float-end">
                                                                              Discount(%)
                                                                              <input type="text" id="dis_pc"  name="dis_pc" 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_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">
                                                                              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="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>
                                                                
                                                                
                                                                         
                                                              
                                                          <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>
                                                   Save
                                            </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-danger btn-sm" id="btn_cancel">
                                                    <i class="ace-icon fa fa-times red2"></i>
                                                    Cancel
                                            </button>
                                        </div>
                                        
                                    </div>
                                     </div>
                                    </div>
                                    
                    
                </div>
                                    
            
      
            </div>
            
            </div>
    </form>        
           
            
            <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/jquery-ui.js"></script>
  <script src="<?php echo base_url(); ?>assets/js/lib/chosen/chosen.jquery.min.js"></script>

<script>

 $( function() {
    $( ".datepicker" ).datepicker();
    $( ".datepicker" ).datepicker( "option", "dateFormat", "yy-mm-dd");
  } );

$(document).ready(function() {
    document.getElementById("load").style.display = "none";
   // cal_ttot();
   // show_product();
   // get_sup();
  $('#tccat').change(function() {
    //debugger;
    $("#supselect").trigger("chosen:updated");
    let tr = $("<tr/>").appendTo("#data tbody");

    $('#tccat').each(function(index) {
      var input = $(this);
      $(tr).insertBefore("#finalrow").append('<td class=row-' + $(input).attr("id") + '><input type="hidden" id="term[]" name="term[]" value="' + $(input).find('option:selected').val() + '">' + $(input).find('option:selected').text() + '  </td>');
    });
    

    $(tr).append('<td class="row-time"></td>');
   // $("#calc")[0].reset();

    var removeBtn = $('<button class="removeBtn btn btn-outline-danger btn-sm" id="removeBtn">X</button>');
    $('.row-time:last').append(removeBtn);

  });
});

$(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;

    }


  });
});



    function cur_cal(){
       // var total = $('#pricelkr').val() / $('#cur_rt').val();
        var total = $('#price').val() * $('#cur_rt').val();
        $('[name="pricelkr"]').val(total.toFixed(2));
        sin_item_tot();
        cal_ttot();
    }
    
        function sin_item_tot(){
        var total = $('#price').val() * $('#qty').val();
        $('[name="total"]').val(total.toFixed(2));
        cal_ttot();
    }

    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_tax_pc(){
        var pc = $('#tax_pc').val();
        var dis = ($('#net').val() * pc)/100;
        //alert(dis);
      $('#tax_total').val(dis.toFixed(2));
      cal_ttot();
      cal_total();
    }
    
    function cal_tax_amt(){
        var tax_total = $('#tax_total').val();
      var pc = (tax_total/$('#net').val())*100;
      $('#tax_pc').val(pc);
      cal_total();
      cal_ttot();
    }

    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 total = parseInt($('#inv_total').val()) - parseInt(dis) + parseInt(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();
            
        }


     function  show_term(){
           
           var tempid = $('#temp_id').val();
                       $.ajax({
                type  : 'ajax',
                url   : '<?php echo base_url(); ?>termshow_data/'+tempid+'',
                async : true,
                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 + parseInt((data[i].po_itm_unitprice * data[i].po_itm_qty));
                       // var tot_item = tot_item + parseInt(data[i].po_itm_qty);
                        
                        $('#lblName').text(data[i].ctname+ ':' +data[i].tdes);
                       
                       
                    }
                   // $('#show_data').html(html);
                   // $('[name="inv_total"]').val(tot);
                   // $('[name="inv_tot_item"]').val(tot_item);
                   // cal_total();
                }
 
            });
       } 

        //$('#addrow').on('click',function(){
            function addrow(){
           
          
           var desc = $('#desc').val();
           var price = $('#price').val();
            var total = $('#total').val();
            var qty = $('#qty').val();
             var descid = $('#descid').val();
            
            var e = document.getElementById("unitid");
            var unitid_id = e.options[e.selectedIndex].value;
            var unitid = e.options[e.selectedIndex].text;
           
           
           var item = '<tr><td></td><td><input type="hidden" id="serid"  name="serid[]"  value='+descid+'><input type="text" class ="col-xs-12 col-sm-12 input-sm form-control-sm form-control" id="serdesc"  name="serdesc[]"  value='+desc+'></td>'+
           '<td><input type="hidden" id="serid"  name="serid_id[]"  value='+unitid_id+'><input style="text-align: right;" type="text" class ="col-xs-12 col-sm-12 input-sm form-control-sm form-control" id="serunit"  name="serunit[]"  value='+unitid+'></td>'+
           '<td><input style="text-align: right;" type="text" class ="col-xs-12 col-sm-12 input-sm form-control-sm form-control" id="serqty"  name="serqty[]"  value='+qty+'></td>'+
           '<td><input style="text-align: right;" type="text" class ="col-xs-12 col-sm-12 input-sm form-control-sm form-control" id="serprice"  name="serprice[]"  value='+price+'></td>'+
           '<td><input style="text-align: right;" type="text" class ="col-xs-12 col-sm-12 input-sm form-control-sm form-control" id="itmtot"  name="itmtot[]" value='+total+'></td>'+
           '<td><button class="removeBtn btn btn-outline-danger btn-sm" id="removeBtn" onclick="deleteRow(this)">X</button></td></tr>';
           
            $("#show_data").after(item);
            $('#desc').val("");
            $('#price').val("");
            $('#total').val("");
            $('#qty').val("");
            $('#descid').val("");
            cal_total();
            get_cal();
           
        };
        
        
        
              function deleteRow(btn) {
            var i = btn.parentNode.parentNode.rowIndex;
    document.getElementById("simple-table").deleteRow(i);
  get_cal();
        }
        

        function get_cal(){
        var table = document.getElementById("simple-table"), sumqty =sumamnt= muby = mul=0;
            
            for(var i = 1; i < table.rows.length; i++)
            {
                mul = parseFloat(table.rows[i].cells[3].innerHTML);
                    $(this).closest('tr').find("input").each(function() {
                        alert(this.value)
                    });
                muby = muby + parseFloat(table.rows[i].cells[5].children[0].value); 
                sumqty = sumqty + parseFloat(table.rows[i].cells[3].children[0].value);
                sumamnt = sumamnt + (mul*muby);
            }
        
            $('#inv_tot_item').val(sumqty.toFixed(2));
            $('#inv_total').val(muby.toFixed(2));
            
            cal_total();
    }    
        
        
        $('#tccat').change(function(){ 
            document.getElementById("load").style.display = "block";
            $('#tcdes option').remove();
             var f = document.getElementById("tccat");
            var cat_id = f.options[f.selectedIndex].value;
           
              $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('gettc_data')?>',
                dataType : 'json',
                data : {cat_id:cat_id},
                success : function(data){
                    $('#tcdes').append($('<option>', {
                                                            value: "0",
                                                            text: "select"
                                                        }));
                                                        
                                                         var i;
                            for (var i = 0; i < data['tc'].length; i++) {
                               $('#tcdes').append($('<option>', {
                                                            value: data['tc'][i].tid,
                                                            text: data['tc'][i].tdes
                                                        }));
                            }
                    $("#tcdes").trigger("chosen:updated");
          document.getElementById("load").style.display = "none";
					
                }
 
            });
        });
        
        function addtcrow(){
            
            var f = document.getElementById("tccat");
            var tc_cat = f.options[f.selectedIndex].value;
            var d = document.getElementById("tcdes");
            var tc_des = d.options[d.selectedIndex].value;
            var tempid = $('#temp_id').val();
            
              $.ajax({
                type : "POST",
                url  : "<?php echo site_url('Po_Controller/addtc')?>",
                dataType : "JSON",
                data : {temp_id:tempid, tc_cat:tc_cat , tc_des:tc_des},
                success: function(data){
                    
                       alert(data);
                    
                    //$("#agentselect").prop("disabled", false);
                   // $('#agentselect').prop('disabled', 'disabled');
                    //show_product();
                    show_term();
                    
                }
            });
            return false;
            
        }
        

    
    $('#catselect').change(function(){ 
        document.getElementById("load").style.display = "block";
    
                $('#partselect option').remove();
                $('#itemselect option').remove();
                $('#specselect option').remove();
                
                $('[name="price"]').val("");
                $('[name="pricelkr"]').val("");
					
          var id = $(this).val();
          if(id=="0000"){
              var g = document.getElementById("catselect");
                var id = g.options[g.selectedIndex].value;
                document.getElementById("load").style.display = "block";
              
              $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('getservice_data')?>',
                dataType : 'json',
                data : {cat_id:id},
                success : function(data){
                    $('#partselect').append($('<option>', {
                                                            value: "",
                                                            text: "select"
                                                        }));
                    
                    
                    
                     $('#itemselect').append($('<option>', {
                                                            value: "",
                                                            text: "select"
                                                        }));
                     
                 var i;
                            for (var i = 1; i < data['service'].length; i++) {
                               $('#itemselect').append($('<option>', {
                                                            value: data['service'][i].service_id,
                                                            text: data['service'][i].service_detail
                                                        }));
                            }
					document.getElementById("load").style.display = "none";
					$("#partselect").trigger("chosen:updated");
					$("#itemselect").trigger("chosen:updated");
				
                }
 
            }); 
          }else{
              document.getElementById("load").style.display = "block";
              var g = document.getElementById("catselect");
                var id = g.options[g.selectedIndex].value;
             $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('getpart_num_data')?>',
                dataType : 'json',
                data : {cat_id:id},
                success : function(data){
                    $('#partselect').append($('<option>', {
                                                            value: "",
                                                            text: "select"
                                                        }));
                    
                    var i;
                    for(i=0; i<data['part'].length; i++){
                            $('#partselect').append($('<option>', {
                                                            value: data['part'][i].partno_id,
                                                            text: data['part'][i].partnum
                                                        }));
                        
                                                
                    }
                    
                     $('#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].brand_name+"|"+data['item'][i].model_name+"|"+data['item'][i].itm_name+"|"+data['item'][i].spec_spec
                                                        }));
                            }
                            
                        $('#specselect').append($('<option>', {
                                                            value: "",
                                                            text: "select"
                                                        }));   
                     
                 var i;
                            for (var i = 0; i < data['spec'].length; i++) {
                               $('#specselect').append($('<option>', {
                                                            value: data['spec'][i].spec_id,
                                                            text: data['spec'][i].spec_spec
                                                        }));
                            }
                            
                            
                    document.getElementById("load").style.display = "none";  
                    choos();
					
                }
 
            }); 
          }
      });
      
    $('#supselect').change(function(){ 
          document.getElementById("load").style.display = "block";
                    $('[name="price"]').val("");
                    $('[name="pricelkr"]').val("");
					$('[name="qty"]').val("");
					$('[name="total"]').val("");
					document.getElementById("curid").selectedIndex = "0";
					 
          var id = $(this).val();
          
             $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('customer_data')?>',
                dataType : 'json',
                data : {sup_id:id},
                success : function(data){
                    $('[name="cur"]').val(data['sup'][0].cu_symbol);
                    $("#curid").val(data['sup'][0].cu_id);
                    $('[name="sup_type"]').val(data['sup'][0].custo_type);
                    document.getElementById("cr_chng").innerHTML = "Rate("+data['sup'][0].cu_symbol+")"; 
                    document.getElementById("cr2_chng").innerHTML = "Total("+data['sup'][0].cu_symbol+")"; 
                    
                    if(data['sup'][0].custo_type=="Foreign"){
                      var txt1 = document.getElementById("for_foreign1");                      
                      txt1.style.display = "none";
                      var txt2 = document.getElementById("trafee");                      
                      txt2.style.display = "none";
                      
                      document.getElementById("for_foreign2").style.display = "block";
                      $('#supselect_chosen').css('border', '3px solid rgb(247, 166, 126)');
                      
                      
                    }else{
                      var txt1 = document.getElementById("for_foreign1");                      
                      txt1.style.display = "none";
                      document.getElementById("for_foreign2").style.display = "none";
                      document.getElementById("trafee").style.display = "block";
                      $('#supselect_chosen').css('border', '0px solid #ced4da');
                    }
                    
                    if(data['sup'][0].custo_tax == 1){
                        if(data['sup'][0].custo_type=="Foreign"){
                            var txt = document.getElementById("tx");
                            txt.style.display = "block";
                        }else{
                      var txt = document.getElementById("for_tax");
                      txt.style.display = "block";
                        }
                    }else{
                      var txt = document.getElementById("for_tax");
                      txt.style.display = "none";
                    }
                    document.getElementById("load").style.display = "none";
                    choos();
                }
 
            }); 
      });
    
    $('#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);
                  $('[name="descid"]').val(data['item'][0].itmid);
                  
                  $('[name="desc"]').val(data['item'][0].brname+"|"+data['item'][0].moname+"|"+data['item'][0].itmname);
                  document.getElementById("load").style.display = "none";
					cur_cal();choos();
                }
 
            }); 
      });  
      
    $('#itemselect').change(function(){ 
       
                $('#partselect option').remove();
                $('#partselect').append($('<option>', {value: "",text: "select" }));
                $('#specselect option').remove();
                $('#specselect').append($('<option>', {value: "",text: "select" }));
                
                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 id = $(this).val();
          
          if(id!=0){
              if(cat!="0000"){
                  
                  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},
                success : function(data){
                  $('#partselect').append($('<option>', {
                                                            value: "",
                                                            text: "select"
                                                        }));
                                                        
                                                        
                  var i;
                    for(i=0; i<data['prt'].length; i++){
                        var dd = data['prt'][i].split("/");
                            $('#partselect').append($('<option>', {
                                                            value: dd[0],
                                                            text: dd[1]
                                                        }));
                        
                                                
                    }
                   
                    $('[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);
                        var g = document.getElementById("itemselect");
                        var id = g.options[g.selectedIndex].text;
                        $("#desc").val(id);
                        $('[name="descid"]').val(g.options[g.selectedIndex].value);
					cur_cal();choos();
					
                }
 
            }); 
            
            
             
                  
              }else{
                  var g = document.getElementById("itemselect");
                var id = g.options[g.selectedIndex].value;
                
                $('#partselect option').remove();
                $('#partselect').append($('<option>', { value: "", text: "select" }));
                $('#specselect option').remove(); $('#specselect').append($('<option>', { value: "", text: "select" }));
                
                $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('getserv_id_data')?>',
                dataType : 'json',
                data : {id:id},
                success : function(data){
                  $('#partselect').append($('<option>', {
                                                            value: "",
                                                            text: "select"
                                                        }));
                                                        var dt = data['service'][0].unit_id+1;
                                                        $("#unitid").val(data['service'][0].unit_id);
                                                         
				
				choos();
			
                }
 
            }); 
                
                   
                    $('[name="price"]').val("1");
                    $('[name="pricelkr"]').val("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();choos();
                }
                
            }); 
      }); 
    
      
                //Save data to invoice
         $('#btn_save').on('click',function(){
          
        
                
                
                                $.ajax({
                            type : "POST",
                            url  : "<?php echo site_url('save_job')?>",
                            dataType : "JSON",
                             data: $("#save_jobnew").serialize(),
                            success: function(data){
                                
                                //show_product()
                                swal(data);
                                
                               
                                location.href = "<?php echo site_url('alljob')?>";
                            }
                        });
               
                
                
            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 product_code = $('#product_code_delete').val();
            $.ajax({
                type : "POST",
                url  : "<?php echo site_url('prodelete_data')?>",
                dataType : "JSON",
                data : {product_code:product_code},
                success: function(data){
                    $('[name="product_code_delete"]').val("");
                    $('#Modal_Delete').modal('hide');
                    show_product();
                }
            });
            return false;
        });
        
               //show add new
    function show_servicedata(){
      $.ajax({
                type  : 'ajax',
                method:'POST',
                url   : '<?php echo site_url('getservice_data')?>',
                dataType : 'json',
                success : function(data){
                     
                 var i;
                            for (var i = 0; i < data['service'].length; i++) {
                               $('#itemselect').append($('<option>', {
                                                            value: data['service'][i].serv_id,
                                                            text: data['service'][i].serv_name
                                                        }));
                            }
					
                }
 
            }); 
         
           
     
    }
    
        // save new data
    $('#save_data').on('click',function(){
     
             var rt = document.getElementById('table').value;
           
            swal({
                  title: "Are you sure?",
                  text: "Save, Entered 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_part(){
        
                if (event.keyCode == 13) {
                 console.log("Enter key is pressed");
                        var part = document.getElementById('add_num').value;
                        var all = $('#part_num').val();
                        if(part!=""){
                            if(all!=""){all = all + "\n" +part;}else{all = part;}
                        }
                        
                        
                        $('#part_num').val(all);
                        $('#add_num').val("");
                 return true;
              } else {
                 return false;
              }
        
    }
    
    function shopro() {
  var x = document.getElementById("view_product");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
} 
    
    function choos(){
                    $("#partselect").trigger("chosen:updated");
					$("#itemselect").trigger("chosen:updated");
					$("#specselect").trigger("chosen:updated");
    }
    
    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){
                            
                              $('#supselect').append($('<option>', {
                                                            value: "",
                                                            text: "select"
                                                        }));
                                                        
                           var i;
                    for(i=0; i<data.length; i++){
                            $('#supselect').append($('<option>', {
                                                            value: data[i][0],
                                                            text: data[i][1]
                                                        }));
                        
                                                
                    }                              
               
                        
                                                
                    
                       $("#supselect").trigger("chosen:updated");
                        }
         
                    });
                    
                    
    }
    
    function get_cat(){ 
        $('#catselect option').remove();
        $("#catselect").trigger("chosen:updated");
        $.ajax({
                        type  : 'ajax',
                        method : "POST",
                        url   : "<?php echo site_url('catagory_list')?>",
                        async : true,
                        dataType : 'json',
                        success : function(data){
                              $('#catselect').append($('<option>', {
                                                            value: "",
                                                            text: "select"
                                                        }));
                                                        
                                                        
                  var i;
                    for(i=0; i<data['cat'].length; i++){
                            $('#catselect').append($('<option>', {
                                                            value: data['cat'][i].cat_id,
                                                            text: data['cat'][i].cat_name
                                                        }));
                        
                                                
                    }
                       $("#catselect").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>