How to Add New Tab Next to Post Reply Tab in Staff Panel of osTicket v1.6 RC5

Have you ever wanted to add a new tab next to Post Reply tab in Staff Panel of your osTicket System? Well, here is the solution. There are two possibilities of this purpose. First, you want to display something which is read-only, such as static information. Or, the second, you want to add the form inside that new tab. We will discuss for those both possibilities. This modification applied for staff-side only.

Open your \include\staff\viewticket.inc.php, and find this code:

342
343
344
345
346
347
348
349
350
351
                        <p>
                            <div  style="margin-left: 50px; margin-top: 30px; margin-bottom: 10px;border: 0px;">
                                <input class="button" type='submit' value='Post Reply' />
                                <input class="button" type='reset' value='Reset' />
                                <input class="button" type='button' value='Cancel' onClick="history.go(-1)" />
                            </div>
                        </p>
                    </form>                
                </p>
            </div>

then after the last line of that code, please insert this following code:

352
353
354
355
356
357
            <div id="youractionhere" class="tabbertab"  align="left">
                <h2>Your New Tab</h2>
                <p>
                This will only demonstrate how you can add your own new tab in viewticket page.
                </p>
	    </div>

It depends on the purpose of that new tab. If you want only to display some information which is read-only, then you simply use the technique that shown on the code above. That’s it, and done until this point! You don’t have to do anything that we will explain on the next paragraph below.

However, if you want this new tab has a form inside, for example, you want to process or send the 2 new field, then we have to created a form and put it inside that new tab. Simply replace this following code that we take from above:

354
355
356
                <p>
                This will only demonstrate how you can add your own new tab in viewticket page.
                </p>

become:

353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
                <p>
                    <form action="tickets.php?id=<?=$id?>#youractionhere" name="youractionhere" class="inline" method="post" enctype="multipart/form-data">
                        <input type="hidden" name="ticket_id" value="<?=$id?>">
                        <input type="hidden" name="a" value="youractionhere">
                        <p>
 
                        <div>
                            <label for="field-one">Field One:</label>
                            <input type="text" name="field-one" id="field-one" value="<?=$info['field-one']?>" size=30px />
                            </select><font class="error">*&nbsp;<?=$errors['field-one']?></font>
                        </div>
                        <div style="margin-top: 3px;">
                            <label for="field-two" valign="top">Field Two:</label>
                                <font class="error">*&nbsp;<?=$errors['field-two']?></font></label><br/>
                            <textarea name="field-two" id="field-two" cols="80" rows="7" wrap="soft" style="width:90%"><?=$info['field-two']?></textarea>
                        </div>
 
                            <div  align="left" style="margin-left: 50px;margin-top: 10px; margin-bottom: 10px;border: 0px;">
                                <input class="button" type='submit' value='Submit' />
                                <input class="button" type='reset' value='Reset' />
                                <input class="button" type='button' value='Cancel' onClick="history.go(-1)" />
                            </div>
                        </p>
                    </form>
                </p>

After that, we have to catch that values from the form in the \scp\tickets.php file. Find this code in that file:

106
107
108
109
            }else{
                $errors['err']=$errors['err']?$errors['err']:'Unable to post the response.';
            }
            break;

then after the last line of that code above, please insert this following code:

110
111
112
113
114
115
116
117
118
119
120
        case 'youractionhere':
            $fields=array();
            $fields['field-one'] = array('type'=>'text',  'required'=>1, 'error'=>'Field one required');
            $fields['field-two'] = array('type'=>'text',  'required'=>1, 'error'=>'Field two required');
            $params = new Validator($fields);
            if(!$params->validate($_POST)){
                $errors=array_merge($errors,$params->errors());
            }
            // Proceed here, what do you want it to do for those two fields above?
            // Insert it or update the existing value to database? It's up to you, right?
	break;

Generally, only those steps above that you have to do. If you want to add another functionality or your own algorithm, you can follow the techniques that already exist on another modifications I created on this blog. Have a nice try, and good luck!

Share

815 viewsPrint This Post Print This Post

Speak Your Mind

*


*