<?php 
// Include main file
include_once('../libs/main.php');
// Check admin Login
include_once('checkLogin.php');
// Logical section of page
$appointmenttypeObj =  new  appointmenttype();
$specialityObj = new speciality();
if(isset($_REQUEST['act']) && $_REQUEST['act']=='edit' && isset($_REQUEST['appointmenttype_id'])){
    $appointmenttypeDetail = $appointmenttypeObj->fromId($_REQUEST['appointmenttype_id']);
}
if(isset($_POST['submit'])){
    	$data=array(
          'appointmenttype_speciality_id'=>trim($_POST['appointmenttype_speciality_id']),
          'appointmenttype_name'=>trim($_POST['appointmenttype_name']),
          'appointmenttype_duration'=>trim($_POST['appointmenttype_duration']),
	);
        if(isset($_POST['appointmenttype_status'])){
            $data['appointmenttype_status'] 			= '1';
        }else{
            $data['appointmenttype_status'] 			= '0';
        }                
	if (isset($_POST['appointmenttype_id'])){
        $id=$_POST['appointmenttype_id'];
        $rs=$appointmenttypeObj->updateRecords($data,$id);
        if ($rs){
                $successMsg = base64_encode(RECORD_UPDATE);			
                header('Location:appointmenttypelist.php?appointmenttype_speciality_id='.$_POST['appointmenttype_speciality_id'].'&successMsg='.$successMsg);
                exit;
            }
	}else{
            $rs = $appointmenttypeObj->addRecords($data);
            if($rs){
                $successMsg = base64_encode(RECORD_ADD);			
                header('Location:appointmenttypelist.php?appointmenttype_speciality_id='.$_POST['appointmenttype_speciality_id'].'&successMsg='.$successMsg);
                exit;
            }
	}
}
$allspecialities = $specialityObj->getAllRecords();

// Include Template 
include_once('../libs/routs.php')

?>