Move getting collection data outside of loops

This commit is contained in:
Ramon Gutierrez 2018-02-01 15:06:56 +08:00
parent 6ea7f294c3
commit 8a2e75f999
2 changed files with 7 additions and 4 deletions

View file

@ -101,11 +101,11 @@ class CustomerController extends BaseController
->getQuery()
->getResult();
$classifications = CustomerClassification::getCollection();
// process rows
$rows = [];
foreach ($obj_rows as $orow) {
$classifications = CustomerClassification::getCollection();
// add row data
$row['id'] = $orow->getID();
$row['first_name'] = $orow->getFirstName();

View file

@ -83,6 +83,9 @@ class TicketController extends BaseController
->getQuery()
->getResult();
$ticket_statuses = TicketStatus::getCollection();
$ticket_types = TicketType::getCollection();
// process rows
$rows = [];
foreach ($obj_rows as $orow) {
@ -93,8 +96,8 @@ class TicketController extends BaseController
$row['first_name'] = $orow->getFirstName();
$row['last_name'] = $orow->getLastName();
$row['contact_num'] = $orow->getContactNumber();
$row['status'] = $orow->getStatusText();
$row['ticket_type'] = $orow->getTicketTypeText();
$row['status'] = $ticket_statuses[$orow->getStatus()];
$row['ticket_type'] = $ticket_types[$orow->getTicketType()];
// add row metadata
$row['meta'] = [