{include file='form_ajax_list_input.inc.tpl'}

<script language="javascript" type="text/javascript">
{literal}

// ZUSATZ ZUM NORMALEM JS FORMCHECK
function validate_form_addon(dom){
	var alert_str = '';
	// WENN TRANSPORTART LUFTFRACHT, DANN PRUEFEN OB TRANSPORTCODE ALPHANUMERISCH
	// IM FORMAT AAA-
	if(dom.elements['transport_types_id'].value != 1){
	    if(dom.elements['start_transport_location'].value.length < 3){
		if(alert_str.length > 0) alert_str += '<br /><br />';
		alert_str += YES_JS_ERROR_START_TRANSPORT_LOCATION;
	    }
	    if(dom.elements['end_transport_location'].value.length < 3){
		if(alert_str.length > 0) alert_str += '<br /><br />';
		alert_str += YES_JS_ERROR_END_TRANSPORT_LOCATION;
	    }
	}
	if(alert_str.length > 0)
		return "<br /><br />"+alert_str;
	else
		return '';
}

var counter = 0;

/**** DEACTIVE *****
function delFieldsCollies(){
	counter--;
	collie_writenode_child = $('dbfdivdepth');
	collie_writenode = collie_writenode_child.parentNode;
	dom = document.forms['exports'];
	dom.removeChild(collie_writenode);
}
function moreFieldsCollies() {
	counter++;
	var newFields = document.getElementById('collies_readroot').cloneNode(true);
	newFields.id = '';
	newFields.style.display = 'block';
	var newField = newFields.childNodes;
	for (var i=0;i<newField.length;i++) {
		var theName = newField[i].name
		if (theName)
			newField[i].name = theName + counter;
	}
	var insertHere = document.getElementById('collies_writeroot');
	insertHere.parentNode.insertBefore(newFields,insertHere);
}
**********************/

var ccounter = 1;
function moreFieldsCosts() {
	ccounter++;
	var newFields = document.getElementById('costs_readroot').cloneNode(true);
	newFields.id = '';
	newFields.style.display = 'block';
	var newField = newFields.childNodes;
	for (var i=0;i<newField.length;i++) {
		var theName = newField[i].name
		if (theName)
			newField[i].name = theName + counter;
	}
	var insertHere = document.getElementById('costs_writeroot');
	insertHere.parentNode.insertBefore(newFields,insertHere);
}

/**** DEACTIVE *****
function _collie_handler(field_instance){
	if(field_instance.value > counter){
		add = field_instance.value - counter;
		for(i=0;i<add;i++){
			moreFieldsCollies();
		}
	}else if(counter > field_instance.value) {
		rem = counter - field_instance.value;
		for(i=0;i<rem;i++){
			delFieldsCollies();
		}
	}
}
*******************/

function _page_load(){
{/literal}
{if $mode != 'add'}
{literal}
	el = document.forms['exports'].elements['recipient_id'];
	ajax_update_dropdown(el,'dbfdivfieldrecipient_contact_id','recipient_contact_id','exports','yes_get_company_customers');
	{/literal}
	{foreach from=$fields item=field}
		{if $field.name == 'recipient_contact_id' and $field.value != ''}
	document.forms['exports'].elements['recipient_contact_id'].value = '{$field.value}';
		{/if}
	{/foreach}
{literal}
	el = document.forms['exports'].elements['agent_id'];
	ajax_update_dropdown(el,'dbfdivfieldagent_contact_id','agent_contact_id','exports','yes_get_company_customers');
	{/literal}
	{foreach from=$fields item=field}
		{if $field.name == 'agent_contact_id' and $field.value != ''}
	document.forms['exports'].elements['agent_contact_id'].value = '{$field.value}';
		{/if}
	{/foreach}
{/if}

{if $MODE == 'add'}
	// kollis
	/**** DEACTIVE *****
	c = document.forms['exports'].vpe.value;
	{literal}
	for(i=0;i<c;i++){
		moreFieldsCollies();
	}
	{/literal}
	*******************/
	// costs
	moreFieldsCosts();
{/if}
	processDBF_DISPLAY(); // SHOW/HIDE RELATIONS
	
	{literal}
}

window.onload = _page_load;

{/literal}
</script>

{if $MODE != 'view'}

{include file='form_validator_view.inc.tpl'}

{/if}



{if $PAGE_MENU}
<div style="padding:8px;padding-left:0px;">{$PAGE_MENU}</div>
{/if}

{if $PAGE_TITLE}
<h3>{$PAGE_TITLE}</h3>
{/if}

{if $MODE != 'view'}


{if $FORM_INPUT_ERRORS}<span class="dbFormError">{$FORM_INPUT_ERRORS}</span>{/if}

<div id="dbform_div">
{$FORM}{$action}
	<div id="dbform_head">{$REQUIRED_INTRO}</div>
	<div id="dbform_row_subgroup">
	{$SUBGROUP_MAIN}
	</div>
{foreach from=$fields item=field}
	{if $field.index and $MODE != 'add'}
		{$field.input}
	{/if}

	{if $field.group_id == 'main'}
	
		{include file='form_field.inc.tpl'}
	
	{/if}
	
{/foreach}

{* SCHIFFSDATEN - NUR IM ADD MODE *}
{if $MODE == 'add'}

	<div id="dbform_row_subgroup">
	{$SUBGROUP_SHIPPER}
	</div>

{foreach from=$fields item=field}
		{if $field.group_id == 'sub1'}
		
			{include file='form_field.inc.tpl'}
	
		{/if}
	
{/foreach}

{/if}

{* ERWEITERBARE KOLLIES - NUR IM ADD MODE *}
{***** INAKTIV
{if $MODE == 'add'}
<span id="collies_writeroot"></span>
{/if}
*******}




{* ERWEITERBARE KOSTEN - NUR IM ADD MODE *}
{if $MODE == 'add'}
	<div id="dbform_row_subgroup">
	{$SUBGROUP_COSTS}
	</div>

<span id="costs_writeroot"></span>
<input class="dbforminput" type="button" id="more_fields" value="{$TEXT_ADD_ENTRY}" onclick="moreFieldsCosts();" />
{/if}


	<div id="dbform_row_save">{$SAVE_BUTTON}</div>
	<div id="dbform_head" style="width:1000px;">{$REQUIRED_INTRO}</div>
</form>
</div>

{*

ERWEITERBARE KOSTEN - NUR IM ADD MODE

*}

{if $MODE == 'add'}

<div id="costs_readroot" style="display:none;">

{foreach from=$fields item=field}
		{if $field.group_id == 'sub3'}

			{include file='form_field.inc.tpl'}

		{/if}
	
{/foreach}
	<input class="dbforminput" type="button" id="remove_field" value="{$TEXT_REMOVE_ENTRY}" onclick="this.parentNode.parentNode.removeChild(this.parentNode);" />
</div>

{/if}


{*

ERWEITERBARE KOLLIES - NUR IM ADD MODE

*}

{***** INAKTIV
{if $MODE == 'add'}

<div id="collies_readroot" style="display:none;">
	<div id="dbform_row_subgroup">
	{$SUBGROUP_COLLIES}
	</div>

{foreach from=$fields item=field}
		{if $field.group_id == 'sub2'}

			{include file='form_field.inc.tpl'}

		{/if}
	
{/foreach}
</div>

{/if}
**********}


{*
/*---------------------------------------------------------------------------
END IF NOT VIEW MODE
---------------------------------------------------------------------------*/
*}

{else}

{*
/*---------------------------------------------------------------------------
START VIEW MODE
---------------------------------------------------------------------------*/
*}
<table class="dbFormTable" cellspacing="0">

{foreach from=$fields item=field key=k}
	{if $field.type != 'hidden' and !$field.index}
<tr class="dbFormRow">
	<td class="dbFormContentTitle" valign="top"><b>{if $field.title != ''}{$field.title}{else}{$field.name}{/if}</b></td>
	<td class="dbFormContentValue" valign="top">
		{if $field.type == 'datetime'}
			{$field.value|date_format:"$date_format"}
		{else}
			{$field.value}
		{/if}
		&nbsp;
	</td>
</tr>
	{/if}
	
{/foreach}
</table>

{*
/*---------------------------------------------------------------------------
END VIEW MODE
---------------------------------------------------------------------------*/
*}
{/if}

