Exemple #1
0
 public function action_renderprintchecks()
 {
     $expense_ids = array();
     $payment_ids = array();
     $taxpayment_ids = array();
     foreach ($this->request->post() as $key => $value) {
         if ($value == "print-check") {
             $key_array = explode('-', $key);
             ${$key_array[0] . '_ids'}[] = $key_array[1];
         }
     }
     $print_vendor_checks = new View_Vendors_Print_Checks();
     $print_vendor_checks->expenses = array();
     $print_vendor_checks->payments = array();
     $print_vendor_checks->taxpayments = array();
     if (count($expense_ids) or count($payment_ids) or count($taxpayment_ids)) {
         foreach ($expense_ids as $expense_id) {
             $expense_lookup = new Beans_Vendor_Expense_Lookup($this->_beans_data_auth((object) array('id' => $expense_id)));
             $expense_lookup_result = $expense_lookup->execute();
             if (!$expense_lookup_result->success) {
                 throw new Exception($this->_beans_result_get_error($expense_lookup_result));
             }
             $print_vendor_checks->expenses[] = $expense_lookup_result->data->expense;
         }
         foreach ($payment_ids as $payment_id) {
             $payment_lookup = new Beans_Vendor_Payment_Lookup($this->_beans_data_auth((object) array('id' => $payment_id)));
             $payment_lookup_result = $payment_lookup->execute();
             if (!$payment_lookup_result->success) {
                 throw new Exception($this->_beans_result_get_error($payment_lookup_result));
             }
             $print_vendor_checks->payments[] = $payment_lookup_result->data->payment;
         }
         foreach ($taxpayment_ids as $taxpayment_id) {
             $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 (!$tax_payment_lookup_result->success) {
                 throw new Exception($this->_beans_result_get_error($tax_payment_lookup_result));
             }
             $print_vendor_checks->taxpayments[] = $tax_payment_lookup_result->data->payment;
         }
     } else {
         throw new Exception("Please include at least one check to print.");
     }
     die($print_vendor_checks->render());
 }
Exemple #2
0
 public function action_vendorpaymentsearch()
 {
     $search_terms = $this->request->post('search_terms');
     $search_vendor_id = $this->request->post('search_vendor_id');
     $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' => 'newest', 'vendor_id' => $search_vendor_id, 'keywords' => '', 'search_and' => FALSE);
     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;
             }
         }
         $search_parameters->keywords .= $term . ' ';
     }
     $account_transaction_search = new Beans_Account_Transaction_Search_Vendor($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->noprintchecks = TRUE;
             $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->noprintchecks = TRUE;
                 $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->noprintchecks = TRUE;
                     $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->noprintchecks = TRUE;
                     $vendor_checks_check->transaction = $transaction;
                     $this->_return_object->data->transactions[$index]->html = $vendor_checks_check->render();
                 }
             }
         }
     }
 }
Exemple #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());
 }