<?php 
// Include main file
include_once('../libs/main.php');
// Check Login
include_once('checkLogin.php');

// Logical section of page
$coverageInsuranceCarrierObj =  new  coverageInsuranceCarrier();

if(isset($_REQUEST['act']) && $_REQUEST['act']=='edit' && isset($_REQUEST['id'])){
    $carrierDetail = $coverageInsuranceCarrierObj->fromId($_REQUEST['id']);
}

if(isset($_POST['submit'])){
    	$data=array(
	  'type'=>trim($_POST['type']),
	  'title'=>trim($_POST['title']),
	  'description'=>trim($_POST['description'])
	);

	if (isset($_POST['id'])){
            $id=$_POST['id'];
            $rs=$coverageInsuranceCarrierObj->updateRecords($data,$id);
            if ($rs){
                $successMsg = base64_encode(RECORD_UPDATE);			
                header('Location:insuranceCarrierlist.php?successMsg='.$successMsg);
                exit;
            }
        }else{
            $rs = $coverageInsuranceCarrierObj->addRecords($data);
            if($rs){
    		$successMsg = base64_encode(RECORD_ADD);			
    		header('Location:insuranceCarrierlist.php?successMsg='.$successMsg);
    		exit;
            }
	}
}
// Include Template 
include_once('../libs/routs.php');

?>

