pbmc-cmod/app/Controllers/UserController.php

68 lines
2.3 KiB
PHP
Raw Normal View History

2024-11-20 16:55:21 +07:00
<?php
namespace App\Controllers;
2024-12-04 11:11:02 +07:00
class UserController extends BaseController {
2024-11-20 16:55:21 +07:00
2024-12-04 11:11:02 +07:00
public function index() {
return view('user/dashboard');
2024-11-21 15:38:56 +07:00
}
2024-12-04 11:11:02 +07:00
public function viewAccess($accessnumber): string {
2024-11-20 16:55:21 +07:00
$db = \Config\Database::connect();
$sql = "select sr.HOSTORDERNUMBER, tu.SAMPLETYPE, ds.SHORTTEXT, tu.TUBESTATUS, ct.COLLSTATUS, ct.TUBECOMMENT from SP_TUBES tu
2024-12-04 11:11:02 +07:00
left join SP_REQUESTS sr on tu.SP_ACCESSNUMBER=sr.SP_ACCESSNUMBER
left join DICT_SAMPLES_TYPES ds on ds.SAMPCODE= tu.SAMPLETYPE
left join cmod.dbo.CM_TUBES ct on ct.SAMPLETYPE=tu.SAMPLETYPE and ct.ACCESSNUMBER=tu.SP_ACCESSNUMBER
where tu.SP_ACCESSNUMBER='$accessnumber'";
2024-11-20 16:55:21 +07:00
$query = $db->query($sql);
$results = $query->getResultArray();
$visit_number = $results[0]['HOSTORDERNUMBER'];
2024-12-04 11:11:02 +07:00
$data['data'] = $results;
2024-12-09 15:05:47 +08:00
$sql = "select hp.PATNUMBER, hp.PATNAME, ho.PAYERNAME, ho.TREATDOC
from cmod.dbo.CM_HIS_ORDERS ho
left join cmod.dbo.CM_HIS_PATIENTS hp on hp.PATID=ho.PATID
WHERE ho.VISITNUMBER='$visit_number'";
2024-12-09 15:05:47 +08:00
$query = $db->query($sql);
$results = $query->getResultArray();
if($results != null) {
$data['patnumber'] = $results[0]['PATNUMBER'];
$data['patient_fullname'] = $results[0]['PATNAME'];
// $data['visit_description'] = $results[0]['Visit Description'];
$data['treating_doctor'] = $results[0]['TREATDOC'];
$data['payer_name'] = $results[0]['PAYERNAME'];
2024-12-09 15:05:47 +08:00
} else {
$data['patnumber'] = "";
2024-12-09 15:05:47 +08:00
$data['patient_fullname'] = "";
// $data['visit_description'] = "";
2024-12-09 15:05:47 +08:00
$data['treating_doctor'] = "";
$data['payer_name'] = "";
}
2024-12-04 11:11:02 +07:00
$data['accessnumber'] = $accessnumber;
2024-12-09 15:05:47 +08:00
return view('admin/dashboard_viewAccess', $data);
2024-11-20 16:55:21 +07:00
}
public function changePass() {
if ($this->request->getMethod() === 'POST') {
$password1 = $this->request->getVar('password1');
$password2 = $this->request->getVar('password2');
$data['password1'] = $password1;
$data['password2'] = $password2;
if($password1 == $password2) {
$password = password_hash($password1,PASSWORD_DEFAULT);
$db = \Config\Database::connect();
$sql = "update cmod.dbo.CM_USERS set PASSWORD='$password' where USERID='$userid'";
$db->query($sql);
return redirect()->to("/");
} else {
return redirect()->to("/auth/setpass/$userid")->with('flash_error', 'password is not the same.');
}
}
return view('changePass');
}
}