<?php
 namespace Modules\Partners\Customers; class Model extends \App\Mvc\Model_ListingAbstract { public function list_execute(\App\Mvc\View\Listing\Members\Params $listingParams) { $filters = $listingParams->getFilters(); $listObj = new \App\EntityList\Customers(); $listObj->setColumns(['cust.idCorporate', 'cust.locked', 'cust.firstName', 'cust.middleName', 'cust.lastName', 'cust.lastName2', 'cust.middleName2', 'cust.firstName2', 'cust.lastName AS name', 'cust.flag', 'cust.title', 'cust.type', 'cust.PNC', 'cust.email', 'cust.telephone', 'cust.telephoneMobile', 'cust.fax', 'cust.idAddUser', 'cust.addTime', 'cust.idRealCustomer', 'cust.lastUpdateTime', 'cust.idUpdateUser']); if (isset($filters['clientType'])) { if ($filters['clientType']=='withoutCompany') { $listObj->setFilter('cust.`idCorporate`', '=', '0'); } elseif ($filters['clientType']=='withCompany') { $listObj->setFilter('idCorporate', '!=', '0'); } } if ($filters['corporate']??null and $filters['corporate']['id']??null) { $listObj->setFilter('cust.`idCorporate`', '=', $filters['corporate']['id']); } if ($filters['passportNumber']??null) { $listObj->setFilter('cp.`number`', 'LIKE', $filters['passportNumber']); } if ($filters['telephone']??null) { $listObj->setCustomFilter("cust.`telephone` LIKE ? OR cust.`telephoneMobile` LIKE ?", [$filters['telephone'], $filters['telephone']]); } if ($filters['email']??null) { $listObj->setFilter('cust.email', 'LIKE', $filters['email']); } if ($filters['PNC']??null) { $listObj->setFilter('cust.PNC', 'LIKE', $filters['PNC']); } if ($filters['idCustomer']) { $listObj->setFilter('cust.id', '=', $filters['idCustomer']); } if ($filters['lastName']??null) { $listObj->setCustomFilter("cust.`lastName` LIKE ? OR cust.`lastName2` LIKE ?", ["{$filters['lastName']}%", "{$filters['lastName']}%"]); } if ($filters['firstName']??null) { $listObj->setCustomFilter("cust.`firstName` LIKE ? OR cust.`firstName2` LIKE ?", ["{$filters['firstName']}%", "{$filters['firstName']}%"]); } if (isset($filters['duplicatedPassengers'])) { if ($filters['duplicatedPassengers'] == "duplicated") { $listObj->setFilter('cust.`idRealCustomer`', '!=', '0'); } if ($filters['duplicatedPassengers'] == "notDuplicated") { $listObj->setFilter('cust.`idRealCustomer`', '=', '0'); } } if (isset($filters['blockedPassengers'])) { if ($filters['blockedPassengers'] == "blocked") { $listObj->setFilter('cust.`locked`', '!=', '0'); } if ($filters['blockedPassengers'] == "notBlocked") { $listObj->setFilter('cust.`locked`', '=', '0'); } } if ($filters['idGdsProfileTemplate']??null) { $listObj->setFilter('cust.idGdsProfileTemplate', '=', $filters['idGdsProfileTemplate']); } $listObj = $this->entityList_inheritListingParams($listingParams, $listObj); $this->recordsList = $listObj->exportRecords(); $this->totalRecordsCount = $listObj->getRecordsCount(); } } 