
{* --------------------------------------------------------------------------------------------- *}
{* ---------- PIVOT TABLE TITLE / DELETE OPTION ------------------------------------------------ *}
{* --------------------------------------------------------------------------------------------- *}
<div>

	<a href="#;" style="float:right" class="link"
		onclick="ajaxIframe('pivotsListDiv', 'index_load_pivotTables_pivotsList.php?delPivot={$pivotKey}');"
	>{$_LANG.reportsManagement.admin.pivots.deletePivotButton}</a>

	<div class="pivotTableBox_title">{$_LANG.reportsManagement.admin.pivots.pivotSubtitle} {if $pivotDetails.n} ({$pivotDetails.n}){/if}</div>

</div>

{* --------------------------------------------------------------------------------------------- *}
{* ---------- MANAGE CURRENT PIVOT TABLE ROWS/COLS/DATA ---------------------------------------- *}
{* --------------------------------------------------------------------------------------------- *}
<table class="list" width="100%" style="margin-bottom:3px;">
	<tr>
		<th width="33%">
			<a class="icon-reportRows" ></a>
			{$_LANG.reportsManagement.admin.pivots.th.rows}
		</th>
		<th width="33%">
			<a class="icon-reportColumns" ></a>
			{$_LANG.reportsManagement.admin.pivots.th.cols}
		</th>
		<th width="34%">
			<a class="icon-reportData" ></a>
			{$_LANG.reportsManagement.admin.pivots.th.data}
		</th>
	</tr>
	<tr>

		{* --- ROWS LIST --- *}
		<td>
			{foreach name=rowsListForeach from=$pivotDetails.rows item=nothing key=colKey}
				<div class="columnDisplay">
					&bull;
					<a href="#;" class="columnOptions"
						onclick=" overlib($('columnOptions_rows_{$colKey}').innerHTML, RIGHT,  BELOW, WIDTH, 200, STICKY, MOUSEOFF, 600); "
					>{$columnsTranslations[$colKey]}</a>
				</div>

				<div id="columnOptions_rows_{$colKey}" style="display: none">
					{if !$smarty.foreach.rowsListForeach.first}
						<a class="menuOption" href="#;"
							onclick="
								ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=rows&column={$colKey}&operation=moveUp', $('mainForm').serialize(true) );
								nd();nd();
							"
						><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-arrowsUp" /> {$_LANG.reportsManagement.admin.pivots.operations.moveUp}</a>
					{/if}
					{if !$smarty.foreach.rowsListForeach.last}
						<a class="menuOption" href="#;"
							onclick="
								ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=rows&column={$colKey}&operation=moveDown', $('mainForm').serialize(true) );
								nd();nd();
							"
						><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-arrowsDown" /> {$_LANG.reportsManagement.admin.pivots.operations.moveDown}</a>
					{/if}
					<a class="menuOption" href="#;"
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=rows&column={$colKey}&operation=moveToCols', $('mainForm').serialize(true) );
							nd();nd();
						"
					><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-reportColumns" /> {$_LANG.reportsManagement.admin.pivots.operations.moveToCols}</a>
					<hr class="menuOption_delimiter" />

					<a class="menuOption" href="#;"
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=rows&column={$colKey}&operation=delete', $('mainForm').serialize(true) );
							nd();nd();
						"
					><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-delete" /> {$_LANG.reportsManagement.admin.pivots.operations.delete}</a>

				</div>
			{foreachelse}
				<div class="noFieldChosen">{$_LANG.reportsManagement.admin.pivots.operations.noFields}</div>
			{/foreach}

		</td>

		{* --- COLS LIST --- *}
		<td>
			{foreach name=colsListForeach from=$pivotDetails.cols item=nothing key=colKey}
				<div class="columnDisplay">
					&bull;
					<a href="#;" class="columnOptions"
						onclick=" overlib($('columnOptions_cols_{$colKey}').innerHTML, RIGHT,  BELOW, WIDTH, 200, STICKY, MOUSEOFF, 600); "
					>{$columnsTranslations[$colKey]}</a>
				</div>

				<div id="columnOptions_cols_{$colKey}" style="display: none">
					{if !$smarty.foreach.colsListForeach.first}
						<a class="menuOption" href="#;"
							onclick="
								ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=cols&column={$colKey}&operation=moveUp', $('mainForm').serialize(true) );
								nd();nd();
							"
						><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-arrowsUp" /> {$_LANG.reportsManagement.admin.pivots.operations.moveUp}</a>
					{/if}
					{if !$smarty.foreach.colsListForeach.last}
						<a class="menuOption" href="#;"
							onclick="
								ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=cols&column={$colKey}&operation=moveDown', $('mainForm').serialize(true) );
								nd();nd();
							"
						><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-arrowsDown" /> {$_LANG.reportsManagement.admin.pivots.operations.moveDown}</a>
					{/if}
					<a class="menuOption" href="#;"
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=cols&column={$colKey}&operation=moveToRows', $('mainForm').serialize(true) );
							nd();nd();
						"
					><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-reportRows" /> {$_LANG.reportsManagement.admin.pivots.operations.moveToRows}</a>
					<hr class="menuOption_delimiter" />

					<a class="menuOption" href="#;"
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=cols&column={$colKey}&operation=delete', $('mainForm').serialize(true) );
							nd();nd();
						"
					><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-delete" /> {$_LANG.reportsManagement.admin.pivots.operations.delete}</a>

				</div>
			{foreachelse}
				<div class="noFieldChosen">{$_LANG.reportsManagement.admin.pivots.operations.noFields}</div>
			{/foreach}
		</td>

		{* --- DATA LIST --- *}
		<td>
			{foreach name=dataListForeach from=$pivotDetails.data item=operation key=colKey}

				{* visible links *}
				<div class="columnDisplay">
					&bull;
					<a href="#;" class="columnOptions"
						onclick=" overlib($('columnOptions_data_{$colKey}').innerHTML, RIGHT,  BELOW, WIDTH, 200, STICKY, MOUSEOFF, 600); "
					>{$columnsTranslations[$colKey]}</a>

					<a href="#;" class="columnOperation"
						onclick=" overlib($('columnOperations_data_{$colKey}').innerHTML, RIGHT,  BELOW, WIDTH, 200, STICKY, MOUSEOFF, 600); "
					>[{$_LANG.reportsManagement.pivotTables.operations[$operation]}]</a>

				</div>

				{* field options *}
				<div id="columnOptions_data_{$colKey}" style="display: none">
					{if !$smarty.foreach.dataListForeach.first}
						<a class="menuOption" href="#;"
							onclick="
								ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=data&column={$colKey}&operation=moveUp', $('mainForm').serialize(true) );
								nd();nd();
							"
						><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-arrowsUp" />{$_LANG.reportsManagement.admin.pivots.operations.moveUp}</a>
					{/if}
					{if !$smarty.foreach.dataListForeach.last}
						<a class="menuOption" href="#;"
							onclick="
								ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=data&column={$colKey}&operation=moveDown', $('mainForm').serialize(true) );
								nd();nd();
							"
						><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-arrowsDown" /> {$_LANG.reportsManagement.admin.pivots.operations.moveDown}</a>
					{/if}
					{if !$smarty.foreach.dataListForeach.first or !$smarty.foreach.dataListForeach.last}
						<hr class="menuOption_delimiter" />
					{/if}

					<a class="menuOption" href="#;"
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=data&column={$colKey}&operation=delete', $('mainForm').serialize(true) );
							nd();nd();
						"
					><img src="{$smarty.const.SMARTY_BLANKGIF}" alt="" align="absmiddle" class="imgIcon icon-delete" /> {$_LANG.reportsManagement.admin.pivots.operations.delete}</a>

				</div>

				{* field operations *}
				<div id="columnOperations_data_{$colKey}" style="display:none">
					<a href="#;" {if $operation=="cnt"}class="menuOption bold"{else}class="menuOption"{/if}
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=data&column={$colKey}&formula=cnt', $('mainForm').serialize(true) );
							nd();nd();
						"
					>{$_LANG.reportsManagement.pivotTables.operations.cnt}</a>
					<a href="#;" {if $operation=="dst"}class="menuOption bold"{else}class="menuOption"{/if}
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=data&column={$colKey}&formula=dst', $('mainForm').serialize(true) );
							nd();nd();
						"
					>{$_LANG.reportsManagement.pivotTables.operations.dst}</a>
					<a href="#;" {if $operation=="sum"}class="menuOption bold"{else}class="menuOption"{/if}
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=data&column={$colKey}&formula=sum', $('mainForm').serialize(true) );
							nd();nd();
						"
					>{$_LANG.reportsManagement.pivotTables.operations.sum}</a>
					<a href="#;" {if $operation=="avg"}class="menuOption bold"{else}class="menuOption"{/if}
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=data&column={$colKey}&formula=avg', $('mainForm').serialize(true) );
							nd();nd();
						"
					>{$_LANG.reportsManagement.pivotTables.operations.avg}</a>
					<a href="#;" {if $operation=="max"}class="menuOption bold"{else}class="menuOption"{/if}
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=data&column={$colKey}&formula=max', $('mainForm').serialize(true) );
							nd();nd();
						"
					>{$_LANG.reportsManagement.pivotTables.operations.max}</a>
					<a href="#;" {if $operation=="min"}class="menuOption bold"{else}class="menuOption"{/if}
						onclick="
							ajaxIframe('pivotTable_{$pivotKey}', 'index_load_pivotTables_pivotUpdate.php?zone=data&column={$colKey}&formula=min', $('mainForm').serialize(true) );
							nd();nd();
						"
					>{$_LANG.reportsManagement.pivotTables.operations.min}</a>
				</div>

			{foreachelse}
				<div class="noFieldChosen">{$_LANG.reportsManagement.admin.pivots.operations.noFields}</div>
			{/foreach}
		</td>

	</tr>
</table>



{* --------------------------------------------------------------------------------------------- *}
{* ---------- MANAGE CURRENT PIVOT TABLE NAME -------------------------------------------------- *}
{* --------------------------------------------------------------------------------------------- *}
<div>

	<div id="pivotDetailsShow" style="height:12px;{if $pivotDetails.det}display:none{/if}">
		<a href="#;"
			class="icon-arrowsDown"
			onclick="$('pivotDetailsShow').hide();$('pivotTableHide').show();$('showDetailsFlag').value='1'; return false;"
			tooltip="{$_LANG.reportsManagement.admin.pivots.operations.showPivotDetails}"
		></a>
	</div>

	<div id="pivotTableHide" class="pivotTableDetailsDiv" {if !$pivotDetails.det}style="display:none"{/if}>
		<a href="#;"
			class="icon-arrowsUp"
			onclick="$('pivotDetailsShow').show();$('pivotTableHide').hide();$('showDetailsFlag').value='0'; return false;"
			tooltip="{$_LANG.reportsManagement.admin.pivots.operations.hidePivotDetails}"
		></a>

		<div>
			{$_LANG.reportsManagement.admin.pivots.pivotNameField}: <input id="pivotTableName" name="pivotName" type="text" value="{$pivotDetails.n}" style="width:130px" maxlength="250" />
			&nbsp; &nbsp;
			<label for="selectedPivotTable">{$_LANG.reportsManagement.admin.pivots.selectedField}</label> <input id="selectedPivotTable" type="checkbox" class="noBorder" name="selected" value="1" {if $pivotDetails.s}checked="1"{/if} />
			&nbsp; &nbsp;
			<label for="visiblePivotTable">{$_LANG.reportsManagement.admin.pivots.visibleField}</label> <input id="visiblePivotTable" type="checkbox" class="noBorder" name="visible" value="1" {if $pivotDetails.v}checked="1"{/if} />
		</div>

		<div>
			{$_LANG.reportsManagement.admin.pivots.exportFileField}: &nbsp;
			{$_LANG.reportsManagement.admin.pivots.fileFormatField}:
			<select size="1" name="format" style="width:90px;"
				onchange="
					{foreach from=$defaultFileExtension key=format item=ext}
						if (this.value=='{$format}') $('extensionField').value='{$ext}';
					{/foreach}
				"
			>
				{foreach from=$pivotTablesExportFileFormats key=format item=active}
					{if $active}
						<option value="{$format}" {if $pivotDetails.format==$format}selected="1"{/if}>{$_LANG.reportsManagement.pivotTables.formats[$format]}</option>
					{/if}
				{/foreach}
			</select>
			&nbsp;
			{$_LANG.reportsManagement.admin.pivots.fileExtField}:
			<input type="text" id="extensionField" name="extension" value="{$pivotDetails.ext}" style="width:80px" maxlength="10" />

		</div>

		<div>
			{$_LANG.reportsManagement.admin.pivots.styleField}:
			<select size="1" name="style" style="width:200px">
				{foreach from=$pivotTablesStyles key=style item=active}
					{if $active}
						<option value="{$style}" {if $pivotDetails.style==$style}selected="1"{/if}>{$_LANG.reportsManagement.pivotTables.styles[$style]}</option>
					{/if}
				{/foreach}
			</select>
		</div>

		<div class="pivotTotalsDiv">
			<a href="#;" class="totalsLink"
				onclick="
					overlib('{$_LANG.loading}', FIXX, $(this).getLeft()-150, FIXY, $(this).getTop()+20, STICKY, WIDTH, 550);
					overlibAjax('pivotTable_displayTotals.php', FIXX, $(this).getLeft()-150, FIXY, $(this).getTop()+20, STICKY, WIDTH, 550);
				"
			>{$_LANG.reportsManagement.admin.pivots.setupTotals}</a>
		</div>

		<input id="showDetailsFlag" type="hidden" name="showDetails" value="{$pivotDetails.det}" />

	</div>
</div>
