change datetime to utc using CI4 find findall
This commit is contained in:
parent
b4fa6c7983
commit
4750f2947b
@ -7,7 +7,7 @@ use CodeIgniter\Model;
|
|||||||
class BaseModel extends Model {
|
class BaseModel extends Model {
|
||||||
protected $beforeInsert = ['normalizeDatesToUTC'];
|
protected $beforeInsert = ['normalizeDatesToUTC'];
|
||||||
protected $beforeUpdate = ['normalizeDatesToUTC'];
|
protected $beforeUpdate = ['normalizeDatesToUTC'];
|
||||||
protected $afterFind = ['convertDatesToUTCISO'];
|
protected $afterFind = ['convertDatesToUTCISO'];
|
||||||
protected $afterInsert = ['convertDatesToUTCISO'];
|
protected $afterInsert = ['convertDatesToUTCISO'];
|
||||||
protected $afterUpdate = ['convertDatesToUTCISO'];
|
protected $afterUpdate = ['convertDatesToUTCISO'];
|
||||||
|
|
||||||
|
|||||||
@ -13,12 +13,6 @@ class ContactDetailModel extends BaseModel {
|
|||||||
protected $createdField = 'ContactStartDate';
|
protected $createdField = 'ContactStartDate';
|
||||||
protected $updatedField = '';
|
protected $updatedField = '';
|
||||||
|
|
||||||
protected $beforeInsert = ['normalizeDatesToUTC'];
|
|
||||||
protected $beforeUpdate = ['normalizeDatesToUTC'];
|
|
||||||
protected $afterFind = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterInsert = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterUpdate = ['convertDatesToUTCISO'];
|
|
||||||
|
|
||||||
public function syncDetails(int $ContactID, array $contactDetails) {
|
public function syncDetails(int $ContactID, array $contactDetails) {
|
||||||
try {
|
try {
|
||||||
$keptSiteIDs = [];
|
$keptSiteIDs = [];
|
||||||
|
|||||||
@ -7,17 +7,14 @@ use App\Models\BaseModel;
|
|||||||
class ContactModel extends BaseModel {
|
class ContactModel extends BaseModel {
|
||||||
protected $table = 'contact';
|
protected $table = 'contact';
|
||||||
protected $primaryKey = 'ContactID';
|
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 $useTimestamps = true;
|
||||||
protected $createdField = 'CreateDate';
|
protected $createdField = 'CreateDate';
|
||||||
protected $updatedField = '';
|
protected $updatedField = '';
|
||||||
|
protected $useSoftDeletes = true;
|
||||||
protected $beforeInsert = ['normalizeDatesToUTC'];
|
protected $deletedField = "EndDate";
|
||||||
protected $beforeUpdate = ['normalizeDatesToUTC'];
|
|
||||||
protected $afterFind = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterInsert = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterUpdate = ['convertDatesToUTCISO'];
|
|
||||||
|
|
||||||
public function getContactsWithDetail() {
|
public function getContactsWithDetail() {
|
||||||
$rows = $this->select("contact.ContactID, cd.SiteID, cd.ContactCode, NameFirst, NameLast, Specialty")
|
$rows = $this->select("contact.ContactID, cd.SiteID, cd.ContactCode, NameFirst, NameLast, Specialty")
|
||||||
@ -37,7 +34,7 @@ class ContactModel extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getContactWithDetail($ContactID) {
|
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 = [];
|
$contact = [];
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
|
|||||||
@ -10,7 +10,8 @@ class CounterModel extends BaseModel {
|
|||||||
protected $useTimestamps = true;
|
protected $useTimestamps = true;
|
||||||
protected $createdField = "CreateDate";
|
protected $createdField = "CreateDate";
|
||||||
protected $updatedField = "";
|
protected $updatedField = "";
|
||||||
protected $useSoftDeletes = "EndDate";
|
protected $useSoftDeletes = true;
|
||||||
|
protected $deletedField = "EndDate";
|
||||||
|
|
||||||
public function use($CounterID) {
|
public function use($CounterID) {
|
||||||
$row = $this->where('CounterID',$CounterID)->get()->getResultArray();
|
$row = $this->where('CounterID',$CounterID)->get()->getResultArray();
|
||||||
|
|||||||
@ -13,19 +13,12 @@ class LocationModel extends BaseModel {
|
|||||||
protected $useSoftDeletes = true;
|
protected $useSoftDeletes = true;
|
||||||
protected $deletedField = 'EndDate';
|
protected $deletedField = 'EndDate';
|
||||||
|
|
||||||
protected $beforeInsert = ['normalizeDatesToUTC'];
|
|
||||||
protected $beforeUpdate = ['normalizeDatesToUTC'];
|
|
||||||
protected $afterFind = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterInsert = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterUpdate = ['convertDatesToUTCISO'];
|
|
||||||
|
|
||||||
public function getLocations($LocCode, $LocName) {
|
public function getLocations($LocCode, $LocName) {
|
||||||
$sql = $this->select("LocationID, LocCode, Parent, LocFull, LocType, v.VDesc ")
|
$sql = $this->select("LocationID, LocCode, Parent, LocFull, LocType, v.VDesc ")
|
||||||
->join("valueset v", "v.VSetID=12 and v.VValue=location.loctype", 'left');
|
->join("valueset v", "v.VSetID=12 and v.VValue=location.loctype", 'left');
|
||||||
if($LocName != '') { $sql->like('LocFull', $LocName, 'both'); }
|
if($LocName != '') { $sql->like('LocFull', $LocName, 'both'); }
|
||||||
if($LocCode != '') { $sql->like('LocCode', $LocCode, 'both'); }
|
if($LocCode != '') { $sql->like('LocCode', $LocCode, 'both'); }
|
||||||
$rows = $sql->get()->getResultArray();
|
$rows = $sql->findAll();
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,8 +26,8 @@ class LocationModel extends BaseModel {
|
|||||||
$rows = $this->select("location.*, la.*, v.*")
|
$rows = $this->select("location.*, la.*, v.*")
|
||||||
->join("locationaddress la", "location.LocationID=la.LocationID", "left")
|
->join("locationaddress la", "location.LocationID=la.LocationID", "left")
|
||||||
->join("valueset v", "v.VSetID=12 and v.VValue=location.loctype", "left")
|
->join("valueset v", "v.VSetID=12 and v.VValue=location.loctype", "left")
|
||||||
->where('location.LocationID', (int) $LocationID)
|
->where('location.LocationID', (int) $LocationID)->findAll();
|
||||||
->get()->getResultArray();
|
//->get()->getResultArray();
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -14,22 +14,17 @@ class PatVisitModel extends BaseModel {
|
|||||||
protected $useTimestamps = true;
|
protected $useTimestamps = true;
|
||||||
protected $createdField = 'CreateDate';
|
protected $createdField = 'CreateDate';
|
||||||
protected $updatedField = '';
|
protected $updatedField = '';
|
||||||
|
protected $useSoftDeletes = true;
|
||||||
protected $beforeInsert = ['normalizeDatesToUTC'];
|
protected $deletedField = 'EndDate';
|
||||||
protected $beforeUpdate = ['normalizeDatesToUTC'];
|
|
||||||
protected $afterFind = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterInsert = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterUpdate = ['convertDatesToUTCISO'];
|
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->db = \Config\Database::connect();
|
|
||||||
$this->visnum_prefix = "DV";
|
$this->visnum_prefix = "DV";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($PVID) {
|
public function show($PVID) {
|
||||||
$rows = $this->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left')
|
$rows = $this->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left')
|
||||||
->join('patvisitadt pva', 'pva.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;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +32,7 @@ class PatVisitModel extends BaseModel {
|
|||||||
$rows = $this->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left')
|
$rows = $this->join('patdiag pd', 'pd.InternalPVID=patvisit.InternalPVID', 'left')
|
||||||
->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left')
|
->join('patvisitadt pva', 'pd.InternalPVID=pva.InternalPVID', 'left')
|
||||||
->join('location l', 'l.LocationID=pva.LocationID', 'left')
|
->join('location l', 'l.LocationID=pva.LocationID', 'left')
|
||||||
->where('patvisit.InternalPID',$InternalPID)->get()->getResultArray();
|
->where('patvisit.InternalPID',$InternalPID)->findAll();
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ class ContainerDefModel extends BaseModel {
|
|||||||
->join('valueset vscol', 'vscol.VID=containerdef.Color', 'left')
|
->join('valueset vscol', 'vscol.VID=containerdef.Color', 'left')
|
||||||
->join('valueset vscla', 'vscla.VID=containerdef.ConClass', 'left')
|
->join('valueset vscla', 'vscla.VID=containerdef.ConClass', 'left')
|
||||||
->join('valueset vsadd', 'vsadd.VID=containerdef.Additive', 'left')
|
->join('valueset vsadd', 'vsadd.VID=containerdef.Additive', 'left')
|
||||||
->where('ConDefID', $ConDefID)->get()->getResultArray();
|
->where('ConDefID', $ConDefID)->findAll();
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14,19 +14,12 @@ class ValueSetDefModel extends BaseModel {
|
|||||||
protected $updatedField = '';
|
protected $updatedField = '';
|
||||||
protected $useSoftDeletes = true;
|
protected $useSoftDeletes = true;
|
||||||
protected $deletedField = 'EndDate';
|
protected $deletedField = 'EndDate';
|
||||||
/*
|
|
||||||
protected $beforeInsert = ['normalizeDatesToUTC'];
|
|
||||||
protected $beforeUpdate = ['normalizeDatesToUTC'];
|
|
||||||
protected $afterFind = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterInsert = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterUpdate = ['convertDatesToUTCISO'];
|
|
||||||
*/
|
|
||||||
public function getValueSetDefs($param = null) {
|
public function getValueSetDefs($param = null) {
|
||||||
if ($param !== null) {
|
if ($param !== null) {
|
||||||
$builder = $this->builder();
|
$rows = $this->like('VSName', $param, 'both')
|
||||||
$builder->like('VSName', $param, 'both');
|
->orlike('VSDesc', $param, 'both')
|
||||||
$builder->orlike('VSDesc', $param, 'both');
|
->findAll();
|
||||||
$rows = $builder->get()->getResultArray();
|
|
||||||
} else {
|
} else {
|
||||||
$rows = $this->findAll();
|
$rows = $this->findAll();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,21 +15,12 @@ class ValueSetModel extends BaseModel {
|
|||||||
protected $useSoftDeletes = true;
|
protected $useSoftDeletes = true;
|
||||||
protected $deletedField = 'EndDate';
|
protected $deletedField = 'EndDate';
|
||||||
|
|
||||||
protected $beforeInsert = ['normalizeDatesToUTC'];
|
|
||||||
protected $beforeUpdate = ['normalizeDatesToUTC'];
|
|
||||||
protected $afterFind = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterInsert = ['convertDatesToUTCISO'];
|
|
||||||
protected $afterUpdate = ['convertDatesToUTCISO'];
|
|
||||||
|
|
||||||
public function getValueSets($param = null) {
|
public function getValueSets($param = null) {
|
||||||
if ($param !== null) {
|
if ($param !== null) {
|
||||||
$builder = $this->builder();
|
$rows = $this->groupStart()
|
||||||
$builder->groupStart()
|
|
||||||
->like('VValue', $param, 'both')
|
->like('VValue', $param, 'both')
|
||||||
->orlike('VDesc', $param, 'both')
|
->orlike('VDesc', $param, 'both')
|
||||||
->groupEnd();
|
->groupEnd()->findAll();
|
||||||
$rows = $builder->get()->getResultArray();
|
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
} else {
|
} else {
|
||||||
return $this->findAll();
|
return $this->findAll();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user