"staff_id" instead of "created_by" in ticket table
2)I changed all references to created_by to staff_id. If the ticket is updated will it change the staff_ID to the user who updated the ticket? if so that is a side effects. I tried to set created_by in the code but was not smart enough. if anyone has the code to do this please post it.
bill
Yes, it will
I have checked about this in \include\class.ticket.php file, and FOUND this:
//Close the ticket
function close(){
$sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('closed').',staff_id=0,isoverdue=0,updated=NOW(),closed=NOW() '.
' WHERE ticket_id='.db_input($this->getId());
return (db_query($sql) && db_affected_rows())?true;
}
It meant that when a ticket has been closed, then the "staff_id" field will be updated and become "0". I think, this will caused why most of you get no result or always zero in the graph! Duh! :(
In addition, and in fact, "staff_id" never been inserted to ticket table after you implement my MOD from the link below (it is strongly recommended you apply this MOD):
http://www.osticket.com/forums/showthread.php?t=2063(http://www.osticket.com/forums/showthread.php?t=2063)
Then, my solution is: I am agree with you that, it is unnecessary to alter ticket table by adding new field named "created_by". I think we should only use this "staff_id" field instead of "created_by" field.
So that code above should be like this (I removed "staff_id=0" from SQL):
//Close the ticket
function close(){
$sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('closed').',isoverdue=0,updated=NOW(),closed=NOW() '.
' WHERE ticket_id='.db_input($this->getId());
return (db_query($sql) && db_affected_rows())?true;
}
This will cause the "staff_id" in ticket table never been changed forever!
In addition, if we see in ticket_respon table, the last "staff_id" who has updated the ticket (i.e closed) will be saved in there. So, again, it is unnecessary to update "staff_id" field in ticket table, because we have this "staff_id" saved in ticket_respon table. How's about that? Is it good enough? ;)
Any other feedback would be truly appreciated. Thanks.
Best regards,
Masino Sinaga