I have a database for scheduling field techs. Each field tech has his own unique login id that can see only his own specific jobs. I have recently added the function to add multiple techs to a single ticket. I am currently running the following loop. Each tech can currently see each job he is assigned on alone. When I start to assign multiple tech is where it gets tricky. Let's say I have 3 techs total: Mickey, Dustin, and Michael.
If I assign 1 job as a multi tech job for Michael and Dustin it appears fine in both techs lists. If I then assign another job for Mickey and Dustin. The previous job I assigned as a multi tech for Dustin disappears from his list but still shows on Michaels.
I am assuming something is getting caught up in the loop but I am having trouble figuring it out. Im a noob. Need Help.
$gettechresult = mysql_query("SELECT tech_id2, tech_id FROM jobs WHERE ((status = '2')) ORDER by $listsort;",$link);
while ($p_row =mysql_fetch_array ($gettechresult) ) {
$tech_id2 = $p_row[tech_id2];
$tech_id = $p_row[tech_id];
$fids = explode(",",$tech_id2);
$fids2 = explode(",",$tech_id);
if (in_array($l_tech_id, $fids))
{
$techteam = 'TRUE';
}
else{
$techteam = 'False';
}
/// Used to make sure the query is not returning False Values
echo "$techteam,";
if ($grp_all == "1")
{
$jobresult = mysql_query("SELECT * FROM jobs WHERE ((status = '2')) ORDER by $listsort;",$link);
}
elseif ((in_array($l_tech_id, $fids)))
{
$jobresult = mysql_query("SELECT * FROM jobs WHERE ((tech_id2 ='$l_tech_id' AND status = '2' || tech_id2 IN ('".$fids."') AND status = '2')) ORDER by $listsort;",$link);
}
}
Here are pictures of my current resultsThis is an image of the scheduled jobs currently in the database
Image of Field tech Dustin's Scheduled List - $l_tech_id = 16
The only job that is not reporting back correctly is the one where Mickey and Dustin are Multiple Techs. Dustin's is the only one that isn't reporting one job. $tech_id2 is the field that captures this info as an array.