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

[MOD] - Due Date on Client New Ticket Form

This is my first MOD guide (As requested by a few forum member) which will allow your clients to select a due date and time when raising a ticket. If you have any problems because it isn't clear or if you find anything that I could have done better please reply!

Lest start by putting the javascript and images required in the right places.

1. Create a folder called js in main directory. So path would be /js/

2. Copy calendar.js from /scp/js/ and paste in to newly created /js/

2a. Copy arrowleftmonth.gif, arrowrightmonth.gif and cal.png from /scp/images/ and paste in to /images/


3. Open /include/client/header.inc.php and below

[HTML][/HTML]

add

[HTML][/HTML]

save and close header.inc.php

4. Open /include/client/open.inc.php and below

[HTML] Subject:

">
 * <?=$errors['subject']?>

[/HTML]

add

[HTML]

Due Date:

"
onclick="event.cancelBubble=true;calendar(this);" autocomplete=OFF>

  
<?php
$min=$hr=null;
if($info['time'])
list($hr,$min)=explode(':',$info['time']);
echo Misc::timeDropdown($hr,$min,'time');
?>
  <?=$errors['duedate']?>


[/HTML]

save and close open.inc.php


5.Finally open /include/class.ticket.php

find (around line 1307)

    $extId=Ticket::genExtRandID();
$sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.


and below

',subject='.db_input(Format::striptags($var['subject'])).


add

',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time']))).


Save and close class.ticket.php and go and test your due date field with date picker.

PS

If your want your due date to be displayed as DD/MM/YY see this thread!

http://osticket.com/forums/showpost.php?p=16926&postcount=4

Cheers
Tom

Comments

  • Thanks for doing this! It will be next week at some point before I get to try adding it to our system, but I am certainly looking forward to it. :D
  • sternen;16957 said:
    Thanks for doing this! It will be next week at some point before I get to try adding it to our system, but I am certainly looking forward to it. :D
    No problem! If you get stuck let me know and I will do what I can to try and help! :p
  • Thanks coatezy! This is a good MOD.;)
    Can you help me with two modification:
    - client can't select due date less that current day-hour-minute;
    - if client doesn't select any due date, generated ticket to be with blank due date not with curent date and 00:00 hour.
    Thanks in advice!
  • Thank you. Prfect MOD. :D
  • coatezy;16953 said:

    5.Finally open /include/class.ticket.php

    find (around line 1307)

        $extId=Ticket::genExtRandID();
    $sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.


    and below

    ',subject='.db_input(Format::striptags($var['subject'])).


    add

    ',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time']))).


    Save and close class.ticket.php and go and test your due date field with date picker.

    PS

    If your want your due date to be displayed as DD/MM/YY see this thread!

    http://osticket.com/forums/showpost.php?p=16926&postcount=4

    Cheers
    Tom
    Hi ! Great MOD !
    I had several issues with it (blank date = current date)
    So, this is how I fixed it :

    At point 5. of your MOD, in include\class.ticket.php, in function create, I added :


    $sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
    ',ticketID='.db_input($extId).
    ',dept_id='.db_input($deptId).
    ',topic_id='.db_input($topicId).
    ',priority_id='.db_input($priorityId).
    ',email='.db_input($var['email']).
    ',name='.db_input(Format::striptags($var['name'])).
    ',subject='.db_input(Format::striptags($var['subject'])).
    ',helptopic='.db_input(Format::striptags($topicDesc)).
    ',phone=\"'.db_input($var['phone'],false).'\"'.
    ',phone_ext='.db_input($var['phone_ext']?$var['phone_ext']:'').
    ',ip_address='.db_input($ipaddress).
    ',source='.db_input($source).
    ',duedate='.($var['duedate']?db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time']))):'NULL'); //--Add 2011/05/11

    //Make sure the origin is staff - avoid firebug hack! --Removed 2011/05/11
    // if($var['duedate'] && !strcasecmp($origin,'staff'))
    // $sql.=',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time'])));


    This sould work fine, although, you authorize anyone to insert a due date when creating a ticket (not only staff members).

    Bye !
    Raysko
  • Thank you, great mod!

    Thank you. I do have one issue that I'm hoping someone here can resolve, though. The dropdown calendar works perfectly for staff that are logged in, but it only shows a text field when you're not logged in. I would like to be able to have this calendar available for all.

    Thanks again for this great mod, and any help would be greatly appreciated.
  • can you please supply the code to allow the due date on the insert to be one day later than the create date
  • MOD conflict?

    This MOD helped me out a bunch, thanks!

    I've been running it fine for a few weeks now, but just ran into an issue that I believe is related to this mod.

    If you create a new ticket from the staff panel and set a due date, then you get an error because the SQL statement is trying to include the due date twice.

    This code added around line 1307 of class.ticket.php for the mod:
    ',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time']))).


    causes a duplicate duedate entry when in staff panel and creating a ticket with a duedate because just below around line 1316 of class.ticket.php is:
            //Make sure the origin is staff - avoid firebug hack!
    if($var['duedate'] && !strcasecmp($origin,'staff'))
    $sql.=',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time'])));


    Seems like duedate is only inputted if origin is staff as to prevent a firebug hack. I don't really understand why or how that works or what. Just know it seems to be causing me problems with creating a ticket from staff panel when setting a due date. Leaving due date blank does not create a problem.

    Resolution? - apparently remove the firebug hack prevention code. Not sure if this is a good idea or not though.

    Dan
  • coatezy;16953 said:
    This is my first MOD guide (As requested by a few forum member) which will allow your clients to select a due date and time when raising a ticket. If you have any problems because it isn't clear or if you find anything that I could have done better please reply!

    Lest start by putting the javascript and images required in the right places.

    1. Create a folder called js in main directory. So path would be /js/

    2. Copy calendar.js from /scp/js/ and paste in to newly created /js/

    2a. Copy arrowleftmonth.gif, arrowrightmonth.gif and cal.png from /scp/images/ and paste in to /images/


    3. Open /include/client/header.inc.php and below

    [HTML][/HTML]

    add

    [HTML][/HTML]

    save and close header.inc.php

    4. Open /include/client/open.inc.php and below

    [HTML] Subject:

    ">
     * <?=$errors['subject']?>

    [/HTML]

    add

    [HTML]

    Due Date:

    "
    onclick="event.cancelBubble=true;calendar(this);" autocomplete=OFF>

      
    <?php
    $min=$hr=null;
    if($info['time'])
    list($hr,$min)=explode(':',$info['time']);
    echo Misc::timeDropdown($hr,$min,'time');
    ?>
      <?=$errors['duedate']?>


    [/HTML]

    save and close open.inc.php


    5.Finally open /include/class.ticket.php

    find (around line 1307)

        $extId=Ticket::genExtRandID();
    $sql= 'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.


    and below

    ',subject='.db_input(Format::striptags($var['subject'])).


    add

    ',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time']))).


    Save and close class.ticket.php and go and test your due date field with date picker.

    PS

    If your want your due date to be displayed as DD/MM/YY see this thread!

    http://osticket.com/forums/showpost.php?p=16926&postcount=4

    Cheers
    Tom
    I am using osticket 1.7 rc2 and i dont see the calendar is there a way to do this in my version? very new to osticket
  • tanza14,

    1.7 rc2 uses jQuery UI, so you can modify the code to use the datepicker function that is inherent in jQuery UI. Here's a screen of what I am doing:

    image

    There are several steps involved, similar to what Coatezy originally did. If you need help I can share my code with you.
  • I too am intrested in adding this for 1.7RC2. If you could please share. Thanks.
  • 1.7RC2 Due Date Mod with jQuery UI Instructions

    Here's how I did it:

    1. Open /include/client/header.inc.php and below:

    <script src=\"<?php echo ROOT_PATH; ?>js/osticket.js\"></script>


    Add:

    <script src=\"<?php echo ROOT_PATH; ?>js/jquery-ui-1.8.18.custom.min.js\"></script>
    <script>
    $(function() {
    $( \"#datepicker\" ).datepicker();
    });
    </script>


    Below:

    <link rel=\"stylesheet\" href=\"<?php echo ASSETS_PATH; ?>css/theme.css\" media=\"screen\">
    <link rel=\"stylesheet\" href=\"<?php echo ASSETS_PATH; ?>css/print.css\" media=\"print\">


    Add:

    <link rel=\"stylesheet\" href=\"<?php echo ASSETS_PATH; ?>css/redmond/jquery-ui-1.9.1.custom.css\">


    Save and close. This makes jQuery UI available to the client interface.

    2. Open /include/client/open.inc.php and below:

            <tr>
    <td class=\"required\">Subject:</td>
    <td>
    <input id=\"subject\" type=\"text\" name=\"subject\" size=\"40\" value=\"<?php echo $info['subject']; ?>\">
    <font class=\"error\">*&nbsp;<?php echo $errors['subject']; ?></font>
    </td>
    </tr>


    Add:

    <!-- Due Date Addition -->
    <tr>
    <td align=\"left\" valign=\"top\"><strong>Due Date:</strong></td>
    <td>
    <input id=\"datepicker\" name=\"duedate\" value=\"<?=Format::htmlchars($info['duedate'])?>\" />
    <?php
    $min=$hr=null;
    if($info['time'])
    list($hr,$min)=explode(':',$info['time']);
    echo Misc::timeDropdown($hr,$min,'time');
    ?>
    </td>
    </tr>
    <!-- Due Date Addition -->


    3. Last, open /includes/class.ticket.php and find:

    .' ,subject='.db_input(Format::striptags($vars['subject']))


    and below it insert:

    .',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($vars['duedate'].' '.$vars['time'])))


    Save and test!

    :) Special thanks to Coatezy for laying the groundwork! :)
  • Tested and in good working order. Much thanks!

    ::Edit::
    Missed that 1.7RC3 was released a few days ago. This works with that as well.
  • staff can't select due date less that current day-hour-minute

    can you please help me for coding so that
    "staff can't select due date less that current day-hour-minute"
  • veryspecialagent;29678 said:
    Here's how I did it::) Special thanks to Coatezy for laying the groundwork! :)
    I've found a 'feature'. The date isn't carrying over to Due Date field when looked at on the /scp log in side. It's blank.
  • How to give restriction in selecting due time?

    First of all thanks for this great MOD. It works fine!
    The due time drop down shows like 00:00, 00:15, 00:30 and so on...
    Is there any way to restrict the time slot - starting from 10:AM to 5:PM only?
  • Totally doesnt work in rc4

    Totally doesn't work in rc4 but there are tweaks to make it work
    visit http://jqueryui.com build your own date picker and download it
    i haven't finished working through the calls and css but it works sorta except due date doesn't post past ticket open page (big problem HELP NEEDED) ill post my steps for critique soon
  • DueDate not working in client form

    I did the update, and everything seems to be working, however, in the client form, when the client enters a due date, it doesn't show up in the ticket. I have to enter it manually.

    However, if I enter the ticket in the staff 'new ticket', the due date DOES show up on the ticket.

    Any ideas? I went over the code and it all looks right.
  • Fixed it!

    Basically to fix it, in the class.ticket.php file, I duplicated this:

    //Make sure the origin is staff - avoid firebug hack!
    if($var['duedate'] && !strcasecmp($origin,'staff'))
    $sql.=',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time'])));

    And basically changed 'staff' to 'web'. That enabled the duedate to now show up in the tickets that the client submits.

    This is the final code:

    //Make sure the origin is staff - avoid firebug hack!
    if($var['duedate'] && !strcasecmp($origin,'staff'))
    $sql.=',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time'])));

    //Make sure the origin is staff - avoid firebug hack!
    if($var['duedate'] && !strcasecmp($origin,'web'))
    $sql.=',duedate='.db_input(date('Y-m-d G:i',Misc::dbtime($var['duedate'].' '.$var['time'])));
  • veryspecialagent;29678 said:
    Here's how I did it:
    1. Open /include/client/header.inc.php and below:


    Save and test!

    :) Special thanks to Coatezy for laying the groundwork! :)

    Date background is white :confused::rolleyes:
    Use on 1.7 version

    Update: does not work on v 1.7 fresh install
    Date_Created.png
    584 x 186 - 9K
  • does not work in 1.9.x :(
  • This was posted in 2010 for version 1.6.
Sign In or Register to comment.