1. Import

This commit is contained in:
2026-03-29 10:34:57 +02:00
parent b0e00c1259
commit a1129565af
4899 changed files with 3007593 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
<?php
/*=======================================================================
*
* cron_export.php
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
if ($argv[1] == "acapella7890") :
$path = getAbsoluteSystemPath();
$passwd = "acapella7890";
$emptyArgument = "\"\"";
$fileNamePrefix = substr(getDateTime("6"), 0, 12); // eq. "YmdHi"
if ($argv[2] == "today") :
$toDay = getDateTime("day");
$toMonth = getDateTime("month");
$toYear = getDateTime("year");
else :
$toDay = getDateTime("day_yesterday");
$toMonth = getDateTime("month_yesterday");
$toYear = getDateTime("year_yesterday");
endif;
// Arguments
// $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 $f_jbp_filter $specialJbPayment $jbpc_id
$exportPars = array();
$exportPars["HTM_HTHH_ABR"] = array("1020","18086","_","export","5","|","RETRANS Abrechnungen","RETRANS Abrechnungen",$fileNamePrefix . ".101.abr",$toDay,$toMonth,$toYear,$emptyArgument,$emptyArgument,"4","81001028");
$exportPars["HTM_HTHH_GUT"] = array("1020","18086","_","export","6","|","RETRANS Abrechnungen","RETRANS Abrechnungen",$fileNamePrefix . ".101.gut",$toDay,$toMonth,$toYear,$emptyArgument,$emptyArgument,"4","81001029");
/*
$exportParsKeys = array_keys($exportPars);
$exportParsKeysLen = count($exportParsKeys);
for ($i = 0; $i < $maskDisplayedArrayLen; $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,$f_jbp_filter,$specialJbPayment,$jbpc_id) = $exportPars[$exportParsKeys[$i]];
$cmd = "php " . $path . "/export/export.php " . $passwd . " " . $hq_id . " " . $usr_id . " " . $dummy_01 . " " . $f_act . " " . $aaaa . " " . $aaaa . " " . $aaaa . " " . $aaaa . " &";
$cmdOutput = null;
exec($cmd, $cmdOutput);
// list($errNo, $errDesc) = $cmdOutput;
endfor;
*/
// TEST
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,$f_jbp_filter,$specialJbPayment,$jbpc_id) = $exportPars["HTM_HTHH_ABR"];
$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 . " " . $f_jbp_filter . " " . $specialJbPayment . " " . $jbpc_id . " &";
echo $cmd . "\n";
$cmdOutput = null;
exec($cmd, $cmdOutput);
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,$f_jbp_filter,$specialJbPayment,$jbpc_id) = $exportPars["HTM_HTHH_GUT"];
$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 . " " . $f_jbp_filter . " " . $specialJbPayment . " " . $jbpc_id . " &";
echo $cmd . "\n";
$cmdOutput = null;
exec($cmd, $cmdOutput);
endif;
?>

View File

@@ -0,0 +1,80 @@
<?php
/*=======================================================================
*
* cron_export4job2.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
// include_once ("../include/auth.inc.php");
include_once ("../include/mcglobal.inc.php");
// Overload function because of call by console
function authCheckEmployeeRights($emp_id, $menuModeId, $referer = "") {
return true;
}
// Check process is still running
// ..........
$retVal = "OK";
$userTypeName = "hq";
$errMsg = "";
$hq_id = "";
$usr_id = "";
if (!isset($argv[1]) || $argv[1] != "acapella7890") :
$errMsg = "watchdog cron export.job2 failed by access code";
endif;
if ($errMsg != "") :
sendInternalMail($errMsg);
die();
endif;
// Execution-Time for script
set_time_limit(30000);
$path = getAbsoluteSystemPath();
$constAmStarttimeInDays = 4;
$startTime = getDateTime("datetime_plus_offset", array(0,0,0,0,-($constAmStarttimeInDays),0), "Y-m-d H:i:s");
// Get all failed tasks writing to job2 by exports
$sqlquery = "SELECT DISTINCT jb.jb_export_time, jb.hq_id, COUNT(*) AS num, exl.exl_id"
. " FROM job AS jb LEFT JOIN exportlog AS exl ON jb.jb_export_time = exl.exl_exporttime"
. " WHERE jb.jb_export_time >= '" . $startTime . "' 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))"
. " GROUP BY jb.jb_export_time";
$result = $db->query($sqlquery);
$job2Array = array();
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
while ($row = $result->fetch_assoc()):
$job2Array[] = array($row["exl_id"], $row["hq_id"], $row["jb_export_time"], $row["num"]);
endwhile;
$result->free();
$job2ArrayLen = count($job2Array);
if ($job2ArrayLen > 0) :
$retVal = "NOK";
for ($i = 0; $i < $job2ArrayLen; $i++) :
$exl_id = $job2Array[$i][0];
$hq_id = $job2Array[$i][1];
$empIdRootAdmin = getEmpIdOfRootAdmin($userTypeName); // In the loop because refers to global $hq_id
$usr_id = getFieldValueFromId("employee", "emp_id", $empIdRootAdmin, "usr_id");
$call_counter = "1";
// Call script to write "job2"
if ($exl_id != "" && $hq_id != "" && $usr_id != "" && $call_counter != "") :
$mcDebugExportErrLogFile = $path . "/log/job2exec_" . $hq_id . "_err.stdout+err";
$cmd = "php " . $path . "/export/export4job2.php acapella7890 " . $hq_id . " " . $usr_id . " " . $exl_id . " " . $call_counter . " > " . $mcDebugExportErrLogFile . " 2>&1 &";
system($cmd);
endif;
echo $exl_id . " " . $hq_id . " " . $usr_id . " " . $call_counter . "\n";
// die();
endfor;
endif;
echo $retVal;

View File

@@ -0,0 +1,68 @@
<?php
/*=======================================================================
*
* cron_export_HHA.php
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
// include_once ("../include/ftp.inc.php");
if ($argv[1] == "acapella7890") :
// Error reporting
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$path = getAbsoluteSystemPath();
$passwd = "acapella7890";
$logFile = $path . "/log/cron_auto_export.log";
$emptyArgument = "\"\"";
$fileNamePrefix = substr(getDateTime("6"), 0, 12); // Format: "YmdHi"
$requestMode = trim($argv[2]);
if ($requestMode == "" || !is_numeric($requestMode)) : $requestMode = "103"; endif; // Init "Alarm"
// date_firstday_lastmonth_currentyear
$date_from = date("Ymd",mktime(0,0,0,date("m")-1,1,date("Y"))); // 20200101, ....
$date_to = date("Ymd",mktime(0,0,0,date("m"),0,date("Y"))); // 20200131, ....
$f_act = "execute";
$hqId = "1";
$f_sort = "0";
$f_stat_export = "1"; // csv-Export
$f_ftp_upload = $emptyArgument;
$sendMode = "NONE";
$exportPars = array();
$exportPars["HHA_EXPORT"] = array($f_act,$hqId,$requestMode,$date_from,$date_to,$f_sort,$f_stat_export,$f_ftp_upload,$sendMode);
$exportParsKeys = array_keys($exportPars);
$exportParsKeysLen = count($exportParsKeys);
if ($exportParsKeysLen != "" && is_numeric($exportParsKeysLen)) :
// Exports
for ($i = 0; $i < $exportParsKeysLen; $i++) :
list($f_act,$hq_id,$requestMode,$date_from,$date_to,$f_sort,$f_stat_export,$f_ftp_upload,$sendMode) = $exportPars[$exportParsKeys[$i]];
// $cmd = "php " . $path . "/export/export_illt.php " . $passwd . " " . $f_act . " " . $hq_id . " " . $requestMode . " " . $date_from . " " . $date_to . " " . $f_sort . " " . $f_stat_export . " " . $f_ftp_upload . " " . $sendMode . " " . " &";
$cmd = "php " . $path . "/export/export_illt_MC.php " . $passwd . " " . $f_act . " " . $hq_id . " " . $requestMode . " " . $date_from . " " . $date_to . " " . $f_sort . " " . $f_stat_export . " " . $f_ftp_upload . " " . $sendMode . " " . " &";
// echo $exportParsKeys[$i] . ":\n";
// echo $cmd . "\n\n\n";
// 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]);
sleep(5); // Avoid too many tasks
endfor;
endif;
endif;
?>

View File

@@ -0,0 +1,118 @@
<?php
/*=======================================================================
*
* cron_export.php
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
if ($argv[1] == "acapella7890") :
$path = getAbsoluteSystemPath();
$passwd = "acapella7890";
$emptyArgument = "\"\"";
$fileNamePrefix = substr(getDateTime("6"), 0, 12); // eq. "YmdHi"
if ($argv[2] == "today") :
$toDay = getDateTime("day");
$toMonth = getDateTime("month");
$toYear = getDateTime("year");
else :
$toDay = getDateTime("day_yesterday");
$toMonth = getDateTime("month_yesterday");
$toYear = getDateTime("year_yesterday");
endif;
// Arguments
// $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 $f_jbp_filter $specialJbPayment $jbpc_id
$exportPars = array();
// $exportPars["HTM_HTHH_ABR"] = array("1020","18086","_","export","5","|","RETRANS Abrechnungen","RETRANS Abrechnungen",$fileNamePrefix . ".101.abr",$toDay,$toMonth,$toYear,$emptyArgument,$emptyArgument,"4","81001028");
// $exportPars["HTM_HTHH_GUT"] = array("1020","18086","_","export","6","|","RETRANS Abrechnungen","RETRANS Abrechnungen",$fileNamePrefix . ".101.gut",$toDay,$toMonth,$toYear,$emptyArgument,$emptyArgument,"4","81001029");
$fileNamePrefix = substr(getDateTime("6"), 0, 11) . "1"; // eq. "YmdHi"
$f_cs_eid_filter = "WAST10224";
$f_jbp_filter = "4"; // EXPORT_CAT_09_JBPMODES_04_GRP_11 => Payment mode "16"
$exportPars["HTM_WAST_UMS_16"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");
$fileNamePrefix = substr(getDateTime("6"), 0, 11) . "2"; // eq. "YmdHi"
$f_cs_eid_filter = "WAST10224";
$f_jbp_filter = "5"; // EXPORT_CAT_09_JBPMODES_05_GRP_11 => Payment mode "17"
$exportPars["HTM_WAST_UMS_17"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");
$fileNamePrefix = substr(getDateTime("6"), 0, 11) . "3"; // eq. "YmdHi"
$f_cs_eid_filter = "WAST10224";
$f_jbp_filter = "6"; // EXPORT_CAT_09_JBPMODES_06_GRP_11 => Payment mode "18"
$exportPars["HTM_WAST_UMS_18"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");
$fileNamePrefix = substr(getDateTime("6"), 0, 11) . "4"; // eq. "YmdHi"
$f_cs_eid_filter = "WAST10224";
$f_jbp_filter = "7"; // EXPORT_CAT_09_JBPMODES_07_GRP_11 => Payment mode "19"
$exportPars["HTM_WAST_UMS_19"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");
$fileNamePrefix = substr(getDateTime("6"), 0, 11) . "5"; // eq. "YmdHi"
$f_cs_eid_filter = "WAST10225";
$f_jbp_filter = "4"; // EXPORT_CAT_09_JBPMODES_04_GRP_11 => Payment mode "16"
$exportPars["HTM_WAST_UMS_16_B"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");
$fileNamePrefix = substr(getDateTime("6"), 0, 11) . "6"; // eq. "YmdHi"
$f_cs_eid_filter = "WAST10225";
$f_jbp_filter = "5"; // EXPORT_CAT_09_JBPMODES_05_GRP_11 => Payment mode "17"
$exportPars["HTM_WAST_UMS_17_B"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");
$fileNamePrefix = substr(getDateTime("6"), 0, 11) . "7"; // eq. "YmdHi"
$f_cs_eid_filter = "WAST10225";
$f_jbp_filter = "6"; // EXPORT_CAT_09_JBPMODES_06_GRP_11 => Payment mode "18"
$exportPars["HTM_WAST_UMS_18_B"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");
$fileNamePrefix = substr(getDateTime("6"), 0, 11) . "8"; // eq. "YmdHi"
$f_cs_eid_filter = "WAST10225";
$f_jbp_filter = "7"; // EXPORT_CAT_09_JBPMODES_07_GRP_11 => Payment mode "19"
$exportPars["HTM_WAST_UMS_19_B"] = array("1111","18091","_","export","9","|","RETRANS Umsatz","RETRANS Umsatz",$fileNamePrefix . ".144.abr",$toDay,$toMonth,$toYear,$f_cs_eid_filter,$f_jbp_filter,"","");
$exportParsKeys = array_keys($exportPars);
$exportParsKeysLen = count($exportParsKeys);
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,$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 . " " . $f_jbp_filter . " " . $specialJbPayment . " " . $jbpc_id . " &";
echo $cmd . "\n";
$cmdOutput = null;
exec($cmd, $cmdOutput);
// list($errNo, $errDesc) = $cmdOutput;
endfor;
// TEST
/*
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,$f_jbp_filter,$specialJbPayment,$jbpc_id) = $exportPars["HTM_HTHH_ABR"];
$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 . " " . $f_jbp_filter . " " . $specialJbPayment . " " . $jbpc_id . " &";
echo $cmd . "\n";
$cmdOutput = null;
exec($cmd, $cmdOutput);
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,$f_jbp_filter,$specialJbPayment,$jbpc_id) = $exportPars["HTM_HTHH_GUT"];
$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 . " " . $f_jbp_filter . " " . $specialJbPayment . " " . $jbpc_id . " &";
echo $cmd . "\n";
$cmdOutput = null;
exec($cmd, $cmdOutput);
*/
endif;
?>

View File

@@ -0,0 +1 @@
077 |K |STB85794| 006| |20260304|17:00|20260304|17:00| 006|021890959|000| | |FP| | | | | | | | |0000002150|0000000|0000000|0000000|0000000|0000000|0000000000|0000000000|0000000000|0000000000|0000000000| | | | | |00000|00000| | | | | | |0000|0000|00|0000|00000000|00000000|00000000|00000000|00001720|000000000| | | | |STB900150|00000000000000|STB900150| | |Besteller/in: Leg Dich gehackt |Abholung: AUCOTEAM GmbH, Josef-Orlopp-Str. 58, 10365 Berlin |Anlieferung: Dosch Messapparate GmbH, Kamenzer Damm 85, 12249 Berlin |(PKW), MA: vA |Treibstoffzuschlag 7,50% auf 20,00 EUR = 1,50 EUR |Die CO2E-Emission nach Well-to-Wheel-Methode für diesen Transport |beträgt 1,78 kg ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||0000|0000000|0000|0000000|0000000|0000|0000000| |0000|0000000| |0000|0000000| |0000|0000000| |0000|0000000| |DE|DE|#Irgendwas |Dosch Messapparate GmbH ||Kamenzer Damm 85 |12249 |Berlin |||| |Besteller/in: Leg Dich gehackt |Abholung: AUCOTEAM GmbH, Josef-Orlopp-Str. 58, 10365 Berlin |Anlieferung: Dosch Messapparate GmbH, Kamenzer Damm 85, 12249 Berlin |(PKW) ||||||||||||||||||||||||||||||||||||||||||||||| | 000

View File

@@ -0,0 +1,18 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="de">
<head>
<title>votian</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="votian"> <meta name="keywords" content="votian">
<meta http-equiv="refresh" content="0; URL=../../index.php">
<link rel="stylesheet" type="text/css" href="css/phoenix.css">
</head>
<body bgcolor="#FFFFFA" leftmargin="1" topmargin="1" marginwidth="0" marginheight="0" link="#990000" vlink="#990000" alink="#990000">
<a href="../../index.php">Bitte hier klicken, wenn Sie nicht automatisch weitergeleitet werden...</a>
</body>
</html>

1947
html/export/export.php Normal file

File diff suppressed because it is too large Load Diff

246
html/export/export4job2.php Normal file
View File

@@ -0,0 +1,246 @@
<?php
/*=======================================================================
*
* export4job2.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
// include_once ("../include/auth.inc.php");
include_once ("../include/mcglobal.inc.php");
// Overload function because of call by console
function authCheckEmployeeRights($emp_id, $menuModeId, $referer = "") {
return true;
}
$errMsg = "";
$hq_id = "";
$usr_id = "";
if (isset($argv[1]) && $argv[1] == "acapella7890") :
if (isset($argv[2]) && $argv[2] != "") :
$hq_id = $argv[2];
if (isset($argv[3]) && $argv[3] != "") :
$usr_id = $argv[3];
if (isset($argv[4]) && $argv[4] != "") :
$exl_id = $argv[4];
if (isset($argv[5]) && $argv[5] != "") :
$call_counter = $argv[5];
endif;
else :
$errMsg = "export.job2 failed by missing exportlog ID";
endif;
else :
$errMsg = "export.job2 failed by missing user ID";
endif;
else :
$errMsg = "export.job2 failed by missing headquarters ID";
endif;
else :
$errMsg = "export.job2 failed by access code";
endif;
if ($errMsg != "") :
sendInternalMail($errMsg . " [HQ_ID:" . $hq_id . "] " . " [USR_ID:" . $usr_id . "] ");
die();
endif;
ini_set('memory_limit', '256M');
// Execution-Time for script
set_time_limit(30000);
// include_once ("../include/ftp.inc.php");
include_once ("../include/html.inc.php");
include_once ("../include/inc_job.inc.php");
$automailer = "INIT";
include_once ("../include/jb_detail_history.inc.php");
// Get table names (currently only for make jobs persistent in "jb_history_data")
getDBNames($dbhistory);
// Define global parameters
defineGlobalParameters($hq_id);
// **** Write historic job data ****
$maxCalls = 50;
if (isset($call_counter)) :
$call_counter++;
if ($call_counter >= $maxCalls) :
$errMsg = "export.job2 terminated by reaching maximum calls";
sendInternalMail($errMsg . " [HQ_ID:" . $hq_id . "] " . " [USR_ID:" . $usr_id . "] " . " [EXL_ID:" . $exl_id . "] " . " [MAX_CALLS:" . $maxCalls . "] ");
die();
endif;
else :
$call_counter = 1;
endif;
$stringOfExportedIds = getFieldValueFromId("exportlog", "exl_id", $exl_id, "exl_rows");
if ($stringOfExportedIds == "") :
$errMsg = "export.job2 failed by missing job IDs from exportlog";
sendInternalMail($errMsg . " [HQ_ID:" . $hq_id . "] " . " [USR_ID:" . $usr_id . "] " . " [EXL_ID:" . $exl_id . "] ");
die();
endif;
// Get all job IDs of the current exportlog row NOT existing in job2
$sqlquery = "SELECT jb.jb_id FROM job AS jb WHERE jb.jb_id IN (" . $stringOfExportedIds . ") AND (NOT EXISTS (SELECT * FROM job2 AS jb2 WHERE jb2.jb_id = jb.jb_id))";
// echo "\n\n" . $sqlquery . "\n\n"; die();
$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();
$arrayOfExportedIdsLen = count($arrayOfExportedIds);
if ($arrayOfExportedIdsLen > 0) :
// Check global usage of the context menu
$maskJobInternalRemarkItems = getParameterValue("0", "MASK_JOBDETAILS_INTERNAL_REMARK_ITEMS", $hq_id);
if ($maskJobInternalRemarkItems != "1") : $maskJobInternalRemarkItems = getParameterValue("0", "MASK_JOBDETAILS_INTERNAL_REMARK_ITEMS", "0"); endif;
$f_act_rem = $f_act;
$f_act = "";
$mcDebugExportLogFile = "../log/job2exec_" . $hq_id . ".log";
writeToFile($mcDebugExportLogFile, "----------------------------------------------------------------------------------------------");
writeToFile($mcDebugExportLogFile, "[HQ_ID:" . $hq_id . "] " . " [USR_ID:" . $usr_id . "] " . " [EXL_ID:" . $exl_id . "]");
writeToFile($mcDebugExportLogFile, "#JobsExported: " . $arrayOfExportedIdsLen);
for ($x = 0; $x < $arrayOfExportedIdsLen; $x++) :
$job_id = $arrayOfExportedIds[$x];
$tmpDelimiter = "-;-";
writeToFile($mcDebugExportLogFile, $job_id);
// [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));
$opState = "::";
if (existsEntry("job2",array("jb_id",$job_id))) :
$res = updateStmt("job2", "jb_id", $job_id, array("jb2_history_rawdata", $currentJobRawData));
if ($db->affected_rows > 0) :
$opState .= " [RAWDATA.UPD => OK]";
else :
$opState .= " [RAWDATA.UPD => NOK]";
endif;
else:
insertStmt("job2", array("jb_id", $job_id, "jb2_history_rawdata", $currentJobRawData));
$opState .= " [RAWDATA.INS]";
endif;
if (existsEntry("job2",array("jb_id",$job_id))) :
$res = updateStmt("job2", "jb_id", $job_id, array("jb2_history_hq", $jbHistoryData));
if ($db->affected_rows > 0) :
$opState .= " [HISTORY.UPD => OK]";
else :
$opState .= " [HISTORY.UPD => NOK]";
endif;
else:
insertStmt("job2", array("jb_id", $job_id, "jb2_history_hq", $jbHistoryData));
$opState .= " [HISTORY.INS]";
endif;
if (existsEntry("job2",array("jb_id",$job_id))) :
$opState = "OK " . $opState;
else :
$opState = "NOK";
endif;
writeToFile($mcDebugExportLogFile, "::[1] " . $opState);
// [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));
$opState = "::";
if (existsEntry("job2",array("jb_id",$job_id))) :
$res = updateStmt("job2", "jb_id", $job_id, array("jb2_history_mail", $jbHistoryData));
if ($db->affected_rows > 0) :
$opState .= " [MAIL.UPD => OK]";
else :
$opState .= " [MAIL.UPD => NOK]";
endif;
else:
insertStmt("job2", array("jb_id", $job_id, "jb2_history_mail", $jbHistoryData));
$opState .= " [MAIL.INS]";
endif;
if (existsEntry("job2",array("jb_id",$job_id))) :
$opState = "OK " . $opState;
else :
$opState = "NOK";
endif;
writeToFile($mcDebugExportLogFile, "::[2] " . $opState);
// [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));
$opState = "::";
if (existsEntry("job2",array("jb_id",$job_id))) :
$res = updateStmt("job2", "jb_id", $job_id, array("jb2_history_cs", $jbHistoryData));
if ($db->affected_rows > 0) :
$opState .= " [CS.UPD => OK]";
else :
$opState .= " [CS.UPD => NOK]";
endif;
else:
insertStmt("job2", array("jb_id", $job_id, "jb2_history_cs", $jbHistoryData));
$opState .= " [CS.INS]";
endif;
if (existsEntry("job2",array("jb_id",$job_id))) :
$opState = "OK " . $opState;
else :
$opState = "NOK <====";
endif;
writeToFile($mcDebugExportLogFile, "::[3] OK");
endfor;
$userTypeName = "hq"; // VERY IMPORTANT TO RESET !!!
$f_act == $f_act_rem;
// Call itself
$path = getAbsoluteSystemPath();
$mcDebugExportErrLogFile = $path . "/log/job2exec_" . $hq_id . "_err.stdout+err";
$cmd = "php " . $path . "/export/export4job2.php acapella7890 " . $hq_id . " " . $usr_id . " " . $exl_id . " " . $call_counter . " > " . $mcDebugExportErrLogFile . " 2>&1 &";
writeToFile($mcDebugExportLogFile, $cmd);
system($cmd);
endif;

992
html/export/export_illt.php Normal file
View File

@@ -0,0 +1,992 @@
<?php
/*=======================================================================
*
* export_illt.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
$autoMode = false;
if (!isset($argv[1]) || $argv[1] == "") :
$isCron = false;
include_once ("../include/auth.inc.php");
getSecHttpVars("1",array("f_act", "customerId", "cscIdRoot", "cscIdActual", "requestMode",
"day_from", "month_from", "year_from", "day_to", "month_to", "year_to",
"g_cs_eid", "g_csc_id", "g_cr_id", "g_cr_eid",
"f_hq_id", "f_text", "f_sort", "f_stat_export", "f_ftp_upload", "deactivateMenu"));
$autoMode = true;
$usrAccessArray["hq"] = "1";
// $usrAccessArray["cs"] = "1";
// $usrAccessArray["cr"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
else :
// Error reporting
// error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED);
error_reporting(0);
// Init parameters
$f_act = ""; $hq_id = ""; $requestMode = ""; $date_from = ""; $date_to = ""; $f_sort = ""; $f_stat_export = ""; $f_ftp_upload = "";
// Call e.g.
// php export_illt.php acapella7890 execute 1 101 20190901000000 20190930235959 0 1 HHA SFTP
$isCron = true;
if ($argv[1] == "acapella7890") : $autoMode = true; endif;
if ($autoMode) :
if (isset($argv[2]) && $argv[2] != "") : $f_act = $argv[2]; endif;
if (isset($argv[3]) && $argv[3] != "") : $hq_id = $argv[3]; endif;
if (isset($argv[4]) && $argv[4] != "") : $requestMode = $argv[4]; endif;
if (isset($argv[5]) && $argv[5] != "") : $date_from = $argv[5]; endif;
if (isset($argv[6]) && $argv[6] != "") : $date_to = $argv[6]; endif;
if (isset($argv[7]) && $argv[7] != "") : $f_sort = $argv[7]; endif;
if (isset($argv[8]) && $argv[8] != "") : $f_stat_export = $argv[8]; endif;
if (isset($argv[9]) && $argv[9] != "") : $f_ftp_upload = $argv[9]; endif;
if (isset($argv[9]) && $argv[10] != "") : $sendMode = $argv[10]; endif;
endif;
$year_from = substr($date_from, 0, 4);
$month_from = substr($date_from, 4, 2);
$day_from = substr($date_from, 6, 2);
$year_to = substr($date_to, 0, 4);
$month_to = substr($date_to, 4, 2);
$day_to = substr($date_to, 6, 2);
endif;
include_once ("../statistic/statistic_sql.inc.php");
include_once ("../include/inc_calendar.inc.php");
include_once ("../include/ftp.inc.php");
// Execution-Time for script
set_time_limit(300);
$deactivateMenuStatic = "1";
getLanguage(__FILE__);
// HASH folder
$hashFolder = "8384739274093038263748";
$secondsForUnlink = 60;
if ($isCron) :
$hashFolder = "7384739274093038263748";
$secondsForUnlink = 864000;
endif;
// Log file
$logFile = getParameterValue("0", "ILLT_EXPORT_LOGFILE", "0");
if ($logFile == "") :
$logFile = getParameterValue("0", "AUTO_EXPORT_LOGFILE", "0");
if ($logFile == "") : $logFile = "../log/auto_export.log"; endif;
endif;
// Send mode
if ($sendMode == "") : $sendMode = "SFTP"; endif;
$debug = false;
$debugLog = false;
if ($isCron) :
$debug = false;
$debugLog = true;
endif;
if ($debug) :
echo "isCron = " . $isCron . "<br>";
echo "hashFolder = " . $hashFolder . "<br>";
echo "f_act = " . $f_act . "<br>";
echo "requestMode = " . $requestMode . "<br>";
echo "f_sort = " . $f_sort . "<br>";
echo "f_stat_export = " . $f_stat_export . "<br>";
echo "day_from = " . $day_from . "<br>";
echo "month_from = " . $month_from . "<br>";
echo "year_from = " . $year_from . "<br>";
echo "day_to = " . $day_to . "<br>";
echo "month_to = " . $month_to . "<br>";
echo "year_to = " . $year_to . "<br>";
endif;
if ($debugLog) :
writeToFile($logFile, $currentTime . " ----------------------------------------------------------------------------------- ");
writeToFile($logFile, $currentTime . " - " . "isCron = " . $isCron);
writeToFile($logFile, $currentTime . " - " . "hashFolder = " . $hashFolder);
writeToFile($logFile, $currentTime . " - " . "f_act = " . $f_act);
writeToFile($logFile, $currentTime . " - " . "requestMode = " . $requestMode);
writeToFile($logFile, $currentTime . " - " . "f_sort = " . $f_sort);
writeToFile($logFile, $currentTime . " - " . "f_stat_export = " . $f_stat_export);
writeToFile($logFile, $currentTime . " - " . "day_from = " . $day_from);
writeToFile($logFile, $currentTime . " - " . "month_from = " . $month_from);
writeToFile($logFile, $currentTime . " - " . "year_from = " . $year_from);
writeToFile($logFile, $currentTime . " - " . "day_to = " . $day_to);
writeToFile($logFile, $currentTime . " - " . "month_to = " . $month_to);
writeToFile($logFile, $currentTime . " - " . "year_to = " . $year_to);
endif;
$pageTitel = getLngt("AUFSTELLUNGEN");
$authCheck = FALSE;
$maxLimitOfRowsDisplayed = 1000;
$currentTime = getDateTime("0");
$currentDate = getDateTime("3");
$currentMonth = getDateTime("month");
if ($requestMode == "101") :
$pageTitel = getLngt("GELDBETRAGSHISTORIE");
if ($isCron) :
$authCheck = TRUE;
else :
$authCheck = authCheckEmployeeRights($emp_id, "0");
endif;
// Parameters
$limitOfRowsDisplayed = getParameterValue("0", "MASK_STAT_ILLT_ROWS_DISPLAYED_101", "0"); // For limitation of the rows displayed
if ($limitOfRowsDisplayed == "" || !is_numeric($limitOfRowsDisplayed)) : $limitOfRowsDisplayed = getParameterValue("0", "MASK_STAT_ILLT_ROWS_DISPLAYED", "0"); endif;
if ($limitOfRowsDisplayed == "" || !is_numeric($limitOfRowsDisplayed)) : $limitOfRowsDisplayed = 10000; endif;
// Get the cs_id if "g_cs_eid" does exist
if ($g_cs_eid != "") :
$cs_id = getFieldValueFromId("customer", "cs_eid", $g_cs_eid, "cs_id");
elseif ($g_csc_id != "") :
$cs_id = getFieldValueFromId("costcenter", "csc_id", $g_csc_id, "cs_id");
$g_cs_eid = getFieldValueFromId("customer", "cs_id", $cs_id, "cs_eid");
endif;
// Statistic values of the customer
/*
if ($cs_id != "") :
// Statistic business volume from 01.01. of the current year to the current day
$tmpFromDate = getDateTime("year") . "-01-01";
$tmpToDate = getDateTime("3");
$statisticValueCurrentYear = getCsStatistic ($rpObjId, $tmpFromDate, $tmpToDate);
// Year before in the same interval
$tmpFromDate = getDateTime("lastyear") . "-01-01";
$tmpToDate = getDateTime("date_lastyear");
$statisticValueLastYear = getCsStatistic ($rpObjId, $tmpFromDate, $tmpToDate);
// Year before complete
$tmpFromDate = getDateTime("lastyear") . "-01-01";
$tmpToDate = getDateTime("lastyear") . "-12-31";
$statisticValueLastYearComplete = getCsStatistic ($rpObjId, $tmpFromDate, $tmpToDate);
endif;
*/
if ($month_from == "" || $year_from == "") :
$month_from = getDateTime("month");
$year_from = getDateTime("year");
endif;
if ($year_from == "" || $month_from == "" || $day_from == "" || $year_to == "" || $month_to == "" || $day_to == "") :
// Default monthly like frontend
$fromDateRange = $year_from . "-" . pad($month_from,2) . "-" . "01";
$toDateRange = $year_from . "-" . pad($month_from,2) . "-" . $calMonthDays[($month_from - 1)];
else :
$fromDateRange = $year_from . "-" . pad($month_from,2) . "-" . pad($day_from,2);
$toDateRange = $year_to . "-" . pad($month_to,2) . "-" . pad($day_to,2);
endif;
elseif ($requestMode == "102") :
$pageTitel = getLngt("KASSETTENBEWEGUNGEN");
if ($isCron) :
$authCheck = TRUE;
else :
$authCheck = authCheckEmployeeRights($emp_id, "0");
endif;
// Parameters
$limitOfRowsDisplayed = getParameterValue("0", "MASK_STAT_ILLT_ROWS_DISPLAYED_102", "0"); // For limitation of the rows displayed
if ($limitOfRowsDisplayed == "" || !is_numeric($limitOfRowsDisplayed)) : $limitOfRowsDisplayed = 10000; endif;
if ($month_from == "" || $year_from == "") :
$month_from = getDateTime("month");
$year_from = getDateTime("year");
endif;
if ($year_from == "" || $month_from == "" || $day_from == "" || $year_to == "" || $month_to == "" || $day_to == "") :
// Default monthly like frontend
$fromDateRange = $year_from . "-" . pad($month_from,2) . "-" . "01";
$toDateRange = $year_from . "-" . pad($month_from,2) . "-" . $calMonthDays[($month_from - 1)];
else :
$fromDateRange = $year_from . "-" . pad($month_from,2) . "-" . pad($day_from,2);
$toDateRange = $year_to . "-" . pad($month_to,2) . "-" . pad($day_to,2);
endif;
elseif ($requestMode == "103") :
$pageTitel = getLngt("ALARMSTATUS");
if ($isCron) :
$authCheck = TRUE;
else :
$authCheck = authCheckEmployeeRights($emp_id, "0");
endif;
// Parameters
$limitOfRowsDisplayed = getParameterValue("0", "MASK_STAT_ILLT_ROWS_DISPLAYED_103", "0"); // For limitation of the rows displayed
if ($limitOfRowsDisplayed == "" || !is_numeric($limitOfRowsDisplayed)) : $limitOfRowsDisplayed = 10000; endif;
if ($month_from == "" || $year_from == "") :
$month_from = getDateTime("month");
$year_from = getDateTime("year");
endif;
if ($year_from == "" || $month_from == "" || $day_from == "" || $year_to == "" || $month_to == "" || $day_to == "") :
// Default monthly like frontend
$fromDateRange = $year_from . "-" . pad($month_from,2) . "-" . "01";
$toDateRange = $year_from . "-" . pad($month_from,2) . "-" . $calMonthDays[($month_from - 1)];
else :
$fromDateRange = $year_from . "-" . pad($month_from,2) . "-" . pad($day_from,2);
$toDateRange = $year_to . "-" . pad($month_to,2) . "-" . pad($day_to,2);
endif;
elseif ($requestMode == "104") :
$pageTitel = getLngt("Abgeholte Kassetten");
if ($isCron) :
$authCheck = TRUE;
else :
$authCheck = authCheckEmployeeRights($emp_id, "0");
endif;
// Parameters
$limitOfRowsDisplayed = getParameterValue("0", "MASK_STAT_ILLT_ROWS_DISPLAYED_104", "0"); // For limitation of the rows displayed
if ($limitOfRowsDisplayed == "" || !is_numeric($limitOfRowsDisplayed)) : $limitOfRowsDisplayed = 10000; endif;
if ($year_from == "" || $month_from == "" || $day_from == "") :
$day_from = getDateTime("day");
$month_from = getDateTime("month");
$year_from = getDateTime("year");
endif;
if ($year_from == "" || $month_from == "" || $day_from == "" || $year_to == "" || $month_to == "" || $day_to == "") :
// Default monthly like frontend
$fromDateRange = $year_from . "-" . pad($month_from,2) . "-" . "01";
$toDateRange = $year_from . "-" . pad($month_from,2) . "-" . $calMonthDays[($month_from - 1)];
else :
$fromDateRange = $year_from . "-" . pad($month_from,2) . "-" . pad($day_from,2);
$toDateRange = $year_to . "-" . pad($month_to,2) . "-" . pad($day_to,2);
endif;
elseif ($requestMode == "105") :
// .............
elseif ($requestMode == "199") :
// .............
else :
if ($day_from == "" || $month_from == "" || $year_from == "" ||
$day_to == "" || $month_to == "" || $year_to == "") :
if ($currentMonth >= 7) :
$fromDateRange = getDateTime("year") . "-07-01";
else :
$fromDateRange = getDateTime("year") . "-01-01";
endif;
$toDateRange = $currentDate;
$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);
$toDateRange = $year_to . "-" . pad($month_to,2) . "-" . pad($day_to,2);
endif;
endif;
// $fromDateRange .= " 00:00:00";
// $toDateRange .= " 23:59:59";
if (!$isCron) :
include ("../admin/menu.php");
endif;
include_once ("../include/html.inc.php");
include_once ("../include/inc_stock.inc.php");
getCurrentScript(__FILE__);
// if (!$isCron && (!$authCheck || !authCheckEmployeeRights($emp_id, "16"))) : gotoReferer("1"); endif;
// Mandator filter (related here to the USER !!!)
if ($f_hq_id == "") : $f_hq_id = array(); endif;
if (count($f_hq_id) == 0) : array_push($f_hq_id, $hq_id); endif;
if ($f_sort == "") : $f_sort = "0"; endif; // ORDER BY column "$fieldArray[$f_sort]"
if ($limitOfRowsDisplayed == "") : $limitOfRowsDisplayed = $maxLimitOfRowsDisplayed; endif;
$f_text = trim($f_text); // Text of an entry
$output = "";
// Export report statistic data as CSV file
if ($f_stat_export == "" || count($f_stat_export) == 0) : $f_stat_export = false; else: $f_stat_export = true; endif;
// Get the array for formatting the database-values for the output according to the defined type
$outputFormatField = defineOutputFormats();
if ($debug) :
echo "fromDateRange = " . $fromDateRange . "<br>";
echo "toDateRange = " . $toDateRange . "<br>";
endif;
if ($debugLog) :
writeToFile($logFile, $currentTime . " - " . "fromDateRange = " . $fromDateRange);
writeToFile($logFile, $currentTime . " - " . "toDateRange = " . $toDateRange);
endif;
if ($f_act == "execute" && $requestMode != "") :
$f_act = ""; // Init
$orderByClause = "";
if ($requestMode == "101") :
// Generate list with header
$titleArray = array(getLngt("Serienr."),getLngt("Datum"),getLngt("BEK"),getLngt("MEK"),getLngt("H1"),getLngt("H2"),getLngt("H3"));
$fieldArray = array("atih_serialno","atih_data_04","atih_data_05","atih_data_06","atih_data_07","atih_data_08","atih_data_09");
$aligns = "l,l,r,r,r,r,r";
$widths = "120,100,80,80,80,80,80";
if ($f_sort != "" && is_numeric($f_sort)) :
$orderByClause = "atih." . $fieldArray[$f_sort];
if ($orderByClause == "atih.atih_serialno") :
$orderByClause .= ", LEFT(atih.atih_data_04,10) ";
endif;
endif;
if ($orderByClause == "") :
$orderByClause = " atih.atih_serialno, LEFT(atih.atih_data_04,10) ";
endif;
// Automatendaten
// $sqlquery = "SELECT CONCAT(atih.atih_serialno,';',LEFT(atih.atih_data_04,10),';',atih.atih_data_05,';',atih.atih_data_06,';',atih.atih_data_07,';',atih.atih_data_08,';',atih.atih_data_09)"
$sqlquery = "SELECT atih.atih_serialno, LEFT(atih.atih_data_04,10) AS atih_data_04, atih.atih_data_05, atih.atih_data_06, atih.atih_data_07, atih.atih_data_08, atih.atih_data_09"
. " FROM"
. " phoenix_log.articleitemhistory AS atih,"
. " phoenix.article AS at"
. " WHERE "
. " LEFT(atih.atih_data_04,10) >= '" . $fromDateRange . "' AND"
. " LEFT(atih.atih_data_04,10) <= '" . $toDateRange . "' AND"
. " atih.at_id = at.at_id AND"
. " at.at_group LIKE '%,1,%'"
. " ORDER BY " . $orderByClause
. (!$f_stat_export ? " LIMIT 0," . $limitOfRowsDisplayed : "");
elseif ($requestMode == "102") :
// Generate list with header
$titleArray = array(getLngt("Lfd."),getLngt("Datum"),getLngt("Serienr."),getLngt("Typ"),getLngt("Quelle"),getLngt("Ziel"),getLngt("Zusatz"));
$fieldArray = array("stkmv_id","stkmv_datetime","stkmv_serialno","at_match","stk_name_from","stk_name_to","stkmv_tan");
$aligns = "r,c,l,l,l,l,l";
$widths = "40,100,80,40,150,150,150";
$whereClause = " LEFT(stkmv.stkmv_datetime,10) >= '" . $fromDateRange . "' AND"
. " LEFT(stkmv.stkmv_datetime,10) <= '" . $toDateRange . "'";
if ($f_sort != "" && is_numeric($f_sort)) :
$orderByClause = $fieldArray[$f_sort];
endif;
if ($orderByClause == "") :
$orderByClause = " stkmv.stkmv_id ";
endif;
$sqlquery = getStmtStockJournal($whereClause, $orderByClause, $limitOfRowsDisplayed);
elseif ($requestMode == "103") :
$postParserField = "usr_id_kill";
$postParserField2 = "utc_kill";
$postParserField3 = "calling_usr_id";
// Generate list with header
$titleArray = array(getLngt("Zeitpunkt"),getLngt("Auslöst durch"),getLngt("Fahrzeug"),getLngt("Beendendet durch"),getLngt("Beendigungszeit"));
$fieldArray = array("bo_createtime", $postParserField3, "usr_name", $postParserField, $postParserField2);
$aligns = "l,l,l,l,l";
$widths = "100,120,120,120,100";
if ($f_sort != "" && is_numeric($f_sort)) :
$orderByClause = "b2b." . $fieldArray[$f_sort];
if ($orderByClause == "usr.usr_firstname" || $orderByClause == "usr.usr_name" || $orderByClause == "crvh.crvh_vh_sign") :
$orderByClause .= ", LEFT(b2b.bo_createtime,10) ";
endif;
endif;
if ($orderByClause == "") :
$orderByClause = " b2b.bo_createtime ";
endif;
// Alarmdaten
$sqlquery = "SELECT b2b.bo_createtime, usr.usr_firstname, usr.usr_name, crvh.crvh_vh_sign, b2b.bo_obj_data AS " . $postParserField
. ", b2b.bo_obj_data AS " . $postParserField2 . ", b2b.bo_obj_data AS " . $postParserField3
. " FROM"
. " phoenix_log.b2b_objects AS b2b,"
. " phoenix.courier AS cr,"
. " phoenix.couriervehicle AS crvh,"
. " phoenix.user AS usr"
. " WHERE "
. " bo_ext_id1 = cr.usr_id AND"
. " cr.cr_id = crvh.cr_id AND"
. " cr.usr_id = usr.usr_id AND"
. " bo_type = 333 AND"
. " LEFT(b2b.bo_createtime,10) >= '" . $fromDateRange . "' AND"
. " LEFT(b2b.bo_createtime,10) <= '" . $toDateRange . "'"
. " ORDER BY " . $orderByClause
. (!$f_stat_export ? " LIMIT 0," . $limitOfRowsDisplayed : "");
elseif ($requestMode == "104") :
// Generate list with header
$titleArray = array(getLngt("Fahrzeug"),getLngt("Automatennummer"),getLngt("Standort"),getLngt("Kassettencode"),getLngt("Betrag"),getLngt("Belegdatum"),getLngt("Belegzeit"),getLngt("Annahmezeit"));
// Abgeholte Kassetten
$sqlquery = "SELECT b2b.bo_id, b2b.bo_createtime, b2b.bo_obj_data, usr.usr_firstname, usr.usr_name"
. " FROM"
. " phoenix_log.b2b_objects AS b2b,"
. " phoenix.courier AS cr,"
. " phoenix.user AS usr"
. " WHERE "
. " bo_ext_id1 = cr.cr_id AND"
. " cr.usr_id = usr.usr_id AND"
. " bo_type IN (221,222) AND"
. " LEFT(b2b.bo_createtime,10) >= '" . $fromDateRange . "' AND"
. " LEFT(b2b.bo_createtime,10) <= '" . $toDateRange . "'"
. " ORDER BY bo_id"
. (!$f_stat_export ? " LIMIT 0," . $limitOfRowsDisplayed : "");
endif;
// echo $sqlquery . "<br>";
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
// Special output for some categories or generic output per standard list by default
if ($requestMode == "104") :
$csvHeader = implode(",", $titleArray);
$csvHeaderLen = strlen($csvHeader);
$csvData = "";
$outputLinesArray = array();
$outputLinesArray[] = $csvHeader;
while ($row = $result->fetch_assoc()):
$boId = $row["bo_id"];
$boCreatetime = $row["bo_createtime"];
$usrFirstname = $row["usr_firstname"];
$usrName = $row["usr_name"];
$boObjData = $row["bo_obj_data"];
// Remove headline from DB content in "bo_obj_data"
$boObjData = substr($boObjData, $csvHeaderLen + 1);
$outputLinesArray[] = $boObjData;
// Aggregate contents in "bo_obj_data"
$csvData .= $boObjData . "\n";
endwhile;
$csvData = $csvHeader . "\n" . $csvData;
$csvDataOutHTML = str_replace("\n", "<br>", $csvData);
$output = $csvDataOutHTML;
else :
// DEFAULT OUTPUT STANDARD LIST
$alignArray = explode(",",$aligns);
$alignTitles = "center";
$widthArray = explode(",",$widths);
$summationField = "";
$mode = "1"; // Output from DB-RESULT
$fieldSortArray = $fieldArray;
$sortDBField = "YES"; // Used in following include-file for sorting per column;
// $javaScriptFunctionNameForSort = "finishPageStatisticIlltSort";
$javaScriptFunctionNameForSort = "";
if (!$f_stat_export) :
include ("../include/inc_list_defineoutput.inc.php");
// Post parsing if necessary
if ($postParserField != "") :
$tableBody = postParseExport($tableBody, $postParserField);
endif;
if ($postParserField2 != "") :
$tableBody = postParseExport($tableBody, $postParserField2, "postparser2");
endif;
if ($postParserField3 != "") :
$tableBody = postParseExport($tableBody, $postParserField3, "postparser3");
endif;
$output = $tableHeader . $tableBody;
else :
$output = "<tr><td>" . getLngt("Keine Bildschirmausgabe bei Download!") . "</td></tr>";
endif;
$result->free();
$sortDBField = "YES"; // Reset
$javaScriptFunctionNameForSort = ""; // Reset
// Define output table
$tableHeader = "";
$tableBody = "";
endif;
// *** File output ***
if ($f_stat_export) :
// Remove old files
foreach (glob("../export/download/" . $hashFolder . "/*.illt_exp_" . $requestMode . ".csv") as $fileNameToBoRemoved) {
// Check for older than 10 days
if ((time() - filemtime($fileNameToBoRemoved)) > $secondsForUnlink) :
if (file_exists($fileNameToBoRemoved)) :
unlink($fileNameToBoRemoved);
endif;
endif;
}
$f_secretFileName = "";
// 2nd request for file output
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
// Special FILE output for some categories or generic output per standard list by default
if ($requestMode == "104") :
else:
// Define output parameters
$delimiter = ';';
$writeHeader = "YES";
$mode = "1";
include_once ("../include/inc_list_defineoutput2file.inc.php");
endif;
$outputLinesArrayLen = count($outputLinesArray);
if ($outputLinesArrayLen > 0) :
if ($filename == "") : $filename = $pageTitel; endif;
// $f_fileName = $filename . "_" . date("YmdHis");
$f_fileName = $filename . "_" . date("Ymd");
$f_secretFileName = $f_fileName . ".illt_exp_" . $requestMode . ".csv";
// Current file to be written
$currFilename = "../export/download/" . $hashFolder . "/" . $f_secretFileName;
// If file does exist then remove it for the following rewrite process
if (file_exists($currFilename)) :
unlink($currFilename);
endif;
// Write (new) file
if ($outputHeader != "") :
writeToFile($currFilename, $outputHeader); // write header if requested
endif;
for ($i = 0; $i < $outputLinesArrayLen; $i++) :
// Post parsing if necessary
if ($postParserField != "") :
$outputLinesArray[$i] = postParseExport($outputLinesArray[$i], $postParserField);
endif;
if ($postParserField2 != "") :
$outputLinesArray[$i] = postParseExport($outputLinesArray[$i], $postParserField2, "postparser2");
endif;
if ($postParserField3 != "") :
$outputLinesArray[$i] = postParseExport($outputLinesArray[$i], $postParserField3, "postparser3");
endif;
writeToFile($currFilename, $outputLinesArray[$i]); // write statistic data
endfor;
if ($f_ftp_upload != "" && $hq_id != "" && is_numeric($hq_id)) :
if ($sendMode == "SFTP" || $sendMode == "FTP") :
$ftp_server = getParameterValue("0", "FTP_SERVER_HHA", $hq_id);
$localPath = getParameterValue("0", "FTP_LOCALPATH_HHA", $hq_id);
$remotePath = getParameterValue("0", "FTP_REMOTEPATH_HHA", $hq_id);
$ftp_user_name = getParameterValue("0", "FTP_USER_HHA", $hq_id);
$ftp_user_pass = getParameterValue("0", "FTP_PASSWORD_HHA", $hq_id);
if ($ftp_server != "" && $localPath != "" && $remotePath != "" && $ftp_user_name != "" && $ftp_user_pass != "") :
// Check remote existence of current file to be uploaded. If does exist then do NOT execute upload !!!!
$continue = true;
$f_ftp_ssl = "0";
if ($sendMode == "SFTP") : $f_ftp_ssl = "2"; endif;
$tmpArray = ftpDir($ftp_server, $ftp_user_name, $ftp_user_pass, $remotePath, "", $f_ftp_ssl);
$fileNamesRemote = $tmpArray[0];
$tmpErrNo = $tmpArray[1];
$tmpErrDesc = $tmpArray[2];
$fileNamesRemoteLen = count($fileNamesRemote);
for ($j = 0; $j < $fileNamesRemoteLen; $j++) :
if ($fileNamesRemote[$j] == $f_secretFileName) :
$continue = false;
writeToFile($logFile, $currentTime . " - ERR: EXPORT ABORTED! REMOTE DATA STILL EXIST!" . " " . $f_secretFileName);
writeToFile($logFile, "-------------------------------------------------------------------------------------------------------------------");
if ($debug) : echo "EXPORT ABORTED! REMOTE DATA STILL EXIST! \n\r"; endif;
break 1;
endif;
endfor;
if ($continue) :
$opArray = ftpUpload($f_secretFileName, $f_secretFileName, $ftp_server, $ftp_user_name, $ftp_user_pass, $localPath, $remotePath, $f_ftp_ssl);
if ($opArray[0] != "0") :
$statusMessage = getLngt("Die Datei konnte nicht hochgeladen werden. Ein Upload-Fehler ist aufgetreten!") . " [" . $f_secretFileName . "] [" . $opArray[0] . " : " . $opArray[1] . "]";
sendInternalMail($statusMessage);
if ($debug) : echo "ERROR! " . $opArray[0] . " : " . $opArray[1] . $br . " \n\r"; endif;
endif;
endif;
else :
$statusMessage = getLngt("Die Datei konnte nicht hochgeladen werden. Der FTP-Modus wurde nicht festgelgt!") . " [" . $f_secretFileName . "]";
endif;
else :
$statusMessage = getLngt("Die Datei konnte nicht hochgeladen werden. Die Verbindungsparameter unvollständig sind!") . " [" . $f_secretFileName . "]";
endif;
endif;
else :
$statusMessage = getLngt("Es wurden keine Daten gefunden! Eine Datei wurde deshalb nicht generiert!");
$f_stat_export = false;
endif;
endif;
endif;
function postParseExport ($textToParse, $postParserField, $parseTag = "") {
global $emp_id, $usr_id, $rpObjId, $reportTypeArray;
$textToParse = trim($textToParse);
if ($parseTag == "") : $parseTag = "postparser"; endif;
$parseTagLen = strlen($parseTag) + 2; // Add 2 signs "<" and ">"
if ($textToParse != "") :
$count = 1;
// Iterate ALL occurrences of "<postparser>...</postparser>"
while (!(strpos($textToParse, "<" . $parseTag . ">") === FALSE)) {
$beginTagPosBegin = strpos($textToParse, "<" . $parseTag . ">");
$beginTagPosEnd = $beginTagPosBegin + $parseTagLen;
$endTagPosBegin = strpos($textToParse, "</" . $parseTag . ">");
$endTagPosEnd = $endTagPosBegin + $parseTagLen + 1;
if ($beginTagPosEnd < $endTagPosBegin) :
$tagContent = substr($textToParse, $beginTagPosEnd, $endTagPosBegin - $beginTagPosEnd);
if ($postParserField == "usr_id_kill") :
$tagContentArray = getKeyValueArrayFromString($tagContent, "|", "=");
$usrName = getFieldValueFromId("user", "usr_id", $tagContentArray["usr_id_kill"], "usr_name");
$usrFirstname = getFieldValueFromId("user", "usr_id", $tagContentArray["usr_id_kill"], "usr_firstname");
$tagContent = $usrName . ($usrFirstname != "" ? ", " : " ") . $usrFirstname;
endif;
if ($postParserField == "utc_kill") :
$tagContentArray = getKeyValueArrayFromString($tagContent, "|", "=");
// $utcKillDatetime = gmdate($tagContentArray["utc_kill"] . ' UTC');
$killdatetime = gmdate("Y-m-d H:i:s", $tagContentArray["utc_kill"]);
$tagContent = $killdatetime;
endif;
if ($postParserField == "imei") :
$tagContentArray = getKeyValueArrayFromString($tagContent, "|", "=");
$tagContent = $tagContentArray["imei"];
endif;
if ($postParserField == "calling_usr_id") :
$tagContentArray = getKeyValueArrayFromString($tagContent, "|", "=");
$usrName = getFieldValueFromId("user", "usr_id", $tagContentArray["calling_usr_id"], "usr_name");
$usrFirstname = getFieldValueFromId("user", "usr_id", $tagContentArray["calling_usr_id"], "usr_firstname");
$tagContent = $usrName . ($usrFirstname != "" ? ", " : " ") . $usrFirstname;
endif;
// Substitute text fragment
$textToParse = substr_replace($textToParse, $tagContent, $beginTagPosBegin, $endTagPosEnd - $beginTagPosBegin);
endif;
$count++;
}
endif;
return $textToParse;
}
$contentFrame = "";
$filter_dateranges = "";
$js_date = "";
// Date-ranges
if ($requestMode == "101" || $requestMode == "102" || $requestMode == "103") :
$filter_dateranges .= "<td>" . getLngt("Monat / Jahr:") . "\n";
$filter_dateranges .= "<select name=\"month_from\" class=\"f8np1\">" . addOptionsFromRange("1", "12", pad($month_from,2), "", "2", "0") . "</select>\n";
$filter_dateranges .= "<select name=\"year_from\" class=\"f8np1\">" . addOptionsFromRange((getDateTime("year") - 3), getDateTime("year"), $year_from) . "</select>\n";
// Javascript-function as template only for
$js_date .= "<script type=\"text/javascript\">\n";
$js_date .= "<!--\n";
$js_date .= "function initForm() { }\n";
$js_date .= "-->\n";
$js_date .= "</script>\n";
elseif ($requestMode == "199") :
// $filter_dateranges .= "<td>" . getLngt("von:") . "\n";
$filter_dateranges .= "<select name=\"day_from\" class=\"f8np1\" onchange=\"javascript:serviceFinishPage('');\"></select>\n";
$filter_dateranges .= "<select name=\"month_from\" class=\"f8np1\" onchange=\"javascript:serviceFinishPage('');\"></select>\n";
$filter_dateranges .= "<select name=\"year_from\" class=\"f8np1\" onchange=\"javascript:serviceFinishPage('');\"></select>\n";
/*
$filter_dateranges .= "<select name=\"day_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $currentFrameName . "', 'history', 'day_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
$filter_dateranges .= "<select name=\"month_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $currentFrameName . "', 'history', 'month_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
$filter_dateranges .= "<select name=\"year_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $currentFrameName . "', 'history', 'year_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
$filter_dateranges .= "</td>";
$filter_dateranges .= "<td>";
$filter_dateranges .= "&nbsp;&nbsp;" . getLngt("bis:") . "\n";
$filter_dateranges .= "<select name=\"day_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $currentFrameName . "', 'history', 'day_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
$filter_dateranges .= "<select name=\"month_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $currentFrameName . "', 'history', 'month_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
$filter_dateranges .= "<select name=\"year_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $currentFrameName . "', 'history', 'year_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
$filter_dateranges .= "</td>";
*/
// Javascript-function as template only for
$js_date .= "<script type=\"text/javascript\">\n";
$js_date .= "<!--\n";
$js_date .= "function initForm() {\n";
$js_date .= " fillDateFields(1,\"" . $currentFrameName . "\",\"history\",\"\",\"day_from\",\"month_from\",\"year_from\",\"\",\"\",\"\");\n";
$js_date .= " setDateTimeFields(\"" . $currentFrameName . "\",\"history\",".$day_from.",".$month_from.",".$year_from.", \"\", \"\", \"day_from\", \"month_from\", \"year_from\", \"\", \"\", \"\");\n";
// $js_date .= " fillDateFields(1,\"" . $currentFrameName . "\",\"history\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
// $js_date .= " setDateTimeFields(\"" . $currentFrameName . "\",\"history\",".$day_to.",".$month_to.",".$year_to.", \"\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
$js_date .= "}\n";
$js_date .= "-->\n";
$js_date .= "</script>\n";
else :
$filter_dateranges = "Von:\n";
$filter_dateranges .= "<select name=\"day_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $contentFrame . "', 'cs_report', 'day_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
$filter_dateranges .= "<select name=\"month_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $contentFrame . "', 'cs_report', 'month_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
$filter_dateranges .= "<select name=\"year_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $contentFrame . "', 'cs_report', 'year_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
$filter_dateranges .= "&nbsp;&nbsp;bis:\n";
$filter_dateranges .= "<select name=\"day_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $contentFrame . "', 'cs_report', 'day_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
$filter_dateranges .= "<select name=\"month_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $contentFrame . "', 'cs_report', 'month_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
$filter_dateranges .= "<select name=\"year_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '" . $contentFrame . "', 'cs_report', 'year_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
// Javascript-function as template only for
$js_date = "<script type=\"text/javascript\">\n";
$js_date .= "<!--\n";
$js_date .= "function initForm() {\n";
$js_date .= " fillDateFields(1,\"" . $contentFrame . "\",\"cs_report\",\"\",\"day_from\",\"month_from\",\"year_from\",\"\",\"\",\"\");\n";
$js_date .= " setDateTimeFields(\"" . $contentFrame . "\",\"cs_report\",".$day_from.",".$month_from.",".$year_from.", \"\", \"\", \"day_from\", \"month_from\", \"year_from\", \"\", \"\", \"\");\n";
$js_date .= " fillDateFields(1,\"" . $contentFrame . "\",\"cs_report\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
$js_date .= " setDateTimeFields(\"" . $contentFrame . "\",\"cs_report\",".$day_to.",".$month_to.",".$year_to.", \"\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
$js_date .= "}\n";
$js_date .= "-->\n";
$js_date .= "</script>\n";
endif;
?>
<?php if (!$isCron) : ?>
<html>
<head>
<title><?php echo $pageTitel ?></title>
<link rel="stylesheet" type="text/css" href="../css/phoenix.css">
<style type="text/css">
<?php include_once ("../css/navigation.css.php"); ?>
</style>
<?php include_once ("../include/js_framework.inc.php"); ?>
<style type="text/css">
.divpadding10 { padding-top:10px; padding-bottom:10px; padding-left:10px; padding-right:10px;}
input.minwidth { min-width:90px; }
</style>
<script src="../include/lib_global.js" type="text/javascript"></script>
<?php echo $js_date ?>
<script type="text/javascript">
<!--
// NAVIGATION
<?php echo $jsMenuOut; ?>
var popupWinMetaFieldSpecial = '';
function finishPage(f_act) {
if (f_act != '') {
document.forms[0].f_act.value = f_act;
}
document.forms[0].submit();
};
function hqCheckAll(numOfHq) {
for (i = 0; i < numOfHq; i++) {
document.getElementsByName('f_hq_id[]')[i].checked = true;
}
}
function hqUncheckAll(numOfHq) {
for (i = 0; i < numOfHq; i++) {
document.getElementsByName('f_hq_id[]')[i].checked = false;
}
}
<?php if ($requestMode == ".......") : ?>
function searchCsCsc() {
var f_act = 'search';
var widthPopupWin = 950;
var heightPopupWin = 600;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../admin/cs_csc_list.php?f_act=" + f_act + "&allowAllCustomerTypes=1&generic=0000000000001&callOpenerFunction=finishPage('')",
"","dependent=yes,width=" + widthPopupWin + ",height=" +
heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin +
",scrollbars=yes");
};
function clearSpecialCustomer() {
document.forms[0].g_cs_eid.value='';
document.forms[0].rpObjId.value='';
};
<?php elseif ($requestMode == ".......") : ?>
function searchCr() {
var f_act = 'search';
var widthPopupWin = 950;
var heightPopupWin = 600;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../admin/courier_list.php?deactivateMenu=1&f_act=search&f_mode=3",
"","dependent=yes,width=" + widthPopupWin + ",height=" +
heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin +
",scrollbars=yes");
};
function clearSpecialCourier() {
document.forms[0].g_cr_id.value='';
document.forms[0].g_cr_eid.value='';
document.forms[0].rpObjId.value='';
};
<?php endif; ?>
function finishPageSort(col) {
document.forms[0].f_sort.value=col;
finishPage('');
};
function downloadExportFile() {
var widthPopupWin = 850;
var heightPopupWin = 600;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../include/data_download.php?f_path=EMC2/export/download/<?php echo $hashFolder ?>/&f_fileName=<?php echo $f_secretFileName ?>", "","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
};
-->
</script>
</head>
<body onLoad="<?php echo $phpCurrentNavigationOnLoad ?>initForm();<?php if ($f_stat_export) : echo "downloadExportFile();"; endif;?><?php if ($f_rpIdToCopy != "") : echo "changeReportForm();"; endif; ?><?php if ($confirmForNewAppointment) : echo "confirmForNewAppointment();"; endif; ?>">
<?php echo $phpMenuOut ?>
<?php echo $phpReducedMenuOut ?>
<?php echo $phpPageTitelOut ?>
<div class="maincontent" name="maincontent" id="maincontent">
<form name="cs_report" action="../export/export_illt.php" method="post" target="">
<input type="hidden" name="f_act" value="<?php echo $f_act ?>">
<input type="hidden" name="contentFrame" value="<?php echo ec($contentFrame) ?>">
<input type="hidden" name="f_sort" value="<?php echo $f_sort ?>">
<?php echo $phpCurrentNavigationInputHidden ?>
<input type="hidden" name="deactivateMenu" value="<?php echo ec($deactivateMenu) ?>">
<?php echo htmlDivLineSpacer("20px"); ?>
<!- Title -->
<div class="f10bp1_blue">
<div style="float:left">
<?php echo $pageTitel; ?>
<?php echo htmlDivLineSpacer("20px"); ?>
<div>
<select name="requestMode" onChange="finishPage('')">
<option value=""><?php echo getLngt("AUSWAHL:") ?></option>
<option value="101" <?php if ($requestMode == "101") : echo "selected"; endif; ?>><?php echo getLngt("Geldbetragshistorie") ?></option>
<option value="102" <?php if ($requestMode == "102") : echo "selected"; endif; ?>><?php echo getLngt("Kassettenbewegungen") ?></option>
<option value="103" <?php if ($requestMode == "103") : echo "selected"; endif; ?>><?php echo getLngt("Alarmstatus") ?></option>
<option value="104" <?php if ($requestMode == "104") : echo "selected"; endif; ?>><?php echo getLngt("Abgeholte Kassetten") ?></option>
</select>&nbsp;&nbsp;&nbsp;&nbsp;
<?php
if ($requestMode != "") :
echo getLngt("CSV-Export") . "&nbsp;<input class=\"f8np1\" type=\"checkbox\" name=\"f_stat_export[]\" value=\"1\">";
endif;
?>
<div>
<?php if ($requestMode == ".......") : ?>
<input type="text" name="g_cs_eid" value="<?php echo $g_cs_eid ?>" size="10" readonly>&nbsp;&nbsp;
<?php elseif ($requestMode == ".........") : ?>
<input type="hidden" name="g_cr_id" value="<?php echo $g_cr_id ?>">
<input type="text" name="g_cr_eid" value="<?php echo $g_cr_eid ?>" size="10" readonly>&nbsp;&nbsp;
<?php endif; ?>
</div>
<?php
if ($requestMode == "......") :
echo defineButtonType10("...", "action_search", "searchCsCsc();", "20", "left", "2");
elseif ($requestMode == "......") :
echo defineButtonType10("...", "action_search", "searchCr();", "20", "left", "2");
elseif ($requestMode == "......") :
echo defineButtonType10("...", "action_pt_search", "searchPt();", "20", "left", "2");
endif;
?>
<div>
<?php if ($requestMode == "......") : ?>
<a href="javascript:clearSpecialCustomer();" tabindex="340"><img src="../images/waste.png" border="0" height="15" width="12"></a>
<?php elseif ($requestMode == "......") : ?>
<a href="javascript:clearSpecialCourier();" tabindex="340"><img src="../images/waste.png" border="0" height="15" width="12"></a>
<?php elseif ($requestMode == "......") : ?>
<a href="javascript:clearSpecialProspect();" tabindex="340"><img src="../images/waste.png" border="0" height="15" width="12"></a>
<?php endif; ?>
</div>
</div>
<?php echo htmlDivLineSpacer("20px", "", "left"); ?>
<?php /* if ($statisticValueCurrentYear != "") : ?>
<div class="f8np1">
[<?php echo getLngt("Umsatz im laufenden Jahr bis heute:"); ?> &nbsp;<?php echo $statisticValueCurrentYear; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
<?php echo getLngt("Umsatz im letzen Jahr in demselben Zeitraum:") ?> &nbsp;<?php echo $statisticValueLastYear; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
<?php echo getLngt("Gesamtumsatz im letzen Jahr:") ?> &nbsp;<?php echo $statisticValueLastYearComplete; ?>]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[<?php echo $invoiceOverview; ?>]
</div>
<?php echo htmlDivLineSpacer("20px"); ?>
<?php endif; */ ?>
<!- Date-ranges -->
<div class="f10bp1_blue">
<?php echo $filter_dateranges ?>
</div>
<?php echo htmlDivLineSpacer("20px"); ?>
<!- Actions -->
<div>
<?php echo defineButtonType10(getLngt("Ausführen"), "action_stat_execute", "finishPage('execute');", "100", "left", "5") ?>
<?php echo defineButtonType10(getLngt("Schließen"), "action_close", "window.close();", "100", "left", "20") ?>
</div>
<?php echo htmlDivLineSpacer("30px", "", "left"); ?>
<!-- Headquarters checkboxes -->
<?php /*
if (!$isCron && authCheckEmployeeRights($emp_id, "10")) :
echo getHeadquartersCheckboxes($f_hq_id);
echo htmlDivLineSpacer("30px", "", "left");
endif; */
?>
<?php
if ($f_act != "") :
// if ($rowCounter > $limitOfRowsDisplayed) :
echo "<div>" . getLngt("Mehr als") . " " . $limitOfRowsDisplayed . " " . getLngt("Datensätze werden nicht dargestellt! Der Export umfasst sämtliche Daten!") . "</div>";
echo htmlDivLineSpacer("20px", "", "left");
// endif;
endif;
?>
<?php echo "<table>" . $output . "</table>" ?>
</form>
</div>
</body>
</html>
<?php endif; ?>

View File

@@ -0,0 +1,53 @@
<?php
/*=======================================================================
*
* exportdata.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
include_once ("../include/auth.inc.php");
getSecHttpVars("1",array("f_fileName","cscIdRoot","customerId","cscIdActual"));
// Check for authentication access and granted rights
$usrAccessArray["hq"] = "1"; $usrAccessArray["cs"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
authCheckEmployeeRights($emp_id, "6", "1");
if ($f_fileName != "") :
// Get the secret filename
getDbFieldValues("exportfiles",array("expf_cryptname"),array("hq_id",$hq_id,"cs_id",$customerId,"expf_name",$f_fileName));
$f_secretFileName = $expf_cryptname;
if ($f_secretFileName != "") :
$mimeType = "text/plain";
$mode = "r";
if (ENCRYPT_EXPORTDATA == "1") :
$mimeType = "application/octet-stream";
$mode = "rb";
endif;
$gmnow = gmdate('D, d M Y H:i:s') . ' GMT';
header("Content-type: " . $mimeType);
header('Expires: ' . $gmnow);
header('Content-Disposition: attachment; filename="' . $f_fileName . '"');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
$fileContent = "";
if (is_file(EXPORT_PATH . $f_secretFileName)) :
$fileContent = readFromFile(EXPORT_PATH . $f_secretFileName, "", $mode);
endif;
echo $fileContent;
endif;
endif;
?>

View File

@@ -0,0 +1,61 @@
<?php
/*=======================================================================
*
* exportdata_ftp.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
include_once ("../include/auth.inc.php");
include_once ("../include/ftp.inc.php");
getSecHttpVars("1",array("f_fileName","cscIdRoot","customerId","cscIdActual"));
// Check for authentication access and granted rights
$usrAccessArray["hq"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
authCheckEmployeeRights($emp_id, "6", "1");
if ($f_fileName != "") :
// Get the secret filename
getDbFieldValues("exportfiles",array("expf_cryptname"),array("hq_id",$hq_id,"cs_id",$customerId,"expf_name",$f_fileName));
$f_secretFileName = $expf_cryptname;
if ($f_secretFileName != "") :
$errorOccurred = FALSE;
$connId = ftpGetConnection();
if ($connId != "") :
$op = ftpUploadSingleFile($connId, EXPORT_PATH . $f_secretFileName, FTP_UPLOADPATH . $f_fileName);
if (!$op) : $errorOccurred = TRUE; endif;
else :
$errorOccurred = TRUE;
endif;
if ($connId != "") :
ftpQuitConnection($connId);
endif;
if ($errorOccurred) :
echo "Der FTP-Transfer der Datei \"" . $f_fileName . "\" ist fehlgeschlagen! <br>";
echo "Bitte wiederholen!<br>";
echo "Sollte nach einigen Versuchen die Übertragung nicht geklappt haben, bitte an uns melden!<br><br>";
echo "Ihr votian-Team<br>";
else :
echo "Der FTP-Transfer der Datei \"" . $f_fileName . "\" war erfolgreich! <br>";
echo "Die Datei sollte in der Liste der \"Externen Dateien\" aufgeführt sein, wenn Sie die Seite \"Datenexport\" aktualisieren. <br>";
// Update the flag if ftp upload was successfully
updateStmt("exportfiles", "expf_name",$f_fileName, array("expf_ftpupload", "1"));
endif;
endif;
endif;
?>

View File

@@ -0,0 +1,85 @@
<?php
/*=======================================================================
*
* exportdata_ftp_auto.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
include_once ("../include/ftp.inc.php");
$errMsg = "";
$f_fileName = "";
if (isset($argv[1]) && $argv[1] == "acapella7890") :
if (isset($argv[2]) && $argv[2] != "") :
$f_fileName = $argv[2];
if (isset($argv[3]) && $argv[3] != "") :
$hq_id = $argv[3];
if (isset($argv[4]) && $argv[4] != "") :
$customerId = $argv[4];
else :
$errMsg = "autoexport.ftp.upload failed by missing customerId";
endif;
else :
$errMsg = "autoexport.ftp.upload failed by missing hq_id";
endif;
else :
$errMsg = "autoexport.ftp.upload failed by missing f_fileName";
endif;
else :
$errMsg = "autoexport.ftp.upload failed by access code";
endif;
if ($errMsg != "") :
$f_fileName = "";
endif;
if ($f_fileName != "" && $hq_id != "") :
// Get the secret filename
getDbFieldValues("exportfiles",array("expf_cryptname"),array("hq_id",$hq_id,"cs_id",$customerId,"expf_name",$f_fileName));
$f_secretFileName = $expf_cryptname;
if ($f_secretFileName != "") :
$ftp_server = getParameterValue("0", "FTP_SERVER", $hq_id);
$ftp_user_name = getParameterValue("0", "FTP_USER", $hq_id);
$ftp_user_pass = getParameterValue("0", "FTP_PASSWORD", $hq_id);
$ftp_ssl = "0";
$export_path = getParameterValue("0", "EXPORT_PATH", $hq_id);
$ftp_uploadpath = getParameterValue("0", "FTP_UPLOADPATH", $hq_id);
$errorOccurred = FALSE;
$connId = ftpGetConnection($ftp_server, $ftp_user_name, $ftp_user_pass, $ftp_ssl);
if ($connId != "") :
$op = ftpUploadSingleFile($connId, $export_path . $f_secretFileName, $ftp_uploadpath . $f_fileName);
if (!$op) : $errorOccurred = TRUE; endif;
else :
$errorOccurred = TRUE;
endif;
ftpQuitConnection($connId);
if ($errorOccurred) :
$errMsg = "autoexport.ftp.upload failed by execution";
else :
// Update the flag if ftp upload was successfully
updateStmt("exportfiles", "expf_name",$f_fileName, array("expf_ftpupload", "1"));
endif;
else :
// $errMsg = "autoexport.ftp.upload failed by missing f_secretFileName";
endif;
endif;
if ($errMsg != "") :
sendInternalMail($errMsg . " [f_fileName:" . $f_fileName . "] " . " [hq_id:" . $hq_id . "] " . " [customerId:" . $customerId . "] ");
$f_fileName = "";
endif;
?>

View File

@@ -0,0 +1,368 @@
<?php
// Javascript-function as template only for categorie depending on date-filter (not status-filter)
$onLoadCall = "displayStatusMessage();";
$js_date = "";
// Check output regarding the export category
$displayFilterByCategory = ($f_exp_category == "4" || $f_exp_category == "5" || $f_exp_category == "6" || $f_exp_category == "7" || $f_exp_category == "8" || $f_exp_category == "9" || $f_exp_category == "110" || $f_exp_category == "115" || $f_exp_category == "120" || $f_exp_category == "125");
if ($displayFilterByCategory || $specialFunctionsArrayLen > 0) :
$js_date .= "<script src=\"../include/lib_global.js\" type=\"text/javascript\">\n";
$js_date .= "</script>\n";
$js_date .= "\n";
$js_date .= "<script type=\"text/javascript\">\n";
$js_date .= "<!--\n";
$js_date .= "function initForm() {\n";
/*
$js_date .= " fillDateFields(1,0,0,0,10,11,12,-1,-1,-1);\n";
$js_date .= " setDateTimeFields(0,0,".$day_from.",".$month_from.",".$year_from.", -1, -1, 10, 11, 12, -1, -1);\n";
$js_date .= " fillDateFields(1, 0, 0, 0, 13, 14, 15, -1, -1, -1);\n";
$js_date .= " setDateTimeFields(0,0,".$day_to.",".$month_to.",".$year_to.", -1, -1, 13, 14, 15, -1, -1);\n";
*/
$js_date .= " fillDateFields(1,\"".$frameName."\",\"export_form\",\"\",\"day_from\",\"month_from\",\"year_from\",\"\",\"\",\"\");\n";
$js_date .= " setDateTimeFields(\"".$frameName."\",\"export_form\",".$day_from.",".$month_from.",".$year_from.", \"\", \"\", \"day_from\", \"month_from\", \"year_from\", \"\", \"\", \"\");\n";
$js_date .= " fillDateFields(1,\"".$frameName."\",\"export_form\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
$js_date .= " setDateTimeFields(\"".$frameName."\",\"export_form\",".$day_to.",".$month_to.",".$year_to.", \"\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
$js_date .= "}\n";
$js_date .= "-->\n";
$js_date .= "</script>\n";
$onLoadCall .= "initForm();";
endif;
$f_headline_0 = "";
if ($f_headline == "1") : $f_headline_0 = "checked"; endif;
?>
<html>
<head>
<title>EXPORT</title>
<link rel="stylesheet" type="text/css" href="../css/phoenix.css">
<style type="text/css">
<?php include_once ("../css/navigation.css.php"); ?>
</style>
<?php include_once ("../include/js_framework.inc.php"); ?>
<script type="text/javascript">
<!--
// NAVIGATION
<?php echo $jsMenuOut; ?>
function finishPage(f_act_value) {
document.forms[0].f_act.value=f_act_value;
document.forms[0].submit();
};
function removeExportfile(f_exportFileToDeleteValue) {
if (confirm('Exportdatei ' + f_exportFileToDeleteValue + ' entfernen?')) {
document.forms[0].f_exportFileToDelete.value=f_exportFileToDeleteValue;
finishPage('removeExportfile');
};
};
-->
</script>
<?php echo $js_date ?>
</head>
<body onLoad="<?php echo $phpCurrentNavigationOnLoad ?><?php echo $onLoadCall ?>">
<?php echo $phpMenuOut ?>
<?php echo $phpReducedMenuOut ?>
<?php echo $phpPageTitelOut ?>
<div class="maincontent" name="maincontent" id="maincontent">
<form name="export_form" action="../export/export.php" method="post">
<input type="hidden" name="adminInterfacePassword" value="<?php echo ec($adminInterfacePassword); ?>">
<input type="hidden" name="f_act" value="">
<input type="hidden" name="f_expp_id" value="<?php echo ec($f_expp_id); ?>">
<input type="hidden" name="customerId" value="<?php echo ec($customerId) ?>">
<input type="hidden" name="cscIdRoot" value="<?php echo ec($cscIdRoot) ?>">
<input type="hidden" name="cscIdActual" value="<?php echo ec($cscIdActual) ?>">
<input type="hidden" name="f_exportFileToDelete" value="">
<?php echo $phpCurrentNavigationInputHidden ?>
<?php echo htmlDivLineSpacer("20px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>><?php echo getLngt("Kategorie:") ?></div>
<div>
<select name="f_exp_category" onChange="submit();">
<option value="0" <?php if ($f_exp_category == "0") : echo "selected"; endif; ?>>---</option>
<?php // echo addOptionsFromTable("exportcategory","expc_id","expc_name","expc_id","expc_usrtype = '".$userType."'",$f_exp_category); ?>
<?php echo addOptionsFromTable("exportcategory","expc_id","expc_name","expc_id","expc_usrtype = '".$userType."' AND expc_type = '0'",$f_exp_category); ?>
</select>
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>><?php echo getLngt("Export-Format:") ?></div>
<div>
<select name="f_parname_export">
<?php echo $parameterNamesOptions ?>
</select>
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>><?php echo getLngt("Dateiname:") ?></div>
<div>
<input type="text" name="f_fileName" value="<?php echo $f_fileName; ?>" size="30">
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>><?php echo getLngt("Kopfzeile:") ?></div>
<div>
<input type="checkbox" name="f_headline[]" value="1" <?php echo $f_headline_0 ?>>
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>><?php echo getLngt("Delimiter:") ?></div>
<div>
<input type="text" name="f_delimiter" value="<?php echo $f_delimiter; ?>" size="5">
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<?php
$statusFilterText_01 = "Alle (kein Log)";
$statusFilterText_02 = "Nur neue";
$statusFilterText_03 = "Nur geänderte";
$statusFilterText_04 = "Nur neue und geänderte";
mcIsSet($categoryFilter);
if ($displayFilterByCategory || $specialFunctionsArrayLen > 0) :
// Date-ranges
$categoryFilter = "<div>\n";
$categoryFilter .= "<div " . setStyleHtmlDiv("200px","left") . ">Datums-Filter:</div>\n";
$categoryFilter .= " <div>\n";
$categoryFilter .= "von:&nbsp;\n";
$categoryFilter .= "<select name=\"day_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'day_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
$categoryFilter .= "<select name=\"month_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'month_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
$categoryFilter .= "<select name=\"year_from\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'year_from', 'day_from', 'month_from', 'year_from', '', '', '')\"></select>\n";
$categoryFilter .= "&nbsp;&nbsp;bis:&nbsp;\n";
$categoryFilter .= "<select name=\"day_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'day_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
$categoryFilter .= "<select name=\"month_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'month_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
$categoryFilter .= "<select name=\"year_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'year_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
$categoryFilter .= " <div>\n";
$categoryFilter .= "<div>\n";
$categoryFilter .= htmlDivLineSpacer("10px");
endif;
if ($displayFilterByCategory && $userTypeName == "hq") :
// Special customer
$categoryFilter .= "<div>\n";
$categoryFilter .= "<div " . setStyleHtmlDiv("200px","left") . ">Spezieller Kunde (EID):</div>\n";
$categoryFilter .= " <div>\n";
$categoryFilter .= " <input type=\"text\" name=\"f_cs_eid_filter\" value=\"".$f_cs_eid_filter."\" size=\"15\">\n";
$categoryFilter .= " <div>\n";
$categoryFilter .= "<div>\n";
$categoryFilter .= htmlDivLineSpacer("10px");
$statusFilterText_01 = "Alle";
$statusFilterText_02 = "Nur Barzahlung";
$statusFilterText_03 = "Nur Rechnung";
$statusFilterText_04 = "";
endif;
mcIsSet($filterSelected_0); mcIsSet($filterSelected_1); mcIsSet($filterSelected_2); mcIsSet($filterSelected_3);
if ($f_status_filter == "0") : $filterSelected_0 = "selected"; endif;
if ($f_status_filter == "1") : $filterSelected_1 = "selected"; endif;
if ($f_status_filter == "2") : $filterSelected_2 = "selected"; endif;
if ($f_status_filter == "3") : $filterSelected_3 = "selected"; endif;
$categoryFilter .= "<div>\n";
$categoryFilter .= "<div " . setStyleHtmlDiv("200px","left") . ">Status-Filter:</div>\n";
$categoryFilter .= " <div>\n";
$categoryFilter .= " <select name=\"f_status_filter\">\n";
$categoryFilter .= " <option value=\"0\" $filterSelected_0 >$statusFilterText_01</option>\n";
$categoryFilter .= " <option value=\"1\" $filterSelected_1 >$statusFilterText_02</option>\n";
$categoryFilter .= " <option value=\"2\" $filterSelected_2 >$statusFilterText_03</option>\n";
if ($statusFilterText_04 != "") :
$categoryFilter .= " <option value=\"3\" $filterSelected_3 >$statusFilterText_04</option>\n";
endif;
$categoryFilter .= " </select>\n";
$categoryFilter .= " <div>\n";
$categoryFilter .= "<div>\n";
$categoryFilter .= htmlDivLineSpacer("10px");
echo $categoryFilter;
?>
<!--
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>>Status-Filter:</div>
<div>
<select name="f_status_filter">
<option value="0" <?php if ($f_status_filter == "0") : echo "selected"; endif; ?>>Alle</option>
<option value="1" <?php if ($f_status_filter == "1") : echo "selected"; endif; ?>>Nur geänderte</option>
<option value="2" <?php if ($f_status_filter == "2") : echo "selected"; endif; ?>>Nur Neue</option>
</select>
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
-->
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>>Fahrzeug-Filter:</div>
<div>
<?php echo addCheckboxesFromTable("f_vht_filter","metatype","mt_sort","mt_value","mt_sort","mt_type = 'vehicletype' AND mt_sort > '0' AND mt_sort < '8'","", "&nbsp;&nbsp;&nbsp;&nbsp;"); ?>
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>>Daten exportieren:</div>
<div>
<?php echo defineButtonType10("Export", "action_export", "finishPage('export');", "100", "left"); ?>
</div>
</div>
<!-- Special export functions -->
<?php if ($specialFunctionsArrayLen > 0) : ?>
<?php echo htmlDivLineSpacer("10px", "", "left"); ?>
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>>Individueller Export:</div>
<div>
<?php
for ($se = 0; $se < $specialFunctionsArrayLen; $se++) :
echo defineButtonType10("Funktion " . $specialFunctionsArray[$se], "action_export", "finishPage('special_export_" . pad($specialFunctionsArray[$se],2) . "');", "120", "left", "3");
endfor;
?>
</div>
</div>
<?php endif; ?>
<?php echo htmlDivLineSpacer("30px", "", "left"); ?>
<!-- Configuration -->
<div>
<div class="f12bp1_blue">Konfiguration</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>>Laden der Einstellungen:</div>
<div>
<select name="f_parname" onChange="submit();">
<?php echo $parameterNamesOptions ?>
</select>
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("200px","left"); ?>>Neuer Speichername:</div>
<div>
<input type="text" name="f_parname_new" value="" size="30">
</div>
</div>
<?php echo htmlDivLineSpacer("20px"); ?>
<!-- Configuration table data -->
<div>
<table border="0">
<?php echo $customConfigOutput ?>
</table>
</div>
<?php echo htmlDivLineSpacer("20px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("250px","left"); ?>>Zeichenfolge am Zeilenanfang:</div>
<div>
<input type="text" name="f_bolchars" value="<?php echo $f_bolchars; ?>" size="122">
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("250px","left"); ?>>Zeichenfolge am Zeilenende:</div>
<div>
<input type="text" name="f_eolchars" value="<?php echo $f_eolchars; ?>" size="122">
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("250px","left"); ?>>Zeichenfolge am Dateianfang:</div>
<div>
<input type="text" name="f_bofchars" value="<?php echo $f_bofchars; ?>" size="122">
</div>
</div>
<?php echo htmlDivLineSpacer("10px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("250px","left"); ?>>Zeichenfolge am Dateiende:</div>
<div>
<input type="text" name="f_eofchars" value="<?php echo $f_eofchars; ?>" size="122">
</div>
</div>
<?php echo htmlDivLineSpacer("20px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("250px","left"); ?>>Konfiguration speichern:</div>
<div>
<?php echo defineButtonType10("Speichern", "action_save", "finishPage('save');", "100", "left"); ?>
</div>
</div>
<?php echo htmlDivLineSpacer("40px", "", "left"); ?>
<!-- Exportfiles (all categories) -->
<div>
<div class="f12bp1_blue">Lokale Exportdateien (alle Kategorien)</div>
</div>
<?php echo htmlDivLineSpacer("15px"); ?>
<div>
<table>
<tr>
<td>
<?php echo $storedExportFiles ?>
</td>
</tr>
</table>
</div>
<?php echo htmlDivLineSpacer("40px"); ?>
<div>
<div class="f12bp1_blue"><?php if ($userTypeName == "hq") : echo "Exportdateien auf dem FTP-Server"; else : echo ""; endif; ?></div>
</div>
<?php echo htmlDivLineSpacer("15px"); ?>
<div>
<table>
<tr>
<td>
<?php echo $storedRemoteExportFiles ?>
</td>
</tr>
</table>
</div>
<?php echo htmlDivLineSpacer("30px"); ?>
</form>
</div>
</body>
</html>

View File

@@ -0,0 +1,635 @@
<?php
// Javascript-function as template only for categorie depending on date-filter (not status-filter)
$onLoadCall = "displayStatusMessage();";
$js_date = "";
// if ($f_exp_category == "4" || $f_exp_category == "5" || $f_exp_category == "6" || $f_exp_category == "7" || $f_exp_category == "8" || $f_exp_category == "9" || $f_exp_category == "110") :
$js_date .= "<script src=\"../include/lib_global.js\" type=\"text/javascript\">\n";
$js_date .= "</script>\n";
$js_date .= "\n";
$js_date .= "<script type=\"text/javascript\">\n";
$js_date .= "<!--\n";
$js_date .= "function initForm() {\n";
$js_date .= " fillDateFields(1,\"".$frameName."\",\"export_form\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
$js_date .= " setDateTimeFields(\"".$frameName."\",\"export_form\",".$day_to.",".$month_to.",".$year_to.", \"\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
$js_date .= "}\n";
$js_date .= "-->\n";
$js_date .= "</script>\n";
$onLoadCall .= "initForm();";
// endif;
// Number of input type="hidden" f_parstr_active and f_parstr_nodelimiter
$numOfinputHidden = 30;
// Generate filename
$f_fileName = getDateTime("year") . getDateTime("month") . getDateTime("day") . getDateTime("hour") . getDateTime("minute") . "." . EXPORT_HQ_KEY . ".";
// Set parameters according to the export call
$outParameters = "";
$outParameters .= "<input type=\"hidden\" name=\"f_act\" value=\"export\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_delimiter\" value=\"|\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_fileName\" value=\"" . $f_fileName . "\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_exp_category\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_parname\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_expp_id\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_parname_export\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_parname_new\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_fillUpChar\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_exportFileToDelete\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_bolchars\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_eolchars\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_bofchars\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_eofchars\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"day_from\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"month_from\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"year_from\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"cscIdRoot\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"customerId\" value=\"0\">\n";
$outParameters .= "<input type=\"hidden\" name=\"cscIdActual\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_export_mode\" value=\"\">\n";
$outParameters .= "<input type=\"hidden\" name=\"f_headline\" value=\"0\">\n";
$outParameters .= "<input type=\"hidden\" name=\"changeModfyStateDisabled\" value=\"\">\n";
for ($j = 0; $j < $numOfinputHidden; $j++) :
$outParameters .= "<input id=\"" . $j . "\" type=\"hidden\" name=\"f_parstr_active[]\" value=\"\">\n";
$outParameters .= "<input id=\"" . ($numOfinputHidden + $j) . "\" type=\"hidden\" name=\"f_parstr_nodelimiter[]\" value=\"\">\n";
endfor;
// Get special customer for the current employee logged in from table "parameter".
// This entry has to exist !!!
$empCsEidSpecialForCategory = "";
$parMaskDispositionCustomer = getParameterValue($emp_id, "MASK_DISPOSITION_INIT_CS", $hq_id);
if ($parMaskDispositionCustomer != "" && is_numeric($parMaskDispositionCustomer) && $parMaskDispositionCustomer != "0") :
$empCsEidSpecialForCategory = getFieldValueFromId("customer", "cs_id", $parMaskDispositionCustomer, "cs_eid");
endif;
?>
<html>
<head>
<title>EXPORT</title>
<style type="text/css">
<?php include_once ("../css/phoenix.css.php"); ?>
<?php include_once ("../css/navigation.css.php"); ?>
<?php include_once ("../css/mc.css.php"); ?>
</style>
<?php include_once ("../include/js_framework.inc.php"); ?>
<script src="../include/checkFormTags.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
// NAVIGATION
<?php echo $jsMenuOut; ?>
function finishPage(export_mode) {
var export_yn = '1';
var confirm_export = '0';
var numOfinputHidden = <?php echo $numOfinputHidden ?>;
var df = document.forms[0];
// Set export mode for hidden document parameter, e.g. = "abr_kred_bv" using the same category like "abr" making needed changes for export process
df.f_export_mode.value = export_mode;
if (export_mode == 'abr' || export_mode == 'gut' || export_mode == 'abr_kred_bv' || export_mode == 'special') {
if (df.day_to.value == '' || df.month_to.value == '' || df.year_to.value == '') {
export_yn = '0';
alert('Geben Sie bitte das Datum an, bis zu dem exportiert werden soll!');
} else {
if (!confirm('Ist das bis-Datum ' + df.day_to.value + '.' + df.month_to.value + '.' + df.year_to.value + ' richtig?')) {
export_yn = '0';
}
}
}
if (export_mode == 'abr_kred_bv') {
// Check for special customer has to be set !!!!
var empCsEidSpecialForCategory = '<?php echo $empCsEidSpecialForCategory ?>';
if (df.f_cs_eid_filter.value == '') { // df.f_cs_eid_filter.value != empCsEidSpecialForCategory
export_yn = '0';
if (empCsEidSpecialForCategory != '') {
df.f_cs_eid_filter.value = empCsEidSpecialForCategory;
<?php
if ($globalParUseRelatedCustomer == "1") :
echo "setSelectedValue('f_csId', empCsEidSpecialForCategory);";
endif;
?>
alert('Die EID wurde automatisch eingetragen! Betätigen Sie bitte nochmals den Button oder löschen Sie ggfs. den Kunden wieder aus der Auswahl, wenn Sie eine andere Exportart gemäß Ihrer Berechtigungen ausführen möchten!');
} else {
alert('Stellen Sie bitte im Mitarbeiterstammblatt Ihren Default-Kunden ein!');
}
}
}
if (export_mode == 'ums') {
// Check for special customer has to be set !!!!
var empCsEidSpecialForCategory = '<?php echo $empCsEidSpecialForCategory ?>';
if (df.f_cs_eid_filter.value == '') { // df.f_cs_eid_filter.value != empCsEidSpecialForCategory
export_yn = '0';
if (empCsEidSpecialForCategory != '') {
df.f_cs_eid_filter.value = empCsEidSpecialForCategory;
<?php
if ($globalParUseRelatedCustomer == "1") :
echo "setSelectedValue('f_csId', empCsEidSpecialForCategory);";
endif;
?>
// Get cs_id
ajaxRequestGet('../include/ajaxReqLib.php', 'mode=0&db_table=customer&db_id_field=cs_eid&search_value=' + empCsEidSpecialForCategory + '&db_return_field=cs_id');
if (retValue != '') {
var cs_id_curr = retValue;
var cs_grp_id_curr = 0;
var tmpCsOrGrp = 'cs';
for(var i = 1; i <= 10; i++) {
// Set filter for payment modes regarding to definition by DB parameter
ajaxRequestGet('../include/ajaxReqLib.php', 'mode=5&search_value=EXPORT_CAT_09_JBPMODE_NAMES_' + padl(i.toString(),2,'0') + '_CS&id_01=' + cs_id_curr);
// If empty check for group parameter the customer belongs to
if (retValue == '') {
// Get grp_id from the current cs_id
ajaxRequestGet('../include/ajaxReqLib.php', 'mode=0&db_table=customer&db_id_field=cs_id&search_value=' + cs_id_curr + '&db_return_field=cs_group');
if (retValue != '') {
var tmpGroupArray = retValue.split(",");
cs_grp_id_curr = tmpGroupArray[1] // .... because of the leading comma sign in group notation
ajaxRequestGet('../include/ajaxReqLib.php', 'mode=5&search_value=EXPORT_CAT_09_JBPMODE_NAMES_' + padl(i.toString(),2,'0') + '_GRP&id_01=' + cs_grp_id_curr);
tmpCsOrGrp = 'grp';
}
}
if (retValue != '') {
insertNewOption('f_jbp_filter', i, retValue, true, true);
}
}
setSelectedValue('f_jbp_filter', 1);
}
alert('Die EID wurde automatisch eingetragen! Betätigen Sie bitte nochmals den Button oder löschen Sie ggfs. den Kunden wieder aus der Auswahl, wenn Sie eine andere Exportart gemäß Ihrer Berechtigungen ausführen möchten!');
} else {
alert('Stellen Sie bitte im Mitarbeiterstammblatt Ihren Default-Kunden ein!');
}
}
}
if (export_yn == '1') {
if (export_mode == 'deb') {
if (confirm('Export der Debitoren jetzt ausführen?')) {
confirm_export = '1';
df.f_fileName.value = df.f_fileName.value + 'deb';
df.f_exp_category.value = '1';
df.f_parname.value = 'RETRANS Debitorenstammsatz';
df.f_expp_id.value = '101';
df.f_parname_export.value = 'RETRANS Debitorenstammsatz';
var f_parstr_active_tmp = new Array(2,3,7,8,10,11,12,13,15,23,24,26,27,29,31,40,42,43,44,45);
for(var i = 0; i < f_parstr_active_tmp.length; i++) {
document.getElementById(i).value = f_parstr_active_tmp[i];
}
var f_parstr_nodelimiter_tmp = new Array(11,42);
for(var i = 0; i < f_parstr_nodelimiter_tmp.length; i++) {
document.getElementById(numOfinputHidden + i).value = f_parstr_nodelimiter_tmp[i];
}
}
}
if (export_mode == 'kred') {
if (confirm('Export der Kreditoren jetzt ausführen?')) {
confirm_export = '1';
df.f_fileName.value = df.f_fileName.value + 'kred';
df.f_exp_category.value = '2';
df.f_parname.value = 'RETRANS Kreditorenstammsatz';
df.f_expp_id.value = '201';
df.f_parname_export.value = 'RETRANS Kreditorenstammsatz';
var f_parstr_active_tmp = new Array(1010,1020,1030,1040,1060,1070,1090,1160,1280,1290,1300,1310,1320,1360);
for(var i = 0; i < f_parstr_active_tmp.length; i++) {
document.getElementById(i).value = f_parstr_active_tmp[i];
}
var f_parstr_nodelimiter_tmp = new Array(1290,'');
for(var i = 0; i < f_parstr_nodelimiter_tmp.length; i++) {
document.getElementById(numOfinputHidden + i).value = f_parstr_nodelimiter_tmp[i];
}
}
}
if (export_mode == 'fzg') {
if (confirm('Export der Fahrzeuge jetzt ausführen?')) {
confirm_export = '1';
df.f_fileName.value = df.f_fileName.value + 'fzg';
df.f_exp_category.value = '3';
df.f_parname.value = 'RETRANS Fahrzeugstammsatz';
df.f_expp_id.value = '301';
df.f_parname_export.value = 'RETRANS Fahrzeugstammsatz';
var f_parstr_active_tmp = new Array(2030,2040,2060,2080,2090,2100,2110,2120,2130,2150,2300,2350);
for(var i = 0; i < f_parstr_active_tmp.length; i++) {
document.getElementById(i).value = f_parstr_active_tmp[i];
}
var f_parstr_nodelimiter_tmp = new Array();
for(var i = 0; i < f_parstr_nodelimiter_tmp.length; i++) {
document.getElementById(numOfinputHidden + i).value = f_parstr_nodelimiter_tmp[i];
}
}
df.f_bolchars.value = '00';
}
if (export_mode == 'abr') {
if (confirm('Export der Aufträge jetzt ausführen?')) {
confirm_export = '1';
df.f_fileName.value = df.f_fileName.value + 'abr';
df.f_exp_category.value = '5';
df.f_parname.value = 'RETRANS Abrechnungen';
df.f_expp_id.value = '501';
df.f_parname_export.value = 'RETRANS Abrechnungen';
var f_parstr_active_tmp = new Array(3300,3320,3325,3330,3340,3350,3360,3370,3390,3400,3410,3420,3430,3440,3460,3480,3500,3510,3520,3530,3570);
for(var i = 0; i < f_parstr_active_tmp.length; i++) {
document.getElementById(i).value = f_parstr_active_tmp[i];
}
var f_parstr_nodelimiter_tmp = new Array();
for(var i = 0; i < f_parstr_nodelimiter_tmp.length; i++) {
document.getElementById(numOfinputHidden + i).value = f_parstr_nodelimiter_tmp[i];
}
df.day_from.value = '01';
df.month_from.value = '01';
df.year_from.value = '2004';
}
}
if (export_mode == 'gut') {
if (confirm('Export der Gutschriften jetzt ausführen?')) {
confirm_export = '1';
df.f_fileName.value = df.f_fileName.value + 'gut';
df.f_exp_category.value = '6';
df.f_parname.value = 'RETRANS Abrechnungen';
df.f_expp_id.value = '601';
df.f_parname_export.value = 'RETRANS Abrechnungen';
var f_parstr_active_tmp = new Array(3700,3720,3725,3730,3740,3750,3760,3770,3790,3800,3810,3820,3830,3840,3860,3880,3910,3920,3930,3970);
for(var i = 0; i < f_parstr_active_tmp.length; i++) {
document.getElementById(i).value = f_parstr_active_tmp[i];
}
var f_parstr_nodelimiter_tmp = new Array();
for(var i = 0; i < f_parstr_nodelimiter_tmp.length; i++) {
document.getElementById(numOfinputHidden + i).value = f_parstr_nodelimiter_tmp[i];
}
df.day_from.value = '01';
df.month_from.value = '01';
df.year_from.value = '2004';
}
}
if (export_mode == 'abr_kred_bv') {
if (confirm('Export der Aufträge jetzt ausführen?')) {
confirm_export = '1';
df.f_fileName.value = df.f_fileName.value + 'abr';
df.f_exp_category.value = '8';
df.f_parname.value = 'RETRANS Fuhrlohn';
df.f_expp_id.value = '803';
df.f_parname_export.value = 'RETRANS Fuhrlohn';
var f_parstr_active_tmp = new Array(10100,10110,10120,10130,10140,10150,10160,10170,10180,10200,10210,10240,10250,10270,10310,10320,10330,10340,10380,10430,10460,10480,10500,10510,10520);
for(var i = 0; i < f_parstr_active_tmp.length; i++) {
document.getElementById(i).value = f_parstr_active_tmp[i];
}
var f_parstr_nodelimiter_tmp = new Array();
for(var i = 0; i < f_parstr_nodelimiter_tmp.length; i++) {
document.getElementById(numOfinputHidden + i).value = f_parstr_nodelimiter_tmp[i];
}
df.day_from.value = '01';
df.month_from.value = '01';
df.year_from.value = '2004';
}
}
if (export_mode == 'ums') {
if (confirm('Export der Einnahmen jetzt ausführen?')) {
confirm_export = '1';
df.f_fileName.value = df.f_fileName.value + 'ums';
df.f_exp_category.value = '9';
df.f_parname.value = 'RETRANS Umsatz';
df.f_expp_id.value = '903';
df.f_parname_export.value = 'RETRANS Umsatz';
var f_parstr_active_tmp = new Array(11010,11020,11040,11060,11080,11090,11100,11140,11160,11170,11180,11190,11210,11220,11230);
for(var i = 0; i < f_parstr_active_tmp.length; i++) {
document.getElementById(i).value = f_parstr_active_tmp[i];
}
var f_parstr_nodelimiter_tmp = new Array();
for(var i = 0; i < f_parstr_nodelimiter_tmp.length; i++) {
document.getElementById(numOfinputHidden + i).value = f_parstr_nodelimiter_tmp[i];
}
df.day_from.value = '01';
df.month_from.value = '01';
df.year_from.value = '2004';
}
}
if (export_mode == 'sales_deb') {
if (confirm('Export der Debitoren für Vertriebsaktivitäten jetzt ausführen?')) {
confirm_export = '1';
df.f_fileName.value = df.f_fileName.value + 'sales_deb';
df.f_exp_category.value = '1';
df.f_parname.value = 'Debitoren Vertrieb';
df.f_expp_id.value = '701';
df.f_parname_export.value = 'Debitoren Vertrieb';
df.f_delimiter.value = ';';
df.f_headline.value = '1';
df.changeModfyStateDisabled.value = '1'; // Disable change of modification state of the db row
/*
var f_parstr_active_tmp = new Array(2,3,7,8,10,11,12,13,15,23,24,26,27,29,31,40,42,43,44,45);
for(var i = 0; i < f_parstr_active_tmp.length; i++) {
document.getElementById(i).value = f_parstr_active_tmp[i];
}
var f_parstr_nodelimiter_tmp = new Array(11,42);
for(var i = 0; i < f_parstr_nodelimiter_tmp.length; i++) {
document.getElementById(numOfinputHidden + i).value = f_parstr_nodelimiter_tmp[i];
}
*/
}
}
if (export_mode == 'special') {
if (df.f_cs_eid_filter.value == '') {
confirm_export = '0';
alert('Geben Sie bitte den Kunden an, dessen Daten exportiert werden sollen!');
} else {
if (confirm('Speziellen Export jetzt ausführen?')) {
confirm_export = '1';
df.f_fileName.value = df.f_fileName.value + 'abr';
df.f_exp_category.value = '5';
df.f_parname.value = 'RETRANS Abrechnungen';
df.f_expp_id.value = '501';
df.f_parname_export.value = 'RETRANS Abrechnungen';
var f_parstr_active_tmp = new Array(3300,3320,3325,3330,3340,3350,3360,3370,3390,3400,3410,3420,3430,3440,3460,3480,3500,3510,3520,3530,3570);
for(var i = 0; i < f_parstr_active_tmp.length; i++) {
document.getElementById(i).value = f_parstr_active_tmp[i];
}
var f_parstr_nodelimiter_tmp = new Array();
for(var i = 0; i < f_parstr_nodelimiter_tmp.length; i++) {
document.getElementById(numOfinputHidden + i).value = f_parstr_nodelimiter_tmp[i];
}
df.day_from.value = '01';
df.month_from.value = '01';
df.year_from.value = '2004';
}
}
}
if (confirm_export == '1') {
df.f_act.value='export';
disabledButtons = new Array('action_cs','action_cr','action_vh','action_jb','action_jb2','action_jb3','action_jbp','action_special','action_sales_cs');
df.submit();
}
}
};
function removeExportfile(f_exportFileToDeleteValue) {
if (confirm('Exportdatei ' + f_exportFileToDeleteValue + ' entfernen?')) {
document.forms[0].f_exportFileToDelete.value=f_exportFileToDeleteValue;
// finishPage('removeExportfile');
document.forms[0].f_act.value='removeExportfile';
document.forms[0].submit();
};
};
function finishPageWithDisabledCheck(export_mode, name) {
notDisabled = checkButtonIsDisabled(name);
if (notDisabled) {
finishPage(export_mode);
}
}
function finishPageConfig() {
// document.forms[0].currentNavigationItem.value='datenexport';
document.forms[0].f_act='';
document.forms[0].submit();
}
function setRelatedCustomerValue() {
document.forms[0].f_cs_eid_filter.value = getSelectedValue('f_csId');
}
-->
</script>
<?php echo $js_date ?>
</head>
<body onLoad="<?php echo $phpCurrentNavigationOnLoad ?><?php echo $onLoadCall ?>">
<?php echo $phpMenuOut ?>
<?php echo $phpReducedMenuOut ?>
<?php echo $phpPageTitelOut ?>
<div class="mc_page-header" id="mc_page-header">
<?php echo getLngt("Export ausführen") ?>
</div>
<div>
<?php
if ($userTypeName == "hq" && $empHasAccess_06) :
$parButtonDisabled = getParameterValue("0", "EXPORT_MASK_DEBITOR_DISABLED", $hq_id);
if ($parButtonDisabled == "") : $parButtonDisabled = getParameterValue("0", "EXPORT_MASK_DEBITOR_DISABLED", "0"); endif;
if ($parButtonDisabled != "1") :
echo defineButtonType10("Debitoren", "action_cs", "finishPageWithDisabledCheck('deb','action_cs');", "120", "left", "0");
endif;
$parButtonDisabled = getParameterValue("0", "EXPORT_MASK_CREDITOR_DISABLED", $hq_id);
if ($parButtonDisabled == "") : $parButtonDisabled = getParameterValue("0", "EXPORT_MASK_CREDITOR_DISABLED", "0"); endif;
if ($parButtonDisabled != "1") :
echo defineButtonType10("Kreditoren", "action_cr", "finishPageWithDisabledCheck('kred','action_cr');", "120", "left", "0");
endif;
$parButtonDisabled = getParameterValue("0", "EXPORT_MASK_VEHICLE_DISABLED", $hq_id);
if ($parButtonDisabled == "") : $parButtonDisabled = getParameterValue("0", "EXPORT_MASK_VEHICLE_DISABLED", "0"); endif;
if ($parButtonDisabled != "1") :
echo defineButtonType10("Fahrzeuge", "action_vh", "finishPageWithDisabledCheck('fzg','action_vh');", "120", "left", "0");
endif;
$parButtonDisabled = getParameterValue("0", "EXPORT_MASK_DEBITNOTE_DISABLED", $hq_id);
if ($parButtonDisabled == "") : $parButtonDisabled = getParameterValue("0", "EXPORT_MASK_DEBITNOTE_DISABLED", "0"); endif;
if ($parButtonDisabled != "1") :
echo defineButtonType10("Aufträge", "action_jb", "finishPageWithDisabledCheck('abr','action_jb');", "120", "left", "0");
endif;
$parButtonDisabled = getParameterValue("0", "EXPORT_MASK_CREDITNOTE_DISABLED", $hq_id);
if ($parButtonDisabled == "") : $parButtonDisabled = getParameterValue("0", "EXPORT_MASK_CREDITNOTE_DISABLED", "0"); endif;
if ($parButtonDisabled != "1") :
echo defineButtonType10("Gutschriften", "action_jb2", "finishPageWithDisabledCheck('gut','action_jb2');", "120", "left", "0");
endif;
$parButtonDisabled = getParameterValue("0", "EXPORT_MASK_CARRIER_DISABLED", $hq_id);
if ($parButtonDisabled == "") : $parButtonDisabled = getParameterValue("0", "EXPORT_MASK_CARRIER_DISABLED", "0"); endif;
if ($parButtonDisabled != "1") :
echo defineButtonType10("Fuhrlöhne", "action_jb3", "finishPageWithDisabledCheck('abr_kred_bv','action_crbv');", "120", "left", "0");
endif;
endif;
if ($userTypeName == "hq" && $empHasAccess_26) :
$parButtonDisabled = getParameterValue("0", "EXPORT_MASK_COLLECTED_VOLUME_DISABLED", $hq_id);
if ($parButtonDisabled == "") : $parButtonDisabled = getParameterValue("0", "EXPORT_MASK_COLLECTED_VOLUME_DISABLED", "0"); endif;
if ($parButtonDisabled != "1") :
echo defineButtonType10("Einnahmen", "action_jbp", "finishPageWithDisabledCheck('ums','action_jbp');", "120", "left", "0");
endif;
endif;
?>
</div>
<?php if (false) : ?>
<?php echo htmlDivLineSpacer("20px", "", "left"); ?>
<div>
<?php
if ($userTypeName == "hq" && $empHasAccess_06) :
$parButtonDisabled = getParameterValue("0", "EXPORT_MASK_DEBITOR_SALES_DISABLED", $hq_id);
if ($parButtonDisabled == "") : $parButtonDisabled = getParameterValue("0", "EXPORT_MASK_DEBITOR_SALES_DISABLED", "0"); endif;
if ($parButtonDisabled != "1") :
echo defineButtonType10("Debitoren Vertrieb", "action_sales_cs", "finishPageWithDisabledCheck('sales_deb','action_sales_cs');", "200", "left", "3");
endif;
endif;
?>
</div>
<?php endif; ?>
<?php echo htmlDivLineSpacer("30px"); ?>
<?php
if ($globalParUseRelatedCustomer == "1") :
$parButtonDisabled = getParameterValue("0", "EXPORT_MASK_SPECIAL_DISABLED", $hq_id);
if ($parButtonDisabled == "") : $parButtonDisabled = getParameterValue("0", "EXPORT_MASK_SPECIAL_DISABLED", "0"); endif;
if ($parButtonDisabled != "1") :
// Start pre-processor für special exports
if ($userTypeName == "hq" && $empHasAccess_06 && $empHasAccess_05) :
echo "<div>";
echo defineButtonType10("Spezial", "action_special", "finishPageWithDisabledCheck('special','action_special');", "120", "left", "3");
echo "</div>";
echo htmlDivLineSpacer("70px");
endif;
endif;
endif;
?>
<div class="maincontent mc_elem" name="maincontent" id="maincontent">
<form name="export_form" action="../export/export.php" method="post">
<?php echo $phpCurrentNavigationInputHidden ?>
<?php echo $outParameters; ?>
<?php echo htmlDivLineSpacer("20px"); ?>
<div class="mc_page-header" id="mc_page-header">
<?php echo getLngt("Filter für Aufträge und Gutschriften") ?>
</div>
<?php echo htmlDivLineSpacer("15px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("250px","left"); ?>><?php echo getLngt("Export bis inklusive") ?>:</div>
<div>
<?php
// To-Date
$categoryFilter = "<select name=\"day_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'day_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
$categoryFilter .= "<select name=\"month_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'month_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
$categoryFilter .= "<select name=\"year_to\" class=\"f8np1\" onchange=\"fillDateFields(0, '".$frameName."', 'export_form', 'year_to', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
echo $categoryFilter;
?>
</div>
</div>
<?php echo htmlDivLineSpacer("20px"); ?>
<div>
<div <?php echo setStyleHtmlDiv("250px","left"); ?>><?php echo getLngt("Nur spezieller Kunde (EID)") ?>:</div>
<div>
<?php
// Special customer
if ($globalParUseRelatedCustomer != "1") :
$categoryFilter = "<input type=\"text\" name=\"f_cs_eid_filter\" value=\"" . ($f_exp_category != "8" && $f_exp_category != "9" ? $f_cs_eid_filter : "") . "\" size=\"15\">\n";
else :
$categoryFilter = "<input type=\"text\" name=\"f_cs_eid_filter\" value=\"" . ($f_exp_category != "8" && $f_exp_category != "9" ? $f_cs_eid_filter : "") . "\" size=\"15\" readonly>\n";
// Group selection (all groups with state "read only" will be displayed)
// $categoryFilter .= "&nbsp;&nbsp;" . getLngt("Gruppe") . ":&nbsp;";
// $categoryFilter .= "<select class=\"f8np1\" name=\"f_grpId\" id=\"f_grpId\" onChange=\"finishPage('');\">\n";
// $categoryFilter .= " <option value=\"\"" . ($f_grpId == "" ? "selected" : "") . ">" . getLngt("----") . "</option>\n";
// $categoryFilter .= addOptionsFromTable("groups AS grp","grp.grp_id","grp.grp_name","grp.grp_id","grp.md_id = '" . $md_id . "' AND grp.grp_readonly = '1'",$f_grpId);
// $categoryFilter .= "</select>\n";
// Customer selection
$categoryFilter .= "&nbsp;&nbsp;" . getLngt("Kunde") . ":&nbsp;";
$categoryFilter .= "<select class=\"f8np1\" name=\"f_csId\" id=\"f_csId\" onChange=\"setRelatedCustomerValue();\">\n";
$categoryFilter .= " <option value=\"\"" . ($f_csId == "" ? "selected" : "") . ">" . getLngt("----") . "</option>\n";
$categoryFilter .= addOptionsFromTable("customer AS cs, company AS cmp","cs.cs_eid","cmp.cmp_comp","cmp.cmp_comp","cs.hq_id = ('" . $hq_id . "') AND cmp.cmp_id = cs.cmp_id AND cmp.cmp_comp != 'EXTERN' AND cs.cs_id_parent != '0' AND NOT isnull(cs.cs_id_parent) AND cs.cs_group LIKE '%," . $f_grpId . ",%'",$f_csId);
$categoryFilter .= "</select>\n";
endif;
echo $categoryFilter;
?>
</div>
</div>
<?php echo htmlDivLineSpacer("20px"); ?>
<?php if ($userTypeName == "hq" && $empHasAccess_26) : ?>
<div>
<div <?php echo setStyleHtmlDiv("250px","left"); ?>><?php echo getLngt("Auswahlfilter für Zahlarten") ?>:</div>
<div>
<?php
// Special payment modes
$jbpModeFilter = "<select name=\"f_jbp_filter\">\n";
$jbpModeFilter .= " <option value=\"\">----</option>\n";
$jbpModeFilter .= "</select>\n";
echo $jbpModeFilter;
?>
</div>
</div>
<?php echo htmlDivLineSpacer("20px"); ?>
<?php endif; ?>
<?php if ($empHasAccess_06) : ?>
<div>
<div <?php echo setStyleHtmlDiv("250px","left"); ?>><?php echo getLngt("Fahrzeug-Filter") ?>:</div>
<div>
<?php echo addCheckboxesFromTable("f_vht_filter","metatype","mt_sort","mt_value","mt_sort","mt_type = 'vehicletype' AND mt_sort > '0' AND mt_sort < '8'","", "&nbsp;&nbsp;&nbsp;&nbsp;"); ?>
</div>
</div>
<?php echo htmlDivLineSpacer("50px"); ?>
<?php endif; ?>
<?php if ($empHasAccess_06) : ?>
<div>
<div <?php echo setStyleHtmlDiv("250px","left"); ?>><?php echo getLngt("Passwort für Konfigurationen") ?>:</div>
<div>
<div style="float:left;">
<input type="password" name="adminInterfacePassword" value="" size="15">&nbsp;&nbsp;&nbsp;
</div>
<?php echo defineButtonType10("Konfiguration", "action_config", "finishPageConfig();", "120", "left"); ?>
</div>
</div>
<?php endif; ?>
<?php echo htmlDivLineSpacer("50px"); ?>
<div class="mc_page-header" id="mc_page-header">
<?php echo getLngt("Lokale Exportdateien (alle Kategorien)") ?>
</div>
<?php echo htmlDivLineSpacer("15px"); ?>
<div>
<?php echo $storedExportFiles ?>
</div>
<?php echo htmlDivLineSpacer("50px"); ?>
<div class="mc_page-header" id="mc_page-header">
<?php echo getLngt("Exportdateien auf FTP-Server") ?>
</div>
<?php echo htmlDivLineSpacer("15px"); ?>
<div>
<?php echo $storedRemoteExportFiles ?>
</div>
</form>
</div>
</body>
</html>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

18
html/export/index.html Normal file
View File

@@ -0,0 +1,18 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="de">
<head>
<title>votian</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="votian"> <meta name="keywords" content="votian">
<meta http-equiv="refresh" content="0; URL=../index.php">
<link rel="stylesheet" type="text/css" href="css/phoenix.css">
</head>
<body bgcolor="#FFFFFA" leftmargin="1" topmargin="1" marginwidth="0" marginheight="0" link="#990000" vlink="#990000" alink="#990000">
<a href="../index.php">Bitte hier klicken, wenn Sie nicht automatisch weitergeleitet werden...</a>
</body>
</html>

633
html/export/post_export.php Normal file
View File

@@ -0,0 +1,633 @@
<?php
/*=======================================================================
*
* post_export.php
*
* Autor: Carsten Annacker
*
=======================================================================*/
// pre_export für Servicekurier (Schnelsen), EKS (Moorfleet), Preisdifferenzen und Rückvergütungen (Altona)
// Sammelnummer in gdc eintragen: gdc_obj_type "jb" gdc_obj_id "$jb_id" gdc_gen_fieldname "collection_number" context $collection_number
// JB_ID_ADDMONT - AUFTRÄGE FEHLEN NOCH BEI SAMS (ANALOG BUSINESSCARD!!!)
// Lagerkosten in Businesscard extra ausweisen (in SAMS nicht vorhanden?)
// Zusatz-Nachmontage extra unter Montage ausweisen
// Mehrere job_payment beachten!
$do_xls = true;
$test = false;
$test_mail = false;
error_reporting(E_ALL ^ (E_DEPRECATED | E_NOTICE));
if ($test)
include_once ("../include/inc_mtf_func.inc.test.php");
else
include_once ("../include/inc_mtf_func.inc.php");
include_once("../include/email/htmlMimeMail.php");
$log_file_name = "../log/prepost_export_";
$temp_csv_folder = "../temp/edifact/";
$paymentBC = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'payment_type' AND mt_objtype = 'grp' AND mt_objid = '11' AND mt_value = 'Businesscard'");
$paymentSAMS = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'payment_type' AND mt_objtype = 'grp' AND mt_objid = '11' AND mt_value = 'Serviceaufträge'");
$paymentSAMScourier = 91;
$paymentEKS = 92;
$paymentDiff = 93;
$paymentReturn = 94;
$cs_ids_nord = array("1", "2", "17093");
$cs_ids_sued = array("3534", "3540");
$cs_id_names = array(
"1" => "Schnelsen",
"2" => "Moorfleet",
"17093" => "Altona"
);
//$sender = "no-reply@hansetrans.de";
$sender = "support@assecutor.de";
if ($test_mail):
$recipients = array(
"1" => array("ca@assecutor.de"),
"2" => array("ca@assecutor.de"),
"17093" => array("ca@assecutor.de"),
"3534" => array("ca@assecutor.de"),
"3540" => array("ca@assecutor.de")
);
$bcc = "";
else:
$recipients = array(
// "1" => array("ikea_schnelsen-abr@hansetrans.de"),
// "2" => array("ikea-moorfleet-abr@hansetrans.de"),
// "17093" => array("ikea-altona-abr@hansetrans.de"),
"1" => array("Livia.Kroemer@hansetrans.de","stefanie.bruemmerstedt@hansetrans.de"),
"2" => array("Livia.Kroemer@hansetrans.de","stefanie.bruemmerstedt@hansetrans.de"),
"17093" => array("Livia.Kroemer@hansetrans.de","stefanie.bruemmerstedt@hansetrans.de"),
"3534" => array("abrechnung-leonberg@walter-moebeltransport.de"),
"3540" => array("abrechnung-leonberg@walter-moebeltransport.de")
);
$bcc = "ca@assecutor.de";
endif;
$subjects = array(
$paymentSAMS => "Serviceaufträge Hansetrans",
$paymentSAMScourier => "Serviceaufträge Kurier Hansetrans",
$paymentBC => "Business Card Hansetrans",
$paymentEKS => "EKS Hansetrans",
$paymentDiff => "Preisdifferenzen Hansetrans",
$paymentReturn => "Rückvergütung Hansetrans"
);
$mailtexts = array(
$paymentSAMS => "Im Anhang finden Sie die Serviceaufträge",
$paymentSAMScourier => "Im Anhang finden Sie die Serviceaufträge, die per Kurier ausgeführt wurden",
$paymentBC => "Im Anhang finden Sie die per Business Card bezahlten Aufträge",
$paymentEKS => "Im Anhang finden Sie die Einkaufsservices",
$paymentDiff => "Im Anhang finden Sie die Liste der Preisdifferenzen",
$paymentReturn => "Im Anhang finden Sie die Liste der Rückvergütungen"
);
$xlsfilename_prefixes = array(
$paymentSAMS => "service",
$paymentSAMScourier => "servicekurier",
$paymentBC => "businesscard",
$paymentEKS => "eks",
$paymentDiff => "preisdifferenz",
$paymentReturn => "rueckverguetung"
);
$serviceLief = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'LI'");
$serviceMont = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'MO'");
$serviceNeuMont = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'NM'");
$serviceKueMont = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'KU'");
$serviceAbhol = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'AB'");
$serviceAust = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'AT'");
//$argv[1] = '563'; // SAMS
//$argv[1] = '564'; // SAMS
//$argv[1] = '565'; // BC
//$argv[1] = 'dummy';
//$argv[2] = '81001029'; // Diff und Return
//$argv[1] = '566'; // Service Lief 81001062, Service Mont 81001063
//$argv[2] = '567'; // BC 81001064
//$argv[2] = '81001065'; // servicecourier
//$argv[2] = '81001066'; // EKS
mcIsSet($argv[1]);
mcIsSet($argv[2]);
myWriteLog("post_export.php: \$argv[1] = " . $argv[1] . ", \$argv[2] = " . $argv[2]);
if (strlen($argv[2]) != 8):
$exl_rows = $db->getOne("SELECT exl_rows FROM exportlog WHERE exl_id = " . $argv[1]);
$exl_exporttime = $db->getOne("SELECT exl_exporttime FROM exportlog WHERE exl_id = " . $argv[1]);
$exl_rowsArr = array_filter(explode(",", $exl_rows));
foreach ($exl_rowsArr as $exl_row) {
$sql_query = "SELECT jbpc_id, cs_id, jbpc_mode FROM jobpaymentcollection WHERE jbpc_id IN ($exl_row) AND jbpc_mode IN ($paymentSAMS, $paymentBC)";
$res = $db->query($sql_query);
if (DB::isError($res)) die ("$PHP_SELF: " . $res->getMessage());
while ($row = $res->fetch_assoc()):
$format = "sued";
if (in_array($row["cs_id"], $cs_ids_nord))
$format = "nord_service";
if($row["jbpc_mode"] == $paymentSAMS)
// send_csv_mail(do_SAMS($row["jbpc_id"]), $row["jbpc_id"], $paymentSAMS, $row["cs_id"]);
send_csv_mail(do_SAMS($exl_row, $row["cs_id"]), $row["jbpc_id"], $paymentSAMS, $row["cs_id"], $format);
if($row["jbpc_mode"] == $paymentBC)
// send_csv_mail(do_BC($row["jbpc_id"]), $row["jbpc_id"], $paymentBC, $row["cs_id"]);
send_csv_mail(do_BC($exl_row, $row["cs_id"]), $row["jbpc_id"], $paymentBC, $row["cs_id"], $format);
endwhile;
}
$res->free();
else:
$jb_id_export = $db->getOne("SELECT gdc_obj_id FROM genericdatacontainer WHERE gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'collection_number' AND gdc_content = '" . $argv[2] . "'");
$jb_exporttime = $db->getOne("SELECT jb_finishtime FROM job WHERE jb_id = $jb_id_export");
$cs_id_export = $db->getOne("SELECT cs_id FROM costcenter WHERE csc_id = " . $db->getOne("SELECT csc_id_payer FROM job WHERE jb_id = $jb_id_export"));
if ($cs_id_export == 32943)
$cs_id_export = 17093;
myWriteLog("post_export.php: \$jb_id_export = " . $jb_id_export . ", \$jb_exporttime = " . $jb_exporttime . ", \$cs_id_export = " . $cs_id_export);
switch ($argv[1]) {
case "express":
send_csv_mail(do_SAMScourier($argv[2]), $argv[2], $paymentSAMScourier, $cs_id_export, "nord_service");
break;
case "eks":
send_csv_mail(do_EKS($argv[2]), $argv[2], $paymentEKS, $cs_id_export, "nord_service");
break;
case "diff_lief":
case "diff_moebel":
if ($cs_id_export == 17093)
send_csv_mail(do_diff($argv[2], "diff", $argv[3], $cs_id_export), $argv[2], $paymentDiff, $cs_id_export, "nord_diff");
else
send_csv_mail(do_diff($argv[2], "diff", $argv[3], $cs_id_export), $argv[2], $paymentDiff, $cs_id_export, "nord_diff_special");
break;
case "return_moebel":
case "return_kueche":
case "return_lief":
if ($cs_id_export == 17093)
send_csv_mail(do_diff($argv[2], "return", $argv[3], $cs_id_export), $argv[2], $paymentReturn, $cs_id_export, "nord_return");
else
send_csv_mail(do_diff($argv[2], "return", $argv[3], $cs_id_export), $argv[2], $paymentReturn, $cs_id_export, "nord_return_special");
}
endif;
function send_csv_mail($csv_contentsArr, $jbpc_id, $paymentType, $cs_id, $format)
{
global $temp_csv_folder, $sender, $bcc, $recipients, $subjects, $mailtexts, $log_file_name, $xlsfilename_prefixes, $cs_ids_nord, $do_xls, $cs_id_names,
$paymentSAMS, $paymentBC, $paymentEKS, $paymentSAMScourier;
$xls_csv_files = "";
for ($i = 0; $i < count($csv_contentsArr); $i += 2) {
// $csv_file_name = $jbpc_id . ".csv";
if ($csv_contentsArr[$i+1] != ""):
$file_name = $cs_id_names[$cs_id] . "_" . $xlsfilename_prefixes[$paymentType] . "_" . $csv_contentsArr[$i] . "_101" . $jbpc_id;
$csv_file_name = $file_name . ".csv";
if ($do_xls):
$csv_file_name = $csv_contentsArr[$i] . ".csv";
if($paymentType == $paymentSAMS || $paymentType == $paymentBC || $paymentType == $paymentEKS || $paymentType == $paymentSAMScourier)
$file_name = $cs_id_names[$cs_id] . "_" . $xlsfilename_prefixes[$paymentType] . "_101" . $jbpc_id;
endif;
myWriteLog("post_export.php: writing " . $temp_csv_folder . $csv_file_name);
$fileHandle = @fopen($temp_csv_folder . $csv_file_name, 'w');
@fwrite($fileHandle, $csv_contentsArr[$i+1]);
@fclose($fileHandle);
$xls_csv_files .= $temp_csv_folder . $csv_file_name . " ";
endif;
}
//die();
$xls_file_name = "101" . $jbpc_id . ".xls";
if (in_array($cs_id, $cs_ids_nord)):
$xls_file_name = $file_name . ".xls";
if (($format == "diff" || $format == "return") && ($cs_id == 1 || $cs_id == 2))
$format .= "_special";
endif;
$cmd = "../tools/mycsv2xls.pl " . $xls_csv_files . " '$format' " . $temp_csv_folder . $xls_file_name . " >> " . $log_file_name . date("Ym") . ".log" . " 2>&1 &";
myWriteLog($cmd);
if ($do_xls):
@unlink($temp_csv_folder . $xls_file_name);
$ausgabe = exec($cmd);
do {
$output = array();
//myWriteLog("ps -fA | grep $xls_file_name");
exec("ps -fA | grep $xls_file_name", $output);
for ($i = 0; $i < count($output); $i++):
//myWriteLog($output[$i]);
$pos = strpos ($output[$i], "mycsv2xls.pl");
if (!($pos === false))
break;
endfor;
usleep(100000);
} while (!($pos === false));
endif;
myWriteLog("sending mail for jbpc_id = '$jbpc_id' ... (paymentType = $paymentType, cs_id = $cs_id)");
$mailObj = new htmlMimeMail();
$mailObj->setFrom($sender);
// $mailObj->setCc("leier@stadtbote.de");
if (trim($bcc) != "")
$mailObj->setBcc($bcc);
$mailObj->setSubject($subjects[$paymentType]);
$mailObj->setText($mailtexts[$paymentType]);
if ($do_xls)
$mailObj->addAttachment($mailObj->getFile($temp_csv_folder . $xls_file_name), $xls_file_name);
else
$mailObj->addAttachment($mailObj->getFile($temp_csv_folder . $csv_file_name), $csv_file_name);
$mailResult = $mailObj->send($recipients[$cs_id], 'smtp');
myWriteLog("result of sending mail for jbpc_id = '$jbpc_id': '" . $mailResult . "' (paymentType = $paymentType, cs_id = $cs_id)");
}
function do_SAMS($jbpc_id, $cs_id)
{
global $db, $exl_exporttime, $serviceLief, $serviceMont, $serviceNeuMont, $serviceKueMont, $serviceAbhol, $serviceAust, $cs_ids_nord, $cs_ids_sued;
if (in_array($cs_id, $cs_ids_sued))
$csv_text =
"Anlage zur Auftrags-Nr. 101$jbpc_id;vom " . formDate($exl_exporttime) . ";Kunden-;Auftrags-;SAMS-;Auftrags-;Erfüll-;Lieferung;Lieferung;Lieferung;Lieferung;EKS;Sofa-;Abholung;SAMS-;SAMS-;Austausch;Abholung;Rücknahme;Lager-;Montage;Annehmer\n" .
"Pos;KartenNr;name;Nr.;Nr.;datum;datum;bis WW 500,-;bis WW 1500,-;ab WW 1501,-;größer 3000kg;;montage;Austausch;Austausch;Lieferung;Palette;Palette;Matratze;geld; ;\n";
if (in_array($cs_id, $cs_ids_nord)):
$csv_textArr = array("Lieferung", "", "Montage", "");
$csv_textArr[1] = $csv_textArr[3] =
"RgNr;Datum;Kaufvertrag;OrderID;BelegNr;KartenNr;Warenwert;Preis\n";
endif;
$sumMont = 0;
$sumAbhol = 0;
$sumAust = 0;
$sumLief = 0;
$cnt = 1;
$sum1_jbp_price_sum = 0;
$sum3_jbp_price_sum = 0;
$sql_query =
"SELECT tr.tr_comp, jb.jb_id, jb.jb_id_parent, tr.tr_commission_no, jb.jb_createtime, jb.jb_ordertime, SUM(jbp.jbp_price) AS jbp_price_sum, jb.jb_service, usr.usr_name" .
" FROM job AS jb, tour AS tr, jobpayment AS jbp LEFT JOIN user AS usr ON jb.emp_id = usr.usr_id" .
" WHERE jb.jb_id = jbp.jb_id AND jbp.jbpc_id IN ($jbpc_id)" .
" AND jb.jb_id = tr.jb_id AND tr.tr_sort = 2 AND NOT (tr.tr_comp LIKE '%Test%') GROUP BY jbp.jb_id";
//echo "\n" . $sql_query . "\n\n";die();
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)):
$jbp_price_sum = bruttoSum($row["jbp_price_sum"]);
$jb_service = mcConvertNum2Sel($row["jb_service"]);
$type_str = "";
$warenwert = $db->getOne("SELECT SUM(trat_price) FROM tourarticle WHERE jb_id = " . $row["jb_id"]); // Nur Nord
if (in_array($serviceAbhol, $jb_service)):
$type_str = $jbp_price_sum . ";0;0;0;0;0;0;0";
$sumAbhol += $jbp_price_sum;
elseif (in_array($serviceAust, $jb_service)):
$type_str = "0;" . $jbp_price_sum . ";0;0;0;0;0;0";
$sumAust += $jbp_price_sum;
elseif (in_array($serviceLief, $jb_service)):
$type_str = "0;0;" . $jbp_price_sum . ";0;0;0;0;0";
$sumLief += $jbp_price_sum;
elseif (in_array($serviceMont, $jb_service)):
// if ($jbp_price_sum != 40 && $jbp_price_sum != 45):
$type_str = "0;0;0;0;0;0;0;" . $jbp_price_sum;
$sumMont += $jbp_price_sum;
// endif;
endif;
if ($type_str != "" && in_array($cs_id, $cs_ids_sued)):
// $log_createtime = $db->getOne("SELECT log_createtime FROM phoenix_log.log WHERE (log.jb_id = '" . $row["jb_id"] . "' OR log.jb_id = '" . $row["jb_id_parent"] . "') AND logo_id = 1");
$csv_text .= $cnt++ . ";;" . str_replace(";", "", $row["tr_comp"]) . ";" . $row["jb_id"] . ";" . check_str($row["tr_commission_no"]) . ";" .
formDate($row["jb_createtime"]) . ";" . formDate($row["jb_ordertime"]) . ";0;0;0;0;0;0;" . $type_str . ";" . $row["usr_name"] . "\n";
endif;
if (in_array($cs_id, $cs_ids_nord)):
$csv_text = "101" . $jbpc_id . ";" . formDate($row["jb_createtime"]) . ";" . $row["jb_id"] . ";" .
check_str($row["tr_commission_no"]) . ";;;" . $warenwert . ";" . $jbp_price_sum . "\n";
if (!in_array($serviceMont, $jb_service)):
$csv_textArr[1] .= $csv_text;
$sum1_jbp_price_sum += $jbp_price_sum;
else:
$csv_textArr[3] .= $csv_text;
$sum3_jbp_price_sum += $jbp_price_sum;
endif;
endif;
endwhile;
mysql_free_result($res);
myWriteLog("do_SAMS($jbpc_id, $cs_id)");
if (in_array($cs_id, $cs_ids_sued)):
$csv_text .= "Summe;;;;;;;0;0;0;0;0;0;" . $sumAbhol . ";" . $sumAust . ";" . $sumLief . ";0;0;0;0;" . $sumMont . ";\n";
return array("Service", $csv_text);
else:
$csv_textArr[1] .= ";;;;;;;" . $sum1_jbp_price_sum . "\n";
$csv_textArr[3] .= ";;;;;;;" . $sum3_jbp_price_sum . "\n";
return $csv_textArr;
endif;
}
function do_SAMScourier($jbpc_id)
{
global $db;
$csv_text_headline =
"RgNr;Datum;Kaufvertrag;OrderID;BelegNr;KartenNr;Warenwert;Preis\n";
$csv_text = $csv_text_headline;
$sql_query =
"SELECT tr.tr_commission_no, jb.jb_id, jb.jb_createtime, jb.jb_totalprice" .
" FROM job AS jb, tour AS tr, genericdatacontainer AS gdc" .
" WHERE jb.jb_id = gdc.gdc_obj_id AND gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'jb_express' AND gdc.gdc_context IN ($jbpc_id) " .
" AND jb.jb_id = tr.jb_id AND tr.tr_sort = 2 ORDER BY jb.jb_id";
//echo "\n" . $sql_query . "\n";
$jb_totalprice_sum = 0;
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)):
$jb_totalprice = bruttoSum($row["jb_totalprice"]);
$lieferwarenwert = $db->getOne("SELECT SUM(trat_price) FROM tourarticle WHERE jb_id = " . $row["jb_id"]);
$csv_text .= "101" . $jbpc_id . ";" . formDate($row["jb_createtime"]) . ";" . $row["jb_id"] . ";;" .
check_str($row["tr_commission_no"]) . ";;" . $lieferwarenwert . ";" . $jb_totalprice . "\n";
$jb_totalprice_sum += $jb_totalprice;
endwhile;
mysql_free_result($res);
$csv_text .= ";;;;;;;" . $jb_totalprice_sum . "\n";
myWriteLog("do_SAMScourier($jbpc_id)");
// return array("Lieferung", $csv_text, "Montage", $csv_text_headline);
return array("Servicekurier", $csv_text);
}
function do_BC($jbpc_id, $cs_id)
{
global $db, $exl_exporttime, $serviceLief, $serviceMont, $serviceNeuMont, $serviceKueMont, $serviceAbhol, $serviceAust, $cs_ids_nord, $cs_ids_sued;
if (in_array($cs_id, $cs_ids_sued))
$csv_text =
"Anlage zur Auftrags-Nr. 101$jbpc_id;vom " . formDate($exl_exporttime) . ";Kunden-;Auftrags-;SAMS-;Auftrags-;Erfüll-;Lieferung;Lieferung;Lieferung;Lieferung;EKS;Sofa-;Abholung;SAMS-;SAMS-;Austausch;Abholung;Rücknahme;Lager-;Montage;Annehmer\n" .
"Pos;KartenNr;name;Nr.;Nr.;datum;datum;bis WW 500,-;bis WW 1500,-;ab WW 1501,-;größer 3000kg;;montage;Austausch;Austausch;Lieferung;Palette;Palette;Matratze;geld; ;\n";
if (in_array($cs_id, $cs_ids_nord)):
$csv_textArr = array("Lieferung", "", "Montage", "");
$csv_textArr[1] = $csv_textArr[3] =
"RgNr;Datum;Kaufvertrag;OrderID;BelegNr;KartenNr;Warenwert;Preis\n";
endif;
$sumMont = 0;
$sumAbhol = 0;
$sumAust = 0;
$sumLief500 = 0;
$sumLief1500 = 0;
$sumLief1501 = 0;
$sumStock = 0;
$cnt = 1;
// auch auf 'jb_family_card' prüfen, falls BC-Nummer im falschen Feld eingetragen wurde
$sql_query =
"SELECT tr.tr_comp, tr.tr_commission_no, jb.jb_id, jb.jb_id_parent, gdc.gdc_content, jb.jb_createtime, jb.jb_ordertime, SUM(jbp.jbp_price) AS jbp_price_sum, jb.jb_service, usr.usr_name" .
" FROM job AS jb, tour AS tr, jobpayment AS jbp, genericdatacontainer AS gdc LEFT JOIN user AS usr ON jb.emp_id = usr.usr_id" .
" WHERE jb.jb_id = jbp.jb_id AND jbp.jbpc_id IN ($jbpc_id) AND gdc.gdc_obj_type = 'jb' AND (jb.jb_id = gdc.gdc_obj_id OR jb.jb_id_parent = gdc.gdc_obj_id) AND (gdc.gdc_gen_fieldname = 'jb_business_card' OR gdc.gdc_gen_fieldname = 'jb_family_card') " .
" AND jb.jb_id = tr.jb_id AND tr.tr_sort = 2 GROUP BY jbp.jb_id";
//echo "\n" . $sql_query . "\n";
$sum1_jbp_price_sum = 0;
$sum3_jbp_price_sum = 0;
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)):
$jbp_price_sum = bruttoSum($row["jbp_price_sum"]);
$stock_costs = $db->getOne("SELECT jbc_totalprice FROM jobcalculator WHERE jb_id = " . $row["jb_id"] . " AND srvt_name = '0003:par_01'");
if ($stock_costs == "")
$stock_costs = 0;
if ($stock_costs > 0):
$jbp_price_sum = bruttoSum(($row["jbp_price_sum"] - $stock_costs));
$stock_costs = bruttoSum($stock_costs);
$sumStock += $stock_costs;
endif;
$jb_service = mcConvertNum2Sel($row["jb_service"]);
$type_str = "0;0;0;0;0;0;$stock_costs;0";
if (in_array($serviceAbhol, $jb_service)):
$type_str = $jbp_price_sum . ";0;0;0;0;0;$stock_costs;0";
$sumAbhol += $jbp_price_sum;
elseif (in_array($serviceAust, $jb_service)):
$type_str = "0;" . $jbp_price_sum . ";0;0;0;0;$stock_costs;0";
$sumAust += $jbp_price_sum;
elseif (in_array($serviceMont, $jb_service)):
$type_str = "0;0;0;0;0;0;$stock_costs;" . $jbp_price_sum;
$sumMont += $jbp_price_sum;
endif;
$type_str1 = "0;0;0;0";
if (in_array($serviceLief, $jb_service)):
$lieferwarenwert = $db->getOne("SELECT SUM(trat_price) FROM tourarticle WHERE jb_id = " . $row["jb_id"]);
if($lieferwarenwert <= 500) {
$type_str1 = $jbp_price_sum . ";0;0";
$sumLief500 += $jbp_price_sum;
} elseif($lieferwarenwert <= 1500) {
$type_str1 = "0;" . $jbp_price_sum . ";0";
$sumLief1500 += $jbp_price_sum;
} else {
$type_str1 = "0;0;" . $jbp_price_sum;
$sumLief1501 += $jbp_price_sum;
}
$lieferwarengewicht = $db->getOne("SELECT SUM(trat_weight) FROM tourarticle WHERE jb_id = " . $row["jb_id"]);
if($lieferwarengewicht > 3000)
$type_str1 .= ";" . $jbp_price_sum;
else
$type_str1 .= ";0";
endif;
// $log_createtime = $db->getOne("SELECT log_createtime FROM phoenix_log.log WHERE (log.jb_id = '" . $row["jb_id"] . "' OR log.jb_id = '" . $row["jb_id_parent"] . "') AND logo_id = 1");
if (in_array($cs_id, $cs_ids_sued))
$csv_text .= $cnt++ . ";" . $row["gdc_content"] . ";" . str_replace(";", "", $row["tr_comp"]) . ";" . $row["jb_id"] . ";;" .
formDate($row["jb_createtime"]) . ";" . formDate($row["jb_ordertime"]) . ";" . $type_str1 . ";0;0;" . $type_str . ";" . $row["usr_name"] . "\n";
if (in_array($cs_id, $cs_ids_nord)):
$csv_text = "101" . $jbpc_id . ";" . formDate($row["jb_createtime"]) . ";" . $row["jb_id"] . ";;" .
check_str($row["tr_commission_no"]) . ";" . $row["gdc_content"] . ";" . $lieferwarenwert . ";" . bruttoSum($row["jbp_price_sum"]) . "\n";
if (!in_array($serviceMont, $jb_service)):
$csv_textArr[1] .= $csv_text;
$sum1_jbp_price_sum += bruttoSum($row["jbp_price_sum"]);
else:
$csv_textArr[3] .= $csv_text;
$sum3_jbp_price_sum += bruttoSum($row["jbp_price_sum"]);
endif;
endif;
endwhile;
mysql_free_result($res);
myWriteLog("do_BC($jbpc_id, $cs_id)");
if (in_array($cs_id, $cs_ids_sued)):
$csv_text .= "Summe;;;;;;;" . $sumLief500 . ";" . $sumLief1500 . ";" . $sumLief1501 . ";0;0;0;" . $sumAbhol . ";" . $sumAust . ";0;0;0;0;" . $sumStock . ";" . $sumMont . ";\n";
return array("BusinessCard", $csv_text);
else:
$csv_textArr[1] .= ";;;;;;;" . $sum1_jbp_price_sum . "\n";
$csv_textArr[3] .= ";;;;;;;" . $sum3_jbp_price_sum . "\n";
//print_r($csv_textArr);die();
return $csv_textArr;
endif;
}
function do_EKS($jbpc_id)
{
global $db;
$csv_text =
"RgNr;Datum;Kaufvertrag;OrderID;BelegNr;KartenNr;Warenwert;Preis\n";
$sql_query =
"SELECT tr.tr_commission_no, jb.jb_id, jb.jb_createtime, jbprc.jbprc_price" .
" FROM job AS jb, tour AS tr, jobprice AS jbprc" .
" WHERE jb.jb_id = jbprc.jb_id AND jbprc.jbprc_reference IN ($jbpc_id) " .
" AND jb.jb_id = tr.jb_id AND tr.tr_sort = 2 AND jbprc.mt_sort = 2 AND jbprc.jbprc_remark = 'Einkaufsservice' ORDER BY jb.jb_id";
//echo "\n" . $sql_query . "\n";
$jbprc_price_sum = 0;
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)):
$jbprc_price = bruttoSum($row["jbprc_price"]);
$lieferwarenwert = $db->getOne("SELECT SUM(trat_price) FROM tourarticle WHERE jb_id = " . $row["jb_id"]);
$csv_text .= "101" . $jbpc_id . ";" . formDate($row["jb_createtime"]) . ";" . $row["jb_id"] . ";;" .
check_str($row["tr_commission_no"]) . ";;" . $lieferwarenwert . ";" . $jbprc_price . "\n";
$jbprc_price_sum += $jbprc_price;
endwhile;
mysql_free_result($res);
$csv_text .= ";;;;;;;" . $jbprc_price_sum . "\n";
myWriteLog("do_EKS($jbpc_id)");
return array("Eks", $csv_text);
}
function do_diff($jbpc_id, $what, $jbpc_id2, $cs_id)
{
global $db, $jb_exporttime, $serviceLief, $serviceMont, $serviceNeuMont, $serviceKueMont, $serviceAbhol, $serviceAust, $paymentDiff;
$csv_text_diff = array("Lieferung", "", "Montage", "", "Zusatzmontage", "", "Kuechenmontage", "");
$csv_text_return = array("Lieferung", "", "Montage", "", "Zusatzmontage", "", "Kuechenmontage", "");
$csv_text_start = "Anlage zur Auftrags-Nr. 101$jbpc_id;vom " . formDate($jb_exporttime) . "\n";
$csv_text_diff[1] = $csv_text_diff[3] = $csv_text_diff[5] = $csv_text_diff[7] =
$csv_text_start . "Name;Kaufvertrag;Leistung;Auftragsdatum;Lieferdatum;Endverbraucherpreis;Gutschrift IKEA;Preis IKEA\n";
$csv_text_return[1] = $csv_text_return[3] = $csv_text_return[5] = $csv_text_return[7] =
$csv_text_start . "Name;Kaufvertrag;Leistung;Auftragsdatum;Lieferdatum;Preis IKEA;Rückvergütung\n";
if ($cs_id == 1 || $cs_id == 2):
$csv_text_diff[1] = $csv_text_diff[3] = $csv_text_diff[5] = $csv_text_diff[7] =
$csv_text_start . "Datum;Kaufvertrag;Service;OrderID;BelegNr;KartenNr;Warenwert;PreisIKEA;Vergütung\n";
$csv_text_return[1] = $csv_text_return[3] = $csv_text_return[5] = $csv_text_return[7] =
$csv_text_start . "Datum;Kaufvertrag;Service;OrderID;BelegNr;KartenNr;Warenwert;PreisIKEA;Vergütung\n";
endif;
$sql_query =
"SELECT tr.tr_comp, tr.tr_commission_no, jb.jb_id, jb.jb_createtime, jb.jb_ordertime, jb.jb_service, jbprc.mt_sort, jbprc.jbprc_price, jbprc.jbprc_remark" .
" FROM job AS jb, tour AS tr, jobprice AS jbprc" .
" WHERE jb.jb_id = jbprc.jb_id AND jbprc.jbprc_reference IN ($jbpc_id, $jbpc_id2)" .
" AND jb.jb_id = tr.jb_id AND tr.tr_sort = 2 AND jbprc.mt_sort IN (0, 1, 2, 3) AND jbprc.jbprc_remark != 'Einkaufsservice' ORDER BY jbprc.jb_id, jbprc_remark, mt_sort";
//echo $sql_query . "\n";
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
$mt_sort_vals = array();
$mt_sort_sums = array(1 => array(0,0,0,0,0), 3 => array(0,0,0,0,0), 5 => array(0,0,0,0,0), 7 => array(0,0,0,0,0));
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)):
$jb_service = mcConvertNum2Sel($row["jb_service"]);
$jbprc_price = bruttoSum($row["jbprc_price"]);
$is_addmont = $db->getOne("SELECT gdc_obj_id FROM genericdatacontainer WHERE gdc_content = " . $row["jb_id"] . " AND gdc_gen_fieldname = 'jb_id_addmont'") != "";
// "Auftragspauschale" kommt immer in die Lieferungstabelle
if (in_array($serviceLief, $jb_service) || in_array($serviceAbhol, $jb_service) || in_array($serviceAust, $jb_service) || $row["jbprc_remark"] == "Auftragspauschale"):
$csv_index = 1;
// "Montage" und "Installation" niemals in Lieferliste in Altona
if ($cs_id == 17093 && !(strpos($row["jbprc_remark"], "Montage") === false) || !(strpos($row["jbprc_remark"], "Installation") === false)):
$csv_index = 3;
if (in_array($serviceKueMont, $jb_service)):
$csv_index = 7;
endif;
endif;
elseif ($is_addmont && (in_array($serviceNeuMont, $jb_service) || in_array($serviceKueMont, $jb_service))):
$csv_index = 5;
elseif (in_array($serviceNeuMont, $jb_service)):
$csv_index = 3;
elseif (in_array($serviceKueMont, $jb_service)):
if (!(strpos($row["jbprc_remark"], "lfd. Meter Montage") === false))
$csv_index = 7;
else
$csv_index = 3;
endif;
if ($db->getOne("SELECT gdc_content FROM genericdatacontainer WHERE gdc_obj_type = 'jb' AND gdc_obj_id = $jb_id AND gdc_gen_fieldname = 'jb_service_job'") == "1"):
$service_job = "Service";
$order_id = check_str($row["tr_commission_no"]);
$beleg_nr = "";
else:
$service_job = "";
$order_id = "";
$beleg_nr = check_str($row["tr_commission_no"]);
endif;
$lieferwarenwert = $db->getOne("SELECT SUM(trat_price) FROM tourarticle WHERE jb_id = " . $row["jb_id"]);
$karten_nr = $db->getOne("SELECT gdc_content FROM genericdatacontainer WHERE gdc_obj_type = 'jb' AND gdc_obj_id = " . $row["jb_id"] . " AND gdc_gen_fieldname = 'jb_business_card'");
if ($row["mt_sort"] == 2 || $row["mt_sort"] == 3):
if ($row["mt_sort"] == 2):
//print_r ($mt_sort_vals) . "\n";
if (($mt_sort_vals[1] > 0 || $jbprc_price > 0) && $mt_sort_vals[1] != $jbprc_price):
if ($cs_id != 1 && $cs_id != 2):
$csv_text_diff[$csv_index] .= str_replace(";", "", $row["tr_comp"]) . ";" . $row["jb_id"] . ";" . $row["jbprc_remark"] . "" . ";" . formDate($row["jb_createtime"]) . ";" .
formDate($row["jb_ordertime"]) . ";" . $mt_sort_vals[0] . ";" . $mt_sort_vals[1] . ";" . $jbprc_price . "\n";
else:
$jbprc_price = $mt_sort_vals[1] - $jbprc_price;
$csv_text_diff[$csv_index] .= formDate($row["jb_createtime"]) . ";" . $row["jb_id"] . ";$service_job;$order_id;" .
$beleg_nr . ";$karten_nr;" . $lieferwarenwert . ";" . $mt_sort_vals[1] . ";" . $jbprc_price . "\n";
endif;
$mt_sort_sums[$csv_index][0] += $mt_sort_vals[0];
$mt_sort_sums[$csv_index][1] += $mt_sort_vals[1];
$mt_sort_sums[$csv_index][2] += $jbprc_price;
endif;
$mt_sort_vals[2] = bruttoSum($row["jbprc_price"]);
elseif ($row["mt_sort"] == 3 && $jbprc_price > 0):
if ($cs_id != 1 && $cs_id != 2):
$csv_text_return[$csv_index] .= str_replace(";", "", $row["tr_comp"]) . ";" . $row["jb_id"] . ";" . $row["jbprc_remark"] . "" . ";" . formDate($row["jb_createtime"]) . ";" .
formDate($row["jb_ordertime"]) . ";" . $mt_sort_vals[2] . ";" . $jbprc_price . "\n";
else:
//echo formDate($row["jb_createtime"]); echo ";" . $row["jb_id"]; echo ";$service_job;$order_id;"; echo $beleg_nr; echo ";$karten_nr;"; echo $lieferwarenwert; echo ";" . $mt_sort_vals[2]; echo ";" . $jbprc_price . "\n";
$csv_text_return[$csv_index] .= formDate($row["jb_createtime"]) . ";" . $row["jb_id"] . ";$service_job;$order_id;" .
$beleg_nr . ";$karten_nr;" . $lieferwarenwert . ";" . $mt_sort_vals[2] . ";" . $jbprc_price . "\n";
endif;
$mt_sort_sums[$csv_index][3] += $jbprc_price;
$mt_sort_sums[$csv_index][4] += $mt_sort_vals[2];
endif;
else:
$mt_sort_vals[$row["mt_sort"]] = $jbprc_price;
endif;
endwhile;
mysql_free_result($res);
foreach (array(1, 3, 5, 7) as $csv_index) {
if ($$mt_sort_sums[$csv_index][1] == $mt_sort_sums[$csv_index][2]):
$csv_text_diff[$csv_index] = "";
else:
if ($cs_id != 1 && $cs_id != 2)
$csv_text_diff[$csv_index] .= ";;;;;" . $mt_sort_sums[$csv_index][0] . ";" . $mt_sort_sums[$csv_index][1] . ";" . $mt_sort_sums[$csv_index][2] . "\n";
else
$csv_text_diff[$csv_index] .= ";;;;;;;" . $mt_sort_sums[$csv_index][1] . ";" . $mt_sort_sums[$csv_index][2] . "\n";
endif;
if ($mt_sort_sums[$csv_index][3] == 0):
$csv_text_return[$csv_index] = "";
else:
if ($cs_id != 1 && $cs_id != 2)
$csv_text_return[$csv_index] .= ";;;;;" . $mt_sort_sums[$csv_index][4] . ";" . $mt_sort_sums[$csv_index][3] . "\n";
else
$csv_text_return[$csv_index] .= ";;;;;;;" . $mt_sort_sums[$csv_index][4] . ";" . $mt_sort_sums[$csv_index][3] . "\n";
endif;
}
myWriteLog("do_diff($jbpc_id $what $jbpc_id2)");
if ($what == "return"):
//print_r($csv_text_return);
return $csv_text_return;
endif;
//print_r($csv_text_diff);
return $csv_text_diff;
}
function formDate($sqlDate)
{
if (trim($sqlDate) == "")
return "";
return substr($sqlDate, 8, 2) . "." . substr($sqlDate, 5, 2) . "." . substr($sqlDate, 0, 4);
}
//function formSum($sum)
//{
// return round($sum, 2);
//// return str_replace(".", ",", round($sum, 2));
//}
function bruttoSum($sum)
{
return round($sum * 1.19, 2);
}
function check_str($aStr)
{
return str_replace(";", "", $aStr);
}
function myWriteLog($log_text) {
global $log_file_name;
$fileHandle = @fopen($log_file_name . date("Ym") . ".log", 'a');
@fwrite($fileHandle, "[" . date("Y-m-d H:i:s") . "] " . $log_text . "\n");
@fclose($fileHandle);
return;
}

494
html/export/pre_export.php Normal file
View File

@@ -0,0 +1,494 @@
<?php
/*=======================================================================
*
* pre_export.php
*
* Autor: Carsten Annacker
*
* Aufzurufen jeden Tag kurz nach Mitternacht als cron
*
* Schnelsen:
* - Wöchentliche Rechnung über Sams (getrennt nach Lieferung und Montage)
* - Wöchentliche Rechnung über Kurieraufträge
* - Wöchentliche Rechnung über Businessaufträge
* - Monatlich Gutschrift der Differenz Montagegrundpauschale s. Anlage (normalerweise monatlich)
* - Monatlich Gutschrift Rückvergütung zu den Lieferungen und Montagen s. Anlage
*
* Moorfleet:
* - Wöchentliche Rechnung über Businessaufträge
* - Wöchentliche Rechnung über EKS
* - Monatlich Gutschrift Rückvergütung zu den Montagen Analog zu Schnelsen
*
* Altona:
*
* - Wöchentliche Rechnung über Businessaufträge
* - Wöchentliche Rechnung über EKS
* - Wöchentliche Rechnung Preisdifferenzen (LP zur Auftragspauschale+Gewicht)
* - Wöchentliche Gutschrift Preisdifferenzen Montagegrundpauschale
* - Wöchentliche Gutschriften zu den Rückvergütungen differenziert nach Küchenmontage, Möbelmontage, Sofamontage.
*
=======================================================================*/
$test = false;
if ($argv[1] != "acapella7890")
die();
error_reporting(E_ALL ^ (E_DEPRECATED | E_NOTICE));
if ($test)
include_once ("../include/inc_mtf_func.inc.test.php");
else
include_once ("../include/inc_mtf_func.inc.php");
$log_file_name = "../log/prepost_export_" . date("Ym") . ".log";
$temp_csv_folder = "../temp/edifact/";
//$paymentBC = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'payment_type' AND mt_objtype = 'grp' AND mt_objid = '11' AND mt_value = 'Businesscard'");
//$paymentSAMS = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'payment_type' AND mt_objtype = 'grp' AND mt_objid = '11' AND mt_value = 'Serviceaufträge'");
//$paymentCash = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'payment_type' AND mt_objtype = 'grp' AND mt_objid = '11' AND mt_value = 'Bar'");
//$paymentECPin = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'payment_type' AND mt_objtype = 'grp' AND mt_objid = '11' AND mt_value = 'EC-Pin'");
//$paymentECLast = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'payment_type' AND mt_objtype = 'grp' AND mt_objid = '11' AND mt_value = 'EC-Lastschrift'");
//$paymentFamily = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'payment_type' AND mt_objtype = 'grp' AND mt_objid = '11' AND mt_value = 'Familycard'");
$serviceLief = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'LI'");
$serviceMont = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'MO'");
$serviceNeuMont = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'NM'");
$serviceKueMont = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'KU'");
$serviceAbhol = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'AB'");
$serviceAust = $db->getOne("SELECT mt_sort FROM metatype WHERE mt_type = 'service' AND mt_mapped_value = 'AT'");
$from_date_week_timestamp = mktime(0, 0, 0, date("m"), date("d") - 7 - (date("w") - 1), date("Y"));
$to___date_week_timestamp = mktime(0, 0, 0, date("m"), date("d") - 2 - (date("w") - 1), date("Y"));
$from_date_week_txt = date("d.m.Y", $from_date_week_timestamp);
$from_date_week_sql = date("Y-m-d 00:00:00", $from_date_week_timestamp);
$to___date_week_txt = date("d.m.Y", $to___date_week_timestamp);
$to___date_week_sql = date("Y-m-d 23:59:59", $to___date_week_timestamp);
$from_date_month_timestamp = mktime(0, 0, 0, date("m") - 1, 1, date("Y"));
$to___date_month_timestamp = mktime(0, 0, 0, date("m"), 0, date("Y"));
$from_date_month_txt = date("d.m.Y", $from_date_month_timestamp);
$from_date_month_sql = date("Y-m-d 00:00:00", $from_date_month_timestamp);
$to___date_month_txt = date("d.m.Y", $to___date_month_timestamp);
$to___date_month_sql = date("Y-m-d 23:59:59", $to___date_month_timestamp);
//$sql_query = "SELECT jb_id FROM job WHERE jb_createtime >= '$from_date_week_sql' ORDER BY jb_createtime ASC";
//$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
//$row = mysql_fetch_array($res);
//$jb_id_from_week = $row['jb_id'];
//mysql_free_result($res);
//$sql_query = "SELECT jb_id FROM job WHERE jb_createtime >= '$from_date_month_sql' ORDER BY jb_createtime ASC";
//$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
//$row = mysql_fetch_array($res);
//$jb_id_from_month = $row['jb_id'];
//mysql_free_result($res);
//$sql_query = "SELECT jb_id FROM job WHERE jb_createtime <= '$to___date_week_sql' ORDER BY jb_createtime DESC";
//$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
//$row = mysql_fetch_array($res);
//$jb_id___to_week = $row['jb_id'];
//mysql_free_result($res);
//$sql_query = "SELECT jb_id FROM job WHERE jb_createtime <= '$to___date_month_sql' ORDER BY jb_createtime DESC";
//$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
//$row = mysql_fetch_array($res);
//$jb_id___to_month = $row['jb_id'];
//mysql_free_result($res);
$jb_invtextArr = array();
//$jb_id_from = 0;
//$jb_id_to = 0;
$from_date_sql = "";
$to___date_sql = "";
// pre_export für Servicekurier (Schnelsen), EKS (Moorfleet), Preisdifferenzen und Rückvergütungen (Altona)
myWriteLog("pre_export.php: date(\"d\") = " . date("d") . ", date(\"D\") = " . date("D"));
$jb_ids_auftragspauschale = array();
// Monatliche Rechnungen
if (date("d") == "01" || $argv[2] == "test"):
init_jb_invtextArr("m");
//print_r($jb_invtextArr);
//echo "\n";
//echo $from_date_sql . "\n";
//echo $to___date_sql . "\n";
//die();
do_diff(1); // Schnelsen
do_diff(2); // Moorfleet
endif;
// Wöchentliche Rechnungen
if (date("D") == "Mon" || $argv[2] == "test"):
init_jb_invtextArr("w");
//print_r($jb_invtextArr);
//echo "\n";
//echo $from_date_sql . "\n";
//echo $to___date_sql . "\n";
//die();
// do_SAMS(1); // Schnelsen
do_SAMScourier(1);
// do_BC(1);
// do_BC(2); // Moorfleet
do_EKS(2);
// do_BC(17051); // Altona
do_EKS(17051);
do_diff(17051); // Altona
endif;
if (date("d") == "01" || date("D") == "Mon" || $argv[2] == "test"):
$cmd = "php ../export/cron_export.php acapella7890 today >> " . $log_file_name . " 2>/dev/null";
myWriteLog($cmd);
$ausgabe = exec($cmd);
endif;
if (date("d") == "01" || $argv[2] == "test") {
myWriteLog("Angabe im Feld 'Anzahl' für die Verteilung der Kostenpauschale: " .
$db->getOne("SELECT COUNT(*) FROM jobprice, job WHERE jobprice.jb_id = job.jb_id AND jbprc_remark = 'Auftragspauschale' and jbprc_reference != 0 AND mt_sort = 2 AND jb_createtime >= '$from_date_month_sql' AND jb_createtime <= '$to___date_month_sql'")
);
$anzahl = $db->getOne("SELECT COUNT(*) FROM jobprice, job WHERE jobprice.jb_id = job.jb_id AND jbprc_remark = 'Auftragspauschale' and jbprc_reference != 0 AND mt_sort = 2 AND jb_createtime >= '$from_date_month_sql' AND jb_createtime <= '$to___date_month_sql'");
$csv_contents =
"Kostenpauschale IKEA Altona vom " . formDate($from_date_sql) . " bis " . formDate($to___date_sql) . ";;;;;" .
";;;;;" .
";Anzahl;Einzelpreis;Gesamt;Gesamt brutto;" .
"von KoSt 8050 (800020 AG) bitte umbuchen auf;;Netto;Netto;;" .
";;;;;" .
"KoSt 80501 Kostenart 803300 (AG);" . $anzahl . ";23,50;" . str_replace(".", ",", ($anzahl * 23.50)) . ";" . str_replace(".", ",", round(($anzahl * 23.50) * 1.19, 2)) . ";Transportschalterbesetzung" .
";;;;;" .
"KoSt 80502 Kostenart 803300 (AG);" . $anzahl . ";14,75;" . str_replace(".", ",", ($anzahl * 14.75)) . ";" . str_replace(".", ",", round(($anzahl * 14.75) * 1.19, 2)) . ";Transportraumbesetzung 2. OG/UG" .
";;;;;" .
"KoSt 80503 Kostenart 803300 (AG);" . $anzahl . ";3,80;" . str_replace(".", ",", ($anzahl * 3.80)) . ";" . str_replace(".", ",", round(($anzahl * 3.80) * 1.19, 2)) . ";Umlage Invest+Vorlauf" .
";;;;;" .
"Summe;;;" . str_replace(".", ",", ($anzahl * 23.50 + $anzahl * 24.75 + $anzahl * 3.80)) . ";" . str_replace(".", ",", (round(($anzahl * 23.50) * 1.19, 2) + round(($anzahl * 14.75) * 1.19, 2) + round(($anzahl * 3.80) * 1.19, 2))) . ";";
$fileHandle = @fopen($temp_csv_folder . "Kostenpauschale", 'w');
@fwrite($fileHandle, $csv_contents);
@fclose($fileHandle);
}
function init_jb_invtextArr($mode) {
global $jb_invtextArr, $from_date_week_txt, $from_date_month_txt, $to___date_week_txt, $to___date_month_txt,
$from_date_sql, $to___date_sql, $from_date_week_sql, $to___date_week_sql, $from_date_month_sql, $to___date_month_sql;
$from_date_txt = $from_date_week_txt;
$to___date_txt = $to___date_week_txt;
$from_date_sql = $from_date_week_sql;
$to___date_sql = $to___date_week_sql;
if ($mode == "m"):
$from_date_txt = $from_date_month_txt;
$to___date_txt = $to___date_month_txt;
$from_date_sql = $from_date_month_sql;
$to___date_sql = $to___date_month_sql;
endif;
$jb_invtextArr = array(
"return_kueche" =>
"Rückvergütung für die durchgeführten Küchenmontagen \n" .
"vom $from_date_txt bis zum $to___date_txt gemäß beiliegender Anlage \n",
"return_moebel" =>
"Rückvergütung für die durchgeführten Möbelmontagen \n" .
"vom $from_date_txt bis zum $to___date_txt gemäß beiliegender Anlage \n",
"diff_moebel" =>
"Wir schreiben Ihnen die Preisdifferenz für Möbelmontagen im Zeitraum \n" .
"vom $from_date_txt bis zum $to___date_txt gemäß beiliegender Anlage gut \n",
"diff_lief" =>
"Wir berechnen Ihnen die Preisdifferenz für Lieferaufträge im Zeitraum \n" .
"vom $from_date_txt bis zum $to___date_txt gemäß beiliegender Anlage \n",
"return_lief" =>
"Rückvergütung für die durchgeführten Lieferungen \n" .
"vom $from_date_txt bis zum $to___date_txt gemäß beiliegender Anlage \n",
"EKS" =>
"Wir berechnen Ihnen für die Einkaufsservices \n" .
"bis einschließlich $to___date_txt gemäß beiliegender Anlage \n",
"SAMScourier" =>
"Wir berechnen Ihnen für die SAMS-Lieferungen per Kurier \n" .
"bis einschließlich $to___date_txt gemäß beiliegender Anlage \n"
);
}
function do_SAMScourier($csc_id_related)
{
global $db, $jb_invtextArr, $from_date_sql, $to___date_sql;
$do_SAMScourier = false;
$sql_query =
"SELECT jb_id, jb_totalprice" .
" FROM job AS jb, genericdatacontainer AS gdc1, genericdatacontainer AS gdc2 " .
" WHERE gdc1.gdc_obj_id = gdc2.gdc_obj_id AND gdc2.gdc_gen_fieldname = 'jb_service_job' AND" .
" gdc1.gdc_obj_type = 'jb' AND jb.jb_id = gdc1.gdc_obj_id AND (jb_storno IS NULL OR jb_storno != 2)" .
" AND gdc1.gdc_gen_fieldname = 'jb_express' AND gdc1.gdc_context = '' " .
" AND jb.csc_id_related = $csc_id_related AND jb_createtime >= '$from_date_sql' AND jb_createtime <= '$to___date_sql' AND jb_totalprice > 0.0001 ORDER BY jb.jb_id";
// " AND jb.csc_id_related = $csc_id_related AND jb.jb_id >= 290922 AND jb.jb_id <= 292960 ORDER BY jb.jb_id";
//echo "\n" . $sql_query . "\n";
$jb_ids = array();
$sum = 0;
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)):
$jb_ids[] = $row["jb_id"];
$sum += $row["jb_totalprice"];
endwhile;
mysql_free_result($res);
myWriteLog("do_SAMScourier($csc_id_related): \$sum = " . $sum . ", count(\$jb_ids) = " . count($jb_ids));
if (count($jb_ids) > 0)
mk_reference_job($sum, implode(",", $jb_ids), $csc_id_related, $jb_invtextArr["SAMScourier"], "express");
}
function do_EKS($csc_id_related)
{
global $db, $jb_invtextArr, $from_date_sql, $to___date_sql;
$sql_query =
"SELECT jbprc_price, jobprice.jb_id FROM jobprice, job" .
" WHERE jobprice.jb_id = job.jb_id AND csc_id_related = $csc_id_related AND mt_sort = 2 AND jbprc_remark = 'Einkaufsservice' AND jbprc_reference = 0" .
// " AND job.jb_id >= 290922 AND job.jb_id <= $jb_id_to ORDER BY job.jb_id";
" AND jb_createtime >= '$from_date_sql' AND jb_createtime <= '$to___date_sql' AND jb_storno IS NULL ORDER BY job.jb_id";
$jb_ids = array();
$sum = 0;
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)):
$jb_ids[] = $row["jb_id"];
$sum += $row["jbprc_price"];
endwhile;
mysql_free_result($res);
myWriteLog("do_EKS($csc_id_related): \$sum = " . $sum . ", count(\$jb_ids) = " . count($jb_ids));
if (count($jb_ids) > 0)
mk_reference_job($sum, implode(",", $jb_ids), $csc_id_related, $jb_invtextArr["EKS"], "eks");
}
function do_diff($csc_id_related)
{
global $db, $serviceLief, $serviceMont, $serviceNeuMont, $serviceKueMont, $serviceAbhol, $serviceAust, $jbpc_id_sav, $jb_ids_auftragspauschale, $jb_invtextArr, $from_date_sql, $to___date_sql;
$sql_query =
"SELECT jbprc_price, jobprice.jb_id, mt_sort, jb_service, jbprc_remark FROM jobprice, job" .
" WHERE jobprice.jb_id = job.jb_id AND jb_storno IS NULL AND jb_offer = 0 AND csc_id_related = $csc_id_related AND mt_sort IN (1, 2, 3) AND jbprc_remark != 'Einkaufsservice' AND jbprc_reference = 0 AND jb_createtime >= '$from_date_sql' AND jb_createtime <= '$to___date_sql'";
// " WHERE jobprice.jb_id = job.jb_id AND csc_id_related = $csc_id_related AND mt_sort IN (1, 2, 3) AND jbprc_remark != 'Einkaufsservice' AND jbprc_reference = 0 AND jobprice.jb_id >= 290922 AND jobprice.jb_id <= 292960";
$mt_sort_sums = array(array(0,0,0), array(0,0,0), array(0,0,0), array(0,0,0));
$jb_ids = array(array(array(), array(), array()), array(array(), array(), array()), array(array(), array(), array()), array(array(), array(), array()));
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)):
$jb_service = mcConvertNum2Sel($row["jb_service"]);
$is_addmont = $db->getOne("SELECT gdc_obj_id FROM genericdatacontainer WHERE gdc_content = " . $row["jb_id"] . " AND gdc_gen_fieldname = 'jb_id_addmont'") != "";
// "Auftragspauschale" kommt immer in die Lieferungstabelle
if (in_array($serviceLief, $jb_service) || in_array($serviceAbhol, $jb_service) || in_array($serviceAust, $jb_service) || $row["jbprc_remark"] == "Auftragspauschale"):
$sum_index = 0;
// Rückvergütungen für "(Sofa-)Montage" und "Installation" in die Montageliste, wenn Altona
if ($row["mt_sort"] == 3 && $csc_id_related == 17051 && (!(strpos($row["jbprc_remark"], "Montage") === false) || !(strpos($row["jbprc_remark"], "Installation") === false))):
$sum_index = 2;
if (in_array($serviceKueMont, $jb_service)):
$sum_index = 3;
endif;
endif;
elseif ($is_addmont && (in_array($serviceNeuMont, $jb_service) || in_array($serviceKueMont, $jb_service))):
$sum_index = 1;
elseif (in_array($serviceNeuMont, $jb_service)):
$sum_index = 2;
elseif (in_array($serviceKueMont, $jb_service)):
if (!(strpos($row["jbprc_remark"], "lfd. Meter Montage") === false))
$sum_index = 3;
else
$sum_index = 2;
endif;
$mt_sort_sums[$sum_index][$row["mt_sort"] - 1] += $row["jbprc_price"];
if ($row["jbprc_remark"] == "Auftragspauschale")
$jb_ids_auftragspauschale[] = $row["jb_id"];
else
$jb_ids[$sum_index][$row["mt_sort"] - 1][] = $row["jb_id"];
endwhile;
mysql_free_result($res);
for ($i = 0; $i <= 3; $i++):
myWriteLog("do_diff($csc_id_related): \$i=$i, \$sum_diff = " . ($mt_sort_sums[$i][0] - $mt_sort_sums[$i][1]) .
", \$sum_credit = " . $mt_sort_sums[$i][0] . ", \$sum_debit = " . $mt_sort_sums[$i][1] . ", \$sum_return = " . $mt_sort_sums[$i][2] .
", count(array_merge(\$jb_ids[$i][1], \$jb_ids[$i][2])) = " . count(array_merge($jb_ids[$i][1], $jb_ids[$i][2])) .
", count(\$jb_ids[$i][2] = " . count($jb_ids[$i][2]));
$auftragspauschale = false;
if ($i == 0):
$auftragspauschale = true;
$jb_invtext_diff = $jb_invtextArr["diff_lief"];
$mode_diff = "diff_lief";
if ($csc_id_related == 1):
$jb_invtext_return = $jb_invtextArr["return_lief"];
$mode_return = "return_lief";
endif;
elseif ($i == 2):
$jb_invtext_diff = $jb_invtextArr["diff_moebel"];
$mode_diff = "diff_moebel";
$jb_invtext_return = $jb_invtextArr["return_moebel"];
$mode_return = "return_moebel";
elseif ($i == 3):
$jb_invtext_return = $jb_invtextArr["return_kueche"];
$mode_return = "return_kueche";
endif;
if (count(array_merge($jb_ids[$i][1], $jb_ids[$i][2])) > 0 && ($csc_id_related == 17051 || ($mode_diff == "diff_moebel" && $csc_id_related == 1)))
mk_reference_job($mt_sort_sums[$i][1] - $mt_sort_sums[$i][0], implode(",", array_unique(array_merge($jb_ids[$i][0], $jb_ids[$i][1]))), $csc_id_related, $jb_invtext_diff, $mode_diff, $auftragspauschale);
else
$jbpc_id_sav = 99999999;
if (count($jb_ids[$i][2]) > 0 && ($csc_id_related == 17051 || $csc_id_related == 1 || ($mode_return == "return_moebel" && $csc_id_related == 2)))
mk_reference_job(0 - $mt_sort_sums[$i][2], implode(",", array_unique($jb_ids[$i][2])), $csc_id_related, $jb_invtext_return, $mode_return);
endfor;
}
function mk_reference_job($sum, $jb_ids, $csc_id_related, $jb_invtext, $mode = '', $auftragspauschale = false)
{
global $db, $log_file_name, $jbpc_id_sav, $jb_ids_auftragspauschale, $to___date_sql;
if ($sum == 0)
return;
$sql_query = "SHOW TABLE STATUS LIKE 'jobpaymentcollection'";
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
$row = mysql_fetch_array($res);
$jbpc_id = $row['Auto_increment'];
mysql_free_result($res);
$sql_query = "ALTER TABLE jobpaymentcollection AUTO_INCREMENT=" . ($jbpc_id + 1);
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
//cr_sid?
//take_time?
//"jb_cr_price", $jb_cr_price, "jb_cr_subprice", $jb_cr_price
// Rechnungstext?
$sql_query = "INSERT INTO job (hq_id, vht_id, vht_id_real, csc_id_payer, jb_payment, jb_ordertime, cr_id, cr_sid, cr_id_order, jb_invtext, jb_status, jb_type, jb_finishtime, jb_fixprice, jb_totalprice, jb_subtotalprice, jb_createtime)" .
" VALUES (1020, 2, 2, " . ($csc_id_related == 17051 ? 32862 : $csc_id_related) . ", 4, '" . $to___date_sql . "', 148, 'HH666', 148, '$jb_invtext', 2, 4, '" . $to___date_sql . "', $sum, $sum, $sum, NOW())";
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
$res = mysql_query("SELECT LAST_INSERT_ID()");
$row = mysql_fetch_array($res);
$jb_id = $row[0];
mysql_free_result($res);
$sql_query = "INSERT INTO genericdatacontainer (gdc_obj_type, gdc_obj_id, gdc_gen_fieldname, gdc_content, gdc_context)" .
" VALUES ('jb', $jb_id, 'collection_number', $jbpc_id, '')";
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
$sql_query = "INSERT INTO tour (jb_id, ad_id, tr_sort, tr_comp, tr_hsno, csc_id, tr_status, tr_ware_from_to, tr_finishtime)" .
" VALUES($jb_id, 443082, 1, 'IKEA', '10', " . ($csc_id_related == 17051 ? 32862 : $csc_id_related) . ", 0, 0, '0000-00-00 00:00:00')";
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
$sql_query = "INSERT INTO tourservice (jb_id, tr_sort, srv_id, trs_srv_name, srvt_id, trs_srvt_name, trs_price, trs_discount, csc_id)" .
" VALUES ($jb_id, 0, 0, 'Fixpreis', 0, '', $sum, 0, " . ($csc_id_related == 17051 ? 32862 : $csc_id_related) . ")";
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
if ($mode == "express"):
$jb_idsArr = array_filter(explode(",", $jb_ids));
foreach ($jb_idsArr as $jb_id_tmp){
$sql_query =
"INSERT INTO jobpayment (jb_id, tr_sort, csc_id, jbp_mode, jbp_price, jbp_bookingtime, jbp_counter, jbpc_id) VALUES " .
"($jb_id_tmp, 2, $csc_id_related, 0, 0.0001, NOW(), 2, '$jbpc_id')";
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
}
$sql_query =
"UPDATE genericdatacontainer SET gdc_context = '$jbpc_id'" .
" WHERE gdc_obj_type = 'jb' AND gdc_obj_id IN ($jb_ids) AND gdc_gen_fieldname = 'jb_express' AND gdc_context = '' ";
elseif ($mode == "eks"):
$sql_query =
"SELECT gdc_content FROM genericdatacontainer, job" .
" WHERE job.jb_id = genericdatacontainer.gdc_obj_id AND genericdatacontainer.gdc_gen_fieldname = 'jb_id_eks' AND job.jb_id IN ($jb_ids)";
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)):
$sql_query =
"INSERT INTO jobpayment (jb_id, tr_sort, csc_id, jbp_mode, jbp_price, jbp_bookingtime, jbp_counter, jbpc_id) VALUES " .
"(" . $row['gdc_content'] . ", 2, $csc_id_related, 0, 0.0001, NOW(), 2, '$jbpc_id')";
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
endwhile;
mysql_free_result($res);
$sql_query =
"UPDATE jobprice SET jbprc_reference = $jbpc_id" .
" WHERE jb_id IN ($jb_ids) AND mt_sort = 2 AND jbprc_remark = 'Einkaufsservice'";
elseif ($mode == "diff_lief" || $mode == "diff_moebel"):
$where_clause = "";
if ($mode == "diff_moebel")
$where_clause = "AND jbprc_remark != 'lfd. Meter Montage'";
$sql_query =
"UPDATE jobprice SET jbprc_reference = $jbpc_id" .
" WHERE jb_id IN ($jb_ids) AND mt_sort IN (0,1,2,3) AND jbprc_remark != 'Einkaufsservice' AND jbprc_remark != 'Auftragspauschale' $where_clause";
$jbpc_id_sav = $jbpc_id;
$jbpc_id2 = 99999999;
elseif ($mode == "return_moebel" || $mode == "return_kueche" || $mode == "return_lief"):
$where_clause = "";
if ($mode == "return_moebel")
$where_clause = "AND jbprc_remark != 'lfd. Meter Montage'";
if ($mode == "return_kueche")
$where_clause = "AND jbprc_remark = 'lfd. Meter Montage'";
$sql_query =
"UPDATE jobprice SET jbprc_reference = $jbpc_id" .
" WHERE jb_id IN ($jb_ids) AND mt_sort IN (2,3) AND jbprc_remark != 'Einkaufsservice' AND jbprc_remark != 'Auftragspauschale' $where_clause";
$jbpc_id2 = $jbpc_id_sav;
if ($jbpc_id2 == "")
$jbpc_id2 = 99999999;
endif;
//echo $sql_query . "\n";
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
if ($auftragspauschale && count($jb_ids_auftragspauschale) > 0):
$sql_query =
"SELECT DISTINCT (jb_id) FROM genericdatacontainer, tourarticle" .
" WHERE gdc_obj_type = 'trat' AND gdc_gen_fieldname = 'packet' AND gdc_obj_id = trat_id AND jb_id IN (" . implode(",", $jb_ids_auftragspauschale) . ")";
$res = mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
while ($row = mysql_fetch_array($res, MYSQL_ASSOC)):
$sql_query =
"INSERT INTO jobpayment (jb_id, tr_sort, csc_id, jbp_mode, jbp_price, jbp_bookingtime, jbp_counter, jbpc_id) VALUES " .
"(" . $row['jb_id'] . ", 2, $csc_id_related, 0, 0.0001, NOW(), 2, '$jbpc_id')";
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
// jb_totalprice für Statistiken reparieren
$sql_query =
"UPDATE job, jobprice SET jb_totalprice = jbprc_price WHERE jobprice.jb_id = job.jb_id AND mt_sort = 6 AND jbprc_remark = 'Gesamt' AND job.jb_id = " . $row['jb_id'];
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
endwhile;
mysql_free_result($res);
$sql_query =
"UPDATE jobprice SET jbprc_reference = $jbpc_id" .
" WHERE jb_id IN (" . implode(",", $jb_ids_auftragspauschale) . ") AND mt_sort IN (0,1,2,3) AND jbprc_remark = 'Auftragspauschale'";
mysql_query($sql_query) or die ($sql_query . ": " . mysql_error());
$jb_ids_auftragspauschale = array();
endif;
myWriteLog("mk_reference_job(): \$jbpc_id = " . $jbpc_id . ", \$jb_id = " . $jb_id . ", \$csc_id_related = " . $csc_id_related .
", \$sum = $sum, \$jb_invtext = $jb_invtext, \$mode = $mode, \$auftragspauschale = $auftragspauschale");
$cmd = "php ../export/post_export.php $mode $jbpc_id $jbpc_id2 >> " . $log_file_name . " 2>&1";
myWriteLog($cmd);
$ausgabe = exec($cmd);
// $f_fileName = date("YmdHi") . ".101";
// if ($sum >= 0):
// $f_exp_category = "5";
// $f_fileName .= ".abr";
// endif;
// if ($sum < 0):
// $f_exp_category = "6";
// $f_fileName .= ".gut";
// endif;
// $f_parname = "RETRANS Abrechnungen";
// $f_parname_export = "RETRANS Abrechnungen";
// $specialJbPayment = "4";
// myWriteLog("mk_reference_job(): " . "\$f_fileName = " . $f_fileName . ", \$f_exp_category = " . $f_exp_category . ", \$f_parname = " . $f_parname . ", \$f_parname_export = " . $f_parname_export . ", \$specialJbPayment = " . $specialJbPayment . ", \$jbpc_id = " . $jbpc_id);
// echo $f_fileName . "\n";
// echo $f_exp_category . "\n";
// echo $f_parname . "\n";
// echo $f_parname_export . "\n";
// echo $specialJbPayment . "\n";
// echo $jbpc_id . "\n";
}
function formDate($sqlDate)
{
if (trim($sqlDate) == "")
return "";
return substr($sqlDate, 8, 2) . "." . substr($sqlDate, 5, 2) . "." . substr($sqlDate, 0, 4);
}
function formSum($sum)
{
return str_replace(".", ",", $sum);
}
function myWriteLog($log_text) {
global $log_file_name;
$fileHandle = @fopen($log_file_name, 'a');
@fwrite($fileHandle, "[" . date("Y-m-d H:i:s") . "] " . $log_text . "\n");
@fclose($fileHandle);
return;
}