<?php
namespace Modules\Admin\Config\Gds\Profiles\Templates;

class Model extends \App\Mvc\Model_ListingAbstract
{

	/**
	 * (non-PHPdoc)
	 * @see \App\Mvc\Model_ListingAbstract::list_execute()
	 */
	public function list_execute(\App\Mvc\View\Listing\Members\Params $listingParams)
	{
		$filters = $listingParams->getFilters();

		// get the fields list
		$listObj = new \App\EntityList\GdsProfilesTemplates();
		$listObj->setColumns([
			'category', 'name', 'addTime',
		]);

		if ($filters['category']) {
			$listObj->setFilter('category', '=', $filters['category']);
		}

		if ($filters['name']) {
			$listObj->setFilter('name', 'LIKE', '%'.$filters['name'].'%');
		}

		$listObj = $this->entityList_inheritListingParams($listingParams, $listObj);

		// these must be called in this specific order
		$this->recordsList = $listObj->exportRecords();
		$this->totalRecordsCount = $listObj->getRecordsCount();
	}

}
