<?php 
// Include main file
include_once('../libs/main.php');
// Check admin Login
include_once('checkLogin.php');
// Logical section of page
$activationKeyObj   = new activationKey();
$adminlogObj = new admin_log();
$modulepagesObj = new module_pages();
$filename=basename($_SERVER['SCRIPT_FILENAME']);
if($filename == 'activationKeyadd.php')
{
    $module_id = $adminlogObj->getModuleId($filename);
    $page_id = $adminlogObj->getPageId($filename);
    $allpages = $modulepagesObj->fromId($page_id);
    $pagename = $allpages->page;
}

if(isset($_REQUEST['act']) && $_REQUEST['act']=='edit' && isset($_REQUEST['activationKey_id'])){
	$activationKeyDetail = $activationKeyObj->fromId($_REQUEST['activationKey_id']);
}
if(isset($_POST['submit'])){
	   
    $data=array(
      'activationKey_number'=>trim($_POST['activationKey_number']),
      'activationKey_key'=>md5("xcare".$_POST['activationKey_number']),
      'activationKey_created_by'=>$_SESSION['admin_id']
    );
    if (isset($_POST['activationKey_id'])){
        
        $id=$_POST['activationKey_id'];
        $rs=$activationKeyObj->updateRecords($data,$id);
        if ($rs){
            $successMsg = base64_encode("Activation Key Update successfully.");			
            header('Location:activationKeylist.php');
            exit;
        }

    }else{

        $data['activationKey_created_at']=date('Y-m-d H:i:s');
        $rs = $activationKeyObj->addRecords($data);
        if($rs){
            $successMsg = base64_encode("Activation key added successfully.");			
            header('Location:activationKeylist.php');
            exit;
        }
    }
}

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

?>