<script src="<?php echo base_url();?>assets/ckeditor/ckeditor.js"></script>
<script src="<?php echo base_url();?>assets/ckfinder/ckfinder.js"></script>

 <?php 
 if($_POST)
 {
  $bill_cnsgnr_id                 =   set_value('bill_cnsgnr_id',$_POST['bill_cnsgnr_id']);
  $bill_cnsgne_id                 =   set_value('bill_cnsgne_id',$_POST['bill_cnsgne_id']);
  $bill_notify_id                 =   set_value('bill_notify_id',$_POST['bill_notify_id']);
  $bill_brnch_id                  =   set_value('bill_brnch_id',$_POST['bill_brnch_id']);
  $bill_port_id                   =   set_value('bill_port_id',$_POST['bill_port_id']);
  $bill_company_id                =   set_value('bill_company_id',$_POST['bill_company_id']);
  $pre_carriage                   =   set_value('pre_carriage',$_POST['pre_carriage']);
  $place_receipt                  =   set_value('place_receipt',$_POST['place_receipt']);
  $ocean_vessel                   =   set_value('ocean_vessel',$_POST['ocean_vessel']);
  $voyage                         =   set_value('voyage',$_POST['voyage']);
  $port_of_loading                =   set_value('port_of_loading',$_POST['port_of_loading']);
  $place_of_delivery              =   set_value('place_of_delivery',$_POST['place_of_delivery']);
  $no_of_bl                       =   set_value('no_of_bl',$_POST['no_of_bl']);
  $freight_payment                =   set_value('freight_payment',$_POST['freight_payment']);
  $freight_charges                =   set_value('freight_charges',$_POST['freight_charges']);
  $delivery_of_goods              =   set_value('delivery_of_goods',$_POST['delivery_of_goods']);
  $place_issue                    =   set_value('place_issue',$_POST['place_issue']);
  $date_of_issue                  =   set_value('date_of_issue',$_POST['date_of_issue']);  
  $container_no                   =   set_value('container_no',$_POST['container_no']);
  $goods                          =   set_value('goods',$_POST['goods']);
  $gross_weight                   =   set_value('gross_weight',$_POST['gross_weight']);
  $cube_measure                   =   set_value('cube_measure',$_POST['cube_measure']);
  
}
else
{
  $bill_cnsgnr_id                 =   '';
  $bill_cnsgne_id                 =   '';
  $bill_notify_id                 =   '';
  $bill_brnch_id                  =   '';
  $bill_port_id                   =   '';
  $bill_company_id                =   '';
  $pre_carriage                   =   '';
  $place_receipt                  =   '';
  $ocean_vessel                   =   '';
  $voyage                         =   '';
  $port_of_loading                =   '';
  $place_of_delivery              =   '';
  $no_of_bl                       =   '';
  $freight_payment                =   '';
  $freight_charges                =   '';
  $delivery_of_goods              =   '';
  $place_issue                    =   '';
  $date_of_issue                  =   '';   
  $container_no                   =   '';
  $goods                          =   '';
  $gross_weight                   =   '';
  $cube_measure                   =   '';
  
}


 ?>
  <style type="text/css">
 .inputcurve {
    height : 30px;
    padding: 5px;
    background: rgba(255, 255, 255, 0.2);
 }
 </style>
 <div class="box-body">
  <div style="color:red;" class="error"><strong><?php if($this->session->flashdata('error')){ echo $this->session->flashdata('error');} ?></strong></div>
    <form role="form" id="add_invoice" name="add_invoice" action="<?php echo base_url();?>Invoice/add_invoice" method="post" enctype="multipart/form-data">
   <div class="row">
   <div class="col-md-12">  
    <div class="col-md-3">
    
      <div class="form-group" style="margin-top: 33px;">
                <label>TYPE</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('container_no');?>
                  <input type="radio" name="type" value="0" id="exp_id"> Export
                  <input type="radio" name="type" value="1"> Import             
            </div>

    </div>
    </div>
    <hr>
    </div>
     <div class="row">
    <div class="col-md-12"> 
    
    <div class="col-md-3">
     <div class="form-group">
                 <label>Company</label>
                 <select class="form-control select2" id="bill_company_id" name="bill_company_id" tabindex="4">
            <!--     <option value="">Select Company</option> -->
                    <?php foreach($company_drpdwn as $row)
                    {?>
                        <option value="<?php echo $row['cmp_id'];?>" <?php if($row['cmp_id']==$bill_company_id)echo "selected";?>><?php echo $row['cmp_name'];?></option>
                <?php }?>
                <input type="hidden" value="<?php echo $row['cmp_id'];?>" id="bill_company_id" name="bill_company_id">                
                
            </div>
    </div>
    <div class="col-md-3">
    
     <div class="form-group">
                 <label>Branch</label><span style="color:red;font-weight: 900;">*</span><?php echo form_error('bill_brnch_id');?>
                 <select class="form-control select2" id="bill_brnch_id" name="bill_brnch_id" tabindex="1">
              <!--   <option value="">Select Branch</option> -->
                    <?php foreach($branch_drpdwn as $row)
                    {?>
                        <option value="<?php echo $row['branch_id'];?>" <?php if($row['branch_id']==$bill_brnch_id)echo "selected";?>><?php echo $row['branch_name'];?></option>
                    <?php }?>
                             
                <input type="hidden" name="branch_bill_no" id="branch_bill_no" class="branch_bill_no">
             
            </div>

    </div>
    
    <div class="col-md-3">
        <div class="form-group">
                <label>Customer</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('bill_cust_id');?>
                <select class="form-control select2" id="bill_cust_id" name="bill_cust_id" tabindex="5">
                  <option value="">Select Customer</option>
                    <?php foreach($customer_drpdwn as $row)
                    {?>
                      <option value="<?php echo $row['customer_id'];?>" <?php if($row['customer_id']==$bill_cnsgne_id)echo "selected";?>><?php echo $row['customer_name'];?></option>
                    <?php }?>
                </select>
            </div>
     </div>
     <div class="col-md-3">
      <div class="form-group" >
                <label>Invoice Date</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('invoice_date');?>
                <input type="text" name="invoice_date" id="invoice_date" class="form-control datepicker" autocomplete="off" value="<?php echo date('d-m-Y'); ?>">
            </div>
     </div>
     
     
    </div>
      </div>
    <div class="row"  id="import_main_div">
    
    
    <div class="col-md-12"> 
    
    <div class="col-md-3">
      <div class="form-group">
                <label>Shipper/Exporter</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('bill_cnsgnr_id');?>
                <select class="form-control select2" id="bill_cnsgnr_id" name="bill_cnsgnr_id" tabindex="2">
                  <option value="">Select Shipper/Exporter</option>
                    <?php foreach($consignor_drpdwn as $row)
                    {?>
                      <option value="<?php echo $row['consignor_id'];?>" <?php if($row['consignor_id']==$bill_cnsgnr_id)echo "selected";?>><?php echo $row['consignor_name'];?></option>
                    <?php }?>
                </select>
            </div>
    
    </div>
    <div class="col-md-3">
    
      <div class="form-group">
                <label>B/L No</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('bill_no');?>
                <input type="text" name="bill_no" id="bill_no" class="form-control" tabindex="18">
            </div>

    </div>
    
    <div class="col-md-3">
        <div class="form-group" >
                <label>Gross Weight</label>
         <input type="text" name="gross_weight" id="gross_weight" class="form-control gross_weight" >
               
            </div>
     </div>
     <div class="col-md-3">
       <div class="form-group" >
                <label>Free Days</label>
         <input type="text" name="free_days" id="free_days" class="form-control free_days" >
               
            </div>
     </div>
    </div>
    
    <div class="col-md-12"> 
    <div class="col-md-3">
    <div class="form-group">
                <label>Port of Loading</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('port_of_loading');?>
                <textarea class="form-control port_of_loading" name="port_of_loading" id="port_of_loading" tabindex="11" tabindex="1"></textarea>
            </div>
       </div>
    <div class="col-md-3">
    
     <div class="form-group">
                <label>Port of Discharge</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('place_of_delivery');?>
                <textarea class="form-control place_of_delivery" name="place_of_delivery" id="place_of_delivery" tabindex="12"></textarea>
            </div>

    </div>
    
    <div class="col-md-3">
         <div class="form-group">
                <label>Final Place of Delivery/CFS</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('freight_payment');?>
                <textarea class="form-control fpod" name="fpod" id="fpod" tabindex="14"></textarea>
            </div>
     </div>
     <div class="col-md-3">
        <div class="form-group">
                <label>Container No.</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('container_no');?>
                <textarea class="form-control container_no" name="container_no" id="container_no" tabindex="19"></textarea>
            </div>
     </div>
    </div>
  
  
  
    <div class="col-md-12"> 
    
    <div class="col-md-3">
    
      <div class="form-group">
          <label>Vessel</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('ocean_vessel');?>
          <textarea class="form-control ocean_vessel" name="ocean_vessel" id="ocean_vessel" tabindex="9"></textarea>
      </div>

    </div>
    
    <div class="col-md-3">
         <div class="form-group">
                <label>Voyage</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('voyage');?>
                <textarea class="form-control voyage" name="voyage" id="voyage" tabindex="10"></textarea>
            </div>
     </div>
     <div class="col-md-3" style="display:none;">
       <div class="form-group">
                <label>Berth</label>
                <input type="text" name="vessel_berth" id="vessel_berth" class="form-control">
            </div>
     </div>
      <div class="col-md-3" >
      <div class="form-group" >
                <label>Berth/Arrival Date</label>
                <input type="text" name="arrival_date" id="arrival_date" class="form-control datepicker" autocomplete="off" tabindex="18">
            </div>
     
     
    </div>
    
    <div class="col-md-3">
    
      <div class="form-group">
                <label>Volume</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('volume');?>
                <textarea class="form-control volume" name="volume" id="volume" tabindex="9"></textarea>
            </div>

    </div>
    </div>
    
    <div class="col-md-12"> 
    
    
    <div class="col-md-3">
         <div class="form-group">
                <label>Job Ref</label>
                <textarea class="form-control voyage" name="job_ref" id="job_ref" tabindex="10"></textarea>
            </div>
     </div>
    
    </div>
    
    
    
    
    
    
    
    
    
  </div>  
    
    
    
   <div class="row"  id="export_div">
  
    
    
    <div class="col-md-12"> 
    
    <div class="col-md-3">
      <div class="form-group">
                <label>Shipper/Exporter</label>
                <select class="form-control select2" id="exp_shipper_id" name="exp_shipper_id" tabindex="2">
                  <option value="">Select Shipper/Exporter</option>
                    <?php foreach($consignor_drpdwn as $row)
                    {?>
                      <option value="<?php echo $row['consignor_id'];?>" <?php if($row['consignor_id']==$exp_shipper_id)echo "selected";?>><?php echo $row['consignor_name'];?></option>
                    <?php }?>
                </select>
            </div>
    
    </div>
    <div class="col-md-3">
    
      <div class="form-group">
                <label>B/L No</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span>
                <input type="text" name="exp_bill_no" id="exp_bill_no" class="form-control" tabindex="18">
            </div>

    </div>
    
    <div class="col-md-3">
        <div class="form-group" >
                <label>Shipping Bill Number</label>
         <input type="text" name="shipping_bill_no" id="shipping_bill_no" class="form-control shipping_bill_no" >
               
            </div>
     </div>
     <div class="col-md-3">
      <div class="form-group">
                <label>Container No.</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span>
                <textarea class="form-control exp_container_no" name="exp_container_no" id="exp_container_no" tabindex="19"></textarea>
            </div>
     </div>
    </div>
    
    
      <div class="col-md-12"> 
    <div class="col-md-3">
      <div class="form-group">
                <label>Volume</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span>
               
         <input type="text" name="exp_volume" id="exp_volume" class="form-control exp_volume" >
            </div> </div>
    <div class="col-md-3">
    
     <div class="form-group">
                <label>Container Type</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('place_of_delivery');?>
                <input type="text" name="exp_container_type" id="exp_container_type" class="form-control exp_container_type" >
            </div>

    </div>
    
    <div class="col-md-3">
    
     <div class="form-group">
                <label>Seal No</label>
                <input type="text" name="seal_no" id="seal_no" class="form-control seal_no" >
            </div>

    </div>
    <div class="col-md-3">
    
     <div class="form-group">
                <label>Job No</label>
                <input type="text" name="job_no" id="job_no" class="form-control job_no" >
            </div>

    </div>
    </div>
    
    
    
    <div class="col-md-12"> 
    <div class="col-md-3">
    <div class="form-group">
                <label>Place of Receipt</label>
                <textarea class="form-control exp_por" name="exp_por" id="exp_por" ></textarea>
            </div>
       </div>
       <div class="col-md-3">
    <div class="form-group">
                <label>Port of Loading</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('exp_pol');?>
                <textarea class="form-control exp_pol" name="exp_pol" id="exp_pol" ></textarea>
            </div>
       </div>
    <div class="col-md-3">
    
     <div class="form-group">
                <label>Port of Discharge</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('exp_pod');?>
                <textarea class="form-control exp_pod" name="exp_pod" id="exp_pod" ></textarea>
            </div>

    </div>
    
    <div class="col-md-3">
         <div class="form-group">
                <label>Final Place of Delivery/CFS</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('exp_fpd');?>
                <textarea class="form-control exp_fpd" name="exp_fpd" id="exp_fpd" ></textarea>
            </div>
     </div>
    
    </div>
  
  
  
    <div class="col-md-12"> 
    
    <div class="col-md-3">
    
      <div class="form-group">
                <label>Vessel Name</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('exp_vessel');?>
                <textarea class="form-control exp_vessel" name="exp_vessel" id="exp_vessel" ></textarea>
            </div>

    </div>
    
    <div class="col-md-3">
         <div class="form-group">
                <label>VOY No</label>&nbsp;&nbsp;&nbsp;<span style="color:red;font-weight: 900;">*</span><?php echo form_error('exp_voy');?>
                <textarea class="form-control exp_voy" name="exp_voy" id="exp_voy" ></textarea>
            </div>
     </div>
    
      <div class="col-md-3">
      <div class="form-group" >
                <label>Sailing Date</label>
                <input type="text" name="exp_sailing_date" id="exp_sailing_date" class="form-control datepicker" autocomplete="off" >
            </div>
    </div>
     <div class="col-md-3">
       <div class="form-group">
                <label>Exchange Rate</label>
                <input type="text" name="exp_exchange_rate" id="exp_exchange_rate" class="form-control" value="0">
            </div>
     </div>
    
    
    
    </div>
    
    
    
    
    
    
    
    
  </div>  
    
    
    
    
    
    
    
    
    


       

       
    

  
    <div class="col-md-12" id="import_div" style="display:none;">
            <input type="hidden" id="impcount" name="impcount" value="1">
            <div class="col-md-2">
                <div class="form-group">
                    <label>From</label>
                   
          <input type="text" data-count="1" idss="1" name="from_date[]" id="from_date1" value="<?php echo date('d-m-Y') ?>" class="form-control datepicker from_date" autocomplete="off">
                </div>
            </div>
            <div class="col-md-2">
                <div class="form-group">
                        <label>To</label>
                    
            <input type="text" data-count="1" idss="1" name="to_date[]" id="to_date1" value="<?php echo date('d-m-Y') ?>" class="form-control datepicker to_date" autocomplete="off">
                </div>
            </div>
            <div class="col-md-1">
                <div class="form-group">
                    <label>Days</label>
                    <input type="text" data-count="1" idss="1" name="imp_days[]" id="imp_days1" value="0" class="form-control imp_days" style="width: 81px;">
                </div>
            </div>
      <div class="col-md-1">
                <div class="form-group">
                    <label>Volume</label>
                    <input type="text" data-count="1" idss="1" name="imp_volume[]" id="imp_volume1" value="0" class="form-control imp_volume" style="width: 81px;">
                </div>
            </div>
       <div class="col-md-1">
                <div class="form-group">
                    <label>USD/Day </label>
                    <input type="text" data-count="1"  idss="1" name="imp_usd[]" id="imp_usd1" value="0" class="form-control imp_usd" style="width: 81px;">
                </div>
            </div>
       <div class="col-md-1">
                <div class="form-group">
                    <label>USD/Total </label>
                    <input type="text" data-count="1" idss="1" name="imp_usd_tot[]" id="imp_usd_tot1" value="0" class="form-control imp_usd_tot" style="width: 81px;">
                </div>
            </div>
       <div class="col-md-1">
                <div class="form-group">
                    <label>EX Rate</label>
                    <input type="text" data-count="1" idss="1" name="imp_rate[]" id="imp_rate1" value="0" class="form-control imp_rate" style="width: 81px;">
                </div>
            </div>
       <div class="col-md-2">
                <div class="form-group">
                    <label>Total</label>
                    <input type="text" data-count="1" idss="1" name="imp_total[]" id="imp_total1" value="0" class="form-control imp_total">
                </div>
            </div>
    
            <div class="col-md-1">
                <div class="form-group" >                   
                    <a  id="import_details" style="color:green;" idss="1" href="javascript:void(0);">
          <i class="fa fa-plus-square " aria-hidden="true" style=" margin-top: 34px;"></i>
          </a> 
                </div>
            </div>
      
      
      
        </div>
    
    <div class="col-md-12" style="display:none;" id="imp_total">
      <div class="col-md-7">
      </div>
      <div class="col-md-2">
        <label> Total Amount</label>
      </div>          
      <div class="col-md-2">
        <input type="text" name="tot_amounts" id="tot_amounts" value='0' class="form-control" readonly>
      </div>  
<div class="col-md-1">
        
      </div>        
    </div>  
  
  <div class="col-md-12">&nbsp;
  </div>
  <div class="col-md-12">&nbsp;
  </div>
       <div class="col-md-12" id="goods_div" style="display:none;">
            <input type="hidden" id="gcount" name="gcount" value="1">
            <div class="col-md-5">
                <div class="form-group">
                    <label>Charges</label>
                    <input type="text" data-count="1" name="goods[]" id="goods1" value="" class="form-control">
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                        <label>SAC</label>
                        <input type="text" data-count="1" name="sac[]" id="sac1" value="" class="form-control">
                </div>
            </div>
            <div class="col-md-3">
                <div class="form-group">
                    <label>AMOUNT IN RUPEES</label>
                    <input type="text" data-count="1" name="amount[]" id="amount1" value="" class="form-control amountClass">
                </div>
            </div>

            <div class="col-md-1">
                <div class="form-group" >                   
                    <a  id="add_goods_field" style="color:green;" href="javascript:void(0);"><i class="fa fa-plus" style=" margin-top: 34px;"></i></a> 
                </div>
            </div>
        </div>
 
         <div class="col-md-12">&nbsp;</div>

        <div class="col-md-12">
     <div class="col-md-3" >
    
           
              
                <label>Remarks</label>
                <textarea class="form-control remarks" name="remarks" id="remarks" ></textarea>
          
           
           
        </div>
    
      <div class="col-md-2"> 
        <div class="form-group" style="float:right;" >
               
                  <input type="radio" name="ihc" value="0" checked><b> TAX</b>
                  <input type="radio" name="ihc" value="1"> <span id="ihclabel"><b>IHC</b>   </span>       
            </div>

      </div>
        <div class="col-md-3" >
    
      
            <div class="form-group" style="float:right;" >
                <label>TAX TYPE&nbsp;</label>
                  <input type="radio" name="tax_type" value="0" checked> SGST
                  <input type="radio" name="tax_type" value="1"> IGST             
            </div>
            <table style="font-weight:bold;display:none;" id="ihc_table">
                   <tr>    
                        <td width="85%" style="text-align: right;">SAC : &nbsp; </td>
                        <td width="15%"><input type="text" id="ihsac" name="ihsac"  class="inputcurve" value="" /></td>
                   </tr>
                   <tr>    
                        <td width="85%" style="text-align: right;" id="amtlabel">IHC : &nbsp; </td>
                        <td width="15%"><input type="text" id="amt" name="amt"  class="inputcurve" value="0" /></td>
                   </tr>
                   <tr>    
                        <td width="85%" style="text-align: right;" id="ihcamtlabel">IHC Amt : &nbsp; </td>
                        <td width="15%"><input type="text" id="ihc_amnt" name="ihc_amnt"  class="inputcurve" value="0" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr> 
                    <tr>    
                        <td width="85%" style="text-align: right;">SGST(%) : &nbsp; </td>
                        <td width="15%"><input type="text" id="ihc_sgst" name="ihc_sgst"  class="inputcurve" value="9" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>
                    <tr>    
                        <td width="85%" style="text-align: right;">SGST : &nbsp; </td>
                        <td width="15%"><input type="text" id="ihc_sgst_amt" name="ihc_sgst_amt"  class="inputcurve" value="0.00" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>
                    <tr>    
                        <td width="85%" style="text-align: right;">CGST(%) : &nbsp; </td>
                        <td width="15%"><input type="text" id="ihc_cgst" name="ihc_cgst"  class="inputcurve" value="9" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>
                    <tr>    
                        <td width="85%" style="text-align: right;">CGST : &nbsp; </td>
                        <td width="15%"><input type="text" id="ihc_cgst_amt" name="ihc_cgst_amt"  class="inputcurve" value="0.00" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>
                    <tr>    
                        <td width="85%" style="text-align: right;">IGST(%) : &nbsp; </td>
                        <td width="15%"><input type="text" id="ihc_igst" name="ihc_igst"  class="inputcurve" value="0" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>
                    <tr>    
                        <td width="85%" style="text-align: right;">IGST : &nbsp; </td>
                        <td width="15%"><input type="text" id="ihc_igst_amt" name="ihc_igst_amt"  class="inputcurve" value="0.00" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>  
                    <tr>
                        <td width="85%" style="text-align: right;">IHC TAX : &nbsp;</td>
                        <td width="15%"><input type="text" id="ihc_tax_amnt" name="ihc_tax_amnt" value="0.00" class="inputcurve"/></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>   
                   
            </table>
        </div>
    
        <div class="col-md-4">
            <table style="font-weight:bold;">
  
                    <tr>    
                        <td width="85%" style="text-align: right;">TOTAL BEFORE TAX : &nbsp; </td>
                        <td width="15%"><input type="text" id="tot_before_tax" name="tot_before_tax"  class="inputcurve" value="0.00" readonly=""/></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr> 
                    <tr>    
                        <td width="85%" style="text-align: right;">SGST(%) : &nbsp; </td>
                        <td width="15%"><input type="text" id="sgst" name="sgst"  class="inputcurve" value="9" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>
                    <tr>    
                        <td width="85%" style="text-align: right;">SGST : &nbsp; </td>
                        <td width="15%"><input type="text" id="sgst_amt" name="sgst_amt"  class="inputcurve" value="0.00" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>
                    <tr>    
                        <td width="85%" style="text-align: right;">CGST(%) : &nbsp; </td>
                        <td width="15%"><input type="text" id="cgst" name="cgst"  class="inputcurve" value="9" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>
                    <tr>    
                        <td width="85%" style="text-align: right;">CGST : &nbsp; </td>
                        <td width="15%"><input type="text" id="cgst_amt" name="cgst_amt"  class="inputcurve" value="0.00" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>
                    <tr>    
                        <td width="85%" style="text-align: right;">IGST(%) : &nbsp; </td>
                        <td width="15%"><input type="text" id="igst" name="igst"  class="inputcurve" value="0" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>
                    <tr>    
                        <td width="85%" style="text-align: right;">IGST : &nbsp; </td>
                        <td width="15%"><input type="text" id="igst_amt" name="igst_amt"  class="inputcurve" value="0.00" /></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>  
                    <tr>
                        <td width="85%" style="text-align: right;">TAX AMOUNT : &nbsp;</td>
                        <td width="15%"><input type="text" id="tax_amnt" name="tax_amnt" value="0.00" class="inputcurve" readonly=""/></td>
                    </tr>
                    <tr>
                        <td width="85%">&nbsp;</td>
                        <td width="15%">&nbsp;</td>                                 
                    </tr>   
                    <tr>
                        <td width="85%" style="text-align: right;" >SUB TOTAL : &nbsp;</td>
                        <td width="15%"><input type="text" id="total" name="total" value="0.00" class="inputcurve" readonly="" /></td>         

                    </tr>
            </table>
        </div>

        </div>
        
            
            <div class="form-group">            
              <div class="col-md-6" style="padding-top: 30px;">
			  <input type="submit" id="submit" name="submit" class="btn btn-info submit" value="Save" style="display:none">
			   <button type="button" id="submit_button" class="btn btn-info" >SAVE</button>
              <a href="<?php echo base_url()?>Invoice/generate_invoice"><button type="button" class="btn btn-warning">Cancel</button></a>
             <button type="button" class="btn btn-warning" onclick="booking_preview()" data-toggle="modal" data-target="#myModal">Preview</button>	

              </div>
			  
			  
			  
			  
			  
			  <div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog" id="modal_id" style="display:none">

    <!-- Modal content-->
    <div class="modal-content" style="width: 1000px;margin-left: -100px;" >
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h2 class="modal-title"><b>Invoice</b></h2>
      </div>
			  <div class="modal-body" >
				<table width="100%">
				<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Company:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="advt_type_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Branch:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="unname_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
					</tr>
					
					
					
					
					
					<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Customer:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="unit_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Invoice Date:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="date_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
					</tr>
					
					<tr width="100%">
					
				<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Shipper/Exporter:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
					
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="editions_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label></label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						<td width="5%">
						</td>
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
					</tr>
					
					
					<tr width="100%">
					
					
						<td width="20%">
							<table  width="100%">
								<tr>
									<td>
										 <label>B/L No:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table  width="100%">
								<tr>
									<td>
										<span id="pos_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table  width="100%">
								<tr>
									<td>
										 <label>Shipping Bill Number:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table  width="100%">
								<tr>
									<td>
										<span id="pageno_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
					</tr>
					
				
					
					<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Container No:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="size_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Volume:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="clr_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
						
					</tr>
					
				
					
					<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Container Type:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="booking_type_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Seal No:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="booking_date_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
					</tr>
					
					
					
					<tr width="100%">
					
					
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Place of Receipt:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="ro_no_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
					</tr>
					
					
					<tr width="100%" id="import_pre_div">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Berth/Arrival Date:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="berth_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Gross Weight: </label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="gross_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="10%">
							<table width="100%">
								<tr>
									<td>
										 <label>Free Days:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="15%">
							<table width="100%">
								<tr>
									<td>
										<span id="free_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
					</tr>
					
					
					
					
					<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Port of Loading: </label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="booking_unit_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
						
					</tr>
					
					<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Port of Discharge: </label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="agency_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Final Place of Delivery/CFS: </label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="client_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
					</tr>
					
					
					
					<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Vessel Name: </label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="canvasser_span"></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>VOY No:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="caption_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
					</tr>
					
					
					
					<tr width="100%">
					
					
						
						
						
						
						
						
					</tr>
					
					<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Exchange Rate:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="billing_to_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
					<!--	<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Charges</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						<td width="5%">:
						</td>
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="price_span" ></span>
									</td>
								</tr>
							</table>
						</td>-->
						
						
						
					</tr>
					
					<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Total Before Tax: </label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="rate_span"></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
						
					</tr>
					
					
					
					<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Remarks:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="taxable_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
						
					</tr>
					<tr width="100%" id="pre_export">
					
					<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Job No:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="ro_date_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Sailing Date:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="cname_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
						
					
					
					</tr>
					
					
					
					
					
					<tr width="100%">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Tax IGST:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="igst_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Tax SGST:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="sgst_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Tax CGST:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="cgst_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
						
						
					</tr>
					
						<tr width="100%" id="pre_ocr">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>OCEAN FR IGST:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="ocigst_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>OCEAN FR SGST:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="ocsgst_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>OCEAN FR CGST:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="occgst_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
						
						
					</tr>
					
					
					
					
					
					<tr width="100%" id="pre_ihc">
					
					
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>IHC IGST:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="ihigst_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>IHC SGST:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="ihsgst_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>IHC CGST:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="ihcgst_span" ></span>
									</td>
								</tr>
							</table>
						</td>
						
						
						
						
						
						
					</tr>
					
					<tr width="100%">
					<td width="20%">
							<table width="100%">
								<tr>
									<td>
										 <label>Grand Total:</label>		
									</td>
									
								</tr>
								
							</table>
						</td>
						
						<td width="25%">
							<table width="100%">
								<tr>
									<td>
										<span id="netamt_span" ></span>
									</td>
								</tr>
							</table>
						</td>
					</tr>
								
							</table>
						
						
						
					</tr>
					
					
								
							</table>
						</td>
						
						
						
						
						
						
						
					</tr>
					
					
				
								
							</table>
						</td>
						
						
					
						
						
						
						
					</tr>
					
					
				
				
					
					
				</table>
			
				
			  </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

  </div>
</div>
			  
			  
		
		
			  
			  
            <div id="myModal" class="modal fade" role="dialog">
            <div class="modal-dialog">

              <!-- Modal content-->
              <div class="modal-content">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal" >&times;</button>
                  <h4 class="modal-title">Invoice</h4>
                </div>
                <div class="modal-body" id ="import">
                  <div class="col-md-12">
                    <div class="col-md-3">
                   <div class="form-group">
                     <label>Invoice Date</label>
                     <input type="text"  id="invoiceDate" class="form-control" readonly>
                   </div>
                 </div>

                 <div class="col-md-3">
                    <div class="form-group">
                      <label>B/L No </label>
                      <input type="text"  id="billNumber" class="form-control" readonly>
                    </div>
                  </div>


                   <div class="col-md-3">
                    <div class="form-group">
                      <label>Gross Weight </label>
                      <input type="text" id="grossWeight" class="form-control" readonly>
                    </div>
                  </div>

                  <div class="col-md-3">
                    <div class="form-group">
                      <label>Free Days</label>
                      <input type="text"  id="freeDays" class="form-control" readonly>
                    </div>
                  </div>
                </div>

                <div class="col-md-12">
                  <div class="col-md-3">
                    <div class="form-group">
                      <label>Port of Loading </label>
                      <input type="text"  id="portOfLoading" class="form-control" readonly>
                    </div>
                  </div>

                    <div class="col-md-5">
                     <div class="form-group">
                      <label>Port of Discharge </label>
                      <input type="text"  id="portOfDischarge" class="form-control" readonly>
                    </div>
                  </div>

                    <div class="col-md-5">
                    <div class="form-group">
                      <label>Final Place of Delivery/CFS  </label>
                      <input type="text"   id="finalDelivery" class="form-control" readonly>
                    </div>
                  </div>

                  <div class="col-md-3">
                    <div class="form-group">
                      <label> Container No </label>
                      <input type="text"  id="containerNumber" class="form-control" readonly>
                    </div>
                  </div>
                  </div>

                  <div class="col-md-12">
                  <div class="col-md-3">
                    <div class="form-group">
                      <label>Vessel </label>
                      <input type="text"  id="vessel" class="form-control" readonly>
                    </div>
                  </div>

                   <div class="col-md-3">
                    <div class="form-group">
                      <label>Voyage </label>
                      <input type="text"  id="voyage" class="form-control" readonly>
                    </div>
                  </div>

                     <div class="col-md-5">
                     <div class="form-group">
                      <label>Berth/Arrival Date </label>
                      <input type="text"  id="arrivalDate" class="form-control" readonly>
                    </div>
                  </div>

                      <div class="col-md-3">
                     <div class="form-group">
                      <label>Volume </label>
                      <input type="text"  id="volume" class="form-control" readonly>
                    </div>
                  </div>
                  </div>
                   <div class="col-md-12">
                    <div class="col-md-3">
                    <div class="form-group">
                      <label>Job Ref </label>
                      <input type="text"  id="jobRef" class="form-control" readonly>
                    </div>
                  </div>
                  </div>
                  

                   
                 
                </div>

                <div class="modal-body" id ="export">
                  
                  <!--  <div class="form-group">
                     <label>Invoice Date</label>
                     <input type="text"  id="invoiceDate" class="form-control" readonly>
                   </div>
 -->
                  <div class="col-md-12">
                    <div class="col-md-3">
                    <div class="form-group">
                     <label>B/L No  </label>
                     <input type="text"  id="billNumbers" class="form-control"  readonly>
                    </div>
                  </div>

                  <div class="col-md-4">
                    <div class="form-group">
                     <label>Shipping Bill Number</label>
                     <input type="text"  id="shippingBill" class="form-control" readonly>
                   </div>
                 </div>

                   <div class="col-md-3">
                   <div class="form-group">
                     <label>Container No</label>
                     <input type="text"  id="containerNumbes" class="form-control" readonly>
                   </div>
                 </div>

                  <div class="col-md-3">
                   <div class="form-group">
                      <label>Volume </label>
                      <input type="text"  id="volumes" class="form-control" readonly>
                    </div>
                  </div>
                  </div>

                  <div class="col-md-12">
                    <div class="col-md-3">
                    <div class="form-group">
                      <label>Container Type </label>
                      <input type="text"  id="containerType" class="form-control" readonly>
                    </div>
                  </div>

                     <div class="col-md-3">
                     <div class="form-group">
                      <label>Seal No </label>
                      <input type="text"  id="sealNumber" class="form-control" readonly>
                    </div>
                  </div>

                    <div class="col-md-3">
                    <div class="form-group">
                      <label>Job No </label>
                      <input type="text"  id="jobNumber" class="form-control" readonly>
                    </div>
                  </div>

                    <div class="col-md-3">
                    <div class="form-group">
                      <label>Place Of Receipt </label>
                      <input type="text"  id="placeOfReceipt" class="form-control" readonly>
                    </div>
                  </div>
                  </div>

                   <div class="col-md-12">
                    <div class="col-md-3">
                    <div class="form-group">
                      <label>Port Of Loading </label>
                      <input type="text"  id="portOfLoading" class="form-control" readonly>
                    </div>
                  </div>

                    <div class="col-md-5">
                    <div class="form-group">
                      <label>Port of Discharge  </label>
                      <input type="text"  id="portOfDischarge" class="form-control" readonly>
                    </div>
                  </div>

                    <div class="col-md-5">
                    <div class="form-group">
                      <label>Final Place of Delivery/CFS  </label>
                      <input type="text"   id="finalDelivery" class="form-control" readonly>
                    </div>
                  </div>

                    <div class="col-md-3">
                    <div class="form-group">
                      <label>Vessel Name </label>
                      <input type="text"  id="vessel" class="form-control" readonly>
                    </div>
                  </div>
                  </div>

                  <div class="col-md-12">
                    <div class="col-md-3">
                    <div class="form-group">
                      <label>Voyage No </label>
                      <input type="text"  id="voyage" class="form-control" readonly>
                    </div>
                  </div>

                   <div class="col-md-3">
                    <div class="form-group">
                      <label>Sailing Date </label>
                      <input type="text"  id="sailingDate" class="form-control" readonly>
                    </div>
                  </div>

                    <div class="col-md-3">
                    <div class="form-group">
                      <label>Exchange Rate </label>
                      <input type="text"  id="exchangeDate" class="form-control" readonly>
                    </div>
                  </div>
                  </div>
                </div>

                <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal" onclick="javascript:window.location.reload()">Close</button>
                </div>
              </div>

            </div>
          </div>
        
            <div class="col-md-6" style="padding-top: 30px;">
              <div class="col-md-4"> 
                <button type="button" class="btn btn-success" id="cal_gtotal">Calculate Grand Total</button>
              </div>
              
              <div class="col-md-4">
                
                  <b>GRAND TOTAL</b>
                
                
              </div>
              <div class="col-md-4">
                
                <input type="text" id="view_total" name="view_total" value="0.00" class="inputcurve" style="margin-left: -14px;" readonly="" />
                
              </div>
            </div>
            </div>

           
      </div>

  </form>
  
</div>
  <script> 
  
 </script>

<script type="text/javascript">


 $(function()
    {
        //setTimeout(branch_select);
        //setTimeout(company_select);
        setTimeout(consignor_select);
        setTimeout(shipper_select);
        setTimeout(consignee_select);
        setTimeout(customer_select);
        setTimeout(notify_select);
        setTimeout(portname_select);
    });

	function booking_preview()
	{
		var height=0;
		var width=0;
		 var type = $("input:radio[name=type]:checked").val();
		 var un_name = $('#bill_cust_id option:selected').text();
		 var company=$('#bill_company_id option:selected').text();
		 var branch=$('#bill_brnch_id option:selected').text();
		 var invoice_date = $("#invoice_date").val();
		 var remarks=$("#remarks").val();
		  var igst_amt=$("#igst_amt").val();
		  var sgst_amt=$("#sgst_amt").val();
		   var cgst_amt=$("#cgst_amt").val();
		   var view_total = $("#view_total").val();
		   netamt_span.textContent = view_total;
		  var tot_before_tax=$("#tot_before_tax").val();
		  
		  igst_span.textContent=igst_amt;
		   sgst_span.textContent=sgst_amt;
		     cgst_span.textContent=cgst_amt;
			 
		 rate_span.textContent=tot_before_tax;
		 taxable_span.textContent=remarks;
		 if(type=='0')
		 {
			$('#modal_id').show();
			
			var exp_bill_no  = $("#exp_bill_no").val();
		var shipping_bill_no = $("#shipping_bill_no").val();		
		var exp_container_no = $("#exp_container_no").val();		
		var exp_volume = $("#exp_volume").val();		
		var exp_container_type = $("#exp_container_type").val();	
		var seal_no = $("#seal_no").val();		
		var job_no = $("#job_no").val();
		var exp_por = $("#exp_por").val();		
		var exp_pol = $("#exp_pol").val();
		var exp_pod=$("#exp_pod").val();
		var exp_fpd = $("#exp_fpd").val();
		var view_total = $("#view_total").val();
		var shipper=$('#exp_shipper_id option:selected').text();
		var exp_vessel=$("#exp_vessel").val();
		var exp_voy=$("#exp_voy").val();
		var exp_sailing_date=$("#exp_sailing_date").val();
		var exp_exchange_rate=$("#exp_exchange_rate").val();
		
		var ihc_sgst_amt=$("#ihc_sgst_amt").val();
		var ihc_cgst_amt=$("#ihc_cgst_amt").val();
		var ihc_igst_amt=$("#ihc_igst_amt").val();
		
		ocigst_span.textContent=ihc_igst_amt;
		occgst_span.textContent=ihc_cgst_amt;
		ocsgst_span.textContent=ihc_sgst_amt;
		
		billing_to_span.textContent=exp_exchange_rate;
		cname_span.textContent=exp_sailing_date;
		caption_span.textContent=exp_voy;
		canvasser_span.textContent=exp_vessel;
		pos_span.textContent = exp_bill_no;
		pageno_span.textContent = shipping_bill_no;
		size_span.textContent = exp_container_no;
		clr_span.textContent = exp_volume;
		
		booking_type_span.textContent = exp_container_type;
		booking_date_span.textContent = seal_no;
		ro_date_span.textContent = job_no;
		ro_no_span.textContent = exp_por;
		booking_unit_span.textContent = exp_pol;
		agency_span.textContent = exp_pod;
		client_span.textContent = exp_fpd;
			
		netamt_span.textContent = view_total;
			unit_span.textContent = un_name;
			advt_type_span.textContent=company;
			unname_span.textContent=branch;
			date_span.textContent=invoice_date;
			editions_span.textContent=shipper;
			
			}
			
			
			else{
				$('#modal_id').show();
				
				var shipper=$('#bill_cnsgnr_id option:selected').text();
				var exp_bill_no  = $("#bill_no").val();
		var port_of_loading = $("#port_of_loading").val();		
		var exp_container_no = $("#container_no").val();		
		var volume = $("#volume").val();		
		var exp_container_type = $("#exp_container_type").val();	
		var seal_no = $("#seal_no").val();		
		var job_no = $("#job_no").val();
		var exp_por = $("#exp_por").val();		
		var exp_pol = $("#exp_pol").val();
		var exp_pod=$("#place_of_delivery").val();
		
		var exp_fpd = $("#fpod").val();
		var ocean_vessel = $("#ocean_vessel").val();
		var voyage = $("#voyage").val();
		var arrival_date=$("#arrival_date").val();
		var gross_weight=$("#gross_weight").val();
		var free_days=$("#free_days").val();
		var ihc_sgst_amt=$("#ihc_sgst_amt").val();
		var ihc_cgst_amt=$("#ihc_cgst_amt").val();
		var ihc_igst_amt=$("#ihc_igst_amt").val();
		
		ihsgst_span.textContent=ihc_sgst_amt;
		ihcgst_span.textContent=ihc_cgst_amt;
		ihigst_span.textContent=ihc_igst_amt;
		
		free_span.textContent=free_days;
		gross_span.textContent=gross_weight;
		berth_span.textContent=arrival_date;
		pos_span.textContent = exp_bill_no;
		pageno_span.textContent = shipping_bill_no;
		size_span.textContent = exp_container_no;
		clr_span.textContent = volume;
		
		booking_type_span.textContent = exp_container_type;
		booking_date_span.textContent = seal_no;
		ro_date_span.textContent = job_no;
		ro_no_span.textContent = exp_por;
		booking_unit_span.textContent = exp_pol;
		agency_span.textContent = exp_pod;
		client_span.textContent = exp_fpd;
		booking_unit_span.textContent=	port_of_loading;
			canvasser_span.textContent=ocean_vessel;
			caption_span.textContent=voyage;
			advt_type_span.textContent=company;	
				unname_span.textContent=branch;
				unit_span.textContent = un_name;
				date_span.textContent=invoice_date;
				editions_span.textContent=shipper;
			}
			
			
			//var bill_company_id = $("#bill_company_id").val();
			//alert(bill_company_id);
		
			
			
			
	}
	
	
	
	
	
	
	
 $(document).on('click', '#Modal', function(){

  var type = $('input[name=type]:checked').val();
  // alert(type);
  if(type == '0'){

    $('#import').hide();
    // $('#export').show();
    //  var invoiceDate = $('#invoice_date').val();
    // $('#invoiceDate').val(invoiceDate);

     var exp_bill_no = $('#exp_bill_no').val();
    $('#billNumbers').val(exp_bill_no);

     var shipping_bill_no = $('#shipping_bill_no').val();
    $('#shippingBill').val(shipping_bill_no);

    var exp_container_no = $('#exp_container_no').val();
    $('#containerNumbes').val(exp_container_no);

     var exp_volume = $('#exp_volume').val();
    $('#volumes').val(exp_volume);
	 var containerType = $('#exp_container_type').val();
    $('#containerType').val(containerType);
	 var seal_no = $('#seal_no').val();
    $('#sealNumber').val(seal_no);
	
	 var job_no = $('#job_no').val();
    $('#jobNumber').val(job_no);

     var exp_por = $('#exp_por').val();
     $('#placeOfReceipt').val(exp_por);
    
    

  } else{

    $('#export').hide();
    // $('import').show();
     var invoiceDate = $('#invoice_date').val();
    $('#invoiceDate').val(invoiceDate);

    var bill_no = $('#bill_no').val();
    $('#billNumber').val(bill_no);

    var gross_weight = $('#gross_weight').val();
    $('#grossWeight').val(gross_weight);

    var free_days = $('#free_days').val();
    $('#freeDays').val(free_days);

     var port_of_loading = $('#port_of_loading').val();
    $('#portOfLoading').val(port_of_loading);

    var place_of_delivery = $('#place_of_delivery').val();
    $('#portOfDischarge').val(place_of_delivery);

     var fpod = $('#fpod').val();
    $('#finalDelivery').val(fpod);

     var container_no = $('#container_no').val();
    $('#containerNumber').val(container_no);

     var ocean_vessel = $('#ocean_vessel').val();
    $('#vessel').val(ocean_vessel);

     var voyage = $('#voyage').val();
    $('#voyage').val(voyage);

     var vessel_berth = $('#vessel_berth').val();
    $('#arrivalDate').val(vessel_berth);

     var volume = $('#volume').val();
    $('#volume').val(volume);

     var job_ref = $('#job_ref').val();
    $('#jobRef').val(job_ref);

    


  }
  // alert(type);
 
  // alert(name);
 });
  
  
  $(document).ready(function() 
  {
    
  
  
  //$("#exp_id").click();
  });

  $(document).on('change','#arrival_date', function() 
  { 
      var arr_val = $('#arrival_date').val();  
     $('#from_date1').val(arr_val);
	 var from_date=$('#from_date1').val();
	 
	var d =new Date(from_date.split("-").reverse().join("-"));
 // alert(d);
  var dd =d.getDate();
  var mm =d.getMonth()+1;
  var yy =d.getFullYear();
  var newdate=yy+"/"+mm+"/"+dd;
  // alert(newdate);
   
   
   
    var d1 = new Date(newdate); 
    var m1 = moment(d1); 
    m1.add('days', 13); 
    d2 = m1.toDate();
  var vv = moment(d2).format('DD-MM-YYYY');
	 $('#to_date1').val(vv);
	 
	  //var id_val = $(this).attr('idss');
    var first      = $('#from_date1').val();
    var second     = $('#to_date1').val();
    var a = moment(first, 'DD/MM/YYYY');
    var b = moment(second, 'DD/MM/YYYY');
    var days = b.diff(a, 'days');
    //var diff =  Math.floor(( Date.parse(second) - Date.parse(first) ) / 86400000); 
    //var difffs = datediff(parseDate(first), parseDate(second));
  
    $('#imp_days1').val(days+1);
	 
	 $('.to_date').trigger("change");
	 
	//var to_date=from_date.setDate(from_date.getDate() + 14);
	 
	// $to_date = date('Y-m-d', strtotime('+14 days', strtotime(from_date)));
	// var to_date=from_date.setDate(from_date.getDate()+14);
	 //var to_date=from_date+14;
	  //alert(vv);
  }); 
  

   $(document).on('change','#amt', function() 
   { 
      var excRate = $('#exp_exchange_rate').val();
      var amt     = $('#amt').val();  
      var ihcAmt  = parseFloat(excRate)*parseFloat(amt);
      ihcAmt      = ihcAmt.toFixed(2);
      $('#ihc_amnt').val(ihcAmt);
  }); 

      $(document).on('change','#exp_exchange_rate', function() 
   { 
      var excRate = $('#exp_exchange_rate').val();
      var amt     = $('#amt').val();  
      var ihcAmt  = parseFloat(excRate)*parseFloat(amt);
      ihcAmt      = ihcAmt.toFixed(2);
      $('#ihc_amnt').val(ihcAmt);
  });
  
  $(document).on('click','#cal_gtotal', function() 
  { 
  
  var ihc_amnt = $("#ihc_amnt").val();
  var ihc_total = $("#ihc_tax_amnt").val();
    var total1 = $("#total").val();
    var total2 = 0; //$("#tot_amounts").val();
  if(total2==null || total2=='') { total2 =0;}
  if(ihc_amnt==null || ihc_amnt=='') { ihc_amnt =0;}
  if(ihc_total==null || ihc_total=='') { ihc_total =0;}
    var total3 =  (parseFloat(total1)+parseFloat(ihc_amnt)+parseFloat(total2)+parseFloat(ihc_total)).toFixed(1);
    var total4 = Math.round(total3 * 100) / 100;
    $("#view_total").val(total4);
	
	
	/*
	setTimeout(
            function() {
                $( "#submit" ).click();
            },
            4000);*/
	
  }); 
  
  
    $(document).on('click','#submit_button', function() 
  { 
  
	$("#submit_button").prop("disabled",true);
	$( "#cal_gtotal" ).click();
	
	
	setTimeout(
            function() {
                $( "#submit" ).click();
            },
            3000);
	
  }); 
  
  
  
  
  
  
  
  
  
 $('#invoice_date,#date_of_issue').datepicker({ format: 'dd-mm-yyyy'});
 
 
 $('.datepicker').datepicker({ format: 'dd-mm-yyyy'});
//$('.from_date').datepicker({ format: 'dd-mm-yyyy'});


 $(document).on('click', '#add_goods_field', function (e) {
            add_goods_field();
    });
  
  
  $(document).on('click','#import_details', function (e) 
  {
    add_rows();
  });

    $("#bill_brnch_id").on('change',function(){
        var branch_name = $("#bill_brnch_id option:selected").text();
        $("#port_of_loading").val(branch_name);
        // console.log(branch_name);
    });

  function add_rows()
   { 
   
   
   
   
     var count = $('#impcount').val();
	 
	  // var first      = $('#from_date'+count).val();
	//alert(first);
   // var second     = $('#to_date'+count).val();
	//alert(second);
	 
    var to_val = $('#to_date'+count).val();
	
	 var d =new Date(to_val.split("-").reverse().join("-"));
  
  var dd =d.getDate();
  var mm =d.getMonth()+1;
  var yy =d.getFullYear();
  var newdate=yy+"/"+mm+"/"+dd;
  // alert(newdate);
   
   
   
    var d1 = new Date(newdate); 
    var m1 = moment(d1); 
    m1.add('days', 1); 
    d2 = m1.toDate();
	var to_val1 = moment(d2).format('DD-MM-YYYY');
	
	
	
	
  
   //var date= '21/01/2015';
  var d =new Date(to_val1.split("-").reverse().join("-"));
  
  var dd =d.getDate();
  var mm =d.getMonth()+1;
  var yy =d.getFullYear();
  var newdate=yy+"/"+mm+"/"+dd;
  // alert(newdate);
   
   
   
    var d1 = new Date(newdate); 
    var m1 = moment(d1); 
    m1.add('days',4); 
    d2 = m1.toDate();
	var vv = moment(d2).format('DD-MM-YYYY');
	
	
	//var first      = $('#from_date'+count).val();
	
  //var vv = moment(d2).format('DD-MM-YYYY');
  
  
 // var id_val = $(this).attr('idss');
    //var first      = $('#from_date'+count).val();
	//alert(first);
   // var second     = $('#to_date'+count).val();
	//alert(second);
    var a = moment(to_val1, 'DD/MM/YYYY');
    var b = moment(vv, 'DD/MM/YYYY');
    var days = b.diff(a, 'days');
    //var diff =  Math.floor(( Date.parse(second) - Date.parse(first) ) / 86400000); 
    //var difffs = datediff(parseDate(first), parseDate(second));
  
   var im=days+1;
  //alert(im);
///


      count     = parseInt(count)+1;     
    
      var str   = '<div class="col-md-2 new_rows'+count+'" ><div class="form-group">'+                     
                       '<input type="text" name="from_date[]" id="from_date'+count+'" value="'+to_val1+'" class="datepicker form-control  from_date" idss="'+count+'" autocomplete="off">'+                                                      
                  '</div>'+
                  '</div>'+

                  '<div class="col-md-2 new_rows'+count+'" ><div class="form-group">'+                     
                       '<input type="text" name="to_date[]" id="to_date'+count+'" value="'+vv+'" class=" datepicker form-control   to_date" idss="'+count+'" autocomplete="off">'+                                                      
                  '</div>'+
                  '</div>'+
          
          '<div class="col-md-1 new_rows'+count+'" ><div class="form-group">'+                     
                       '<input type="text" name="imp_days[]" id="imp_days'+count+'" value="'+im+'" class="form-control imp_days" style="width: 81px;" idss="'+count+'">'+                                                      
                  '</div>'+
                  '</div>'+
          
          '<div class="col-md-1 new_rows'+count+'" ><div class="form-group">'+                     
                       '<input type="text" name="imp_volume[]" id="imp_volume'+count+'" value="0" class="form-control imp_volume" style="width: 81px;" idss="'+count+'">'+                                                      
                  '</div>'+
                  '</div>'+
          
          '<div class="col-md-1 new_rows'+count+'" ><div class="form-group">'+                     
                       '<input type="text" name="imp_usd[]" id="imp_usd'+count+'" value="0" class="form-control imp_usd" style="width: 81px;" idss="'+count+'">'+                                                      
                  '</div>'+
                  '</div>'+
          
           '<div class="col-md-1 new_rows'+count+'" ><div class="form-group">'+                     
                       '<input type="text" name="imp_usd_tot[]" id="imp_usd_tot'+count+'" value="0" class="form-control imp_usd_tot" style="width: 81px;" idss="'+count+'">'+                                                      
                  '</div>'+
                  '</div>'+
          
           '<div class="col-md-1 new_rows'+count+'" ><div class="form-group">'+                     
                       '<input type="text" name="imp_rate[]" id="imp_rate'+count+'" value="0" class="form-control imp_rate" style="width: 81px;" idss="'+count+'">'+                                                      
                  '</div>'+
                  '</div>'+
          
           '<div class="col-md-2 new_rows'+count+'" ><div class="form-group">'+                     
                       '<input type="text" name="imp_total[]" id="imp_total'+count+'" value="0" class="form-control imp_total" idss="'+count+'">'+                                                      
                  '</div>'+
                  '</div>'+
         
                  '<div class="col-md-1 new_rows'+count+'"><div class="form-group">'+                    
                       '<a class="del_imp_field" data-rowID="'+count+'"  id ="delt'+count+'" style="color:red;" href="javascript:void(0);" idss="'+count+'"><i class="fa fa-remove"></i></a>'+                                                      
                  '</div>'+
                  '</div>';    
          
              
    $("#import_div").append(str);   
  $('.datepicker').datepicker({ format: 'dd-mm-yyyy'}); 
    $("#impcount").val(count);
     
  }
  

   $(document).on('click','.datepicker', function() { 
   $(this).datepicker();
    }); 
  
 function add_goods_field()
   { 
      var count = $('#gcount').val();
      count     = parseInt(count)+1;     
      var str   = '<div class="col-md-5 new_row'+count+'" ><div class="form-group">'+                     
                       '<input type="text" name="goods[]" id="goods'+count+'" value=""  class="form-control">'+                                                      
                  '</div>'+
                  '</div>'+

                  '<div class="col-md-3 new_row'+count+'" ><div class="form-group">'+                    
                       '<input type="text" name="sac[]" id="sac'+count+'" value="" class="form-control">'+                                                      
                  '</div>'+
                  '</div>'+

                  '<div class="col-md-3 new_row'+count+'" ><div class="form-group">'+                    
                       '<input type="text" name="amount[]" id="amount'+count+'" value="" class="form-control amountClass">'+                                                      
                  '</div>'+
                  '</div>'+

                  '<div class="col-md-1 new_row'+count+'"><div class="form-group">'+                    
                       '<a class="del_goods_field" data-rowID="'+count+'"  id ="del'+count+'" style="color:red;" href="javascript:void(0);"><i class="fa fa-remove"></i></a>'+                                                      
                  '</div>'+
                  '</div>';    
          
              
    $("#goods_div").append(str);    
    $("#gcount").val(count);
     
  }
 jQuery(document).on('change','#ihc_amnt',taxAmount_ihc);
 jQuery(document).on('keyup','.amountClass',totbeftax);
 //jQuery(document).on('change','.to_date',calculatedaydiff);
 //jQuery(document).on('change','.from_date',calculatedaydiff);
 jQuery(document).on('change','.imp_total',get_tot_amount);
 //jQuery(document).on('change','.imp_total',totbeftax);
 
  jQuery(document).on('change','.imp_days',import_sub_total);
  jQuery(document).on('change','.imp_volume',import_sub_total);
  jQuery(document).on('change','.imp_days',import_sub_total);
  jQuery(document).on('change','.imp_usd',import_sub_total);
  jQuery(document).on('change','.imp_usd_tot',import_sub_total);
  jQuery(document).on('change','.imp_rate',import_sub_total);
  jQuery(document).on('change','.from_date',import_sub_total);
  jQuery(document).on('change','.to_date',import_sub_total);
  
  jQuery(document).on('change','.from_date',date_diff_fn);
  jQuery(document).on('change','.to_date',date_diff_fn);
  jQuery(document).on('change','.to_date',from_date_fn);
  
  function import_sub_total()
  {
    var id_val = $(this).attr('idss');
  
    var days           = $('#imp_days'+id_val).val();
    var imp_volume     = $('#imp_volume'+id_val).val();
    var imp_usd      = $('#imp_usd'+id_val).val();
    var imp_usd_tot    = $('#imp_usd_tot'+id_val).val();
    var imp_rate     = $('#imp_rate'+id_val).val();
    
    var tot_usd_tot    = parseFloat(days)*parseFloat(imp_volume)*parseFloat(imp_usd);
    var tot_total      = parseFloat(imp_rate)*parseFloat(tot_usd_tot);
    $('#imp_usd_tot'+id_val).val(tot_usd_tot);
    $('#imp_total'+id_val).val(tot_total);
    //tot_amount         = parseFloat(tot_amount)+parseFloat(amount);
  
    //$('#tot_amounts').val(tot_amount);  
    
    get_tot_amount();
    
  }
  
  
  function parseDate(str) 
  {
    var mdy = str.split('-');
    return new Date(mdy[2], mdy[0]-1, mdy[1]);
  }

  function datediff(first,second) 
  {
    
    return Math.round((second-first)/(1000*60*60*24));
  }

  
  function date_diff_fn() 
  {
    
    var id_val = $(this).attr('idss');
    var first      = $('#from_date'+id_val).val();
    var second     = $('#to_date'+id_val).val();
    var a = moment(first, 'DD/MM/YYYY');
    var b = moment(second, 'DD/MM/YYYY');
    var days = b.diff(a, 'days');
    //var diff =  Math.floor(( Date.parse(second) - Date.parse(first) ) / 86400000); 
    //var difffs = datediff(parseDate(first), parseDate(second));
  
    $('#imp_days'+id_val).val(days+1);
  }
  
   function from_date_fn() 
  {
	  var count = $('#impcount').val();
	 // alert(count);
	 
	 var id_val = $(this).attr('idss');
	 var c=count-id_val;
	//alert(c);
	  for(var i=1;i<=c;i++)
	  {
	 // alert(id_val);
    var first      = $('#from_date'+id_val).val();
    var second     = $('#to_date'+id_val).val();
	//alert(second);
	var d =new Date(second.split("-").reverse().join("-"));
  
  var dd =d.getDate();
  var mm =d.getMonth()+1;
  var yy =d.getFullYear();
  var newdate=yy+"/"+mm+"/"+dd;
  
   var d1 = new Date(newdate); 
    var m1 = moment(d1); 
    m1.add('days', 1); 
    d2 = m1.toDate();
  var vv = moment(d2).format('DD-MM-YYYY');
	id_val++;
	
	 $('#from_date'+id_val).val(vv);
	 
   
	
	//alert(id_val1);
	
	
	var d=new Date(vv.split("-").reverse().join("-"));
	var dd =d.getDate();
	var mm=d.getMonth()+1;
	var yy=d.getFullYear();
	var newdate=yy+"/"+mm+"/"+dd;
	var d1=new Date(newdate);
	var m1=moment(d1);
	m1.add('days',4);
	d2=m1.toDate();
	var vv2=moment(d2).format('DD-MM-YYYY');
	$('#to_date'+id_val).val(vv2);
	 var a = moment(vv, 'DD/MM/YYYY');
    var b = moment(vv2, 'DD/MM/YYYY');
    var days = b.diff(a, 'days');
	//alert(days);
	 $('#imp_days'+id_val).val(days+1);
	
	
	  }
	//from_date_fn();
	
  }
  
  
  
  
  
   $('input[type=radio][name=tax_type0]').change(function() 
  {
    var ihc = $("input:radio[name=ihc]:checked").val();
    var this_val = this.value;
    $('#tax_amnt').val(0);
    
    if(ihc == '1') // ihc
    {
		
		
		
      if(this_val == '0') // sgst
      {
        $('#sgst').val(6);
        
        $('#cgst').val(6);
        
        $('#igst').val(0);
        $('#igst_amt').val(0);
      }
      else
      {
        $('#sgst').val(0);
        $('#sgst_amt').val(0);
        $('#cgst').val(0);
        $('#cgst_amt').val(0);
        
        $('#igst').val(12);
        
      }
    }
    else   // tax
    {
      if(this_val == '0') // sgst
      {
        $('#sgst').val(9);
        
        $('#cgst').val(9);
        
        $('#igst').val(0);
        $('#igst_amt').val(0);
      }
      else
      {
        $('#sgst').val(0);
        $('#sgst_amt').val(0);
        $('#cgst').val(0);
        $('#cgst_amt').val(0);
        
        $('#igst').val(18);
        
      }
    }
    
    
    taxAmount();
    
    
  });
  
   $('input[type=radio][name=tax_type]').change(function() 
  {
    var ihc = $("input:radio[name=ihc]:checked").val();
	 var type = $("input:radio[name=type]:checked").val();
	 //alert(type);
    var this_val = this.value;
    $('#tax_amnt').val(0);
    
    if(ihc == '1') // ihc
    {
		if(type=='0')
		{
			
			$('#pre_ihc').hide();
			$('#pre_ocr').show();
			
			$('#pre_export').show();
			
			
			 $('#ihc_table').show();
      
      if(this_val == '0') // sgst
      {
        
        $('#ihc_sgst').val(2.5);
        
        $('#ihc_cgst').val(2.5);
        
        $('#ihc_igst').val(0);
        $('#ihc_igst_amt').val(0);
      }
      else
      {
        $('#ihc_sgst').val(0);
        $('#ihc_sgst_amt').val(0);
        $('#ihc_cgst').val(0);
        $('#ihc_cgst_amt').val(0);
        
        $('#ihc_igst').val(5);
        
      }
			
		}
		else{
      $('#ihc_table').show();
	  
	  $('#pre_ihc').show();
			$('#pre_ocr').hide();
	  $('#pre_export').hide();
      
      if(this_val == '0') // sgst
      {
        
        $('#ihc_sgst').val(6);
        
        $('#ihc_cgst').val(6);
        
        $('#ihc_igst').val(0);
        $('#ihc_igst_amt').val(0);
      }
      else
      {
        $('#ihc_sgst').val(0);
        $('#ihc_sgst_amt').val(0);
        $('#ihc_cgst').val(0);
        $('#ihc_cgst_amt').val(0);
        
        $('#ihc_igst').val(12);
        
      }
		}
    }
    else   // tax
    {
      $('#ihc_table').hide();
      if(this_val == '0') // sgst
      {
        $('#sgst').val(9);
        
        $('#cgst').val(9);
        
        $('#igst').val(0);
        $('#igst_amt').val(0);
        
        
        $('#ihc_sgst').val(0);
        
        $('#ihc_cgst').val(0);
        
        $('#ihc_igst').val(0);
        $('#ihc_igst_amt').val(0);
      }
      else
      {
        $('#sgst').val(0);
        $('#sgst_amt').val(0);
        $('#cgst').val(0);
        $('#cgst_amt').val(0);
        
        $('#igst').val(18);
        
        
        $('#ihc_sgst').val(0);
        $('#ihc_sgst_amt').val(0);
        $('#ihc_cgst').val(0);
        $('#ihc_cgst_amt').val(0);
        
        $('#ihc_igst').val(10);
        
      }
    }
    
    
    taxAmount();
    taxAmount_ihc();
    
  });
  
  
  
   $('input[type=radio][name=ihc]').change(function() 
  {
    var ihc = this.value; 
    var this_val =  $("input:radio[name=tax_type]:checked").val();
	 var type = $("input:radio[name=type]:checked").val();
    $('#tax_amnt').val(0); 
    
    if(ihc == '1') // ihc
    {
		if(type=='0')
		{
			 $('#ihc_table').show();
      
      if(this_val == '0') // sgst
      {
        
        $('#ihc_sgst').val(2.5);
        
        $('#ihc_cgst').val(2.5);
        
        $('#ihc_igst').val(0);
        $('#ihc_igst_amt').val(0);
      }
      else
      {
        $('#ihc_sgst').val(0);
        $('#ihc_sgst_amt').val(0);
        $('#ihc_cgst').val(0);
        $('#ihc_cgst_amt').val(0);
        
        $('#ihc_igst').val(5);
        
      }
			
		}
		
		else{
		
		
		
		
      $('#ihc_table').show();
      
      if(this_val == '0') // sgst
      {
        
        $('#ihc_sgst').val(0);
        
        $('#ihc_cgst').val(0);
        
        $('#ihc_igst').val(0);
        $('#ihc_igst_amt').val(0);
      }
      else
      {
        $('#ihc_sgst').val(0);
        $('#ihc_sgst_amt').val(0);
        $('#ihc_cgst').val(0);
        $('#ihc_cgst_amt').val(0);
        
        $('#ihc_igst').val(12);
        
      }
		}
    }
    else   // tax
    {
      $('#ihc_table').hide();
      if(this_val == '0') // sgst
      {
		  
		  
		  
        $('#sgst').val(9);
        
        $('#cgst').val(9);
        
        $('#igst').val(0);
        $('#igst_amt').val(0);
        
        
        $('#ihc_sgst').val(0);
        
        $('#ihc_cgst').val(0);
        
        $('#ihc_igst').val(0);
        $('#ihc_igst_amt').val(0);
      }
      else
      {
        $('#sgst').val(0);
        $('#sgst_amt').val(0);
        $('#cgst').val(0);
        $('#cgst_amt').val(0);
		
		
		 //$('#pre_igst').show();
        
        $('#igst').val(18);
        
        
        $('#ihc_sgst').val(0);
        $('#ihc_sgst_amt').val(0);
        $('#ihc_cgst').val(0);
        $('#ihc_cgst_amt').val(0);
        
        $('#ihc_igst').val(10);
        
      }
    }
    
    
    taxAmount();
    taxAmount_ihc();
    
  });
  
   function taxAmount_ihc()
   {
     var tot_before_tax  = parseFloat($('#ihc_amnt').val());
     var tax_per_cgst    = parseFloat($('#ihc_cgst').val());
     var tax_per_sgst    = parseFloat($('#ihc_sgst').val());
     var tax_per_igst    = parseFloat($('#ihc_igst').val());
     var cgst_amount     = parseFloat((tax_per_cgst*tot_before_tax)/100);
     var sgst_amount     = parseFloat((tax_per_sgst*tot_before_tax)/100);
     var igst_amount     = parseFloat((tax_per_igst*tot_before_tax)/100);
     var tot_tax_amount  = parseFloat(((tax_per_cgst+tax_per_sgst+tax_per_igst)*tot_before_tax)/100);

     $('#ihc_tax_amnt').val(tot_tax_amount.toFixed(2));
     $('#ihc_sgst_amt').val(sgst_amount.toFixed(2));
     $('#ihc_cgst_amt').val(cgst_amount.toFixed(2));
     $('#ihc_igst_amt').val(igst_amount.toFixed(2)); // total

   }
  
   $('input[type=radio][name=ihc0]').change(function() 
  {
    var  this_val= $("input:radio[name=tax_type]:checked").val();
    var ihc = this.value;
    $('#tax_amnt').val(0);
    
    if(ihc == '1') // ihc
    {
      if(this_val == '0') // sgst
      {
        $('#sgst').val(6);
        
        $('#cgst').val(6);
        
        $('#igst').val(0);
        $('#igst_amt').val(0);
      }
      else
      {
        $('#sgst').val(0);
        $('#sgst_amt').val(0);
        $('#cgst').val(0);
        $('#cgst_amt').val(0);
        
        $('#igst').val(12);
        
      }
    }
    else   // tax
    {
      if(this_val == '0') // sgst
      {
        $('#sgst').val(9);
        
        $('#cgst').val(9);
        
        $('#igst').val(0);
        $('#igst_amt').val(0);
      }
      else
      {
        $('#sgst').val(0);
        $('#sgst_amt').val(0);
        $('#cgst').val(0);
        $('#cgst_amt').val(0);
        
        $('#igst').val(18);
        
      }
    }
    
    
    taxAmount();
    
    
  });
  
  
  
  
  
  
  
  
  
 
 
  function get_tot_amount()
  {
     var count = $('#impcount').val();
  
    tot_amount=0;
    //tot_returnamount=0;
      for(i=1;i<=count;i++)
      {
      amount           = $('#imp_total'+i).val();
      //returnrate       = $('#returnrate'+i).val();
      tot_amount       = parseFloat(tot_amount)+parseFloat(amount);
      //tot_returnamount = parseFloat(tot_returnamount)+parseFloat(returnrate);
     
    }
    //alert(tot_amount);
    $('#tot_amounts').val(tot_amount);  
    //$('#tot_return_rate').val(tot_returnamount);  
    
    totbeftax();
  }
  function calculatedaydiff()
  {
   
      var id     = $(this).attr('idss');
    var fdate  = $("#from_date"+id).val();
    var tdate  = $("#to_date"+id).val();
  

    var d1 = new Date(fdate);
    var d2 = new Date(tdate);
    
    var yr1 = d1.getFullYear();
    var yr2 = d2.getFullYear();
    
    var mn1 = d1.getMonth();
    var mn2 = d2.getMonth();
    
    var dy1 = d1.getDay();
    var dy2 = d2.getDay();
    
    
    var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds
            // Convert both dates to milliseconds
            var date1_ms = fdate.getTime();
            var date2_ms = tdate.getTime();
            // Calculate the difference in milliseconds
            var difference_ms = Math.abs(date1_ms - date2_ms);

            // Convert back to days and return
          var diffDays = Math.round(difference_ms/oneDay);
    
    
    
    var firstDate = new Date(yr1,mn1,dy1);
    var secondDate = new Date(yr2,mn2,dy2);

    var diffDays = Math.round(Math.abs((firstDate.getTime() - secondDate.getTime())/(oneDay)));
    alert(diffDays);
   
  }
  
  
  function totbeftax(){
    var ggtotal = 0;
    var totAmtbeftax = 0;
    $(".amountClass").each(function(){
            
       if($(this).val()){  
            totAmtbeftax += parseFloat($(this).val());  
        }                          
    }); 
  var tot_amounts  = parseFloat($('#tot_amounts').val());
  if(tot_amounts=='' && tot_amounts==null)
  {
    tot_amounts = 0;
  }
  ggtotal = totAmtbeftax+tot_amounts;
    $('#tot_before_tax').val(ggtotal.toFixed(2));
    taxAmount();
    totaftertax();

   }

   function taxAmount()
   {
     var tot_before_tax  = parseFloat($('#tot_before_tax').val());
     var tax_per_cgst    = parseFloat($('#cgst').val());
     var tax_per_sgst    = parseFloat($('#sgst').val());
     var tax_per_igst    = parseFloat($('#igst').val());
     var cgst_amount     = parseFloat((tax_per_cgst*tot_before_tax)/100);
     var sgst_amount     = parseFloat((tax_per_sgst*tot_before_tax)/100);
     var igst_amount     = parseFloat((tax_per_igst*tot_before_tax)/100);
     var tot_tax_amount  = parseFloat(((tax_per_cgst+tax_per_sgst+tax_per_igst)*tot_before_tax)/100);

     $('#tax_amnt').val(tot_tax_amount.toFixed(2));
     $('#sgst_amt').val(sgst_amount.toFixed(2));
     $('#cgst_amt').val(cgst_amount.toFixed(2));
     $('#igst_amt').val(igst_amount.toFixed(2)); // total

   }

   function totaftertax(){
     var totBefTax  = parseFloat($('#tot_before_tax').val());
     var totTax     = parseFloat($('#tax_amnt').val());
    // var ihc_tax_amnt     = parseFloat($('#ihc_tax_amnt').val());
     var ihc_tax_amnt     = 0;
    // alert(ihc_tax_amnt);
     var grandTotal = parseFloat(totBefTax+totTax+ihc_tax_amnt);
     $('#total').val(grandTotal.toFixed(2));
   }

  $(document).on('keyup','#sgst', function() 
  { 
        var sgst_per = parseFloat($('#sgst').val());
        $('#cgst').val(sgst_per);
        $('#igst').val(0);
        taxAmount();
        totaftertax();
        if($('#sgst').val()>0){            
            $('#igst').attr('readonly', 'true');
        }else{           
            $('#igst').removeAttr("readonly");
        }
   }); 

   
   
    $(document).on('keyup','#cgst', function() { 
        var cgst_per = parseFloat($('#cgst').val());
        $('#sgst').val(cgst_per);
        $('#igst').val(0);
        taxAmount();
        totaftertax();
        if(cgst_per>0){
            $('#igst').attr('readonly', 'true');
        }else{
            $('#igst').removeAttr("readonly"); 
        }
   }); 

  $(document).on('keyup','#igst', function() { 
        taxAmount();
        totaftertax();    
 });

 $(document).on('click','.del_goods_field', function() {  
        var rowCount =  $("#gcount").val();    
        var id       = $(this).attr('data-rowId');       
        if(rowCount > 1)
        {
          $(".new_row"+id).remove();
        }
        var count = rowCount-1;
        $("#gcount").val(count);
        totbeftax();
        taxAmount();
        totaftertax();
 });
 
 
 
 $(document).on('click','.del_imp_field', function() {
  
   
   var rowCount =  $("#impcount").val();    
        var id       = $(this).attr('data-rowId');       
        if(rowCount > 1)
        {
          $(".new_rows"+id).remove();
        }
        var count = rowCount-1;
        $("#impcount").val(count);
        totbeftax();
        taxAmount();
        totaftertax();
   
 });
 
    
  $('input[type=radio][name=type]').change(function() 
  {
  
    if (this.value == '0')  // export
    {
      $('#import_div').hide();
      $('#imp_total').hide();
      $('#import_main_div').hide();
	  $('#import_pre_div').hide();
	    $('#pre_export').show();
	 
	   $('#pre_ihc').hide();
	  $('#pre_ocr').show();
	 
      $('#export_div').show();
        $('#goods_div').show();

      document.getElementById("ihclabel").innerHTML="OCEAN FR.";
      document.getElementById("amtlabel").innerHTML="USD";
      document.getElementById("ihcamtlabel").innerHTML="RS";
    }
    else if (this.value == '1')  // 1 import
    {
		 $('#pre_export').hide();
		
		 $('#pre_ihc').show();
	  $('#pre_ocr').hide();
		
		
      $('#import_div').show();
      
       $('#import_pre_div').show();
      $('#imp_total').show();
      $('#import_main_div').show();
      $('#export_div').hide();
        $('#goods_div').show();

        document.getElementById("ihclabel").innerHTML="IHC";
        document.getElementById("amtlabel").innerHTML="IHC RT";
        document.getElementById("ihcamtlabel").innerHTML="IHC AMT";   
    }
  });
  
 
 

  function consignor_select()
    {
        $("#bill_cnsgnr_id").select2({
            ajax: { 
                dataType: 'json', 
                url: '<?php echo base_url();?>Generate_bill/get_consignor',
                cache: true,
                data: function (params) 
                    {
                        return {
                            q: params.term
                        }
                    }
            }
        });
    }
  
    function shipper_select()
    {
        $("#exp_shipper_id").select2({
            ajax: { 
                dataType: 'json', 
                url: '<?php echo base_url();?>Generate_bill/get_consignor',
                cache: true,
                data: function (params) 
                    {
                        return {
                            q: params.term
                        }
                    }
            }
        });
    }
    function consignee_select()
    {
        $("#bill_cnsgne_id").select2({
            ajax: { 
                dataType: 'json', 
                url: '<?php echo base_url();?>Generate_bill/get_consignee',
                cache: true,
                data: function (params) 
                    {
                        return {                                                                                                                               
                            q: params.term
                        }
                    }
            }
        });
    }

        function customer_select()
    {
        $("#bill_cust_id").select2({
            ajax: { 
                dataType: 'json', 
                url: '<?php echo base_url();?>Invoice/get_customer',
                cache: true,
                data: function (params) 
                    {
                        return {
                            q: params.term
                        }
                    }
            }
        });
    }
  function notify_select()
      {
          $("#bill_notify_id").select2({
              ajax: { 
                  dataType: 'json', 
                  url: '<?php echo base_url();?>Generate_bill/get_notify',
                  cache: true,
                  data: function (params) 
                      {
                          return {
                              q: params.term
                          }
                      }
              }
          });
      }
  function portname_select()
        {
            $("#bill_port_id").select2({
                ajax: { 
                    dataType: 'json', 
                    url: '<?php echo base_url();?>Generate_bill/get_portname',
                    cache: true,
                    data: function (params) 
                        {
                            return {
                                q: params.term
                            }
                        }
                }
            });
        }
    

        $('#bill_brnch_id').on('change', function() 
        {
        var id = $("#bill_brnch_id").val();
        if (id !== "") 
        {
        $.ajax({
        url:'<?php echo base_url();?>Generate_bill/get_branch_bill_no',
        method:'post',
        data:{id:id},
        dataType:'json',
        success:function(data)
        {   
        $("#branch_bill_no").val(data.branch_bill_no);
        }
        });
        }
        else
        {
        $("#branch_bill_no").val('');
        }
        });
  
</script>
