Exemplo n.º 1
0
 /**
  * View a list of all customers
  */
 public function indexAction()
 {
     $customersTable = new Customers();
     $this->view->customers = $customersTable->fetchAll();
 }
Exemplo n.º 2
0
 private function getNewInvoiceForm(array $values = null)
 {
     $customersTable = new Customers();
     $customers = $customersTable->fetchAll();
     $customerList = array();
     if ($customers->count() > 0) {
         foreach ($customers as $c) {
             $customerList[$c->customer_id] = $c->company;
         }
     }
     $form = new Zend_Form();
     $form->setAction('/invoices/save')->setMethod('post');
     $customer = new Zend_Form_Element_Select('customer');
     $customer->addMultiOptions($customerList)->setLabel('Customer');
     $invoiceDate = new Zend_Form_Element_Text('invoice_date');
     $invoiceDate->setRequired(true)->setLabel('Invoice Date')->addValidator(new Zend_Validate_Date())->setAttrib('class', 'date')->setValue(date('Y-m-d'));
     $dueDate = new Zend_Form_Element_Text('due_date');
     $dueDate->setRequired(true)->setLabel('Due Date')->addValidator(new Zend_Validate_Date())->setAttrib('class', 'date')->setValue(date('Y-m-d', strtotime('+1 month')));
     $notes = new Zend_Form_Element_Textarea('notes');
     $notes->setLabel('Notes');
     $submit = new Zend_Form_Element_Submit('submit');
     if (isset($values)) {
         $customer->setValue($values['customer_id']);
         $invoiceDate->setValue($values['invoice_date']);
         $dueDate->setValue($values['due_date']);
         $notes->setValue($values['notes']);
     }
     $form->addElement($customer)->addElement($invoiceDate)->addElement($dueDate)->addElement($notes)->addElement($submit);
     return $form;
 }