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

class View_Options extends \App\Mvc\View_Window_PaginatedListing_OptionsAbstract
{
	/**
	 * (non-PHPdoc)
	 * @see \App\Mvc\View_Window_PaginatedListing_OptionsAbstract::populateDefinedOptions()
	 */
	public function populateDefinedOptions(\App\Mvc\View\Utils\RowOptions\Container\Simple $options)
	{
		$options

			// block/unblock
			->append(\App\Mvc\View\Utils\RowOptions\Container\OptionEmulator::create()
				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create("block")
					->setDescription($this->lang['index']['options']['description']['block'])
					->setIcon("lock")
					->setJsCallback("MVC.listing.installedHandlers.listing.blockCurrentWithConfirmation(this);")
				)
				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create("unblock")
					->setDescription($this->lang['index']['options']['description']['unblock'])
					->setIcon('unlock')
					->setJsCallback("MVC.listing.installedHandlers.listing.unblockCurrentWithConfirmation(this);")
				)
			)

			// update
			->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create("update")
				->setIcon('edit')
				->setDescription($this->lang['index']['options']['description']['update'])
				->setModule("Modules/Invoices/Cashings/Management")
				->setAction("update")
				->setKeyForCurrentRow("id")
				->setDimensions(750, 500)
			)


			->append(\App\Mvc\View\Utils\RowOptions\Container\OptionsMenu::create("mainOptions")

				// issue
				->append(\App\Mvc\View\Utils\RowOptions\Option\Popup\ManageDocuments::createWithPivot("issue", 'cashing')
					->setLabel($this->lang['index']['options']['description']['issue'])
				)

				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create("view")
					->setLabel($this->lang['index']['options']['description']['view'])
					->setIcon('view')
					->setJsCallback("clientInvoiceView(MVC.listing.installedHandlers.listing.getItemData(this).get('invoiceId'))")
				)

				// INVOICE CASHINGS
				->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create("cashingInvoices")
					->setLabel($this->lang['index']['options']['description']['cashingInvoices'])
					->setIcon('cashing')
					->setModule('Modules/Invoices/Cashings/Management')
					->setAction('index')
					->setDimensions(950, 550)
					->addParamFromJs('filters[idInvoice]', "MVC.listing.installedHandlers.listing.getItemData(this).get('invoiceId')")
				)

				// cancel
				->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create("cancel")
					->setIcon('delete')
					->setModule('Modules/Invoices/Cashings/Management/Cancel')
					->setAction('index')
					->setKeyForCurrentRow('id[]')
					->setLabel($this->lang['index']['options']['description']['cancel'])
					->setDimensions(700, 300)
				)
			)

			->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']['description']['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']['description']['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']['description']['cancel'])
				->setDimensions(700, 300)
			)

		;

		$options->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create("documentsBulkDownload")
			->setDescription($this->lang['index']['options']['description']['bulkDownload'])
			->setIcon('export')
			->addParamFromJs('ids', "MVC.listing.installedHandlers.listing.getSelectedIds(this)")
			->setModule('Modules/Documents/BulkDownload')
			->setAction("index")
			->setSection('bulk')
			->setDimensions(800, 500)
			->addParam('pivot', 'cashing')
		);
	}
}
