change datetime to utc using CI4 find findall

This commit is contained in:
mahdahar 2025-10-15 19:14:13 +07:00
parent b4fa6c7983
commit 4750f2947b
9 changed files with 23 additions and 59 deletions

View File

@ -13,12 +13,6 @@ class ContactDetailModel extends BaseModel {
protected $createdField = 'ContactStartDate';
protected $updatedField = '';
protected $beforeInsert = ['normalizeDatesToUTC'];
protected $beforeUpdate = ['normalizeDatesToUTC'];
protected $afterFind = ['convertDatesToUTCISO'];
protected $afterInsert = ['convertDatesToUTCISO'];
protected $afterUpdate = ['convertDatesToUTCISO'];
public function syncDetails(int $ContactID, array $contactDetails) {
try {
$keptSiteIDs = [];

View File

@ -7,17 +7,14 @@ use App\Models\BaseModel;
class ContactModel extends BaseModel {
protected $table = 'contact';
protected $primaryKey = 'ContactID';
protected $allowedFields = ['NameFirst', 'NameLast', 'Title', 'Initial', 'Birthdate', 'EmailAddress1', 'EmailAddress2', 'Phone', 'MobilePhone1', 'MobilePhone2', 'Specialty', 'SubSpecialty', 'CreateDate', 'EndDate'];
protected $allowedFields = ['NameFirst', 'NameLast', 'Title', 'Initial', 'Birthdate', 'EmailAddress1', 'EmailAddress2', 'Phone',
'MobilePhone1', 'MobilePhone2', 'Specialty', 'SubSpecialty', 'CreateDate', 'EndDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $beforeInsert = ['normalizeDatesToUTC'];
protected $beforeUpdate = ['normalizeDatesToUTC'];
protected $afterFind = ['convertDatesToUTCISO'];
protected $afterInsert = ['convertDatesToUTCISO'];
protected $afterUpdate = ['convertDatesToUTCISO'];
protected $useSoftDeletes = true;
protected $deletedField = "EndDate";
public function getContactsWithDetail() {
$rows = $this->select("contact.ContactID, cd.SiteID, cd.ContactCode, NameFirst, NameLast, Specialty")
@ -37,7 +34,7 @@ class ContactModel extends BaseModel {
}
public function getContactWithDetail($ContactID) {
$rows = $this->where('contact.ContactID', $ContactID)->join('contactdetail cd', 'contact.ContactID=cd.ContactID','left')->get()->getResultArray();
$rows = $this->join('contactdetail cd', 'contact.ContactID=cd.ContactID','left')->where('contact.ContactID', $ContactID)->findAll();
$contact = [];
foreach ($rows as $row) {

View File

@ -10,7 +10,8 @@ class CounterModel extends BaseModel {
protected $useTimestamps = true;
protected $createdField = "CreateDate";
protected $updatedField = "";
protected $useSoftDeletes = "EndDate";
protected $useSoftDeletes = true;
protected $deletedField = "EndDate";
public function use($CounterID) {
$row = $this->where('CounterID',$CounterID)->get()->getResultArray();

View File

@ -13,19 +13,12 @@ class LocationModel extends BaseModel {
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
protected $beforeInsert = ['normalizeDatesToUTC'];
protected $beforeUpdate = ['normalizeDatesToUTC'];
protected $afterFind = ['convertDatesToUTCISO'];
protected $afterInsert = ['convertDatesToUTCISO'];
protected $afterUpdate = ['convertDatesToUTCISO'];
public function getLocations($LocCode, $LocName) {
$sql = $this->select("LocationID, LocCode, Parent, LocFull, LocType, v.VDesc ")
->join("valueset v", "v.VSetID=12 and v.VValue=location.loctype", 'left');
if($LocName != '') { $sql->like('LocFull', $LocName, 'both'); }
if($LocCode != '') { $sql->like('LocCode', $LocCode, 'both'); }
$rows = $sql->get()->getResultArray();
$rows = $sql->findAll();
return $rows;
}
@ -33,8 +26,8 @@ class LocationModel extends BaseModel {
$rows = $this->select("location.*, la.*, v.*")
->join("locationaddress la", "location.LocationID=la.LocationID", "left")
->join("valueset v", "v.VSetID=12 and v.VValue=location.loctype", "left")
->where('location.LocationID', (int) $LocationID)
->get()->getResultArray();
->where('location.LocationID', (int) $LocationID)->findAll();
//->get()->getResultArray();
return $rows;
}

View File

@ -14,22 +14,17 @@ class PatVisitModel extends BaseModel {
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $beforeInsert = ['normalizeDatesToUTC'];
protected $beforeUpdate = ['normalizeDatesToUTC'];
protected $afterFind = ['convertDatesToUTCISO'];
protected $afterInsert = ['convertDatesToUTCISO'];
protected $afterUpdate = ['convertDatesToUTCISO'];
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
public function __construct() {
$this->db = \Config\Database::connect();
$this->visnum_prefix = "DV";
}
public function show($PVID) {
$rows = $this->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left')
->join('patvisitadt pva', 'pva.InternalPVID=patvisit.InternalPVID', 'left')
->where('patvisit.PVID',$PVID)->get()->getResultArray();
->where('patvisit.PVID',$PVID)->findAll();
return $rows;
}
@ -37,7 +32,7 @@ class PatVisitModel extends BaseModel {
$rows = $this->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left')
->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left')
->join('location l', 'l.LocationID=pva.LocationID', 'left')
->where('patvisit.InternalPID',$InternalPID)->get()->getResultArray();
->where('patvisit.InternalPID',$InternalPID)->findAll();
return $rows;
}

View File

@ -25,7 +25,7 @@ class ContainerDefModel extends BaseModel {
->join('valueset vscol', 'vscol.VID=containerdef.Color', 'left')
->join('valueset vscla', 'vscla.VID=containerdef.ConClass', 'left')
->join('valueset vsadd', 'vsadd.VID=containerdef.Additive', 'left')
->where('ConDefID', $ConDefID)->get()->getResultArray();
->where('ConDefID', $ConDefID)->findAll();
return $rows;
}
}

View File

@ -14,19 +14,12 @@ class ValueSetDefModel extends BaseModel {
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
/*
protected $beforeInsert = ['normalizeDatesToUTC'];
protected $beforeUpdate = ['normalizeDatesToUTC'];
protected $afterFind = ['convertDatesToUTCISO'];
protected $afterInsert = ['convertDatesToUTCISO'];
protected $afterUpdate = ['convertDatesToUTCISO'];
*/
public function getValueSetDefs($param = null) {
if ($param !== null) {
$builder = $this->builder();
$builder->like('VSName', $param, 'both');
$builder->orlike('VSDesc', $param, 'both');
$rows = $builder->get()->getResultArray();
$rows = $this->like('VSName', $param, 'both')
->orlike('VSDesc', $param, 'both')
->findAll();
} else {
$rows = $this->findAll();
}

View File

@ -15,21 +15,12 @@ class ValueSetModel extends BaseModel {
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
protected $beforeInsert = ['normalizeDatesToUTC'];
protected $beforeUpdate = ['normalizeDatesToUTC'];
protected $afterFind = ['convertDatesToUTCISO'];
protected $afterInsert = ['convertDatesToUTCISO'];
protected $afterUpdate = ['convertDatesToUTCISO'];
public function getValueSets($param = null) {
if ($param !== null) {
$builder = $this->builder();
$builder->groupStart()
$rows = $this->groupStart()
->like('VValue', $param, 'both')
->orlike('VDesc', $param, 'both')
->groupEnd();
$rows = $builder->get()->getResultArray();
->groupEnd()->findAll();
return $rows;
} else {
return $this->findAll();