+ Post New Thread
Results 1 to 12 of 12
Web Development Thread, Trying to display a field from a mysql website with ability to edit it on the page? in Coding and Web Development; I am currently using Hesk as our helpdesk which is brilliant and free. One thing it does not have, however, ...
  1. #1
    reggiep's Avatar
    Join Date
    Apr 2008
    Location
    In the vast area of space and time
    Posts
    1,548
    Thank Post
    517
    Thanked 56 Times in 50 Posts
    Rep Power
    29

    Trying to display a field from a mysql website with ability to edit it on the page?

    I am currently using Hesk as our helpdesk which is brilliant and free.
    One thing it does not have, however, is the ability to assign jobs to different staff.
    I thought an easy (not for me!) way to do this would be to edit the subject line so it had the tech's name at the end e.g. "printer broken - Allocated to Dave".

    I guess to achieve this I need to edit the admin's view php page of the ticket so they can edit the subject but I just don't have the skills to do this.

    Can anyone suggest some code to show a field with the ability to edit on a page or maybe a site with tutorials that I could go to to learn how to do this for myself?

    thanks

  2. #2

    maniac's Avatar
    Join Date
    Feb 2007
    Location
    Kent
    Posts
    3,037
    Thank Post
    209
    Thanked 425 Times in 306 Posts
    Rep Power
    144
    Quote Originally Posted by reggiep View Post
    I am currently using Hesk as our helpdesk which is brilliant and free.
    One thing it does not have, however, is the ability to assign jobs to different staff.
    I thought an easy (not for me!) way to do this would be to edit the subject line so it had the tech's name at the end e.g. "printer broken - Allocated to Dave".

    I guess to achieve this I need to edit the admin's view php page of the ticket so they can edit the subject but I just don't have the skills to do this.

    Can anyone suggest some code to show a field with the ability to edit on a page or maybe a site with tutorials that I could go to to learn how to do this for myself?

    thanks
    The coding for Hesk is well written, I added this feature to it when I used to use it for my helpdesk which displayed a drop down box at the bottom of the view ticket screen with all the users names in, you could select the user and click update and it allocated it to that person. I also added an extra collumn to the main display to show who the ticket was allocated to and also an extra line at the top of the ticket display to show the same information.

    All you need to do is add an extra field to the mySQL database, then for the collumn display and the display at the top of the ticket replicate some of the lines from the HESK script, changing the database field it references to your newly added one. For the allocation bit, I took the script which displays all the usernames at login and adapted it with a simple form submit button which updated the database - again this was stolen from elsewhere in the program.

    I had zero experience with PHP when I did this a long time ago, if you start looking through the PHP files, it's relatively easy to work out what they do, just have a play with a seperate copy of it like I did, and eventually you'll get the right bits of code in the right places and it will work.

    I don't have the code anymore unfortunitely, so I can't share it - sorry.

    Mike.
    Last edited by maniac; 24th January 2010 at 03:03 PM.

  3. Thanks to maniac from:

    reggiep (24th January 2010)

  4. #3
    reggiep's Avatar
    Join Date
    Apr 2008
    Location
    In the vast area of space and time
    Posts
    1,548
    Thank Post
    517
    Thanked 56 Times in 50 Posts
    Rep Power
    29
    @Maniac,
    Thanks, I have been trying my best to work out where I could steal bits from within Hesk. Using the login box is a stroke of genius. I shall have a play with that.

  5. #4

    Join Date
    Sep 2008
    Location
    Oakham
    Posts
    31
    Thank Post
    14
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Do you mean you want a dropdown box with staff members in that is pulled from sql db and made into a dropdown menu?

    Dan

  6. #5
    reggiep's Avatar
    Join Date
    Apr 2008
    Location
    In the vast area of space and time
    Posts
    1,548
    Thank Post
    517
    Thanked 56 Times in 50 Posts
    Rep Power
    29
    @Danny159
    That is the sort of thing yes!

    I am still struggling at the moment.

  7. #6

    Join Date
    Sep 2008
    Location
    Oakham
    Posts
    31
    Thank Post
    14
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Ahh easy when you know how =)

    Here you go:

    PHP Code:
    <?php
    $resultt 
    mysql_query("SELECT * FROM users ORDER BY id");
    echo 
    "<select name='assign' id='assign' class='text_field'>
    <option value='' selected='selected'>Select Someone...</option>"
    ;
    while (
    $row mysql_fetch_array($resultt))
    {
    $id $row["id"];
    $c_name $row["name"];
    $c_email $row["email"];
    echo 
    "<option value='$c_email'>$c_name - $c_email</option>";
    }
    echo 
    "</select>";
    ?>
    Hope this helps

    Dan

  8. Thanks to Danny159 from:

    reggiep (25th January 2010)

  9. #7
    reggiep's Avatar
    Join Date
    Apr 2008
    Location
    In the vast area of space and time
    Posts
    1,548
    Thank Post
    517
    Thanked 56 Times in 50 Posts
    Rep Power
    29
    Thanks, Not quite sure what I need to do with it but I'll try inserting it in different parts of different pages!

  10. #8

    Join Date
    Sep 2008
    Location
    Oakham
    Posts
    31
    Thank Post
    14
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Do you know PHP?

    Post some of your code and I will put it in for you and explain

    Dan

  11. #9
    reggiep's Avatar
    Join Date
    Apr 2008
    Location
    In the vast area of space and time
    Posts
    1,548
    Thank Post
    517
    Thanked 56 Times in 50 Posts
    Rep Power
    29
    Ok here goes!

    Code:
    define('IN_SCRIPT',1);
    define('HESK_PATH','../');
    
    /* Get all the required files and functions */
    require(HESK_PATH . 'hesk_settings.inc.php');
    require(HESK_PATH . 'language/'.$hesk_settings['language'].'.inc.php');
    require(HESK_PATH . 'inc/common.inc.php');
    require(HESK_PATH . 'inc/database.inc.php');
    
    hesk_session_start();
    hesk_isLoggedIn();
    hesk_dbConnect();
    
    /* Check permissions for this feature */
    hesk_checkPermission('can_view_tickets');
    $can_del_notes	= hesk_checkPermission('can_del_notes',0);
    $can_reply		= hesk_checkPermission('can_reply_tickets',0);
    $can_delete		= hesk_checkPermission('can_del_tickets',0);
    $can_edit		= hesk_checkPermission('can_edit_tickets',0);
    
    $trackingID = strtoupper(hesk_input($_REQUEST['track']));
    if (empty($trackingID))
    {
    	print_form();
    }
    
    /* Get ticket info */
    $sql = "SELECT * FROM `".$hesk_settings['db_pfix']."tickets` WHERE `trackid`='$trackingID' LIMIT 1";
    $result = hesk_dbQuery($sql);
    if (hesk_dbNumRows($result) != 1)
    {
    	hesk_error($hesklang['ticket_not_found']);
    }
    $ticket = hesk_dbFetchAssoc($result);
    
    /* Get category name and ID */
    $sql = "SELECT * FROM `".$hesk_settings['db_pfix']."categories` WHERE `id`=$ticket[category] LIMIT 1";
    $result = hesk_dbQuery($sql);
    /* If this category has been deleted use the default category with ID 1 */
    if (hesk_dbNumRows($result) != 1)
    {
    	$sql = "SELECT * FROM `".$hesk_settings['db_pfix']."categories` WHERE `id`=1 LIMIT 1";
    	$result = hesk_dbQuery($sql);
    }
    $category = hesk_dbFetchAssoc($result);
    
    /* Is this user allowed to view tickets inside this category? */
    hesk_okCategory($category['id']);
    
    /* Delete post action */
    if (isset($_GET['delete_post']) && $can_delete)
    {
    	$n = hesk_isNumber($_GET['delete_post']);
        if ($n)
        {
    		$sql = "DELETE FROM `".$hesk_settings['db_pfix']."replies` WHERE `id`=$n LIMIT 1";
    		$res = hesk_dbQuery($sql);
            $_SESSION['HESK_NOTICE']  = $hesklang['repd'];
            $_SESSION['HESK_MESSAGE'] = $hesklang['repl'];
        }
        header('Location: admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999));
        exit();
    }
    
    /* Delete notes action */
    if (isset($_GET['delnote']))
    {
    	$n = hesk_isNumber($_GET['delnote']);
        if ($n)
        {
        	if ($can_del_notes)
            {
    			$sql = "DELETE FROM `".$hesk_settings['db_pfix']."notes` WHERE `id`=$n LIMIT 1";
            }
            else
            {
            	$sql = "DELETE FROM `".$hesk_settings['db_pfix']."notes` WHERE `id`=$n AND `who`=$_SESSION[id] LIMIT 1";
            }
    		$res = hesk_dbQuery($sql);
        }
        header('Location: admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999));
        exit();
    }
    This is the beginning of a long page of code. i can see how your code would get some info out of a database but my server is hosted externally so i am not sure how to call from my own mysql tables, I can guess. I could make a table called users or techs and populate that through phpmyadmin and then call that with your php script?
    Last edited by reggiep; 25th January 2010 at 06:27 PM.

  12. #10
    Marci's Avatar
    Join Date
    Jun 2008
    Location
    Wakefield, West Yorkshire
    Posts
    888
    Thank Post
    84
    Thanked 234 Times in 193 Posts
    Rep Power
    82
    Alternatively, rethink how you use the ticket categories...? Quick and easy to implement... we have a category for each technician.

  13. #11

    Join Date
    Sep 2008
    Location
    Oakham
    Posts
    31
    Thank Post
    14
    Thanked 1 Time in 1 Post
    Rep Power
    0
    This is a bit confusing but that bit of code should work, if you get it in the right place on the right file!!!

    Dan

  14. #12
    Marci's Avatar
    Join Date
    Jun 2008
    Location
    Wakefield, West Yorkshire
    Posts
    888
    Thank Post
    84
    Thanked 234 Times in 193 Posts
    Rep Power
    82
    but my server is hosted externally so i am not sure how to call from my own mysql tables
    You don't - you call from the server's MySQL database which runs locally on your webserver. Add a table to the server's MySQL database (same one that Hesk uses) for your own info...

SHARE:
+ Post New Thread

Similar Threads

  1. Edit email field in A.D. for batch of users.
    By kennysarmy in forum Windows
    Replies: 4
    Last Post: 1st September 2009, 05:33 PM
  2. Cannot display 'uninstall Component' page
    By kerlj001 in forum EduGeek Joomla 1.0 Package
    Replies: 0
    Last Post: 18th May 2009, 07:56 PM
  3. Which file do I need to edit to change front page graphics?
    By reggiep in forum EduGeek Joomla 1.0 Package
    Replies: 2
    Last Post: 22nd April 2008, 02:18 PM
  4. Censornet Access Denied Page Edit
    By HallX in forum *nix
    Replies: 4
    Last Post: 12th March 2007, 09:05 AM
  5. PHP/mysql website cms problem
    By netadmin in forum Web Development
    Replies: 3
    Last Post: 10th March 2007, 03:44 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •