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

Adding a New Field to tickets

2456789

Comments

  • micro3d

    Thanks so much for the help so far. I am close to getting this to work. The only problem now is that when I add


    Domain / Company:
    <?=Format::htmlchars($ticket->getdomain_name())?>


    ....everything AFTER that point won't display on the page. I added it after the getName variable and even tried it after other variables and it won't display the value requested nor anything after. I get a blank page after that point.

    Never mind....I added the wrong var name to 'get'....it's working great now...thanks a million :-D
  • Works great but...

    Hi,

    Great mod and works really well, the only issue i have i've changed open.ini.php so that it if the client is logged in it remembers there company details. So I used this as the code;

    <tr>
    <th width=\"20%\">Company:</th>
    <td>
    <?if ($thisclient && ($company=$thisclient->getCompany())) {
    ?>
    <input type=\"hidden\" name=\"company\" value=\"<?=$company?>\"><?=$company?>
    <?}else {?>
    <input type=\"text\" name=\"company\" size=\"25\" value=\"<?=$info['company']?>\">
    <?}?>
    &nbsp;<font class=\"error\">*&nbsp;<?=$errors['company']?></font>
    </td>
    </tr>

    but the page then wont load. If i use this (as listed on first post);

    <tr>
    <th>Company:</th>
    <td>
    <input type=\"text\" name=\"company\" size=\"25\" value=\"<?=$info['company']?>\">
    &nbsp;<font class=\"error\">*&nbsp;<?=$errors['company']?></font>
    </td>
    </tr>

    it loads fine but i would like to have it remeber the new field

    Any ideas please people?

    Many thanks in advance,
    Brad
  • hello sir its working realy good i have done all things not u know what how do i change drop down menu like there is written suppot, billing like this i want to change it how its possible in Help Topic:
  • MySQL field not getting populated.

    Hey guys. Ive got all the code in place as descried in the first post of this topic however its not working. For some reason the MySQL field created is not being populated by the web form. Any ideas why?

    Does the file class.client.php need to be edited?
  • Frink09;3304 said:
    As a favor, can someone help us with adding that new field to the "tickets.inc.php" page?!?! It would be greatly appreciated. We'd like to be able to see Company in that table as a column where you see the ticket id, date, department, priority etc.
    Any news on this?
  • neo.sunny - yes, you should add

    function getNewvar(){
    return($this->Newvar);
    }


    to your class.client.php

    It will work for sure ...

    Pete
  • What does it mean when i get this error?

    * Forum Name Required (type not set)
  • blabley;5547 said:
    Hi,

    Great mod and works really well, the only issue i have i've changed open.ini.php so that it if the client is logged in it remembers there company details. So I used this as the code;

    <tr>
    <th width=\"20%\">Company:</th>
    <td>
    <?if ($thisclient && ($company=$thisclient->getCompany())) {
    ?>
    <input type=\"hidden\" name=\"company\" value=\"<?=$company?>\"><?=$company?>
    <?}else {?>
    <input type=\"text\" name=\"company\" size=\"25\" value=\"<?=$info['company']?>\">
    <?}?>
    &nbsp;<font class=\"error\">*&nbsp;<?=$errors['company']?></font>
    </td>
    </tr>

    but the page then wont load. If i use this (as listed on first post);

    <tr>
    <th>Company:</th>
    <td>
    <input type=\"text\" name=\"company\" size=\"25\" value=\"<?=$info['company']?>\">
    &nbsp;<font class=\"error\">*&nbsp;<?=$errors['company']?></font>
    </td>
    </tr>

    it loads fine but i would like to have it remeber the new field

    Any ideas please people?

    Many thanks in advance,
    Brad
    In include\class.client.php

    Working on new var being company change following:

    Line 29 add:

    var $company;


    Line 45 add "company" between "name," and "email"

    function lookup($id,$email=''){
    $sql='SELECT ticket_id,ticketID,name,company,email FROM '.TICKET_TABLE.' WHERE ticketID='.db_input($id);
    if($email){ //don't validate...using whatever is entered.
    $sql.=' AND email='.db_input($email);
    }


    Line 60 add:

    	$this->company = $row['company'];


    Line 84 add:

    function getCompany(){
    return($this->company);
    }


    Hope that helps.
  • Email var

    FYI

    I wanted to use the new field I created in the staff emails so I have just added the following:

    \include\class.ticket.php

    Line 549:

    $body = str_replace(\"%company\", $this->getCompany(),$body);


    Line 1015:

     $body = str_replace(\"%company\", $ticket->getCompany(),$body);


    Now I can %company to my staff email templates

    Seems to work for me.
  • Would it be possible for someone to zip up the edited effected files and post them. I'm not a programmer and all the variations are a bit confusing on which ones to use. THANKS Meanwhile, I will see if I can get this to work.
  • Details not dispalying

    Hey guys...

    We have added the new filed. The new filed gets populated in mysql however when trying to view the filed though viewticket.php it displays blank.

    Any ideas
  • I gave up on this app. Adding fields needs to added to the core. You shouldn't have to spend weeks hacking the pages to get what you want. I found another app that has the ability to add fields through the admin settings and it adds the fields to the database. Much easier.

    Don't get me wrong, OS ticket is a great peice of software. And it has a couple features that the new software doesn't. But those I can live without. Good Luck.
  • Trouble

    I added custom fields by edited the required code; however, when I try to test the fields by creating a test ticket, it returns the "Unable to create a ticket. Please correct errors below and try again!" error message even after de-flagging the variables as being required.

    Any suggestions?

    EDIT: After some tinkering, I figured out that the database is not being populated with information from the custom fields, I can't figure out why it isn't working.
  • No being added to database

    Hi,

    I have tried 6 times and have looked over all my files many times. I added an order number field and when I open a support ticket it submits the ticket correctly. But does not insert the order number into the database. If I add it manually using phpmyadmin it shows up correctly in the admin side. I cannot figure out why its not added when the support ticket is submitted.

    Any suggestions?

    I setup the database entry as follows:

    Field: orderid
    Type: VARCHAR
    Length: 6
    Collation: Latin1_swedish_ci
    Null: not null

    Thanks,
    Jamie
  • @john2323,

    Have you added your new field to the INSERT INTO SQL code just like shown below? (See newvar code)

            $sql=   'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
    ',ticketID='.db_input($extId).
    ',dept_id='.db_input($deptId).
    ',priority_id='.db_input($priorityId).
    ',email='.db_input($var['email']).
    ',name='.db_input(Format::striptags($var['name'])).
    ',newvar='.db_input(Format::striptags($var['newvar'])).


    Best regards,
    Masino Sinaga
  • Hi,

    Yes I have added that code.

    Thanks,
    Jamie
  • Oh wait, let me check, maybe not.
  • No I did add it. You just replace the newvar with the database table name. In this case I named it orderid. Correct?
  • Sorry for all the posts. Found the problem. Code should be:

     $sql=   'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
    ',ticketID='.db_input($extId).
    ',dept_id='.db_input($deptId).
    ',priority_id='.db_input($priorityId).
    ',email='.db_input($var['email']).
    ',name='.db_input(Format::striptags($var['name'])).
    ',subject='.db_input(Format::striptags($var['subject'])).
    ',phone='.db_input($var['phone']).
    ',ip_address='.db_input($ipaddress).
    ',orderid='.db_input(Format::striptags($var['orderid'])).
    ',source='.db_input($source);


    I had:

     $sql=   'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
    ',ticketID='.db_input($extId).
    ',dept_id='.db_input($deptId).
    ',priority_id='.db_input($priorityId).
    ',email='.db_input($var['email']).
    ',name='.db_input(Format::striptags($var['name'])).
    ',subject='.db_input(Format::striptags($var['subject'])).
    ',phone='.db_input($var['phone']).
    ',ip_address='.db_input($ipaddress).
    ',source='.db_input($source);
    ',orderid='.db_input(Format::striptags($var['orderid'])).


    I don't know the technical wording but the ); in the source database, I assume closes out the code so it would not submit to the database.

    Anyway seems to be working great! Thanks for the help!

    Jamie
  • @john2323,

    You're welcome. It's nice to know you solved your own code by yourself. Never give up, and have a nice day. ;)

    Best regards,
    Masino Sinaga
  • Just to say, thanks for this John, saved me a lot of searching! :)
    john2323;7295 said:
    Sorry for all the posts. Found the problem. Code should be:

     $sql=   'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
    ',ticketID='.db_input($extId).
    ',dept_id='.db_input($deptId).
    ',priority_id='.db_input($priorityId).
    ',email='.db_input($var['email']).
    ',name='.db_input(Format::striptags($var['name'])).
    ',subject='.db_input(Format::striptags($var['subject'])).
    ',phone='.db_input($var['phone']).
    ',ip_address='.db_input($ipaddress).
    ',orderid='.db_input(Format::striptags($var['orderid'])).
    ',source='.db_input($source);


    I had:

     $sql=   'INSERT INTO '.TICKET_TABLE.' SET created=NOW() '.
    ',ticketID='.db_input($extId).
    ',dept_id='.db_input($deptId).
    ',priority_id='.db_input($priorityId).
    ',email='.db_input($var['email']).
    ',name='.db_input(Format::striptags($var['name'])).
    ',subject='.db_input(Format::striptags($var['subject'])).
    ',phone='.db_input($var['phone']).
    ',ip_address='.db_input($ipaddress).
    ',source='.db_input($source);
    ',orderid='.db_input(Format::striptags($var['orderid'])).


    I don't know the technical wording but the ); in the source database, I assume closes out the code so it would not submit to the database.

    Anyway seems to be working great! Thanks for the help!

    Jamie
  • adding address to ticket

    i'm not familiar with php-editing but i want to add an address and postal field to the ticket. Can somebody help me please ?
  • Thanks for this mod, I was able to successfully add a "serial number" field.

    However, when I use the search in the dashboard view, searches for the serial numbers do not return any results.

    Are custom fields just not searchable? Or did I do something wrong?

    Thanks,

    Steve
  • I went through and added new fields to my ticket. And I can successfully add tickets and what not. But I cannot edit the ticket and change the fields. It submits everything, but will not submit the new fields I added.

    Any ideas what I am missing?
  • Hi cyid
    I have added a field called company and I have made the following changes which also allows me to edit the field. So have a look and check that you have done the same:
    include/staff/editticket.inc.php
    at about line 11 add:
    'company' =>$ticket->getCompany(),
    at about line 52 add:

    Company:

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


    include/staff/tickets.inc.php
    At around line 199 include company in the $qselect = statement as follows:
    $qselect = 'SELECT DISTINCT ticket.ticket_id,lock_id,ticketID,ticket.dept_id,ticket.staff_id,subject,name,company,email,dept_name '.
    ',ticket.status,ticket.source,isoverdue,isanswered,ticket.created,pri.* ,count(attach.attach_id) as attachments ';
    At around line 383 add another column for the tickets table as follows:
    Company
    Also adjust the column widths of all the columns here so your new column fits in niceley, I have done mine like this:
    At around line 422 add to the last column (the last td statement):
    <?=Format::truncate($row['company'],19,strpos($row['company'],'@'))?> 
    Again adjust the truncate numbers so that it looks ok on your web page - I set mine at 19.

    tickets.php:
    At around line 39 add a variable to the existing ones:
    var $company; //mod090727_new_ticket_field
    At around line 72 add:
    $this->company =$row['company'];
    At around line 138 add:
    function getCompany(){
    return $this->company;
    }
    Because my field is a Comapany field I try to add it after the name or fullname each time.

    At around line 406 add company to the list of $search = array...:
    $search = array('/%id/','/%ticket/','/%email/','/%name/','/%company/','/%subject/','/%topic/','/%phone/','/%status/','/%priority/', '/%dept/','/%assigned_staff/','/%createdate/','/%duedate/','/%closedate/','/%url/');
    At around line 412 add (after name):
    $this->getCompany(),
    At around line 984 add (after name):
    $fields['company'] = array('type'=>'string', 'required'=>0, 'error'=>'Enter Private if not a Company');
    At around line 1022 add (after name):
    ',company='.db_input(Format::striptags($var['company'])).
    At around line 1071 add:
    $fields['company'] = array('type'=>'string', 'required'=>0, 'error'=>'Use Private if not a Company');
    At around line 1197 add (after name):
    ',company='.db_input(Format::striptags($var['company'])).
    And that seems to be it. Hopefully I have covered some things not already covered in this forum.

    Note: I cannot seem to make the field Company a non required field even though I have set the required value to 0. Hence the error response "Use Private if not a Company". This seems to work OK.
  • stevieg909;8491 said:
    Thanks for this mod, I was able to successfully add a "serial number" field.

    However, when I use the search in the dashboard view, searches for the serial numbers do not return any results.

    Are custom fields just not searchable? Or did I do something wrong?

    Thanks,

    Steve
    I had the same issue but I just figured it out. I have a custom field named acct_num that I wanted to be searchable. Here's how I did it.

    Open up tickets.inc.php and find this line:
    $qselect = 'SELECT DISTINCT ticket.ticket_id,lock_id,ticketID,ticket.dept_id,ticket.staff_id,subject,name,email,dept_name '.
    ',ticket.status,ticket.source,isoverdue,isanswered,ticket.created,pri.* ,count(attach.attach_id) as attachments ';


    made it into:

    $qselect = 'SELECT DISTINCT ticket.ticket_id,ticket.acct_num,lock_id,ticketID,ticket.dept_id,ticket.staff_id,subject,name,email,dept_name '.
    ',ticket.status,ticket.source,isoverdue,isanswered,ticket.created,pri.* ,count(attach.attach_id) as attachments ';


    THEN

    Find:
    $qwhere.=\" AND ticket.ticketID LIKE '$queryterm%' \";


    Made it:
    $qwhere.=\" AND (ticket.ticketID LIKE '$queryterm%' OR ticket.acct_num LIKE '$queryterm%')\";


    Now our account numbers are purely numerical so I got to be lazy in regards to implimenting it, it just took a while to find the stuff.
  • Adding a Dropdown Option

    Hi, Firstly a big massive thanks for this post so far, I found the instructions to add additional fields a very easily but have come accross another hurdle. I would like to add a new field which is a drop down option or preselected responses that aren't found in the MySQL Database but is is on the "support/include/client/open.inc.php" but once the form has been completed it will save the information into the database.

    For simplicity I have kept up with the new variation called "newvar"

    Below is part of the text found in the open.inc.php file


    <select name=\"newvar\" style=\"width:100%\">
    <option value=\"\" selected>Select One</option>
    <option value=\"option1\">option1</option>
    <option value=\"option2\">option2</option>
    <option value=\"option3\">option3</option>
    </select>


    In the class.ticket.php I have understood the first parts being


    class Ticket{

    var $id;
    var $extid;
    var $email;
    var $status;
    var $created;
    var $updated;
    var $priority;
    var $priority;
    var $newvar;


    second part


    if(($res=db_query($sql)) && db_num_rows($res)):
    $row=db_fetch_array($res);
    $this->id =$row['ticket_id'];
    $this->extid =$row['ticketID'];
    $this->email =$row['email'];
    $this->fullname =$row['name'];
    $this->newvar =$row['newvar'];


    third part


    //GET
    function getId(){
    return $this->id;
    }

    function getExtId(){
    return $this->extid;
    }

    function getEmail(){
    return $this->email;
    }

    function getNewvar(){
    return $this->newvar;
    }


    fourth part i guess, i think i got it correct


    function create($var,&$errors,$origin,$autorespond=true,$alertstaff=true) {
    global $cfg,$thisclient,$_FILES;

    $id=0;
    $fields=array();
    $fields['newvar'] = array('type'=>'int', 'required'=>1, 'error'=>'Field Required');



    last part


    I'm dunno what to do for this part and seek any assistance
  • Changes

    I see Many different bits and bobs of code spread throughout this topic and now confused which one to follow and test? Im using the Newest version of osTicket at the moment.

    I'll await someone's reply before going for it I think.
  • Follow the first post, thats the one i followed and worked great.
  • Help?

    Majority of it seems easy but im not entirely sure which to edit when I want these new specific fields..

    Domain Name/IP Address

    Cast Control Username/Password

    cPanel Username/Password

    I might give it a shot later but the main things im not too sure are the DATABASE stuff. If anyone has any time for a Remote Assistance later maybe so you can see if all is going well on my end? (Not asking anyone to do it for me unless they didnt mind, just thought remote assistance would be good so I can learn it myself and someone that knows this all can check im doing it correctly and any errors (if any).

    Jordan
Sign In or Register to comment.