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

class Addplugnote extends BaseController{
    private $dbHandle;

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

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

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