<?php 

// Include main file
include_once('../libs/main.php');

// Check admin Login
include_once('checkLogin.php');

// Logical section of page
$pointcategoryObj =  new  pointcategory();

/*$adminlogObj = new admin_log();
$modulepagesObj = new module_pages();
$filename=basename($_SERVER['SCRIPT_FILENAME']);

if($filename == 'adminadd.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['pointcategory_id'])){
	$pointDetail = $pointcategoryObj->fromId($_REQUEST['pointcategory_id']);
    //print_r($pointDetail->pointcategory_id);exit;
}



if(isset($_REQUEST['act']) && $_REQUEST['act']=='load' && isset($_REQUEST['pointcategory_title']) && $_REQUEST['pointcategory_title'] != ""){
    $data=array(
        'pointcategory_title' => trim($_POST['pointcategory_title']),
        'pointcategory_desc'  => trim($_POST['pointcategory_desc']),
        'pointcategory_mPoints'=>$_POST['pointcategory_mPoints'],
        'pointcategory_mTopup'=>$_POST['pointcategory_mTopup'],
        'pointcategory_created_at' => date('Y-m-d H:i:s'),
    );

    
    if (isset($_REQUEST['pointcategory_id']) && $_REQUEST['pointcategory_id'] != ''){
    
        $id=$_REQUEST['pointcategory_id'];
        $rs=$pointcategoryObj->updateRecords($data,$id);
        if ($rs){
            header('Location:pointcategorylist.php');
            exit;
        }
    }else{
        $point_add  = $pointcategoryObj->addRecords($data);
        if($point_add){
            header('Location:pointcategorylist.php');
            exit;
        }
    }
}


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

?>