コード例 #1
0
ファイル: dash.php プロジェクト: rrsc/beansbooks
 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();
 }
コード例 #2
0
ファイル: lookup.php プロジェクト: rrsc/beansbooks
 protected function _execute()
 {
     if (!$this->_customer->loaded()) {
         throw new Exception("Customer could not be found.");
     }
     // Grab customer sales.
     $customer_sale_search = new Beans_Customer_Sale_Search($this->_beans_data_auth((object) array('search_customer_id' => $this->_customer->id)));
     $customer_sale_search_result = $customer_sale_search->execute();
     if (!$customer_sale_search_result->success) {
         throw new Exception("An error occurred when looking up customer sales.");
     }
     return (object) array("customer" => $this->_return_customer_element($this->_customer), "sales" => $customer_sale_search_result->data->sales);
 }
コード例 #3
0
ファイル: json.php プロジェクト: rrsc/beansbooks
 public function action_salesloadmore()
 {
     $last_sale_id = $this->request->post('last_sale_id');
     $last_sale_date = $this->request->post('last_sale_date');
     $search_terms = $this->request->post('search_terms');
     $search_customer_id = $this->request->post('search_customer_id');
     $search_past_due = $this->request->post('search_past_due');
     $search_invoiced = $this->request->post('search_invoiced');
     $count = $this->request->post('count');
     if (!$count) {
         $count = 20;
     }
     $this->_return_object->data->sales = array();
     $page = 0;
     $search_parameters = new stdClass();
     $search_parameters->sort_by = 'newest';
     $search_parameters->page_size = $count * 2;
     if ($search_invoiced == "1") {
         $search_parameters->invoiced = TRUE;
     }
     if ($search_customer_id and strlen(trim($search_customer_id))) {
         $search_parameters->search_customer_id = $search_customer_id;
     }
     if ($search_past_due) {
         $search_parameters->past_due = TRUE;
     }
     $search_parameters->keywords = $search_terms;
     do {
         $search_parameters->page = $page;
         $customer_sales = new Beans_Customer_Sale_Search($this->_beans_data_auth($search_parameters));
         $customer_sales_result = $customer_sales->execute();
         if (!$customer_sales_result->success) {
             return $this->_return_error("An unexpected error occurred: " . $this->_beans_result_get_error($customer_sales_result));
         }
         foreach ($customer_sales_result->data->sales as $sale) {
             if (strtotime($sale->date_created) <= strtotime($last_sale_date) and $sale->id < $last_sale_id or strtotime($sale->date_created) < strtotime($last_sale_date) or !$last_sale_id) {
                 $html = new View_Partials_Customers_Sales_Sale();
                 $html->sale = $sale;
                 $html->invoice_view = $this->request->post('invoice_view');
                 $sale->html = $html->render();
                 $this->_return_object->data->sales[] = $sale;
             }
             if (count($this->_return_object->data->sales) >= $count) {
                 return;
             }
         }
         $page++;
     } while ($page < $customer_sales_result->data->pages and count($this->_return_object->data->sales) < $count);
 }
コード例 #4
0
ファイル: customers.php プロジェクト: rrsc/beansbooks
 public function action_payments()
 {
     $payment_id = $this->request->param('id');
     $customer_payment_search = new Beans_Customer_Payment_Search($this->_beans_data_auth((object) array('page_size' => 5, 'sort_by' => 'newest')));
     $customer_payment_search_result = $customer_payment_search->execute();
     if ($this->_beans_result_check($customer_payment_search_result)) {
         $this->_view->customer_payment_search_result = $customer_payment_search_result;
     }
     // Oustanding sales
     $customer_sale_search = new Beans_Customer_Sale_Search($this->_beans_data_auth((object) array('page_size' => 30, 'invoiced' => TRUE, 'has_balance' => TRUE, 'sort_by' => 'duesoonest')));
     $customer_sale_search_result = $customer_sale_search->execute();
     if ($this->_beans_result_check($customer_sale_search_result)) {
         $this->_view->customer_sale_search_result = $customer_sale_search_result;
     }
     $this->_view->requested_payment_id = $payment_id;
     $this->_view->force_current_uri = "/customers/payments";
 }