Example #1
0
 public function action_vendor()
 {
     $vendor_id = $this->request->param('id');
     $vendor_lookup = new Beans_Vendor_Lookup($this->_beans_data_auth((object) array('id' => $vendor_id)));
     $vendor_lookup_result = $vendor_lookup->execute();
     if ($this->_beans_result_check($vendor_lookup_result)) {
         $this->_view->vendor_lookup_result = $vendor_lookup_result;
         $this->_action_tab_name = $vendor_lookup_result->data->vendor->company_name;
         $this->_action_tab_uri = '/' . $this->request->uri();
         $vendor_address_search = new Beans_Vendor_Address_Search($this->_beans_data_auth((object) array('search_vendor_id' => $vendor_id)));
         $vendor_address_search_result = $vendor_address_search->execute();
         if ($this->_beans_result_check($vendor_address_search_result)) {
             $this->_view->vendor_address_search_result = $vendor_address_search_result;
         }
         $account_transaction_search = new Beans_Account_Transaction_Search_Vendor($this->_beans_data_auth((object) array('vendor_id' => $vendor_id, 'page_size' => 5, 'sort_by' => 'newest')));
         $account_transaction_search_result = $account_transaction_search->execute();
         if ($this->_beans_result_check($account_transaction_search_result)) {
             foreach ($account_transaction_search_result->data->transactions as $index => $transaction) {
                 if (isset($transaction->form) and $transaction->form and isset($transaction->form->id) and $transaction->form->type == "expense") {
                     $vendor_expense_lookup = new Beans_Vendor_Expense_Lookup($this->_beans_data_auth((object) array('id' => $transaction->form->id)));
                     $vendor_expense_lookup_result = $vendor_expense_lookup->execute();
                     if ($this->_beans_result_check($vendor_expense_lookup_result)) {
                         $account_transaction_search_result->data->transactions[$index]->expense = $vendor_expense_lookup_result->data->expense;
                     }
                 } else {
                     if ($transaction->payment and $transaction->payment == "vendor") {
                         $vendor_payment_lookup = new Beans_Vendor_Payment_Lookup($this->_beans_data_auth((object) array('id' => $transaction->id)));
                         $vendor_payment_lookup_result = $vendor_payment_lookup->execute();
                         if ($this->_beans_result_check($vendor_payment_lookup_result)) {
                             $account_transaction_search_result->data->transactions[$index]->payment = $vendor_payment_lookup_result->data->payment;
                         }
                     } else {
                         if ($transaction->tax_payment and isset($transaction->tax_payment->id)) {
                             $tax_payment_lookup = new Beans_Tax_Payment_Lookup($this->_beans_data_auth((object) array('id' => $transaction->tax_payment->id)));
                             $tax_payment_lookup_result = $tax_payment_lookup->execute();
                             if ($this->_beans_result_check($tax_payment_lookup_result)) {
                                 $account_transaction_search_result->data->transactions[$index]->taxpayment = $tax_payment_lookup_result->data->payment;
                             }
                         }
                     }
                 }
             }
         }
         $this->_view->noprintchecks = TRUE;
         if ($this->_beans_result_check($account_transaction_search_result)) {
             $this->_view->account_transaction_search_result = $account_transaction_search_result;
         }
     }
 }
Example #2
0
 public function action_vendoraddresses()
 {
     $vendor_id = $this->request->post('vendor_id');
     $vendor_address_search = new Beans_Vendor_Address_Search($this->_beans_data_auth((object) array('search_vendor_id' => $vendor_id)));
     $vendor_address_search_result = $vendor_address_search->execute();
     if (!$vendor_address_search_result->success) {
         return $this->_return_error("An error occurred: " . $this->_beans_result_get_error($vendor_address_search_result));
     }
     $vendor_lookup = new Beans_Vendor_Lookup($this->_beans_data_auth((object) array('id' => $vendor_id)));
     $vendor_lookup_result = $vendor_lookup->execute();
     if (!$vendor_lookup_result->success) {
         return $this->_return_error($vendor_lookup_result->auth_error . $vendor_lookup_result->error);
     }
     $this->_return_object->data->vendor = $vendor_lookup_result->data->vendor;
     $this->_return_object->data->addresses = $vendor_address_search_result->data->addresses;
 }
Example #3
0
 public function action_vendorpayment()
 {
     $payment_id = $this->request->param('id');
     $vendor_payment_lookup = new Beans_Vendor_Payment_Lookup($this->_beans_data_auth((object) array('id' => $payment_id)));
     $vendor_payment_lookup_result = $vendor_payment_lookup->execute();
     if (!$vendor_payment_lookup_result->success) {
         // V2Item - Clean up and output nicely.
         die("An error occurred: " . $vendor_payment_lookup_result->auth_error . $vendor_payment_lookup_result->error);
     }
     $default_address = FALSE;
     if ($vendor_payment_lookup_result->data->payment->vendor->default_remit_address_id) {
         $vendor_address_lookup = new Beans_Vendor_Address_Lookup($this->_beans_data_auth((object) array('id' => $vendor_payment_lookup_result->data->payment->vendor->default_remit_address_id)));
         $vendor_address_lookup_result = $vendor_address_lookup->execute();
         $default_address = $vendor_address_lookup_result->data->address;
     } else {
         $vendor_address_search = new Beans_Vendor_Address_Search($this->_beans_data_auth((object) array('search_vendor_id' => $vendor_payment_lookup_result->data->payment->vendor->id)));
         $vendor_address_search_result = $vendor_address_search->execute();
         foreach ($vendor_address_search_result->data->addresses as $address) {
             if (!$default_address) {
                 $default_address = $address;
             }
         }
     }
     $vendors_print_payment = new View_Vendors_Print_Payment();
     $vendors_print_payment->vendor_address = $default_address;
     $vendors_print_payment->payment = $vendor_payment_lookup_result->data->payment;
     $vendors_print_payment->setup_company_list_result = $this->_setup_company_list_result;
     die($vendors_print_payment->render());
 }