" if does not exist if (!existsEntry("parameter",array("par_key", "FDS_CUSTOMER_ENABLED_CS_" . $g_cs_id))) : insertStmt("parameter", array("par_key", "FDS_CUSTOMER_ENABLED_CS_" . $g_cs_id, "par_value", "1")); endif; // Generate new vehicle in the "Fast Disposition Structure" or update (renew) if it does exist // generateVehicleFastDispositionStructure($crvhId, "2", $g_cs_id); // Write logdata into log database $tmpFields = getFieldsValueFromId("couriervehicle", "crvh_id", $crvhId, array("cr_id","crvh_sid")); writeToLogDB("126",$hq_id,"",$usr_id,$tmpFields[0],$tmpFields[1],$g_cs_id,""); TA("C"); TA("E"); // $cmd = "php ../tools/setFDSVehicleAvailability_HTG.php tornado"; // system($cmd . " > /dev/null &"); $cmd = "php ../tools/setFDSVehicleAvailability_HTG.php tornado " . $crvhId . " &"; $cmdOutput = null; exec($cmd, $cmdOutput); else : $statusMessage = getLngt("Es existiert schon ein Eintrag zwischen dem Fahrzeug und diesem Kunden!"); endif; endif; // Compute week day and day times string if ($f_act == "updateVehicleCustomer" && $crvhId != "" && $csIdUpdate != "") : // Overwrite array of day times if does exist for this special customer if (existsEntry("metatype",array("mt_type", "day_time", "mt_objtype", "cs", "mt_objid", $csIdUpdate))) : $dayTimes = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $csIdUpdate . "'", "", "mt_sort", ""); $dayTimeNames = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $csIdUpdate . "'", "", "mt_sort", ""); $dayTimesLen = count($dayTimes); endif; /* // For displaying checkboxes only $activatedWeekDays = ""; if (is_array($f_csvh_day_times)) : $f_csvh_day_times_len = count($f_csvh_day_times); // Values from the checkboxes if ($f_csvh_day_times_len > 0) : $weekDayArray = array(); for ($i = 0; $i < $f_csvh_day_times_len; $i++) : $tmpArray = spliti("_", $f_csvh_day_times[$i]); // [0] = cs_id, [1] = weekday, [2] = day time if ($tmpArray[0] == $csIdUpdate) : if ($weekDayArray[$tmpArray[1]] == "") : $weekDayArray[$tmpArray[1]] = $tmpArray[1] . "=" . $tmpArray[2]; else : $weekDayArray[$tmpArray[1]] .= "," . $tmpArray[2]; endif; endif; endfor; $activatedWeekDays = implode("|", $weekDayArray); endif; endif; */ $activatedWeekDays = ""; $weekDayArray = array(); for ($k = 0; $k < $dayTimesLen; $k++) : for ($l = 0; $l < $weekDaysLen; $l++) : list($selVal) = getSecHttpVars("1", array("f_csvh_day_times_zone_" . $csIdUpdate . "_" . $weekDays[$l] . "_" . $dayTimes[$k])); if ($selVal != "") : if ($weekDayArray[$weekDays[$l]] == "") : $weekDayArray[$weekDays[$l]] = $weekDays[$l] . "=" . $dayTimes[$k] . "-" . $selVal; else : $weekDayArray[$weekDays[$l]] .= "," . $dayTimes[$k] . "-" . $selVal; endif; endif; endfor; endfor; $activatedWeekDays = implode("|", $weekDayArray); // Insert customervehicle updateStmt("customervehicle", "crvh_id", $crvhId, array("csvh_day_times", $activatedWeekDays), "cs_id = '" . $csIdUpdate . "'"); // Insert parameter "FDS_CUSTOMER_ENABLED_" if does not exist if (!existsEntry("parameter",array("par_key", "FDS_CUSTOMER_ENABLED_CS_" . $csIdUpdate))) : insertStmt("parameter", array("par_key", "FDS_CUSTOMER_ENABLED_CS_" . $csIdUpdate, "par_value", "1")); endif; // Update vehicle in the "Fast Disposition Structure" // generateVehicleFastDispositionStructure($crvhId, "2", $csIdUpdate); // Write logdata into log database $tmpFields = getFieldsValueFromId("couriervehicle", "crvh_id", $crvhId, array("cr_id","crvh_sid")); writeToLogDB("128",$hq_id,"",$usr_id,$tmpFields[0],$tmpFields[1],$csIdUpdate,""); // $cmd = "php ../tools/setFDSVehicleAvailability_HTG.php tornado"; // system($cmd . " > /dev/null &"); $cmd = "php ../tools/setFDSVehicleAvailability_HTG.php tornado " . $crvhId . " &"; $cmdOutput = null; exec($cmd, $cmdOutput); endif; // Remove vehiclecustomer if ($f_act == "removeVehicleCustomer" && $crvhId != "") : TA("B"); // Entries to be deleted? $fieldsLength = count($f_del_customer_id); if ($fieldsLength > 0 && $f_del_customer_id[0] != "") : for ($i = 0; $i < $fieldsLength; $i++) : deleteStmt("customervehicle","crvh_id = " . $crvhId . " AND cs_id = " . $f_del_customer_id[$i]); // Resort the sort value of the favoured couriers of the customer $sqlquery = "SELECT cs_id, crvh_id FROM customervehicle WHERE cs_id = " . $f_del_customer_id[$i] . " AND csvh_relation = '1' ORDER BY csvh_sort"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $sortCounter = 1; while ($row = $result->fetch_assoc()): $tmpCsId = $row["cs_id"]; $tmpCrvhId = $row["crvh_id"]; updateStmt("customervehicle", "cs_id", $tmpCsId, array("csvh_sort", $sortCounter),"crvh_id = '" . $tmpCrvhId . "' AND csvh_relation = '1'"); $sortCounter++; endwhile; $result->free(); // Remove vehicle from the "Fast Disposition Structure" for a special customer only generateVehicleFastDispositionStructure($crvhId, "0", $f_del_customer_id[$i]); // Remove jobs of this vehicle for the selected customer from FDS $vhdJbIdsToRemoveArray = getColVectorFromDB2ArrayByClause("vehicledisposition AS vhd, job AS jb, costcenter AS csc", "vhd.jb_id", "vhd.crvh_id = '" . $crvhId . "' AND vhd.jb_id = jb.jb_id AND jb.csc_id_related = csc.csc_id AND csc.cs_id = '" . $f_del_customer_id[$i] . "'", "", "", "DISTINCT"); $vhdJbIdsToRemoveArrayLen = count($vhdJbIdsToRemoveArray); if ($vhdJbIdsToRemoveArrayLen > 0) : updateStmt("vehicledisposition", "", "", array("jb_id", "0"), "jb_id IN (" . implode(",", $vhdJbIdsToRemoveArray) . ")"); endif; // Write logdata into log database $tmpFields = getFieldsValueFromId("couriervehicle", "crvh_id", $crvhId, array("cr_id","crvh_sid")); writeToLogDB("127",$hq_id,"",$usr_id,$tmpFields[0],$tmpFields[1],$f_del_customer_id[$i],""); endfor; else : $statusMessage = getLngt("Bitte markieren Sie zu löschende Verbindungen durch anklicken der jeweiligen Checkbox hinter dem Eintrag!"); endif; TA("C"); TA("E"); endif; // *************************************************************************** // * Get the vehicle-customer relations of a specified courier for selection * // *************************************************************************** $count = 0; if ($crvhId != "") : $sqlquery = getStmtCustomerVehicleRelation($crvhId, ""); $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $f_cmp_comp[$count] = $row["cmp_comp"]; $f_cmp_comp2[$count] = $row["cmp_comp2"]; $f_cs_id[$count] = $row["cs_id"]; $f_cs_eid[$count] = $row["cs_eid"]; $f_cs_hq_id[$count] = $row["hq_id"]; $f_csvh_relation[$count] = $row["csvh_relation"]; $f_csvh_day_times[$count] = $row["csvh_day_times"]; $f_csvh_description[$count] = $row["csvh_description"]; $count++; endwhile; $result->free(); endif; // Only for output $tmpFields = getFieldsValueFromId("couriervehicle", "crvh_id", $crvhId, array("cr_id","crvh_sid")); $tmp_cr_id = $tmpFields[0]; $tmp_crvh_sid = $tmpFields[1]; $tmp_usr_id = getFieldValueFromId("courier", "cr_id", $tmp_cr_id, "usr_id"); $tmpFields = getFieldsValueFromId("user","usr_id",$tmp_usr_id,array("usr_name","usr_firstname")); $tmp_usr_name = $tmpFields[0]; $tmp_usr_firstname = $tmpFields[1]; $title = getLngt("Einsatzmodalitäten bei Kunden von Fahrzeug:") . "  " . $tmp_crvh_sid . " [" . $tmp_usr_firstname . " " . $tmp_usr_name . "]"; // Output of the existing relations of the current selected area $customerOutput = ""; for ($j = 0; $j < $count; $j++) : // Overwrite array of day times if does exist for this special customer if (existsEntry("metatype",array("mt_type", "day_time", "mt_objtype", "cs", "mt_objid", $f_cs_id[$j]))) : $dayTimes = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $f_cs_id[$j] . "'", "", "mt_sort", ""); $dayTimeNames = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $f_cs_id[$j] . "'", "", "mt_sort", ""); else : $dayTimes = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = 'day_time' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", ""); $dayTimeNames = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'day_time' AND mt_objtype = '' AND mt_objid = '0'", "", "mt_sort", ""); endif; $dayTimesLen = count($dayTimes); $customerOutput .= $f_cmp_comp[$j] . "
"; if ($f_cmp_comp2[$j] != "") : $customerOutput .= $f_cmp_comp2[$j] . "
"; endif; $customerOutput .= $f_cs_eid[$j] . "  "; $imgName = "circle_red.jpg"; if ($f_csvh_relation[$j] == "1") : $imgName = "circle_green.jpg"; endif; $customerOutput .= "  "; $customerOutput .= "
"; $customerOutput .= $f_csvh_description[$j]; $customerOutput .= "
\n"; // Get day time values to be checked for the current customer regarding the current vehicle $dayTimesArrayOfTheWeek = getKeyValueArrayFromString($f_csvh_day_times[$j], "|", "="); $customerOutput .= "\n"; // Table header with names of the weekdays $customerOutput .= "\n"; $customerOutput .= "\n"; for ($l = 0; $l < $weekDaysLen; $l++) : $customerOutput .= "\n"; endfor; // Table body $customerOutput .= "\n"; for ($k = 0; $k < $dayTimesLen; $k++) : $customerOutput .= "\n"; $customerOutput .= "\n"; for ($l = 0; $l < $weekDaysLen; $l++) : $tmpDayTimes = $dayTimesArrayOfTheWeek[$l + 1]; $tmpDayTimesArray = spliti(",", $tmpDayTimes); /* // For displaying checkboxes only $tmpChecked = ""; if (!(array_search($dayTimes[$k], $tmpDayTimesArray) === FALSE)) : $tmpChecked = "checked"; endif; $customerOutput .= "\n"; */ // Select special zone for each day time of each week day $tmpSelectedValue = ""; $tmpDayTimesArrayLen = count($tmpDayTimesArray); for ($m = 0; $m < $tmpDayTimesArrayLen; $m++) : $tmp2 = spliti("-", $tmpDayTimesArray[$m]); if ($tmp2[0] == $dayTimes[$k]) : $tmpSelectedValue = $tmp2[1]; endif; endfor; $customerOutput .= "\n"; endfor; $customerOutput .= "\n"; endfor; $customerOutput .= "
" . " " . "" . $weekDayNames[$l] . "
" . $dayTimeNames[$k] . "" . "" . "\n"; $customerOutput .= " "; $customerOutput .= "
\n"; $customerOutput .= defineButtonType08(getLngt("Konfiguration speichern"), "action_update", "finishPage('updateVehicleCustomer', '" . $f_cs_id[$j] . "');", "240"); $customerOutput .= "

\n"; endfor; // Button to remove associations between courier and customer(s). Only show if at least one customer is associated to the current area. if ($count > 0) : $customerOutput .= "
\n"; $customerOutput .= defineButtonType10(getLngt("Markierte Verknüpfungen entfernen"), "action_remove", "finishPage('removeVehicleCustomer', '');", "240"); $customerOutput .= "

\n"; endif; if ($customerOutput == "") : $customerOutput = getLngt("Zur Zeit sind keine Verknüpfungen eingetragen!"); endif; ?> <?php echo $pageTitel ?>
>
>
 
 
>
name="f_relationStatus" value="0">
name="f_relationStatus" value="1" checked>