201\n","" . getLngt("Benutzername oder Passwort nicht spezifiziert.") . "\n"); else : $sqlquery = "SELECT usr_id, hq_id FROM user WHERE usr_account = '$usrName' AND usr_password = PASSWORD('$usrPassword') AND usr_type = '1'"; $result = $db->query($sqlquery); $usr_id = ""; $hq_id = ""; if (DB::isError($result)): $retArray = array("202","202\n","" . getLngt("Datenbankfehler") . "\n"); else: while ($row = $result->fetch_assoc()): $usr_id = $row["usr_id"]; $hq_id = $row["hq_id"]; endwhile; $result->free(); // Get the IP of the current client calling the page $currentClientIP = trim($_SERVER['REMOTE_ADDR']); if ($usr_id == '') : $retArray = array("203","203\n","" . getLngt("Benutzerdaten unbekannt.") . "\n"); writeToLogDB("52",$hq_id,"",$usr_id,"","","","ACCOUNT=" . $usrName . "|MESS=Login failed|IP=" . $currentClientIP); else : // Check for rights (cs=0, grp=11, rp=16) if (!(authCheckEmployeeRightsUser($usr_id, "0") && authCheckEmployeeRightsUser($usr_id, "11") && authCheckEmployeeRightsUser($usr_id, "16"))) : $retArray = array("205","205\n","" . getLngt("Berechtigungen fehlen.") . "\n"); writeToLogDB("52",$hq_id,"",$usr_id,"","","","ACCOUNT=" . $usrName . "|ACCESS=No rights|IP=" . $currentClientIP); else : // Check for "session hash" in remote instance metaobjects $sessionHash = ""; // Get current global number of THIS database instance $constGlobalDbInstNo = getParameterValue("0", "GLOBAL_UNIQUE_DB_INSTANCE_NO", "0", "0"); if ($constGlobalDbInstNo != "" && is_numeric($constGlobalDbInstNo)) : // Get database instance connection data of metaobject $constExtDbInst = getExternalMetaDbInst(); $db_conn = getDbConnectionSpecial($constExtDbInst, $dbname, $dblogin, $dbpassword); $tmpSqlQuery = "SELECT mo_hash FROM meta_object.metaobject WHERE mo_obj_type = 'usr' AND mo_id_ref_db = '" . $constGlobalDbInstNo . "' AND mo_obj_id = '" . $usr_id . "'"; $result = $db_conn->query($tmpSqlQuery); while ($row = $result->fetch_assoc()): $sessionHash = $row["mo_hash"]; endwhile; $result->free(); endif; if ($sessionHash != "") : $usrRealName = getFieldValueFromId("user", "usr_id", $usr_id, "usr_name"); $usrRealFirstname = getFieldValueFromId("user", "usr_id", $usr_id, "usr_firstname"); $hqName = ""; $hqMnemonic = ""; if ($hq_id > "0") : $hqName = getFieldValueFromId("headquarters", "hq_id", $hq_id, "hq_name"); $hqMnemonic = getFieldValueFromId("headquarters", "hq_id", $hq_id, "hq_mnemonic"); endif; $retArray = array("0", $usr_id, $hq_id, $sessionHash, $usrRealName, $usrRealFirstname, $hqName, $hqMnemonic); writeToLogDB("52",$hq_id,"",$usr_id,"","","","ACCOUNT=" . $usrName . "|MESS=Login ok|IP=" . $currentClientIP); else : $retArray = array("204","204\n","" . getLngt("Keine Session-ID für den Benutzer verfügbar.") . "\n"); writeToLogDB("52",$hq_id,"",$usr_id,"","","","ACCOUNT=" . $usrName . "|MESS=Login failed|IP=" . $currentClientIP); endif; endif; endif; endif; endif; return $retArray; } function checkAccess ($sessionHash) { global $db, $PHP_SELF; global $dbname, $dblogin, $dbpassword; global $usr_id, $hq_id; $retBool = false; if ($sessionHash != "") : // Get current global number of THIS database instance $constGlobalDbInstNo = getParameterValue("0", "GLOBAL_UNIQUE_DB_INSTANCE_NO", "0", "0"); if ($constGlobalDbInstNo != "" && is_numeric($constGlobalDbInstNo)) : // Get database instance connection data of metaobject $constExtDbInst = getExternalMetaDbInst(); $db_conn = getDbConnectionSpecial($constExtDbInst, $dbname, $dblogin, $dbpassword); $tmpSqlQuery = "SELECT mo_obj_id FROM meta_object.metaobject WHERE mo_obj_type = 'usr' AND mo_id_ref_db = '" . $constGlobalDbInstNo . "' AND mo_hash = '" . $sessionHash . "'"; $result = $db_conn->query($tmpSqlQuery); while ($row = $result->fetch_assoc()): $usr_id = $row["mo_obj_id"]; $retBool = true; endwhile; $result->free(); $hq_id = getFieldValueFromId("user", "usr_id", $usr_id, "hq_id"); endif; endif; return $retBool; } // ---------------------------------------------------------------------------------------------------------------- // ***************** // *** CONSTANTS *** // ***************** // // $calWeekDays = getColVectorFromDB2Array("metatype","mt_type","cal_week_days","mt_value","mt_sort"); // $calMonthNames = getColVectorFromDB2Array("metatype","mt_type","cal_months","mt_value","mt_sort"); // $calCurrentDayNumOfTheYear = date("z", mktime(0, 0, 0, $selMonth, $selDay, $selYear)); // 0 .. 365 // $calCurrentDayNumOfTheYear++; // Increment ... // $calCurrentDayNumOfTheWeek = date("w", mktime(0, 0, 0, $selMonth, $selDay, $selYear)); // 0 = Sunday, 1 = Monday, etc. // if ($calCurrentDayNumOfTheWeek == 0) : $calCurrentDayNumOfTheWeek = "7"; endif; // Reformat to 1 = Monday, ... , 7 = Sunday // $calCurrentWeekNum = date("W", mktime(0, 0, 0, $selMonth, $selDay, $selYear)); // Calendar week // $calCurrentWeekName = "KW"; // Calendar week name // $calMonthDays = array("31","28","31","30","31","30","31","31","30","31","30","31"); // $calCurrentYearIsLeapYear = date("L", mktime(0, 0, 0, $selMonth, $selDay, $selYear)); // if ($calCurrentYearIsLeapYear == "1") : $calMonthDays[1] = "29"; endif; // $minuteArray = array("00","05","10","15","20","25","30","35","40","45","50","55"); // // *********************** // *** Initialisations *** // *********************** // $messageReqRawData = file_get_contents('php://input'); getSecHttpVars("1", array("data")); $messageReq = $data; // $messageReq = mcDecode($messageReq); $currentTime = getDateTime("0"); $currentClientIP = trim($_SERVER['REMOTE_ADDR']); writeToFile("../log/mobile.log", $currentTime . " | " . $currentClientIP); // writeToFile("../log/mobile.log", $messageReqRawData); writeToFile("../log/mobile.log", $messageReq); writeToFile("../log/mobile.log", "-------------------------------------------------------------------------------------------"); // Check for POST raw data $functionName = getSingleTagContent($messageReq, "", ""); $userName = getSingleTagContent($messageReq, "", ""); $userPassword = getSingleTagContent($messageReq, "", ""); $userSession = getSingleTagContent($messageReq, "", ""); $selYear = getSingleTagContent($messageReq, "", ""); $selMonth = getSingleTagContent($messageReq, "", ""); $selWeek = getSingleTagContent($messageReq, "", ""); $selDay = getSingleTagContent($messageReq, "", ""); $apId = getSingleTagContent($messageReq, "", ""); $apText = getSingleTagContent($messageReq, "", ""); $execDatetime = getSingleTagContent($messageReq, "", ""); $endDatetime = getSingleTagContent($messageReq, "", ""); $usr_id = getSingleTagContent($messageReq, "", ""); $csId = getSingleTagContent($messageReq, "", ""); $csEid = getSingleTagContent($messageReq, "", ""); $hq_id = getSingleTagContent($messageReq, "", ""); $apCat1 = getSingleTagContent($messageReq, "", ""); $apCat2 = getSingleTagContent($messageReq, "", ""); $apCat3 = getSingleTagContent($messageReq, "", ""); $apCat4 = getSingleTagContent($messageReq, "", ""); $viewMode = getSingleTagContent($messageReq, "", ""); $actionMode = getSingleTagContent($messageReq, "", ""); $usrIdsParticipantsString = getSingleTagContent($messageReq, "", ""); $search = getSingleTagContent($messageReq, "", ""); $fromDateRange = getSingleTagContent($messageReq, "", ""); $toDateRange = getSingleTagContent($messageReq, "", ""); $rpId = getSingleTagContent($messageReq, "", ""); $rpType = getSingleTagContent($messageReq, "", ""); // 1="Verschiedenes", 2="Abschluss", 3="Angebotserstellung", ... 10="Konferenz/Seminar/Urlaub", ... $rpObjType = getSingleTagContent($messageReq, "", ""); // "cs", "cr", ... $rpObjId = getSingleTagContent($messageReq, "", ""); // e.g. "cs_id = 20001 = rpObjId || cr_id = 3333 = rpObjId" $rpConfidential = getSingleTagContent($messageReq, "", ""); // Kennzeichen für "Vertraulich" $crId = getSingleTagContent($messageReq, "", ""); $crEid = getSingleTagContent($messageReq, "", ""); $rpText = getSingleTagContent($messageReq, "", ""); // Decode $search = mcDecode($search); $userName = mcDecode($userName); $userPassword = mcDecode($userPassword); $apText = mcDecode($apText); $rpText = mcDecode($rpText); // Conversion $execDatetime = substr($execDatetime, 0, 4) . "-" . substr($execDatetime, 4, 2) . "-" . substr($execDatetime, 6, 2) . " " . substr($execDatetime, 8, 2) . ":" . substr($execDatetime, 10, 2) . ":" . substr($execDatetime, 12, 2); $endDatetime = substr($endDatetime, 0, 4) . "-" . substr($endDatetime, 4, 2) . "-" . substr($endDatetime, 6, 2) . " " . substr($endDatetime, 8, 2) . ":" . substr($endDatetime, 10, 2) . ":" . substr($endDatetime, 12, 2); // HARDCODED START ENVIRONMENT if (!isset($hq_id) || $hq_id == "") : $hq_id = ""; endif; // Empty for default $f_selUsrId = "0"; // No user selected if ($usr_id != "") : $f_selUsrId = $usr_id; endif; if (!isset($rpObjType) || $rpObjType == "") : $rpObjType = "cs"; endif; // "cs" default (for test) // "login" /* $functionName = "login"; $userName = "hh_testapp"; $userPassword = "testx12345"; $usrIdsParticipants = array(); */ // "getAppointmentsOfOneMonth" /* $functionName = "getAppointmentsOfOneMonth"; $usrIdsParticipants = array(); $userSession = "728af2fb27f319c4be373ea371e0aba4"; */ // "getCustomerList" /* $functionName = "getCustomerList"; $userSession = "728af2fb27f319c4be373ea371e0aba4"; $search = "ther"; */ // "getCustomerSpecial" /* $functionName = "getCustomerSpecial"; $userSession = "6651526b6fb8f29a00507de6a49ce30fec8956637a99787bd197eacd77acce5e2b4ead82e2c7758545e7af34ef7b58cbd41d8cd98f00b204e9800998ecf8427e"; $csId = "20815"; */ /* $functionName = "getReportList"; $userSession = "728af2fb27f319c4be373ea371e0aba4"; */ /* $functionName = "actionReport"; $userSession = "728af2fb27f319c4be373ea371e0aba4"; $actionMode = "insert"; $rpObjId = "20815"; // <=> $csEid = "HTHH41943"; $rpType = "3"; $rpText = "APP TEST INSERT !!!"; $rpConfidential = "1"; */ // Mode for output if requested if ($viewMode == "") : $viewMode = "1"; endif; // Customer if ($csEid != "" && $csId == "") : $csId = getFieldValueFromId("customer", "cs_eid", $csEid, "cs_id"); endif; if ($csEid == "" && $csId != "") : $csEid = getFieldValueFromId("customer", "cs_id", $csId, "cs_eid"); endif; // Report if ($rpObjType == "cs") : // Customer of the report if ($csEid != "" && $rpObjId == "") : $rpObjId = getFieldValueFromId("customer", "cs_eid", $csEid, "cs_id"); endif; if ($csEid == "" && $rpObjId != "") : $csEid = getFieldValueFromId("customer", "cs_id", $rpObjId, "cs_eid"); endif; elseif ($rpObjType == "cr") : // Customer of the report if ($crEid != "" && $rpObjId == "") : $rpObjId = getFieldValueFromId("courier", "cr_eid", $crEid, "cr_id"); endif; if ($crEid == "" && $rpObjId != "") : $crEid = getFieldValueFromId("courier", "cr_id", $rpObjId, "cr_eid"); endif; endif; // Mandator filter if ($f_hq_id == "") : $f_hq_id = array(); endif; if (count($f_hq_id) == 0) : array_push($f_hq_id, $hq_id); endif; if ($selYear == "") : $selYear = date("Y"); endif; if ($selMonth == "") : $selMonth = date("m"); endif; if ($selWeek == "") : $selWeek = date("W"); endif; if ($selDay == "") : $selDay = date("d"); endif; // Check ranges of time. All fields have to be set if ($f_hour == "" || $f_minute == "" || $f_hour_to == "" || $f_minute_to == "") : $f_hour = "00"; $f_minute = "00"; $f_hour_to = "23"; $f_minute_to = "59"; endif; $f_hour = pad($f_hour,2); $f_minute = pad($f_minute,2); $f_hour_to = pad($f_hour_to,2); $f_minute_to = pad($f_minute_to,2); // Time range if ($fromTimeRange == "" && $f_hour != "" && $f_minute != "") : $fromTimeRange = " " . $f_hour . ":" . $f_minute . ":00"; endif; if ($toTimeRange == "" && $f_hour != "" && $f_minute != "") : $toTimeRange = " " . $f_hour . ":" . $f_minute . ":59"; endif; // Date range if ($fromDateRange == "" && $f_year != "" && $f_month != "" && $f_day != "") : $fromDateRange = $f_year . "-" . pad($f_month,2) . "-" . pad($f_day,2) . $fromTimeRange; endif; if ($toDateRange == "" && $f_year_to != "" && $f_month_to != "" && $f_day_to != "") : $toDateRange = $f_year_to . "-" . pad($f_month_to,2) . "-" . pad($f_day_to,2) . $toTimeRange; endif; // Appointment categories if ($apCat1 == "") : $apCat1 = "1"; endif; // State: Business (default), private if ($apCat2 == "") : $apCat2 = "1"; endif; // Visibility: Participants, only author, everybody if ($apCat3 == "") : $apCat3 = "1"; endif; // Kind: Misc., Meeting, reminder, ... if ($apCat4 == "") : $apCat4 = "0"; endif; // Deadline monitoring on/off // Participants $usrIdsParticipants = array(); if ($usrIdsParticipantsString != "") : $usrIdsParticipants = spliti(",", $usrIdsParticipantsString); endif; // ***************** // *** FUNCTIONS *** // ***************** // // Gets the last calendar week (number) of a specified year // function calLastWeekNumofYear($selYear) {}; // Gets the first calendar week (number) of a specified month and year (calendar week of the 01.01.YYYY) // function calFirstWeekNumofMonth($selMonth, $selYear) {}; // Gets the first day (number) of a specified month and year // function calFirstDayNumOfMonth($selMonth, $selYear) {}; // Gets the first day (number) of the first calendar week of a specified year, it has to be a "Monday" // function calFirstDayNumOfFirstCalendarWeekOfYear($selYear) {}; // Gets the first day (number) of a specified calendar week and year // function calFirstDayNumOfWeek($selWeek, $selYear) {}; // Gets an array with days of a specified month (and year), where there is at least one appointment per day // function getDaysWithAppointments($selYear, $selMonth) {} // Modifies array according to the appointments starting and ending on different days // $apArray = Array with appointments of the time interval (week, month, ...) // $lowerRangeDate = Date of the beginning of the interval (week, month, ...) // $upperRangeDate = Date of the end of the interval (week, month, ...) // function modifyIntervalAppointments2SingleDayAppointments($apArray, $lowerRangeDate, $upperRangeDate) {} // Gets the appointments of one day // function getAppointmentsOfOneDay($selYear, $selMonth, $selDay, $csId = "") {} // Gets the appointments of one week // function getAppointmentsOfOneWeek($selWeek, $selYear, $selMonth, $selDay, $csId = "") {} // Gets the appointments of one month // function getAppointmentsOfOneMonth($selYear, $selMonth, $csId = "") {} // Gets the appointments of one year // function getAppointmentsOfOneYear($selYear, $csId = "") {} // Gets a customer list according to a special search string // function getCustomerList ($search) => defined in "inc_customer.inc.php" // Gets special data from a single customer // function getCustomerSpecial ($csId) => defined in "inc_customer.inc.php" // Gets ALL data from a special customer // function getCustomer ($cmpId) => defined in "inc_customer.inc.php" // Inserts a new customer // function insertCustomer ($csArray = array()) => defined in "inc_customer.inc.php" // // Gets the headline with the current day function getAppointmentHeader($viewMode, $selYear, $selMonth, $selDay, $selWeek) { global $calWeekDays,$calCurrentDayNumOfTheWeek, $calMonthNames, $calMonthDays; global $calCurrentWeekNum, $calCurrentWeekName, $calCurrentDayNumOfTheYear; $out = ""; // Daily output if ($viewMode == "1") : // Name of the week day (E.g.: "Donnerstag") --- Day, Name of the month and year (E.g.: "29 Juni 2006") --- calendar week (E.g.: "KW 26") $out .= $calWeekDays[$calCurrentDayNumOfTheWeek - 1] . ", " . $selDay . ". " . $calMonthNames[$selMonth - 1] . " " . $selYear . " " . $calCurrentWeekName . " " . $calCurrentWeekNum . " " . $calCurrentDayNumOfTheYear . getLngt(". Tag des Jahres"); endif; // Weekly output if ($viewMode == "2") : // Get the first day ("Monday") of the specified week and compute date interval of the week $firstDayOfWeek = calFirstDayNumOfWeek($selWeek, $selYear); $tmpDatetime = mktime(0, 0, 0, $firstDayOfWeek[1], $firstDayOfWeek[0] + 6, $firstDayOfWeek[2]); // calendar week (E.g.: "KW 26") $out .= $calCurrentWeekName . " " . $selWeek . " " . "[" . $selYear . "]" . " " . $firstDayOfWeek[0] . "." . $firstDayOfWeek[1] . "." . ($firstDayOfWeek[2] != date("Y", $tmpDatetime) ? $firstDayOfWeek[2] : "") . " - " . date("d", $tmpDatetime) . "." . date("m", $tmpDatetime) . "." . ($firstDayOfWeek[2] != date("Y", $tmpDatetime) ? date("Y", $tmpDatetime) : "") . " "; endif; // Monthly output if ($viewMode == "3") : // Name of the month and year (E.g.: "Juni 2006") $out .= $calMonthNames[$selMonth - 1] . " " . $selYear . " " . "01." . $selMonth . ". - " . $calMonthDays[$selMonth - 1] . "." . $selMonth . "."; endif; // Yearly output if ($viewMode == "4") : // Name of the year (E.g.: "2006") $out .= $selYear . " " . "01.01. - 31.12."; endif; return $out; } // Gets the title of the output table function getAppointmentTitle($viewMode) { $appointmentTitleArray = array(); // Daily output if ($viewMode == "1") : $appointmentTitleArray = array(getLngt("Beginn"), getLngt("Ende"), getLngt("Ersteller, Teilnehmer"), getLngt("Kunde"), getLngt("Aktion")); endif; // Weekly output if ($viewMode == "2") : $appointmentTitleArray = array(getLngt("Tag"), getLngt("Zeit"), getLngt("Ersteller, Teilnehmer"), getLngt("Beschreibung"), getLngt("Kunde")); endif; return $appointmentTitleArray; } // *********** // * Actions * // *********** // DB actions for an appointment function actionAppointment ($actionMode, $apId, $apText, $execDatetime, $endDatetime, $hq_id, $usr_id, $csId, $usrIdsParticipants, $apCat1, $apCat2, $apCat3, $apCat4) { global $db, $PHP_SELF; $opCode = "0"; $currentTime = getDateTime("0"); $sendPerMail = false; $apText = trim($apText); // $execDatetime = getDateTime("format",array($f_hour,$f_minute,0,$f_month,$f_day,$f_year),"Y-m-d H:i:s"); // $endDatetime = getDateTime("format",array($f_hour_to,$f_minute_to,0,$f_month_to,$f_day_to,$f_year_to),"Y-m-d H:i:s"); if (($actionMode == "insert" && $apText != "") || ($actionMode == "update" && $apId != "")) : if ($hq_id != "" && $usr_id != "") : if ($execDatetime != "" && $endDatetime != "" && $execDatetime <= $endDatetime) : $usrIdsParticipantsString = ""; if ($usrIdsParticipants != "" && count($usrIdsParticipants) > 0) : $usrIdsParticipantsString = "," . implode(",", $usrIdsParticipants) . ","; endif; if ($actionMode == "insert") : // Insert values insertStmt("phoenix_group.appointment", array("usr_id", $usr_id, "hq_id", $hq_id, "ap_category_1", $apCat1, "ap_category_2", $apCat2, "ap_category_3", $apCat3, "ap_category_4", $apCat4, "ap_participants", $usrIdsParticipantsString, "ap_text", $apText, "ap_execdate", $execDatetime, "ap_enddate", $endDatetime, "ap_modifytime", $currentTime, "cs_id", $csId)); $opCode = getLastInsertID(); elseif ($actionMode == "update") : // Update values updateStmt("phoenix_group.appointment", "ap_id", $apId, array("ap_category_1", $apCat1, "ap_category_2", $apCat2, "ap_category_3", $apCat3,"ap_category_4", $apCat4, "ap_participants", $usrIdsParticipantsString, "ap_text", $apText, "ap_execdate", $execDatetime, "ap_enddate", $endDatetime, "ap_modifytime", $currentTime, "cs_id", $csId)); $opCode = $apId; endif; $sendPerMail = true; endif; endif; elseif ($actionMode == "delete") : if ($apId != "") : deleteStmt("phoenix_group.appointment","ap_id = ".$apId); $opCode = $apId; $sendPerMail = true; endif; elseif ($actionMode == "confirm") : if ($apId != "" && $usr_id != "") : // Get confirmation string from appointment $tmpApConfirmed = getFieldValueFromId("phoenix_group.appointment", "ap_id", $apId, "ap_confirmed"); $tmpApConfirmed = substr($tmpApConfirmed,1,-1); // Remove commata from db-field $tmpApConfirmed = spliti(",", $tmpApConfirmed); // It has to be an array $j = array_search($usr_id, $tmpApConfirmed); if ($j === FALSE) : if (count($tmpApConfirmed) == 1 && trim($tmpApConfirmed[0] == "")) : $tmpApConfirmed = array($usr_id); else : array_push($tmpApConfirmed, $usr_id); endif; updateStmt("phoenix_group.appointment", "ap_id", $apId, array("ap_confirmed", "," . implode(",", $tmpApConfirmed) . ",")); $opCode = $apId; endif; endif; elseif ($actionMode == "finish") : if ($apId != "") : updateStmt("phoenix_group.appointment", "ap_id", $apId, array("ap_category_4", "2")); $opCode = $apId; endif; endif; if (false && $sendPerMail) : $mailAddresses = array(); // Get email address of the creator of the appointment $fromEmailAddress = getFieldValueFromId("user", "usr_id", $usr_id, "usr_email"); if (checkEmailFormat($fromEmailAddress)) : array_push($mailAddresses, $fromEmailAddress); endif; // Get data of the appointment if ($actionMode == "insert" || $actionMode == "update") : $tmpParticipants = $usrIdsParticipants; $tmpText = $apText; elseif ($actionMode == "delete") : $tmpExecDatetime = getFieldValueFromId("phoenix_group.appointment", "ap_id", $apId, "ap_execdate"); $tmpText = getFieldValueFromId("phoenix_group.appointment", "ap_id", $apId, "ap_text"); $tmpParticipants = getFieldValueFromId("phoenix_group.appointment", "ap_id", $apId, "ap_participants"); $tmpParticipants = substr($tmpParticipants,1,-1); // Remove commata from db-field $tmpParticipants = spliti(",", $tmpParticipants); // It has to be an array endif; $lenTmp = count($tmpParticipants); for ($i = 0; $i < $lenTmp; $i++) : $toEmailAddress = getFieldValueFromId("user", "usr_id", $tmpParticipants[$i], "usr_email"); if (checkEmailFormat($toEmailAddress)) : array_push($mailAddresses, $toEmailAddress); endif; endfor; $mailAddressesString = implode(",", $mailAddresses); $mailObj = new htmlMimeMail(); // Format mailtext $mailtext = ""; $mailtext .= ""; $mailtext .= "

"; $mailtext .= "
" . getLngt("Sehr geehrte Damen und Herren,") . "

"; $tmpText = str_replace("\r", '
', $tmpText); $mailtext .= "
" . $tmpText . "

"; $mailtext .= "
" . getLngt("Mit freundlichem Gruß!") . "

"; // Logo $logoName = getParameterValue("0", "IMG_LOGO_NAME", $hq_id); $logoHeight = getParameterValue("0", "IMG_LOGO_HEIGHT", $hq_id); $logoWidth = getParameterValue("0", "IMG_LOGO_WIDTH", $hq_id); if ($logoName != "" && $logoHeight != "" && $logoWidth != "") : $mailtext .= "


"; endif; $mailtext .= ""; $mailObj->setHtml($mailtext, null, "./"); $mailObj->setFrom($fromEmailAddress); // $mailObj->setCc($mailCcAddress); // $mailObj->setBcc($mailBccAddress); $mailObj->setSubject(getLngt("Termin abgesagt: ") . $tmpExecDatetime); $mailResult = $mailObj->send(array($mailAddressesString), 'smtp'); if (!$mailResult) : $statusMessage .= getLngt("Die Nachricht konnte nicht gesendet werden!") . " "; endif; $mailObj = NULL; endif; return $opCode; } // Gets a report list according to a special customer function getReportList ($fromDateRange, $toDateRange, $rpObjType = "cs", $rpObjId = "", $rpType = "") { global $db, $PHP_SELF; global $f_hq_id; $retArray = array(); if (false) : // $retArray = array("301","301\n","" . getLngt("Ein Suchbegriff wurde nicht eingegeben!") . "\n"); else : // Get status of the customer according to being meta customer $isMeta = "0"; $csParentIdArray = array(); if ($rpType == "cs" && $rpObjId != "" && is_numeric($rpObjId)) : if (existsEntry("customer",array("cs_id_parent",$rpObjId))) : $isMeta = "1"; $csParentIdArray = getColVectorFromDB2Array("customer","cs_id_parent",$rpObjId,"cs_id",""); array_push($csParentIdArray, $rpObjId); // meta customer inclusive endif; endif; $sqlquery = getReportListStatement ($fromDateRange, $toDateRange, $rpObjType, $rpObjId, $rpType, $isMeta, $csParentIdArray); $result = $db->query($sqlquery); if (DB::isError($result)): $retArray = array("202","202\n","" . getLngt("Datenbankfehler") . "\n"); else: while ($row = $result->fetch_assoc()): $retArray[] = array($row["rp_id"], $row["rp_reporttype"], $row["rp_text"], $row["rp_confidential"], $row["rp_createtime"], $row["usr_id"], $row["usr_name"], $row["usr_firstname"], $row["usr_phone"], $row["eid"], $row["cmp_comp"], $row["cmp_comp2"], $row["hq_id"], $row["hq_name"]); endwhile; $result->free(); endif; endif; return $retArray; } // DB actions for an report function actionReport ($actionMode, $rpId, $rpType, $rpObjType = "cs", $rpObjId, $rpText, $rpConfidential = "0", $hq_id, $usr_id) { global $db, $PHP_SELF; $opCode = "0"; $currentTime = getDateTime("0"); $sendPerMail = false; $rpText = trim($rpText); /* echo "actionMode: " . $actionMode . "
"; echo "rpId: " . $rpId . "
"; echo "rpType: " . $rpType . "
"; echo "rpObjType: " . $rpObjType . "
"; echo "rpObjId: " . $rpObjId . "
"; echo "rpText: " . $rpText . "
"; echo "rpConfidential: " . $rpConfidential . "
"; echo "hq_id: " . $hq_id . "
"; echo "usr_id: " . $usr_id . "
"; */ /* writeToFile("../log/mobile.log", "-----------------------------"); writeToFile("../log/mobile.log", "actionMode: " . $actionMode); writeToFile("../log/mobile.log", "rpId: " . $rpId); writeToFile("../log/mobile.log", "rpType: " . $rpType); writeToFile("../log/mobile.log", "rpObjType: " . $rpObjType); writeToFile("../log/mobile.log", "rpObjId: " . $rpObjId); writeToFile("../log/mobile.log", "rpText: " . $rpText); writeToFile("../log/mobile.log", "rpConfidential: " . $rpConfidential); writeToFile("../log/mobile.log", "hq_id: " . $hq_id); writeToFile("../log/mobile.log", "usr_id: " . $usr_id); */ if (($actionMode == "insert" && $rpText != "") || ($actionMode == "update" && $rpId != "")) : if ($hq_id != "" && $usr_id != "") : if ($actionMode == "insert") : if ($rpObjId != "" && $rpObjType != "") : if ($rpText != "") : // Insert values insertStmt("phoenix_group.report_process", array("usr_id", $usr_id, "hq_id", $hq_id, "rp_reporttype", $rpType, "rp_text", $rpText, "rp_createtime", $currentTime, "rp_objId", $rpObjId, "rp_objtype", $rpObjType, "rp_confidential", $rpConfidential)); $opCode = getLastInsertID(); endif; endif; elseif ($actionMode == "update") : // Update values if ($rpId != "" && $rpText != "") : updateStmt("phoenix_group.report_process", "rp_id", $rpId, array("rp_reporttype", $rpType, "rp_text", $rpText, "rp_confidential", $rpConfidential)); $opCode = $apId; endif; endif; endif; elseif ($actionMode == "delete") : if ($rpId != "") : deleteStmt("phoenix_group.report_process","rp_id = ".$rpId); $opCode = $rpId; endif; endif; return $opCode; } // ------------------------------------------------------------------------------------------------------ // ************** // * XML Output * // ************** $retVal = ""; $xmlOut = ""; $xmlNoErrOut .= "0\nOK\n"; $xmlErrOut .= "100\nCurrently not implemented.\n"; if ($functionName == "login" || checkAccess($userSession)) : if ($transactionHandle != "") : // $xmlOut .= "" . $transaction_no . "\n"; endif; $xmlOut .= "\n"; if (($hq_id != "" && is_numeric($hq_id)) || $functionName == "login") : if ($functionName != "") : if (function_exists($functionName) || $functionName == "getApEnvironment") : if ($functionName == "login") : $retVal = call_user_func_array($functionName, array($userName, $userPassword)); // Check user data if ($retVal[0] != "0") : $xmlOut .= $retVal[1] . $retVal[2]; else : $usr_id = $retVal[1]; $hq_id = $retVal[2]; $xmlOut .= $xmlNoErrOut; $xmlOut .= "" . $retVal[3] . "\n"; $xmlOut .= "" . $hq_id . "\n"; $xmlOut .= "\n"; $xmlOut .= "" . $retVal[7] . "\n"; $xmlOut .= "" . $usr_id . "\n"; $xmlOut .= "\n"; $xmlOut .= "\n"; endif; elseif ($functionName == "getApEnvironment") : if ($retVal[0] != "0") : $xmlOut .= $xmlNoErrOut; // Appointment categories for ($j = 1; $j <= 4; $j++) : $tmpApCatArray = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'appointment_category_" . $j . "'", "mt_sort", "mt_sort"); $tmpKeysArray = array_keys($tmpApCatArray); $tmpKeysArrayLen = count($tmpKeysArray); $xmlOut .= "\n"; for ($i = 0; $i < $tmpKeysArrayLen; $i++) : $xmlOut .= "\n"; $xmlOut .= " \n"; $xmlOut .= "\n"; endfor; $xmlOut .= "\n"; endfor; // Participants if ($hq_id != "") : $sqlquery = "SELECT usr_id, usr_firstname, usr_name FROM user WHERE usr_type = '1' AND hq_id = '" . $hq_id . "'"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: [$sqlquery]" . $result->getMessage()); $xmlOut .= "\n"; while ($row = $result->fetch_assoc()): $xmlOut .= "\n"; $xmlOut .= " \n"; $xmlOut .= " \n"; $xmlOut .= "\n"; endwhile; $result->free(); $xmlOut .= "\n"; endif; // Report types $tmpApCatArray = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'report_type'", "mt_sort", "mt_sort"); $tmpKeysArray = array_keys($tmpApCatArray); $tmpKeysArrayLen = count($tmpKeysArray); $xmlOut .= "\n"; for ($i = 0; $i < $tmpKeysArrayLen; $i++) : $xmlOut .= "\n"; $xmlOut .= " \n"; $xmlOut .= "\n"; endfor; $xmlOut .= "\n"; endif; elseif ($functionName == "calLastWeekNumofYear") : $retVal = call_user_func_array($functionName, array($selYear)); // Gets the last calendar week (number) of a specified year $xmlOut .= $xmlErrOut; elseif ($functionName == "calFirstWeekNumofMonth") : $retVal = call_user_func_array($functionName, array($selMonth, $selYear)); // Gets the first calendar week (number) of a specified month and year (calendar week of the 01.01.YYYY) $xmlOut .= $xmlErrOut; elseif ($functionName == "calFirstDayNumOfMonth") : $retVal = call_user_func_array($functionName, array($selMonth, $selYear)); // Gets the first day (number) of a specified month and year $xmlOut .= $xmlErrOut; elseif ($functionName == "calFirstDayNumOfFirstCalendarWeekOfYear") : $retVal = call_user_func_array($functionName, array($selYear)); // Gets the first day (number) of the first calendar week of a specified year, it has to be a "Monday" $xmlOut .= $xmlErrOut; elseif ($functionName == "calFirstDayNumOfWeek") : $retVal = call_user_func_array($functionName, array($selWeek, $selYear)); // Gets the first day (number) of a specified calendar week and year $xmlOut .= $xmlErrOut; elseif ($functionName == "getDaysWithAppointments") : $retVal = call_user_func_array($functionName, array($selYear, $selMonth)); // Gets an array with days of a specified month (and year), where there is at least one appointment per day $xmlOut .= $xmlErrOut; elseif ($functionName == "modifyIntervalAppointments2SingleDayAppointments") : $retVal = call_user_func_array($functionName, array($apArray, $lowerRangeDate, $upperRangeDate)); // Modifies array according to the appointments starting and ending on different days $xmlOut .= $xmlErrOut; elseif ($functionName == "getAppointmentsOfOneDay" || $functionName == "getAppointmentsOfOneWeek" || $functionName == "getAppointmentsOfOneMonth" || $functionName == "getAppointmentsOfOneYear") : if ($functionName == "getAppointmentsOfOneDay") : $retVal = call_user_func_array($functionName, array($selYear, $selMonth, $selDay, $csId)); // Gets the appointments of one day elseif ($functionName == "getAppointmentsOfOneWeek") : $retVal = call_user_func_array($functionName, array($selWeek, $selYear, $selMonth, $selDay, $csId)); // Gets the appointments of one week elseif ($functionName == "getAppointmentsOfOneMonth") : $retVal = call_user_func_array($functionName, array($selYear, $selMonth, $csId)); // Gets the appointments of one month elseif ($functionName == "getAppointmentsOfOneYear") : $retVal = call_user_func_array($functionName, array($selYear, $csId)); // Gets the appointments of one year endif; $retValLen = count($retVal); if ($retValLen > 0) : $xmlOut .= "\n"; $xmlOut .= "\n"; $tmpRemYear = ""; $tmpRemMonth = ""; $tmpRemDay = ""; $tmpApNewYearBool = false; $tmpApNewMonthBool = false; $tmpApNewDayBool = false; for ($i = 0; $i < $retValLen; $i++) : $tmpApYear = substr($retVal[$i][2],0,4); $tmpApMonth = substr($retVal[$i][2],5,2); $tmpApDay = substr($retVal[$i][2],8,2); // Closing TAGs if ($tmpRemDay != "" && $tmpRemDay != $tmpApDay) : $xmlOut .= "\n"; $xmlOut .= "\n"; endif; if ($tmpRemMonth != "" && $tmpRemMonth != $tmpApMonth) : $xmlOut .= "\n"; $xmlOut .= "\n"; endif; // if ($tmpRemYear != "" && $tmpRemYear != $tmpApYear) : // ... // endif; // Opening TAGs if ($tmpRemYear == "" || $tmpRemYear != $tmpApYear) : $tmpRemYear = $tmpApYear; $xmlOut .= "" . $tmpApYear . "\n"; endif; if ($tmpRemMonth == "" || $tmpRemMonth != $tmpApMonth) : $tmpRemMonth = $tmpApMonth; $tmpApNewMonthBool = true; $xmlOut .= "\n"; $xmlOut .= "" . $tmpApMonth . "\n"; $xmlOut .= "\n"; endif; if ($tmpRemDay == "" || $tmpRemDay != $tmpApDay) : $tmpRemDay = $tmpApDay; $tmpApNewDayBool = true; $xmlOut .= "\n"; $xmlOut .= "" . $tmpApDay . "\n"; $xmlOut .= "\n"; endif; $xmlOut .= "\n"; $xmlOut .= "\n"; $xmlOut .= "" . $retVal[$i][2] . "\n"; $xmlOut .= "" . $retVal[$i][3] . "\n"; $xmlOut .= "\n"; $xmlOut .= "\n"; $xmlOut .= "" . $retVal[$i][7] . "\n"; $xmlOut .= "" . $retVal[$i][8] . "\n"; $xmlOut .= "" . $retVal[$i][9] . "\n"; $xmlOut .= "\n"; $xmlOut .= "\n"; if (false) : $xmlOut .= "" . $retVal[$i][12] . "\n"; else : $tmpParticipantsIDs = $retVal[$i][12]; // Remove commas at the beginning and at the end if do exist if (substr($tmpParticipantsIDs, 0, 1) == ",") : $tmpParticipantsIDs = substr($tmpParticipantsIDs, 1); endif; if (substr($tmpParticipantsIDs, -1) == ",") : $tmpParticipantsIDs = substr($tmpParticipantsIDs, 0, strlen($tmpParticipantsIDs)-1); endif; $xmlOut .= "\n"; if ($tmpParticipantsIDs != "") : $tmpParticipantsArray = spliti(",", $tmpParticipantsIDs); $tmpParticipantsArrayLen = count($tmpParticipantsArray); for ($j = 0; $j < $tmpParticipantsArrayLen; $j++) : $usrRealName = getFieldValueFromId("user", "usr_id", $tmpParticipantsArray[$j], "usr_name"); $usrRealFirstname = getFieldValueFromId("user", "usr_id", $tmpParticipantsArray[$j], "usr_firstname"); $xmlOut .= "\n"; $xmlOut .= " \n"; $xmlOut .= " \n"; $xmlOut .= "\n"; endfor; endif; $xmlOut .= "\n"; endif; $xmlOut .= "" . $retVal[$i][13] . "\n"; $xmlOut .= "\n"; $xmlOut .= "\n"; $xmlOut .= "" . $retVal[$i][16] . "\n"; $xmlOut .= "" . $retVal[$i][17] . "\n"; $xmlOut .= "" . $retVal[$i][18] . "\n"; $xmlOut .= "" . $retVal[$i][19] . "\n"; $xmlOut .= "" . $retVal[$i][20] . "\n"; $xmlOut .= "" . $retVal[$i][21] . "\n"; $xmlOut .= "\n"; endfor; // Final closing TAGs if ($tmpApNewDayBool) : $xmlOut .= "\n"; $xmlOut .= "\n"; endif; if ($tmpApNewMonthBool) : $xmlOut .= "\n"; $xmlOut .= "\n"; endif; $xmlOut .= "\n"; $xmlOut .= "\n"; endif; elseif ($functionName == "getAppointmentHeader") : $retVal = call_user_func_array($functionName, array($viewMode, $selYear, $selMonth, $selDay, $selWeek)); // Gets the headline with the current day $xmlOut .= $xmlErrOut; elseif ($functionName == "getAppointmentTitle") : $retVal = call_user_func_array($functionName, array($viewMode)); // Gets the title of the output table $xmlOut .= $xmlErrOut; elseif ($functionName == "actionAppointment") : $retVal = call_user_func_array($functionName, array($actionMode, $apId, $apText, $execDatetime, $endDatetime, $hq_id, $usr_id, $csId, $usrIdsParticipants, $apCat1, $apCat2, $apCat3, $apCat4)); // DB actions for an appointment $xmlOut .= "\n"; $xmlOut .= "\n"; $xmlOut .= "" . $actionMode . "\n"; $xmlOut .= "" . $apId . "\n"; $xmlOut .= "" . $retVal . "\n"; $xmlOut .= "\n"; $xmlOut .= "\n"; elseif ($functionName == "getCustomerList") : $retVal = call_user_func_array($functionName, array($search)); // Gets the customer list $retValLen = count($retVal); if (!is_array($retVal[0]) && $retVal[0] != "0") : $xmlOut .= $retVal[1] . $retVal[2]; else : // if ($retValLen > 0) : $xmlOut .= "\n"; for ($i = 0; $i < $retValLen; $i++) : $xmlOut .= "\n"; // $xmlOut .= " " . $retVal[$i][1] . "\n"; $xmlOut .= " " . $retVal[$i][2] . "\n"; $xmlOut .= " \n"; $xmlOut .= " \n"; $xmlOut .= " \n"; $xmlOut .= " \n"; $xmlOut .= " " . $retVal[$i][7] . "\n"; $xmlOut .= " " . $retVal[$i][8] . "\n"; // $xmlOut .= " \n"; // $xmlOut .= " " . $retVal[$i][10] . "\n"; // $xmlOut .= " " . $retVal[$i][11] . "\n"; $xmlOut .= " \n"; $xmlOut .= "\n"; endfor; $xmlOut .= "\n"; // endif; endif; elseif ($functionName == "getCustomerSpecial") : $retVal = call_user_func_array($functionName, array($csId)); // Gets a single customer $retValLen = count($retVal); if (!is_array($retVal[0]) && $retVal[0] != "0") : $xmlOut .= $retVal[1] . $retVal[2]; else : // if ($retValLen > 0) : $xmlOut .= "\n"; for ($i = 0; $i < $retValLen; $i++) : $xmlOut .= "\n"; $xmlOut .= " " . $retVal[$i][1] . "\n"; $xmlOut .= " " . $retVal[$i][2] . "\n"; $xmlOut .= " \n"; $xmlOut .= " \n"; $xmlOut .= " \n"; $xmlOut .= " \n"; $xmlOut .= " " . $retVal[$i][7] . "\n"; $xmlOut .= " " . $retVal[$i][8] . "\n"; $xmlOut .= " \n"; $xmlOut .= " " . $retVal[$i][10] . "\n"; $xmlOut .= " " . $retVal[$i][11] . "\n"; $xmlOut .= " \n"; $xmlOut .= "\n"; endfor; $xmlOut .= "\n"; // endif; endif; elseif ($functionName == "getReportList") : $retVal = call_user_func_array($functionName, array($fromDateRange, $toDateRange, $rpObjType, $rpObjId, $rpType)); // Gets the report list $retValLen = count($retVal); if (!is_array($retVal[0]) && $retVal[0] != "0") : $xmlOut .= $retVal[1] . $retVal[2]; else : // if ($retValLen > 0) : $xmlOut .= "\n"; for ($i = 0; $i < $retValLen; $i++) : $xmlOut .= "\n"; $xmlOut .= " " . $retVal[$i][1] . "\n"; $xmlOut .= " \n"; $xmlOut .= " " . $retVal[$i][3] . "\n"; $xmlOut .= " " . $retVal[$i][4] . "\n"; $xmlOut .= " " . $retVal[$i][5] . "\n"; $xmlOut .= " \n"; $xmlOut .= " \n"; $xmlOut .= " " . $retVal[$i][8] . "\n"; $xmlOut .= " " . $retVal[$i][9] . "\n"; $xmlOut .= " \n"; $xmlOut .= " \n"; $xmlOut .= " " . $retVal[$i][12] . "\n"; $xmlOut .= " \n"; $xmlOut .= "\n"; endfor; $xmlOut .= "\n"; // endif; endif; elseif ($functionName == "actionReport") : $retVal = call_user_func_array($functionName, array($actionMode, $rpId, $rpType, $rpObjType, $rpObjId, $rpText, $rpConfidential, $hq_id, $usr_id)); // DB actions for a report $xmlOut .= "\n"; $xmlOut .= "\n"; $xmlOut .= "" . $actionMode . "\n"; $xmlOut .= "" . $rpId . "\n"; $xmlOut .= "" . $retVal . "\n"; $xmlOut .= "\n"; $xmlOut .= "\n"; elseif ($functionName == "getCsStatistic") : $retVal = call_user_func_array($functionName, array($csId, $fromDateRange, $toDateRange)); // Special customer statistic: Business volume $xmlOut .= "\n"; $xmlOut .= "" . $csId . "\n"; $xmlOut .= "" . $csEid . "\n"; $xmlOut .= "" . $retVal . "\n"; $xmlOut .= "\n"; else : $xmlOut .= "103\n"; $xmlOut .= "Function does not exist in API.\n"; endif; else : $xmlOut .= "102\n"; $xmlOut .= "Specified function does not exist.\n"; endif; else : $xmlOut .= "101\n"; $xmlOut .= "No function specified.\n"; endif; else : $xmlOut .= "104\n"; $xmlOut .= "No headquarters defined.\n"; endif; $xmlOut .= "\n"; endif; echo $xmlOut; ?>