= "5.6") :
$phpVer56Plus = true;
endif;
// Get global export path
$globalExportPath = getParameterValue("0", "EXPORT_PATH", "0");
if ($globalExportPath == "") : $globalExportPath = getParameterValue("0", "EXPORT_PATH", "0"); endif;
if ($globalExportPath == "") : $globalExportPath = "../export/download/"; endif;
$path = getAbsoluteSystemPath();
// Check range of date. All fields have to be set
if ($day_from == "" || $month_from == "" || $year_from == "" ||
$day_to == "" || $month_to == "" || $year_to == "") :
// Initialize date-ranges to the current date
$fromDateRange = getDateTime("1") . "000000";
$toDateRange = getDateTime("1") . "235959";
$day_from = getDateTime("day");
$month_from = getDateTime("month");
$year_from = getDateTime("year");
$day_to = getDateTime("day");
$month_to = getDateTime("month");
$year_to = getDateTime("year");
else :
$fromDateRange = $year_from . pad($month_from,2) . pad($day_from,2) . "000000";
$toDateRange = $year_to . pad($month_to,2) . pad($day_to,2) . "235959";
endif;
// Select user-type for mode of security check
$userType = getFieldValueFromId("user","usr_id",$usr_id,"usr_type");
// Check authentication verifying emmployee an his/her costcenter- and customer-association
if ( !( ($userType == "1") || authCheck($hq_id,$usr_id,$emp_id,$cscIdRoot,$customerId,$cscIdActual) ) ) : gotoReferer("1"); endif;
// Get the rights of the employee logged in and check the accessibility
authCheckEmployeeRights($emp_id, "7", "1");
getDBNames("0"); // Only use current tables (no history tables)
// Get company data
$g_cmp_id = getFieldValueFromId("customer", "cs_id", $g_cs_id, "cmp_id");
$g_cs_eid = getFieldValueFromId("customer", "cs_id", $g_cs_id, "cs_eid");
$g_cmp_comp = getFieldValueFromId("company", "cmp_id", $g_cmp_id, "cmp_comp");
$g_cmp_comp2 = getFieldValueFromId("company", "cmp_id", $g_cmp_id, "cmp_comp2");
$f_inv_no = trim($f_inv_no);
$f_inv_datetime = "";
if ($f_inv_datetime_month >= "1" && $f_inv_datetime_month <= "12" && $f_inv_datetime_day >= "1" && $f_inv_datetime_day <= "31") :
$f_inv_datetime = $f_inv_datetime_year . "-" . $f_inv_datetime_month . "-" . $f_inv_datetime_day . " 12:00:00";
endif;
if ($f_filter == "") : $f_filter = "0"; endif; // Filter (order clause by CSV generation)
if ($f_vht_filter == "") : $f_vht_filter = array(); endif; // filter for vehicle of the courier for exporting ALL or ONLY the specified vehicle types
// Store invoice data to jobs
/*
if ($f_act == "storeJobs") :
if ($g_cs_id != "") :
if ($f_jobs_len > 0) :
if ($f_inv_no != "" && $f_inv_datetime != "") :
// Transaction control starts here
// TA("B");
// Iterate all jobs
for ($i = 0; $i < $f_jobs_len; $i++) :
$jbId = $f_jobs[$i];
// Insert job into table "invoice" if does not exist else update
if (!(existsEntry("invoice",array("jb_id",$jbId)))) :
insertStmt("invoice", array("jb_id", $jbId, "inv_no", $f_inv_no, "inv_datetime", $f_inv_datetime));
else :
updateStmt("invoice", "jb_id", $jbId, array("inv_no", $f_inv_no, "inv_datetime", $f_inv_datetime));
endif;
endfor;
// TA("C");
// TA("E");
$f_act = "loadJobsOfCustomer";
else :
$statusMessage = "Sie müssen eine Rechnungsnummer und ein Rechnungsdatum vergeben!";
endif;
else :
$statusMessage = "Es wurden noch keine Aufträge identifiziert!";
endif;
else :
$statusMessage = "Sie haben noch keinen Kunden ausgewählt!";
endif;
endif;
*/
// Generate CSV document
if ($f_act == "generateCSV") :
if ($g_cs_id != "") :
$passwd = "acapella7890";
$logFile = $path . "/log/sys_auto_export.log";
$emptyArgument = "\"\"";
$fileNameSuffix = substr(getDateTime("6"), 0, 12); // Format: "YmdHi"
// Get data for calling customer export functionality
$g_cs_admin = getFieldValueFromId("customer", "cs_id", $g_cs_id, "cs_admin");
$g_hq_id = getFieldValueFromId("customer", "cs_id", $g_cs_id, "hq_id");
$g_hq_mnemonic = getFieldValueFromId("headquarters", "hq_id", $g_hq_id, "hq_mnemonic");
$g_usr_id = getFieldValueFromId("employee", "emp_id", $g_cs_admin, "usr_id");
// Noch parametrisieren !!!!!!!!!!!!!!!!!!!!!!!!!!!
$f_act = "special_export_4";
// Arguments for calling customer export
// $hq_id $usr_id $dummy_01 $f_act $f_exp_category $f_delimiter $f_parname $f_parname_export $f_fileName $day_to $month_to $year_to $f_cs_eid_filter $day_from $month_from $year_from $f_jbp_filter $specialJbPayment $jbpc_id
// Bsp: STHB.t:m: $g_hq_id = "1"; $g_hq_mnemonic = "HB"; $g_cs_id = "832514"; $g_usr_id = "840785";
$exportPars = array();
$exportPars[] = array($g_hq_id,$g_usr_id,"_",$f_act,$emptyArgument,$emptyArgument,$emptyArgument,$emptyArgument,$g_cs_eid . "_" . $fileNameSuffix . ".csv",$day_to,$month_to,$year_to,$emptyArgument,$day_from,$month_from,$year_from,$g_cs_id);
$exportParsKeys = array_keys($exportPars);
$exportParsKeysLen = count($exportParsKeys);
if ($exportParsKeysLen != "" && is_numeric($exportParsKeysLen)) :
// Exports
for ($i = 0; $i < $exportParsKeysLen; $i++) :
list($hq_id,$usr_id,$dummy_01,$f_act,$f_exp_category,$f_delimiter,$f_parname,$f_parname_export,$f_fileName,
$day_to,$month_to,$year_to,$f_cs_eid_filter,$day_from,$month_from,$year_from,$customerId,$f_jbp_filter,$specialJbPayment,$jbpc_id) = $exportPars[$exportParsKeys[$i]];
$cmd = "php " . $path . "/export/export.php " . $passwd . " " . $hq_id . " " . $usr_id . " " . $dummy_01 . " " . $f_act . " " . $f_exp_category . " " . "\"" . $f_delimiter. "\"" . " "
. "\"" . $f_parname . "\"" . " " . "\"" . $f_parname_export . "\"" . " " . "\"" . $f_fileName . "\"" . " " . $day_to . " " . $month_to . " " . $year_to . " "
. $f_cs_eid_filter . " " . $day_from . " " . $month_from . " " . $year_from . " " . $customerId . " " . $f_jbp_filter . " " . $specialJbPayment . " " . $jbpc_id; // . " &";
// echo $cmd . "\n\n\n"; die();
$cmdOutput = null;
exec($cmd, $cmdOutput);
// list($errNo, $errDesc) = $cmdOutput;
$currentTime = getDateTime("0");
writeToFile($logFile, "OP=AUTO_EXPORT|DATETIME=" . $currentTime . "|CUST=" . $exportParsKeys[$i]);
$f_act = "loadJobsOfCustomer";
// sleep(5); // Avoid too many tasks
endfor;
endif;
else :
$statusMessage = "Sie haben noch keinen Kunden ausgewählt!";
endif;
endif;
// Show all specified jobs of the customer
$invoiceNumberArray = array(); // Distinct array of all invoice numbers of the selelected date interval
if ($f_act == "loadJobsOfCustomer") :
if ($g_cs_id != "") :
// Filter export according specified vehicle types (if NO type is specified then this filter is not be used)
$whereClauseFilterVehicleType = "";
$f_vht_filter_len = count($f_vht_filter);
if ($f_vht_filter_len > 0) :
for ($i = 0; $i < $f_vht_filter_len; $i++) :
if ($whereClauseFilterVehicleType != "") :
$whereClauseFilterVehicleType .= " OR ";
endif;
$whereClauseFilterVehicleType .= " jb.vht_id = '" . $f_vht_filter[$i] . "'";
endfor;
if ($whereClauseFilterVehicleType != "") :
$whereClauseFilterVehicleType = " AND (" . $whereClauseFilterVehicleType . ") ";
endif;
endif;
$sqlquery = "SELECT jb.jb_id, jb.jb_totalprice AS price, jb.jb_export_time, jb.jb_ordertime, jb.jb_finishtime, jb.jb_freetext_1,"
. " jb.cr_sid, tr.tr_commission_no, csc.csc_name"
. " FROM job AS jb, tour AS tr, costcenter AS csc"
. " WHERE jb.jb_status = '2' AND"
. " (NOT isnull(jb.jb_export_time)) AND"
. " jb.jb_ordertime >= '$fromDateRange' AND"
. " jb.jb_ordertime <= '$toDateRange' AND"
. " jb.jb_id = tr.jb_id AND"
. " tr.tr_sort = '1' AND"
. " jb.csc_id_payer = csc.csc_id AND"
. " csc.cs_id = '" . $g_cs_id . "' "
. $whereClauseFilterVehicleType
. " ORDER BY jb.jb_id";
$result = $db->query($sqlquery);
// echo $sqlquery . "
";
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
$out = "";
while ($row = $result->fetch_assoc()):
$numOfRows++;
$sumOfJobPrices += $row["price"];
$out .= "
| Datum / Uhrzeit | WEB-Download | "; $storedExportFiles .= "||
| " . formatOutput($row["expf_storetime"],"timestamp") . " | "; $storedExportFiles .= "" . $row["expf_name"] . " | "; // Enable FTP upload option only for headquarter /* if ($userTypeName == "hq" && $parFTPuploadDisabled != "1") : if ($row["expf_ftpupload"] != "1") : $storedExportFiles .= "" . $row["expf_name"] . " | "; else : $storedExportFiles .= "" . $row["expf_name"] . " | "; endif; endif; */ $storedExportFiles .= "