public function action_index() { $report_cash = new Beans_Report_Cash($this->_beans_data_auth((object) array('date' => date("Y-m-d")))); $report_cash_result = $report_cash->execute(); if ($this->_beans_result_check($report_cash_result)) { $this->_view->report_cash_result = $report_cash_result; } // Past Due Sales $sales_past_due = new Beans_Customer_Sale_Search($this->_beans_data_auth((object) array('past_due' => TRUE, 'sort_by' => 'duelatest', 'page_size' => 100))); $sales_past_due_result = $sales_past_due->execute(); if ($this->_beans_result_check($sales_past_due_result)) { $this->_view->sales_past_due_result = $sales_past_due_result; } // Not Sent Sales $sales_not_invoiced = new Beans_Customer_Sale_Search($this->_beans_data_auth((object) array('invoiced' => FALSE, 'cancelled' => FALSE, 'sort_by' => 'oldest', 'page_size' => 100, 'date_created_before' => date("Y-m-d", strtotime("-30 Days"))))); $sales_not_invoiced_result = $sales_not_invoiced->execute(); if ($this->_beans_result_check($sales_not_invoiced_result)) { $this->_view->sales_not_invoiced_result = $sales_not_invoiced_result; } // Past Due Purchases $purchases_past_due = new Beans_Vendor_Purchase_Search($this->_beans_data_auth((object) array('past_due' => TRUE, 'sort_by' => 'duelatest', 'page_size' => 100))); $purchases_past_due_result = $purchases_past_due->execute(); if ($this->_beans_result_check($purchases_past_due_result)) { $this->_view->purchases_past_due_result = $purchases_past_due_result; } // Not Sent Sales $purchases_not_invoiced = new Beans_Vendor_Purchase_Search($this->_beans_data_auth((object) array('invoiced' => FALSE, 'cancelled' => FALSE, 'sort_by' => 'oldest', 'page_size' => 100, 'date_created_before' => date("Y-m-d", strtotime("-30 Days"))))); $purchases_not_invoiced_result = $purchases_not_invoiced->execute(); if ($this->_beans_result_check($purchases_not_invoiced_result)) { $this->_view->purchases_not_invoiced_result = $purchases_not_invoiced_result; } // Determine any messages $this->_view->messages = $this->_dash_index_messages(); }
public function action_purchases() { $purchase_id = $this->request->param('id'); $vendor_purchase_search = new Beans_Vendor_Purchase_Search($this->_beans_data_auth((object) array('page_size' => 20, 'sort_by' => 'newest'))); $vendor_purchase_search_result = $vendor_purchase_search->execute(); if ($this->_beans_result_check($vendor_purchase_search_result)) { $this->_view->vendor_purchase_search_result = $vendor_purchase_search_result; } $this->_view->requested_purchase_id = $purchase_id; $this->_view->force_current_uri = "/vendors/purchases"; }
protected function _execute() { if (!$this->_vendor->loaded()) { throw new Exception("Vendor could not be found."); } $vendor_purchase_search = new Beans_Vendor_Purchase_Search($this->_beans_data_auth((object) array('vendor_id' => $this->_vendor->id))); $vendor_purchase_search_result = $vendor_purchase_search->execute(); if (!$vendor_purchase_search_result->success) { throw new Exception("An error occurred when looking up vendor purchase purchases."); } $vendor_expense_search = new Beans_Vendor_Expense_Search($this->_beans_data_auth((object) array('vendor_id' => $this->_vendor->id))); $vendor_expense_search_result = $vendor_expense_search->execute(); if (!$vendor_expense_search_result->success) { throw new Exception("An error occurred when looking up vendor expenses."); } return (object) array("vendor" => $this->_return_vendor_element($this->_vendor), "purchases" => $vendor_purchase_search_result->data->purchases, "expenses" => $vendor_expense_search_result->data->expenses); }
public function action_invoicepurchases() { $search_terms = $this->request->post('search_terms'); $search_parameters = new stdClass(); $search_parameters->sort_by = "oldest"; $search_parameters->page_size = "20"; $search_parameters->keywords = $search_terms; $vendor_purchases_search = new Beans_Vendor_Purchase_Search($this->_beans_data_auth($search_parameters)); $vendor_purchases_search_result = $vendor_purchases_search->execute(); if (!$vendor_purchases_search_result->success) { return $this->_return_error($this->_beans_result_get_error($vendor_purchases_search_result)); } foreach ($vendor_purchases_search_result->data->purchases as $index => $purchase) { $html = new View_Partials_Vendors_Invoices_Purchase(); $html->purchase = $purchase; $vendor_purchases_search_result->data->purchases[$index]->html = $html->render(); } $this->_return_object->data->purchases = $vendor_purchases_search_result->data->purchases; }