<?php


namespace App\Form\Input;

class Autocomplete_Data_OrderNumber extends \Engine\Form\Input\Autocomplete_Data_GeneralAbstract
{

	/**
	 * (non-PHPdoc)
	 * @see \Engine\Form\Input\Autocomplete_Data_GeneralAbstract::getPageResultsBulk()
	 */
	protected function getPageResultsBulk() :array
	{

		$ordersListObj = new \App\EntityList\Orders();
		$ordersListObj->applyUserRestriction(false);
		$ordersListObj->setFilter('res.reservationNumber', '=', $this->searchString);
		$ordersListObj->setFilter('res.date', '>=', \Engine\DateTime::create('-1 year')->formatDateIso());
		$ordersListObj->setColumn('res.reservationNumber');
		$ordersListObj->setOrderBy('id', 'ASC');
		$ordersListObj->setLimit($this->offset, $this->resultsCountPage);

		$return = $ordersListObj->exportRecords();
		$this->resultsCountTotal = $ordersListObj->getRecordsCount();
		return $return;

	}


	/**
	 * (non-PHPdoc)
	 * @see \Engine\Form\Input\Autocomplete_Data_GeneralAbstract::getPageResultsFormatted()
	 */
	protected function getPageResultsFormatted(Array $pageResults)
	{
		$list=[];
		foreach($pageResults as $row) {
			$list[] = $this->getCleanItem($row['id'], $row['reservationNumber']);
		}
		return $list;
	}

}