<?php

#require_once LIBRARY.'modules/view.php';

class CustomerView extends View {
    
    public function 
create() {
        
$model RootController::getModuleModel();
        
$modelAddress = new CustomerAddressModel();
        
        
$this->getObjectData($model'customer');
        
$this->getInvalidFields('customer');
        
        
$this->getLabelData($model);
        
$this->tplData['title'] = $this->tplData['title_new'];
        
$this->tplData['counties'] = $modelAddress->getAllCounties();

        return 
$this->loadTemplate(RootController::getModuleName(), 'customerEditable');
    }
    
    public function 
edit() {
        
$model RootController::getModuleModel();
        
$modelAddress = new CustomerAddressModel();
        
$customerId RootController::getModuleParameter(0);
        
        
$this->getObjectData($model'customer'$customerId);
        
$this->getInvalidFields('customer');
        
        
$this->getLabelData($model);
        
$this->tplData['title'] = $this->tplData['title_edit'];
        
$this->tplData['counties'] = $modelAddress->getAllCounties();
        
        return 
$this->loadTemplate(RootController::getModuleName(), 'customerEditable');
    }
    
    public function 
display() {
        
$model RootController::getModuleModel();
        
$customerId RootController::getModuleParameter(0);
        
        
$this->getObjectData($model'customer'$customerId);
        
        
$this->getLabelData($model);
        
$this->tplData['title'] = $this->tplData['title_show'];
        
        
$output $this->loadTemplate(RootController::getModuleName(), 'customer');
        
        
# invoice list in customer view
        
$invoicesView = new InvoicesView();
        
$output .= '<br/><br/>';
        
$output .= $invoicesView->display($customerId);
        
        return 
$output;
    }
}