<table class="invoiceHeader">
	<tr>
		
		<td class="box1">
		
			<table class="headerFields">	
				<tr>
				
					<td>{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['series']}{if $invoiceCfgs['idInvoiceSeries']['mandatory']}<sup>*</sup>{/if}:</td>
					<td>
						{$inputs['series']->render()}
					</td>
				</tr> 
				<tr>
					<td>
						{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['invDate']}<sup>*</sup>:
					</td>
					<td>
						{$inputs['invoiceDate']->render()}
					</td>
				</tr>		
				<tr>
					<td>
						{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['dueDate']}{if $invoiceCfgs['dueDate']['mandatory']}<sup>*</sup>{/if}:
					</td>
					<td>
						{$inputs['dueDate']->render()}
					</td>
				</tr>
				<tr>
					<td>
						{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['ffDate']}{if $invoiceCfgs['fulfillmentDate']['mandatory']}<sup>*</sup>{/if}:
					</td>
					<td> 
						{$inputs['fulfillmentDate']->render()}
					</td>
				</tr>
			</table>
		</td>
		
		<td class="box2">
			<table class="headerFields">
				<tr>
					<td>{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['temp']}:</td>
					<td>
						{$inputs['temporary']->render()}
					</td>
				</tr>						
				<tr>
					<td>{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['fop']}{if $inputs['formOfPayment']->getMandatory()}<sup>*</sup>{/if}:</td>
					<td>
						{$inputs['formOfPayment']->render()}
					</td>
				</tr>
				<tr>
					<td>{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['ba']}{if $invoiceCfgs['idBankAccount']['mandatory']}<sup>*</sup>{/if}:</td>
					<td>
						{$inputs['bankAccount']->render()}
					</td>
				</tr>
				<tr>
					<td>{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['respUser']}<sup>*</sup>:</td>
					<td>
						{$inputs['user']->render()}
					</td>
				</tr>
			</table>		
		
		</td>
		
		<td class="box3">
			
			<table class="headerFields">
				<tr>
					<td>{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['comm']}{if $invoiceCfgs['comments']['mandatory']}<sup>*</sup>{/if}:</td>
					<td>
						{$inputs['comments']->render()}
					</td>
				</tr>						
				<tr>
					<td>{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['rm']}{if $invoiceCfgs['remarks']['mandatory']}<sup>*</sup>{/if}:</td>
					<td>
						{$inputs['remarks']->render()}
					</td>
				</tr>
			</table>
		
		</td>
		
		<td class="box4">

			{* CLIENT SELECTOR ----------------------------------------------------------------- *}

			<div>{$_LANG['Invoices']['InvoiceUpdate']['index']['headerFields']['client']}<sup>*</sup>:</div>
			<select name="idClient" style="width:350px" id="idClient" onChange="clientLoadProfile()"
				{if $invoiceEnt->invoiceClientBlocked} disabled="1" {/if} 
			>
				{if $clientsList['corporates']}
					<optgroup label="{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['client_corpCat']}" class="clientCat">
						{foreach $clientsList['corporates'] as $idCorp=>$corpName}
							<option value="{$idCorp}" 
								{if $idCorp==$clientsList['defaultCorporate']}class="owner"{else}class="normal"{/if}
								{if $idCorp==$formData['idClient']} selected="1" {/if}
							>{$corpName}</option>
						{/foreach}
					</optgroup>										
				{/if}
				{if $clientsList['customers']}
					<optgroup label="{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['client_custCat']}" class="clientCat">
						{foreach $clientsList['customers'] as $idCust=>$custName}
							<option value="{$idCust}" 
								{if $idCust==$clientsList['defaultCustomer']} class="owner" {else} class="normal" {/if}
								{if $idCust==$formData['idClient']} selected="1" {/if} 
							>{$custName}</option>
						{/foreach}
					</optgroup>
				{/if}
			</select>

			
			{* CLIENT OPTIONS ------------------------------------------------------------------ *}
			{$selectedClientDetails=$formData['idClient']|split:'|'}

			{* corporate options *}		
			
			<div id="corporateOptions" {if !$selectedClientDetails[0]}style="display:none"{/if}>
				<div class="clientOption">
					<a href="#;" class="link" tooltip="{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['corpViewTltp']}"
						onclick="
							var clientDetails = $('idClient').value.split('|');
							RemoteLoad.loadEntity(this, 'corporate', clientDetails[0])
						"
					>{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['corpViewBtn']}</a>
					/
					<a href="#;" class="link" 
						{if CurrentUserAccess::getInstance()->hasAccessToSection('Modules/Partners/Corporates')}
							tooltip="{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['corpOptionsTltp']}"
							onclick="
								var clientDetails = $('idClient').value.split('|');
								window.open(MVC.appUrl('Partners/Corporates', 'index', { 'listing[reset]': 1, 'listing[paramsSlot]': 1, 'filters[text]': clientDetails[0], 'filters[searchField]': 'corp.id', 'filters[searchMode]': 'exact' }), '_blank');	
							"
						{else}
							tooltip="{$_LANG['noAccessToOption']}"
						{/if}
					>{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['corpOptionsBtn']}</a>
				</div>
				<div class="clientOption">
					<a href="#;" class="link"
						{if CurrentUserAccess::getInstance()->hasAccessToOption('Modules/Partners/Corporates-update')}
							onclick="
								var clientDetails = $('idClient').value.split('|');
								corporateUpdate(clientDetails[0]);
							"
						{else}
							tooltip="{$_LANG['noAccessToOption']}"
						{/if}
					>{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['corpUpdateBtn']}</a>
					/
					<a href="#;" class="link"
						{if CurrentUserAccess::getInstance()->hasAccessToOption('Modules/Partners/Corporates-update')}
							onclick="
								var clientDetails = $('idClient').value.split('|');
								corporateOfficeUpdate(clientDetails[1]);
							"
						{else}
							tooltip="{$_LANG['noAccessToOption']}"
						{/if}
					>{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['corpOffUpdateBtn']}</a>
				</div>
			</div>

			{* customer options *}
	
			<div id="customerOptions" {if $selectedClientDetails[0]}style="display:none"{/if}>
				<div class="clientOption">
					<a href="#;" class="link" tooltip="{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['custViewTltp']}"
						onclick="
							var clientDetails = $('idClient').value.split('|');
							RemoteLoad.loadEntity(this, 'customer', clientDetails[1])
						"
					>{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['custViewBtn']}</a>
					/
					<a href="#;" class="link" tooltip="{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['custOptionsTltp']}"
						onclick="
							var clientDetails = $('idClient').value.split('|');
							window.open(MVC.appUrl('Partners/Customers', 'index', { 'listing[reset]': 1, 'listing[paramsSlot]': 1, 'filters[text]': clientDetails[1] }), '_blank');	
						"
					>{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['custOptionsBtn']}</a>
				</div>
				<div class="clientOption">
					<a href="#;" class="link"
						{if CurrentUserAccess::getInstance()->hasAccessToOption('Modules/Partners/Customers-update')}
							onclick="
								var clientDetails = $('idClient').value.split('|');
								customerUpdate(clientDetails[1]);
							"
						{else}
							tooltip="{$_LANG['noAccessToOption']}"
						{/if}
					>{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['custUpdateBtn']}</a>
				</div>
			</div>

			{* general client options *}
			{if !$invoiceEnt->invoiceClientBlocked}
				<div class="clientOption">
					<a href="#;" class="link"
						{if CurrentUserAccess::getInstance()->hasAccessToOption('Modules/Orders-canAddCorporateOnOrder')}
							onclick="
								$('addNewCorporate').toggle();
								$('addNewCustomer').hide();
								if ($('addNewCorporate').visible()) {
									$('idCorporateInsert_title_').focus();
								}
							"
						{else}
							tooltip="{$_LANG['noAccessToOption']}"
						{/if}
					>{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['corpAdd']}</a>
					/
					<a href="#;" class="link"
						{if CurrentUserAccess::getInstance()->hasAccessToOption('Modules/Orders-canAddCustomerOnOrder')}
							onclick="
								$('addNewCorporate').hide();	
								$('addNewCustomer').toggle();
								if ($('addNewCustomer').visible()) {
									$('idCustomerInsert_title_').focus();
								}
							"
						{else}
							tooltip="{$_LANG['noAccessToOption']}"
						{/if}
					>{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['custAdd']}</a>
				</div>
	
				<div class="clientOption">
					<div id="addNewCorporate" style="display:none;">
						{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['corpSel']}: {$inputs['corporateInsert']->render()}
					</div>
					<div id="addNewCustomer" style="display:none;">
						{$_LANG['Invoices']['InvoiceUpdate']['index']['clientOptions']['custSel']}: {$inputs['customerInsert']->render()}
					</div>
					<input type="hidden" id="addClientOnOrder" name="addClientOnOrder" value="0" />
				</div>			
			{/if}
			
		</td>
		
	</tr>
</table>