<?php
namespace App\Controllers;
use Config\Services;

class Addmodulecat extends BaseController{
    private $dbHandle;

    public function index(){
        $this->dbHandle   = \Config\Database::connect();
        $dataToReturn = [];

        $now = time();
         
        $data = [
            'modulecat' => strtoupper($this->request->getVar('modulecat')),
            'note' => $this->request->getVar('note'),
            'personnel' => $this->request->getVar('personnel'),
            'transactdate' => date('Y-m-d H:i:s', $now)
        ];
        
        $this->dbHandle->table('modulecategories')->insert($data);
        $E = $this->dbHandle->error();
        $dataToReturn['status'] = $E['code'];

        return json_encode($dataToReturn, JSON_HEX_APOS | JSON_HEX_QUOT);
    }
}