<div id="customerEditable">

<span class="moduleTitle">
    <?php
    ?>
<a class="button" href="<?php print $_SERVER['PHP_SELF'].'?mod=customers';?>"><img src="images/list_12x12.png"/></a><?php
    ?>
<!--a class="button" href="<?php print $_SERVER['PHP_SELF'].'?mod=customer&a=edit&ap='.$this->gd('customer')->id;?>"><img src="images/edit_12x12.png"/></a--><?php
    
if (((int)$this->gd('customer')->id) > 0) {
        
?><a class="button" href="<?php print $_SERVER['PHP_SELF'].'?mod=customer&ap='.$this->gd('customer')->id;?>"><img src="images/details_12x12.png"/></a><?php
        
if (CustomerModel::hasSystem($this->gd('customer')->id)) {
            
?><a class="button" onclick="catchEvent(event);"><img src="images/delete_12x12_disabled.png"/></a><?php
        
} else {
            
?><a class="button" href="<?php print $_SERVER['PHP_SELF'].'?mod='.RootController::getModuleName().'&a='.RootController::getModuleAction().'&ap='.$this->gd('customer')->id;?>&confirmDelete"><img src="images/delete_12x12.png"/></a><?php
        
}
    }
    
?>&nbsp;<?php $this->pd('title');?>
</span>

<form name="formname" id="formCustomerEditable" action="" method="post" onsubmit="return _stdonsubmit();" >

<input name="id" type="hidden" value="<?php print $this->gd('customer')->id;?>"/>

<label for="title"><?php $this->pd('labelTitle');?></label>
<textarea name="title" class="textareaFlat"><?php print $this->gd('customer')->title;?></textarea>
<br/>
<label for="firstname"><?php $this->pd('labelFirstname');?></label>
<textarea name="firstname" class="textareaFlat"><?php print $this->gd('customer')->firstname;?></textarea>
<br/>
<label for="name" class="<?php print ($this->isInvalid('name''customer') ? 'invalidField' '');?>"><?php $this->pd('labelName');?></label>
<textarea name="name" class="textareaFlat"><?php print $this->gd('customer')->name;?></textarea>
<br/>
<br/>
<label class="sectionLabel"><?php $this->pd('labelAddresses')?></label>
<br/>
<br/>
<?php
    $aNr 
0;
    foreach (
$this->gd('customer')->address as $address) {
        
?>
            <input type="hidden"   id="customerAddress_<?php print $aNr;?>_id"           name="customerAddress[<?php print $aNr;?>][id]"                             value="<?php print $address->id?>" />
            <input type="hidden"   id="customerAddress_<?php print $aNr;?>_customerId"   name="customerAddress[<?php print $aNr;?>][customerId]"                     value="<?php print $address->customerId?>" />
            
            <label                                                                        for="customerAddress[<?php print $aNr;?>][street]"><?php $this->pd('labelStreet');?></label>
            <input type="text"     id="customerAddress_<?php print $aNr;?>_street"       name="customerAddress[<?php print $aNr;?>][street]"                         value="<?php print $address->street?>" /><br/>
            <!--<textarea              id="customerAddress_<?php print $aNr;?>_street"   name="customerAddress[<?php print $aNr;?>][street]" rows="4" cols="30" ><?php print $address->street?></textarea><br/>-->
            
            <label                                                                        for="customerAddress[<?php print $aNr;?>][streetNumber]"><?php $this->pd('labelStreetNumber');?></label>
            <input type="text"     id="customerAddress_<?php print $aNr;?>_streetNumber" name="customerAddress[<?php print $aNr;?>][streetNumber]"                   value="<?php print $address->streetNumber?>" /><br/>
            
            <label                                                                        for="customerAddress[<?php print $aNr;?>][postalCode]"><?php $this->pd('labelPostalCode');?></label>
            <input type="text"     id="customerAddress_<?php print $aNr;?>_postalCode"   name="customerAddress[<?php print $aNr;?>][postalCode]"                     value="<?php print $address->postalCode?>" /><br/>
            
            <label                                                                        for="customerAddress[<?php print $aNr;?>][city]"><?php $this->pd('labelCity');?></label>
            <input type="text"     id="customerAddress_<?php print $aNr;?>_city"         name="customerAddress[<?php print $aNr;?>][city]"                           value="<?php print $address->city?>" /><br/>
            
            <label for="county"><?php $this->pd('labelCountyName');?></label>
            <select id="customerAddress_<?php print $aNr;?>_countyId"         name="customerAddress[<?php print $aNr;?>][countyId]">
                <option value=""></option>
                <?php
                
foreach ($this->gd('counties') as $county) {
                    
?><option value="<?php print $county->countyId?><?php if ($county->countyId == $address->countyId) print 'selected="selected"';?> ><?php print $county->countyName?></option><?php
                
}
                
?>
            </select>
            <br/>
            
            <label                                                                                         for="customerAddress[<?php print $aNr;?>][maintenanceContractNumber]"><?php $this->pd('labelMaintenanceContractNumber');?></label>
            <input type="text" id="customerAddress_<?php print $aNr;?>_maintenanceContractNumber"         name="customerAddress[<?php print $aNr;?>][maintenanceContractNumber]"    value="<?php print $address->maintenanceContractNumber?>" /><br/>
            
            <label                                                                                        for="customerAddress[<?php print $aNr;?>][maintenanceDate]"><?php $this->pd('labelMaintenanceDate');?></label>
            <input id="customerAddress_<?php print $aNr;?>_maintenanceDate" class="noAutocomplete"        name="customerAddress[<?php print $aNr;?>][maintenanceDate]" type="text" onclick="displayDatePicker('customerAddress[<?php print $aNr;?>][maintenanceDate]', false, 'dmy', '.');" value="<?php print Helper::dateFormat($address->maintenanceDate);?>"/>
            <input type="button" class="squareButton"                                                                                                                              onclick="displayDatePicker('customerAddress[<?php print $aNr;?>][maintenanceDate]', false, 'dmy', '.');" value="<?php $this->pd('txtMaintenanceDateButton');?>"/>
            <br/>
            
            <label                                                                               for="customerAddress[<?php print $aNr;?>][maintenanceDone]"><?php $this->pd('labelMaintenanceDone');?></label>
            <input type="hidden"                                                                name="customerAddress[<?php print $aNr;?>][maintenanceDone]"    value="0" />
            <input type="checkbox" id="customerAddress_<?php print $aNr;?>_maintenanceDone"     name="customerAddress[<?php print $aNr;?>][maintenanceDone]"    value="1"  <?php print ((((int)$address->maintenanceDone)>0) ? 'checked="checked"' '' );?> /><br/>
            <br/>
            
            <!--<input type="button"   id="customerAddress_<?php print $aNr;?>_city"                                                                                 value=".."            onclick="serviceRowSelector_open(<?php print $aNr;?>);" /></td>-->
            <label></label>
            <input type="button"   id="customerAddress_<?php print $aNr;?>_remove"       name="customerAddress_remove_<?php print $aNr;?>"    class="squareButton"   value="X"             onclick="specialSubmit('formname', 'customerAddress_remove_<?php print $aNr;?>')" />
            <input type="button"   id="customerAddress_<?php print $aNr;?>_add"          name="customerAddress_add_<?php print $aNr;?>"       class="squareButton"   value="+"             onclick="specialSubmit('formname', 'customerAddress_add_<?php print $aNr;?>')" />
            
            <br>
            <br>
            <br>
            <br>
        <?php
        $aNr
++;
    }
    foreach (
$this->gd('customer')->removeAddress as $removeAddressId) {
        
?>
            <input type="hidden"   name="removeCustomerAddress[]"    value="<?php print $removeAddressId?>" />
        <?php
    
}
?>
<label class="sectionLabel"><?php $this->pd('labelTelephoneNumbers')?></label>
<br/>
<br/>
<?php
    $tNr 
0;
    foreach (
$this->gd('customer')->telephone as $telephone) {
        
?>
            <input type="hidden"   id="customerTelephone_<?php print $tNr;?>_id"           name="customerTelephone[<?php print $tNr;?>][id]"                             value="<?php print $telephone->id?>" />
            <input type="hidden"   id="customerTelephone_<?php print $tNr;?>_customerId"   name="customerTelephone[<?php print $tNr;?>][customerId]"                     value="<?php print $telephone->customerId?>" />
            
            <label                                                                          for="customerTelephone[<?php print $tNr;?>][telephone]"><?php $this->pd('labelTelephone');?></label>
            <input type="text"     id="customerTelephone_<?php print $tNr;?>_telephone"    name="customerTelephone[<?php print $tNr;?>][telephone]"                      value="<?php print $telephone->telephone?>" />
            <!--<textarea              id="customerTelephone_<?php print $tNr;?>_street"   name="customerTelephone[<?php print $tNr;?>][telephone]" rows="4" cols="30" ><?php print $telephone->telephone?></textarea><br/>-->
            
            <input type="button"   id="customerTelephone_<?php print $tNr;?>_remove"       name="customerTelephone_remove_<?php print $tNr;?>"    class="squareButton"   value="X"             onclick="specialSubmit('formname', 'customerTelephone_remove_<?php print $tNr;?>')" />
            <input type="button"   id="customerTelephone_<?php print $tNr;?>_add"          name="customerTelephone_add_<?php print $tNr;?>"       class="squareButton"   value="+"             onclick="specialSubmit('formname', 'customerTelephone_add_<?php print $tNr;?>')" />
            
            <br>
            <br>
        <?php
        $tNr
++;
    }
    foreach (
$this->gd('customer')->removeTelephone as $removeTelephoneId) {
        
?>
            <input type="hidden"   name="removeCustomerTelephone[]"    value="<?php print $removeTelephoneId?>" />
        <?php
    
}
?>
<label class="sectionLabel"><?php $this->pd('labelEmailAddresses')?></label>
<br/>
<br/>
<?php
    $eNr 
0;
    foreach (
$this->gd('customer')->emailAddress as $emailAddress) {
        
?>
            <input type="hidden"   id="customerEmailAddress_<?php print $eNr;?>_id"           name="customerEmailAddress[<?php print $eNr;?>][id]"                             value="<?php print $emailAddress->id?>" />
            <input type="hidden"   id="customerEmailAddress_<?php print $eNr;?>_customerId"   name="customerEmailAddress[<?php print $eNr;?>][customerId]"                     value="<?php print $emailAddress->customerId?>" />
            
            <label                                                                             for="customerEmailAddress[<?php print $eNr;?>][emailAddress]"><?php $this->pd('labelEmailAddress');?></label>
            <input type="text"     id="customerEmailAddress_<?php print $eNr;?>_emailAddress" name="customerEmailAddress[<?php print $eNr;?>][emailAddress]"                      value="<?php print $emailAddress->emailAddress?>" />
            <!--<textarea              id="customerEmailAddress_<?php print $eNr;?>_street"   name="customerEmailAddress[<?php print $eNr;?>][emailAddress]" rows="4" cols="30" ><?php print $emailAddress->emailAddress?></textarea><br/>-->
            
            <input type="button"   id="customerEmailAddress_<?php print $eNr;?>_remove"       name="customerEmailAddress_remove_<?php print $eNr;?>"    class="squareButton"   value="X"             onclick="specialSubmit('formname', 'customerEmailAddress_remove_<?php print $eNr;?>')" />
            <input type="button"   id="customerEmailAddress_<?php print $eNr;?>_add"          name="customerEmailAddress_add_<?php print $eNr;?>"       class="squareButton"   value="+"             onclick="specialSubmit('formname', 'customerEmailAddress_add_<?php print $eNr;?>')" />
            
            <br>
            <br>
        <?php
        $eNr
++;
    }
    foreach (
$this->gd('customer')->removeEmailAddress as $removeEmailAddressId) {
        
?>
            <input type="hidden"   name="removeCustomerEmailAddress[]"    value="<?php print $removeEmailAddressId?>" />
        <?php
    
}
?>
<br/>
<label for="submit"></label>
<input name="submitSave" type="submit" value="<?php print _('speichern')?>" />

</form>

</div>