예제 #1
0
파일: json.php 프로젝트: rrsc/beansbooks
 /**
  * Returns a list of customer addresses.
  */
 public function action_customeraddresses()
 {
     $customer_id = $this->request->post('customer_id');
     $customer_address_search = new Beans_Customer_Address_Search($this->_beans_data_auth((object) array('search_customer_id' => $customer_id)));
     $customer_address_search_result = $customer_address_search->execute();
     // Not efficient, but clean - we'll model this everywhere for now.
     if (!$customer_address_search_result->success) {
         return $this->_return_error($this->_beans_result_get_error($customer_address_search_result));
     }
     $customer_lookup = new Beans_Customer_Lookup($this->_beans_data_auth((object) array('id' => $customer_id)));
     $customer_lookup_result = $customer_lookup->execute();
     if (!$customer_lookup_result->success) {
         return $this->_return_error($this->_beans_result_get_error($customer_lookup_result));
     }
     $this->_return_object->data->addresses = $customer_address_search_result->data->addresses;
     $this->_return_object->data->customer = $customer_lookup_result->data->customer;
 }
예제 #2
0
 public function action_customer()
 {
     $customer_id = $this->request->param('id');
     $customer_lookup = new Beans_Customer_Lookup($this->_beans_data_auth((object) array('id' => $customer_id)));
     $customer_lookup_result = $customer_lookup->execute();
     if ($this->_beans_result_check($customer_lookup_result)) {
         $this->_view->customer_lookup_result = $customer_lookup_result;
         $this->_action_tab_name = $customer_lookup_result->data->customer->display_name;
         $this->_action_tab_uri = '/' . $this->request->uri();
         $customer_address_search = new Beans_Customer_Address_Search($this->_beans_data_auth((object) array('search_customer_id' => $customer_id)));
         $customer_address_search_result = $customer_address_search->execute();
         if ($this->_beans_result_check($customer_address_search_result)) {
             $this->_view->customer_address_search_result = $customer_address_search_result;
         }
         $customer_sale_search = new Beans_Customer_Sale_Search($this->_beans_data_auth((object) array('search_customer_id' => $customer_id, 'page_size' => 5, 'sort_by' => 'newest', 'search_and' => TRUE)));
         $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;
         }
     }
 }