Exemple #1
0
 public function get_row(midcom_core_dbaobject $invoice)
 {
     $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
     $entry = array();
     $number = $invoice->get_label();
     $link_html = "<a href='{$prefix}invoice/{$invoice->guid}/'>" . $number . "</a>";
     if ($number == "") {
         $number = "n/a";
     }
     $entry['id'] = $invoice->id;
     $entry['index_number'] = $number;
     $entry['number'] = $link_html;
     if (!is_a($this->_customer, 'org_openpsa_contacts_group_dba')) {
         try {
             $customer = org_openpsa_contacts_group_dba::get_cached($invoice->customer);
             $entry['customer'] = "<a href=\"{$this->_request_data['invoices_url']}list/customer/all/{$customer->guid}/\">" . $customer->get_label() . "</a>";
         } catch (midcom_error $e) {
             $entry['customer'] = '';
         }
     }
     if (!is_a($this->_customer, 'org_openpsa_contacts_person_dba')) {
         try {
             $contact = org_openpsa_contacts_person_dba::get_cached($invoice->customerContact);
             $entry['contact'] = "<a href=\"{$this->_request_data['invoices_url']}list/customer/all/{$contact->guid}/\">" . $contact->get_label() . "</a>";
         } catch (midcom_error $e) {
             $entry['contact'] = '';
         }
     }
     if (!empty($this->_request_data['deliverable'])) {
         $constraints = array('invoice' => $invoice->id, 'deliverable' => $this->_request_data['deliverable']->id);
         $item_sum = org_openpsa_invoices_invoice_item_dba::get_sum($constraints);
         $this->_request_data['totals']['deliverable'] += $item_sum;
         $entry['index_item_sum'] = $item_sum;
         $entry['item_sum'] = '<span title="' . $this->_l10n->get('sum including vat') . ': ' . org_openpsa_helpers::format_number($item_sum / 100 * $invoice->vat + $item_sum) . '">' . org_openpsa_helpers::format_number($item_sum) . '</span>';
     }
     $entry['index_sum'] = $invoice->sum;
     $entry['sum'] = '<span title="' . $this->_l10n->get('sum including vat') . ': ' . org_openpsa_helpers::format_number($invoice->sum / 100 * $invoice->vat + $invoice->sum) . '">' . org_openpsa_helpers::format_number($invoice->sum) . '</span>';
     $entry['due'] = '';
     if ($invoice->due > 0) {
         $entry['due'] = strftime('%Y-%m-%d', $invoice->due);
     }
     $colname = 'action';
     if ($this->_list_type == 'paid') {
         $colname = 'paid';
     }
     $entry[$colname] = $this->_master->render_invoice_actions($invoice);
     return $entry;
 }