예제 #1
0
 function view($id = FALSE)
 {
     $this->view_data['submenu'] = array($this->lang->line('application_back') => 'invoices');
     $invoice = $this->view_data['invoice'] = Invoice::find($id);
     $this->view_data['items'] = InvoiceHasItem::find('all', array('conditions' => array('invoice_id=?', $id)));
     $this->view_data['invoice_addresses'] = InvoiceHasAddress::find('all', array('conditions' => array('invoice_id=?', $id)));
     if ($this->view_data['invoice']->company_id != $this->client->company->id) {
         redirect('cinvoices');
     }
     $this->view_data['trackings'] = InvoiceHasTracking::find('all', array('conditions' => array('invoice_id=?', $id)));
     $this->content_view = 'invoices/client_views/view';
 }
예제 #2
0
 function view($id = FALSE)
 {
     $this->view_data['submenu'] = array($this->lang->line('application_back') => 'invoices');
     $this->view_data['invoice'] = Invoice::find($id);
     $data["core_settings"] = Setting::first();
     $this->view_data['items'] = InvoiceHasItem::find('all', array('conditions' => array('invoice_id=?', $id)));
     $this->projectlib->updateInvoiceTotal($this->view_data['invoice']);
     $this->view_data['invoice_addresses'] = InvoiceHasAddress::find('all', array('conditions' => array('invoice_id=?', $id)));
     $this->view_data['trackings'] = InvoiceHasTracking::find('all', array('conditions' => array('invoice_id=?', $id)));
     $this->content_view = 'invoices/view';
 }
예제 #3
0
 function view($id = FALSE)
 {
     $this->view_data['submenu'] = array($this->lang->line('application_back') => 'cestimates');
     $this->view_data['estimate'] = Invoice::find($id);
     if ($this->view_data['estimate']->company_id != $this->client->company->id) {
         redirect('cestimates');
     }
     $data["core_settings"] = Setting::first();
     $estimate = $this->view_data['estimate'];
     $this->view_data['items'] = InvoiceHasItem::find('all', array('conditions' => array('invoice_id=?', $id)));
     $this->projectlib->updateInvoiceTotal($estimate);
     $this->view_data['estimate_addresses'] = InvoiceHasAddress::find('all', array('conditions' => array('invoice_id=?', $id)));
     $this->content_view = 'estimates/client_views/view';
 }
예제 #4
0
 public function updateInvoiceAddress($invoice_id = FALSE, $update_shipping = FALSE, $shipping_address = array())
 {
     if (empty($invoice_id)) {
         return;
     }
     $invoice = Invoice::find($invoice_id);
     $company_id = $invoice->company_id;
     if (empty($company_id)) {
         return;
     }
     $company = Company::find($company_id);
     $primary_contact_id = $company->client_id;
     $primary_contact = Client::find($primary_contact_id);
     $address = array('company_id' => $company_id, 'invoice_id' => $invoice_id, 'billing_name' => $primary_contact->firstname . ' ' . $primary_contact->lastname, 'billing_company' => $company->name, 'billing_address' => $company->address, 'billing_city' => $company->city, 'billing_state' => $company->province, 'billing_zip' => $company->zipcode, 'billing_country' => $company->country, 'billing_phone' => $company->phone, 'billing_email' => $primary_contact->email, 'billing_website' => $company->website);
     $shipping = array();
     if ($update_shipping) {
         if (!count($shipping_address)) {
             $shipping = array('shipping_name' => $primary_contact->firstname . ' ' . $primary_contact->lastname, 'shipping_company' => $company->name, 'shipping_address' => $company->address, 'shipping_city' => $company->city, 'shipping_state' => $company->province, 'shipping_zip' => $company->zipcode, 'shipping_country' => $company->country, 'shipping_phone' => $company->phone, 'shipping_email' => $primary_contact->email, 'shipping_website' => $company->website);
         } else {
             foreach ($shipping_address as $key => $val) {
                 $shipping[$key] = $val;
             }
         }
     }
     $address = $address + $shipping;
     $invoice_addresses = InvoiceHasAddress::find('all', array('conditions' => array('invoice_id=?', $invoice_id), 'limit' => 1));
     if (count($invoice_addresses)) {
         foreach ($invoice_addresses as $iaddress) {
             return $iaddress->update_attributes($address);
         }
     } else {
         return $invoice_address = InvoiceHasAddress::create($address);
     }
 }