Пример #1
0
 public function testCRUD()
 {
     midcom::get('auth')->request_sudo('org.openpsa.invoices');
     $data = new org_openpsa_invoices_billing_data_dba();
     $data->linkGuid = self::$_contact->guid;
     $data->useContactAddress = true;
     $stat = $data->create();
     $this->assertTrue($stat, midcom_connection::get_error_string());
     $this->register_object($data);
     $parent = $data->get_parent();
     $this->assertEquals($parent->guid, self::$_contact->guid);
     self::$_contact->refresh();
     $this->assertEquals(self::$_contact->street, $data->street);
     $data->vat = 12;
     $data->due = 12;
     $stat = $data->update();
     $this->assertTrue($stat);
     self::$_contact->refresh();
     $invoice = new org_openpsa_invoices_invoice_dba();
     $invoice->customerContact = self::$_contact->id;
     $invoice_data = $invoice->get_billing_data();
     $this->assertEquals($data->guid, $invoice_data->guid);
     $this->assertEquals($data->vat, $invoice->get_default('vat'));
     $this->assertEquals($data->due, $invoice->get_default('due'));
     $stat = $data->delete();
     $this->assertTrue($stat);
     midcom::get('auth')->drop_sudo();
 }
Пример #2
0
 public function render_invoice_actions(org_openpsa_invoices_invoice_dba $invoice)
 {
     $action = '';
     $next_marker = array();
     // unsent invoices
     if ($invoice->sent == 0) {
         // sending per mail enabled in billing data?
         $billing_data = $invoice->get_billing_data();
         // only show if mail was chosen as option
         if (intval($billing_data->sendingoption) == 2) {
             $next_marker[] = 'sent_per_mail';
         } else {
             $next_marker[] = 'sent';
         }
     } else {
         if (!$invoice->paid) {
             $next_marker[] = 'paid';
         } else {
             $action .= strftime('%Y-%m-%d', $invoice->paid);
         }
     }
     // generate next action buttons
     if ($invoice->can_do('midgard:update') && count($next_marker) > 0) {
         foreach ($next_marker as $mark) {
             $action .= '<button id="invoice_' . $invoice->guid . '" class="yes mark_' . $mark . '">';
             $action .= $this->_l10n->get('mark ' . $mark);
             $action .= '</button>';
         }
     }
     return $action;
 }