\n"; } else if ($_REQUEST['function'] == "chgClient") { // get a list of open wo's // get a list of all clients } else if ($_REQUEST['function'] == "mergeWO") { // $newLinkRef = sqlSelect("headers", "jobNo = '".$_REQUEST['keeper']."'"); // $newLinkRef = mysql_fetch_assoc($newLinkRef['r']); // // $oldLinkRef = sqlSelect("headers", "jobNo = '".$_REQUEST['discard']."'"); // $oldLinkRef = mysql_fetch_assoc($oldLinkRef['r']); // echo "
Keep\n";
//		print_r($newLinkRef);
//		echo "\nDelete\n";
//		print_r($oldLinkRef);
//		echo "

\n"; // log the merge // sqlInsert("logents", "eType = 's', linkRef = '".$newLinkRef['tid']."', empNo = '".$_SESSION['user']['empNo']."', note = 'ORDER MERGED with ".$_REQUEST['discard']."'"); // foreach ($_SESSION['linkTables'] as $tbl => $col) // { if ($tbl != "headers") // { echo "Updating $tbl"; // // if ($col == "linkRef") // { $newVal = "linkRef = '".$newLinkRef['tid']."'"; // $oldVal = "linkRef = '".$oldLinkRef['tid']."'"; // } // else // { $newVal = "jobNo = '".$newLinkRef['jobNo']."'"; // $oldVal = "jobNo = '".$oldLinkRef['jobNo']."'"; // } // $test = sqlSelect($tbl, $oldVal); // $nAffected = $test['n']; // if ($nAffected) // { if ($tbl == "logents") // { // parse the list of the entries that will be affected // while ($entData = mysql_fetch_assoc($test['r'])) // { // sqlUpdate("logents", "$newVal, note = 'MOVED FROM ".$_REQUEST['discard']." BY MERGE: ".addslashes($entData['note'])."'", "tid = '".$entData['tid']."'"); // } // } // else // $r = sqlUpdate($tbl, $newVal, $oldVal); // echo "... $nAffected entries updated
\n"; // } // else // echo "...Not required
\n"; // } // } // do the header update // echo "Updating Headers ... Fixing lead assignment"; // priority order: from "lead" in schedule, keeper (if set), discard (if set) // $lead = sqlSelect("schedule", "linkRef = '".$newLinkRef['tid']."' and role = 'LEAD'"); // if ($lead['n']) // { $lead = mysql_fetch_assoc($lead['r']); // sqlUpdate("headers", "assignto = '".$lead['empNo']."', status = 'SCHED'", "jobNo = '".$newLinkRef['jobNo']."'"); // } // else // { if (empty($newLinkRef['assignto']) and !empty($oldLinkRef['assignto'])) // sqlUpdate("headers", "assignto = '".$oldLinkRef['assignto']."'", "jobNo = '".$newLinkRef['jobNo']."'"); // } // echo " ... Done
\n"; // // echo "Removing extra header data"; //echo "update headers set jobNo = '', cCode = '', fName = '', lName = '', assignment = '' status = '', assignto = '0' where jobNo = '".$oldLinkRef['jobNo']."'
\n"; // $r = sqlUpdate("headers", "assignment = 'DUPLICATE: SEE ".$newLinkRef['jobNo']."', status = 'VOID', assignto = '0'", "jobNo = '".$oldLinkRef['jobNo']."'"); // sqlInsert("logents", "eType = 's', linkRef = '".$oldLinkRef['tid']."', empNo = '1', note = 'VOID: ORDER MERGED with ".$newLinkRef['jobNo']."'"); } } //******************************************* END PRE PROCESS ******************************************* // ***** get a list of all open orders; this will be used for BOTH selectors // $r = sqlSelect("headers", "status != 'CLOSED'", "", "lName, fName, jobNo", "jobNo, fName, lName, status"); // if ($r['n'] == 0) // { echo "NO ORDERS FOUND THAT ARE ELEGIBLE FOR MERGE [MERGES0080]
\n"; // exit(); // } ?> \n"; exit(); } echo "

\n"; echo " \n"; echo "
\n"; // reset the result parser to the begining .. mysql_data_seek($r['r'], 0); echo "
\n"; echo " ARE YOU SURE?
\n"; echo " THIS ACTION CANNOT BE UNDONE!
\n"; echo " \n"; echo "

\n"; echo "Change client on work order

\n"; echo "Merge two work orders

\n"; ?>