Esempio n. 1
0
 public function action_checksearch()
 {
     $search_terms = $this->request->post('search_terms');
     $count = $this->request->post('count');
     $page = $this->request->post('page');
     if (!$count) {
         $count = 5;
     }
     if (!$page) {
         $page = 0;
     }
     $search_parameters = (object) array('page' => $page, 'page_size' => $count, 'sort_by' => 'checknewest', 'vendor_keywords' => ' ');
     foreach (explode(' ', $search_terms) as $search_term) {
         $term = trim($search_term);
         if ($term and is_numeric($search_term)) {
             $search_parameters->check_number = $term;
         } else {
             if ($term and date('Y-m-d', strtotime($term)) == $term) {
                 $search_parameters->date = $term;
             } else {
                 $search_parameters->vendor_keywords .= $term . ' ';
             }
         }
     }
     $account_transaction_search = new Beans_Account_Transaction_Search_Check($this->_beans_data_auth($search_parameters));
     $account_transaction_search_result = $account_transaction_search->execute();
     if (!$account_transaction_search_result->success) {
         return $this->_return_error($this->_beans_result_get_error($account_transaction_search_result));
     }
     $this->_return_object->data = $account_transaction_search_result->data;
     // $this->_return_object->data->checks = array();
     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 (!$vendor_expense_lookup_result->success) {
                 return $this->_return_error($this->_beans_result_get_error($vendor_expense_lookup_result));
             }
             $vendor_checks_check = new View_Partials_Vendors_Checks_Check();
             $vendor_checks_check->expense = $vendor_expense_lookup_result->data->expense;
             $this->_return_object->data->transactions[$index]->html = $vendor_checks_check->render();
         } 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 (!$vendor_payment_lookup_result->success) {
                     return $this->_return_error($this->_beans_result_get_error($vendor_payment_lookup_result));
                 }
                 $vendor_checks_check = new View_Partials_Vendors_Checks_Check();
                 $vendor_checks_check->payment = $vendor_payment_lookup_result->data->payment;
                 $this->_return_object->data->transactions[$index]->html = $vendor_checks_check->render();
             } 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 (!$tax_payment_lookup_result->success) {
                         return $this->_return_error($this->_beans_result_get_error($tax_payment_lookup_result));
                     }
                     $vendor_checks_check = new View_Partials_Vendors_Checks_Check();
                     $vendor_checks_check->taxpayment = $tax_payment_lookup_result->data->payment;
                     $this->_return_object->data->transactions[$index]->html = $vendor_checks_check->render();
                 } else {
                     $vendor_checks_check = new View_Partials_Vendors_Checks_Check();
                     $vendor_checks_check->transaction = $transaction;
                     $this->_return_object->data->transactions[$index]->html = $vendor_checks_check->render();
                 }
             }
         }
     }
 }
Esempio n. 2
0
 public function action_printchecks()
 {
     $check_print_queue = Session::instance()->get('check_print_queue');
     $this->_view->expenses = array();
     $this->_view->payments = array();
     $this->_view->taxpayments = array();
     if ($check_print_queue) {
         foreach ($check_print_queue->expense_ids as $expense_id => $include) {
             $expense_lookup = new Beans_Vendor_Expense_Lookup($this->_beans_data_auth((object) array('id' => $expense_id)));
             $expense_lookup_result = $expense_lookup->execute();
             if ($this->_beans_result_check($expense_lookup_result)) {
                 $this->_view->expenses[] = $expense_lookup_result->data->expense;
             }
         }
         foreach ($check_print_queue->payment_ids as $payment_id => $include) {
             $payment_lookup = new Beans_Vendor_Payment_Lookup($this->_beans_data_auth((object) array('id' => $payment_id)));
             $payment_lookup_result = $payment_lookup->execute();
             if ($this->_beans_result_check($payment_lookup_result)) {
                 $this->_view->payments[] = $payment_lookup_result->data->payment;
             }
         }
         foreach ($check_print_queue->taxpayment_ids as $taxpayment_id => $include) {
             $tax_payment_lookup = new Beans_Tax_Payment_Lookup($this->_beans_data_auth((object) array('id' => $taxpayment_id)));
             $tax_payment_lookup_result = $tax_payment_lookup->execute();
             if ($this->_beans_result_check($tax_payment_lookup_result)) {
                 $this->_view->taxpayments[] = $tax_payment_lookup_result->data->payment;
             }
         }
     }
     // Search Other Checks
     $account_transaction_search = new Beans_Account_Transaction_Search_Check($this->_beans_data_auth((object) array('page_size' => 5, 'sort_by' => 'checknewest')));
     $account_transaction_search_result = $account_transaction_search->execute();
     if ($this->_beans_result_check($account_transaction_search_result)) {
         // We have to parse out the proper form for these transactions...
         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->account_transaction_search_result = $account_transaction_search_result;
     }
 }