<div class="acg-top-pad10">
<div id="inshow">
<script src="eportal/js/function.js" type="text/javascript"></script>
<script src="eportal/js/jquery.carouFredSel-5.5.0-packed.js" type="text/javascript"></script>
<script src="eportal/js/functions.js" type="text/javascript"></script>
<?php 
include("eportal/leftsidebar.php");
$modid=$_REQUEST['modid'];
$frmid=$_REQUEST['frmid'];

$rurl="&modid=".$modid."&frmid=".$frmid."";
$target="index.php?route=eportal/inv_dec_index".$rurl;
if(isset($_POST['premium_submit'])){
    
          $noofdepends=count($_REQUEST['policy_no']);
            for($dep=0;$dep<$noofdepends;$dep++)
            {
                $data_dep['emp_id']      =$_REQUEST['emp_id'];
                $data_dep['policy_no']      =$_REQUEST['policy_no'][$dep];
                $data_dep['premium_amt']      =$_REQUEST['premium_amt'][$dep]; 
                $data_dep['payment_term']      =$_REQUEST['payment_term'][$dep];
                $data_dep['due_date']      =FormatDateForSQL($_REQUEST['due_date'][$dep]);
                $data_dep['paid_on']      =FormatDateForSQL($_REQUEST['paid_on'][$dep]); 
                $data_dep['modified_by']            =$_REQUEST['created_by'];
                $data_dep['modified_date']          =date("Y-m-d H:i:s");
                $cond_premimum_id="id='".$_REQUEST['prcal'][$dep]."'";
                $s->RecordEdit('hr_premium_calculation', $data_dep,$cond_premimum_id);
            }
$s->pageLocation( $target); 
}
$emp_id  =  $s->getFieldValue("www_users","id='".$_SESSION['UserID']."' ","empid");
 $result =  DB_query("select * from empmaster where id = '".$emp_id."'",$db);
 $data = DB_fetch_array($result);
 extract($data);
?>
	<h2>Premium Calculation</h2>
  <form method="post" id="premium_form_edit">
           <div class="cat">    
             <input type="hidden" name="emp_id" value="<?php echo $id; ?>">   
             <input type="hidden" name="created_by" value="<?php echo $_SESSION['UserID']; ?>">          
                  <table width="98%" border="0" cellspacing="0" cellpadding="3">
                      <tr>
                        <td width="10%" valign="top" rowspan="2" style="border-top:#c1c1c1 1px solid;"><strong>Emp ID</strong></td>
                        <td width="36%" valign="top" rowspan="2" style="border-top:#c1c1c1 1px solid;"><input type="text" style="width:100%;" value="<?php echo $emp_code; ?>" /></td>
                        <td width="15%" valign="middle" style="border-top:#c1c1c1 1px solid;"><strong>Name</strong></td>
                        <td valign="middle" style="border-top:#c1c1c1 1px solid;"><input type="text"  value="<?php echo $emp_name; ?>" style="width:100%;" /></td>
                      </tr>
                      <tr>
                        <td valign="middle"><strong>Mobile Number</strong></td>
                        <td valign="middle"><input type="text" value="<?php echo $s->getFieldValue("employee_address","emp_id='".$id."' ","per_mobile"); ?>" style="width:100%;" /></td>
                      </tr>                 
                  </table>
                </div>
                <div class="cat">
                  <table width="98%" border="0" cellspacing="0" cellpadding="3">
                      <tr>
                        <th width="6%" valign="middle" style="text-align:center;"><strong>S.No.</strong></th>
                        <th width="25%" valign="middle" style="text-align:center;"><strong>Policy Number</strong></th>
                        <th width="20%" valign="middle" style="text-align:center;"><strong>Premium Amount</strong></th>
                        <th width="15%" valign="middle" style="text-align:center;"><strong>Payment Term</strong></th>
                        <th width="15%" valign="middle" style="text-align:center;"><strong>Due Date</strong></th>
                        <th valign="middle" style="text-align:center;"><strong>Paid on</strong></th>
                      </tr>
                      <?php
                      $sql_prcal="SELECT * FROM hr_premium_calculation WHERE emp_id='".$emp_id."' and fin_year ='".$_SESSION['fin_year']."'";
                        $query_prcal=DB_query($sql_prcal,$db);
                        $pr=0;
                        while($prcal_row=DB_fetch_assoc($query_prcal)){
                       ?>
                      <tr>
                        <td valign="middle" align="center"><strong><?php echo $pr+1; ?>
                        <input type="hidden" name="prcal[]" value="<?php echo $prcal_row['id']; ?>" style="width:100%;" />
                        </strong></td>
                        <td valign="top"><input type="text" name="policy_no[]" value="<?php echo $prcal_row['policy_no']; ?>" style="width:100%;" /></td>
                        <td valign="top"><input type="text" name="premium_amt[]" value="<?php echo $prcal_row['premium_amt']; ?>" style="width:100%;" /></td>
                        <td valign="top"><input type="text" name="payment_term[]" value="<?php echo $prcal_row['payment_term']; ?>" style="width:100%;" /></td>
                        <td valign="top"><input type="text" name="due_date[]" value="<?php echo ConvertSQLDate($prcal_row['due_date']); ?>" style="width:100%;" /></td>
                        <td valign="top"><input type="text" name="paid_on[]" value="<?php echo ConvertSQLDate($prcal_row['paid_on']); ?>" style="width:100%;" /></td>
                      </tr>
                      <?php $pr++; } ?>
                      <tr>
                        <td align="center" colspan="6" height="60" valign="middle"><input type="submit" name="premium_submit" onclick="pre_cal_final_edit();" value="Update" /></td>
                      </tr>
                </div>
          </form>
	</div>
</div>