Hi there,
I've found that if we delete staff record from Admin Panel -> Staff, then the record will be deleted, and this "staff_id" in ticket table, and the "manager_id" field in dept table will be updated to zero value (0).
The next question is: do you think it is good if we remove the staff record from staff table if the record still being used by another table? In my humble opinion, it is not recommended, I think, to delete staff record without knowing first whether the ticket still being assigned to the staff.
I made a modification for this. This MOD will check first whether the staff record still being used in ticket table. If yes, then display error message to let admin know that this staff record being used by ticket table, and suggest admin/manager what they should do. This MOD is useful for you to prevent miss-deleting by admin or manager if staff still being used by ticket table. Therefore, they still have the chance to re-assign the ticket to another staff, or perhaps removing the ticket (the last option is strange, right?!) first before removing the staff record.
Open \scp\admin.php, FIND:
case 'mass_process':
//ok..at this point..look WMA.
REPLACE WITH:
case 'mass_process':
//ok..at this point..look WMA.
// Begin Check whether staff being used in ticket table, MOD by Masino Sinaga, May 3, 2009
if($_POST && is_array($_POST)) {
$uidvalues = $_POST;
foreach ($uidvalues as $userid) {
$sql='SELECT staff_id FROM '.TICKET_TABLE.' WHERE staff_id = '.$userid.'';
if (db_num_rows(db_query($sql))>0) {
$errors.='This staff (ID='.$userid.') is being used. Remove first the ticket before delete this staff<br />';
}
}
}
if (!$errors) {
// End of Check whether staff being used in ticket table, MOD by Masino Sinaga, May 3, 2009
FIND:
}else{
$errors='No users selected.';
}
REPLACE WITH:
}else{
$errors='No users selected.';
}
} // if (!$errors)
That's all. Enjoy the result.
Any feedback please?
Best regards,
Masino Sinaga