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

// Logical section of page
$documentationObj = new documentation();
// Edit Load
if(isset($_REQUEST['act']) && $_REQUEST['act']=='edit' && isset($_REQUEST['id'])){
     $documentationDetail = $documentationObj->fromId($_REQUEST['id']);
}

// Add / Update submit
if(isset($_REQUEST['act']) && $_REQUEST['act']=='load' && isset($_REQUEST['title']) && $_REQUEST['title'] != "")
{
    $data=array(
        'title'=>trim($_REQUEST['title']),
        'description'=>$_REQUEST['description']
    );
    
    if(isset($_REQUEST['status']) && $_REQUEST['status'] == '1'){
        $data['status'] = 1;
    }else{
        $data['status'] = 0;
    } 

    
    // Update
    if (isset($_REQUEST['id'])){
        $id=$_REQUEST['id'];
        
        $rs=$documentationObj->updateRecords($data,$id);
        if ($rs)
        {   	
            header('Location:documentationlist.php');
            exit;
        }
    }
    else // Insert
    {
     
        //print_r($data);exit;   
        $rs = $documentationObj->addRecords($data);
        if($rs)
        {
            header('Location:documentationlist.php');
            exit;
        }
    }
}

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