public function index()
{
if($this->request->is([‘post’]))
{
$someVariable = $this->request->getData("username");
$stampsTable = TableRegistry::get('Stamps');
$stamp = $stampsTable->newEntity();
$dteNow = Date::now();
$tmeNow = Time::now();
$answer = $_POST['Type'];
if ($answer == 1) {
$query = $stampsTable->find()->where(['username' => $someVariable, 'outin' => 1]);
if ($query->isEmpty())
{
$stamp->username = $someVariable;
$stamp->tin =$tmeNow;
$stamp->datenow= Date::now();
$stamp->outin=1;
if ($stampsTable->save($stamp))
{
$this->Flash->success(__('The stamp has been saved.'));
}
}else{
$this->Flash->error(__('The stamp is already existing! Please try again!'));
}
}elseif($answer==2){
$affectedRows=$stampsTable->updateAll(array("tout" => $tmeNow,"outin"=>2),array("username IN" => $someVariable , "dateNow IN"=>$dteNow,"outin"=>1));
if($afftectedRows=1)
{
$this->Flash->success(__('The stamp has been saved.'));
}
}else{
$this->Flash->error(__('Complete the form to proceed!'));
}
$this->Flash->error('Access Denied!');
}
{
$users = $this->paginate($this->Users);
$this->set(compact('users'));
}