<?php
if(isset($_POST['state'])){
    require_once('../../assets/config/config.php');
    $obj=new Database();
    if($_POST['state']=='shift'){

        $shift_name=$_POST['shift_name'];
        $shift_time=$_POST['shift_time'];
        $date=date('d-M-Y');
        echo $obj->insert('shift',['create_date'=>$date,'shift_name'=>$shift_name,'shift_time'=>$shift_time,'status'=>'Active']);

    }
    if($_POST['state']=='course'){
        $name=$_POST['name'];
        $desc=$_POST['desc'];
        $duration=$_POST['duration'];
        $date=date('d-M-Y');
        echo $obj->insert('course',['date'=>$date,'name'=>$name,'description'=>$desc,'duration'=>$duration,'status'=>'Active']);
    }

    if($_POST['state']=='exam'){
        $e_name=$_POST['e_name'];
        $c_name=$_POST['c_name'];
        $date=date('d-M-Y');
        echo $obj->insert('exam',['date'=>$date,'exam_name'=>$e_name,'course_name'=>$c_name,'status'=>'Active']);
    }
    if($_POST['state']=='fee'){
        $fee_type=$_POST['shift_name'];
        $fee=$_POST['shift_time'];
        $course=$_POST['course'];
        $date=date('d-M-Y');
        echo $obj->insert('fee',['date'=>$date,'fee_type'=>$fee_type,'amount'=>$fee,'course_name'=>$course,'status'=>'Active']);
    }
    if($_POST['state']=='mail'){

    $h_name=$_POST['h_name'];
    $email=$_POST['email'];
    $password=$_POST['password'];
    $port_no=$_POST['port_no'];
    $header=$_POST['header'];

    echo $obj->update('email_config',['host_name'=>$h_name,'email_id'=>$email,'password'=>$password,'port_no'=>$port_no,'header'=>$header],'id=1');
    }


}
?>