{extends file=$smarty.const.SMARTY_LAYOUT_MAIN_GENERAL_PAGINATED_LISTING}

{block name="template-head" append}
	{$CSS->load("_layout/{$smarty.const.THEME}/styles/orders/ordersList/index.css")}

	{$JS->loadGroup("remoteHtmlView")}
	{$CSS->loadGroup("remoteHtmlView")}

	{$CSS->load("_layout/{$smarty.const.THEME}/quickNavigation/index.css")}
{/block}

{block name="js" append}

	<script type="text/javascript">

		MVC.pageRefresh = function (module, action, windowName, execOutput) {
			if (module=='Invoices/SupplierInvoices/Management') {
				return;
			}

			MVC.reloadPage();
		}

		MVC.scheduleOnLoad(function(){
			$('listingContainer').observe('listing:initialize', function(evt) {
				var listing = evt.memo.listing;

				// show/hide
				listing.elements.container.on('click', 'a.showServiceDetails', function(evt) {
					this.showServiceDetails(evt.element());
				}.bind(listing));

				// service offer
				listing.elements.container.on('click', 'li.serviceOffer', function(evt) {
					this.servOfferOption(evt.element());
				}.bind(listing));
			});

			// show hide services details
			MVC.listing.prototype.showServiceDetails = function(element) {

				 var trSelected = element.up('table.engine-listing tbody tr');

				 trSelected.setConditionedClassNames(trSelected.hasClassName('serviceDetails-invisible'), 'serviceDetails-visible', 'serviceDetails-invisible');
			}

			// service offer option
			MVC.listing.prototype.servOfferOption = function(element) {
				var idService = element.up('div[data-idService]').readAttribute('data-idService');

				window.location ='{$APP_URL}reservations/serviceOffers/?idService='+idService;
			}

		});
	</script>
{/block}
