<?php
namespace Modules\Bsp\Settlement;

abstract class ModelGenerateReportAbstract
{
	/**
	 * @var \App\Mvc\View\Listing\Members\Params
	 */
	protected $listingParams = null;

	/**
	 * @var String
	 */
	protected $filename = null;


	/**
	 * Set the used listing params
	 * @param \App\Mvc\View\Listing\Members\Params $listingParams
	 * @return void
	 */
	public function setListingParams(\App\Mvc\View\Listing\Members\Params $listingParams)
	{
		$this->listingParams = $listingParams;
		return $this;
	}

	abstract public function generate($outputFile);

	protected function getBspIterator(\App\Mvc\View\Listing\Members\Params $listingParams)
	{
		$model = new Model();

		// remove pagination and orderBy
		$listingParams->setCurrentPage(0)->setResultsPerPage(15);	// don't set limits
		$listingParams->setOrderColumn('');

		// build the same iterator as the listing
		$sqlIterator = $model->buildNonPaginatedIterator($listingParams);

		$sqlIterator->setOption('queueLength', 10000);

		return $sqlIterator;
	}
}
