= '" . $dateYesterday . " 00:00:00' AND" . " jb.jb_export_time != '9999-12-31 23:59:59' AND" . " (NOT EXISTS (SELECT * FROM job2 AS jb2 WHERE jb2.jb_id = jb.jb_id))" . " ORDER BY jb.jb_id"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $arrayOfExportedIds = array(); while ($row = $result->fetch_assoc()): $arrayOfExportedIds[] = $row["jb_id"]; endwhile; $result->free(); // Write historic job data $arrayOfExportedIdsLen = count($arrayOfExportedIds); if ($arrayOfExportedIdsLen > 0) : $f_act = ""; for ($x = 0; $x < $arrayOfExportedIdsLen; $x++) : // if ($x == 1) : break; endif; $job_id = $arrayOfExportedIds[$x]; $tmpDelimiter = "-;-"; // [1.] Store view of the headquarters and store raw data of the job (also headquarters view) $jobentry = ""; $tourentry = ""; $jobcosts = ""; $courierentry = ""; $employeeentry = ""; $userTypeName = "hq"; $tmpJobDataArray = getJobSnapshot($job_id, "1"); $currentJobRawData = $tmpJobDataArray[0]; $currentJobParameterState = $tmpJobDataArray[1]; $currentJobRawData = str_replace('\'', '\\\'', $currentJobRawData); $jbHistoryData = $currentJobParameterState . $tmpDelimiter . $jobentry . $tmpDelimiter . $tourentry . $tmpDelimiter . $jobcosts . $tmpDelimiter . $courierentry . $tmpDelimiter . $employeeentry; $jbHistoryData = str_replace('\'', '\\\'', $jbHistoryData); // $sqlquery = "UPDATE job SET jb_history_data = '" . $jbHistoryData . "' WHERE jb_id = '" . $job_id . "'"; // $result = $db->query($sqlquery); // if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $currentJobRawData = escapeMysqlForBinary(compress($currentJobRawData)); $jbHistoryData = escapeMysqlForBinary(compress($jbHistoryData)); if (existsEntry("job2",array("jb_id",$job_id))) : updateStmt("job2", "jb_id", $job_id, array("jb2_history_rawdata", $currentJobRawData)); else: insertStmt("job2", array("jb_id", $job_id, "jb2_history_rawdata", $currentJobRawData)); endif; if (existsEntry("job2",array("jb_id",$job_id))) : updateStmt("job2", "jb_id", $job_id, array("jb2_history_hq", $jbHistoryData)); else: insertStmt("job2", array("jb_id", $job_id, "jb2_history_hq", $jbHistoryData)); endif; // [2.] Store view of a mail $jobentry = ""; $tourentry = ""; $jobcosts = ""; $courierentry = ""; $employeeentry = ""; $userTypeName = "hq"; $f_act = "export"; $currentJobParameterState = getJobSnapshot($job_id); $f_act = ""; $jbHistoryData = $currentJobParameterState . $tmpDelimiter . $jobentry . $tmpDelimiter . $tourentry . $tmpDelimiter . $jobcosts . $tmpDelimiter . $courierentry . $tmpDelimiter . $employeeentry; $jbHistoryData = str_replace('\'', '\\\'', $jbHistoryData); $jbHistoryData = escapeMysqlForBinary(compress($jbHistoryData)); if (existsEntry("job2",array("jb_id",$job_id))) : updateStmt("job2", "jb_id", $job_id, array("jb2_history_mail", $jbHistoryData)); else: insertStmt("job2", array("jb_id", $job_id, "jb2_history_mail", $jbHistoryData)); endif; // [3.] Store view of the customer $jobentry = ""; $tourentry = ""; $jobcosts = ""; $courierentry = ""; $employeeentry = ""; $userTypeName = "cs"; $currentJobParameterState = getJobSnapshot($job_id); $jbHistoryData = $currentJobParameterState . $tmpDelimiter . $jobentry . $tmpDelimiter . $tourentry . $tmpDelimiter . $jobcosts . $tmpDelimiter . $courierentry . $tmpDelimiter . $employeeentry; $jbHistoryData = str_replace('\'', '\\\'', $jbHistoryData); $jbHistoryData = escapeMysqlForBinary(compress($jbHistoryData)); if (existsEntry("job2",array("jb_id",$job_id))) : updateStmt("job2", "jb_id", $job_id, array("jb2_history_cs", $jbHistoryData)); else: insertStmt("job2", array("jb_id", $job_id, "jb2_history_cs", $jbHistoryData)); endif; writeToFile($logFilename, $job_id); endfor; endif; writeToFile($logFilename, "----------------------------------------------------------------------------------------------"); endif; ?>