955 lines
46 KiB
PHP
955 lines
46 KiB
PHP
<?php
|
|
/*=======================================================================
|
|
*
|
|
* jb_list.php (../customer/)
|
|
*
|
|
* Autor: Marc Vollmann
|
|
*
|
|
=======================================================================*/
|
|
|
|
include_once ("../include/mcglobal.inc.php");
|
|
include_once ("../include/auth.inc.php");
|
|
include_once ("../include/caglobal.inc.php"); // For courier-list only
|
|
include_once ("../include/copy_job.inc.php"); // E.g. for "Storno"
|
|
include_once ("../include/ranking.inc.php"); // Checks ranking to be lost or not
|
|
|
|
// Check HTTP-Parameters
|
|
getSecHttpVars("1",array("f_act", "customerId", "cscIdRoot", "cscIdActual", "numOfStationSearchs",
|
|
"jb_status", "jb_costcenter", "jb_sort", "jb_sel_cs",
|
|
"day_from", "month_from", "year_from", "day_to", "month_to", "year_to",
|
|
"f_search", "f_stationBasedSearch", "jb_id_storno", "f_jb_id", "f_cr_sid", "dbhistory", "deactivateMenu"));
|
|
|
|
getLanguage(__FILE__);
|
|
|
|
$pageTitel = getLngt("AUFTRAGSLISTEN");
|
|
include_once ("../admin/menu.php");
|
|
include_once ("../include/html.inc.php");
|
|
include_once ("../include/inc_job.inc.php");
|
|
|
|
getCurrentScript(__FILE__);
|
|
|
|
// Check for authentication access and granted rights
|
|
$usrAccessArray["cs"] = "1";
|
|
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
|
|
|
|
// Check GLOBAL parameter to use "related customer" or "normal payer" (!!!!)
|
|
$globalParUseRelatedCustomer = getParameterValue("0", "GLOBAL_USE_RELATED_CUSTOMER", "0");
|
|
$costcenterPayerOrRelatedClause = "jb.csc_id_payer";
|
|
$doCscSubst = true;
|
|
if ($doCscSubst) :
|
|
// WITH CASH PAYER
|
|
$costcenterPayerOrRelatedClause = "<SUBST_CSC>";
|
|
endif;
|
|
if ($globalParUseRelatedCustomer == "1") :
|
|
$costcenterPayerOrRelatedClause = "jb.csc_id_related";
|
|
endif;
|
|
|
|
// Get tax value
|
|
$globalParSalesTaxRate = getParameterValue("0", "GLOBAL_SALES_TAX", "0");
|
|
if ($globalParSalesTaxRate == "" || !is_numeric($globalParSalesTaxRate)) : $globalParSalesTaxRate = 19; endif;
|
|
|
|
if ($numOfStationSearchs == "" || !is_numeric($numOfStationSearchs)) :
|
|
$numOfStationSearchs = 0;
|
|
endif;
|
|
|
|
// Search value
|
|
$f_search = trim($f_search);
|
|
$f_job_search = $f_search;
|
|
|
|
if ($globalParUseRelatedCustomer == "1" && $f_job_search != "" && !is_numeric($f_job_search)) :
|
|
$f_job_search = getJobIdSearchOutput($f_job_search);
|
|
endif;
|
|
|
|
if ($jb_status == "") :
|
|
$jb_status = "0";
|
|
$tmpJbStateDefault = trim(getParameterValue($emp_id, "CUSTOMER_MASK_JOBLIST_JBSTATUS_DEFAULT", "0"));
|
|
if ($tmpJbStateDefault != "" && is_numeric($tmpJbStateDefault)) :
|
|
$jb_status = $tmpJbStateDefault;
|
|
endif;
|
|
endif;
|
|
// Attention: Parameter also used for meta customer !!!
|
|
if ($jb_costcenter == "") :
|
|
$jb_costcenter = "1";
|
|
$tmpCscDefault = trim(getParameterValue($emp_id, "CUSTOMER_MASK_JOBLIST_CSC_DEFAULT", "0"));
|
|
if ($tmpCscDefault != "" && is_numeric($tmpCscDefault)) :
|
|
$jb_costcenter = $tmpCscDefault;
|
|
endif;
|
|
endif;
|
|
|
|
// Flag for station based search
|
|
if ($f_stationBasedSearch == "" || count($f_stationBasedSearch) == 0) :
|
|
$f_stationBasedSearch = false;
|
|
else:
|
|
$f_stationBasedSearch = true;
|
|
endif;
|
|
|
|
// Check range of date. All fields have to be set
|
|
if ($day_from == "" || $month_from == "" || $year_from == "" ||
|
|
$day_to == "" || $month_to == "" || $year_to == "") :
|
|
|
|
// Initialize date-ranges to the current date
|
|
$fromDateRange = getDateTime("3") . " 00:00:00";
|
|
$toDateRange = getDateTime("3") . " 23:59:59";
|
|
|
|
$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) . " 00:00:00";
|
|
$toDateRange = $year_to . "-" . pad($month_to,2) . "-" . pad($day_to,2) . " 23:59:59";
|
|
endif;
|
|
|
|
// Init
|
|
$empIdMaster = "";
|
|
$cr_id_order_list = "";
|
|
$cr_id_order_list2 = "";
|
|
$vht_id_str_js = "";
|
|
|
|
// Decision to use the archive or normal tables
|
|
getDBNames($dbhistory, $year_from);
|
|
|
|
// All open jobs in the future have to be displayed
|
|
// if ($jb_status == "0" || $jb_status == "9") : $toDateRange = ""; endif;
|
|
|
|
// Map jobs
|
|
// if ($jb_status == "8" || $jb_status == "9") : $jb_status == "0"; endif;
|
|
|
|
|
|
// Secure-check of the association between customer, costcenter and employee
|
|
$tmpFields = array("cs_id",$customerId,"csc_id",$cscIdActual);
|
|
|
|
if (existsEntry("costcenter",$tmpFields)) :
|
|
|
|
// *** Save job-informations (Begin) ***
|
|
if ($f_act == "storno" && $jb_id_storno != "") :
|
|
|
|
// Check job is generated by customer
|
|
$jbStornoCscId = getFieldValueFromId("job","jb_id",$jb_id_storno,"csc_id");
|
|
$jbStornoUsrId = getFieldValueFromId("job","jb_id",$jb_id_storno,"emp_id"); // "emp_id" contains the "usr_id"
|
|
$jbStornoEmpUsrType = getFieldValueFromId("user","usr_id",$jbStornoUsrId,"usr_type");
|
|
|
|
// Set the current timestamp to store the data
|
|
$currentTime = getDateTime("0");
|
|
|
|
if ($jbStornoCscId > 0 || $jbStornoEmpUsrType == "2") :
|
|
|
|
TA("B");
|
|
|
|
// Get current jb_status and cr_id of the storno job
|
|
$jbStatus = getFieldValueFromId("job","jb_id",$jb_id_storno,"jb_status");
|
|
$jb_storno_costs = "2";
|
|
|
|
// Update the job-entry:
|
|
// jb_storno = 1 (costs because of cs-storno), jb_status = 2 (finished), jb_finishtime = NOW()
|
|
$res = updateStmt("job", "jb_id", $jb_id_storno,
|
|
array("jb_storno", $jb_storno_costs, "usr_id_storno", $usr_id, "jb_status", "2", "jb_finishtime", $currentTime, "jb_freetext_3", getLngt("Storno durch Kunde im Kundenzugang!")),
|
|
"(jb_status = '9' OR jb_status = '8') AND (isnull(jb_storno) OR jb_storno = '0')");
|
|
|
|
if ($db->affected_rows > 0) :
|
|
|
|
// Check for storno-job has a standing order
|
|
/*
|
|
$jbPermanent = getFieldValueFromId("job","jb_id",$jb_id_storno,"jb_permanent");
|
|
|
|
if ($jbPermanent != "" && $jbPermanent > "0") :
|
|
// Check for the continued existence of the standing order rule
|
|
if ($jb_storno_rhythm == "2") :
|
|
// Update row for termnination of the standing order
|
|
updateStmt("job", "jb_id", $jb_id_storno, array("jb_permanent", "0"));
|
|
endif;
|
|
endif;
|
|
*/
|
|
|
|
// Call for generation of a new job with negative invoice data
|
|
if ($globalParUseRelatedCustomer != "1") :
|
|
copy_job($jb_id_storno, $jb_storno_costs, $jbStatus, true);
|
|
else :
|
|
// Remove commission no.
|
|
updateStmt("tour", "jb_id", $jb_id_storno, array("tr_commission_no", ""));
|
|
endif;
|
|
updateStmt("tour", "jb_id", $jb_id_storno, array("tr_commission_no", ""));
|
|
|
|
// Write logdata into log database
|
|
writeToLogDB("10",$hq_id,$jb_id_storno,$usr_id,"","","","COSTS=NO|JBP_REMOVAL=NO|FDS_REMOVAL=NO|CUSTOMER_STORNO=YES");
|
|
|
|
$statusMessage = getLngt("Der Auftrag") . " " . $jb_id_storno . " " . getLngt("wurde storniert");
|
|
endif;
|
|
|
|
TA("C");
|
|
TA("E");
|
|
else :
|
|
// MELDUNG: STORNO NICHT MÖGLICH!
|
|
endif;
|
|
endif;
|
|
// *** Save job-informations (End) ***
|
|
|
|
|
|
if ($f_act == "setCourier" && $f_cr_sid != "" && $f_jb_id != "") :
|
|
// Get current cr_id of the job before changing the courier
|
|
$crIdCurrent = getFieldValueFromId("job","jb_id",$f_jb_id,"cr_id");
|
|
$crIdOrderCurrent = getFieldValueFromId("job","jb_id",$f_jb_id,"cr_id_order");
|
|
$jbHqId = getFieldValueFromId("job","jb_id",$f_jb_id,"hq_id_dispo");
|
|
if ($jbHqId == "" || !is_numeric($jbHqId) || $jbHqId == "0") : $jbHqId = $hq_id; endif;
|
|
if ($f_cr_availabletime_reset != "1") : $f_cr_availabletime_reset = "0"; endif;
|
|
|
|
// getDbFieldValues("courier",array("cr_id","cr_occupied"),array("cr_sid",$f_cr_sid));
|
|
$cr_id = getFieldValueFromClause("courier","cr_id","cr_sid = '" . $f_cr_sid . "' ORDER BY cr_logintime");
|
|
$jb_status_new = "0";
|
|
$cr_id_new = "";
|
|
|
|
if ($cr_id == ""): // Offline-Dispo
|
|
$cr_id = getFieldValueFromClause("couriervehicle","cr_id","crvh_sid = '" . $f_cr_sid . "' ORDER BY crvh_export_time DESC");
|
|
if ($cr_id != "")
|
|
$jb_status_new = "1";
|
|
$cr_id_new = $cr_id;
|
|
endif;
|
|
|
|
if ($cr_id != "") :
|
|
|
|
// RANKING
|
|
// Special treatment according to vehicletype ("BUS" or greater will NOT be revoked if job-order is "PKW")
|
|
// Get cr.vht_id and jb.vht_id
|
|
/*
|
|
$arLooseRanking = "1"; // Init: Loose ranking "yes"
|
|
$courierVhtId = getFieldValueFromId("courier","cr_id",$cr_id,"vht_id");
|
|
$jobVhtId = getFieldValueFromId("job","jb_id",$f_jb_id,"vht_id");
|
|
if ($courierVhtId != "" && $jobVhtId != "" && $courierVhtId >= getVhtId("5", "transporter_01") && $jobVhtId <= getVhtId("3", "car_02")) :
|
|
$arLooseRanking = "0"; // Loose ranking "no"
|
|
endif;
|
|
*/
|
|
// Special treatment according areas
|
|
$jbAdressIdStart = getFieldValueFromClause("tour", "ad_id", "jb_id = '" . $f_jb_id . "' AND tr_sort = '1'");
|
|
$jbZipcodeStart = getFieldValueFromId("address", "ad_id", $jbAdressIdStart, "ad_zipcode");
|
|
|
|
// 29.01.2018: No check for looseRanking if the job is in the future
|
|
$sqlStmt = "SELECT jb_ordertime, srvpt_traveltime, job.hq_id_dispo, DATE_SUB(jb_ordertime, INTERVAL GREATEST(srvpt_traveltime, 30) MINUTE) AS datesub, UNIX_TIMESTAMP(DATE_SUB(jb_ordertime, INTERVAL GREATEST(srvpt_traveltime, 30) MINUTE)) AS unixtimestamp" .
|
|
" FROM serviceplz, serviceplztraveltime, job" .
|
|
" WHERE serviceplz.srvp_id = serviceplztraveltime.srvp_id AND srvp_plz = '" . $jbZipcodeStart . "' AND serviceplztraveltime.hq_id = job.hq_id_dispo AND jb_id = " . $f_jb_id;
|
|
// writeLog_("../log/jb_list_", $sqlStmt);
|
|
$res = $db->query($sqlStmt);
|
|
if ($row = $res->fetch_assoc()):
|
|
// writeLog_("../log/jb_list_", "jb_id = " . $f_jb_id . ", jbZipcodeStart = " . $jbZipcodeStart . ", srvpt_traveltime = " . $row['srvpt_traveltime'] . ", hq_id = " . $row["hq_id_dispo"] . ", jb_ordertime = " . $row['jb_ordertime'] . ", datesub = " . $row['datesub'] . ", unixtimestamp = " . $row['unixtimestamp']);
|
|
$unixtimestamp = $row['unixtimestamp'];
|
|
endif;
|
|
$res->free();
|
|
$arLooseRanking = "0";
|
|
if ($unixtimestamp < time()):
|
|
// writeLog_("../log/jb_list_", "looseRanking will be checked\n");
|
|
$arLooseRanking = looseRanking($cr_id, $jbZipcodeStart, $jbHqId);
|
|
else:
|
|
// writeLog_("../log/jb_list_", "looseRanking will _not_ be checked\n");
|
|
endif;
|
|
|
|
// Check first that courier is NOT occupied
|
|
// $cr_occupied = getFieldValueFromId("courier", "cr_id", $cr_id, "cr_occupied");
|
|
// if ($cr_occupied == "0") :
|
|
// if (getCountOfTable("job","cr_id_order = '" . $cr_id . "' AND (jb_status = '1' OR jb_status = '0') AND (isnull(jb_globaljob) or jb_globaljob = '0')") == 0) :
|
|
|
|
$currentTime = getDateTime("0");
|
|
|
|
TA("B");
|
|
|
|
// Update job
|
|
// According to be TA-safe the WHERE-Clause depends on the current list the user is in
|
|
$jbStatusString = " (jb_status = '8' OR jb_status = '9' OR jb_status = '0' OR jb_status = '1') ";
|
|
// if (is_numeric($jb_status)) : $jbStatusString = "jb_status = '" . $jb_status . "'"; endif;
|
|
$res = updateStmt("job", "jb_id", $f_jb_id, array("cr_id", $cr_id_new, "cr_id_order", $cr_id, "jb_status", $jb_status_new, "cr_sid", $f_cr_sid, "jb_globaljob", "0", "jb_autoranking", "0"), $jbStatusString);
|
|
|
|
if ($db->affected_rows > 0) :
|
|
|
|
// Set current assigning time for revoking a job if not taken by the courier
|
|
if (existsEntry("autoranking",array("jb_id",$f_jb_id,"cr_id",$cr_id))) :
|
|
updateStmt("autoranking", "jb_id", $f_jb_id, array("ar_challenge", "0", "ar_lastassigntime", $currentTime, "ar_looseranking", $arLooseRanking, "ar_locating", "0"),"cr_id = '" . $cr_id . "'");
|
|
else :
|
|
insertStmt("autoranking", array("jb_id", $f_jb_id, "cr_id", $cr_id, "ar_challenge", "0", "ar_lastassigntime", $currentTime, "ar_looseranking", $arLooseRanking, "ar_locating", "0"));
|
|
endif;
|
|
|
|
// Insert PDA command to remove job (take cr_id/cr_id_order before changing)
|
|
$currentTimePDA = getDateTime("datetime_plus_offset", array(0,0,30,0,0,0), $formatStr = "Y-m-d H:i:s");
|
|
if ($crIdCurrent != "" && $crIdCurrent != "0") :
|
|
insertPDACommand($jbHqId, $crIdCurrent, "4", "1", $f_jb_id, $currentTimePDA, "");
|
|
endif;
|
|
if ($crIdOrderCurrent != "" && $crIdOrderCurrent != "0" && $crIdOrderCurrent != $crIdCurrent) :
|
|
insertPDACommand($jbHqId, $crIdOrderCurrent, "4", "1", $f_jb_id, $currentTimePDA, "");
|
|
endif;
|
|
|
|
// Reset availabletime of the OLD courier if requested by the disposition manually
|
|
if ($f_cr_availabletime_reset == "1") :
|
|
updateStmt("courier", "cr_id", $crIdCurrent, array("cr_availabletime", $currentTime));
|
|
endif;
|
|
|
|
// Write logdata into log database
|
|
writeToLogDB("7",$jbHqId,$f_jb_id,$usr_id,$cr_id,$f_cr_sid,"","LOST_RANKING=" . ($arLooseRanking == "1" ? "YES" : "NO"));
|
|
|
|
// Survey
|
|
checkJobForSurvey($f_jb_id);
|
|
endif;
|
|
|
|
TA("C");
|
|
TA("E");
|
|
// else :
|
|
// $statusMessage = getLngt("Dem Fahrzeug") . " " . $f_cr_sid . " " . getLngt("wurde zwischenzeitlich ein Auftrag zugewiesen! Bitte ein anderes Fahrzeug wählen.");
|
|
// endif;
|
|
endif;
|
|
endif;
|
|
|
|
|
|
// Get the array for formatting the database-values for the output according to the defined type
|
|
$outputFormatField = defineOutputFormats();
|
|
|
|
// Get the pathname of the actual costcenter
|
|
$tmpFields = getFieldsValueFromId("costcenter","csc_id",$cscIdActual,array("csc_path","csc_name"));
|
|
$cscPathActual = $tmpFields[0];
|
|
$cscNameActual = $tmpFields[1];
|
|
|
|
// Get status of the customer according to being meta customer
|
|
$isMetaCs = "0";
|
|
if (existsEntry("customer",array("cs_id_parent",$customerId))) :
|
|
$isMetaCs = "1";
|
|
endif;
|
|
|
|
|
|
// --- JOB -------------------
|
|
|
|
// Enable special customer to make cancellation
|
|
$parCancellationEnabled = getParameterValue("0", "CUSTOMER_MASK_JOBLIST_CANCELLATION_ENABLED_" . $customerId, "0");
|
|
|
|
// Enable current headquarters to display cancelled jobs
|
|
$parDisplayCancelledJobsEnabled = getParameterValue("0", "CUSTOMER_MASK_JOBLIST_DISPLAY_CANCELLED_JOBS", $hq_id);
|
|
|
|
// Enable current headquarters to display cancelled jobs
|
|
$parCscIdPayerCash = getParameterValue("0", "CSC_ID_PAYER_CASH", $hq_id);
|
|
|
|
// Get state of customer to be abled to place jobs to favoured couriers
|
|
$parDispoFavEnabled = getParameterValue("0", "CUSTOMER_MASK_JOBLIST_DISPO_FAV_ENABLED_" . $customerId, "0");
|
|
|
|
// Enable special customer to be able to search in field "tr_remark"
|
|
// $parSearchByRemarkEnabled = getParameterValue("0", "CUSTOMER_MASK_JOBLIST_SEARCH_BY_REMARK_ENABLED_" . $customerId, "0");
|
|
$parSearchByRemarkEnabled = "1";
|
|
|
|
// Enable special customer for "tr_remark" being displayed
|
|
// $parDisplayTourRemarkEnabled = getParameterValue("0", "CUSTOMER_MASK_JOBLIST_DISPLAY_TOUR_REMARK_ENABLED_" . $customerId, "0");
|
|
$parDisplayTourRemarkEnabled = "1";
|
|
|
|
// Enable special customer to be able to search in address fields
|
|
$parSearchByAddressEnabled = getParameterValue("0", "CUSTOMER_MASK_JOBLIST_SEARCH_BY_ADDRESS_ENABLED_" . $customerId, "0");
|
|
|
|
|
|
if ($f_stationBasedSearch) :
|
|
|
|
$titles = getLngt("Nr.").",".getLngt("Kommissionsnr.").",".getLngt("Kostenstelle").",".getLngt("Firma").",,".getLngt("Straße und Hausnr.").",".getLngt("PLZ").",".getLngt("Ort").",".getLngt("Fahrz.").",".getLngt("Auftragszeit").",".getLngt("Kurier");
|
|
$titles .= ($parDisplayTourRemarkEnabled == "1" ? ",".getLngt("Bemerkung") : ""); // Tour remark
|
|
$titles .= ($jb_status != "2" ? ",".getLngt("Bearbeiten") : ""); // Edit job
|
|
|
|
$fields = "jb_id,tr_commission_no,csc_name,tr_comp,tr_comp2,streethsno,ad_zipcode,ad_city,vht_value,jb_ordertime,cr_sid";
|
|
$fields .= ($parDisplayTourRemarkEnabled == "1" ? ",tr_remark" : "");
|
|
$fields .= ($jb_status != "2" ? ",jb_edit" : "");
|
|
|
|
$aligns = "r,l,l,l,l,l,c,l,c,c,c";
|
|
$aligns .= ($parDisplayTourRemarkEnabled == "1" ? ",l" : "");
|
|
$aligns .= ($jb_status != "2" ? ",r" : "");
|
|
|
|
else :
|
|
|
|
// Initialize
|
|
$titles = trim(getParameterValue($emp_id, "CUSTOMER_MASK_JOBLIST_TITLES", "0"));
|
|
if ($titles == "") : $titles = trim(getParameterValue("0", "CUSTOMER_MASK_JOBLIST_TITLES_" . $customerId, "0")); endif;
|
|
$fields = trim(getParameterValue($emp_id, "CUSTOMER_MASK_JOBLIST_FIELDS", "0"));
|
|
if ($fields == "") : $fields = trim(getParameterValue("0", "CUSTOMER_MASK_JOBLIST_FIELDS_" . $customerId, "0")); endif;
|
|
$aligns = trim(getParameterValue($emp_id, "CUSTOMER_MASK_JOBLIST_ALIGNS", "0"));
|
|
if ($aligns == "") : $aligns = trim(getParameterValue("0", "CUSTOMER_MASK_JOBLIST_ALIGNS_" . $customerId, "0")); endif;
|
|
|
|
// if ($jb_costcenter == "2" && $isMetaCs == "0") :
|
|
if ($titles == "" || $fields == "" || $aligns == "") :
|
|
$titles = getLngt("Nr.").",".getLngt("Preis").",".getLngt("Kommissionsnr.").",".getLngt("Referenznr.").",".getLngt("Kostenstelle").",".getLngt("Firma").",,".getLngt("Kunde").",".getLngt("Startadresse").",,".getLngt("Zieladresse").",".getLngt("Fahrz.").",".getLngt("Auftragszeit").",".getLngt("Kurier");
|
|
$titles .= ($jb_status != "2" && $parDispoFavEnabled == "1" ? ",".getLngt("Annahme") : ""); // Taketime
|
|
$titles .= ($jb_status != "2" ? ",".getLngt("Bearbeiten") : ""); // Edit job
|
|
$titles .= (($parDisplayCancelledJobsEnabled == "1" && $jb_status == "2") || ($parCancellationEnabled == "1" && $jb_status != "2") ? ",".getLngt("Storno") : ""); // Cancel job
|
|
|
|
$fields = "jb_id,business_volume_with_toll,tr_commission_no,tr2_commission_no,csc_name,tr_comp,tr_comp2,tr2_comp,streethsno,ad_zipcode,target_address,vht_value,jb_ordertime,cr_sid";
|
|
$fields .= ($jb_status != "2" && $parDispoFavEnabled == "1" ? ",jb_taketime" : "");
|
|
$fields .= ($jb_status != "2" ? ",jb_edit" : "");
|
|
$fields .= (($parDisplayCancelledJobsEnabled == "1" && $jb_status == "2") || ($parCancellationEnabled == "1" && $jb_status != "2") ? ",jb_storno" : "");
|
|
|
|
$aligns = "r,r,l,l,l,l,l,l,l,c,l,c,c,c";
|
|
$aligns .= ($jb_status != "2" && $parDispoFavEnabled == "1" ? ",c" : "");
|
|
$aligns .= ($jb_status != "2" ? ",r" : "");
|
|
$aligns .= (($parDisplayCancelledJobsEnabled == "1" && $jb_status == "2") || ($parCancellationEnabled == "1" && $jb_status != "2") ? ",r" : "");
|
|
endif;
|
|
// else :
|
|
// ........ was the same !!!! ........
|
|
// endif;
|
|
endif;
|
|
|
|
$addOnTitles = trim(getParameterValue($emp_id, "CUSTOMER_MASK_JOBLIST_ADD_ON_TITLES", "0"));
|
|
if ($addOnTitles != "") :
|
|
if ($titles != "") : $titles .= ","; endif;
|
|
$titles .= $addOnTitles;
|
|
endif;
|
|
$addOnfields = trim(getParameterValue($emp_id, "CUSTOMER_MASK_JOBLIST_ADD_ON_FIELDS", "0"));
|
|
if ($addOnfields != "") :
|
|
if ($fields != "") : $fields .= ","; endif;
|
|
$fields .= $addOnfields;
|
|
endif;
|
|
$addOnaligns = trim(getParameterValue($emp_id, "CUSTOMER_MASK_JOBLIST_ADD_ON_ALIGNS", "0"));
|
|
if ($addOnaligns != "") :
|
|
if ($aligns != "") : $aligns .= ","; endif;
|
|
$aligns .= $addOnaligns;
|
|
endif;
|
|
|
|
// Init dummies
|
|
$valigns = ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,";
|
|
$cellTextPre = ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,";
|
|
|
|
$titlesArray = spliti(",",$titles);
|
|
$fieldsArray = spliti(",",$fields);
|
|
$fieldsLength = count($fieldsArray);
|
|
$alignsArray = spliti(",",$aligns);
|
|
$valignsArray = spliti(",",$valigns);
|
|
$cellTextPreArray = spliti(",",$cellTextPre);
|
|
|
|
$fieldClause = getDBFields("job") . ", jb.hq_id AS jb_hq_id, " . "jb.hq_id_exec AS jb_hq_id_exec" . "," . "jb.hq_id_dispo AS jb_hq_id_dispo" . "," . "jb.hq_id_sales AS jb_hq_id_sales" . "," . getDBFields("jb_tourzipcodes") . "," . getDBFields("jb_tourcities") . "," . getDBFields("jb_edit") . "," . getDBFields("tour") . "," . getDBFields("address") . "," .
|
|
getDBFields("vehicletype") . "," . getDBFields("ad_street_hsno") . "," . getDBFields("jb_latesttaketime") . ", jb.csc_id AS jb_csc_id";
|
|
|
|
if (!$f_stationBasedSearch) :
|
|
$fieldClause .= ", tr2.tr_commission_no AS tr2_commission_no, tr2.tr_comp AS tr2_comp";
|
|
|
|
// $fieldClause .= ", IFNULL(trs.jb_id,tr.jb_id) AS jb_id_group, SUM(trs.trs_price * ((100 - trs.trs_discount) / 100)) AS business_volume ";
|
|
|
|
// Toll fields
|
|
$fieldClause .= ", jb.jb_totalprice AS business_volume ";
|
|
$fieldClause .= ", gdc_toll.gdc_content AS gdc_toll_content ";
|
|
$fieldClause .= "," . "(jb.jb_totalprice + IF (gdc_toll.gdc_content != '', gdc_toll.gdc_content, 0)) AS business_volume_with_toll ";
|
|
$fieldClause .= "," . "(jb.jb_cr_price + IF (gdc_toll.gdc_content != '', gdc_toll.gdc_content, 0)) AS jb_cr_price_with_toll ";
|
|
$fieldClause .= "," . "(jb.jb_cr_subprice + IF (gdc_toll.gdc_content != '', gdc_toll.gdc_content, 0)) AS jb_cr_subprice_with_toll ";
|
|
$fieldClause .= "," . "(jb.jb_totalprice * (1 + (" . $globalParSalesTaxRate . " / 100)) + IF (gdc_toll.gdc_content != '', gdc_toll.gdc_content, 0)) AS business_volume_gross_with_toll ";
|
|
$fieldClause .= "," . "(jb.jb_cr_price * (1 + (" . $globalParSalesTaxRate . " / 100)) + IF (gdc_toll.gdc_content != '', gdc_toll.gdc_content, 0)) AS jb_cr_price_gross_with_toll ";
|
|
|
|
// Extra fields defined according to parameters
|
|
$parFieldClause = trim(getParameterValue($emp_id, "CUSTOMER_MASK_JOBLIST_FIELDCLAUSE", "0"));
|
|
if ($parFieldClause != "") : $fieldClause .= "," . $parFieldClause; endif;
|
|
|
|
// Target address (only 2nd stop)
|
|
// $fieldClause .= "," . " ad2.ad_street AS ad2_street, ad2.ad_zipcode AS ad2_zipcode, ad2.ad_city AS ad2_city, tr2.tr_hsno AS tr2_hsno ";
|
|
$fieldClause .= "," . " CONCAT(ad2.ad_street,' ',tr2.tr_hsno,', ',ad2.ad_zipcode) AS target_address ";
|
|
$fieldClause .= "," . " CONCAT(ad2.ad_street,' ',tr2.tr_hsno,', ',ad2.ad_zipcode,', ',ad2.ad_city) AS target_address2 ";
|
|
$fieldClause .= "," . " tr2.tr_finishtime AS tr2_finishtime, tr2.tr_person AS tr2_person, tr2.tr_signname AS tr2_signname ";
|
|
endif;
|
|
|
|
$fromClause = $dbh_tr . " AS tr, address AS ad, metatype AS vht";
|
|
|
|
$whereClause = "";
|
|
$orderByClause = "jb_ordertime";
|
|
if ($f_stationBasedSearch) :
|
|
$orderByClause .= ", tr_sort";
|
|
endif;
|
|
if ($jb_sort != "") : $orderByClause = $fieldsArray[$jb_sort]; endif;
|
|
// ASCending or DESCending
|
|
if ($orderByClause == "jb_ordertime") : $orderByClause = "jb_ordertime ASC"; endif;
|
|
|
|
// Check for being meta customer
|
|
if ($isMetaCs == "0") :
|
|
// Only this cutomer
|
|
if ($jb_costcenter == "1") :
|
|
$whereClause .= " " . $costcenterPayerOrRelatedClause . " = " . $cscIdActual . " AND ";
|
|
endif;
|
|
if ($jb_costcenter == "2") :
|
|
$fieldClause .= "," . getDBFields("costcenter");
|
|
$fromClause .= ", costcenter AS csc ";
|
|
/*
|
|
$whereClause .= "((" . $costcenterPayerOrRelatedClause . " = " . $cscIdActual . " AND " . $costcenterPayerOrRelatedClause . " = csc.csc_id) OR " .
|
|
"(" . $costcenterPayerOrRelatedClause . " = csc.csc_id AND csc.csc_path LIKE '%//" . $cscNameActual . "//%')) AND " .
|
|
"csc.cs_id = " . $customerId . " AND ";
|
|
*/
|
|
$whereClause .= "(" . $costcenterPayerOrRelatedClause . " = " . $cscIdActual . " OR csc.csc_path LIKE '%//" . $cscNameActual . "//%') AND " .
|
|
$costcenterPayerOrRelatedClause . " = csc.csc_id AND " .
|
|
"csc.cs_id = " . $customerId . " AND ";
|
|
endif;
|
|
else :
|
|
// Customer is meta customer
|
|
$fieldClause .= "," . getDBFields("costcenter");
|
|
$fromClause .= ", costcenter AS csc, customer AS cs ";
|
|
$whereClause .= "<SUBST_01>";
|
|
$whereClause1 = "cs.cs_id = '" . $customerId . "'";
|
|
$whereClause2 = "cs.cs_id_parent = '" . $customerId . "'";
|
|
$whereClause .= " AND cs.cs_id = csc.cs_id AND " . $costcenterPayerOrRelatedClause . " = csc.csc_id AND ";
|
|
|
|
// Selection for individual cuatomer
|
|
if ($jb_sel_cs != "") :
|
|
$whereClause .= " cs.cs_id = " . $jb_sel_cs . " AND ";
|
|
endif;
|
|
endif;
|
|
|
|
$fromClause .= ", " . $dbh_jb . " AS jb";
|
|
if (!$f_stationBasedSearch) :
|
|
// Price
|
|
// $fromClause .= " LEFT JOIN " . $dbh_trs . " AS trs ON trs.jb_id = jb.jb_id ";
|
|
// Target address (only 2nd stop)
|
|
$fromClause .= " LEFT JOIN " . $dbh_tr . " AS tr2 ON tr2.jb_id = jb.jb_id AND tr2.tr_sort = '2' ";
|
|
$fromClause .= " LEFT JOIN address AS ad2 ON ad2.ad_id = tr2.ad_id ";
|
|
$fromClause .= " LEFT JOIN genericdatacontainer AS gdc_toll ON gdc_toll.gdc_obj_type = 'jb' AND gdc_toll.gdc_obj_id = jb.jb_id AND gdc_toll.gdc_gen_fieldname = 'jb_toll' ";
|
|
endif;
|
|
$fromClause .= " LEFT JOIN genericdatacontainer AS gdc_search ON gdc_search.gdc_obj_type = 'jb' AND gdc_search.gdc_obj_id = jb.jb_id AND gdc_search.gdc_gen_fieldname = 'search' ";
|
|
|
|
// Separate list for each status
|
|
// if ($jb_status != "") : $whereClause .= "jb.jb_status = " . $jb_status . " AND "; endif;
|
|
|
|
// Aggregated list for different status displayed in ONE list
|
|
if ($jb_status != "2") :
|
|
$whereClause .= "(jb.jb_status IN (8,9,0,1)) AND ";
|
|
else :
|
|
$whereClause .= "jb.jb_status = " . $jb_status . " AND ";
|
|
endif;
|
|
|
|
if (!(($parDisplayCancelledJobsEnabled == "1" && $jb_status == "2") || ($parCancellationEnabled == "1" && $jb_status != "2"))) :
|
|
$whereClause .= "(isnull(jb.jb_storno) || jb.jb_storno = '0') AND ";
|
|
endif;
|
|
|
|
$whereClause .= "(jb.vht_id = vht.mt_sort AND vht.mt_type = 'vehicletype') AND ";
|
|
if ($f_search == "") :
|
|
if ($fromDateRange != "") :
|
|
$whereClause .= "jb.jb_ordertime >= '$fromDateRange' AND ";
|
|
endif;
|
|
if ($toDateRange != "") :
|
|
$whereClause .= "jb.jb_ordertime <= '$toDateRange' AND ";
|
|
endif;
|
|
else :
|
|
// Job ID
|
|
$whereClauseJobId = "";
|
|
if (is_numeric($f_job_search)) :
|
|
$whereClauseJobId = " jb.jb_id = '" . $f_job_search . "' OR ";
|
|
// Job parent ID
|
|
if ($globalParUseRelatedCustomer == "1") :
|
|
// Check parent
|
|
$whereClauseJobId .= " jb.jb_id_parent = '" . $f_job_search . "' OR ";
|
|
// Check GDC
|
|
$tmpArray = getColVectorFromDB2ArrayByClause("genericdatacontainer", "gdc_obj_id", "gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'info_0' AND gdc_content = '" . $f_search . "'", "", "", "");
|
|
if (count($tmpArray) > 0) :
|
|
$whereClauseJobId .= " jb.jb_id IN (" . implode(",", $tmpArray) . ") OR ";
|
|
endif;
|
|
endif;
|
|
endif;
|
|
|
|
// Check GDC.search
|
|
// $tmpArray = getColVectorFromDB2ArrayByClause("genericdatacontainer", "gdc_obj_id", "gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'search' AND gdc_content LIKE '%," . $f_search . ",%'", "", "", "");
|
|
$tmpArray = getColVectorFromDB2ArrayByClause("genericdatacontainer", "gdc_obj_id", "gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'search' AND gdc_content = '" . $f_search . "'", "", "", "");
|
|
if (count($tmpArray) > 0) :
|
|
$whereClauseJobId .= " jb.jb_id IN (" . implode(",", $tmpArray) . ") OR ";
|
|
endif;
|
|
|
|
$whereClauseExtended = "";
|
|
if ($f_stationBasedSearch && ($parSearchByRemarkEnabled == "1" || $parSearchByAddressEnabled == "1")) :
|
|
if ($parSearchByRemarkEnabled == "1") :
|
|
$whereClauseExtended .= " OR tr.tr_remark LIKE '%" . $f_search . "%' ";
|
|
endif;
|
|
if ($parSearchByAddressEnabled == "1") :
|
|
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
$whereClauseExtended .= " OR ad.ad_street LIKE '%" . $f_search . "%'";
|
|
$whereClauseExtended .= " OR ad.ad_zipcode LIKE '%" . $f_search . "%'";
|
|
$whereClauseExtended .= " OR ad.ad_city LIKE '%" . $f_search . "%' ";
|
|
endif;
|
|
|
|
// if (!is_numeric($f_search)) :
|
|
if ($fromDateRange != "") :
|
|
$whereClause .= "jb.jb_ordertime >= '$fromDateRange' AND ";
|
|
endif;
|
|
if ($toDateRange != "") :
|
|
$whereClause .= "jb.jb_ordertime <= '$toDateRange' AND ";
|
|
endif;
|
|
$numOfStationSearchs++;
|
|
if ($numOfStationSearchs == 1) :
|
|
$statusMessage = getLngt("Bitte beachten: Die Suche ist eingeschränkt auf den angegebenen Zeitraum!");
|
|
endif;
|
|
// endif;
|
|
endif;
|
|
|
|
if ($f_stationBasedSearch) :
|
|
$whereClause .= "( " . $whereClauseJobId . " tr.tr_commission_no LIKE '%" . $f_search . "%' OR tr.tr_comp LIKE '%" . $f_search . "%'" . $whereClauseExtended . ") AND ";
|
|
else :
|
|
$whereClause .= "( " . $whereClauseJobId . " tr.tr_commission_no LIKE '%" . $f_search . "%' OR tr.tr_comp LIKE '%" . $f_search . "%' OR tr2.tr_commission_no LIKE '%" . $f_search . "%' OR tr2.tr_comp LIKE '%" . $f_search . "%'" . $whereClauseExtended . ") AND ";
|
|
endif;
|
|
endif;
|
|
if ($f_stationBasedSearch) :
|
|
$whereClause .= "jb.jb_id = tr.jb_id AND tr.ad_id = ad.ad_id ";
|
|
else :
|
|
$whereClause .= "jb.jb_id = tr.jb_id AND tr.tr_sort = 1 AND tr.ad_id = ad.ad_id ";
|
|
endif;
|
|
|
|
// Price
|
|
// $whereClause .= " GROUP BY trs.jb_id ";
|
|
// $groupByClause = " GROUP BY trs.jb_id ";
|
|
// $groupByClause = " GROUP BY jb_id_group ";
|
|
$groupByClause = "";
|
|
|
|
if ($isMetaCs == "0") :
|
|
if ($doCscSubst) :
|
|
$whereClause1 = str_replace("<SUBST_CSC>", "jb.csc_id_payer", $whereClause);
|
|
$whereClause2 = " jb.csc_id_payer = '" . $parCscIdPayerCash . "' AND " . str_replace("<SUBST_CSC>", "jb.csc_id", $whereClause);
|
|
$sqlquery = "(". generateStatement($fieldClause,$fromClause,$whereClause1 . $groupByClause,"") . ") UNION (" . generateStatement($fieldClause,$fromClause,$whereClause2 . $groupByClause,"") . ") ORDER BY " . $orderByClause;
|
|
else :
|
|
$sqlquery = generateStatement($fieldClause,$fromClause,$whereClause . $groupByClause,$orderByClause);
|
|
endif;
|
|
else :
|
|
$whereClause1 = str_replace("<SUBST_01>", $whereClause1, $whereClause);
|
|
if ($doCscSubst) :
|
|
$whereClause1a = str_replace("<SUBST_CSC>", "jb.csc_id_payer", $whereClause1);
|
|
$whereClause1b = " jb.csc_id_payer = '" . $parCscIdPayerCash . "' AND " . str_replace("<SUBST_CSC>", "jb.csc_id", $whereClause1);
|
|
endif;
|
|
if ($jb_costcenter == "1") :
|
|
if ($doCscSubst) :
|
|
$sqlquery = "(". generateStatement($fieldClause,$fromClause,$whereClause1a . $groupByClause,"") . ") UNION (" . generateStatement($fieldClause,$fromClause,$whereClause1b . $groupByClause,"") . ") ORDER BY " . $orderByClause;
|
|
else :
|
|
$sqlquery = generateStatement($fieldClause,$fromClause,$whereClause1 . $groupByClause,$orderByClause);
|
|
endif;
|
|
else :
|
|
$whereClause2 = str_replace("<SUBST_01>", $whereClause2, $whereClause);
|
|
if ($doCscSubst) :
|
|
$whereClause2a = str_replace("<SUBST_CSC>", "jb.csc_id_payer", $whereClause2);
|
|
$whereClause2b = " jb.csc_id_payer = '" . $parCscIdPayerCash . "' AND " . str_replace("<SUBST_CSC>", "jb.csc_id", $whereClause2);
|
|
$sqlquery = "(" . generateStatement($fieldClause,$fromClause,$whereClause1a . $groupByClause,"") . ")"
|
|
. " UNION (" . generateStatement($fieldClause,$fromClause,$whereClause1b . $groupByClause,"") . ")"
|
|
. " UNION (" . generateStatement($fieldClause,$fromClause,$whereClause2a . $groupByClause,"") . ")"
|
|
. " UNION (" . generateStatement($fieldClause,$fromClause,$whereClause2b . $groupByClause,"") . ")"
|
|
. " ORDER BY " . $orderByClause;
|
|
else :
|
|
$sqlquery = "(". generateStatement($fieldClause,$fromClause,$whereClause1 . $groupByClause,"") . ") UNION (" . generateStatement($fieldClause,$fromClause,$whereClause2 . $groupByClause,"") . ") ORDER BY " . $orderByClause;
|
|
endif;
|
|
endif;
|
|
endif;
|
|
// echo $sqlquery . "<br>";
|
|
|
|
// FILTER-DEFINITIONS
|
|
// $filter_status = addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'job_status'",$jb_status);
|
|
$listStatusSelected_0 = "";
|
|
$listStatusSelected_1 = "";
|
|
$listStatusSelected_2 = "";
|
|
$listStatusSelected_9 = "";
|
|
if ($jb_status == "0") : $listStatusSelected_0 = "selected"; endif;
|
|
if ($jb_status == "1") : $listStatusSelected_1 = "selected"; endif;
|
|
if ($jb_status == "2") : $listStatusSelected_2 = "selected"; endif;
|
|
// if ($jb_status == "9") : $listStatusSelected_9 = "selected"; endif;
|
|
$filter_status = "";
|
|
// $filter_status .= "<option value=\"0\" " . $listStatusSelected_0 . ">Offene Aufträge</option>";
|
|
// $filter_status .= "<option value=\"9\" " . $listStatusSelected_9 . ">" . getLngt("Zuzuweisende Aufträge") . "</option>";
|
|
$filter_status .= "<option value=\"1\" " . $listStatusSelected_1 . ">" . getLngt("Laufende Aufträge") . "</option>";
|
|
$filter_status .= "<option value=\"2\" " . $listStatusSelected_2 . ">" . getLngt("Erledigte Aufträge") . "</option>";
|
|
|
|
$filter_cs_special = "";
|
|
if ($isMetaCs == "0") :
|
|
$filter_costcenter = addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'job_costcenter'",$jb_costcenter);
|
|
else :
|
|
$filter_costcenter = addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'job_cs_meta'",$jb_costcenter);
|
|
$filter_cs_special = addOptionsFromTable("customer", "cs_id", "cs_eid", "cs_eid", "cs_id_parent = '" . $customerId . "'", $jb_sel_cs, "");
|
|
endif;
|
|
|
|
// Searchfield
|
|
if ($globalParUseRelatedCustomer == "1") :
|
|
$filter_searchfield = getLngt("Auftrag/Komm.Nr./Firma/Kunde") . ($f_stationBasedSearch && $parSearchByRemarkEnabled == "1" ? getLngt("/Bemerkung") : "") . ($f_stationBasedSearch && $parSearchByAddressEnabled == "1" ? getLngt("/Adresse") : "") . ":\n";
|
|
else :
|
|
$filter_searchfield = getLngt("Auftrag") . ($f_stationBasedSearch && $parSearchByRemarkEnabled == "1" ? getLngt("/Bemerkung") : "") . ($f_stationBasedSearch && $parSearchByAddressEnabled == "1" ? getLngt("/Firma/Kunde/Komm.Nr./Adresse") : "") . ":\n";
|
|
endif;
|
|
$filter_searchfield .= "<input class=\"f8np1\" type=\"text\" name=\"f_search\" value=\"" . $f_search . "\" size=\"15\">\n";
|
|
$filter_searchfield .= " \n";
|
|
|
|
// Date-ranges
|
|
$filter_dateranges = " " . getLngt("von") . ":\n";
|
|
$filter_dateranges .= "<select name=\"day_from\" class=\"f8np1\" onchange=\"fillDateFieldsCheck(0, 'maincontent', 'jb_list', 'day_from', 'day_from', 'month_from', 'year_from', '', '', '', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
|
|
$filter_dateranges .= "<select name=\"month_from\" class=\"f8np1\" onchange=\"fillDateFieldsCheck(0, 'maincontent', 'jb_list', 'month_from', 'day_from', 'month_from', 'year_from', '', '', '', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
|
|
$filter_dateranges .= "<select name=\"year_from\" class=\"f8np1\" onchange=\"fillDateFieldsCheck(0, 'maincontent', 'jb_list', 'year_from', 'day_from', 'month_from', 'year_from', '', '', '', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
|
|
$filter_dateranges .= " " . getLngt("bis") . ":\n";
|
|
$filter_dateranges .= "<select name=\"day_to\" class=\"f8np1\" onchange=\"fillDateFieldsCheck(0, 'maincontent', 'jb_list', 'day_to', 'day_from', 'month_from', 'year_from', '', '', '', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
|
|
$filter_dateranges .= "<select name=\"month_to\" class=\"f8np1\" onchange=\"fillDateFieldsCheck(0, 'maincontent', 'jb_list', 'month_to', 'day_from', 'month_from', 'year_from', '', '', '', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
|
|
$filter_dateranges .= "<select name=\"year_to\" class=\"f8np1\" onchange=\"fillDateFieldsCheck(0, 'maincontent', 'jb_list', 'year_to', 'day_from', 'month_from', 'year_from', '', '', '', 'day_to', 'month_to', 'year_to', '', '', '')\"></select>\n";
|
|
$filter_dateranges .= "  ";
|
|
|
|
// 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,\"maincontent\",\"jb_list\",\"\",\"day_from\",\"month_from\",\"year_from\",\"\",\"\",\"\");\n";
|
|
$js_date .= " setDateTimeFields(\"maincontent\",\"jb_list\",".$day_from.",".$month_from.",".$year_from.", \"\", \"\", \"day_from\", \"month_from\", \"year_from\", \"\", \"\", \"\");\n";
|
|
$js_date .= " fillDateFields(1,\"maincontent\",\"jb_list\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
|
|
$js_date .= " setDateTimeFields(\"maincontent\",\"jb_list\",".$day_to.",".$month_to.",".$year_to.", \"\", \"\", \"day_to\", \"month_to\", \"year_to\", \"\", \"\", \"\");\n";
|
|
$js_date .= "}\n";
|
|
$js_date .= "-->\n";
|
|
$js_date .= "</script>\n";
|
|
|
|
|
|
// Send request to database
|
|
if ($jb_status == "2") :
|
|
getDb2Connection(); // Try to connect request server because of performance
|
|
$result = $db2->query($sqlquery);
|
|
else :
|
|
$result = $db->query($sqlquery);
|
|
endif;
|
|
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
|
|
|
|
|
|
// Header and entries of the list
|
|
$targetPath = "customer"; // used in following include-file
|
|
$jobEditPath = "jobs2";
|
|
if ($jb_status == "2") :
|
|
// $summationField = "business_volume";
|
|
$summationField = "business_volume_with_toll";
|
|
endif;
|
|
$jobEditParameter = "&customerId=" . $customerId . "&cscIdRoot=" . $cscIdRoot . "&cscIdActual=" . $cscIdActual;
|
|
include_once ("../include/jb_list_defineoutput.inc.php");
|
|
|
|
if ($jb_status == "2" && $sumOfSummationField != 0) :
|
|
$tableBody .= "<tr><td class=\"f8np1_red\">" . getLngt("EINTRÄGE:") . "</td><td class=\"f8np1_red\" align=\"left\" colspan=\"" . (count($fieldsArray) - 1) . "\">" . $rowCounter . "</td></tr>\n";
|
|
$tableBody .= "<tr><td class=\"f8np1_red\">" . getLngt("GESAMTSUMME:") . "</td><td class=\"f8np1_red\" align=\"left\" colspan=\"" . (count($fieldsArray) - 1) . "\">" . number_format(round($sumOfSummationField,2), 2, ",", ".") . "</td></tr>\n";
|
|
endif;
|
|
|
|
$result->free();
|
|
|
|
$reload_status = "1";
|
|
if ($jb_status == "2" || $jb_status == "10" || $jb_status == "ALL") :
|
|
$reload_status = "0";
|
|
endif;
|
|
endif;
|
|
|
|
|
|
// wenn MASK_AUTO_REFRESH == 0, dann wird die Kurierliste dynamisch (bei Aufruf) aufgebaut
|
|
// wenn MASK_AUTO_REFRESH == 1, dann wird die Kurierliste statisch (hier) aufgebaut
|
|
if (MASK_AUTO_REFRESH == "1"):
|
|
include_once("../jobs/job_courier.inc.php");
|
|
endif;
|
|
$auto_refresh = MASK_AUTO_REFRESH;
|
|
$cr_id_order_list_out = "var cs_jbedit_cr = 1;\n var MASK_COURIER_SORT_BY_OCCUPIED = \"\";\n" . $cr_id_order_list . $cr_id_order_list2 . $vht_id_str_js . getCustomerCouriers($db, $customerId) . "when = \"" . date("H:i") . "\";\n";
|
|
?>
|
|
|
|
<html>
|
|
<head>
|
|
<title><?php echo $pageTitel ?></title>
|
|
|
|
<link rel="stylesheet" type="text/css" href="../css/reset.css">
|
|
<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 src="../include/lib_global.js" type="text/javascript"></script>
|
|
|
|
<script src="../include/lib_courier.8.js" type="text/javascript"></script>
|
|
|
|
<?php echo $js_date ?>
|
|
|
|
<script type="text/javascript">
|
|
<!--
|
|
// NAVIGATION
|
|
<?php echo $jsMenuOut; ?>
|
|
|
|
var checkReloadCnt = 0;
|
|
|
|
var refreshStatus = <?php echo $reload_status ?>;
|
|
|
|
function setRefreshStatus() {
|
|
if (document.forms[0].refreshStatusCheckbox.checked == true) {
|
|
refreshStatus = 1;
|
|
startTimeout();
|
|
} else {
|
|
refreshStatus = 0;
|
|
}
|
|
}
|
|
|
|
var auto_refresh = "<?php echo $auto_refresh ?>";
|
|
|
|
function startTimeout()
|
|
{
|
|
self.setTimeout("startReload()", 60000);
|
|
}
|
|
|
|
function startReload()
|
|
{
|
|
if (refreshStatus == 1) {
|
|
checkReload();
|
|
// self.location.reload();
|
|
finishPage();
|
|
}
|
|
}
|
|
|
|
function checkReload()
|
|
{
|
|
if (++checkReloadCnt == 300)
|
|
{
|
|
// alert("Der Server antwortet nicht. Bitte überprüfen Sie\n" +
|
|
// "ob Sie noch mit dem Internet verbunden sind!");
|
|
// self.close();
|
|
}
|
|
else
|
|
self.setTimeout("checkReload()", 100);
|
|
}
|
|
|
|
// Opens a new (popup-)window with specified parameters
|
|
function popupWindow(url,title,config) {
|
|
popup = window.open(url,title,config);
|
|
}
|
|
|
|
function finishPage() {
|
|
for(i=0;i<document.forms[0].jb_costcenter_select.length;++i) {
|
|
if (document.forms[0].jb_costcenter_select.options[i].selected == true) {
|
|
document.forms[0].jb_costcenter.value=document.forms[0].jb_costcenter_select.options[i].value;
|
|
}
|
|
};
|
|
for(i=0;i<document.forms[0].jb_status_select.length;++i) {
|
|
if (document.forms[0].jb_status_select.options[i].selected == true) {
|
|
document.forms[0].jb_status.value=document.forms[0].jb_status_select.options[i].value;
|
|
}
|
|
};
|
|
document.forms[0].submit();
|
|
};
|
|
|
|
function makeStorno(jb_id,jb_permanent,cr_id,jbp_id) {
|
|
// if (jbStornoCscId > 0 || jbStornoEmpUsrType == "2") {
|
|
if (true) {
|
|
if (confirm('<?php echo getLngt("Auftrag") ?> ' + jb_id + ' <?php echo getLngt("wirklich stornieren?") ?>')) {
|
|
document.forms[0].jb_id_storno.value = jb_id;
|
|
document.forms[0].f_act.value = 'storno';
|
|
finishPage();
|
|
};
|
|
} else {
|
|
alert('<?php echo getLngt("Dieser Auftrag kann nicht storniert werden!") ?>');
|
|
};
|
|
};
|
|
|
|
// *** Courier-List ***
|
|
|
|
function setCourier(jb_id,cr_sid,cr_availabletime_reset) {
|
|
document.forms[0].f_jb_id.value = jb_id;
|
|
document.forms[0].f_cr_sid.value = cr_sid;
|
|
if (cr_availabletime_reset != '1') {cr_availabletime_reset = '0';};
|
|
document.forms[0].f_cr_availabletime_reset.value = cr_availabletime_reset;
|
|
document.forms[0].f_act.value = 'setCourier';
|
|
finishPage();
|
|
};
|
|
|
|
var cr_id_order_list = new Array();
|
|
<?php echo $cr_id_order_list_out ?>
|
|
-->
|
|
</script>
|
|
<noscript>
|
|
<center>
|
|
<b><br><?php echo getLngt("JavaScript ist nicht verfügbar. Bitte aktivieren Sie JavaScript<br><br>in Ihrem Browser, damit diese Seite ordnungsgemäß funktioniert!") ?></b><br><br>
|
|
</center>
|
|
</noscript>
|
|
</head>
|
|
<body onLoad="<?php echo $phpCurrentNavigationOnLoad ?>initForm();startTimeout();displayStatusMessage()">
|
|
|
|
<?php echo $phpMenuOut ?>
|
|
<?php echo $phpReducedMenuOut ?>
|
|
<?php echo $phpPageTitelOut ?>
|
|
|
|
<div class="maincontent" name="maincontent" id="maincontent">
|
|
|
|
<form name="jb_list" action="../customer/jb_list.php" method="post">
|
|
<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="empIdMaster" value="<?php echo ec($empIdMaster) ?>">
|
|
<input type="hidden" name="dbhistory" value="<?php echo ec($dbhistory) ?>">
|
|
<input type="hidden" name="jb_costcenter" value="1">
|
|
<input type="hidden" name="jb_status" value="">
|
|
<input type="hidden" name="jb_sort" value="<?php echo $jb_sort ?>">
|
|
<input type="hidden" name="f_cr_availabletime_reset" value="">
|
|
<input type="hidden" name="numOfStationSearchs" value="<?php echo $numOfStationSearchs ?>">
|
|
<?php echo $phpCurrentNavigationInputHidden ?>
|
|
<input type="hidden" name="deactivateMenu" value="<?php echo ec($deactivateMenu) ?>">
|
|
|
|
<?php echo htmlDivLineSpacer("10px"); ?>
|
|
|
|
<div class="f12bp1_blue">
|
|
<?php echo getLngt("Aufträge der Kostenstelle") ?>: <?php echo $cscNameActual ?>
|
|
</div>
|
|
<?php echo htmlDivLineSpacer("10px"); ?>
|
|
|
|
|
|
<!-- SELECTION-FILTERS -->
|
|
|
|
<!-- Refresh status of the list -->
|
|
<div style="float:left;">
|
|
<input type="checkbox" name="refreshStatusCheckbox" value="<?php echo $reload_status ?>" onClick="javascript:setRefreshStatus();"> <?php echo getLngt("Refresh") ?>
|
|
<script type="text/javascript">
|
|
if (refreshStatus == 1) {
|
|
document.forms[0].refreshStatusCheckbox.checked = true;
|
|
} else {
|
|
document.forms[0].refreshStatusCheckbox.checked = false;
|
|
}
|
|
</script>
|
|
|
|
</div>
|
|
|
|
<!-- Costcenter -->
|
|
<div style="float:left;">
|
|
<select class="f8np1" name="jb_costcenter_select">
|
|
<?php echo $filter_costcenter ?>
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<!-- Customer selection if current customer is a meta customer -->
|
|
<?php if ($isMetaCs == "1") : ?>
|
|
<div style="float:left;">
|
|
<select class="f8np1" name="jb_sel_cs">
|
|
<option value="">---</option>
|
|
<?php echo $filter_cs_special ?>
|
|
</select>
|
|
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Job-status -->
|
|
<div style="float:left;">
|
|
<select class="f8np1" name="jb_status_select">
|
|
<?php echo $filter_status ?>
|
|
</select>
|
|
</div>
|
|
|
|
<div style="float:left;">
|
|
<?php echo $filter_dateranges ?>
|
|
</div>
|
|
|
|
<div style="float:left;">
|
|
<?php echo $filter_searchfield ?>
|
|
</div>
|
|
|
|
<!-- Search-Button -->
|
|
<?php echo defineButtonType10(getLngt("Anzeigen"), "action_show", "finishPage();", "80", "left", "2") ?>
|
|
<div>
|
|
<?php echo getLngt("Etappenliste") ?> <input type="checkbox" name="f_stationBasedSearch[]" value="1" <?php if ($f_stationBasedSearch) : echo "checked"; endif; ?>>
|
|
</div>
|
|
<?php echo htmlDivLineSpacer("10px", "", "left"); ?>
|
|
|
|
<!-- TABLE OF JOBS -->
|
|
<div>
|
|
<table width="95%" align="left" cellspacing="0" cellpadding="0" vspace="0" hspace="0">
|
|
<tr>
|
|
<td>
|
|
|
|
</td>
|
|
</tr>
|
|
<?php echo $tableHeader ?>
|
|
|
|
<?php echo $tableBody ?>
|
|
<tr>
|
|
<td>
|
|
|
|
</td>
|
|
<tr>
|
|
</table>
|
|
</div>
|
|
|
|
<input type="hidden" name="jb_id_storno" value="">
|
|
<input type="hidden" name="f_cr_sid" value="">
|
|
<input type="hidden" name="f_jb_id" value="2">
|
|
<input type="hidden" name="f_act" value="">
|
|
|
|
</form>
|
|
</div>
|
|
</body>
|
|
</html>
|