Ok... so we're here to test me? I like it!

Anyway, I failed :

Here's my code for now:

<? if($row == "1")

{ ?>

<td style="background-color:#9C0"><?=$status_arr[$row;?></td>

<? } else { ?>

<? if ($row == "2")

{ ?>

<td style="background-color: #F00"><?=$status_arr[$row;?></td>

<? } else { ?>

<? if ($row == "3")

{ ?>

<td style="background-color: #FF0"><?=$status_arr[$row;?></td>

<? } ?>

<? } ?>

<? } ?>

Any suggestions?

EDIT:

Ooops! I didnt' see the tricky curve ball you threw in there!!

I just had to change staff_id to sold so it actually looks at the right colum in the DB... hehe...

Thanks!! This is great!

-Emil

Congrats! Now go (conditionally) conquer the world!!

Congrats! Now go (conditionally) conquer the world!!

Heh, well I did what you suggested and this I guess is my final code:

<? if($row == "0") {?>

<td style="background-color:#9C0"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "1") {?>

<td style="background-color:#F00"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "2") {?>

<td style="background-color:#F90"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "3") {?>

<td style="background-color:#FF0"><?=$status_arr[$row;?></td>

<? } ?>

It works great... Now, of course one thing leads to another so I guess my next challenge will be to post an internal reply every time somebody updates the ticket and who/when it was done.. :

Expect some questions :

-Emil

teryakisan, sorry for taking over your thread like this, but I'm at a dead end.. go figure :

So now that we are able to update the status of a ticket, I want to show WHO did it by an internal note..

I found a different hack that I did last week that shows who closed/re-opened a ticket so I tried to us some of that to my advantage but it's confusing.

from (http://sudobash.net/?p=133) he just added inside class.ticket.php:

$this->postNote('Ticket Closed');

return (db_query($sql) && db_affected_rows())?true;

inside the function of either close or re-open.

I'm thinking I need to create 4 new functions for each status update and based on that update, that function needs to be called. Is that right?

So at this point I'm at class.ticket.php:

function onUpdateSold() {

$this->postNote('Ticket Updated to Sold');

return (db_query($sql) && db_affected_rows())?true;

}

function onUpdateUnsold() {

$this->postNote('Ticket Updated to Unsold');

return (db_query($sql) && db_affected_rows())?true;

}

function onUpdatePending() {

$this->postNote('Ticket Updated to Pending');

return (db_query($sql) && db_affected_rows())?true;

}

function onUpdateWorking() {

$this->postNote('Ticket Updated to Working');

return (db_query($sql) && db_affected_rows())?true;

}

My problem is, how do I invoke these functions based on pressing the "update" button we created?

Wouldn't it be easier to just modify the the setSimpleStatus function instead? The idea is, make the function post up a note every time someone changes the work status, right? The setSimpleStatus function is the part that does all the heavy lifting, so lets make it do some more.

So here's what we have to start out with...

in class.ticket.php

function setSimpleStatus($status_val){

$status_val = (int) $status_val; // only allowed to use int

// you can add an error check and message here if you want

$sql = 'UPDATE ' . TICKET_TABLE . ' SET work=' .

db_input($status_val) . ' WHERE ' .

'ticket_id='.db_input($this->getId());

db_query($sql);

}

Lets use our handy dandy IF statement to write the note everytime we update the status...

function setSimpleStatus($status_val){

$status_val = (int) $status_val;// only allowed to use int

if ($status_val == 1){

$this->postNote('Status set to Reviewed');

}

if ($status_val == 2){

$this->postNote('Status set to Responded');

};

// you can add an error check and message here if you want

$sql = 'UPDATE ' . TICKET_TABLE . ' SET work=' .

db_input($status_val) . ' WHERE ' .

'ticket_id='.db_input($this->getId());

db_query($sql);

}

blank

There we go. No need for any new functions. The "what" the "who" and the "when" all wrapped up in one. Woohoo. Just add as many IF's as you have statuses. Note the semi-colons inside the curly braces. These are required since we are running a PHP function inside of another function. Once again, there is probably a much more efficient way to git r done, but, this works and helps you learn about the power of IF!!

BONUS!: In the event that you want to send the client the message about the status change, you can use postMessage in parallel with postNote, like this....

if ($status_val == 1){

$this->postNote('Status set to Reviewed');

$this->postMessage('Your Ticket has been reviewed, someone will contact you shortly.');

}

Here I go again, trying to kill a fly with a shot gun! :

Thanks teryakisan, you save me yet again!

9 days later

trying to put into frontend

teryakisan,

What a fantastic mod! It works great!

I also would like to have this status been shown on the client-side.

I was trying to edit /include/client/viewticket.inc.php

On the top (just under the <?php ) I put the code

$status_arr = array();

$qry = db_query('SELECT * FROM '. STATUS_TABLE);

while($res = db_fetch_array($qry)) {

$status_arr[$res = $res;

}

Then I made a new row in the table

<tr>

<td class="ColLabel"><strong>Voortgang:</strong></td>

<td><span><?=$status_arr[$row;?></span></td>

<td class="ColLabel"><strong>Email:</strong></td>

<td><span><?=$ticket->getEmail()?></span></td>

</tr>

Still it doesn't show the status.. What am I doing wrong?

I have a select drop-down that should simply inform my team members where we stand on the status of an RMA.

I am about to embark on some modifications myself and have a question about your design choice in implementing the simple status field. Specifically, how do you use this field, compared with the existing status enum field? It seems that your Finished is probably about the same as status Closed. Is that right? And everything else would be a variety of Open?

I suppose implementing a separate field gave you more flexibility than extending the status enum?

The reason for simple status to exist at all is because we use our OSTicket installation as a Support Ticketing / RMA system. Simple status is the status for the RMA part of the system, Regular status is for the support ticket part.

6 days later

Is it a fully working mod ?

if I try your mod will it work ?

can I show the status to the client side ?

yep

Yes it is a fully working mod and it does display on the client side. This was developed for a RMA system, which has lots of steps, and keeps the client informed of their RMA status.

Do I follow your first post ? is there a complete code that I could follow ?

I think you did some fix after you did the first post right ?

The full instructions are in post #28, 29, an 30.

I can't find the Email code in staff/ticket.inc.php

2. Next we'll add a new header to the table. I called mine "Progress".

Find this code...

Email

Directly beneath, add this code...

Progress

3. Now we will display the status. At the very top of the page, below the very first <?PHP , add this code...

$status_arr = array("Reviewed","Responded","Quotation Sent","PO Requested","PO Recieved","Awaiting Payment","Payment Recieved","In Transit", "Working", "Finished", "In Return Transit");

Then Find this code...

<td>&nbsp;<?=Format:($row,40)?></td>

Directly below, add this code...

<td nowrap >

<?=$status_arr[$row;?>

</td>

All done, now we have Simple status displaying in staff/tickets.inc.php, MOD completed in next post.

I believe that "email" may have been a field that I added myself. The entry is simply written to the table header, hence the . Good catch.

After implementation. I am getting Error in STATUS when I have click on.

"Problems loading requested admin page. (status)

Possibly access denied, if you believe this is in error please get technical support. "

What could be possibility for above Error?

Yes it is a fully working mod and it does display on the client side. This was developed for a RMA system, which has lots of steps, and keeps the client informed of their RMA status.

I did exactly the steps that you described in #28, 29 and 30.

I don't see any "RMA" simplestatus on the client side! Where do my clients see there "RMA" simplestatus then?

I can only see the "RMA" status in the backend... (when I'm logged in as staff or Admin)

oops!! I added it to my install but didn't update the tutorial. :

in include/client/viewticket.inc.php

under the very first <?php tag add this code...

function showOptionsDrop($selected){ // shows all options but selected...

$string = '';

$sql = 'SELECT * FROM ' . STATUS_TABLE;

$res = db_query($sql);

while ($row = db_fetch_array($res)) {

$k = $row;

$v = $row;

if($selected == $k) // don't double display the selected option

$string .= '<option selected value="'.$k.'">'.$v.'</option>'."\n";

else

$string .= '<option value="'.$k.'">'.$v.'</option>'."\n";

}

return $string;

}

Find this code...

<table align="center" class="infotable" cellspacing="1" cellpadding="3" width="100%" border=0>

Directly below add this code...

<tr>

<th width="100" >Simple Status:</th>

<td nowrap >

<form method="" action="" name="update">

<select name="updatework" width="150" style="width: 150px" disabled="disabled">

<?php echo showOptionsDrop($ticket->getSimpleStatus()); ?>

</select>

</form>

</tr>

Lets also display the status to the client on their open ticket list.

include/client/tickets.inc.php

Find the first block of table headers,around line 100 or so, add...

<th width="150">SimpleStatus</th>

Then, around line 129 or so, add this code...

<td nowrap >

<?if($row == "1")

{?>

<?php echo 'Reviewed'; ?>

<?}?>

<?if($row == "2")

{?>

<?php echo 'Responded'; ?>

<?}?>

<?if($row == "3")

{?>

<?php echo 'Quotation Sent'; ?>

<?}?>

<?if($row == "4")

{?>

<?php echo 'PO Requested'; ?>

<?}?>

<?if($row == "5")

{?>

<?php echo 'PO Recieved'; ?>

<?}?>

<?if($row == "6")

{?>

<span style="color:#F00; text-decoration;"><?php echo 'DFNP'; ?></span>

<?}?>

<?if($row == "7")

{?>

<span style="color:#2A9F00; text-decoration;"><?php echo 'DFP'; ?></span>

<?}?>

<?if($row == "8")

{?>

<?php echo 'Awaiting Payment'; ?>

<?}?>

<?if($row == "9")

{?>

<?php echo 'Payment Recieved'; ?>

<?}?>

<?if($row == "10")

{?>

<?php echo 'In Transit'; ?>

<?}?>

<?if($row == "11")

{?>

<?php echo 'Working'; ?>

<?}?>

<?if($row == "12")

{?>

<?php echo 'Finished'; ?>

<?}?>

<?if($row == "13")

{?>

<?php echo 'In Return Transit'; ?>

<?}?>

</td>

</tr>

There we go. Simple status on the client end. It could probably be prettier and better coded. :

I believe that "email" may have been a field that I added myself. The entry is simply written to the table header, hence the . Good catch.

so can you explain where I add the progress status in ticket.inc.php ?

oops!! I added it to my install but didn't update the tutorial. :

in include/client/viewticket.inc.php

under the very first <?php tag add this code...

...

Find this code...

...

Directly below add this code...

....

Lets also display the status to the client on their open ticket list.

include/client/tickets.inc.php

Find the first block of table headers,around line 100 or so, add...

..

Then, around line 129 or so, add this code...

...

There we go. Simple status on the client end. It could probably be prettier and better coded. :

Thank you so much Teryakisan!

I made an adjustment to the code from Teryakisan, so that the statusses are pulled from the DB instead of the hardcoded statusses in Teryakisan's code...

in include/client/tickets.inc.php

under the very first <?php tag add this code...

$status_arr = array();

$qry = db_query('SELECT * FROM '. STATUS_TABLE);

while($res = db_fetch_array($qry)) {

$status_arr[$res = $res;

}

Then replace to code from Teryakisan that you added around line 129 into:

<? if($row == NULL) {?>

<td><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "1") {?>

<td style="background-color:#FFAA7F"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "2") {?>

<td style="background-color:#FFFFAA"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "3") {?>

<td style="background-color:#D4FFFF"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "4") {?>

<td style="background-color:#D4D4FF"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "5") {?>

<td style="background-color:#D4FF7F"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "6") {?>

<td style="background-color:#9C0"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "7") {?>

<td style="background-color:#9C0"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "8") {?>

<td style="background-color:#9C0"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "9") {?>

<td style="background-color:#9C0"><?=$status_arr[$row;?></td>

<? } ?>

<? if($row == "10") {?>

<td style="background-color:#9C0"><?=$status_arr[$row;?></td>

<? } ?>