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; }
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; } } }