<?php
namespace Modules\Admin\AutoProcessRules;

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

			// INSERT ACTION
			->append(\App\Mvc\View\Utils\RowOptions\Option\Popup\Insert::create('insert')
				->setDescription($this->lang['index']['options']['buttons']['insert'])
				->setDimensions(880,700)
			)

			// logs
			->append(\App\Mvc\View\Utils\RowOptions\Option\Window::create("filterLogs")
				->setDescription($this->lang['index']['options']['buttons']['filterLogs'])
				->setIcon("filter")
				->setModule('Modules/Admin/AutoProcessRulesLogs')
				->setAction('index')
				->addParamFromJs('filters[idRule]', "MVC.listing.installedHandlers.listing.getItemId(this)")
				->addParam('listing[paramsSlot]', 1)
				->resetWindowListing()
				->setOpenInNewTab(true)
			)

			// separator
			->append(\App\Mvc\View\Utils\RowOptions\Option\Separator::create('separator1'))

			// ACTIVATE/DEACTIVATE ONE ITEM
			->append(\App\Mvc\View\Utils\RowOptions\Container\OptionEmulator::create()
				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create("deactivate")
					->setIcon('lock')
					->setDescription($this->lang['index']['options']['buttons']['deactivate'])
					->setJsCallback("MVC.listing.installedHandlers.listing.deactivateCurrent(this);")
				)
				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create("activate")
					->setIcon('unlock')
					->setDescription($this->lang['index']['options']['buttons']['activate'])
					->setJsCallback("MVC.listing.installedHandlers.listing.activateCurrent(this);")
				)
			)

			// UPDATE ACTION ///////////////////////////////////////////////////////////////////////////
			->append( \App\Mvc\View\Utils\RowOptions\Option\Popup\Update::create("update")
				->setDescription($this->lang['index']['options']['buttons']['update'])
				->setDimensions(880, 700)
			)

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

				->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create("execute")
					->setLabel($this->lang['index']['options']['buttons']['execute'])
					->setIcon("play")
					->setModule('Modules/Admin/AutoProcessRules/Execute')->setAction('index')
					->setDimensions(550, 400)
					->setKeyForCurrentRow('id')
				)

				->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create("duplicate")
					->setLabel($this->lang['index']['options']['buttons']['duplicate'])
					->setIcon("clone")
					->setAction("duplicate")
					->setDimensions(880, 700)
					->setKeyForCurrentRow('idDuplicatedRule')
				)

				->append(\App\Mvc\View\Utils\RowOptions\Option\Delete::create("delete")
					->setLabel($this->lang['index']['options']['buttons']['delete'])
				)
			)

			// ACTIVATE/DEACTIVATE MULTIPLE ITEMS
			->append(\App\Mvc\View\Utils\RowOptions\Container\OptionEmulator::create()
				->setSection('bulk')
				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create("deactivate")
					->setIcon('lock')
					->setDescription($this->lang['index']['options']['buttons']['deactivate'])
					->setJsCallback("MVC.listing.installedHandlers.listing.deactivateSelectedWithConfirmation(this);")
				)
				->append(\App\Mvc\View\Utils\RowOptions\Option\Option::create("activate")
					->setIcon('unlock')
					->setDescription($this->lang['index']['options']['buttons']['activate'])
					->setJsCallback("MVC.listing.installedHandlers.listing.activateSelectedWithConfirmation(this);")
				)
			)


			// BULK UPDATE
			->append(\App\Mvc\View\Utils\RowOptions\Container\OptionEmulator::create()
				->setSection('bulk')

				// process imported services
				->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create('processImportedServices')
					->setDescription($this->lang['index']['options']['buttons']['bulkUpdate'])
					->setIcon("edit2")
					->setModule('Modules/Admin/AutoProcessRules/BulkUpdate/ProcessImportedServices')
					->setAction('index')
					->addParamFromJs('rulesIds', "MVC.listing.installedHandlers.listing.getSelectedIds(this)")
					->setDimensions(550, 600)
				)

				// issue invoice
				->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create('issueInvoice')
					->setDescription($this->lang['index']['options']['buttons']['bulkUpdate'])
					->setIcon("edit2")
					->setModule('Modules/Admin/AutoProcessRules/BulkUpdate/InvoiceIssue')
					->setAction('index')
					->addParamFromJs('rulesIds', "MVC.listing.installedHandlers.listing.getSelectedIds(this)")
					->setDimensions(550, 600)
				)

				// cumulate invoice
				->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create('cumulateInvoice')
					->setDescription($this->lang['index']['options']['buttons']['bulkUpdate'])
					->setIcon("edit2")
					->setModule('Modules/Admin/AutoProcessRules/BulkUpdate/InvoiceCumulate')
					->setAction('index')
					->addParamFromJs('rulesIds', "MVC.listing.installedHandlers.listing.getSelectedIds(this)")
					->setDimensions(550, 600)
				)

				// add invoice
				->append(\App\Mvc\View\Utils\RowOptions\Option\Popup::create('addInvoice')
					->setDescription($this->lang['index']['options']['buttons']['bulkUpdate'])
					->setIcon("edit2")
					->setModule('Modules/Admin/AutoProcessRules/BulkUpdate/InvoiceInsert')
					->setAction('index')
					->addParamFromJs('rulesIds', "MVC.listing.installedHandlers.listing.getSelectedIds(this)")
					->setDimensions(550, 600)
				)
			)

			// DELETE MULTIPLE ITEMS
			->append(\App\Mvc\View\Utils\RowOptions\Option\DeleteSelected::create("delete")
				->setDescription($this->lang['index']['options']['description']['delete'])
			)
		;
	}
}