<table class="invoiceHeader">
	<tr>
		
		<td class="box1">
		
			<table class="headerFields">	
				<tr>
					<td>{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['headerFields']['series']}{if $invoiceCfgs['idInvoiceSeries']['mandatory']}<sup>*</sup>{/if}:</td>
					<td>
						{$inputs['series']->render()}
					</td>
				</tr>
				<tr>
					<td>
						{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['headerFields']['invDate']}<sup>*</sup>:
					</td>
					<td>
						{$inputs['invoiceDate']->render()}
					</td>
				</tr>
				<tr>
					<td>
						{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['headerFields']['dueDate']}{if $invoiceCfgs['dueDate']['mandatory']}<sup>*</sup>{/if}:
					</td>
					<td>
						{$inputs['dueDate']->render()}
					</td>
				</tr>
				<tr>
					<td>
						{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['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']['InvoiceInsert']['index']['step2']['headerFields']['temp']}:</td>
					<td>
						{$inputs['temporary']->render()}
					</td>
				</tr>						
				<tr>
					<td>{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['headerFields']['fop']}{if $inputs['formOfPayment']->getMandatory()}<sup>*</sup>{/if}:</td>
					<td>
						{$inputs['formOfPayment']->render()}
					</td>
				</tr>
				<tr>
					<td>{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['headerFields']['ba']}{if $invoiceCfgs['idBankAccount']['mandatory']}<sup>*</sup>{/if}:</td>
					<td>
						{$inputs['bankAccount']->render()}
					</td>
				</tr>
				<tr>
					<td>{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['headerFields']['respUser']}<sup>*</sup>:</td>
					<td>
						{$inputs['user']->render()}
					</td>
				</tr>
			</table>
				
		
		</td>
		
		<td class="box3">
			
			<table class="headerFields">
				<tr>
					<td>{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['headerFields']['comm']}{if $invoiceCfgs['comments']['mandatory']}<sup>*</sup>{/if}:</td>
					<td>
						{$inputs['comments']->render()}
					</td>
				</tr>						
				<tr>
					<td>{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['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']['InvoiceInsert']['index']['step2']['headerFields']['client']}<sup>*</sup>:</div>
			<select name="idClient" style="width:350px" id="idClient" onChange="clientLoadProfile()" >
				{if $clientsList['corporates']}
					<optgroup label="{$_LANG['Invoices']['InvoiceInsert']['index']['step1']['fields']['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']['InvoiceInsert']['index']['step1']['fields']['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']['InvoiceInsert']['index']['step2']['clientOptions']['corpViewTltp']}"
						onclick="
							var clientDetails = $('idClient').value.split('|');
							RemoteLoad.loadEntity(this, 'corporate', clientDetails[0])
						"
					>{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['clientOptions']['corpViewBtn']}</a>
					/
					<a href="#;" class="link"
						{if CurrentUserAccess::getInstance()->hasAccessToSection('Modules/Partners/Corporates')}
							tooltip="{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['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']['InvoiceInsert']['index']['step2']['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']['InvoiceInsert']['index']['step2']['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']['InvoiceInsert']['index']['step2']['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']['InvoiceInsert']['index']['step2']['clientOptions']['custViewTltp']}"
						onclick="
							var clientDetails = $('idClient').value.split('|');
							RemoteLoad.loadEntity(this, 'customer', clientDetails[1])
						"
					>{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['clientOptions']['custViewBtn']}</a>
					/
					<a href="#;" class="link" tooltip="{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['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']['InvoiceInsert']['index']['step2']['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']['InvoiceInsert']['index']['step2']['clientOptions']['custUpdateBtn']}</a>
				</div>
			</div>

			{* general client options *}
			<div class="clientOption">
				<a href="#;" class="link"
					{if CurrentUserAccess::getInstance()->hasAccessToOption('Modules/Orders-canAddCorporateOnOrder')}
						onclick="
							$('addNewCorporate').toggle();
							$('addNewCustomer').hide();
						"
					{else}
						tooltip="{$_LANG['noAccessToOption']}"
					{/if}
				>{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['clientOptions']['corpAdd']}</a>
				/
				<a href="#;" class="link"
					{if CurrentUserAccess::getInstance()->hasAccessToOption('Modules/Orders-canAddCustomerOnOrder')}
						onclick="
							$('addNewCorporate').hide();	
							$('addNewCustomer').toggle();
						"
					{else}
						tooltip="{$_LANG['noAccessToOption']}"
					{/if}
				>{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['clientOptions']['custAdd']}</a>
			</div>
			<div class="clientOption">
				<div id="addNewCorporate" style="display:none;">
					{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['clientOptions']['corpSel']}: {$inputs['corporateInsert']->render()}
				</div>
				<div id="addNewCustomer" style="display:none;">
					{$_LANG['Invoices']['InvoiceInsert']['index']['step2']['clientOptions']['custSel']}: {$inputs['customerInsert']->render()}
				</div>
			
			</div>			

		</td>
		
	</tr>
</table>