Jump to content

ty0716

Members
  • Posts

    59
  • Joined

  • Last visited

Posts posted by ty0716

  1. You should be using

    $api->post('clients', 'create', $vars);
    

    But aside from that, the 'Failed to retrieve the default value' error is the result of a bug in ionCube. I've never seen it happen in a non-encoding file, though. So it must be calling something in AppModel which is encoded. I hate ionCube so much.

     

    thank you ,but use post method still return same error.

     

    I found this can be success in order plugin,signup :$this->clients->create($vars);

     

    There are other ways to achieve registration by API, unless post data to a custom plugin then register?

  2. error:

     

    post-11272-0-58215000-1443422528_thumb.p

     

     

    why this?

    <?php
    require_once "../blesta/blesta_api.php";
    
    $user = "resller";
    $key = "**********";
    $url = "http://*********/api/";
    
    $api = BlestaApi::getIns($url, $user, $key);
    
    $json='{"action":"signup","first_name":"\u9676","last_name":"\u96e8","company":"\u6c49\u53e3\u5b66\u9662","address1":"\u6c5f\u590f\u533a\u6587\u5316\u5927\u9053299\u53f7","address2":"16703","city":"\u6b66\u6c49\u5e02","country":"CN","state":"13","zip":"430070","numbers":[{"type":"phone","location":"work","number":"15527474844"},{"type":"fax","location":"work","number":"13396009700"}],"email":"hkxy99@163.com","tax_id":"95599","custom_field1":"424460883","username_type":"email","username":"","new_password":"qaz12345","confirm_password":"qaz12345","client_group_id":"1","settings":{"username_type":"email","tax_id":"95599","default_currency":null,"language":"en_us"},"custom":{"1":"424460883"}}';
    
    
    $vars=json_decode($json,true);
    
    $response=$api->get('clients','create',$vars);
    
    print_r($response->response());
    print_r($response->errors());
    

    data:

    json->array:

    {"action":"signup","first_name":"\u9676","last_name":"\u96e8","company":"\u6c49\u53e3\u5b66\u9662","address1":"\u6c5f\u590f\u533a\u6587\u5316\u5927\u9053299\u53f7","address2":"16703","city":"\u6b66\u6c49\u5e02","country":"CN","state":"13","zip":"430070","numbers":[{"type":"phone","location":"work","number":"15527474844"},{"type":"fax","location":"work","number":"13396009700"}],"email":"hkxy99@163.com","tax_id":"95599","custom_field1":"424460883","username_type":"email","username":"","new_password":"qaz12345","confirm_password":"qaz12345","client_group_id":"1","settings":{"username_type":"email","tax_id":"95599","default_currency":null,"language":"en_us"},"custom":{"1":"424460883"}}
    

    Error:

    Internal error: Failed to retrieve the default valuestdClass Object ( [error] => stdClass Object ( [message] => An unexpected error occured. [response] => Internal error: Failed to retrieve the default value ) )
    
  3. Now i build a new user center base on blesta api.Simplifying a number of steps.

     

    In this site user can view invoices, so, how can i make this go to payment url? instead of redevelopment.

     

    my english is poor,May be expressed is not clear. 

     

    thanks you.

  4. I find in this :  http://dev.blesta.com/browse/CORE-639

     

    http://www.blesta.com/forums/index.php?/topic/2173-price-tiers/

     

     

    This is still not achieved?

     

    for example, set in a group for some customers buy more frequently. When they buy automatic discount.

     

    Not use Coupon,this is not what I want, nor is it a good solution.Because such a group to go to a setting, and to inform the customer coupon code.

     

    Or what plugins to achieve?If the self-development seems to modify many system files are not easy to upgrade.in addition,I'm not very understanding blesta.

     

    Do you have any good suggestions to me?

  5. Is there such a plugins? I need to manage all of the menu like wordpress,There may be outside url.

     

    If not,Did you have any good suggestions?

     

    They are as follows:

    1.menu add,edit,add,Whether to hide,Submenu

    2.Sequence

    3.Whether it is outside the chain.

     

     

    Another problem is:

     

    if i          $this->set("value",$value);   in plugins ,How to use this variable in the dashboard?

  6. As shown in figure:

     

    this client dashboard Widgets orign is show Invoices , Services and transactions.  but now i need to change transactions to ticket. this ticket is support_mange plugin.

     

    I don't know how to add to dashboard. Then i change app/client_controller.php protected function clientWidgets():

    protected function clientWidgets() {
    		$widgets = array();
    		$widget_location = null;
    		switch ($this->controller) {
    			case "client_main":
    				$widget_location = "widget_client_home";
    				
    				// Set the default widgets to appear
    				$widgets = array(
    					'client_invoices'=>array('uri'=>$this->base_uri . "invoices/?whole_widget=true"),
    					'client_services'=>array('uri'=>$this->base_uri . "services/?whole_widget=true"),
    					'client_tickets'=>array('uri'=>$this->base_uri . "plugin/support_manager/client_tickets/index/not_closed/"),
    					/*'client_transactions'=>array('uri'=>$this->base_uri . "transactions/?whole_widget=true")*/
    				);
    				break;
    		}
    

    but this not display title ,then i change 

    $this->WidgetClient->create($this->_("ClientTickets.index.boxtitle_tickets", true), array('id'=>"client_tickets"),null);
    
    //or
    
    $this->WidgetClient->create($this->_("ClientTickets.index.boxtitle_tickets", true), array('id'=>"client_tickets"),"full");
    

    It can display title, but click Open or Closed will display 2 panel-title.

     

    How should I solve this problem?

    I see invoces and services ajax return "{"replacer":null,"content":"\n\t\t\t\n\t\t\t\t<div id=\"client_invoices\" class=\"panel panel-blesta content_section\"

     

     

    but my ticket widgets ajax return "{"replacer":".panel_content","content":"\t\t\t<script type=\"text\/javascript\">\n$(document).blestaSetHeadTag(\"link\",";

    20150814143249.png

     

     

     

    20150814142548.jpg

  7. My solution:

     

    change websiteroot//app/client_controller.php  on line:69 to→→

    $widgets = array(
    					'client_invoices'=>array('uri'=>$this->base_uri . "invoices/?whole_widget=true"),
    					'client_services'=>array('uri'=>$this->base_uri . "services/?whole_widget=true"),
    					'client_tickets'=>array('uri'=>$this->base_uri . "plugin/support_manager/client_tickets/index/not_closed/")/*,
    					'client_transactions'=>array('uri'=>$this->base_uri . "transactions/?whole_widget=true")*/
    				); 

    Then if find this problem.Not show support tickets title

     

    20150814094216.png

     

     

     

    Followed by a variety of search.I see a topic http://www.blesta.com/forums/index.php?/topic/3669-client-widget-render/

     

     

    change /plugins/support_manager/views/default/client_tickets.pdt  on line:22

    $this->WidgetClient->create($this->_("ClientTickets.index.boxtitle_tickets", true), array('id'=>"client_tickets"),null);
    			// $this->Html->ifSet($render_section, null)
    

    Perfect solution.

     

    20150814094626.png

     

     

    ======================================================================================

     

    As shown in Figure:

     

    in http://domain.com/client/main,  this is ajax load.

     

    Now i want to remove "Transactions" area. or Replace "Transactions" to  "ticket".

     

    How to do this?

     

     

    20150813103130.png

     

    20150813102346.png

  8. In "plugins/support_managerpro/controllers/client_tickets.php"

    Line:181 and 334

    $this->SupportManagerproTickets->sendEmail($reply_id);
    

    to

    //$this->SupportManagerproTickets->sendEmail($reply_id);
    

    In "plugins/support_managerpro/models/support_managerpro_tickets.php"

     

    On line 468

    change:

    // Return the ID of the reply
    

    to

    $this->sendEmail($reply_id);
    // Return the ID of the reply
    

    =================================================================================

     

     

     

    I find use api create ticket or reply ticket seems to no email send.

     

     

    because sendEmail() in controller and some is private method,but api call the model.How to solve this problem?

     

    If there is not,whether through the API to send mail and choose a template?

  9. resolvent :

    $reply_data = array(
        'ticket_id'=>9,
        'vars' => array(
            'ticket_id'=>9,
            'staff_id' => null, // the reply is from this staff user
            'client_id' => 2, // the reply is from this client user
            'contact_id' => null, // the reply is from this client contact user
            'type' => "reply", // this is a ticket reply
            'details' => "API reply", // the ticket reply description
            'status' => "open", // status of the ticket
            'staff_id' => null, // the staff user the ticket is assigned to
        ),
        'files' => null,
        'new_ticket' => false // this reply is for a newly created ticket
    );
    $response = $api->post("support_managerpro.support_managerpro_tickets", "addReply", $reply_data);
    

    =================================================================================================================================

     

    Now i need to use api reply tickets. But I've had some problems.

     

    This is my code:

    $vars=array('ticket_id'=>9,'details'=>'API回复工单','action_type'=>'reply','type'=>'reply','staff_id'=>null,'contact_id'=>null,'status'=>'open');
    
    $ticket= $api->post("support_managerpro.support_managerpro_tickets", "addReply",array("ticket_id"=>9,$vars));
    
    print_r($ticket->raw());
    

    when i use 

    $ticket= $api->post("support_managerpro.support_managerpro_tickets", "addReply",array("ticket_id"=>9,$vars));
    

    this page return  {"message":"An unexpected error occured.","response":"Internal error: Failed to retrieve the default value"}

     

     

    when i use 

    $ticket= $api->get("support_managerpro.support_managerpro_tickets", "addReply",array("ticket_id"=>9,$vars));
    

    this page return this error info:{"message":"The requested resource does not exist.","response":null}

     

    What should I do to use API to achieve a reply?thanks!

     

     

     

    support_managerpro::

     

    Model's addReply method():

    	/**
    	 * Adds a reply to a ticket. If ticket data (e.g. department_id, status, priority, summary) have changed
    	 * then this will also invoke SupportManagerproTickets::edit() to update the ticket, and record any log entries.
    	 *
    	 * Because of this functionality, this method is assumed to (and should) already be in a transaction when called,
    	 * and SupportManagerproTickets::edit() should not be called separately.
    	 * 
    	 * @param int $ticket_id The ID of the ticket to reply to
    	 * @param array $vars A list of reply vars, including:
    	 * 	- staff_id The ID of the staff member this reply is from (optional)
    	 * 	- client_id The ID of the client this reply is from (optional)
         * 	- contact_id The ID of a client's contact that this reply is from (optional)
    	 * 	- type The type of reply (i.e. "reply, "note", "log") (optional, default "reply")
    	 * 	- details The details of the ticket (optional)
    	 * 	- department_id The ID of the ticket department (optional)
    	 * 	- summary The ticket summary (optional)
    	 * 	- priority The ticket priority (optional)
    	 * 	- status The ticket status (optional)
    	 * 	- ticket_staff_id The ID of the staff member the ticket is assigned to (optional)
    	 * @param array $files A list of file attachments that matches the global FILES array, which contains an array of "attachment" files
    	 * @param boolean $new_ticket True if this reply is apart of ticket being created, false otherwise (default false)
    	 * @return int The ID of the ticket reply on success, void on error
    	 */
    	public function addReply($ticket_id, array $vars, array $files = null, $new_ticket = false) {
    		$vars['ticket_id'] = $ticket_id;
    		$vars['date_added'] = date("c");
    		if (!isset($vars['type']))
    			$vars['type'] = "reply";
    			
    		// Remove reply details if it contains only the signature
    		if (isset($vars['details']) && isset($vars['staff_id'])) {
    			if (!isset($this->SupportManagerproStaff))
    				Loader::loadModels($this, array("SupportManagerpro.SupportManagerproStaff"));
    				
    			$staff_settings = $this->SupportManagerproStaff->getSettings($vars['staff_id'], Configure::get("Blesta.company_id"));
    			if (isset($staff_settings['signature']) && trim($staff_settings['signature']) == trim($vars['details']))
    				$vars['details'] = "";
    		}
    		
    		// Determine whether or not options have changed that need to be logged
    		$log_options = array();
    		// "status" should be the last element in case it is set to closed, so it will be the last log entry added
    		$loggable_fields = array('department_id' => "department_id", 'ticket_staff_id' => "staff_id", 'summary' => "summary",
    			'priority' => "priority", 'status' => "status");
    
    		if (!$new_ticket && (isset($vars['department_id']) || isset($vars['summary']) || isset($vars['priority']) || isset($vars['status']) || isset($vars['ticket_staff_id']))) {
    			if (($ticket = $this->get($ticket_id, false))) {
    				// Determine if any log replies need to be made
    				foreach ($loggable_fields as $key => $option) {
    					// Save to be logged iff the field has been changed
    					if (isset($vars[$key]) && property_exists($ticket, $option) && $ticket->{$option} != $vars[$key])
    						$log_options[] = $key;
    				}
    			}
    		}
    		
    		// Check whether logs are being added simultaneously, and if so, do not
    		// add a reply iff no reply details, nor files, are attached
    		// i.e. allow log entries to be added without a reply/note regardless of vars['type']
    		$skip_reply = false;
    		if (!empty($log_options) && empty($vars['details']) && (empty($files) || empty($files['attachment']['name'][0])))
    			$skip_reply = true;
    		
    		if (!$skip_reply) {
    
    			$this->Input->setRules($this->getReplyRules($vars, $new_ticket));
    			
    			if ($this->Input->validates($vars)) {
    				// Create the reply
                    $fields = array("ticket_id", "staff_id", "contact_id", "type", "details", "date_added");
    				$this->Record->insert("support_repliespro", $vars, $fields);
    				$reply_id = $this->Record->lastInsertId();
    
                    // Update reply ticket status to awaiting_reply if replyed by staff
                    if (isset($vars['staff_id'])){
                        if ($vars['staff_id'] > 0 && $vars['type'] == "reply" && $vars['status'] != "awaiting_reply"){
                            $this->edit($vars['ticket_id'], array('status' => "awaiting_reply"));
                        }
                    }
    
                	// Handle file upload
    				if (!empty($files['attachment'])) {
    					Loader::loadComponents($this, array("SettingsCollection", "Upload"));
    					
    					// Set the uploads directory
    					$temp = $this->SettingsCollection->fetchSetting(null, Configure::get("Blesta.company_id"), "uploads_dir");
    					$upload_path = $temp['value'] . Configure::get("Blesta.company_id") . DS . "support_managerpro_files" . DS;
    					
    					$this->Upload->setFiles($files, false);
    					$this->Upload->setUploadPath($upload_path);
    					
    					$file_vars = array('files' => array());
    					if (!($errors = $this->Upload->errors())) {
    						// Will not overwrite existing file
    						$this->Upload->writeFile("attachment", false, null, array($this, "makeFileName"));
    						$data = $this->Upload->getUploadData();
    						
    						// Set the file names/paths
    						foreach ($files['attachment']['name'] as $index => $file_name) {
    							if (isset($data['attachment'][$index])) {
    								$file_vars['files'][] = array(
    									'name' => $data['attachment'][$index]['orig_name'],
    									'file_name' => $data['attachment'][$index]['full_path']
    								);
    							}
    						}
    						
    						$errors = $this->Upload->errors();
    					}
    					
    					// Error, could not upload the files
    					if ($errors) {
    						$this->Input->setErrors($errors);
    						// Attempt to remove the files if they were somehow written
    						foreach ($file_vars['files'] as $files) {
    							if (isset($files['file_name']))
    								@unlink($files['file_name']);
    						}
    						return;
    					}
    					else {
    						// Add the attachments
    						$file_fields = array("reply_id", "name", "file_name");
    						foreach ($file_vars['files'] as $files) {
    							if (!empty($files))
    								$this->Record->insert("support_attachmentspro", array_merge($files, array('reply_id' => $reply_id)), $file_fields);
    						}
    					}
    				}
    			}
    		}
    		
    		// Only attempt to update log options if there are no previous errors
    		if (!empty($log_options) && !$this->errors()) {
    			// Update the support ticket
    			$data = array_intersect_key($vars, $loggable_fields);
    			$ticket_staff_id_field = array();
    			if (isset($data['ticket_staff_id']))
    				$ticket_staff_id_field = (isset($data['ticket_staff_id']) ? array('staff_id' => $data['ticket_staff_id']) : array());
    				
    			$this->edit($ticket_id, array_merge($data, $ticket_staff_id_field), false);
    			
    			if (!($errors = $this->errors())) {
    				// Log each support ticket field change
    				foreach ($log_options as $field) {
    					$log_vars = array(
                            'staff_id' => (array_key_exists("staff_id", $vars) ? $vars['staff_id'] : $this->system_staff_id),
    						'type' => "log"
    					);
    					
    					$lang_var1 = "";
    					switch ($field) {
    						case "department_id":
    							$department = $this->Record->select("name")->from("support_departmentspro")->
    								where("id", "=", $vars['department_id'])->fetch();
    							$lang_var1 = ($department ? $department->name : "");
    							break;
    						case "priority":
    							$priorities = $this->getPriorities();
    							$lang_var1 = (isset($priorities[$vars['priority']]) ? $priorities[$vars['priority']] : "");
    							break;
    						case "status":
    							$statuses = $this->getStatuses();
    							$lang_var1 = (isset($statuses[$vars['status']]) ? $statuses[$vars['status']] : "");
    							break;
    						case "ticket_staff_id":
    							if (!isset($this->Staff))
    								Loader::loadModels($this, array("Staff"));
    								
    							$staff = $this->Staff->get($vars['ticket_staff_id']);
    							
    							if ($vars['ticket_staff_id'] && $staff)
    								$lang_var1 = $staff->first_name . " " . $staff->last_name;
    							else
    								$lang_var1 = Language::_("SupportManagerproTickets.log.unassigned", true);
    						default:
    							break;
    					}
    					
    					$log_vars['details'] = Language::_("SupportManagerproTickets.log." . $field, true, $lang_var1);
    					
    					$this->addReply($ticket_id, $log_vars);
    				}
    			}
    		}
    		
    		// Return the ID of the reply
    		if (isset($reply_id))
    			return $reply_id;
    	}
    
  10. It's possible, but not recommended for the aforementioned reason of breaking the MVC design pattern. It is simpler for the controller to just call a plugin's model that creates the query and returns the results.

     

     

     

    Take a look here. Call the API using the plugin's name and model, e.g. consider fetching a support department from the support manager plugin:

    $response = $api->get("support_manager.support_manager_departments", "get", array('department_id' => 1));
    

    Could you clarify?

     

     

    I need to change the title of the plugin to display in the client page.

    $response = $api->get("support_manager.support_manager_departments", "get", array('department_id' => 1));
    

    Is this method also can be used for open ticket?

  11. You have two solutions (not in any particular order):

    One solution is you can make two separate calls. First make a call to the function auth from the user model. If the function returns true, then you make another call to get the client id via the function getByUsername. getByUsername will return an object for that user, which would include the client id (among other properties that you might need).

    Second solution is to pass in the correct Session Object to the login function you have above. You might want to include miniPHP's session object and pass that in. You could also create a class that has the same public methods as miniPHP's session class, but do nothing / return null (that might work).

    A complete list of the functions and parameters for users can be found here: http://source-docs.blesta.com/class-Users.html More information on miniPHP's session class can be found here: http://source-docs.blesta.com/class-Session.html

    -Adam

     

    Now i use first,ths!

×
×
  • Create New...