Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

How to assign task to php script?

Hello, some of my tickets may be fixed w/o human needs, like: "I did not recive email, pls send it to me again". I want for choosen category after OST create ticket execute some script with provided variables ( i see it like curl with POST var). My script do something and close ticket if success. 

Does it somehow possible with OST?

Comments

  • This is not currently a feature in osTicket. 
  • I thought a little about possibilities.
    I think i can get ticket by asking what i need directly from mysql.

    But next question how to close tickets after php self-solve it? 
    I guess, i have to duplicate what ost do to close ticket, any helpful direction to file i need?
  • Depending on if the email you're reffering to is from osticket then you should be able to do it all in the post process but if it's an external process you can use the below code to close the ticket from a script.

    Create this file under /api/close_ticket.php

    <?php
    @chdir(dirname(__FILE__).'/'); //Change dir.
    require('api.inc.php');

    if (!osTicket::is_cli())
        die(__('close_ticket.php only supports local cron calls - use http -> api/tasks/cron'));
    if (!isset($_GET['ticket_id']))
    die(__('close_ticket.php requires the ticket_id parameter ?ticket_id=1'));

    require_once(INCLUDE_DIR.'class.ticket.php');
    if(($temp = Ticket::lookup($_GET['ticket_id'])))
    echo $temp->setState('closed');
    ?>

    Then you should be able to close the ticket with %PHPDIR%/php.exe %OSTICKET%/api/close_ticket.php?ticket_id=1
    where you change the 1 to the id of the ticket you want to close, and the directory variables with your paths.
  • edited March 23
    Thanks, i got the idea. 

    Is there a function to add inner coment before close ticket? 
  • $temp->logActivity("Title", "Message body.");
Sign In or Register to comment.