Custom Field Required Format

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
Josh
Posts: 31
Joined: Wed Apr 04, 2007 3:13 pm

Custom Field Required Format

Post by Josh »

Script URL: na
Version of script: .94
Hosting company: Internal
URL of phpinfo.php: na
URL of session_test.php: na
What terms did you try when SEARCHING for a solution: Date/custom/format

Write your message below:

Seems you've been doing a lot up updates with Hesk. Congrats to you Klemen. I've done some mild customizing with my small amount of PHP knowledge and I've got an open question to anyone.

This is the admin_main screen. The "Date Needed" is an optional custom field that is sortable. (see image)

My question is: Is there a way to prepopulate the field or require a particular format (MM\DD\YY) so that we can easily query by this custom date field. One of our users has a MySQL ODBC connector for MS Access and generates reports for ticket assignments, etc. As it stands I think it's just a text based field and queries do not produce a desired result.

We simply want users to be required to enter a standard date format since they like to ignore this and type things like "ASAP" when they submit a ticket.

Thanks.

-Josh

Image
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Still using such an old version? Ow, upgrade it :wink:

Do you use any other custom fields? If yes what number is the "Date needed" one?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Josh
Posts: 31
Joined: Wed Apr 04, 2007 3:13 pm

Post by Josh »

I know, it's time to upgrade. After customizing it's a little painful. :lol:

4 of the 5 custom fields are being used. The Date field is Custom Field #2 set to 8 characters currently.

Thanks,

josh
Klemen
Site Admin
Posts: 10142
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

You could try changing adding something like this

Code: Select all

if ($k == 'custom2')
{
	echo '
	<tr>
	<td style="text-align:right" width="150">'.$v['name'].': '.$v['req'].'</td>
	<td width="80%"><input type="text" name="'.$k.'" size="40" maxlength="'.$v['maxlen'].'" value="'.date("m\\\d\\\y").'" /></td>
	</tr>
	';
	continue;
}
to index.php just below

Code: Select all

            else
            {
            	$k_value  = '';
            }
(twice in the file!).

Haven't tested it, but this should this should prepopulate the filed with correct date format.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Josh
Posts: 31
Joined: Wed Apr 04, 2007 3:13 pm

Post by Josh »

Thanks Klemen

My index page is a little old, so here's what I got. Seems to work so far even with the m/d/y change. Thanks for that.

I may tweek it just a bit as +7 days (if possible) might be a good default for expected completion which is what the field is used for in our case.

Thanks again.

Code: Select all


<!-- START CUSTOM BEFORE -->
<?php
/* custom fields BEFORE comments */
if ($hesk_settings['use_custom'] && $hesk_settings['custom_place']==1) {

    echo '<table border="0">';

    foreach ($hesk_settings['custom_fields'] as $k=>$v) {
        if ($v['use']) {
            if ($v['req']) {$v['req']='<font class="important">*</font>';}
            else {$v['req']='';}
            $k_value = stripslashes(hesk_input($_SESSION["c_$k"]));
			if ($k == 'custom2')
{
   echo '
   <tr>
   <td style="text-align:right" width="150">'.$v['name'].': '.$v['req'].'</td>
   <td width="80%"><input type="text" name="'.$k.'" size="40" maxlength="'.$v['maxlen'].'" value="'.date("m/d/y").'" /></td>
   </tr>
   ';
   continue;
}
            echo <<<EOC
    <tr>
    <td align="right" width="150">$v[name]: $v[req]</td>
    <td align="left" width="600"><input type="text" name="$k" size="40" maxlength="$v[maxlen]" value="$k_value"></td>
    </tr>

EOC;
        }
    }

    echo '</table> <hr>';
}
?>
<!-- END CUSTOM BEFORE -->
Post Reply