<?php
namespace Modules\Invoices\Cashings\Management;

class View_Options extends \App\Mvc\View_Popup_PaginatedListing_OptionsAbstract
{
	/**
	 * (non-PHPdoc)
	 * @see \App\Mvc\View_Window_PaginatedListing_OptionsAbstract::populateDefinedOptions()
	 */
	public function populateDefinedOptions(\App\Mvc\View\Utils\RowOptions\Container\Simple $options)
	{
		$options
			// insert
			->append(\App\Mvc\View\Utils\RowOptions\Option\Popup\Insert::create("insert")
				->setDescription($this->lang['index']['options']['buttons']['insert'])
				->setDimensions(750, 580)
				->addParamFromJs('idInvoice', '$F(\'idInvoice\')')
			)
			// manage documents
			->append(\App\Mvc\View\Utils\RowOptions\Option\Popup\ManageDocuments::createWithPivot('issue', 'cashing')
				->setDescription($this->lang['index']['options']['buttons']['issue'])
			)
			->append(\App\Mvc\View\Utils\RowOptions\Container\OptionEmulator::create()
				// block
				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create('block')
					->setIcon('lock')
					->setDescription($this->lang['index']['options']['buttons']['block'])
					->setJsCallback('MVC.listing.installedHandlers.listing.blockCurrentWithConfirmation(this)')
				)
				// unblock
				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create('unblock')
					->setIcon('unlock')
					->setDescription($this->lang['index']['options']['buttons']['unblock'])
					->setJsCallback('MVC.listing.installedHandlers.listing.unblockCurrentWithConfirmation(this)')
				)
			)
			// update
			->append(\App\Mvc\View\Utils\RowOptions\Option\Popup\Update::create("update")
				->setDescription($this->lang['index']['options']['buttons']['update'])
				->setDimensions(750, 550)
			)
			// cancel
			->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create("cancel")
				->setIcon('delete')
				->setModule('Modules/Invoices/Cashings/Management/Cancel')
				->setAction('index')
				->setKeyForCurrentRow('id[]')
				->setDescription($this->lang['index']['options']['buttons']['void'])
				->setDimensions(700, 300)
			)

			// bulk options // TODO: refactor this
			->append(\App\Mvc\View\Utils\RowOptions\Container\OptionEmulator::create()
				->setSection('bulk')
				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create("block")
					->setDescription($this->lang['index']['options']['buttons']['block'])
					->setIcon("lock")
					->setJsCallback("MVC.listing.installedHandlers.listing.blockSelectedWithConfirmation(this);")
				)
				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create("unblock")
					->setDescription($this->lang['index']['options']['buttons']['unblock'])
					->setIcon('unlock')
					->setJsCallback("MVC.listing.installedHandlers.listing.unblockSelectedWithConfirmation(this);")
				)
			)
			->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create("cancelBulk")
				->setSection('bulk')
				->setIcon('delete')
				->setModule('Modules/Invoices/Cashings/Management/Cancel')
				->setAction('index')
				->setKeyForSelectedRows('id')
				->setDescription($this->lang['index']['options']['buttons']['cancelBulk'])
				->setDimensions(700, 300)
			)
		;

		// more insert options, used by plugins to insert their buttons here
		$cashingInsertGroup = \App\Mvc\View\Utils\RowOptions\Container\OptionsMenu::create("cashingInsertOptions");
		$cashingInsertGroup->setSection('global');
		$cashingInsertGroup->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create("transferToCredit")
			->setLabel($this->lang['index']['options']['buttons']['transferToCredit'])
			->setDimensions(500, 400)
			->setIcon("cashing")
			->setModule('Modules/Invoices/Cashings/Management/TransferToCredit')
			->setAction("index")
			->addParamFromJs('idInvoice', '$F(\'idInvoice\')')
		);

		$options->append($cashingInsertGroup);
	}
}
