416 lines
22 KiB
PHP
416 lines
22 KiB
PHP
<?php
|
|
/*=======================================================================
|
|
*
|
|
* statistic_special_GFL.php
|
|
*
|
|
* Autor: Marc Vollmann
|
|
*
|
|
=======================================================================*/
|
|
|
|
|
|
include_once ("../include/mcglobal.inc.php");
|
|
include_once ("../include/inc_category_dbfields.inc.php");
|
|
include_once ("../include/inc_dbfields2array.inc.php");
|
|
include_once ("../include/inc_group.inc.php");
|
|
include_once ("../statistic/statistic_sql.inc.php");
|
|
include_once ("../include/email/htmlMimeMail.php");
|
|
|
|
|
|
$autoMode = true;
|
|
$hasAccess = false;
|
|
if (!isset($argv[1]) || $argv[1] == "") :
|
|
include_once ("../include/auth.inc.php");
|
|
$usrAccessArray["hq"] = "1";
|
|
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
|
|
authCheckEmployeeRights($emp_id, "8", "1");
|
|
$autoMode = false;
|
|
$hasAccess = true;
|
|
else :
|
|
if ($argv[1] == "acapella7890") :
|
|
$hasAccess = true;
|
|
endif;
|
|
endif;
|
|
|
|
|
|
function statisticSetGlobalParameterArray () {
|
|
global $aligns, $f_statusMode, $f_dateMode, $f_showDateAndTime, $f_crvh_sid, $f_direction_sort;
|
|
global $f_filter, $f_filter2, $f_filter3, $f_filter4, $f_filter5, $f_filter6, $f_filter7, $f_filter8, $f_filter9, $f_filter10;
|
|
global $f_price_formular, $f_filter_a, $f_filter_interval, $g_crvh_filter, $f_mode_statistic, $f_filter_calc, $f_service, $f_servicetype, $f_jb_service, $f_split_jb_services, $f_jb_specifics;
|
|
global $f_cs_meta, $f_cr_meta, $f_cr_parent, $f_cr_pda_actions, $f_show_invoice_address, $f_show_delivery_address, $summationField, $summationField2, $uniqueSearchFields;
|
|
global $hour_from, $minute_from, $hour_to, $minute_to, $fromTimeRange, $toTimeRange, $f_cmp_new_date, $f_cs_become_cs_date, $f_net_gross;
|
|
global $f_group, $f_groupLen, $f_staticGroup, $f_staticGroupLen, $f_priceMode;
|
|
|
|
$globalParArray = array($aligns, $f_statusMode, $f_dateMode, $f_showDateAndTime, $f_crvh_sid, $f_direction_sort,
|
|
$f_filter, $f_filter2, $f_filter3, $f_filter4, $f_filter5, $f_filter6, $f_filter7, $f_filter8, $f_filter9, $f_filter10,
|
|
$f_price_formular, $f_filter_a, $f_filter_interval, $g_crvh_filter, $f_mode_statistic, $f_filter_calc, $f_service, $f_servicetype, $f_jb_service, $f_split_jb_services, $f_jb_specifics,
|
|
$f_cs_meta, $f_cr_meta, $f_cr_parent, $f_cr_pda_actions, $f_show_invoice_address, $f_show_delivery_address, $summationField, $summationField2, $uniqueSearchFields,
|
|
$hour_from, $minute_from, $hour_to, $minute_to, $fromTimeRange, $toTimeRange, $f_cmp_new_date, $f_cs_become_cs_date, $f_net_gross,
|
|
$f_group, $f_groupLen, $f_staticGroup, $f_staticGroupLen, $f_priceMode);
|
|
return $globalParArray;
|
|
}
|
|
|
|
|
|
if ($hasAccess) :
|
|
|
|
// Mode in $argv[2]
|
|
// $mode = trim ($argv[2]);
|
|
$mode = "Umsatz";
|
|
$currencySymbol = "€";
|
|
|
|
// Init system parameter
|
|
$path = "../temp/download/";
|
|
|
|
|
|
// Init global parameter for script
|
|
$aligns = "";
|
|
$f_statusMode = "1"; // Finished jobs
|
|
$f_dateMode = "1"; // "creating date", "booking date", "finish date" [default], "export date", "order_date"
|
|
$f_showDateAndTime = "0"; // Clock time restriction (0 = none)
|
|
$f_crvh_sid = ""; // Filter for special vehicle SID
|
|
$f_direction_sort = "0"; // ORDER BY ASC or DESC"
|
|
$f_filter = "0"; // Filter (Split for vehicletype, start zipcode, etc.)
|
|
$f_filter2 = "0"; // Filter (Split for "Aufträge und Gutschriften") (0 = none)
|
|
$f_filter3 = "0"; // Filter (Split for "Fahrzeugkategorie" ["jb_type"]) (0 = none)
|
|
$f_filter4 = "0"; // Filter (Split for headquarters) (0 = none)
|
|
$f_filter5 = "0"; // Filter (Split for branches) (0 = none)
|
|
$f_filter6 = "0"; // Filter (Split for carriers [ONLY customer statistics]) (0 = none)
|
|
$f_filter7 = "0"; // Filter (Split for vehicles) (0 = none)
|
|
$f_filter8 = "0"; // Filter (Split for employees) (0 = none)
|
|
$f_filter9 = "0"; // Filter (Split for job types ["jb_type"]) (0 = none)
|
|
$f_filter10 = "0"; // Filter (Split for costcenter ["csc_id_payer" / "csc_id_related"]) (0 = none)
|
|
$f_price_formular = "0"; // Computation of the price (0 = jb_totalprice)
|
|
$f_filter_a = "0"; // Subfilter to $f_filter (Kind of vehicletype [Requested or real]) (0 = none)
|
|
$f_filter_interval = "0"; // Filter (Split for time intervals) (0 = none)
|
|
$g_crvh_filter = ""; // Vehicle filter ("" = default)
|
|
$f_mode_statistic = "0"; // Normal statistic (0 = default, 1 = calculator)
|
|
$f_filter_calc = "0"; // (0 = none)
|
|
$f_service = "0"; // Service for "service statistic" (0 = none)
|
|
$f_servicetype = "0"; // Servicetype for "service statistic" (0 = none)
|
|
$f_jb_service = array(); // Job service array as filter (empty array = default)
|
|
$f_split_jb_services = "0"; // Filter (Split for job services) (0 = none)
|
|
$f_jb_specifics = array(); // Job specifics used as filter (empty array = default)
|
|
$f_cs_meta = "0"; // Filter (Split for sub customers ["meta-customer"]) (0 = none)
|
|
$f_cr_meta = "0"; // Filter (Split for driver) (0 = none)
|
|
$f_cr_parent = ""; // Every courier or driver OR cumulation by parent ("" = default)
|
|
$f_cr_pda_actions = "0"; // Filter for courier action statistics (absolute/relative per job) (0 = none)
|
|
$f_show_invoice_address = "0";
|
|
$f_show_delivery_address = "0";
|
|
$summationField = "stat.count_jobs";
|
|
$summationField2 = "stat.business_volume";
|
|
$uniqueSearchFields = array();
|
|
$hour_from = "";
|
|
$minute_from = "";
|
|
$hour_to = "";
|
|
$minute_to = "";
|
|
$fromTimeRange = "";
|
|
$toTimeRange = "";
|
|
$f_cmp_new_date = ""; // Filter (Only new data set since date)
|
|
$f_cs_become_cs_date = ""; // Filter (Only new customers since date)
|
|
$f_net_gross = "0";
|
|
$f_group = array();
|
|
$f_groupLen = 0;
|
|
$f_staticGroup = array();
|
|
$f_staticGroupLen = 0;
|
|
|
|
|
|
// Init "Local" parameters
|
|
if ($f_hq_id == "") :
|
|
// $f_hq_id = getColVectorFromDB2ArrayByClause("mandatorheadquarters AS mdhq, headquarters AS hq", "hq.hq_id", "mdhq.md_id = '" . $md_id . "' AND mdhq.hq_id = hq.hq_id", "", "hq.hq_mnemonic", "");
|
|
$hqIdArrayOrg = getColVectorFromDB2ArrayByClause("headquarters", "hq_id", "", "", "", "");
|
|
$hqIdArray = $hqIdArrayOrg;
|
|
|
|
// Add element for computation of the sum of all headquarters
|
|
array_push($hqIdArray, "ALL_HQ");
|
|
endif;
|
|
$hqIdArrayLen = count($hqIdArray);
|
|
|
|
// Init system parameter
|
|
$path = "../temp/download/";
|
|
$f_secretFileName = "GFL_" . str_replace("-","",getDateTime("date_yesterday_currentmonth_currentyear")) . ".csv";
|
|
$matrix = array(); // array("","Monat Vorjahr","Vormonat","Aktueller Monat IST","Aktueller Monat SOLL")
|
|
$output = "";
|
|
|
|
// Remove potential existing file
|
|
if (file_exists($path . $f_secretFileName)) :
|
|
unlink($path . $f_secretFileName);
|
|
endif;
|
|
|
|
$matrix[0][0] = "Kumulierte Monatswerte";
|
|
$matrix[0][1] = "Monat Vorjahr";
|
|
$matrix[0][2] = "Vormonat";
|
|
$matrix[0][3] = "Aktueller Monat IST";
|
|
$matrix[0][4] = "BSG [%]";
|
|
$matrix[0][5] = "Monat Vorjahr";
|
|
$matrix[0][6] = "Vormonat";
|
|
$matrix[0][7] = "Aktueller Monat IST";
|
|
$matrix[0][8] = "BSG";
|
|
$matrix[0][9] = "Monat Vorjahr";
|
|
$matrix[0][10] = "Vormonat";
|
|
$matrix[0][11] = "Aktueller Monat IST";
|
|
$matrix[0][12] = "BSG";
|
|
|
|
|
|
// Iterate all headquarters
|
|
for ($h = 0; $h < $hqIdArrayLen; $h++) :
|
|
|
|
if ($hqIdArray[$h] == "ALL_HQ") :
|
|
$f_hq_id = $hqIdArrayOrg;
|
|
$hqName = "ALLE NIEDERLASSUNGEN";
|
|
$hqMnemonic = "GESAMT";
|
|
else :
|
|
$f_hq_id = array($hqIdArray[$h]);
|
|
$hqName = getFieldValueFromId("headquarters","hq_id",$hqIdArray[$h],"hq_name");
|
|
$hqMnemonic = getFieldValueFromId("headquarters","hq_id",$hqIdArray[$h],"hq_mnemonic");
|
|
endif;
|
|
|
|
$csEid = "";
|
|
$crEid = "";
|
|
$orderByClause = "";
|
|
|
|
$line = ($h + 1); // Row of the matrix
|
|
|
|
// First column
|
|
$matrix[$line][0] = $hqMnemonic;
|
|
|
|
// **** Current month of last year ****
|
|
$globalParArray = statisticSetGlobalParameterArray();
|
|
$f_category = "1";
|
|
$f_statistic = "30";
|
|
$idArrayLen = getCategoryDBFields($f_statistic);
|
|
if (date("d") == "01") :
|
|
$fromDateRange = getDateTime("date_firstday_lastmonth_lastyear");
|
|
$toDateRange = getDateTime("date_yesterday_lastmonth_lastyear");
|
|
else :
|
|
$fromDateRange = getDateTime("date_firstday_currentmonth_lastyear");
|
|
$toDateRange = getDateTime("date_yesterday_currentmonth_lastyear");
|
|
endif;
|
|
$currentMonthLastYear = getStatistic($globalParArray, $f_statistic, $fromDateRange . " 00:00:00", $toDateRange . " 23:59:59", $csEid, $crEid, $orderByClause);
|
|
|
|
// Output
|
|
$matrix[$line][1] = number_format(round($currentMonthLastYear[0][0]["business_volume"],2), 2, ",", ".");
|
|
$matrix[$line][5] = number_format($currentMonthLastYear[0][0]["count_jobs"], 0, ",", ".");
|
|
$matrix[$line][9] = number_format(round(($currentMonthLastYear[0][0]["business_volume"] / $currentMonthLastYear[0][0]["count_jobs"]),2), 2, ",", ".");
|
|
|
|
|
|
// **** Last month of current year ****
|
|
$globalParArray = statisticSetGlobalParameterArray();
|
|
$f_category = "1";
|
|
$f_statistic = "30";
|
|
$idArrayLen = getCategoryDBFields($f_statistic);
|
|
if (date("d") == "01") :
|
|
$fromDateRange = getDateTime("date_firstday_nexttolastmonth_currentyear");
|
|
$toDateRange = getDateTime("date_yesterday_nexttolastmonth_currentyear");
|
|
else :
|
|
$fromDateRange = getDateTime("date_firstday_lastmonth_currentyear");
|
|
$toDateRange = getDateTime("date_yesterday_lastmonth_currentyear");
|
|
endif;
|
|
$lastMonthCurrentYear = getStatistic($globalParArray, $f_statistic, $fromDateRange . " 00:00:00", $toDateRange . " 23:59:59", $csEid, $crEid, $orderByClause);
|
|
// Output
|
|
$matrix[$line][2] = number_format(round($lastMonthCurrentYear[0][0]["business_volume"],2), 2, ",", ".");
|
|
$matrix[$line][6] = number_format($lastMonthCurrentYear[0][0]["count_jobs"], 0, ",", ".");
|
|
$matrix[$line][10] = number_format(round(($lastMonthCurrentYear[0][0]["business_volume"] / $lastMonthCurrentYear[0][0]["count_jobs"]),2), 2, ",", ".");
|
|
|
|
|
|
// **** Current month of current year ****
|
|
$globalParArray = statisticSetGlobalParameterArray();
|
|
$f_category = "1";
|
|
$f_statistic = "30";
|
|
$idArrayLen = getCategoryDBFields($f_statistic);
|
|
if (date("d") == "01") :
|
|
$fromDateRange = getDateTime("date_firstday_lastmonth_currentyear");
|
|
$toDateRange = getDateTime("date_yesterday_lastmonth_currentyear");
|
|
else :
|
|
$fromDateRange = getDateTime("date_firstday_currentmonth_currentyear");
|
|
$toDateRange = getDateTime("date_yesterday_currentmonth_currentyear");
|
|
endif;
|
|
$currentMonthCurrentYear = getStatistic($globalParArray, $f_statistic, $fromDateRange . " 00:00:00", $toDateRange . " 23:59:59", $csEid, $crEid, $orderByClause);
|
|
// Output
|
|
$matrix[$line][3] = number_format(round($currentMonthCurrentYear[0][0]["business_volume"],2), 2, ",", ".");
|
|
$matrix[$line][7] = number_format($currentMonthCurrentYear[0][0]["count_jobs"], 0, ",", ".");
|
|
$matrix[$line][11] = number_format(round(($currentMonthCurrentYear[0][0]["business_volume"] / $currentMonthCurrentYear[0][0]["count_jobs"]),2), 2, ",", ".");
|
|
|
|
|
|
// **** BSG values of the current month an current year ****
|
|
// Init for BSG call
|
|
$f_priceMode = "2";
|
|
$globalParArray = statisticSetGlobalParameterArray();
|
|
$bsgCurrentMonthCurrentYear = getStatistic($globalParArray, $f_statistic, $fromDateRange . " 00:00:00", $toDateRange . " 23:59:59", $csEid, $crEid, $orderByClause);
|
|
// Output
|
|
$matrix[$line][4] = number_format(round($bsgCurrentMonthCurrentYear[0][0]["business_volume"],2), 2, ",", ".");
|
|
$matrix[$line][8] = 0;
|
|
$matrix[$line][12] = 0;
|
|
// Reset to "normal" statistic
|
|
$f_priceMode = "0";
|
|
endfor;
|
|
|
|
|
|
// **** Computed values ****
|
|
// Abweichung Monat [€]/[abs.]
|
|
$line++;
|
|
|
|
$currentMonthVolumeIstMinusVorjahr = ($currentMonthCurrentYear[0][0]["business_volume"] - $currentMonthLastYear[0][0]["business_volume"]); // IST minus Vorjahr
|
|
$currentMonthVolumeIstMinusVormonat = ($currentMonthCurrentYear[0][0]["business_volume"] - $lastMonthCurrentYear[0][0]["business_volume"]); // IST minus Vormonat
|
|
$currentMonthVolumeIstMinusPlan = ($currentMonthCurrentYear[0][0]["business_volume"] - $plannedYesterdayVolume); // IST minus Plan
|
|
|
|
$currentMonthCountIstMinusVorjahr = ($currentMonthCurrentYear[0][0]["count_jobs"] - $currentMonthLastYear[0][0]["count_jobs"]); // IST minus Vorjahr
|
|
$currentMonthCountIstMinusVormonat = ($currentMonthCurrentYear[0][0]["count_jobs"] - $lastMonthCurrentYear[0][0]["count_jobs"]); // IST minus Vormonat
|
|
$currentMonthCountIstMinusPlan = ($currentMonthCurrentYear[0][0]["count_jobs"] - $plannedYesterdayCount); // IST minus Plan
|
|
|
|
$currentMonthAverageIstMinusVorjahr = ($currentMonthCurrentYear[0][0]["business_volume"] / $currentMonthCurrentYear[0][0]["count_jobs"]) - ($currentMonthLastYear[0][0]["business_volume"] / $currentMonthLastYear[0][0]["count_jobs"]); // IST minus Vorjahr
|
|
$currentMonthAverageIstMinusVormonat = ($currentMonthCurrentYear[0][0]["business_volume"] / $currentMonthCurrentYear[0][0]["count_jobs"]) - ($lastMonthCurrentYear[0][0]["business_volume"] / $lastMonthCurrentYear[0][0]["count_jobs"]); // IST minus Vormonat
|
|
$currentMonthAverageIstMinusPlan = ($currentMonthCurrentYear[0][0]["business_volume"] / $currentMonthCurrentYear[0][0]["count_jobs"]) - ($plannedYesterdayVolume / $plannedYesterdayCount); // IST minus Plan
|
|
|
|
$matrix[$line][0] = "Abweichung Monat [" . $currencySymbol . "]";
|
|
|
|
$matrix[$line][1] = number_format(round($currentMonthVolumeIstMinusVorjahr,2), 2, ",", "."); // IST minus Vorjahr
|
|
$matrix[$line][2] = number_format(round($currentMonthVolumeIstMinusVormonat,2), 2, ",", "."); // IST minus Vormonat
|
|
$matrix[$line][3] = " ";
|
|
// $matrix[$line][4] = number_format(round($currentMonthVolumeIstMinusPlan,2), 2, ",", "."); // IST minus Plan
|
|
$matrix[$line][4] = " ";
|
|
|
|
$matrix[$line][5] = number_format(round($currentMonthCountIstMinusVorjahr,2), 2, ",", "."); // IST minus Vorjahr
|
|
$matrix[$line][6] = number_format(round($currentMonthCountIstMinusVormonat,2), 2, ",", "."); // IST minus Vormonat
|
|
$matrix[$line][7] = " ";
|
|
$matrix[$line][8] = number_format(round($currentMonthCountIstMinusPlan,2), 2, ",", "."); // IST minus Plan
|
|
|
|
$matrix[$line][9] = number_format(round($currentMonthAverageIstMinusVorjahr,2), 2, ",", "."); // IST minus Vorjahr
|
|
$matrix[$line][10] = number_format(round($currentMonthAverageIstMinusVormonat,2), 2, ",", "."); // IST minus Vormonat
|
|
$matrix[$line][11] = " ";
|
|
$matrix[$line][12] = number_format(round($currentMonthAverageIstMinusPlan,2), 2, ",", "."); // IST minus Plan
|
|
|
|
// Abweichung Monat [%]
|
|
$line++;
|
|
|
|
$currentMonthPercentVolumeIstMinusVorjahr = (($currentMonthVolumeIstMinusVorjahr / $currentMonthLastYear[0][0]["business_volume"]) * 100); // (Abweichung Vorjahr in € durch Vorjahr in €) * 100
|
|
$currentMonthPercentVolumeIstMinusVormonat = (($currentMonthVolumeIstMinusVormonat / $lastMonthCurrentYear[0][0]["business_volume"]) * 100); // (Abweichung Vormonat in € durch Vormonat in €) * 100
|
|
$currentMonthPercentVolumeIstMinusPlan = (($currentMonthVolumeIstMinusPlan / $plannedMonthVolume) * 100); // (Abweichung Plan in € durch Plan in €) * 100
|
|
|
|
$currentMonthPercentCountIstMinusVorjahr = (($currentMonthCountIstMinusVorjahr / $currentMonthLastYear[0][0]["count_jobs"]) * 100); // (Abweichung Vorjahr durch Vorjahr) * 100
|
|
$currentMonthPercentCountIstMinusVormonat = (($currentMonthCountIstMinusVormonat / $lastMonthCurrentYear[0][0]["count_jobs"]) * 100); // (Abweichung Vormonat durch Vormonat) * 100
|
|
$currentMonthPercentCountIstMinusPlan = (($currentMonthCountIstMinusPlan / $plannedMonthCount) * 100); // (Abweichung Plan durch Plan) * 100
|
|
|
|
$currentMonthPercentAverageIstMinusVorjahr = (($currentMonthAverageIstMinusVorjahr / ($currentMonthLastYear[0][0]["business_volume"] / $currentMonthLastYear[0][0]["count_jobs"])) * 100); // (Abweichung Vorjahr durch Vorjahr) * 100
|
|
$currentMonthPercentAverageIstMinusVormonat = (($currentMonthAverageIstMinusVormonat / ($lastMonthCurrentYear[0][0]["business_volume"] / $lastMonthCurrentYear[0][0]["count_jobs"])) * 100); // (Abweichung Vormonat durch Vormonat) * 100
|
|
$currentMonthPercentAverageIstMinusPlan = (($currentMonthAverageIstMinusPlan / ($plannedMonthVolume / $plannedMonthCount)) * 100); // (Abweichung Plan durch Plan) * 100
|
|
|
|
$matrix[$line][0] = "Abweichung Monat [%]";
|
|
|
|
$matrix[$line][1] = number_format(round($currentMonthPercentVolumeIstMinusVorjahr,2), 2, ",", ".");
|
|
$matrix[$line][2] = number_format(round($currentMonthPercentVolumeIstMinusVormonat,2), 2, ",", ".");
|
|
$matrix[$line][3] = " ";
|
|
// $matrix[$line][4] = number_format(round($currentMonthPercentVolumeIstMinusPlan,2), 2, ",", "."); // IST minus Plan
|
|
$matrix[$line][4] = " ";
|
|
|
|
$matrix[$line][5] = number_format(round($currentMonthPercentCountIstMinusVorjahr,2), 2, ",", "."); // IST minus Vorjahr
|
|
$matrix[$line][6] = number_format(round($currentMonthPercentCountIstMinusVormonat,2), 2, ",", "."); // IST minus Vormonat
|
|
$matrix[$line][7] = " ";
|
|
$matrix[$line][8] = number_format(round($currentMonthPercentCountIstMinusPlan,2), 2, ",", "."); // IST minus Plan
|
|
|
|
$matrix[$line][9] = number_format(round($currentMonthPercentAverageIstMinusVorjahr,2), 2, ",", "."); // IST minus Vorjahr
|
|
$matrix[$line][10] = number_format(round($currentMonthPercentAverageIstMinusVormonat,2), 2, ",", "."); // IST minus Vormonat
|
|
$matrix[$line][11] = " ";
|
|
$matrix[$line][12] = number_format(round($currentMonthPercentAverageIstMinusPlan,2), 2, ",", "."); // IST minus Plan
|
|
|
|
|
|
// Define potential hidden cols
|
|
$hiddenCols = array("8","12");
|
|
|
|
|
|
// Define HTML output
|
|
$output .= "<table style=\"border:1px solid #7777FF; border-collapse:collapse; background-color:#CCCCFF;\" border=\"1\">";
|
|
$output .= "<tr><td class=\"td_border td_cell\"> </td><td colspan=\"4\" class=\"td_border td_cell\" align=\"center\"><b>" . $mode . "</b></td><td colspan=\"3\" class=\"td_border td_cell\" align=\"center\"><b>" . "Anzahl Aufträge" . "</b></td><td colspan=\"3\" class=\"td_border td_cell\" align=\"center\"><b>" . "Durchschnittlicher Auftragswert" . "</b></td><tr>";
|
|
for ($i = 0; $i <= $line; $i++) :
|
|
$output .= "<tr>";
|
|
for ($j = 0; $j < 13; $j++) :
|
|
$k = array_search($j, $hiddenCols);
|
|
if ($k === FALSE) :
|
|
$output .= "<td class=\"td_border td_cell\" align=\"right\">" . $matrix[$i][$j] . "</td>";
|
|
endif;
|
|
endfor;
|
|
$output .= "</tr>";
|
|
endfor;
|
|
$output .= "</table>";
|
|
|
|
|
|
// **** Generate CSV output (lines) and write file ****
|
|
// $lineArray = convertMatrixToCsv ($matrix, ";" . $mode . ";;;;Anzahl Aufträge;;;;Durchschnittlicher Auftragswert");
|
|
$lineArray = convertMatrixToCsv ($matrix, ";" . $mode . ";;;Anzahl Aufträge;;;Durchschnittlicher Auftragswert", ";", $hiddenCols); // OHNE Spalte "Plan"
|
|
$lineArrayLen = count($lineArray);
|
|
for ($i = 0; $i < $lineArrayLen; $i++) :
|
|
writeToFile($path . $f_secretFileName, $lineArray[$i]);
|
|
endfor;
|
|
|
|
|
|
// **** Send CSV file per mail ****
|
|
$mailObj = new htmlMimeMail();
|
|
$mailCssFontType = "Calibri, Arial, Verdana, Helvetica, sans-serif";
|
|
|
|
$mailtext = "<html><head><meta text/html>";
|
|
$mailtext .= "<style type=\"text/css\">";
|
|
$mailtext .= ".f8np1 { font-family: " . $mailCssFontType . "; font-size: 8pt; font-weight: normal; padding: 1px}";
|
|
$mailtext .= ".f8bp1 { font-family: " . $mailCssFontType . "; font-size: 8pt; font-weight: bold; padding: 1px}";
|
|
$mailtext .= ".f10np1 { font-family: " . $mailCssFontType . "; font-size: 10pt; font-weight: normal; padding: 1px}";
|
|
$mailtext .= ".f10bp1 { font-family: " . $mailCssFontType . "; font-size: 10pt; font-weight: bold; padding: 1px}";
|
|
$mailtext .= ".f8np1_red { font-family: " . $mailCssFontType . "; font-size: 8pt; font-weight: normal; padding: 1px; color: #FF0000;}";
|
|
|
|
$mailtext .= " table { border-width: 2px; border-style: solid; border-color: white; }";
|
|
$mailtext .= " .td_border { border-width: 2px; border-style: solid; border-color: white; }";
|
|
$mailtext .= " .td_cell { padding: 5px; }";
|
|
|
|
$mailtext .= "</style>";
|
|
$mailtext .= "</head><body><h4>";
|
|
$mailtext .= $output;
|
|
$mailtext .= "</h4></body></html>";
|
|
|
|
$mailSubject = strtoupper($mode) . "- UND AUFTRAGSDATENÜBERSICHT GFL für den Monat " . substr(getDateTime("date_yesterday_currentmonth_currentyear"),0,7);
|
|
$mailObj->setSubject($mailSubject);
|
|
|
|
$mailObj->setHtml($mailtext, null, "./");
|
|
|
|
// $mailSenderAddress = getParameterValue("0", "MAIL_SENDER_ADDRESS", "0");
|
|
// if ($mailSenderAddress != "" && checkEmailFormat($mailSenderAddress)) :
|
|
$mailSenderAddress = "hb.transport@hansetrans.de";
|
|
// endif;
|
|
$mailObj->setFrom($mailSenderAddress);
|
|
|
|
$mailCcAddress = getParameterValue("0", "MAIL_CC_ADDRESS", "0");
|
|
if ($mailCcAddress != "" && checkEmailFormat($mailCcAddress)) :
|
|
$mailObj->setCc($mailCcAddress);
|
|
endif;
|
|
|
|
$mailBccAddress = getParameterValue("0", "MAIL_BCC_ADDRESS", "0");
|
|
if ($mailBccAddress != "" && checkEmailFormat($mailBccAddress)) :
|
|
$mailObj->setBcc($mailBccAddress);
|
|
endif;
|
|
|
|
if (file_exists($path . $f_secretFileName)) :
|
|
$attachment = $mailObj->getFile($path . $f_secretFileName);
|
|
$mailObj->addAttachment($attachment, $f_secretFileName, 'text/csv');
|
|
endif;
|
|
|
|
$mailResult = $mailObj->send(array("mail-cron@assecutor.de","ca@hansetrans.de","sascha.engel@hansetrans.de"), 'smtp');
|
|
// $mailResult = $mailObj->send(array("mv@assecutor.de"), 'smtp');
|
|
|
|
if ($mailResult) :
|
|
// $mailsendStatus = getLngt("Die Nachricht wurde versandt!");
|
|
// Write logdata into log database
|
|
// writeToLogDB("22",$currentHqId,$job_id,$currentSessionUsrId,"","","",$f_email . "|STATION");
|
|
else :
|
|
// $mailsendStatus = getLngt("Die Nachricht konnte nicht gesendet werden!");
|
|
// Write logdata into log database
|
|
// writeToLogDB("23",$currentHqId,$job_id,$currentSessionUsrId,"","","",$f_email . "|STATION");
|
|
endif;
|
|
|
|
$mailObj = NULL;
|
|
if (file_exists($path . $f_secretFileName)) :
|
|
unlink($path . $f_secretFileName);
|
|
endif;
|
|
|
|
|
|
// OUTPUT
|
|
if (!$autoMode) :
|
|
echo $mailtext;
|
|
endif;
|
|
endif;
|
|
?>
|