Jump to content
Sign in to follow this  
Blesta.Store

Support manager API

Recommended Posts

Is there a way to extend the support manager to create a ticket or will it be best to use the API and if it's the API how is the best way to do it?

I saw @Blesta Addons did this and I edited it but I'm trying to start a ticket?
 

$reply_data = array(
              'ticket_id'=> NULL,
              'vars' => array(
                  'ticket_id'=>null,
                  'staff_id' => null,
                  'client_id' => $data['client_id'],
                  'contact_id' => null,
                  'type' => "reply",
                  'details' => $data['content'],
                  'status' => "open",
                  'staff_id' => null,
              ),
              'files' => null,
              'new_ticket' => true
          );
          $response = $api->post("support_manager.support_manager_tickets", "addReply", $reply_data);

Because I would like to set these up somehow:
- Subject
- Department

- priority

Thank you for your help.

the big lebowski thank you GIF

Share this post


Link to post
Share on other sites

Well I kinds depends.  If you are looking to do it through the API then you should first call SupportManagerTickets::add() like this

$ticket_data = [
    'vars' => [
        'department_id' => 1,
        'staff_id' => 1,  // This field is optional
        'service_id' => 1,  // This field is optional
        'client_id' => 1,  // This field is optional
        'email' => 'firsttes@mailinator.com',  // This field is optional
        'summary' => 'Something is terribly wrong',
        'priority' => 'critical',
        'status' => 'open'
    ]
]

$ticket = $api->post("support_manager.support_manager_tickets", "add", $ticket_data);

On the other hand, if you are within Blesta you should be able to use the loader to access the model even though it's from a plugin.  In a controller that would look like this

$ticket_data = [
    'department_id' => 1,
    'staff_id' => 1,  // This field is optional
    'service_id' => 1,  // This field is optional
    'client_id' => 1,  // This field is optional
    'email' => 'firsttes@mailinator.com',  // This field is optional
    'summary' => 'Something is terribly wrong',
    'priority' => 'critical',
    'status' => 'open'
];

$this->uses(['SupportManager.SupportManagerTickets']);
$ticket = $this->SupportManagerTickets->add($ticket_data);

brad pitt hello GIF

Share this post


Link to post
Share on other sites
6 minutes ago, Tyson said:

There are two separate calls you need to make:

  1. Create a ticket (as @Jono mentioned above)
  2. Create a reply for the ticket (as you did in your OP).
    1. FYI the first question from a customer that opens the ticket represents the first reply

Thanks mate. Is there a way to redirect to another function in Blesta for example:

<?php

public function index(){
  if($success == true){
      return self::success();
  }
}

public function success(){
	//run this function?
}

?>

 

Share this post


Link to post
Share on other sites
56 minutes ago, Blesta.Store said:

Thanks mate. Is there a way to redirect to another function in Blesta for example:


<?php

public function index(){
  if($success == true){
      return self::success();
  }
}

public function success(){
	//run this function?
}

?>

 

Your example mixes procedural and class syntax, so I'm not sure if you're running individual functions or if those are methods in a class.

If you are writing procedural functions, simply:

return success();

otherwise for one class method to call another non-statically:

return $this->success();

 

Share this post


Link to post
Share on other sites

Thanks @Tyson mate that return

$this->valid($client_info);

worked as I found I had to pass the variable through to the function to show the information on the views.

However submitting another form it tries to run the first form post in the index function and not the post in the success function do I need to set something up on the forms to call each one?

<?php
class Validate extends SupportController
{
  public function index(){
      if (!empty($this->post)) {
		$data2 = (isset($this->post) ? $this->post : '');
		if($data2){
			return $this->valid($data2);
		}
      }
  }
  public function valid($data2){
	if (!empty($this->post)) {
		$data = (isset($this->post) ? $this->post : '');
		if($data){
			return true;
		}
	}
  }
}

both of the forms have this in the views:
 

<?php
	$this->Form->create(null, ['id' => 'validate', 'enctype' => 'multipart/form-data']);
?>
<?php
	$this->Form->create(null, ['id' => 'support_ticket', 'enctype' => 'multipart/form-data']);
?>

 

Share this post


Link to post
Share on other sites

It sounds like you want to POST each form to a separate location.

<?php
// POST to the valid method
$this->Form->create('/validate/valid/', [...]);
...
$this->Form->end();

// POST to the index method
$this->Form->create(null, [...]);
...
$this->Form->end();

Your Validate::valid() method really shouldn't require an argument if you want to POST to it

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...