$currentDate) : $f_future_date_existing = $selDate; elseif ($selDate < $currentDate) : $f_act = ""; $f_future_date_existing = ""; $day_from = getDateTime("day"); $month_from = getDateTime("month"); $year_from = getDateTime("year"); $statusMessage = getLngt("Das Datum muss in der Zukunft liegen!"); endif; // Presently future dates are enabled for service mode "0" only (!!!!) // HARDCODED !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $futureDatesEnabled = true; if ($serviceMode != "0") : $futureDatesEnabled = false; $f_future_date_existing = ""; endif; // Restrictions regarding access rights $whereClauseRightsService = ""; if ($serviceMode == "0") : $parServiceRights = getParameterValue("0", "RIGHTS_TABLE_SERVICE", $hq_id); if ($parServiceRights == "") : $parServiceRights = getParameterValue("0", "RIGHTS_TABLE_SERVICE", "0"); endif; if ($parServiceRights != "") : $rightArr = getKeyValueArrayFromString($parServiceRights); $tmpKeys = array_keys($rightArr); $tmpKeysLen = count($tmpKeys); for ($i = 0; $i < $tmpKeysLen; $i++) : if (!authCheckEmployeeRights($emp_id, $rightArr[$tmpKeys[$i]])) : $whereClauseRightsService .= " AND srv_name != '" . $tmpKeys[$i] . "' "; endif; endfor; endif; endif; if ($srvDebug) : echo "serviceMode = " . $serviceMode . "
"; echo "futureDatesEnabled = " . $futureDatesEnabled . "
"; echo "day_from = " . $day_from . "
"; echo "month_from = " . $month_from . "
"; echo "year_from = " . $year_from . "
"; echo "selDate = " . $selDate . "
"; echo "currentDate = " . $currentDate . "
"; echo "currentTime = " . $currentTime . "
"; endif; if ($pageFirstCall == "" || ($f_chkbx_toggle == "" && $f_chkbx_toggle_cr == "")) : $pageFirstCall = 1; $f_chkbx_toggle = "service"; $f_chkbx_toggle_cr = ""; endif; $f_chkbx_toggle_checked = ""; if ($f_chkbx_toggle == "service") : $f_chkbx_toggle_checked = "checked"; endif; $f_chkbx_toggle_cr_checked = ""; if ($f_chkbx_toggle_cr == "service_cr") : $f_chkbx_toggle_cr_checked = "checked"; endif; // Price-mode or discount-mode if ($mode == "") : $mode = "price" ; endif; // General price/discount for all customers if ($csId == "") : $csId = "0" ; endif; // Check opener ONLY for output in target $htmlFormTarget = "target=\"\""; if ($opener == "1") : $htmlFormTarget = ""; endif; $cmpComp = ""; $cmpComp2 = ""; if ($csId != "0") : $cmpId = getFieldValueFromId("customer","cs_id",$csId,"cmp_id"); $tmpFields = getFieldsValueFromId("company","cmp_id",$cmpId,array("cmp_comp","cmp_comp2")); $cmpComp = $tmpFields[0]; $cmpComp2 = $tmpFields[1]; endif; // ORDER BY to be displayed if ($orderByService == "") : $orderByService = "srv_group, srv_sort" ; endif; if ($orderByServiceType == "") : $orderByServiceType = "srvt_group, srvt_name" ; endif; if ($orderByServiceCustomer == "") : $orderByServiceCustomer = "srvt.srvt_group, srvt.srvt_name" ; endif; // Check mandator state; if enabled (= 1) then differ between mandators, else set HQ_ID = 0 => same values for ALL mandators $currentHqId = $hq_id; if ($serviceMode >= "1") : $constHqId = getParameterValue("0", "MANDATOR_SERVICE2_ENABLED", $hq_id); else : $constHqId = getParameterValue("0", "MANDATOR_SERVICE_ENABLED", $hq_id); endif; if ($constHqId == "" || $constHqId == "0") : $currentHqId = "0"; endif; // *** Storing-processes *** // *** BEGIN *************** // Change name of a service if ($f_act == "save_service_change") : if ($f_service_id != "") : TA("B"); updateStmt("service", "srv_id", $f_service_id, array("srv_name", $f_service_change)); writeToLogDB("57",$hq_id,"",$usr_id,"","","","DBOP=Update_service|SRV_MODE=".$serviceMode); TA("C"); TA("E"); else : $statusMessage = getLngt("Der gewünschte Name existiert leider schon!"); endif; endif; // Insert new service if ($f_act == "save_service_new") : if ($f_service_new != "") : TA("B"); $tmpFields = array("srv_mode",$serviceMode,"hq_id",$currentHqId,"cs_id",$csId,"srv_name",$f_service_new); insertStmt("service",$tmpFields); writeToLogDB("58",$hq_id,"",$usr_id,"","","","DBOP=Insert_service|SRV_MODE=".$serviceMode); TA("C"); TA("E"); else : $statusMessage = getLngt("Vergeben Sie bitte einen Namen!"); endif; endif; // Change name of a servicetype if ($f_act == "save_servicetype_change") : if ($f_servicetype_id != "") : TA("B"); updateStmt("servicetype", "srvt_id", $f_servicetype_id, array("srvt_name", $f_servicetype_change)); writeToLogDB("59",$hq_id,"",$usr_id,"","","","DBOP=Update_servicetype|SRV_MODE=".$serviceMode); TA("C"); TA("E"); else : $statusMessage = getLngt("Der gewünschte Name existiert leider schon!"); endif; endif; // Insert new servicetype if ($f_act == "save_servicetype_new") : if ($f_servicetype_new != "") : TA("B"); $tmpFields = array("srvt_mode",$serviceMode,"hq_id",$currentHqId,"cs_id",$csId,"srvt_name",$f_servicetype_new); insertStmt("servicetype",$tmpFields); writeToLogDB("60",$hq_id,"",$usr_id,"","","","DBOP=Insert_servicetype|SRV_MODE=".$serviceMode); TA("C"); TA("E"); else : $statusMessage = getLngt("Vergeben Sie bitte einen Namen!"); endif; endif; // Removal of a service if ($f_act == "remove_service_single") : if ($f_service_id != "") : TA("B"); $tmpSrvName = getFieldValueFromId("service", "srv_id", $f_service_id, "srv_name"); deleteStmt("service","srv_id = " . $f_service_id); writeToLogDB("131",$hq_id,"",$usr_id,"","","","DBOP=Delete_service|SRV_MODE=".$serviceMode."|SRV_ID=".$f_service_id."|SRV_NAME=".$tmpSrvName); TA("C"); TA("E"); else : $statusMessage = getLngt("Eine Löschung konnte nicht erfolgen!"); endif; endif; // Removal of a service type if ($f_act == "remove_service_type_single") : if ($f_servicetype_id != "") : TA("B"); $tmpSrvtName = getFieldValueFromId("servicetype", "srvt_id", $f_servicetype_id, "srvt_name"); deleteStmt("servicetype","srvt_id = " . $f_servicetype_id); writeToLogDB("132",$hq_id,"",$usr_id,"","","","DBOP=Delete_servicetype|SRV_MODE=".$serviceMode."|SRVT_ID=".$f_servicetype_id."|SRVT_NAME=".$tmpSrvtName); TA("C"); TA("E"); else : $statusMessage = getLngt("Eine Löschung konnte nicht erfolgen!"); endif; endif; // *** END *************** // ***************************** // * Selection of all services * // ***************************** if ($csId > "0" && $serviceMode >= "1") : $sqlquery = "SELECT srv.srv_id, srv.srv_name, srv.srv_sort, srv.srv_group, srv.cs_id" . " FROM service AS srv, customerservice AS cssrv" . " WHERE srv.hq_id = '" . $currentHqId . "' AND srv.cs_id = '0' AND srv.srv_mode = '" . $serviceMode . "' AND" . " srv.srv_id = cssrv.srv_id AND cssrv.cs_id = '" . $csId . "'"; $sqlquery2 = "SELECT srv_id, srv_name, srv_sort, srv_group, cs_id" . " FROM service" . " WHERE hq_id = '" . $currentHqId . "' AND cs_id = '" . $csId . "' AND srv_mode = '" . $serviceMode . "'"; $sqlquery = "(" . $sqlquery . ") UNION (" . $sqlquery2 . ") ORDER BY " . $orderByService; else : // Default $sqlquery = "SELECT srv_id, srv_name, srv_sort, srv_group, cs_id" . " FROM service" . " WHERE hq_id = '" . $currentHqId . "' AND cs_id = '0' AND srv_mode = '" . $serviceMode . "'" . $whereClauseRightsService . " ORDER BY " . $orderByService; endif; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $services = array(); $count = 0; while ($row = $result->fetch_assoc()): $count++; $services["id"][$count] = $row["srv_id"]; $services["name"][$count] = $row["srv_name"]; $services["sort"][$count] = $row["srv_sort"]; $services["group"][$count] = $row["srv_group"]; $services["cs_id"][$count] = $row["cs_id"]; endwhile; $result->free(); // ********************************* // * Selection of all servicetypes * // ********************************* if ($csId > "0" && $serviceMode >= "1") : $sqlquery = "SELECT srvt.srvt_id, srvt.srvt_name, srvt.srvt_group, srvt.cs_id" . " FROM servicetype AS srvt, customerservicetype AS cssrvt" . " WHERE srvt.hq_id = '" . $currentHqId . "' AND srvt.cs_id = '0' AND srvt.srvt_mode = '" . $serviceMode . "' AND" . " srvt.srvt_id = cssrvt.srvt_id AND cssrvt.cs_id = '" . $csId . "'"; $sqlquery2 = "SELECT srvt_id, srvt_name, srvt_group, cs_id" . " FROM servicetype" . " WHERE hq_id = '" . $currentHqId . "' AND cs_id = '" . $csId . "' AND srvt_mode = '" . $serviceMode . "'"; // $sqlquery = "(" . $sqlquery . ") UNION (" . $sqlquery2 . ")"; $sqlquery = "(" . $sqlquery . ") UNION ALL (" . $sqlquery2 . ") ORDER BY " . $orderByServiceType; else : // Default $sqlquery = "SELECT srvt_id, srvt_name, srvt_group, cs_id" . " FROM servicetype" . " WHERE hq_id = '" . $currentHqId . "' AND cs_id = '0' AND srvt_mode = '" . $serviceMode . "'" . " ORDER BY " . $orderByServiceType; endif; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $serviceTypes = array(); $count = 0; while ($row = $result->fetch_assoc()): $count++; $serviceTypes["id"][$count] = $row["srvt_id"]; $serviceTypes["name"][$count] = $row["srvt_name"]; $serviceTypes["group"][$count] = $row["srvt_group"]; $serviceTypes["cs_id"][$count] = $row["cs_id"]; endwhile; $result->free(); // Check for moving future data in "servicehistory" being current now to "servicecustomer", depending on "hq_id" function moveSrvh2Srvc () { global $db, $PHP_SELF, $srvDebug; global $currentTime, $currentDate, $services, $serviceTypes, $hq_id, $csId, $vhtId; global $srvc_price, $srvc_discount, $srvc_cr_price, $srvc_cr_discount; $srvIdArr = $services["id"]; $srvtIdArr = $serviceTypes["id"]; $srvIdArrLen = count($srvIdArr); $srvtIdArrLen = count($srvtIdArr); if ($srvDebug) : echo "servicesLen = " . $srvIdArrLen . "
"; echo "serviceTypesLen = " . $srvtIdArrLen . "
"; echo "
"; print_r($srvIdArr); echo "
"; echo "
"; print_r($srvtIdArr); echo "

"; endif; for ($i = 1; $i <= $srvIdArrLen; $i++) : $srvId = $srvIdArr[$i]; for ($j = 1; $j <= $srvtIdArrLen; $j++) : $srvtId = $srvtIdArr[$j]; // Check existence of the row in "servicecustomer" if (!existsEntry("servicecustomer",array("srv_id",$srvId,"srvt_id",$srvtId,"hq_id",$hq_id,"cs_id",$csId))) : // Generate empty row insertStmt("servicecustomer",array("srv_id",$srvId,"srvt_id",$srvtId,"hq_id",$hq_id,"cs_id",$csId)); endif; // Get youngest "servicehistory" value // Call with "4" returns array($price, $crPrice, $discount, $crDiscount) $currSrvhVal = getServiceValues($srvId, $srvtId, $csId, $hq_id, $currentTime, "4", $vhtId); if ($currSrvhVal[0] == "" || $currSrvhVal[0] == "0") : $currSrvhVal[0] = "0.00"; endif; if ($currSrvhVal[1] == "" || $currSrvhVal[1] == "0") : $currSrvhVal[1] = "0.00"; endif; if ($currSrvhVal[2] == "" || $currSrvhVal[2] == "0") : $currSrvhVal[2] = "0.00"; endif; if ($currSrvhVal[3] == "" || $currSrvhVal[3] == "0") : $currSrvhVal[3] = "0.00"; endif; $srvhValidFromDate = $currSrvhVal[4]; // Get "servicecustomer" value $srvc_price = ""; $srvc_discount = ""; $srvc_cr_price = ""; $srvc_cr_discount = ""; // Init globals getDbFieldValues("servicecustomer",array("srvc_price","srvc_cr_price","srvc_discount","srvc_cr_discount","srvc_modify"),array("srv_id",$srvId,"srvt_id",$srvtId,"hq_id",$hq_id,"cs_id",$csId)); if ($srvc_price == "" || $srvc_price == "0") : $srvc_price = "0.00"; endif; if ($srvc_cr_price == "" || $srvc_cr_price == "0") : $srvc_cr_price = "0.00"; endif; if ($srvc_discount == "" || $srvc_discount == "0") : $srvc_discount = "0.00"; endif; if ($srvc_cr_discount == "" || $srvc_cr_discount == "0") : $srvc_cr_discount = "0.00"; endif; if ($srvDebug) : if ($srvc_price != $currSrvhVal[0] || $srvc_cr_price != $currSrvhVal[1] || $srvc_discount != $currSrvhVal[2] || $srvc_cr_discount != $currSrvhVal[3]) : echo ""; else : echo ""; endif; echo "[".$srvId."][".$srvtId."] = [".$srvc_price." / ".$srvc_cr_price." / ".$srvc_discount." / ".$srvc_cr_discount . "][".$currSrvhVal[0]." / ".$currSrvhVal[1]." / ".$currSrvhVal[2]." / ".$currSrvhVal[3] . "]"; echo ""; echo "

"; endif; // Move current values from "servicehistory" to "servicecustomer" $whereClause = "srv_id = '" . $srvId . "' AND srvt_id = '" . $srvtId . "' AND hq_id = '" . $hq_id . "' AND cs_id = '" . $csId . "'"; if ($srvc_price != $currSrvhVal[0]) : $sqlStmt = "UPDATE servicecustomer SET srvc_price = '" . $currSrvhVal[0] . "' WHERE " . $whereClause; if ($srvDebug) : echo $sqlStmt . "
"; endif; $res = $db->query($sqlStmt); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; endif; if ($srvc_cr_price != $currSrvhVal[1]) : $sqlStmt = "UPDATE servicecustomer SET srvc_cr_price = '" . $currSrvhVal[1] . "' WHERE " . $whereClause; if ($srvDebug) : echo $sqlStmt . "
"; endif; $res = $db->query($sqlStmt); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; endif; if ($srvc_discount != $currSrvhVal[2]) : $sqlStmt = "UPDATE servicecustomer SET srvc_discount = '" . $currSrvhVal[2] . "' WHERE " . $whereClause; if ($srvDebug) : echo $sqlStmt . "
"; endif; $res = $db->query($sqlStmt); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; endif; if ($srvc_cr_discount != $currSrvhVal[3]) : $sqlStmt = "UPDATE servicecustomer SET srvc_cr_discount = '" . $currSrvhVal[3] . "' WHERE " . $whereClause; if ($srvDebug) : echo $sqlStmt . "
"; endif; $res = $db->query($sqlStmt); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; endif; if ($srvDebug) : echo "
"; endif; endfor; endfor; } // Check for (future) values to be moved from "servicehistory" to "servicecustomer" because future date becomes current date if ($f_future_date_existing == "") : // REMOVE IF MORE THAN ONE FUTURE DATE WILL EXIST !!!! moveSrvh2Srvc(); endif; // *************************************** // * Selection of servicecustomer-values * // *************************************** if ($f_future_date_existing == "") : $sqlquery = "SELECT srvc.srv_id, srvc.srvt_id, srvc.cs_id, srvc.srvc_price, srvc.srvc_discount, srvc.srvc_cr_price, srvc.srvc_cr_discount" . " FROM service AS srv, servicetype AS srvt, servicecustomer AS srvc" . " WHERE srvc.srv_id = srv.srv_id" . " AND srv.srv_mode = '" . $serviceMode . "'" . " AND srvc.srvt_id = srvt.srvt_id" . " AND srvt.srvt_mode = '" . $serviceMode . "'" . " AND srvc.cs_id = " . $csId . " AND srvc.hq_id = " . $currentHqId . " ORDER BY " . $orderByServiceCustomer; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $servicePrices = array(); $serviceDiscounts = array(); $serviceCrPrices = array(); $serviceCrDiscounts = array(); while ($row = $result->fetch_assoc()): $servicePrices[$row["srv_id"]][$row["srvt_id"]] = $row["srvc_price"]; $serviceDiscounts[$row["srv_id"]][$row["srvt_id"]] = $row["srvc_discount"]; $serviceCrPrices[$row["srv_id"]][$row["srvt_id"]] = $row["srvc_cr_price"]; $serviceCrDiscounts[$row["srv_id"]][$row["srvt_id"]] = $row["srvc_cr_discount"]; endwhile; $result->free(); else : // Get values for the selected future date $sqlqueryHistory = "SELECT srvh.srv_id, srvh.srvt_id, srvh.cs_id, srvh.srvh_price, srvh.srvh_discount, srvh.srvh_cr_price, srvh.srvh_cr_discount" . " FROM service AS srv, servicetype AS srvt, servicehistory AS srvh" . " WHERE srvh.srv_id = srv.srv_id" . " AND srv.srv_mode = '" . $serviceMode . "'" . " AND srvh.srvt_id = srvt.srvt_id" . " AND srvt.srvt_mode = '" . $serviceMode . "'" . " AND srvh.cs_id = " . $csId . " AND srvh.hq_id = " . $currentHqId . " AND LEFT(srvh.srvh_validfrom, 10) = '" . $f_future_date_existing . "'" . " ORDER BY " . $orderByServiceCustomer; $result = $db->query($sqlqueryHistory); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $servicePrices = array(); $serviceDiscounts = array(); $serviceCrPrices = array(); $serviceCrDiscounts = array(); while ($row = $result->fetch_assoc()): $servicePrices[$row["srv_id"]][$row["srvt_id"]] = $row["srvh_price"]; $serviceDiscounts[$row["srv_id"]][$row["srvt_id"]] = $row["srvh_discount"]; $serviceCrPrices[$row["srv_id"]][$row["srvt_id"]] = $row["srvh_cr_price"]; $serviceCrDiscounts[$row["srv_id"]][$row["srvt_id"]] = $row["srvh_cr_discount"]; endwhile; $result->free(); endif; // Number of entries $lenServices = count($services["id"]); $lenServiceTypes = count($serviceTypes["id"]); // ************************************************* // * Storing prices and discounts if requested * // * Using the results of the statements before!!! * // ************************************************* if ($f_act != "" && $f_act == "save") : TA("B"); for ($i = 1; $i <= $lenServiceTypes; $i++) : for ($j = 1; $j <= $lenServices; $j++) : // Define current service-id and service-type-id $srvCur = $services["id"][$j]; $srvtCur = $serviceTypes["id"][$i]; // Get current input-type-text-field with price-/dicount-value list ($newValueToBeStored) = getHttpVars(array("service_". $srvCur ."_" . $srvtCur)); if ($newValueToBeStored == "") : $newValueToBeStored = "0"; endif; list ($newCrValueToBeStored) = getHttpVars(array("service_cr_". $srvCur ."_" . $srvtCur)); if ($newCrValueToBeStored == "") : $newCrValueToBeStored = "0"; endif; // Allow float data with "." and "," $newValueToBeStored = str_replace (",", ".", $newValueToBeStored); $newCrValueToBeStored = str_replace (",", ".", $newCrValueToBeStored); if ($servicePrices[$srvCur][$srvtCur] == "") : $servicePrices[$srvCur][$srvtCur] = "0"; endif; if ($serviceDiscounts[$srvCur][$srvtCur] == "") : $serviceDiscounts[$srvCur][$srvtCur] = "0"; endif; if ($serviceCrPrices[$srvCur][$srvtCur] == "") : $serviceCrPrices[$srvCur][$srvtCur] = "0"; endif; if ($serviceCrDiscounts[$srvCur][$srvtCur] == "") : $serviceCrDiscounts[$srvCur][$srvtCur] = "0"; endif; if ($f_future_date_existing == "") : if ($mode == "price") : // Check for necessity to update or insert if ($servicePrices[$srvCur][$srvtCur] != $newValueToBeStored || $serviceCrPrices[$srvCur][$srvtCur] != $newCrValueToBeStored) : if (existsEntry("servicecustomer",array("srv_id",$srvCur,"srvt_id",$srvtCur,"hq_id",$currentHqId,"cs_id",$csId))) : $sqlStmt = "UPDATE servicecustomer SET srvc_price = $newValueToBeStored, srvc_cr_price = $newCrValueToBeStored" . " WHERE srv_id = $srvCur AND srvt_id = $srvtCur AND hq_id = $currentHqId AND cs_id = $csId"; $res = $db->query($sqlStmt); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; else : if ($newValueToBeStored != "0" || $newCrValueToBeStored != "0") : // Insert the new price $tmpFields = array("srv_id",$srvCur,"srvt_id",$srvtCur,"hq_id",$currentHqId,"cs_id",$csId,"srvc_price",$newValueToBeStored,"srvc_discount",$serviceDiscounts[$srvCur][$srvtCur],"srvc_cr_price",$newCrValueToBeStored,"srvc_cr_discount",$serviceCrDiscounts[$srvCur][$srvtCur]); insertStmt("servicecustomer",$tmpFields); endif; endif; // Insert current prices AND (!) discounts into the servicehistory $tmpFields = array("srv_id",$srvCur,"srvt_id",$srvtCur,"hq_id",$currentHqId,"cs_id",$csId,"usr_id",$currentSessionUsrId,"srvh_validfrom",$currentTime,"srvh_price",$newValueToBeStored,"srvh_discount",$serviceDiscounts[$srvCur][$srvtCur],"srvh_cr_price",$newCrValueToBeStored,"srvh_cr_discount",$serviceCrDiscounts[$srvCur][$srvtCur]); insertStmt("servicehistory",$tmpFields); $servicePrices[$srvCur][$srvtCur] = $newValueToBeStored; $serviceCrPrices[$srvCur][$srvtCur] = $newCrValueToBeStored; endif; else : // Check for necessity to update or insert if ($serviceDiscounts[$srvCur][$srvtCur] != $newValueToBeStored || $serviceCrDiscounts[$srvCur][$srvtCur] != $newCrValueToBeStored) : if (existsEntry("servicecustomer",array("srv_id",$srvCur,"srvt_id",$srvtCur,"hq_id",$currentHqId,"cs_id",$csId))) : // Update the new discount $sqlStmt = "UPDATE servicecustomer SET srvc_discount = $newValueToBeStored, srvc_cr_discount = $newCrValueToBeStored" . " WHERE srv_id = $srvCur AND srvt_id = $srvtCur AND hq_id = $currentHqId AND cs_id = $csId"; $res = $db->query($sqlStmt); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; else : if ($newValueToBeStored != "0" || $newCrValueToBeStored != "0") : // Insert the new discount $tmpFields = array("srv_id",$srvCur,"srvt_id",$srvtCur,"hq_id",$currentHqId,"cs_id",$csId,"srvc_price",$servicePrices[$srvCur][$srvtCur],"srvc_discount",$newValueToBeStored,"srvc_cr_price",$serviceCrPrices[$srvCur][$srvtCur],"srvc_cr_discount",$newCrValueToBeStored); insertStmt("servicecustomer",$tmpFields); endif; endif; // Insert current prices AND (!) discounts into the servicehistory $tmpFields = array("srv_id",$srvCur,"srvt_id",$srvtCur,"hq_id",$currentHqId,"cs_id",$csId,"usr_id",$currentSessionUsrId,"srvh_validfrom",$currentTime,"srvh_price",$servicePrices[$srvCur][$srvtCur],"srvh_discount",$newValueToBeStored,"srvh_cr_price",$serviceCrPrices[$srvCur][$srvtCur],"srvh_cr_discount",$newCrValueToBeStored); insertStmt("servicehistory",$tmpFields); $serviceDiscounts[$srvCur][$srvtCur] = $newValueToBeStored; $serviceCrDiscounts[$srvCur][$srvtCur] = $newCrValueToBeStored; endif; endif; else : // Update values for selected future date in "servicehistory" only (!!!!) if ($mode == "price") : if (existsEntry("servicehistory",array("srv_id",$srvCur,"srvt_id",$srvtCur,"hq_id",$currentHqId,"cs_id",$csId,"srvh_validfrom",$f_future_date_existing . " 00:00:00"))) : $sqlStmt = "UPDATE servicehistory SET srvh_price = $newValueToBeStored, srvh_cr_price = $newCrValueToBeStored" . " WHERE srv_id = $srvCur AND srvt_id = $srvtCur AND hq_id = $currentHqId AND cs_id = $csId AND srvh_validfrom = '" . $f_future_date_existing . " 00:00:00'"; $res = $db->query($sqlStmt); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; else : if ($newValueToBeStored != "0" || $newCrValueToBeStored != "0") : // Insert the new price $tmpFields = array("srv_id",$srvCur,"srvt_id",$srvtCur,"hq_id",$currentHqId,"cs_id",$csId,"usr_id",$currentSessionUsrId,"srvh_price",$newValueToBeStored,"srvh_discount",$serviceDiscounts[$srvCur][$srvtCur],"srvh_cr_price",$newCrValueToBeStored,"srvh_cr_discount",$serviceCrDiscounts[$srvCur][$srvtCur],"srvh_validfrom",$f_future_date_existing . " 00:00:00"); insertStmt("servicehistory",$tmpFields); endif; endif; else : if (existsEntry("servicehistory",array("srv_id",$srvCur,"srvt_id",$srvtCur,"hq_id",$currentHqId,"cs_id",$csId,"srvh_validfrom",$f_future_date_existing . " 00:00:00"))) : $sqlStmt = "UPDATE servicehistory SET srvh_discount = $newValueToBeStored, srvh_cr_discount = $newCrValueToBeStored" . " WHERE srv_id = $srvCur AND srvt_id = $srvtCur AND hq_id = $currentHqId AND cs_id = $csId AND srvh_validfrom = '" . $f_future_date_existing . " 00:00:00'"; $res = $db->query($sqlStmt); if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; else: if ($newValueToBeStored != "0" || $newCrValueToBeStored != "0") : // Insert the new discount $tmpFields = array("srv_id",$srvCur,"srvt_id",$srvtCur,"hq_id",$currentHqId,"cs_id",$csId,"usr_id",$currentSessionUsrId,"srvh_price",$servicePrices[$srvCur][$srvtCur],"srvh_discount",$newValueToBeStored,"srvh_cr_price",$serviceCrPrices[$srvCur][$srvtCur],"srvh_cr_discount",$newCrValueToBeStored,"srvh_validfrom",$f_future_date_existing . " 00:00:00"); insertStmt("servicehistory",$tmpFields); endif; endif; endif; endif; // $f_future_date_existing endfor; endfor; TA("C"); TA("E"); endif; // Get values of the selected future date AFTER storing AGAIN (!!!) if ($f_future_date_existing != "") : // Get values for the selected future date // sqlqueryHistory = .... Statement see above .... $result = $db->query($sqlqueryHistory); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $servicePrices[$row["srv_id"]][$row["srvt_id"]] = $row["srvh_price"]; $serviceDiscounts[$row["srv_id"]][$row["srvt_id"]] = $row["srvh_discount"]; $serviceCrPrices[$row["srv_id"]][$row["srvt_id"]] = $row["srvh_cr_price"]; $serviceCrDiscounts[$row["srv_id"]][$row["srvt_id"]] = $row["srvh_cr_discount"]; endwhile; $result->free(); endif; // ***************************************************** // * Generation of the price-matrix or discount-matrix * // ***************************************************** // Table-header $serviceOutput = "\n"; $serviceOutput .= " \n"; // because of the following row-names for ($j = 1; $j <= $lenServices; $j++) : $serviceOutput .= "" . $services["name"][$j] . "\n"; endfor; $serviceOutput .= "\n"; // Table-data $remServiceTypeGroup = ""; for ($i = 1; $i <= $lenServiceTypes; $i++) : if ($remServiceTypeGroup != $serviceTypes["group"][$i]) : $remServiceTypeGroup = $serviceTypes["group"][$i]; $tmpGroupIdArray = spliti(",", substr($serviceTypes["group"][$i], 1, -1)); $tmpGroupIdArrayLen = count($tmpGroupIdArray); $tmpGroupName = ""; for ($k = 0; $k < $tmpGroupIdArrayLen; $k++) : if ($tmpGroupName != "") : $tmpGroupName .= "  /  "; endif; $tmpGroupName .= getFieldValueFromId("groups", "grp_id", $tmpGroupIdArray[$k], "grp_name"); endfor; $serviceOutput .= "" . $tmpGroupName . "\n"; // "$lenServices" because of number of cols endif; $serviceOutput .= "\n"; $serviceOutput .= "" . $serviceTypes["name"][$i] . "\n"; for ($j = 1; $j <= $lenServices; $j++) : // Define current service-id and service-type-id $srvCur = $services["id"][$j]; $srvtCur = $serviceTypes["id"][$i]; if ($mode == "price") : if ($servicePrices[$srvCur][$srvtCur] == "") : $servicePrices[$srvCur][$srvtCur] = "0"; endif; if ($serviceCrPrices[$srvCur][$srvtCur] == "") : $serviceCrPrices[$srvCur][$srvtCur] = "0"; endif; $serviceOutput .= "\n"; $serviceOutput .= "
\n"; $serviceOutput .= "
\n"; $serviceOutput .= "\n"; else : if ($serviceDiscounts[$srvCur][$srvtCur] == "") : $serviceDiscounts[$srvCur][$srvtCur] = "0"; endif; if ($serviceCrDiscounts[$srvCur][$srvtCur] == "") : $serviceCrDiscounts[$srvCur][$srvtCur] = "0"; endif; $serviceOutput .= "\n"; $serviceOutput .= "
\n"; $serviceOutput .= "
\n"; $serviceOutput .= "\n"; endif; endfor; $serviceOutput .= "\n"; endfor; // Future dates with prices and discounts $futureDatesArr = getColVectorFromDB2ArrayByClause("servicehistory", "LEFT(srvh_validfrom,10) AS srvh_validfrom", "hq_id = '" . $currentHqId . "' AND cs_id = '" . $csId . "' AND LEFT(srvh_validfrom,10) > '" . $currentDate . "'", "", "srvh_validfrom", "DISTINCT"); $futureDatesArrLen = count($futureDatesArr); if ($srvDebug) : // print_r($futureDatesArr); echo "
"; echo "futureDatesArrLen = " . $futureDatesArrLen . "
"; echo "f_future_date_existing = " . $f_future_date_existing . "
"; endif; // Output if ($mode == "price") : $title = getLngt("Allgemeine Preise"); else : $title = getLngt("Allgemeine Rabatte [in %]"); endif; if ($csId != "0") : if ($mode == "price") : $title = getLngt("Preise speziell für den Kunden") . " " . $cmpComp . " " . $cmpComp2; else : $title = getLngt("Rabatte speziell für den Kunden") . " " . $cmpComp . " " . $cmpComp2; endif; endif; $currentFrameName = ""; // Empty string for "main frame" // Date-ranges $filter_dateranges = "\n" . "\n" . "\n"; // Javascript-function as template only for $js_date = "\n"; ?> <?php echo $pageTitel; ?> displayStatusMessage();">
>
>    >      0) : ?>
>:
> = "1" && authCheckEmployeeRights($emp_id, "31")) : echo " "; endif; ?>
>   
> Neuer Preistyp:
>    
>:
> = "1" && authCheckEmployeeRights($emp_id, "31")) : echo " "; endif; ?>
>   
> Neuer Leistungstyp:
>