<?php
$AvlAmount = 0;
$ReqType =''; 
$CompanyAddress = '';
if(!empty($CompanyDetails))
{
    foreach ($CompanyDetails as $Req)
    {
        $CompanyAddress = $Req->Address;
    }
}

$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));                
$CurrentDate =  $dt->format('Y-m-d');

$MaxPoDate = '';
if(!empty($MaxPODate))
{
    foreach ($MaxPODate as $date)
    {
        $MaxPoDate = $date->PODate;     
    }
}

if(!empty($AvlBudAmt))
{
   
        $AvlAmount = $AvlBudAmt;        
    
}
?>

<style>
            .modal
{
    padding-right:25% ! important;
}
.dataTables_paginate
{
        margin-top: -5%;
}
.dataTables_wrapper {
    padding-bottom: 0px;
}
</style>

<script src="<?php echo base_url(); ?>assets/js/CreatePOValidation.js" type="text/javascript">
    
</script>


<script>
 $(document).ready(function(){

        //Initialize Select2 Elements for currency type
        $("#currencytype").select2();
		
     var POMaxDate = '<?php echo $MaxPoDate;?>';
  var d = new Date(POMaxDate);
         $("#PODate").datepicker({
            minDate : d,
            maxDate : 'now',
            dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true,yearRange: '-100:+0'
        });
        $("#Deliverydt").datepicker({
            minDate : 'now',
            dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true,yearRange: '0:+10'
        });

    });

</script>

<div class="content-wrapper">
         <?php
                      $attributes = array('class' => 'form-label-left ImportPO ','name'  => 'ImportPO','id'  => 'ImportPO');
                        
                        echo form_open($this->config->base_url().'/purchaseorder/addPO/',$attributes); ?>
 
 
     <section class="content">
      
     <div style="border:2px solid #333">
        
			 
			 <center><b><h2>Siddharth Industries - Import Purchase Order</h2></b></center><br/>
			 
			 
		 
         <div class="container-fluid">
        <div class="row">
    <div class="col-md-12">
    <div class="col-md-3">
        <div class="col-md-12">

           <label>Requistion No</label>
             <?php
                 
                      $options = array("0"=>'Selected Requisition Numbers'); 
                         if(!empty($ReqList))
                {
                foreach ($ReqList as $SID):
                  
              // print_r($SID->ReqNo);
                   $options[$SID->ReqNo] = $SID->ReqNo ."-". $SID->ReqBy;
                   $ReqType = $SID->ReqType;
                endforeach;
                }   
                    echo form_multiselect('RequistionNo', $options,set_value('RequistionNo'),'id="RequistionNo"' , 'required="true"');

            ?>  
     </div>
    <div class="col-md-12">
    <label>Currency Type</label>

          <?php
              $options = array("0"=>'Select Currency Type');
               //print_r($Currency);
              if(!empty($Currency))
                        {  //print_r($Currency);
                        foreach ($Currency as $CUR):
                          
                          
                          $options[$CUR->CurrencyCode] =  $CUR->CurrencyCode.' '.' - '.' '.$CUR->CurrencyName;

                        endforeach;
                        } 

              echo form_dropdown('currencytype', $options,set_value('currencytype'),'id="currencytype"'  ,'required="true"' ,'class="form-control select2');
          ?>
                
        </div>   
        <div class="col-md-12">
            <a href="http://www.xe.com/" target="_blank"><u>Click here to check Today's Foreign Exchange value</u></a>        
        </div>                                           
                         
    </div>
    <div class="col-md-9">
        <div class="col-md-4">
            <div class="col-md-12">
                <label>Supplier</label>
                     
                         <?php
                        $options = array("0"=>'Select Supplier');     
                        //print_r(  $options);
                        if(!empty($Suplist))
                        {
                        foreach ($Suplist as $SID):
                          
                       
                          $options[$SID->SupplierID] =  $SID->SupplierID.' '.' - '.' '.$SID->SupplierName;

                        endforeach;
                        }                                       
            
                        echo form_dropdown('drpSupplier', $options,set_value('drpSupplier'),'id="drpSupplier"'  ,'required="true"' ,'class="form-control select2');

                        ?>                       
                     
            </div>
            <div class="col-md-12"><br/>
                <label>Address</label>
                    <div class="form-group">
                                <?php
                         $data = array('name' => 'SupAddress','value' => set_value('SupAddress'),'id'=>'SupAddress',  'class' => 'form-control' ,'readonly' => 'true','rows' => '3', 'cols' => '40');
                        echo Form_textarea($data);
                        ?>   
                    </div>
            </div>
            <div class="col-md-12">
                <label>Exchange Rate </label>
                <div class="form-group">
                    <?php
                    $data = array('name' => 'ExchangeRate','value' => set_value('ExchangeRate'),'id'=>'ExchangeRate',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'USRate()');
                    echo form_input($data);
                    ?>
                </div>                
            </div>
        </div>
        <div class="col-md-4">
            <div class="col-md-12">
                 <label>Purchase Order Type</label>
                        <div class="form-group">
                        
                                    <?php
                             $data = array('name' => 'POType','value' => set_value('POType',IMPORT),'id'=>'POType',  'class' => 'form-control' ,'readonly' => 'true');
                            echo form_input($data);
                            ?>   
                        </div>
            </div>
            <div class="col-md-12">
                 <label>Delivery Address</label>
                    <div class="form-group">
                                <?php
                         $data = array('name' => 'DeliveryAddr','value' => set_value('DeliveryAddr',$CompanyAddress),'id'=>'DeliveryAddr',  'class' => 'form-control' ,'required' => 'true', 'rows' => '3', 'cols' => '40');
                        echo Form_textarea($data);
                        ?>   
                    </div>
            </div>
			 <div class="col-md-12">
                <label>Purchase Order Date</label>
                        <div class="form-group">
                                    <?php
                             $data = array('name' => 'PODate','value' => set_value('PODate',$CurrentDate),'id'=>'PODate',  'class' => 'form-control' ,'required' => 'true', 'onkeypress'=>'return false;');
                            echo form_input($data);
                            ?>   
                        </div>
            </div>
           <!-- <div class="col-md-12">
                Basic value in INR :
                <div class="form-group">
                    <?php
                    $data = array('name' => 'INRBasicvalues','value' => set_value('INRBasicvalues'),'id'=>'INRBasicvalues',  'class' => 'form-control' ,'readonly' => 'true');
                    echo form_input($data);
                    ?>
                </div>
            </div>-->
        </div>
        <div class="col-md-4">
		<div class="col-md-12">

                            <b><u>Select Delivery By</u></b><br/>
                            <tr>
                                <td>
                                    <?php echo form_label('Date', 'Date') ."&nbsp;&nbsp;". form_radio(array("name"=>"DateRange", "id"=>"Date", "value"=>"0", 'checked'=>set_radio('DateRange', '0', TRUE))); ?>&nbsp;&nbsp;&nbsp;&nbsp;</td>
                                <td>
                                    <?php echo form_label('Schedule', 'Schedule') ."&nbsp;&nbsp;". form_radio(array("name"=>"DateRange", "id"=>"Schedule", "value"=>"1", 'checked'=>set_radio('DateRange', '1', FALSE))); ?>

                                </td>
                            </tr>
                        </div>
            
				<div class="col-md-12" id="Schedulediv" style="display:none;"><br/>
						<label >Schedule :</label>
						 
						<?php
						$data = array('name' => 'Scheduleby','value' => set_value('Scheduleby'),'id'=>'Scheduleby',  'class' => 'form-control' ,'required' => 'true' ,'rows' => '3', 'cols' => '40');
						echo Form_textarea($data);
						?>

				</div>
				<div class="col-md-12" id="Deliverydtdiv">
                            <label>Delivery Date</label>
                             
                                <?php
                                $data = array('name' => 'Deliverydt','value' => set_value('Deliverydt'),'id'=>'Deliverydt',  'class' => 'form-control'  ,'required' => 'true');
                                echo form_input($data);
                                ?>
                             
                </div>

                         
        </div>
        
    </div>
    </div>     
    </div>
        
     
          <div class="">  
     <table class="table table-bordered" style="border:1px solid #333">
  <div align="right" style="padding-right:10px">
<div align="right">
<a data-toggle="modal" data-target="#importpomodel"  class="btn btn-primary" data-dismiss="modal" onclick="myFunction();" >Add Line Item </a>
  

   

  <!--<a data-toggle="modal"><button type="submit"  onclick="myFunction();" class="btn btn-primary" id="abcd" >Select Line Item</button> </a>-->

  
    <!-- <div class="modal fade" id="importpomodel" role="dialog">-->

     <div  id="importpomodel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <!-- Modal content-->
                                <form>
                                    <div class="modal-content" style="width:900px;">
                                        <div class="modal-header" style="background-color: #3c8dbc;color:#fff;">
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                            <center><h4>Add Import Purchase Order Item </h4></center>
                                        </div>
                                        <div align="left">

                                            <div class="col-md-12">
                                                <div class="col-md-3">
                                                    <label>Req No</label>
                                                    <div>
                                                        <?php
                                                        $options = array("0"=>'Req No');
                                                        //echo form_dropdown('ImportMaterialCode', $options,set_value('ImportMaterialCode'),'id="ImportMaterialCode"' ,'class="form-control required"');
                                            $RL = array("0"=>'Select Req No');     
                                            if(!empty($RequistionDetails))
                                            {
                                            foreach ($RequistionDetails as $SID):              
                                                $RL[$SID->ReqNo] =  $SID->ReqNo.' '.' - '.' '.$SID->DepartmentName;
                                            endforeach;
                                            }
                            
                                            echo form_dropdown('ReqNo', $RL,set_value('ReqNo'),'id="ReqNo"' ,'class="form-control"');

                                                        ?>
                                                    </div>
                                                </div>

                                                <div class="col-md-3">
                                                    <label>Department Name</label>
                                                    <div class="form-group">
                                                        <?php
                                                        //$data = array('name' => 'ImportDepartmentName','value' => set_value('ImportDepartmentName'),'id'=>'ImportDepartmentName',  'class' => 'form-control' ,'readonly' => 'true');
                                            $data = array('name' => 'deptName','value' => set_value('deptName'),'id'=>'deptName',  'class' => 'form-control','readonly'=>'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-3">
                                                    <label>Cost Center Name</label>
                                                    <div class="form-group">
                                                        <?php
                                                        //$options = array("0"=>'Select Cost Center');

                                                        //echo form_dropdown('CostCenter', $options,set_value('CostCenter'),'id="CostCenter"' ,'class="form-control"');

                                                        $data = array('name' => 'CostCenter','value' => set_value('CostCenter'),'id'=>'CostCenter',  'class' => 'form-control' ,'readonly' => 'true');
                                                echo form_input($data);

                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-3">
                                                    <label>Available Budget Amount</label>
                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'AvlBudAmt','value' => set_value('AvlBudAmt'),'id'=>'AvlBudAmt',  'class' => 'form-control' ,'readonly' => 'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-12">
                                                <div class="col-md-2">
                                                    <label>Item Code</label>
                                                    
                                                        <!--In this item code the value should come from DB , so it getting error , so i am disabling this div , once get the data from DB uncommand this div-->
                                                        <div>
                                                        <?php
                                        
                                                        $options = array("0"=>'Item Code');     
                                        //print_r(  $options);
                                        
                                        echo form_dropdown('MaterialCode', $options,set_value('MaterialCode'),'id="MaterialCode"' ,'class="form-control"');

                                                        ?>
                                                    </div> 

                                                </div>

                                                <div class="col-md-2">
                                                    <label>Item Name</label>
                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'ItemName','value' => set_value('ItemName'),'id'=>'ItemName',  'class' => 'form-control' ,'readonly' => 'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <label>UOM</label>
                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'UOM','value' => set_value('UOM'),'id'=>'UOM',  'class' => 'form-control' ,'readonly' => 'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <label>Quantity</label>
                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'Quantity','value' => set_value('Quantity'),'id'=>'Quantity',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'Ratechange()');
                                                        echo form_input($data);

                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <label>Rate </label>
                                                    <div class="form-group">
                                                        <?php
                                                       $data = array('name' => 'Rate','value' => set_value('Rate'),'id'=>'Rate',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);' ,'onchange'=>'Ratechange()' );
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <label>Basic Amount </label>
                                                    <div class="form-group">
                                                        <?php
                                                        //$data = array('name' => 'imTotalAmount','value' => set_value('imTotalAmount'),'id'=>'imTotalAmount',  'class' => 'form-control'  ,'readonly' => 'true');

                                                    $data = array('name' => 'txtBasicValue','value' => set_value('txtBasicValue'),'id'=>'txtBasicValue',  'class' => 'form-control' ,'readonly' => 'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-12">

                                                <div class="col-md-3">

                                                    Basic Price in US $ per Ton :


                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'imBasicPrice','value' => set_value('imBasicPrice'),'id'=>'imBasicPrice',  'class' => 'form-control' ,'placeholder '=>'basic price','onkeypress'=>'return isNumberKey(event);','onchange'=>'USRate()');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>

                                                <div class="col-md-3">

                                                    Exchange Rate :


                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'ExchangeRt','value' => set_value('ExchangeRt'),'id'=>'ExchangeRt',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>

                                                </div>

                                                <div class="col-md-3">

                                                    Basic value in INR :



                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'INRBasicvalue','value' => set_value('INRBasicvalue'),'id'=>'INRBasicvalue',  'class' => 'form-control' ,'readonly' => 'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                                <!--<div class="col-md-3">
                                             <a href="http://www.xe.com/" target="_blank"><u>Click nere to check Today's Foreign Exchange value</u></a>
                                     </div>-->

                                                <div class="col-md-12"  style="border:1px solid #000;padding:0px;">
                                                    <br/>
                                                    <div class="col-md-6" style="padding:0px;">
                                                        <div class="col-md-12">
                                                            <div class="col-md-4" >
                                                                Basic Price:
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'BasicPriceTax','value' => set_value('BasicPriceTax'),'id'=>'BasicPriceTax',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AfterBasicPriceTax','value' => set_value('AfterBasicPriceTax'),'id'=>'AfterBasicPriceTax',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Landing charge
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'LandingCharge','value' => set_value('LandingCharge'),'id'=>'LandingCharge',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'Calculateloadingcharge()');
                                                                    echo form_input($data);

                                                  
                                                                    
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AfterLandingCharge','value' => set_value('AfterLandingCharge'),'id'=>'AfterLandingCharge',  'class' => 'form-control'  ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                High seas sales charge
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'Highseas ','value' => set_value('Highseas'),'id'=>'Highseas',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'CalculateHighseassalescharge()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AfterHighseas','value' => set_value('AfterHighseas'),'id'=>'AfterHighseas',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Custom duty : (a)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'Customduty','value' => set_value('Customduty'),'id'=>'Customduty',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'CalculateCustomduty()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AfterCustomduty','value' => set_value('AfterCustomduty'),'id'=>'AfterCustomduty',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Excise duty : (b)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'ExcisedutyTax','value' => set_value('ExcisedutyTax'),'id'=>'ExcisedutyTax',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'CalculateExciseDuty()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AfterExcisedutyTax','value' => set_value('AfterExcisedutyTax'),'id'=>'AfterExcisedutyTax',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Excise duty ED_cess : (C)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'ExcisedutyEDcess','value' => set_value('ExcisedutyEDcess'),'id'=>'ExcisedutyEDcess',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'CalculateExciseED1()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AfterExcisedutyEDcess','value' => set_value('AfterExcisedutyEDcess'),'id'=>'AfterExcisedutyEDcess',  'class' => 'form-control','readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Excise duty S & H cess :(d)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'ExcisedutySHcess','value' => set_value('ExcisedutySHcess'),'id'=>'ExcisedutySHcess',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'CalculateexciseSHcess()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AfterExcisedutySHcess','value' => set_value('AfterExcisedutySHcess'),'id'=>'AfterExcisedutySHcess',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Custom ED_cess : (e)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'CustomEDcess','value' => set_value('CustomEDcess'),'id'=>'CustomEDcess',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'CalculateCustomEdcess()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AfterCustomEDcess','value' => set_value('AfterCustomEDcess'),'id'=>'AfterCustomEDcess',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Custom S & H cess : (f)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'CustomSHcess','value' => set_value('CustomSHcess'),'id'=>'CustomSHcess',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'CalculateCustomSHcess()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AfterCustomSHcess','value' => set_value('AfterCustomSHcess'),'id'=>'AfterCustomSHcess',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6" style="padding:0px;">
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Additional Excise duty : (g)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AdditionalExciseduty ','value' => set_value('AdditionalExciseduty'),'id'=>'AdditionalExciseduty',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'CalculateaddlExciseDuty(),CalculateAvlModvat(),CalculateGrossExpense()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AfterAdditionalExciseduty','value' => set_value('AfterAdditionalExciseduty'),'id'=>'AfterAdditionalExciseduty',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-8">
                                                                Gross duty payable
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'Grossdutypayable ','value' => set_value('Grossdutypayable'),'id'=>'Grossdutypayable',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true','onchange'=>'CalculateAvlModvat()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-8">
                                                                Available Modvat set-off on import :
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'AvailableModvat','value' => set_value('AvailableModvat'),'id'=>'AvailableModvat',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>   (b + c + d + g)
                                                                </div>
                                                            </div>

                                                        </div>
                                                        <div class="col-md-12">

                                                            <div class="col-md-8">
                                                                Gross expenses due to custom duty:
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'Grossexpenses','value' => set_value('Grossexpenses'),'id'=>'Grossexpenses',  'class' => 'form-control' ,'readonly'=>'true','onkeypress'=>'return isNumberKey(event);');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="col-md-12">
                                                            <center> <label>Cost of the product Per KG</label></center>
                                                            <hr/>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                purchase rate [Basic]
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'purchaserate','value' => set_value('purchaserate'),'id'=>'purchaserate',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4"  style="margin-top: -4.8%">
                                                                <span>Quantity</span>
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'PurQuantity','value' => set_value('PurQuantity'),'id'=>'PurQuantity',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'CalculateCtable()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>

                                                        </div>
                                                        <div class="col-md-12">

                                                            <div class="col-md-4">
                                                                Custom Duty Expenses
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'CustomDutyExpenses ','value' => set_value('CustomDutyExpenses'),'id'=>'CustomDutyExpenses',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>

                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                RMC Including Customers
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'RMCIncludingCustomers','value' => set_value('RMCIncludingCustomers'),'id'=>'RMCIncludingCustomers',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                         <div class="col-md-4">
                                                                Total Amount:
                                                            </div>
                                                           <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'TotalExp','value' => set_value('TotalExp'),'id'=>'TotalExp',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>

                                                        </div>


                                                    </div>
                                                </div>
                                            </div>

                                        </div>
                                        <div class="modal-footer">
                                            <a class="btn btn-info font AddImport"  ID="AddImport" ><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Add Import</span></a>
                                            <!--<a class="btn btn-primary font AddService"  ID="AddService" ><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Add Service</span></a>-->

                                            <a class="btn btn-info" data-dismiss="modal"  value="Cancel">Cancel</a>

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

                            </div>
                        </div>        
  </div>
</div>
   
   

<!--Edit modal body-->

 <div  id="editimportpomodel" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <!-- Modal content-->
                                <form>
                                    <div class="modal-content" style="width:900px;">
                                        <div class="modal-header" style="background-color: #3c8dbc;color:#fff;">
                                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                                            <center><h4>Edit Import Purchase Order Item </h4></center>
                                        </div>
                                        <div align="left">

                                            <div class="col-md-12">
                                                <div class="col-md-3">
                                                    <label>Req No</label>
                                                    <div>
                                                        <?php
                                            
                                        $data = array('name' => 'EditReqNo','value' => set_value('EditReqNo'),'id'=>'EditReqNo',  'class' => 'form-control','readonly'=>'true');
                                        echo form_input($data);?>
                                                    </div>
                                                </div>

                                                <div class="col-md-3">
                                                    <label>Department Name</label>
                                                    <div class="form-group">
                                                        <?php
                                         $data = array('name' => 'EditdeptName','value' => set_value('EditdeptName'),'id'=>'EditdeptName',  'class' => 'form-control','readonly'=>'true');
                                        echo form_input($data);
                                        ?>   
                                                    </div>
                                                </div>
                                                <div class="col-md-3">
                                                    <label>Cost Center Name</label>
                                                    <div class="form-group">
                                                        <?php
                                                        $options = array("0"=>'Select Cost Center');

                                                        //echo form_dropdown('EditCostCenter', $options,set_value('EditCostCenter'),'id="EditCostCenter"' ,'class="form-control"');

                                                          $data = array('name' => 'EditCostCenter','value' => set_value('EditCostCenter'),'id'=>'EditCostCenter',  'class' => 'form-control' ,'readonly' => 'true');
                                                echo form_input($data);

                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-3">
                                                    <label>Available Budget Amount</label>
                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'EditAvlBudAmt','value' => set_value('EditAvlBudAmt'),'id'=>'EditAvlBudAmt',  'class' => 'form-control' ,'readonly' => 'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-12">
                                                <div class="col-md-2">
                                                    <label>Item Code</label>
                                                    
                                                        <!--In this item code the value should come from DB , so it getting error , so i am disabling this div , once get the data from DB uncommand this div-->
                                                        <div>
                                                        <?php
                                                       // $options = array("0"=>'Item Code');

                                                        //if(!empty($MaterialList))
                                                        //{
                                                          //  foreach ($MaterialList as $SID):


                                                            //    $options[$SID->MaterialCode] =  $SID->MaterialCode.' '.' - '.' '.$SID->MaterialName;

                                                            //endforeach;
                                                        //}

                                                        //echo form_dropdown('ImportMaterialCode', $options,set_value('ImportMaterialCode'),'id="ImportMaterialCode"' ,'class="form-control"');

                                                        $options = array("0"=>'Item Code');     
                                        //print_r(  $options);
                                        
                                                                            
                            
                                        echo form_dropdown('EditMaterialCode', $options,set_value('EditMaterialCode'),'id="EditMaterialCode"' ,'class="form-control"');

                                                        ?>
                                                    </div> 

                                                </div>

                                                <div class="col-md-2">
                                                    <label>Item Name</label>
                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'EditItemName','value' => set_value('EditItemName'),'id'=>'EditItemName',  'class' => 'form-control' ,'readonly' => 'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <label>UOM</label>
                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'EditUOM','value' => set_value('EditUOM'),'id'=>'EditUOM',  'class' => 'form-control' ,'readonly' => 'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <label>Quantity</label>
                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'EditQuantity','value' => set_value('EditQuantity'),'id'=>'EditQuantity',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'Ratechange()');
                                                        echo form_input($data);

                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <label>Rate </label>
                                                    <div class="form-group">
                                                        <?php
                                                       $data = array('name' => 'EditRate','value' => set_value('EditRate'),'id'=>'EditRate',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);' ,'onchange'=>'Ratechange()' );
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                                <div class="col-md-2">
                                                    <label>Basic Amount </label>
                                                    <div class="form-group">
                                                        <?php
                                                        //$data = array('name' => 'imTotalAmount','value' => set_value('imTotalAmount'),'id'=>'imTotalAmount',  'class' => 'form-control'  ,'readonly' => 'true');

                                                    $data = array('name' => 'EdittxtBasicValue','value' => set_value('EdittxtBasicValue'),'id'=>'EdittxtBasicValue',  'class' => 'form-control' ,'readonly' => 'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-md-12">

                                                <div class="col-md-3">

                                                    Basic Price in US $ per Ton :


                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'EditimBasicPrice','value' => set_value('EditimBasicPrice'),'id'=>'EditimBasicPrice',  'class' => 'form-control' ,'placeholder '=>'basic price','onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>

                                                <div class="col-md-3">

                                                    Exchange Rate :


                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'EditExchangeRt','value' => set_value('EditExchangeRt'),'id'=>'EditExchangeRt',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>

                                                </div>

                                                <div class="col-md-3">

                                                    Basic value in INR :



                                                    <div class="form-group">
                                                        <?php
                                                        $data = array('name' => 'EditINRBasicvalue','value' => set_value('EditINRBasicvalue'),'id'=>'EditINRBasicvalue',  'class' => 'form-control' ,'readonly' => 'true');
                                                        echo form_input($data);
                                                        ?>
                                                    </div>
                                                </div>
                                                <!--<div class="col-md-3">
                                             <a href="http://www.xe.com/" target="_blank"><u>Click nere to check Today's Foreign Exchange value</u></a>
                                     </div>-->

                                                <div class="col-md-12"  style="border:1px solid #000;padding:0px;">
                                                    <br/>
                                                    <div class="col-md-6" style="padding:0px;">
                                                        <div class="col-md-12">
                                                            <div class="col-md-4" >
                                                                Basic Price:
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditBasicPriceTax','value' => set_value('EditBasicPriceTax'),'id'=>'EditBasicPriceTax',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAfterBasicPriceTax','value' => set_value('EditAfterBasicPriceTax'),'id'=>'EditAfterBasicPriceTax',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Landing charge
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditLandingCharge','value' => set_value('EditLandingCharge'),'id'=>'EditLandingCharge',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'EditCalculateloadingcharge()');
                                                                    echo form_input($data);

                                                  
                                                                    
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAfterLandingCharge','value' => set_value('EditAfterLandingCharge'),'id'=>'EditAfterLandingCharge',  'class' => 'form-control'  ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                High seas sales charge
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditHighseas ','value' => set_value('EditHighseas'),'id'=>'EditHighseas',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'EditCalculateHighseassalescharge()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAfterHighseas','value' => set_value('EditAfterHighseas'),'id'=>'EditAfterHighseas',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Custom duty : (a)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditCustomduty','value' => set_value('EditCustomduty'),'id'=>'EditCustomduty',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'EditCalculateCustomduty()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAfterCustomduty','value' => set_value('EditAfterCustomduty'),'id'=>'EditAfterCustomduty',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Excise duty : (b)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditExcisedutyTax','value' => set_value('EditExcisedutyTax'),'id'=>'EditExcisedutyTax',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'EditCalculateExciseDuty()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAfterExcisedutyTax','value' => set_value('EditAfterExcisedutyTax'),'id'=>'EditAfterExcisedutyTax',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Excise duty ED_cess : (C)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditExcisedutyEDcess','value' => set_value('EditExcisedutyEDcess'),'id'=>'EditExcisedutyEDcess',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'EditCalculateExciseED1()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAfterExcisedutyEDcess','value' => set_value('EditAfterExcisedutyEDcess'),'id'=>'EditAfterExcisedutyEDcess',  'class' => 'form-control','readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Excise duty S & H cess :(d)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditExcisedutySHcess','value' => set_value('EditExcisedutySHcess'),'id'=>'EditExcisedutySHcess',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'EditCalculateexciseSHcess()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAfterExcisedutySHcess','value' => set_value('EditAfterExcisedutySHcess'),'id'=>'EditAfterExcisedutySHcess',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Custom ED_cess : (e)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditCustomEDcess','value' => set_value('EditCustomEDcess'),'id'=>'EditCustomEDcess',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'EditCalculateCustomEdcess()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAfterCustomEDcess','value' => set_value('EditAfterCustomEDcess'),'id'=>'EditAfterCustomEDcess',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Custom S & H cess : (f)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditCustomSHcess','value' => set_value('EditCustomSHcess'),'id'=>'EditCustomSHcess',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'EditCalculateCustomSHcess()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAfterCustomSHcess','value' => set_value('EditAfterCustomSHcess'),'id'=>'EditAfterCustomSHcess',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="col-md-6" style="padding:0px;">
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                Additional Excise duty : (g)
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAdditionalExciseduty ','value' => set_value('EditAdditionalExciseduty'),'id'=>'EditAdditionalExciseduty',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'EditCalculateaddlExciseDuty(),EditCalculateAvlModvat(),EditCalculateGrossExpense()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAfterAdditionalExciseduty','value' => set_value('EditAfterAdditionalExciseduty'),'id'=>'EditAfterAdditionalExciseduty',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-8">
                                                                Gross duty payable
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditGrossdutypayable ','value' => set_value('EditGrossdutypayable'),'id'=>'EditGrossdutypayable',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-8">
                                                                Available Modvat set-off on import :
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditAvailableModvat','value' => set_value('EditAvailableModvat'),'id'=>'EditAvailableModvat',  'class' => 'form-control' ,'readonly' => 'true');
                                                                    echo form_input($data);
                                                                    ?>   (b + c + d + g)
                                                                </div>
                                                            </div>

                                                        </div>
                                                        <div class="col-md-12">

                                                            <div class="col-md-8">
                                                                Gross expenses due to custom duty:
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditGrossexpenses','value' => set_value('EditGrossexpenses'),'id'=>'EditGrossexpenses',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        </div>

                                                        <div class="col-md-12">
                                                            <center> <label>Cost of the product Per KG</label></center>
                                                            <hr/>
                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                purchase rate [Basic]
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'Editpurchaserate','value' => set_value('Editpurchaserate'),'id'=>'Editpurchaserate',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                            <div class="col-md-4"  style="margin-top: -4.8%">
                                                                <span>Quantity</span>
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditPurQuantity','value' => set_value('EditPurQuantity'),'id'=>'EditPurQuantity',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'EditCalculateCtable()');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>

                                                        </div>
                                                        <div class="col-md-12">

                                                            <div class="col-md-4">
                                                                Custom Duty Expenses
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditCustomDutyExpenses ','value' => set_value('EditCustomDutyExpenses'),'id'=>'EditCustomDutyExpenses',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>

                                                        </div>
                                                        <div class="col-md-12">
                                                            <div class="col-md-4">
                                                                RMC Including Customers
                                                            </div>
                                                            <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditRMCIncludingCustomers','value' => set_value('EditRMCIncludingCustomers'),'id'=>'EditRMCIncludingCustomers',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>
                                                         <div class="col-md-4">
                                                                Total Amount:
                                                            </div>
                                                           <div class="col-md-4">
                                                                <div class="form-group">
                                                                    <?php
                                                                    $data = array('name' => 'EditTotalExp','value' => set_value('EditTotalExp'),'id'=>'EditTotalExp',  'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);','readonly'=>'true');
                                                                    echo form_input($data);
                                                                    ?>
                                                                </div>
                                                            </div>

                                                        </div>


                                                    </div>
                                                </div>
                                            </div>

                                        </div>
                                        <div class="modal-footer">
                                            <a class="btn btn-info font EditImport"  ID="EditImport" ><i class="fa fa-plus" ></i>&nbsp;&nbsp;<span class="bold">Edit Import</span></a>
                                            <!--<a class="btn btn-primary font AddService"  ID="AddService" ><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Add Service</span></a>-->

                                            <a class="btn btn-info" data-dismiss="modal"  value="Cancel">Cancel</a>

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

                            </div>
                        </div>        
  </div>
 





   <br/>
        <div class="box-body" style="margin-top: -3%;">
              <table id="ImportTax" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
                <thead style="background-color:#ddf">
                <tr>
                    <th>SNo</th>
                    <th>Requisition No</th>
                    <th>Item Name</th>
                    <th>Quantity</th>
                    <th>UOM</th>
                    <th>Rate</th>
                    <th>Basic Amount</th>
                    <th>Tax Amount</th>
                    <th>Total Order Amount</th>
                    <th>Action</th>
                </tr>
                </thead>                
               
             <tbody id='ImportAppend'>     
    
            </tbody>
              </table>
            </div>
   
      <div class="col-md-12" style="border: 1px solid;">

       <div class="col-md-12">
            <div class="col-md-4">
              <label >Total Landing Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotallanding','value' => set_value('txttotallanding'),'id'=>'txttotallanding',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>

            <div class="col-md-4">
              <label >Total High seas sales Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalhighseas','value' => set_value('txttotalhighseas'),'id'=>'txttotalhighseas',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>

            <div class="col-md-4">
              <label >Total Custom Duty Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalcustom','value' => set_value('txttotalcustom'),'id'=>'txttotalcustom',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>

            <div class="col-md-4">
              <label >Total Excise duty  Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalexcise','value' => set_value('txttotalexcise'),'id'=>'txttotalexcise',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>

            <div class="col-md-4">
              <label >Total Excise duty ED_cess Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalexciseED','value' => set_value('txttotalexciseED'),'id'=>'txttotalexciseED',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>


            <div class="col-md-4">
              <label >Total Excise duty S & H cess  Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalexciseSH','value' => set_value('txttotalexciseSH'),'id'=>'txttotalexciseSH',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>

            <div class="col-md-4">
              <label >Total Custom ED_cess Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalcustomED','value' => set_value('txttotalcustomED'),'id'=>'txttotalcustomED',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>

            <div class="col-md-4">
              <label >Total Custom S & H cess Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalcustomSH','value' => set_value('txttotalcustomSH'),'id'=>'txttotalcustomSH',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>

            <div class="col-md-4">
              <label >Total Additional Excise duty Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalAdditionalExciseduty','value' => set_value('txttotalAdditionalExciseduty'),'id'=>'txttotalAdditionalExciseduty',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>


            <div class="col-md-4">
              <label >Total Gross duty payable Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalgrossduty','value' => set_value('txttotalgrossduty'),'id'=>'txttotalgrossduty',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>

             <div class="col-md-4">
              <label >Total Available Modvat set-off on import Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalavlmodvat','value' => set_value('txttotalavlmodvat'),'id'=>'txttotalavlmodvat',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>


            <div class="col-md-4">
              <label >Total Gross expenses due to custom duty Charge  :</label> 
                                            
                            <?php
                         $data = array('name' => 'txttotalgrossexpense','value' => set_value('txttotalgrossexpense'),'id'=>'txttotalgrossexpense',  'class' => 'form-control'   ,'readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>                      
            </div>
        

           

                    <div  class="col-md-4">
                            <label>Total Order Value :</label>  <?php
                         $data = array('name' => 'txtToatlOrder','value' => set_value('txtToatlOrder'),'id'=>'txtToatlOrder',  'class' => 'form-control' ,'required' => 'true','readonly' => 'true','style'=>'text-align:right;');
                        echo form_input($data);
                        ?>   
                    </div>
            </div> 
                
                    

                    <div class="col-md-12">
                      <div class="col-md-12">
                            <label>Comments for Special Instructions :</label>  <?php
                         $data = array('name' => 'txtSpcialInstruction','value' => set_value('txtSpcialInstruction'),'id'=>'txtSpcialInstruction',  'class' => 'form-control','rows' => '3', 'cols' => '40' );
                        echo form_textarea($data);
                        ?>   
                      </div>   
                     </div> 
					 <div align="right" style="padding-right:10px">

<div class="col-md-3 col-md-offset-9"><br/>
        <input type="hidden" name="txtPoRange" id="txtPoRange" /> 
        <input type="hidden" name="isEdit" id="isEdit" value="0" /> 
        <input type="hidden" name="txtStatus" id="txtStatus" /> 
        <input type="hidden" name="txtRowCount" id="txtRowCount" />
        <input type="hidden" name="txtDeletedRow" id="txtDeletedRow" />   
        <a class="btn btn-primary Save"  ID="Save" onclick="Save(0)" >&nbsp;&nbsp;<span class="bold">Save</span></a> 
        <a class="btn btn-primary Submit"  ID="Submit" onclick="Save(1)" >&nbsp;&nbsp;<span class="bold">Submit</span></a> 
    <input type="reset" class="btn btn-primary" value="Reset">
  
  </div>
         <br/>
     </div>
            </div> 
 
         </div>
		 </div>
    </section>   
</div>

<script type="text/html" id="ImportList">
<tr  id="<%=index%>">
<td align="left"><%=index%></td>
 <td align="left"><%=ReqNo%></td>
 
  <td align="left"><%=ItemName%></td>
  <td align="left"><%=Quantity%></td> 
  <td align="left"><%=UOM%></td>
   <td align="left"><%=Rate%></td>
    <td align="left"><%=BasicAmount%></td>
    <td align="left"><%=Taxvalue%></td>
    <td align="left"><%=TotalValue%></td>
    
   <td>
                          <a    data-target='#editimportpomodel'  data-id="<%=index%>" data-userid="<%=index%>" data-toggle="modal" href="#editimportpomodel"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the  <%=ReqNo%> Requisition details"></i>&nbsp;&nbsp;&nbsp;</a> <a href='#' onclick = "DeleteRow(<%=index%>)" class="link" data-id="<%=index%>" data-userid="<%=index%>"  id="Del" ><span class="glyphicon glyphicon-trash"></span></a>
                         
                          
                      </td>
</tr>
</script>


<script type="text/javascript">
// for delivey date and scheduled
$(document).ready(function () {
                $('#Date').click(function () {
                    //for Date range selection
                    $('#Schedulediv').hide();
                    $('#Deliverydtdiv').show();
                });
                $('#Schedule').click(function () {
                    //for schedule range selection
                    $('#Deliverydtdiv').hide();
                    $('#Schedulediv').show();
                });
            });
 alert();
var SelectedMaterialCode = [];
var RequistQuantity = '';
var AvilBudAmt = '';
 var CollIndex = 0;
var index='1';
var userid  = '';
var NilType = '<?php echo NILTYPE;?>';
 var PercentageType = '<?php echo PERCENTAGE;?>';
 var IsEdit = '0';
 var SelectedMaterialList = {
    Mat: []
};

$('#drpSupplier').change(function() {
    
 var id = $('#drpSupplier').val();

 $("#SupAddress").val('');
 
        if(id != '0')
        {
            var y = <?php echo json_encode($Suplist, JSON_PRETTY_PRINT) ?>;

                
        $.each(y, function(idx, obj) {
            if(obj.SupplierID === id)
            {
                $("#SupAddress").val(obj.Address);
                
            }
            
        });
            
        }
        else
        {
            alert('Please select the SupplierID');
            return false;
        }
  
}); 



$('#ReqNo').change(function() {
    
 var id = $('#ReqNo').val();
 $("#AvlBudAmt").val('');
 $("#CostCenter").empty();
  $("#MaterialCode").empty();
  $("#deptName").val('');
 $("#UOM").val('');
$("#Quantity").val('');
$("#ItemName").val('');
$("#Rate").val('');
$("#txtBasicValue").val('');
 //clearTaxField();
        if(id != '0')
        {
            var y = <?php echo json_encode($RequistionDetails, JSON_PRETTY_PRINT) ?>;
          
            var Material = <?php echo json_encode($MaterialList, JSON_PRETTY_PRINT) ?>;
            var AvlBudAmt = '<?php echo $AvlAmount ?>'; 
            //alert(Material);
            
        // For Binding DepartmentName                       
        $.each(y, function(idx, obj) {
            if(obj.ReqNo === id)
            {
                $("#deptName").val(obj.DepartmentName);
                $("#CostCenter").val(obj.CostCenterCode);
                
            }           
        });
        $("#AvlBudAmt").val(AvlBudAmt); 
            // For Binding Cost center for the selected department  
       /* $("#CostCenter").append( $('<option></option>').val("0").html("Select Cost Center") );
        $.each(cost, function(idx, obj) {
            if(obj.ReqNo === id)
            {
                $("#CostCenter").append( $('<option></option>').val(obj.CostCenterCode).html(obj.CostCenterCode + "-" + obj.CostCenterName) );
                
            }
            
        });*/
        // For Binding Material list center for the selected Requistion Number  
        $("#MaterialCode").append( $('<option></option>').val("0").html("Select Material Code") );
        var isAdded = "0";
         for(i=0;i<Material.length;i++)
        {
        $.each(Material[i], function(idx, obj) {
            
                if(obj.ReqNo === id )
                {
                                    
                        $.each(SelectedMaterialList.Mat, function(idx1, el){                                                            
                            if (id == el.ReqNo )
                            {
                                                            
                                if(el.materialCode == obj.MaterialCode)
                                {
                                        isAdded  = "1";
                                        return false;                                                                        
                                }
                                else
                                {
                                    isAdded  = "0";
                                }
                                
                            }
                    });
                    
                    
                        if(isAdded  == "0")
                        {
                            
                            $("#MaterialCode").append( $('<option></option>').val(obj.MaterialCode).html(obj.MaterialCode + "-" + obj.MaterialName));
                        }
                                                
                }
            
            
        });
        }
        }
        else
        {
            alert('Please select the Requisition Number');
            return false;
        }
        id = '';
  
});



$('#MaterialCode').change(function() {
    
 var id = $('#MaterialCode').val();
  $("#ItemName").val('');
$("#UOM").val('');
$("#Quantity").val('');
$("#ItemName").val('');
$("#Rate").val('');
$("#txtBasicValue").val('');
 RequistQuantity = '';
 //clearTaxField();
        if(id != '0')
        {
            var Material = <?php echo json_encode($MaterialList, JSON_PRETTY_PRINT) ?>;
            
     for(i=0;i<Material.length;i++)
        {
        $.each(Material[i], function(idx, obj) {
            if(obj.MaterialCode === id)
            {
                $("#ItemName").val(obj.MaterialName);
                $("#UOM").val(obj.UOM);
                $("#Quantity").val(obj.Quantity);
                RequistQuantity =   obj.Quantity;       
            }           
        });         
        }
        }
        else
        {
            alert('Please select the MaterialCode');
            return false;
        }
  
});

function USRate()
{ 

    if($('#imBasicPrice').val() != '' && $('#ExchangeRate').val() != '')
    {
       var txtbasics=parseFloat($('#imBasicPrice').val());
       var txtexchangerate=parseFloat($('#ExchangeRate').val());
       $('#ExchangeRt').val(txtexchangerate);
       var txtINRvalue=txtbasics*txtexchangerate;
       $('#INRBasicvalues').val(txtINRvalue)
       $('#INRBasicvalue').val(txtINRvalue);
       $('#BasicPriceTax').val(txtINRvalue);
       //txtINR = Math.ceil(txtINR*10)/10;
       txtINR = Math.round(txtINRvalue);
       //alert(txtINR);BasicPriceTax
       
      $('#AfterBasicPriceTax').val(txtINR);
      $('#imBasicPrice').val(txtbasics);
      $('#ExchangeRt').val(txtexchangerate);
      $('#EditAfterBasicPriceTax').val(txtINR);
      $('#EditimBasicPrice').val(txtbasics);
      $('#EditExchangeRt').val(txtexchangerate);
      $('#EditINRBasicvalue').val(txtINRvalue);

     
    }
}



function Ratechange(){
    //alert();
    if($('#ReqNo').val() == "0")
         {
             alert('Please select the Requisition Number');
             $('#ReqNo').focus();
             return false;
         }
         else if($('#MaterialCode').val() == "0")
         {
            alert('Please select the Material Code');
            $('#MaterialCode').focus();
           return false;
         }
         else if($('#CostCenter').val() == "0")
         {
                alert('Please select the CostCenterCode');
                $('#CostCenter').focus();
            return false;
         }

          //ExceedQuantityCheck();

           if($('#Quantity').val() != '' && $('#Rate').val() != '')
     {    
      var txtQuantity = parseFloat( $('#Quantity').val());
      var txtUnitPrice = parseFloat($('#Rate').val());
      var Tot =  txtQuantity * txtUnitPrice
      $('#txtBasicValue').val(Tot);
     }
}


function Calculateloadingcharge()
 {
    //alert();
$('#AfterHighseas').val('');
$('#AfterCustomduty').val('');
$('#AfterExcisedutyTax').val('');
$('#AfterExcisedutyEDcess').val('');
$('#AfterExcisedutySHcess').val('');
$('#AfterCustomEDcess').val('');
$('#AfterCustomSHcess').val('');
$('#AfterAdditionalExciseduty').val('');
$('#Grossdutypayable').val('');
$('#AvailableModvat').val('');
$('#Grossexpenses').val('');
$('#purchaserate').val('');
$('#CustomDutyExpenses').val('');
$('#RMCIncludingCustomers').val('');
$('#TotalExp').val('');

    var txtlanding=0;
    var txtbasicprice=0;
    txtlanding=parseFloat($('#LandingCharge').val());
    txtbasicprice=parseFloat($('#AfterBasicPriceTax').val());
    
    //var result=(txtlanding*txtbasicprice/100);
    var result= <?php echo LOADING_CHARGE;?>;

    $('#AfterLandingCharge').val(parseFloat(Math.round(result)));
    CalculateHighseassalescharge();

    //alert();
 }


 function EditCalculateloadingcharge()
 {
    //alert();
    var txtlanding=0;
    var txtbasicprice=0;

    
    txtlanding=parseFloat($('#EditLandingCharge').val());
    txtbasicprice=parseFloat($('#EditAfterBasicPriceTax').val());
    //var result=(txtlanding*txtbasicprice/100);
    var result= <?php echo LOADING_CHARGE;?>;
    $('#EditAfterLandingCharge').val(parseFloat(Math.round(result)));
    EditCalculateHighseassalescharge();
    //alert();
 }


 function CalculateHighseassalescharge()
 {
     
    //alert();
    var txtbasicprice=0;
    var txtlandingcharge=0;
    var totalhighsess=0;
    var highsesspercentage=0;
    txtbasicprice=parseFloat($('#AfterBasicPriceTax').val());  
    txtlandingcharge=parseFloat($('#AfterLandingCharge').val());
   // alert(txtlandingcharge);
    totalhighsess=txtbasicprice+txtlandingcharge;
    highsesspercentage=parseFloat($('#Highseas').val());
    
     
    //var txthighsess=(totalhighsess*highsesspercentage)/100;
    var txtAfterhighsess=<?php echo HIGHSEAS_SALES;?>;
    if(isNaN(txtAfterhighsess))
    {
        $('#AfterHighseas').val('');
    }
    else{
    $('#AfterHighseas').val(parseFloat(Math.round(txtAfterhighsess)));
     }
    
    CalculateCustomduty();
 }

function EditCalculateHighseassalescharge()
 {

    //alert();
    var txtbasicprice=0;
    var txtlandingcharge=0;
    var totalhighsess=0;
    var highsesspercentage=0;
    var txthighsess=0;
    txtbasicprice=parseFloat($('#EditAfterBasicPriceTax').val());  
    txtlandingcharge=parseFloat($('#EditAfterLandingCharge').val());
    totalhighsess=txtbasicprice+txtlandingcharge;
    highsesspercentage=parseFloat($('#EditHighseas').val());
    //var txthighsess=(totalhighsess*highsesspercentage)/100;
    txthighsess=<?php echo HIGHSEAS_SALES;?>;
    if(isNaN(txthighsess))
    {
        $('#EditAfterHighseas').val('');
    }
    else{
    $('#EditAfterHighseas').val(parseFloat(Math.round(txthighsess)));
    }
    EditCalculateCustomduty();
 }

 function CalculateCustomduty()
{
    var txtbasic=0;
    var txtcustompercentage=0;
    var txthighse=0;
    var txtlandingch=0;
    var sumcustom=0;
    var txtcustomduty=0;
   txtbasic=parseFloat($('#AfterBasicPriceTax').val());
   txtcustompercentage=parseFloat($('#Customduty').val());
   txthighse=parseFloat($('#AfterHighseas').val());
   txtlandingch=parseFloat($('#AfterLandingCharge').val());
   sumcustom=txthighse+txtlandingch+txtbasic;
   //var txtcustomduty=(txtbasic*txtcustompercentage)/100;
   txtcustomduty=<?php echo CUSTOM_DUTY;?>;
   if(isNaN(txtcustomduty))
   {
     $('#AfterCustomduty').val('');
   }
   else{
   $('#AfterCustomduty').val(parseFloat(Math.round(txtcustomduty)));
   }
   CalculateExciseDuty() ;

}

function EditCalculateCustomduty()
{
    var txtbasic=0;
    var txtcustompercentage=0;
    var txthighse=0;
    var txtlandingch=0;
    var sumcustom=0;
    var txtcustomduty=0;
   txtbasic=parseFloat($('#EditAfterBasicPriceTax').val());
   txtcustompercentage=parseFloat($('#EditCustomduty').val());
   txthighse=parseFloat($('#EditAfterHighseas').val());
   txtlandingch=parseFloat($('#EditAfterLandingCharge').val());
   sumcustom=txthighse+txtlandingch+txtbasic;
   //var txtcustomduty=(txtbasic*txtcustompercentage)/100;
   txtcustomduty=<?php echo CUSTOM_DUTY;?>;
   if(isNaN(txtcustomduty))
   {
    $('#EditAfterCustomduty').val('');
   }
   else{
   $('#EditAfterCustomduty').val(parseFloat(Math.round(txtcustomduty)));
   }
   EditCalculateExciseDuty() ;

}


function CalculateExciseDuty()  
{

    var txtcustomduty=0;
    var txthighsess=0;
    var txtaftrlanding=0;
    var txtbasicc=0;
    var txtpercentage=0;
    var txtexcisesum=0;
    var totalexcise=0;
    txtcustomduty=parseFloat($('#AfterCustomduty').val());
    txthighsess=parseFloat($('#AfterHighseas').val());
    txtaftrlanding=parseFloat($('#AfterLandingCharge').val());
    txtbasicc=parseFloat($('#AfterBasicPriceTax').val());

    txtpercentage=parseFloat($('#ExcisedutyTax').val());
    txtexcisesum=txtcustomduty+txthighsess+txtaftrlanding+txtbasicc;
    //var Exciseduty=(txtexcisesum*txtpercentage)/100;
    totalexcise=<?php echo EXCISE_DUTY;?>;
    if(isNaN(totalexcise))
    {
        $('#AfterExcisedutyTax').val('');
    }
    //var totalexcise=txtcustomduty+Exciseduty;
    else{
    $('#AfterExcisedutyTax').val(parseFloat(Math.round(totalexcise)));
      }
    CalculateExciseED1();
}



function EditCalculateExciseDuty()  
{  //alert('edit');
     var txtcustomduty=0;
     var txthighsess=0;
     var txtaftrlanding=0;
     var txtbasicc=0;
     var txtpercentage=0;
     var txtexcisesum=0;
     var totalexcise=0;     
    txtcustomduty=parseFloat($('#EditAfterCustomduty').val());
    txthighsess=parseFloat($('#EditAfterHighseas').val());
    txtaftrlanding=parseFloat($('#EditAfterLandingCharge').val());
    txtbasicc=parseFloat($('#EditAfterBasicPriceTax').val());

    txtpercentage=parseFloat($('#EditExcisedutyTax').val());
    txtexcisesum=txtcustomduty+txthighsess+txtaftrlanding+txtbasicc;
    //var Exciseduty=(txtexcisesum*txtpercentage)/100;
    totalexcise=<?php echo EXCISE_DUTY;?>;
    if(isNaN(totalexcise))
    {
        $('#EditAfterExcisedutyTax').val('');
    }
    else
    {
    //var totalexcise=txtcustomduty+Exciseduty;
    $('#EditAfterExcisedutyTax').val(parseFloat(Math.round(totalexcise)));
    }
    EditCalculateExciseED1();
}


function CalculateExciseED1()
{
  var txtexcise=0;    
  var txtexcisepercentage=0;
  var txtexcisetot=0;
  txtexcise=parseFloat($('#AfterExcisedutyTax').val());
  txtexcisepercentage=parseFloat($('#ExcisedutyEDcess').val());
  //var txtexcisetot=(txtexcise*txtexcisepercentage)/100;
  txtexcisetot=<?php echo EXCISE_ED;?>;
  if(isNaN(txtexcisetot))
  {
    $('#AfterExcisedutyEDcess').val('');
  }
  else
  {
  $('#AfterExcisedutyEDcess').val(parseFloat(Math.round(txtexcisetot)));
   }
 
  CalculateexciseSHcess();

//AfterExcisedutyEDcess
}

function EditCalculateExciseED1()
{
    var txtexcise=0;
    var txtexcisepercentage=0;
    var txtexcisetot=0; 
  txtexcise=parseFloat($('#EditAfterExcisedutyTax').val());
  txtexcisepercentage=parseFloat($('#EditExcisedutyEDcess').val());
  //var txtexcisetot=(txtexcise*txtexcisepercentage)/100;
  txtexcisetot=<?php echo EXCISE_ED;?>;
  if(isNaN(txtexcisetot))
  {
   $('#EditAfterExcisedutyEDcess').val('');
  }
  else
  {
  $('#EditAfterExcisedutyEDcess').val(parseFloat(Math.round(txtexcisetot)));
  }
  EditCalculateexciseSHcess();

//AfterExcisedutyEDcess
}

function CalculateexciseSHcess()
 {
    var excisetxt=0;
    var exciseshcess=0; 
    var exciseshcesstot=0;
    excisetxt=parseFloat($('#AfterExcisedutyTax').val());
    exciseshcess=parseFloat($('#ExcisedutySHcess').val());
    //var exciseshcesstot=(excisetxt*exciseshcess)/100;
    exciseshcesstot=<?php echo EXCISE_SH;?>;
    if(isNaN(exciseshcesstot))
    {
     $('#AfterExcisedutySHcess').val('');
    }
    else
    {
    $('#AfterExcisedutySHcess').val(parseFloat(Math.round(exciseshcesstot)));
    //$('#AfterExcisedutySHcess').val('');
    }
    CalculateCustomEdcess();

 }

 function EditCalculateexciseSHcess()
 {
    //alert();
    var excisetxt=0;
    var exciseshcess=0;
    //var exciseshcesstot=(excisetxt*exciseshcess)/100;
    var exciseshcesstot=0;

    excisetxt=parseFloat($('#EditAfterExcisedutyTax').val());
    exciseshcess=parseFloat($('#EditExcisedutySHcess').val());
    //var exciseshcesstot=(excisetxt*exciseshcess)/100;
    exciseshcesstot=<?php echo EXCISE_SH;?>;
    if(isNaN(exciseshcesstot))
    {
     $('#EditAfterExcisedutySHcess').val('');
    }
    else
    {
    $('#EditAfterExcisedutySHcess').val(parseFloat(Math.round(exciseshcesstot)));
    }
    EditCalculateCustomEdcess();

 }


 function CalculateCustomEdcess()
 {

    var txtloading=0;
    var txthighses=0;
    var txtcustomduty1=0;
    var txtexciseduty=0;
    var txtedexciseduty=0;
    var txtshexcisesess=0;
    var totalval=0;
    var txtedcesspercentage=0;
    //var txtcustomedsess=(totalval*txtedcesspercentage)/100;
    var txtcustomedsess=0;




    txtloading=parseFloat($('#AfterLandingCharge').val());
    txthighses=parseFloat($('#AfterHighseas').val());
    txtcustomduty1=parseFloat($('#AfterCustomduty').val());
    txtexciseduty=parseFloat($('#AfterExcisedutyTax').val());
    txtedexciseduty=parseFloat($('#AfterExcisedutyEDcess').val());
    txtshexcisesess=parseFloat($('#AfterExcisedutySHcess').val());
    totalval=txtloading+txtcustomduty1+txtexciseduty+ txtedexciseduty+txthighses+txtshexcisesess;
    txtedcesspercentage=parseFloat($('#CustomEDcess').val());
    //var txtcustomedsess=(totalval*txtedcesspercentage)/100;
    txtcustomedsess=<?php echo CUSTOM_ED;?>;
    if(isNaN(txtcustomedsess))
    {

     $('#AfterCustomEDcess').val('');
    }
    else
    {
    $('#AfterCustomEDcess').val(parseFloat(Math.round(txtcustomedsess)));
    }
    CalculateCustomSHcess();

 }



function EditCalculateCustomEdcess()
 {
    var txtloading=0;
    var txthighses=0;
    var txtcustomduty1=0;
    var txtexciseduty=0;
    var txtedexciseduty=0;
    var txtshexcisesess=0;
    var totalval=0;
    var txtedcesspercentage=0;
    //var txtcustomedsess=(totalval*txtedcesspercentage)/100;
    var txtcustomedsess=0;

    txtloading=parseFloat($('#EditAfterLandingCharge').val());
    txthighses=parseFloat($('#EditAfterHighseas').val());
    txtcustomduty1=parseFloat($('#EditAfterCustomduty').val());
    txtexciseduty=parseFloat($('#EditAfterExcisedutyTax').val());
    txtedexciseduty=parseFloat($('#EditAfterExcisedutyEDcess').val());
    txtshexcisesess=parseFloat($('#EditAfterExcisedutySHcess').val());
    totalval=txtloading+txtcustomduty1+txtexciseduty+ txtedexciseduty+txthighses+txtshexcisesess;
    txtedcesspercentage=parseFloat($('#EditCustomEDcess').val());
    //var txtcustomedsess=(totalval*txtedcesspercentage)/100;
    txtcustomedsess=<?php echo CUSTOM_ED;?>;
    if(isNaN(txtcustomedsess))
    {
     $('#EditAfterCustomEDcess').val('');
    }
    else
    {
    $('#EditAfterCustomEDcess').val(parseFloat(Math.round(txtcustomedsess)));
    }
    EditCalculateCustomSHcess();

 }


 function CalculateCustomSHcess()
 {//alert();

  var landingch=0;
  var highsesssalles=0;
  var customch=0;
  var excisech=0;
  var exciseedch=0;
  var exciseshch=0;
  var totcustomsh=0;

  var txtshpercentage=0;
  //var totresult=(totcustomsh*txtshpercentage)/100;
  var totresult=0;



  landingch=parseFloat($('#AfterLandingCharge').val());
  highsesssalles=parseFloat($('#AfterHighseas').val());
  customch=parseFloat($('#AfterCustomduty').val());
  excisech=parseFloat($('#AfterExcisedutyTax').val());
  exciseedch=parseFloat($('#AfterExcisedutyEDcess').val());
  exciseshch=parseFloat($('#AfterExcisedutySHcess').val());
  totcustomsh=landingch+highsesssalles+customch+excisech+exciseedch+exciseshch;

  txtshpercentage=parseFloat($('#CustomSHcess').val());
  //var totresult=(totcustomsh*txtshpercentage)/100;
  totresult=<?php echo CUSTOM_SH;?>;
  if(isNaN(totresult))
  {
     $('#AfterCustomSHcess').val('');
  }
  else
  {
  $('#AfterCustomSHcess').val(parseFloat(Math.round(totresult)));
  }
  CalculateaddlExciseDuty();

 }


 function EditCalculateCustomSHcess()
 {//alert();

  var landingch=0;
  var highsesssalles=0;
  var customch=0;
  var excisech=0;
  var exciseedch=0;
  var exciseshch=0;
  var totcustomsh=0;

  var txtshpercentage=0;
  //var totresult=(totcustomsh*txtshpercentage)/100;
  var totresult=0;

  landingch=parseFloat($('#EditAfterLandingCharge').val());
  highsesssalles=parseFloat($('#EditAfterHighseas').val());
  customch=parseFloat($('#EditAfterCustomduty').val());
  excisech=parseFloat($('#EditAfterExcisedutyTax').val());
  exciseedch=parseFloat($('#EditAfterExcisedutyEDcess').val());
  exciseshch=parseFloat($('#EditAfterExcisedutySHcess').val());
  totcustomsh=landingch+highsesssalles+customch+excisech+exciseedch+exciseshch;

  txtshpercentage=parseFloat($('#EditCustomSHcess').val());
  //var totresult=(totcustomsh*txtshpercentage)/100;
  var totresult=<?php echo CUSTOM_SH;?>;
  if(isNaN(totresult))
  {
    $('#EditAfterCustomSHcess').val('');
  }
  else
  {
  $('#EditAfterCustomSHcess').val(parseFloat(Math.round(totresult)));
  }
  EditCalculateaddlExciseDuty();

 }
  
function CalculateaddlExciseDuty()
{

  var basic=0;
  var landingcha=0;
  var highsesssalless=0;
  var customcha=0;
  var excisecha=0;
  var exciseedcha=0;
  var exciseshcha=0;
  var customed=0;
  var customsh=0;
  var totaddtnlexcise=0;
  var addtnpercentage=0;
 // var txtaddtnexciseduty=(totaddtnlexcise*addtnpercentage)/100;
 var txtaddtnexciseduty=0;
 var txtgrossduty=0;

  basic=parseFloat($('#AfterBasicPriceTax').val());
  landingcha=parseFloat($('#AfterLandingCharge').val());
  highsesssalless=parseFloat($('#AfterHighseas').val());
  customcha=parseFloat($('#AfterCustomduty').val());
  excisecha=parseFloat($('#AfterExcisedutyTax').val());
  exciseedcha=parseFloat($('#AfterExcisedutyEDcess').val());
  exciseshcha=parseFloat($('#AfterExcisedutySHcess').val());
  customed=parseFloat($('#AfterCustomEDcess').val());
  customsh=parseFloat($('#AfterCustomSHcess').val());
  totaddtnlexcise=basic+landingcha+highsesssalless+customcha+excisecha+exciseedcha+exciseshcha+customed+customsh;
  addtnpercentage=parseFloat($('#AdditionalExciseduty').val());
 // var txtaddtnexciseduty=(totaddtnlexcise*addtnpercentage)/100;
 txtaddtnexciseduty=<?php echo ADDTNL_EXCISEDUTY;?>;
 if(isNaN(txtaddtnexciseduty))
 {
      $('#AfterAdditionalExciseduty').val('');
 }
 else
 {
  $('#AfterAdditionalExciseduty').val(parseFloat(Math.round(txtaddtnexciseduty)));
  }
  //var txtgrossduty=landingcha+highsesssalless+customcha+excisecha+exciseedcha+exciseshcha+customed+customsh+txtaddtnexciseduty;

  txtgrossduty=<?php echo GROSS_DUTY;?>;
  if(isNaN(txtgrossduty))
  {
    $('#Grossdutypayable').val('');
  }
  else{
  $('#Grossdutypayable').val(parseFloat(Math.round(txtgrossduty)));
  }
  CalculateAvlModvat();

}


function EditCalculateaddlExciseDuty()
{
  
  var basic=0;
  var landingcha=0;
  var highsesssalless=0;
  var customcha=0;
  var excisecha=0;
  var exciseedcha=0;
  var exciseshcha=0;
  var customed=0;
  var customsh=0;
  var totaddtnlexcise=0;
  var addtnpercentage=0;
 // var txtaddtnexciseduty=(totaddtnlexcise*addtnpercentage)/100;
 var txtaddtnexciseduty=0;
 var txtgrossduty=0;


  basic=parseFloat($('#EditAfterBasicPriceTax').val());
  landingcha=parseFloat($('#EditAfterLandingCharge').val());
  highsesssalless=parseFloat($('#EditAfterHighseas').val());
  customcha=parseFloat($('#EditAfterCustomduty').val());
  excisecha=parseFloat($('#EditAfterExcisedutyTax').val());
  exciseedcha=parseFloat($('#EditAfterExcisedutyEDcess').val());
  exciseshcha=parseFloat($('#EditAfterExcisedutySHcess').val());
  customed=parseFloat($('#EditAfterCustomEDcess').val());
  customsh=parseFloat($('#EditAfterCustomSHcess').val());
  totaddtnlexcise=basic+landingcha+highsesssalless+customcha+excisecha+exciseedcha+exciseshcha+customed+customsh;
  addtnpercentage=parseFloat($('#EditAdditionalExciseduty').val());
 // var txtaddtnexciseduty=(totaddtnlexcise*addtnpercentage)/100;
 txtaddtnexciseduty=<?php echo ADDTNL_EXCISEDUTY;?>;
 if(isNaN(txtaddtnexciseduty))
 {
    $('#EditAfterAdditionalExciseduty').val('');
 }
 else
 {
  $('#EditAfterAdditionalExciseduty').val(Math.round(txtaddtnexciseduty));
 }
  //var txtgrossduty=landingcha+highsesssalless+customcha+excisecha+exciseedcha+exciseshcha+customed+customsh+txtaddtnexciseduty;

  txtgrossduty=<?php echo GROSS_DUTY;?>;
  if(isNaN(txtgrossduty))
  {
    $('#EditGrossdutypayable').val('');
  }
  else
  {
  $('#EditGrossdutypayable').val(parseFloat(Math.round(txtgrossduty)));
  }
  EditCalculateAvlModvat();

}

function CalculateAvlModvat()
{

  var txtexciseduty1=0;
  var txtexciseedcess=0;
  var txtexciseshcess=0;
  var txtaddtnlexcise=0;
  //var totavlmodvat=txtexciseduty1+txtexciseedcess+txtexciseshcess+txtaddtnlexcise;
  var totavlmodvat=0;

  txtexciseduty1=parseFloat($('#AfterExcisedutyTax').val());
  txtexciseedcess=parseFloat($('#AfterExcisedutyEDcess').val());
  txtexciseshcess=parseFloat($('#AfterExcisedutySHcess').val());
  txtaddtnlexcise=parseFloat($('#AfterAdditionalExciseduty').val());
  //var totavlmodvat=txtexciseduty1+txtexciseedcess+txtexciseshcess+txtaddtnlexcise;
  totavlmodvat=<?php echo AVL_MODVAT;?>;
  if(isNaN(totavlmodvat))
  {
    $('#AvailableModvat').val('');
  }
  else
  {
  $('#AvailableModvat').val(parseFloat(Math.round(totavlmodvat)));
  }
  CalculateGrossExpense();

}


function EditCalculateAvlModvat()
{

  
  var txtexciseduty1=0;
  var txtexciseedcess=0;
  var txtexciseshcess=0;
  var txtaddtnlexcise=0;
  //var totavlmodvat=txtexciseduty1+txtexciseedcess+txtexciseshcess+txtaddtnlexcise;
  var totavlmodvat=0;


  txtexciseduty1=parseFloat($('#EditAfterExcisedutyTax').val());
  txtexciseedcess=parseFloat($('#EditAfterExcisedutyEDcess').val());
  txtexciseshcess=parseFloat($('#EditAfterExcisedutySHcess').val());
  txtaddtnlexcise=parseFloat($('#EditAfterAdditionalExciseduty').val());
  //var totavlmodvat=txtexciseduty1+txtexciseedcess+txtexciseshcess+txtaddtnlexcise;
  totavlmodvat=<?php echo AVL_MODVAT;?>;
  if(isNaN(totavlmodvat))
  {
    $('#EditAvailableModvat').val('');
  }
  else
  {
  $('#EditAvailableModvat').val(parseFloat(Math.round(totavlmodvat)));
   }
  EditCalculateGrossExpense();
}
 

function CalculateGrossExpense()
{

    var txtgrossdutypayable=0;
    var txtmodvat=0;
    //var grossexp=(txtgrossdutypayable-txtmodvat);
    var grossexp=0;


    txtgrossdutypayable=parseFloat($('#Grossdutypayable').val());
    txtmodvat=parseFloat($('#AvailableModvat').val());
    //var grossexp=(txtgrossdutypayable-txtmodvat);
    grossexp=<?php echo GROSS_EXP;?>;
    if(isNaN(grossexp))
    {
        $('#Grossexpenses').val('');
    }
    else
    {
    $('#Grossexpenses').val(parseFloat(Math.round(grossexp)));
    }
    CalculateCtable();

}


function EditCalculateGrossExpense()
{


    var txtgrossdutypayable=0;
    var txtmodvat=0;
    //var grossexp=(txtgrossdutypayable-txtmodvat);
    var grossexp=0;


    txtgrossdutypayable=parseFloat($('#EditGrossdutypayable').val());
    txtmodvat=parseFloat($('#EditAvailableModvat').val());
    //var grossexp=(txtgrossdutypayable-txtmodvat);
    grossexp=<?php echo GROSS_EXP;?>;
    if(isNaN(grossexp))
    {
        $('#EditGrossexpenses').val('');
    }
    else
    {
    $('#EditGrossexpenses').val(parseFloat(Math.round(grossexp)));
    }
    EditCalculateCtable()

}

function CalculateCtable()
{
    //alert();
    //purchaserate 

    var txtCtablequantity=0;
    var txtbasicinrprice=0;
    var txtpurchaserate=0;
    var txtgrossexp=0;
    var txtcustomdutyexp=0;
    var txtrmc=0;
    var total=0;
    var basicamt=0;
    basicamt=parseFloat($('#txtBasicValue').val());

    txtCtablequantity=parseFloat($('#PurQuantity').val());
    txtbasicinrprice=parseFloat($('#AfterBasicPriceTax').val());
    //txtpurchaserate=txtbasicinrprice/txtCtablequantity;
    txtpurchaserate=<?php echo PURCHASE_RATE;?>;
    if(isNaN(txtpurchaserate))
    {
        $('#purchaserate').val('');
    }
    else
    {
    $('#purchaserate').val(txtpurchaserate);
    }
    //CustomDutyExpenses
    //RMCIncludingCustomers
    txtgrossexp=parseFloat($('#Grossexpenses').val());
    //txtcustomdutyexp=txtgrossexp/txtCtablequantity;
    txtcustomdutyexp=<?php echo CUSTOMDUTY_EXP;?>;
    if(isNaN(txtcustomdutyexp))
    {
        $('#CustomDutyExpenses').val('');
    }
    else
    {
    $('#CustomDutyExpenses').val(Math.round(txtcustomdutyexp));
    }
    //txtrmc=txtpurchaserate+txtcustomdutyexp;
    txtrmc=<?php echo RMC_CAL;?>;
    if(isNaN(txtrmc))
    {
        $('#RMCIncludingCustomers').val('');
    }
    else
    {
    $('#RMCIncludingCustomers').val(Math.round(txtrmc));
    }
    quantity=parseFloat($('#Quantity').val());
    basicprice=parseFloat($('#txtBasicValue').val());
    total=<?php echo CALCULATE_TOTAL;?>;
    if(isNaN(total))
    {
     $('#TotalExp').val('');
    }
    else
    {
    $('#TotalExp').val(Math.round(total));
    }

//$('#AfterHighseas').val('');
//$('#AfterCustomduty').val('');
///$('#AfterExcisedutyTax').val('');
//$('#AfterExcisedutyEDcess').val('');
//$('#AfterExcisedutySHcess').val('');
//$('#AfterCustomEDcess').val('');
//$('#AfterCustomSHcess').val('');
//$('#AfterAdditionalExciseduty').val('');
//$('#Grossdutypayable').val('');
//$('#AvailableModvat').val('');
//$('#Grossexpenses').val('');
//$('#purchaserate').val('');
//$('#CustomDutyExpenses').val('');
//$('#RMCIncludingCustomers').val('');
//$('#TotalExp').val('');

}


function EditCalculateCtable()
{
    //alert();
    //purchaserate 
    var txtCtablequantity=0;
    var txtbasicinrprice=0;
    var txtpurchaserate=0;
    var txtgrossexp=0;
    var txtcustomdutyexp=0;
    var txtrmc=0;
    var total=0;
    var basicamt=0;
    basicamt=parseFloat($('#EdittxtBasicValue').val());
    txtCtablequantity=parseFloat($('#EditPurQuantity').val());
    txtbasicinrprice=parseFloat($('#EditAfterBasicPriceTax').val());
    //txtpurchaserate=txtbasicinrprice/txtCtablequantity;
    txtpurchaserate=<?php echo PURCHASE_RATE;?>;
    $('#Editpurchaserate').val(txtpurchaserate);
    //CustomDutyExpenses
    //RMCIncludingCustomers
    txtgrossexp=parseFloat($('#EditGrossexpenses').val());
    //txtcustomdutyexp=txtgrossexp/txtCtablequantity;
    txtcustomdutyexp=<?php echo CUSTOMDUTY_EXP;?>;
    $('#EditCustomDutyExpenses').val(txtcustomdutyexp);
    //txtrmc=txtpurchaserate+txtcustomdutyexp;
    txtrmc=<?php echo RMC_CAL;?>;
    purquantity=parseFloat($('#PurQuantity').val());
    $('#EditRMCIncludingCustomers').val(txtrmc);
    total=<?php echo CALCULATE_TOTAL;?>;
    $('#EditTotalExp').val(total);

}



$('.AddImport').click(function()
{
 
   //alert('out');
   if(validateImport())
   {
   //alert('in');
   
   var temp = index;
   //alert('in');
   var Reqnumber = $('#ReqNo').val();
   //alert(JSON.strigify(Reqnumber));
   var departmentName =$('#deptName').val();
   var AvilBudget = $('#AvlBudAmt').val();
   var costCode = $('#CostCenter').val();
   var materialCode =$('#MaterialCode').val();
   var materialName =  $("#ItemName").val();
   var uom = $("#UOM").val();
   var quantity = $("#Quantity").val();
   var itemRate = $("#Rate").val();
   var BasicAmt=parseFloat($("#txtBasicValue").val());
   var taxamt=parseFloat($("#RMCIncludingCustomers").val());
   var totalexp=parseFloat($("#TotalExp").val());
   var Exchangerate=parseFloat($("#ExchangeRt").val());
   var Basicpriceinus=parseFloat($("#imBasicPrice").val());

   //alert(JSON.stringify(totalexp));

  // index = parseInt(index)+1;   
 // alert('in');
   //var template = jQuery("#ImportList").html();
   //$('#ImportAppend').append(_.template(template,{index:temp,ReqNo:Reqnumber,ItemName:materialName,Quantity:quantity,UOM:uom,Rate:itemRate,BasicAmount:BasicAmt,Taxvalue:taxamt,TotalValue:totalexp}));

    

  //var template = jQuery("#ImportList").html();
  //from design id
   
    var BasicPrice=$("#BasicPriceTax").val();
    var AfterBasicPrice=parseFloat($("#AfterBasicPriceTax").val());
    var LandingChargee=$("#LandingCharge").val();
    var AfterLandingChargee=$("#AfterLandingCharge").val();
    var Highseass=$("#Highseas").val();
    var AfterHighseass=$("#AfterHighseas").val();
    //var AfterHighseass=($"#AfterHighseas").val();
    var CustomDutyy=$("#Customduty").val();
    var AfterCustomDutyy=$("#AfterCustomduty").val();
    
    var ExciseDutyy=$("#ExcisedutyTax").val();
    var AfterExciseDutyy=$("#AfterExcisedutyTax").val();
    var ExciseDutyEd=$("#ExcisedutyEDcess").val();
    var AfterExciseDutyEd=$("#AfterExcisedutyEDcess").val();
    var ExciseDutySH=$("#ExcisedutySHcess").val();
    var AfterExciseDutySH=$("#AfterExcisedutySHcess").val();
    var CustomED=$("#CustomEDcess").val();
    var AfterCustomED=$("#AfterCustomEDcess").val();
    var CustomSH=$("#CustomSHcess").val();
    var AfterCustomSH=$("#AfterCustomSHcess").val();
    var AdditnlExcise=$("#AdditionalExciseduty").val();
    var AfterAdditnlExcise=$("#AfterAdditionalExciseduty").val();
    var GrossDuty=$("#Grossdutypayable").val();
    var Avlmodvat=$("#AvailableModvat").val();
    var Grossexpenseduetocustom=$("#Grossexpenses").val();
    var PurchaseQuantity=$("#PurQuantity").val();
    var purate=$("#purchaserate").val();
    var CustomDutyExpense=$("#CustomDutyExpenses").val();
    var RMCIncluderate=$("#RMCIncludingCustomers").val();
    $('#MaterialCode option[value='+materialCode+']').remove();
    
    
      $('#MaterialCode option[value='+materialCode+']').remove();
       SelectedMaterialCode[CollIndex] = materialCode;
            CollIndex = CollIndex + 1;

            SelectedMaterialList.Mat.push({ 
        "materialCode" :  materialCode,
        "ReqNo"  : Reqnumber,
      
        }); 



            populateValueMainFormForImportTax();

            index = parseInt(index)+1;   
  //alert('in');
   var template = jQuery("#ImportList").html();
   $('#ImportAppend').append(_.template(template,{index:temp,ReqNo:Reqnumber,ItemName:materialName,Quantity:quantity,UOM:uom,Rate:itemRate,BasicAmount:BasicAmt,Taxvalue:taxamt,TotalValue:totalexp}));
   //alert(JSON.strigify(BasicAmt));

    
 //$('#ImportAppend').append(_.template(template,{index:temp,ReqNo:Reqnumber,ItemName:materialName,Quantity:quantity,UOM:uom,Rate:itemRate,BasicAmount:BasicAmt,Taxvalue:taxamt,TotalValue:totalexp}));
          //clearTaxField();

          //from above defined variables

         var theForm = $(".ImportPO");
          
          addHidden(theForm,"Reqnumber"+temp,Reqnumber );
          addHidden(theForm,"departmentName"+temp,departmentName );
          addHidden(theForm,"AvilBudget"+temp,AvilBudget );
          addHidden(theForm,"costCode"+temp,costCode );      
          addHidden(theForm,"materialCode"+temp,materialCode );
          addHidden(theForm,"materialName"+temp,materialName );
          addHidden(theForm,"uom"+temp,uom);
          addHidden(theForm,"quantity"+temp,quantity);
          addHidden(theForm,"itemRate"+temp,itemRate);
          addHidden(theForm,"BasicAmt"+temp,BasicAmt);
          addHidden(theForm,"taxamt"+temp,taxamt); 
          addHidden(theForm,"Exchangerate"+temp,Exchangerate);
          addHidden(theForm,"BasicPriceTax"+temp,BasicPriceTax);
          addHidden(theForm,"BasicPriceinUS"+temp,Basicpriceinus);
          addHidden(theForm,"AfterBasicPriceTax"+temp,AfterBasicPrice);
          addHidden(theForm,"LandingChargee"+temp,LandingChargee);
          addHidden(theForm,"AfterLandingChargee"+temp,AfterLandingChargee);
          addHidden(theForm,"Highseass"+temp,Highseass);
          addHidden(theForm,"AfterHighseass"+temp,AfterHighseass);
          addHidden(theForm,"Customduty"+temp,CustomDutyy);
          addHidden(theForm,"AfterCustomduty"+temp,AfterCustomDutyy);
          addHidden(theForm,"ExcisedutyTax"+temp,ExciseDutyy);
          addHidden(theForm,"AfterExcisedutyTax"+temp,AfterExciseDutyy);
          addHidden(theForm,"ExcisedutyED"+temp,ExciseDutyEd);
          addHidden(theForm,"AfterExcisedutyED"+temp,AfterExciseDutyEd);
          addHidden(theForm,"ExcisedutySH"+temp,ExciseDutySH);
          addHidden(theForm,"AfterExcisedutySH"+temp,AfterExciseDutySH);
          addHidden(theForm,"CustomEDcess"+temp,CustomED);
          addHidden(theForm,"AfterCustomEDcess"+temp,AfterCustomED);
          addHidden(theForm,"CustomSHcess"+temp,CustomSH);
          addHidden(theForm,"AfterCustomSHcess"+temp,AfterCustomSH);
          addHidden(theForm,"AdditionalExciseduty"+temp,AdditnlExcise);
          addHidden(theForm,"AfterAdditionalExciseduty"+temp,AfterAdditnlExcise);
          addHidden(theForm,"Grossdutypayable"+temp,GrossDuty);
          addHidden(theForm,"Grossexpenses"+temp,Grossexpenseduetocustom);
          addHidden(theForm,"PurQuantity"+temp,PurchaseQuantity);
          addHidden(theForm,"purchaserate"+temp,purate);
          addHidden(theForm,"CustomDutyExpenses"+temp,CustomDutyExpense);
          addHidden(theForm,"RMCIncludingCustomers"+temp,RMCIncluderate);
          addHidden(theForm,"AvilableModvat"+temp,Avlmodvat);
          addHidden(theForm,"TotalExp"+temp,totalexp);
         // alert(JSON.stringify(totalexp));

     
         
       
         // addHidden(theForm,"AfterBasicPriceTax"+temp,AfterBasicPriceTax);
          //addHidden(theForm,"AfterBasicPriceTax"+temp,AfterBasicPriceTax);
           $('#txtRowCount').val(temp);
           clearTaxField();

 
 }
    
   
});



function validateImport()
{
 //alert();
    if($('#ReqNo').val() == "0")
    {
        alert('Please select the Requisition Number');
        $('#ReqNo').focus();
        return false;
    }
    else if($('#CostCenter').val() == "0")
    {
        alert('Please select the Cost center');
        $('#CostCenter').focus();
        return false;
    }
    else if($('#MaterialCode').val() == "0")
    {
        alert('Please select the Material Code');
        $('#MaterialCode').focus();
        return false;
    }       
    else if($('#Quantity').val() == '')
    {
        alert('Please Enter the Quantity value');
        $('#Quantity').focus();
        return false;
    }
    else if($('#Rate').val() == '')
    {
        alert('Please Enter the Rate of the Item');
        $('#Rate').focus();
        return false;
    }
    else if($('#imBasicPrice').val()=='')
    {
        alert('Please Enter Basic Price In Us');
        $('#imBasicPrice').focus();
        return false;
    }
   /* else if(ExceedQuantityCheck() ==  false)
    {  
        return false;
    }*/
    else 
        return true;
}



function addHidden(theForm, key, value) {
    // Create a hidden input element, and append it to the form:
    var input = document.createElement('input');
    input.type = 'hidden';
    input.name = key;'name-as-seen-at-the-server';
    input.id = key;'name-as-seen-at-the-server';
    input.value = value;
    theForm.append(input);
}


function populateValueMainFormForImportTax()
{

//$('#txtToatlOrder').val(parseFloat(TotalOrderValue)).toFixed(2);

var AfterLandingCharge= $('#AfterLandingCharge').val() == '' ? '0.00' : $('#AfterLandingCharge').val();
var AfterHighseas=$('#AfterHighseas').val()==''?'0.00':$('#AfterHighseas').val();
var AfterCustomduty=$('#AfterCustomduty').val()==''?'0.00':$('#AfterCustomduty').val();
var AfterExcisedutyTax=$('#AfterExcisedutyTax').val()==''?'0.00':$('#AfterExcisedutyTax').val();
var AfterExcisedutyEDcess=$('#AfterExcisedutyEDcess').val()==''?'0.00':$('#AfterExcisedutyEDcess').val();
var AfterExciseDutySH=$("#AfterExcisedutySHcess").val()==''?'0.00':$('#AfterExcisedutySHcess').val();
var AfterCustomEDcess=$('#AfterCustomEDcess').val()==''?'0.00':$('#AfterCustomEDcess').val();
var AfterCustomSHcess=$('#AfterCustomSHcess').val()==''?'0.00':$('#AfterCustomSHcess').val();
var AfterAdditionalExciseduty=$('#AfterAdditionalExciseduty').val()==''?'0.00':$('#AfterAdditionalExciseduty').val();
var Grossdutypayable=$('#Grossdutypayable').val()==''?'0.00':$('#Grossdutypayable').val();
var AvailableModvat=$('#AvailableModvat').val()==''?'0.00':$('#AvailableModvat').val();
var Grossexpenses=$('#Grossexpenses').val()==''?'0.00':$('#Grossexpenses').val();
var totalexp=$('#TotalExp').val()==''?'0.00':$('#TotalExp').val();
var TotalLanding=$('#txttotallanding').val()==''?'0.00':$('#txttotallanding').val();
var TotalHighseas=$('#txttotalhighseas').val()==''?'0.00':$('#txttotalhighseas').val();
var TotalCustom=$('#txttotalcustom').val()==''?'0.00':$('#txttotalcustom').val();
var TotalExcise=$('#txttotalexcise').val()==''?'0.00':$('#txttotalexcise').val();
var TotalExciseED=$('#txttotalexciseED').val()==''?'0.00':$('#txttotalexciseED').val();
var TotalExciseSH=$('#txttotalexciseSH').val()==''?'0.00':$('#txttotalexciseSH').val();
var TotalCustomED=$('#txttotalcustomED').val()==''?'0.00':$('#txttotalcustomED').val();
var TotalCustomSH=$('#txttotalcustomSH').val()==''?'0.00':$('#txttotalcustomSH').val();
var TotalAdditionalExcise=$('#txttotalAdditionalExciseduty').val()==''?'0.00':$('#txttotalAdditionalExciseduty').val();
var TotalGrossDuty=$('#txttotalgrossduty').val()==''?'0.00':$('#txttotalgrossduty').val();
var TotalAvlmodvat=$('#txttotalavlmodvat').val()==''?'0.00':$('#txttotalavlmodvat').val();
var TotalGrossExpense=$('#txttotalgrossexpense').val()==''?'0.00':$('#txttotalgrossexpense').val();
var TotalOrder=$('#txtToatlOrder').val()==''?'0.00':$('#txtToatlOrder').val();
$('#txttotallanding').val((parseFloat(AfterLandingCharge) + parseFloat(TotalLanding)).toFixed(2) );
$('#txttotalhighseas').val((parseFloat(TotalHighseas) + parseFloat(AfterHighseas)).toFixed(2) );
$('#txttotalcustom').val((parseFloat(TotalCustom) + parseFloat(AfterCustomduty)).toFixed(2) );
$('#txttotalexcise').val((parseFloat(TotalExcise) + parseFloat(AfterExcisedutyTax)).toFixed(2) );
$('#txttotalexciseED').val((parseFloat(TotalExciseED) + parseFloat(AfterExcisedutyEDcess)).toFixed(2) );
$('#txttotalexciseSH').val((parseFloat(TotalExciseSH) + parseFloat(AfterExciseDutySH)).toFixed(2) );
$('#txttotalcustomED').val((parseFloat(TotalCustomED) + parseFloat(AfterCustomEDcess)).toFixed(2) );
$('#txttotalcustomSH').val((parseFloat(TotalCustomSH) + parseFloat(AfterCustomSHcess)).toFixed(2) );
$('#txttotalAdditionalExciseduty').val((parseFloat(TotalAdditionalExcise) + parseFloat(AfterAdditionalExciseduty)).toFixed(2) );
$('#txttotalgrossduty').val((parseFloat(TotalGrossDuty) + parseFloat(Grossdutypayable)).toFixed(2) );
$('#txttotalavlmodvat').val((parseFloat(TotalAvlmodvat) + parseFloat(AvailableModvat)).toFixed(2) );
$('#txttotalgrossexpense').val((parseFloat(TotalGrossExpense) + parseFloat(Grossexpenses)).toFixed(2) );
$('#txtToatlOrder').val((parseFloat(TotalOrder) + parseFloat(totalexp)).toFixed(2) );
//alert(JSON.stringify(totalexp));
alert(TotalOrder);



}


function clearTaxField()
{
    //$('#AfterBasicPriceTax').val('');
    $('#ReqNo').val('');
    $('#deptName').val('');
    $('#CostCenter').val('');
    $('#AvlBudAmt').val('');
    $('#MaterialCode').val('');
    $('#ItemName').val('');
    $('#UOM').val('');
    $('#Quantity').val('');
    $('#Rate').val('');
    $('#txtBasicValue').val('');
    $('#imBasicPrice').val('');
    $('#ExchangeRt').val('');
    $('#INRBasicvalue').val('');
    $('#BasicPriceTax').val('');
    $('#AfterBasicPriceTax').val('');
    $('#TotalExp').val('');
    $('#AfterLandingCharge').val('');
    $('#LandingCharge').val('');
    $('#AfterHighseas').val('');
    $('#Highseas').val('');
    $('#AfterCustomduty').val('');
    $('#Customduty').val('');
    $('#AfterExcisedutyTax').val('');
    $('#ExcisedutyTax').val('');
    $('#AfterExcisedutyEDcess').val('');
    $('#ExcisedutyEDcess').val('');
    $('#AfterExcisedutySHcess').val('');
    $('#ExcisedutySHcess').val('');
    $('#AfterCustomEDcess').val('');
    $('#CustomEDcess').val('');
    $('#AfterCustomSHcess').val('')
    $('#CustomSHcess').val('');
    $('#AfterCustomSHcess').val('');
    $('#AfterAdditionalExciseduty').val('');
    $('#AdditionalExciseduty').val('');
    $('#Grossdutypayable').val('');
    $('#AvailableModvat').val('');
    $('#Grossexpenses').val('');
    $('#PurQuantity').val('');
    $('#purchaserate').val('');
    $('#CustomDutyExpenses').val('');
    $('#RMCIncludingCustomers').val('');
}


$("#editimportpomodel").on("shown.bs.modal", function(e) {
        userid = $(e.relatedTarget).data('userid');
        //alert(userid);
        //alert('inadd');
        var tr= document.getElementById(userid);
        //alert(tr);
        var cellval = tr.cells;
        //alert(cellval);
        var id= $('#Reqnumber'+userid).val();
        //alert(id);
        $('#EditReqNo').val($('#Reqnumber'+userid).val());

//alert($('#Reqnumber'+userid).val());  
      $('#EditdeptName').val($('#departmentName'+userid).val());
        $("#EditCostCenter").val($('#costCode'+userid).val());
        $('#EditAvlBudAmt').val($('#AvilBudget'+userid).val());
        
        $('#EditItemName').val($('#materialName'+userid).val());
        $('#EditUOM').val($('#uom'+userid).val());
        $('#EditQuantity').val($('#quantity'+userid).val());
        //RequistQuantity = $('#quantity'+userid).val();
        $('#EditRate').val($('#itemRate'+userid).val());
         $('#EdittxtBasicValue').val($('#BasicAmt'+userid).val());
        $('#EditBasicPrice').val($("#BasicPriceTax"+userid).val());
       //$('#EditAfterBasicPrice').val($("#AfterBasicPriceTax"+userid).val());
        $('#EditLandingCharge').val($("#LandingChargee"+userid).val());
        $('#EditAfterLandingCharge').val($("#AfterLandingChargee"+userid).val());
        $('#EditHighseas').val($("#Highseass"+userid).val());
        $('#EditAfterHighseas').val($("#AfterHighseass"+userid).val());
        $('#EditCustomduty').val($("#Customduty"+userid).val());
        $('#EditAfterCustomduty').val($("#AfterCustomduty"+userid).val());
        $('#EditExcisedutyTax').val($("#ExcisedutyTax"+userid).val());
        $('#EditAfterExcisedutyTax').val($("#AfterExcisedutyTax"+userid).val());
        $('#EditExcisedutyEDcess').val($("#ExcisedutyED"+userid).val());
        $('#EditAfterExcisedutyEDcess').val($("#AfterExcisedutyED"+userid).val());
        $('#EditExcisedutySHcess').val($("#ExcisedutySH"+userid).val());
        $('#EditAfterExcisedutySHcess').val($("#AfterExcisedutySH"+userid).val());

        $('#EditCustomEDcess').val($("#CustomEDcess"+userid).val());
        $('#EditAfterCustomEDcess').val($("#AfterCustomEDcess"+userid).val());
        $('#EditCustomSHcess').val($("#CustomSHcess"+userid).val());
        $('#EditAfterCustomSHcess').val($("#AfterCustomSHcess"+userid).val());
        $('#EditAdditionalExciseduty').val($("#AdditionalExciseduty"+userid).val());
        $('#EditAfterAdditionalExciseduty').val($("#AfterAdditionalExciseduty"+userid).val());
        $('#EditGrossdutypayable').val($("#Grossdutypayable"+userid).val());
        $('#EditGrossexpenses').val($("#Grossexpenses"+userid).val());
        $('#EditPurQuantity').val($("#PurQuantity"+userid).val());
        $('#Editpurchaserate').val($("#purchaserate"+userid).val());
        $('#EditCustomDutyExpenses').val($("#CustomDutyExpenses"+userid).val());
        $('#EditRMCIncludingCustomers').val($("#RMCIncludingCustomers"+userid).val());
        $('#EditAfterBasicPriceTax').val($("#AfterBasicPriceTax"+userid).val());
        $('#EditAvailableModvat').val($("#AvilableModvat"+userid).val());
        $('#EditTotalExp').val($("#TotalExp"+userid).val());
        $('#EditTotalOrderValue').val(cellval[8].innerHTML);
        $("#EditMaterialCode").empty();
        var Material = <?php echo json_encode($MaterialList, JSON_PRETTY_PRINT) ?>;
        $("#EditMaterialCode").append( $('<option></option>').val($('#materialCode'+userid).val()).html($('#materialCode'+userid).val() + "-" + $('#materialName'+userid).val()  ) );
        var isAdded = "0";
         for(i=0;i<Material.length;i++)
        {
        $.each(Material[i], function(idx, obj) {
            
                if(obj.ReqNo === id )
                {
                                      
                        $.each(SelectedMaterialList.Mat, function(idx1, el){                                                            
                            if (id == el.ReqNo )
                            {
                                                            
                                if(el.materialCode == obj.MaterialCode)
                                {
                                        isAdded  = "1";
                                        return false;                                                                        
                                }
                                else
                                {
                                    isAdded  = "0";
                                }
                                
                            }
                    });
                    
                    
                        if(isAdded  == "0")
                        {
                            
                            $("#EditMaterialCode").append( $('<option></option>').val(obj.MaterialCode).html(obj.MaterialCode + "-" + obj.MaterialName));
                        }
                                                
                }
            
            
        });
        }
        
});



$('.EditImport').click(function(){
    //alert('inside edit');

   var CostCode =  $("#EditCostCenter").val();
   var AvilBudget = $('#EditAvlBudAmt').val();
   var editMaterialCode =  $("#EditMaterialCode").val();
   var edititemname = $("#EditItemName").val();     
   var editUOM = $('#EditUOM').val();
   var editQuantity = $('#EditQuantity').val();
   var itemRate = $("#EditRate").val();
   var BasicValue=$("#EdittxtBasicValue").val();
   //var BasicValue=$("#EdittxtBasicValue").val();
   var BasicPrice=$("#EditBasicPriceTax").val();
   var AfterBasicPrice=$("#EditAfterBasicPriceTax").val();
   var Landingcharge=$("#EditLandingCharge").val();
   var AfterLanding=$("#EditAfterLandingCharge").val();
   var Highseass=$("#EditHighseas").val();
   var AfterHighseas=$("#EditAfterHighseas").val();
   var CustomDuty=$("#EditCustomduty").val();
   var AfterCustomDuty=$("#EditAfterCustomduty").val();
   var ExciseDuty=$("#EditExcisedutyTax").val();
   var AfterExciseDuty=$("#EditAfterExcisedutyTax").val();
   var ExciseEd=$("#EditExcisedutyEDcess").val();
   var AfterExciseEd=$("#EditAfterExcisedutyEDcess").val();  
   var ExciseDutySH=$("#EditExcisedutySHcess").val();
   var AfterExciseDutySH=$("#EditAfterExcisedutySHcess").val();
   var CustomED=$("#EditCustomEDcess").val();
   var AfterCustomED=$("#EditAfterCustomEDcess").val();
   var CustomSH=$("#EditCustomSHcess").val();
   var AfterCustomSH=$("#EditAfterCustomSHcess").val();
   var AdditionalExciseduty=$("#EditAdditionalExciseduty ").val();
   var AfterAdditionalExciseduty=$("#EditAfterAdditionalExciseduty").val();
   var GrossDuty=$("#EditGrossdutypayable").val();
   var AvailaleModvat=$("#EditAvailableModvat").val();
   var GrossExpense=$("#EditGrossexpenses").val();
   var PurchaseRate=$("#Editpurchaserate").val();
   var Quantity=$("#EditPurQuantity").val();
   var CustomDutyExpense=$("#EditCustomDutyExpenses").val();
   var RMC=$("#EditRMCIncludingCustomers").val();
   var TotalExp=$('#EditTotalExp').val();


   var tr= document.getElementById(userid);
   var cellval = tr.cells; 

             
   cellval[3].innerHTML = editQuantity;
   cellval[4].innerHTML =editUOM;
   cellval[5].innerHTML =itemRate;
   cellval[6].innerHTML =BasicValue;
  
          $('#materialCode'+userid).val(editMaterialCode);
          $('#materialName'+userid).val(edititemname);
          $('#uom'+userid).val(editUOM);
          $('#Quantity'+userid).val(EditQuantity);
          $('#itemRate'+userid).val(EditRate);
          $('#BasicAmt'+userid).val(BasicValue);
          $('#BasicPriceTax'+userid).val(BasicPrice);
          $('#AfterBasicPriceTax'+userid).val(AfterBasicPrice);
          $('#LandingChargee'+userid).val(Landingcharge);
          $('#AfterLandingChargee'+userid).val(AfterLanding);
          $('#Highseass'+userid).val(Highseass);
          $('#AfterHighseass'+userid).val(AfterHighseas);
          $('#Customduty'+userid).val(CustomDuty); 
          $('#AfterCustomduty'+userid).val(AfterCustomDuty);
          $('#ExcisedutyTax'+userid).val(ExciseDuty);
          $('#AfterExcisedutyTax'+userid).val(AfterExciseDuty);
          $('#ExcisedutyED'+userid).val(ExciseEd);
          $('#AfterExcisedutyED'+userid).val(AfterExciseEd);
          $('#ExcisedutySH'+userid).val(ExciseDutySH);
          $('#AfterExcisedutySH'+userid).val(AfterExciseDutySH);
          $('#CustomEDcess'+userid).val(CustomED);
          $('#AfterCustomEDcess'+userid).val(AfterCustomED);
          $('#CustomSHcess'+userid).val(CustomSH);
          $('#AfterCustomSHcess'+userid).val(AfterCustomSH);
          $('#AdditionalExciseduty'+userid).val(AdditionalExciseduty);
          $('#AfterAdditionalExciseduty'+userid).val(AfterAdditionalExciseduty);
          $('#Grossdutypayable'+userid).val(GrossDuty);
          $('#Grossexpenses'+userid).val(GrossExpense);
          $('#purchaserate'+userid).val(PurchaseRate);
          $('#PurQuantity'+userid).val(Quantity);
          $('#CustomDutyExpenses'+userid).val(CustomDutyExpense);
          $('#RMCIncludingCustomers'+userid).val(RMC);
          $('#TotalExp'+userid).val(TotalExp);
           populateValueMainFormForEditImportTax();
          //$('#Grossexpenses'+userid).val(GrossExpense);

          //addHidden(theForm,"taxamt"+temp,taxamt);//RMC 
          //addHidden(theForm,"totalexp"+temp,totalexp);//totalexpense
          
          //addHidden(theForm,"AfterBasicPriceTax"+,AfterBasicPrice);
          
          /*addHidden(theForm,"Grossdutypayable"+temp,GrossDuty);
          addHidden(theForm,"Grossexpenses"+temp,Grossexpenseduetocustom);
          addHidden(theForm,"PurQuantity"+temp,PurchaseQuantity);
          addHidden(theForm,"purchaserate"+temp,purate);
          addHidden(theForm,"CustomDutyExpenses"+temp,CustomDutyExpense);
          addHidden(theForm,"RMCIncludingCustomers"+temp,RMCIncluderate);
          addHidden(theForm,"AvilableModvat"+temp,Avlmodvat);*/


  } );   


function populateValueMainFormForEditImportTax()
{
  var rows =document.getElementById('ImportTax').rows.length;
  var TotalLanding=0;
  var TotalHighseas=0;
  var TotalCustom=0;
  var TotalExcise=0;
  var TotalExciseED=0;
  var TotalExciseSH=0;
  var TotalCustomED=0;
  var TotalCustomSH=0;
  var TotalAdditionalExcise=0;
  var TotalGrossDuty=0;
  var TotalAvlmodvat=0;
  var TotalGrossExpense=0;
  var i = 0;
  var TotalRMC=0;
  do{
     i += 1;
     var tr= document.getElementById(i);
     if(tr != null)
     {
       cells = tr.getElementsByTagName('td');
       var rowid = cells[0].innerHTML;

var AfterLandingCharge= $('#AfterLandingCharge').val() == '' ? '0.00' : $('#AfterLandingCharge').val();
var AfterHighseas=$('#AfterHighseas').val()==''?'0.00':$('#AfterHighseas').val();
var AfterCustomduty=$('#AfterCustomduty').val()==''?'0.00':$('#AfterCustomduty').val();
var AfterExcisedutyTax=$('#AfterExcisedutyTax').val()==''?'0.00':$('#AfterExcisedutyTax').val();
var AfterExcisedutyEDcess=$('#AfterExcisedutyEDcess').val()==''?'0.00':$('#AfterExcisedutyEDcess').val();
var AfterExciseDutySH=$("#AfterExcisedutySHcess").val()==''?'0.00':$('#AfterExcisedutySHcess').val();
var AfterAdditionalExciseduty=$('#AfterAdditionalExciseduty').val()==''?'0.00':$('#AfterAdditionalExciseduty').val();
var AfterCustomEDcess=$('#AfterCustomEDcess').val()==''?'0.00':$('#AfterCustomEDcess').val();
var AfterCustomSHcess=$('#AfterCustomSHcess').val()==''?'0.00':$('#AfterCustomSHcess').val();
var AdditionalExciseduty=$('#AdditionalExciseduty').val()==''?'0.00':$('#AdditionalExciseduty').val();
var Grossdutypayable=$('#Grossdutypayable').val()==''?'0.00':$('#Grossdutypayable').val();
var AvailableModvat=$('#AvailableModvat').val()==''?'0.00':$('#AvailableModvat').val();
var Grossexpenses=$('#Grossexpenses').val()==''?'0.00':$('#Grossexpenses').val();
var RMC=$('#RMCIncludingCustomers').val()==''?'0.00':$('#RMCIncludingCustomers').val();
TotalLanding  = parseFloat(TotalLanding) + parseFloat(AfterLandingCharge);
TotalHighseas  = parseFloat(TotalHighseas) + parseFloat(AfterHighseas);
TotalCustom  = parseFloat(TotalCustom) + parseFloat(AfterCustomduty);
TotalExcise  = parseFloat(TotalExcise) + parseFloat(AfterExcisedutyTax);
TotalExciseED  = parseFloat(TotalExciseED ) + parseFloat(AfterExcisedutyEDcess);
TotalExciseSH  = parseFloat(TotalExciseSH) + parseFloat(AfterExciseDutySH);
TotalCustomED  = parseFloat(TotalCustomED) + parseFloat(AfterCustomEDcess);
TotalCustomSH  = parseFloat(TotalCustomSH ) + parseFloat(AfterCustomSHcess);
TotalAdditionalExcise  = parseFloat(TotalAdditionalExcise ) + parseFloat(AdditionalExciseduty);
TotalGrossDuty  = parseFloat(TotalGrossDuty) + parseFloat(Grossdutypayable);
TotalAvlmodvat  = parseFloat(TotalAvlmodvat ) + parseFloat(AvailableModvat);
TotalGrossExpense  = parseFloat(TotalGrossExpense ) + parseFloat(Grossexpenses);
//TotalRMC=parseFloat(TotalRMC)+parseFloat(RMC);
   


   var AfterLandingCharge= $('#AfterLandingCharge').val() == '' ? '0.00' : $('#AfterLandingCharge').val();
var AfterHighseas=$('#AfterHighseas').val()==''?'0.00':$('#AfterHighseas').val();
var AfterCustomduty=$('#AfterCustomduty').val()==''?'0.00':$('#AfterCustomduty').val();
var AfterExcisedutyTax=$('#AfterExcisedutyTax').val()==''?'0.00':$('#AfterExcisedutyTax').val();
var AfterExcisedutyEDcess=$('#AfterExcisedutyEDcess').val()==''?'0.00':$('#AfterExcisedutyEDcess').val();
var AfterExciseDutySH=$("#AfterExcisedutySHcess").val()==''?'0.00':$('#AfterExcisedutySHcess').val();
var AfterCustomEDcess=$('#AfterCustomEDcess').val()==''?'0.00':$('#AfterCustomEDcess').val();
var AfterCustomSHcess=$('#AfterCustomSHcess').val()==''?'0.00':$('#AfterCustomSHcess').val();
var AfterAdditionalExciseduty=$('#AfterAdditionalExciseduty').val()==''?'0.00':$('#AfterAdditionalExciseduty').val();
var Grossdutypayable=$('#Grossdutypayable').val()==''?'0.00':$('#Grossdutypayable').val();
var AvailableModvat=$('#AvailableModvat').val()==''?'0.00':$('#AvailableModvat').val();
var Grossexpenses=$('#Grossexpenses').val()==''?'0.00':$('#Grossexpenses').val();
var totalexp=$('#TotalExp').val()==''?'0.00':$('#TotalExp').val();
var TotalLanding=$('#txttotallanding').val()==''?'0.00':$('#txttotallanding').val();
var TotalHighseas=$('#txttotalhighseas').val()==''?'0.00':$('#txttotalhighseas').val();
var TotalCustom=$('#txttotalcustom').val()==''?'0.00':$('#txttotalcustom').val();
var TotalExcise=$('#txttotalexcise').val()==''?'0.00':$('#txttotalexcise').val();
var TotalExciseED=$('#txttotalexciseED').val()==''?'0.00':$('#txttotalexciseED').val();
var TotalExciseSH=$('#txttotalexciseSH').val()==''?'0.00':$('#txttotalexciseSH').val();
var TotalCustomED=$('#txttotalcustomED').val()==''?'0.00':$('#txttotalcustomED').val();
var TotalCustomSH=$('#txttotalcustomSH').val()==''?'0.00':$('#txttotalcustomSH').val();
var TotalAdditionalExcise=$('#txttotalAdditionalExciseduty').val()==''?'0.00':$('#txttotalAdditionalExciseduty').val();
var TotalGrossDuty=$('#txttotalgrossduty').val()==''?'0.00':$('#txttotalgrossduty').val();
var TotalAvlmodvat=$('#txttotalavlmodvat').val()==''?'0.00':$('#txttotalavlmodvat').val();
var TotalGrossExpense=$('#txttotalgrossexpense').val()==''?'0.00':$('#txttotalgrossexpense').val();
var TotalOrder=$('#txtToatlOrder').val()==''?'0.00':$('txtToatlOrder').val();

     }


    }while (i < rows);

    $('#txttotallanding').val(parseFloat(TotalLanding).toFixed(2));
    $('#txttotalhighseas').val(parseFloat(TotalHighseas).toFixed(2));
    $('#txttotalcustom').val(parseFloat(TotalCustom).toFixed(2));
    $('#txttotalexcise').val(parseFloat(TotalExcise).toFixed(2));
    $('#txttotalexciseED').val(parseFloat(TotalExciseED).toFixed(2));
    $('#txttotalexciseSH').val(parseFloat(TotalExciseSH).toFixed(2));
    $('#txttotalcustomED').val(parseFloat(TotalCustomED).toFixed(2));
    $('#txttotalcustomSH').val(parseFloat(TotalCustomSH).toFixed(2));
    $('#txttotalAdditionalExciseduty').val(parseFloat(TotalAdditionalExcise).toFixed(2));
    $('#txttotalgrossduty').val(parseFloat(TotalGrossDuty).toFixed(2));
    $('#txttotalavlmodvat').val(parseFloat(TotalAvlmodvat).toFixed(2));
    $('#txttotalgrossexpense').val(parseFloat(TotalGrossExpense).toFixed(2));
    $('#txtToatlOrder').val(parseFloat(TotalOrder).toFixed(2));



    //$('#txttotallanding').val(parseFloat(TotalLanding).toFixed(2));
}



function DeleteRow(rowid)
{ //alert('Delete');
    var DelRows  = $('#txtDeletedRow').val();
    var answer = confirm(" Do you want to delete the Item from the List?")
    if (answer) 
        {   
            //alert('Confirm');
            var td = document.getElementById(rowid);
            td.parentNode.removeChild(td);
            
            var removeItem = $('#materialCode'+rowid).val();      
        
        
            
          SelectedMaterialCode.splice( SelectedMaterialCode.indexOf('removeItem'), 1 );
          $.each(SelectedMaterialList.Mat, function(i, el){
        
            if (this.materialCode == removeItem){//Type = '';
                  SelectedMaterialList.Mat.splice(i, 1);
        }
        });
         // alert(SelectedMaterialCode);
          if(DelRows != '')
          {
          DelRows = DelRows + ":" + rowid;
          }
          else
          {
              DelRows=  "0" + ":" + rowid;
          }
          $('#txtDeletedRow').val(DelRows);
         populateValueMainFormForDeleteItem(rowid);
         }
        
 }



function populateValueMainFormForDeleteItem(rowid)
{
  var TotalLanding=0;
  var TotalHighseas=0;
  var TotalCustom=0;
  var TotalExcise=0;
  var TotalExciseED=0;
  var TotalExciseSH=0;
  var TotalCustomED=0;
  var TotalCustomSH=0;
  var TotalAdditionalExcise=0;
  var TotalGrossDuty=0;
  var TotalAvlmodvat=0;
  var TotalGrossExpense=0;
var AfterLandingCharge= $('#AfterLandingCharge').val() == '' ? '0.00' : $('#AfterLandingCharge').val();
var AfterHighseas=$('#AfterHighseas').val()==''?'0.00':$('#AfterHighseas').val();
var AfterCustomduty=$('#AfterCustomduty').val()==''?'0.00':$('#AfterCustomduty').val();
var AfterExcisedutyTax=$('#AfterExcisedutyTax').val()==''?'0.00':$('#AfterExcisedutyTax').val();
var AfterExcisedutyEDcess=$('#AfterExcisedutyEDcess').val()==''?'0.00':$('#AfterExcisedutyEDcess').val();
var AfterExciseDutySH=$("#AfterExcisedutySHcess").val()==''?'0.00':$('#AfterExcisedutySHcess').val();
var AfterAdditionalExciseduty=$('#AfterAdditionalExciseduty').val()==''?'0.00':$('#AfterAdditionalExciseduty').val();
var AfterCustomEDcess=$('#AfterCustomEDcess').val()==''?'0.00':$('#AfterCustomEDcess').val();
var AfterCustomSHcess=$('#AfterCustomSHcess').val()==''?'0.00':$('#AfterCustomSHcess').val();
var AdditionalExciseduty=$('#AdditionalExciseduty').val()==''?'0.00':$('#AdditionalExciseduty').val();
var Grossdutypayable=$('#Grossdutypayable').val()==''?'0.00':$('#Grossdutypayable').val();
var AvailableModvat=$('#AvailableModvat').val()==''?'0.00':$('#AvailableModvat').val();
var Grossexpenses=$('#Grossexpenses').val()==''?'0.00':$('#Grossexpenses').val();
var totalExp=$('#TotalExp').val()==''?'0.00':$('#TotalExp').val();
TotalLanding  = parseFloat(TotalLanding) - parseFloat(AfterLandingCharge);
TotalHighseas  = parseFloat(TotalHighseas) - parseFloat(AfterHighseas);
TotalCustom  = parseFloat(TotalCustom) - parseFloat(AfterCustomduty);
TotalExcise  = parseFloat(TotalExcise) - parseFloat(AfterExcisedutyTax);
TotalExciseED  = parseFloat(TotalExciseED ) - parseFloat(AfterExcisedutyEDcess);
TotalExciseSH  = parseFloat(TotalExciseSH) - parseFloat(AfterExciseDutySH);
TotalCustomED  = parseFloat(TotalCustomED) - parseFloat(AfterCustomEDcess);
TotalCustomSH  = parseFloat(TotalCustomSH ) - parseFloat(AfterCustomSHcess);
TotalAdditionalExcise  = parseFloat(TotalAdditionalExcise ) - parseFloat(AdditionalExciseduty);
TotalGrossDuty  = parseFloat(TotalGrossDuty) - parseFloat(Grossdutypayable);
TotalAvlmodvat  = parseFloat(TotalAvlmodvat ) - parseFloat(AvailableModvat);
TotalGrossExpense  = parseFloat(TotalGrossExpense ) - parseFloat(Grossexpenses);
TotalOrderValue=parseFloat(TotalOrderValue)-parseFloat()

    $('#txttotallanding').val(parseFloat(TotalLanding).toFixed(2));
    $('#txttotalhighseas').val(parseFloat(TotalHighseas).toFixed(2));
    $('#txttotalcustom').val(parseFloat(TotalCustom).toFixed(2));
    $('#txttotalexcise').val(parseFloat(TotalExcise).toFixed(2));
    $('#txttotalexciseED').val(parseFloat(TotalExciseED).toFixed(2));
    $('#txttotalexciseSH').val(parseFloat(TotalExciseSH).toFixed(2));
    $('#txttotalcustomED').val(parseFloat(TotalCustomED).toFixed(2));
    $('#txttotalcustomSH').val(parseFloat(TotalCustomSH).toFixed(2));
    $('#txttotalAdditionalExciseduty').val(parseFloat(TotalAdditionalExcise).toFixed(2));
    $('#txttotalgrossduty').val(parseFloat(TotalGrossDuty).toFixed(2));
    $('#txttotalavlmodvat').val(parseFloat(TotalAvlmodvat).toFixed(2));
    $('#txttotalgrossexpense').val(parseFloat(TotalGrossExpense).toFixed(2));
    $('#txtToatlOrder').val(parseFloat(TotalOrderValue).toFixed(2));

   


}



function Save(status)
{
//alert();
if(status == '0')
{
    stat = '<?php echo PO_DRAFT; ?>';
}
else
{
    stat = '<?php echo PO_CREATED; ?>';
}

$('#txtStatus').val(stat);

var txtRowCount = $('#txtRowCount').val();
var txtDeletedRow = $('#txtDeletedRow').val();
//alert(stat);
//alert(JSON.stringify(txtStatus));
//exit();
if(validate())
{
 if(document.getElementById('ImportTax').rows.length <= 0)
   {

    alert('Please Select Line item to Create PO');
    $('#Deliverydt').focus();
    return false;
   }
   else
   {

     $('#content').loader('show');
          $.ajax({ 
            data:$('.ImportPO').serialize()+"&txtRowCount="+txtRowCount+"&txtDeletedRow="+txtDeletedRow+"&textStatus="+stat,

            //data:$('.CreatealterPO').serialize()+"&TextRowCount="+TextRowCount+"&TextDeQletedRowCount="+TextDeletedRowCount+"&TextTotalOrderValueSummaryService="+TextTotalOrderValueSummaryService+"&TextSpcialInstruction="+TextSpcialInstruction+"&TextExchangerate"+ExcLandingCharge="+hangerate+"Status="+TextStatus,
            type:"POST",
            url:"<?php echo base_url() ?>purchaseorder/addNewImportPurchaseOrder", 
            success:function(data) {
            if(data)
            {
                $('#content').loader('hide'); 
                alert(data);
                $('#txtRowCount').val('');
                $('#txtDeletedRow').val('');
                //$('#SpcialInstruction').val('');
                //$('#txtDeliveryAddress').val('');
             window.location =   "purchaseorderListing";
            
            }
                else
                {
                    alert("Error"); 
                }           
        
                }
  
            });

   }

}




}

 $(function () {
   //$("#revenueTax").DataTable();
    $('#ImportTax').DataTable({
      "paging": false,
      "lengthChange": true,
      "searching": false,
      "ordering": false,
     // "info": true,
      "autoWidth": true
       
    }); 
  });

 
</script>
 
