"; $out .= ""; $out .= $calWeekDays[$calCurrentDayNumOfTheWeek - 1] . ", "; // Name of the week day (E.g.: "Donnerstag") $out .= $selDay . ". " . $calMonthNames[$selMonth - 1] . " " . $selYear; // Day, Name of the month and year (E.g.: "29 Juni 2006") $out .= "     "; $out .= $calCurrentWeekName . " " . $calCurrentWeekNum; // calendar week (E.g.: "KW 26") $out .= "     "; $out .= $calCurrentDayNumOfTheYear . getLngt(". Tag des Jahres"); $out .= ""; $out .= ""; 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]); $out .= ""; $out .= ""; $out .= $calCurrentWeekName . " " . $selWeek; // calendar week (E.g.: "KW 26") $out .= "     "; $out .= "[" . $selYear . "]"; $out .= "     "; $out .= $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) : "") . " "; $out .= ""; $out .= ""; endif; // Monthly output if ($viewMode == "3") : $out .= ""; $out .= ""; $out .= $calMonthNames[$selMonth - 1] . " " . $selYear; // Name of the month and year (E.g.: "Juni 2006") $out .= "     "; $out .= "01." . $selMonth . ". - " . $calMonthDays[$selMonth - 1] . "." . $selMonth . "."; $out .= ""; $out .= ""; endif; // Yearly output if ($viewMode == "4") : $out .= ""; $out .= ""; $out .= $selYear; // Name of the year (E.g.: "2006") $out .= "     "; $out .= "01.01. - 31.12."; $out .= ""; $out .= ""; endif; // Statistic: Yearly output if ($viewMode == "9") : $out .= ""; $out .= ""; $out .= pad($f_day_from_apstat,2) . "." . pad($f_month_from_apstat,2) . "." . $f_year_from_apstat . " - " . pad($f_day_to_apstat,2) . "." . pad($f_month_to_apstat,2) . "." . $f_year_to_apstat; $out .= ""; $out .= ""; endif; return $out; } // Prints the title of the output table // $cellCol : Colour of the cell function printAppointmentTitle($cellCol = "FFFFFF") { global $emp_id, $usr_id, $f_selUsrId, $f_hq_id; global $viewMode; $out = ""; // Daily output if ($viewMode == "1") : $out .= ""; $out .= "" . getLngt("Beginn") . ""; $out .= "" . getLngt("Ende") . ""; // $out .= "" . getLngt("Ersteller") . ""; $out .= "" . getLngt("Ersteller, Teilnehmer") . ""; $out .= "Beschreibung"; $out .= "" . getLngt("Kunde") . ""; $out .= "" . getLngt("Aktion") . ""; $out .= ""; endif; // Weekly output if ($viewMode == "2") : $out .= ""; $out .= "" . getLngt("Tag") . ""; $out .= "" . getLngt("Zeit") . ""; // $out .= "" . getLngt("Ersteller") . ""; $out .= "" . getLngt("Ersteller, Teilnehmer") . ""; $out .= "" . getLngt("Beschreibung") . ""; $out .= "" . getLngt("Kunde") . ""; $out .= "" . getLngt("Aktion") . ""; $out .= ""; endif; return $out; } // Prints the headline with the current day // $selYear : Selected year // $selMonth : Selected month // $selDay : Selected day // $cellCol : Colour of the cell // $csId : Special customer function printAppointmentsOfOneDay($selYear, $selMonth, $selDay, $csId = "", $cellCol = "FFFFFF") { global $db, $PHP_SELF; global $usr_id, $f_apIdToUpdate; // $apArray = getAppointmentsFromDB($selYear, $selMonth, $selDay); $apArray = getAppointmentsOfOneDay($selYear, $selMonth, $selDay, $csId); $lenApArray = count($apArray); $out = ""; for ($j = 0; $j < $lenApArray; $j++) : $tmpId = $apArray[$j][0]; $tmpText = $apArray[$j][1]; $tmpText = nl2br($tmpText); $tmpExecDateTime = $apArray[$j][2]; $tmpExecDate = substr($tmpExecDateTime,8,2) . "." . substr($tmpExecDateTime,5,2) . "." . substr($tmpExecDateTime,0,4); $tmpExecTime = substr($tmpExecDateTime,11,5); $tmpCmpId = trim($apArray[$j][3]); $tmpCmpComp = trim($apArray[$j][4]); $tmpCmpComp2 = trim($apArray[$j][5]); $tmpCsId = $apArray[$j][6]; $tmpCsEid = $apArray[$j][7]; $tmpEndDateTime = $apArray[$j][8]; $tmpEndDate = substr($tmpEndDateTime,8,2) . "." . substr($tmpEndDateTime,5,2) . "." . substr($tmpEndDateTime,0,4); $tmpEndTime = substr($tmpEndDateTime,11,5); $tmpUsrId = trim($apArray[$j][9]); $tmpUsrFirstname = trim($apArray[$j][10]); $tmpUsrName = trim($apArray[$j][11]); $tmpParticipants = trim($apArray[$j][12]); $tmpParticipants = substr($tmpParticipants,1,-1); // Remove commata from db-field $tmpConfirmed = trim($apArray[$j][13]); $tmpConfirmed = substr($tmpConfirmed,1,-1); // Remove commata from db-field $tmpCsUsrName = trim($apArray[$j][14]); $tmpCsUsrFirstname = trim($apArray[$j][15]); $tmpCsUsrPhone = $apArray[$j][16]; $tmpCsUsrPhone2 = $apArray[$j][17]; $tmpApCat1 = $apArray[$j][18]; $tmpApCat2 = $apArray[$j][19]; $tmpApCat3 = $apArray[$j][20]; $tmpApCat4 = $apArray[$j][21]; // Dates (From, To) $out .= "" . $tmpExecDate . "

" . $tmpExecTime . "
"; if ($tmpApCat4 == "1") : $out .= "  " . ""; endif; $out .= ""; if ($tmpEndTime != "00:00") : $out .= "" . $tmpEndDate . "

" . $tmpEndTime . "
"; else : $out .= " "; endif; // Author and participants $out .= ""; if ($tmpUsrId != "") : $out .= "" . $tmpUsrName . " " . $tmpUsrFirstname . ""; $out .= "
"; endif; if ($tmpParticipants != "") : $tmpParticipants = spliti(",", $tmpParticipants); // It has to be an array $tmpParticipantsLen = count($tmpParticipants); // Needs array of users confirmed the appointment $tmpConfirmed = spliti(",", $tmpConfirmed); for ($k = 0; $k < $tmpParticipantsLen; $k++) : $participantName = $db->getOne("SELECT CONCAT(usr_name,', ',usr_firstname) AS name FROM user WHERE usr_id = '" . $tmpParticipants[$k] . "'"); $participantConfirmed = "[?]"; $l = array_search($tmpParticipants[$k], $tmpConfirmed); if (!($l === FALSE)) : $participantConfirmed = "[" . getLngt("OK") . "]"; else : if ($tmpParticipants[$k] == $tmpUsrId) : $participantConfirmed = "[" . getLngt("OK") . "]"; elseif ($tmpParticipants[$k] == $usr_id) : // Only the user has a link to confirm his/her own entry $participantConfirmed = "[" . getLngt("Bestätigen") . "]"; endif; endif; $out .= $participantName . " " . $participantConfirmed . "
"; endfor; else : $out .= " "; endif; $out .= ""; // Text $out .= ""; if ($tmpApCat3 != "" && $tmpApCat3 > 0) : $out .= "" . getFieldValueFromClause("metatype","mt_value","mt_type = 'appointment_category_3' AND mt_sort = '" . $tmpApCat3 . "'") . ""; $out .= "
"; endif; $out .= $tmpText; $out .= ""; // Potential customer relation (Company name and EID) if ($tmpCsId != "") : $out .= "" . $tmpCmpComp . "
" . ($tmpCmpComp2 != "" ? $tmpCmpComp2 . "
" : "") . $tmpCsEid . "
" . "" . "" . "" . ""; else : $out .= " "; endif; // Actions $out .= ""; $out .= ""; $out .= "
"; $out .= ""; $out .= "
"; $out .= ""; if ($tmpApCat4 == "1") : $out .= "
"; $out .= ""; endif; $out .= ""; if ($j < $lenApArray - 1) : $out .= ""; endif; endfor; $out .= ""; return $out; } // Prints the headline with the current week // $selWeek : Selected week // $selYear : Selected year // $selMonth : Selected month // $selDay : Selected day // $cellCol : Colour of the cell // $csId : Special customer function printAppointmentsOfOneWeek($selWeek, $selYear, $selMonth, $selDay, $csId = "", $cellCol = "FFFFFF") { global $db, $PHP_SELF; global $usr_id, $f_apIdToUpdate; global $calCurrentWeekNum, $calWeekDays; /* if ($selWeek == "") : $selWeek = $calCurrentWeekNum; endif; // Get the first day ("Monday") of the specified week $firstDayOfWeek = calFirstDayNumOfWeek($selWeek, $selYear); // Compute interval to week (eq. 7 days) $tmpDatetime = mktime(0, 0, 0, $firstDayOfWeek[1], $firstDayOfWeek[0] + 6, $firstDayOfWeek[2]); $weekBeginDate = date("Y-m-d", mktime(0, 0, 0, $firstDayOfWeek[1], $firstDayOfWeek[0], $firstDayOfWeek[2])); $weekEndDate = date("Y-m-d", mktime(0, 0, 0, $firstDayOfWeek[1], $firstDayOfWeek[0] + 6, $firstDayOfWeek[2])); // Get appointments of the specified week $apArray = getAppointmentsFromDB($firstDayOfWeek[2], $firstDayOfWeek[1], $firstDayOfWeek[0], date("Y", $tmpDatetime), date("m", $tmpDatetime), date("d", $tmpDatetime)); // Modifies array according to the appointments starting and ending on different days $apArray = modifyIntervalAppointments2SingleDayAppointments($apArray, $weekBeginDate, $weekEndDate); */ $firstDayOfWeek = calFirstDayNumOfWeek($selWeek, $selYear); $apArray = getAppointmentsOfOneWeek($selWeek, $selYear, $selMonth, $selDay, $csId); $lenApArray = count($apArray); $out = ""; $tmpExecDateDayNumRemember = "1"; // Start with Monday $tmpExecDateDayNumRememberArray = array("1","0","0","0","0","0","0","0"); if ($lenApArray == 0) : // Check execution dates of appointments for day names to be displayed (Monday, Tuesday, ... have to be displayed also without appointments) while ($tmpExecDateDayNumRemember <= 7) : $tmpMktime = mktime(0, 0, 0, $firstDayOfWeek[1], $firstDayOfWeek[0] + ($tmpExecDateDayNumRemember - 1), $firstDayOfWeek[2]); $tmpDayNum = date("w", $tmpMktime); if ($tmpDayNum == 0) : $tmpDayNum = "7"; endif; $out .= "" . $calWeekDays[$tmpDayNum - 1] . "
" . date("d", $tmpMktime) . "." . date("m", $tmpMktime) . ".
"; $out .= " "; // $out .= " "; $out .= " "; $out .= " "; $out .= " "; $out .= " "; $out .= ""; $tmpExecDateDayNumRemember++; endwhile; else : $tmpExecDateYearRemember = ""; $tmpExecDateMonthRemember = ""; $tmpExecDateDayRemember = ""; for ($j = 0; $j < $lenApArray; $j++) : $tmpId = $apArray[$j][0]; $tmpText = $apArray[$j][1]; $tmpText = nl2br($tmpText); $tmpExecDate = substr($apArray[$j][2],0,10); $tmpExecTime = substr($apArray[$j][2],11,5); $tmpExecDateYear = substr($apArray[$j][2],0,4); $tmpExecDateMonth = substr($apArray[$j][2],5,2); $tmpExecDateDay = substr($apArray[$j][2],8,2); $tmpExecDateDayNum = date("w", mktime(0, 0, 0, $tmpExecDateMonth, $tmpExecDateDay, $tmpExecDateYear)); if ($tmpExecDateDayNum == 0) : $tmpExecDateDayNum = "7"; endif; $tmpExecTime = substr($apArray[$j][2],11,5); $tmpCmpId = trim($apArray[$j][3]); $tmpCmpComp = trim($apArray[$j][4]); $tmpCmpComp2 = trim($apArray[$j][5]); $tmpCsId = $apArray[$j][6]; $tmpCsEid = $apArray[$j][7]; $tmpEndDate = substr($apArray[$j][8],0,10); $tmpEndTime = substr($apArray[$j][8],11,5); $tmpUsrId = trim($apArray[$j][9]); $tmpUsrFirstname = trim($apArray[$j][10]); $tmpUsrName = trim($apArray[$j][11]); $tmpParticipants = trim($apArray[$j][12]); $tmpParticipants = substr($tmpParticipants,1,-1); // Remove commata from db-field $tmpConfirmed = trim($apArray[$j][13]); $tmpConfirmed = substr($tmpConfirmed,1,-1); // Remove commata from db-field $tmpApCat1 = $apArray[$j][18]; $tmpApCat2 = $apArray[$j][19]; $tmpApCat3 = $apArray[$j][20]; $tmpApCat4 = $apArray[$j][21]; $tmpOk = true; for ($d = 1; $d < $tmpExecDateDayNum; $d++) : if ($tmpExecDateDayNumRememberArray[$d] == "0") : $tmpOk = false; endif; endfor; if ($tmpOk) : $tmpExecDateDayNumRemember = $tmpExecDateDayNum; endif; // Check execution dates of appointments for day names to be displayed (Monday, Tuesday, ... have to be displayed also without appointments) while ($tmpExecDateDayNum > $tmpExecDateDayNumRemember) : if ($tmpExecDateDayNumRememberArray[$tmpExecDateDayNumRemember] == "0") : $tmpMktime = mktime(0, 0, 0, $firstDayOfWeek[1], $firstDayOfWeek[0] + ($tmpExecDateDayNumRemember - 1), $firstDayOfWeek[2]); $tmpDayNum = date("w", $tmpMktime); if ($tmpDayNum == 0) : $tmpDayNum = "7"; endif; $out .= "" . $calWeekDays[$tmpDayNum - 1] . "
" . date("d", $tmpMktime) . "." . date("m", $tmpMktime) . ".
"; $out .= " "; // $out .= " "; $out .= " "; $out .= " "; $out .= " "; $out .= " "; $out .= ""; endif; $tmpExecDateDayNumRememberArray[$tmpExecDateDayNumRemember] = "1"; $tmpExecDateDayNumRemember++; endwhile; // Date $out .= ""; if ($tmpExecDateYearRemember != $tmpExecDateYear || $tmpExecDateMonthRemember != $tmpExecDateMonth || $tmpExecDateDayRemember != $tmpExecDateDay) : $out .= "" . $calWeekDays[$tmpExecDateDayNum - 1] . "
" . $tmpExecDateDay . "." . $tmpExecDateMonth . ".
"; $tmpExecDateYearRemember = $tmpExecDateYear; $tmpExecDateMonthRemember = $tmpExecDateMonth; $tmpExecDateDayRemember = $tmpExecDateDay; $tmpExecDateDayNumRememberArray[$tmpExecDateDayNum] = "1"; endif; $out .= ""; // Times (From, To) $out .= "" . $tmpExecTime . ""; if ($tmpEndTime != "00:00") : $out .= "
-
" . $tmpEndTime . "
"; endif; if ($tmpApCat4 == "1") : $out .= "

" . ""; endif; $out .= ""; // Author and participants $out .= ""; if ($tmpUsrId != "") : $out .= "" . $tmpUsrName . " " . $tmpUsrFirstname . ""; $out .= "
"; endif; if ($tmpParticipants != "") : $tmpParticipants = spliti(",", $tmpParticipants); // It has to be an array $tmpParticipantsLen = count($tmpParticipants); // Needs array of users confirmed the appointment $tmpConfirmed = spliti(",", $tmpConfirmed); for ($k = 0; $k < $tmpParticipantsLen; $k++) : $participantName = $db->getOne("SELECT CONCAT(usr_name,', ',usr_firstname) AS name FROM user WHERE usr_id = '" . $tmpParticipants[$k] . "'"); $participantConfirmed = "[?]"; $l = array_search($tmpParticipants[$k], $tmpConfirmed); if (!($l === FALSE)) : $participantConfirmed = "[" . getLngt("OK") . "]"; else : if ($tmpParticipants[$k] == $tmpUsrId) : $participantConfirmed = "[" . getLngt("OK") . "]"; elseif ($tmpParticipants[$k] == $usr_id) : // Only the user has a link to confirm his/her own entry $participantConfirmed = "[" . getLngt("Bestätigen") . "]"; endif; endif; $out .= $participantName . " " . $participantConfirmed . "
"; endfor; else : $out .= " "; endif; $out .= ""; // Text (Edit, read only) $out .= ""; if ($tmpApCat3 != "" && $tmpApCat3 > 0) : $out .= "" . getFieldValueFromClause("metatype","mt_value","mt_type = 'appointment_category_3' AND mt_sort = '" . $tmpApCat3 . "'") . ""; $out .= "
"; endif; if ($f_apIdToUpdate == $tmpId) : $out .= ""; else : $out .= $tmpText; endif; $out .= ""; // Potential customer relation (Company name and EID) if ($tmpCsId != "") : $out .= "" . $tmpCmpComp . "
" . ($tmpCmpComp2 != "" ? $tmpCmpComp2 . "
" : "") . $tmpCsEid . "
" . "" . "" . "" . ""; else : $out .= " "; endif; // Actions $out .= ""; $out .= ""; $out .= "
"; $out .= ""; $out .= "
"; $out .= ""; if ($tmpApCat4 == "1") : $out .= "
"; $out .= ""; endif; $out .= ""; if ($j < $lenApArray - 1) : $out .= ""; endif; endfor; // Fill up the rest of the week if ($tmpExecDateDayNumRemember <= 7) : $out .= ""; while ($tmpExecDateDayNumRemember <= 7) : if ($tmpExecDateDayNumRememberArray[$tmpExecDateDayNumRemember] == "0") : $tmpMktime = mktime(0, 0, 0, $firstDayOfWeek[1], $firstDayOfWeek[0] + ($tmpExecDateDayNumRemember - 1), $firstDayOfWeek[2]); $tmpDayNum = date("w", $tmpMktime); if ($tmpDayNum == 0) : $tmpDayNum = "7"; endif; $out .= "" . $calWeekDays[$tmpDayNum - 1] . "
" . date("d", $tmpMktime) . "." . date("m", $tmpMktime) . ".
"; $out .= " "; // $out .= " "; $out .= " "; $out .= " "; $out .= " "; $out .= " "; $out .= ""; endif; $tmpExecDateDayNumRemember++; endwhile; endif; endif; $out .= ""; return $out; } // Prints the headline with the current month // $selYear : Selected year // $selMonth : Selected month // $cellCol : Colour of the cell // $csId : Special customer function printAppointmentsOfOneMonth($selYear, $selMonth, $csId = "", $cellCol = "FFFFFF") { global $db, $PHP_SELF; global $usr_id, $f_apIdToUpdate; global $calCurrentWeekNum, $calWeekDays; global $calMonthDays; /* // Get the calendar week of the first day of the selected month $calFirstWeekNumofTheMonth = calFirstWeekNumofMonth($selMonth, $selYear); // Get the number of the first day of the selected month $calFirstDayNumOfTheMonth = calFirstDayNumOfMonth($selMonth, $selYear); // Get appointments of the specified month $apArray = getAppointmentsFromDB($selYear, $selMonth, "1", $selYear, $selMonth, $calMonthDays[$selMonth - 1]); $lenApArray = count($apArray); $monthBeginDate = date("Y-m-d", mktime(0, 0, 0, $selMonth, "1", $selYear)); $monthEndDate = date("Y-m-d", mktime(0, 0, 0, $selMonth, $calMonthDays[$selMonth - 1], $selYear)); // Modifies array according to the appointments starting and ending on different days $apArray = modifyIntervalAppointments2SingleDayAppointments($apArray, $monthBeginDate, $monthEndDate); */ // Get the calendar week of the first day of the selected month $calFirstWeekNumofTheMonth = calFirstWeekNumofMonth($selMonth, $selYear); // Get the number of the first day of the selected month $calFirstDayNumOfTheMonth = calFirstDayNumOfMonth($selMonth, $selYear); $apArray = getAppointmentsOfOneMonth($selYear, $selMonth, $csId); $lenApArray = count($apArray); $dayCounter = 1; $appointmentCounter = 0; $out = ""; for ($i = 1; $i < 7; $i++) : // Display the calendar week $out .= ""; $out .= $calFirstWeekNumofTheMonth; $out .= ""; // Display the days of the calendar week for ($j = 1; $j <= 7; $j++) : if ((($i > 1) || ($i == 1 && $j >= $calFirstDayNumOfTheMonth)) && $dayCounter <= $calMonthDays[$selMonth - 1]) : $cellCol2 = $cellCol; if ($selYear == date("Y") && $selMonth == date("m") && $dayCounter == date("d")) : $cellCol2 = "FFFF00"; // Yellow endif; $out .= ""; $out .= "" . pad($dayCounter,2) . "." . pad($selMonth,2) . "."; // "   " . substr($calWeekDays[$j - 1],0,2) . // display appointments of the day for ($a = $appointmentCounter; $a < $lenApArray; $a++) : $tmpId = $apArray[$a][0]; $tmpText = $apArray[$a][1]; $tmpText = nl2br($tmpText); $tmpExecDate = substr($apArray[$a][2],0,10); $tmpExecDateYear = substr($apArray[$a][2],0,4); $tmpExecDateMonth = substr($apArray[$a][2],5,2); $tmpExecDateDay = substr($apArray[$a][2],8,2); $tmpExecDateDayNum = date("w", mktime(0, 0, 0, $tmpExecDateMonth, $tmpExecDateDay, $tmpExecDateYear)); if ($tmpExecDateDayNum == 0) : $tmpExecDateDayNum = "7"; endif; $tmpExecTime = substr($apArray[$a][2],11,5); $tmpCmpId = trim($apArray[$a][3]); $tmpCmpComp = trim($apArray[$a][4]); $tmpCmpComp2 = trim($apArray[$a][5]); $tmpCsId = $apArray[$a][6]; $tmpCsEid = $apArray[$a][7]; $tmpEndDate = substr($apArray[$a][8],0,10); $tmpEndTime = substr($apArray[$a][8],11,5); $tmpUsrId = trim($apArray[$a][9]); $tmpUsrFirstname = trim($apArray[$a][10]); $tmpUsrName = trim($apArray[$a][11]); $tmpParticipants = trim($apArray[$a][12]); $tmpParticipants = substr($tmpParticipants,1,-1); // Remove commata from db-field $tmpConfirmed = trim($apArray[$a][13]); $tmpConfirmed = substr($tmpConfirmed,1,-1); // Remove commata from db-field $tmpApCat4 = $apArray[$a][21]; if ($tmpExecDateDay == $dayCounter) : $out .= "
"; $out .= "" . $tmpExecTime . " - " . $tmpEndTime . ""; if ($tmpApCat4 == "1") : $out .= "    " . ""; endif; $out .= "
"; $out .= "" . $tmpText. "
"; // Customer buttons if ($tmpCsId != "") : $out .= "Kunde: " . $tmpCsEid . "
" . $tmpCmpComp . " " . ($tmpCmpComp2 != "" ? $tmpCmpComp2 : "") . "
" . "" . "" . ""; endif; $out .= "
"; // Appointment buttons $out .= "" . "" . ""; if ($tmpApCat4 == "1") : $out .= ""; endif; $appointmentCounter++; else : break; endif; endfor; $out .= ""; $dayCounter++; else : $out .= " "; endif; endfor; if ($i < 6) : $out .= ""; endif; // Check especially for changing of the year if ($selMonth == 1 && $calFirstWeekNumofTheMonth >= 52) : $calFirstWeekNumofTheMonth = 0; endif; $calFirstWeekNumofTheMonth++; if ($selMonth == 12 && $calFirstWeekNumofTheMonth > calLastWeekNumofYear($selYear)) : $calFirstWeekNumofTheMonth = 1; endif; endfor; $out .= ""; return $out; } // Prints the headline with the current month // $selYear : Selected year // $selMonth : Selected month // $cellCol : Colour of the cell // $csId : Special customer function printAppointmentsOfOneYear($selYear, $csId = "", $cellCol = "FFFFFF") { global $db, $PHP_SELF; global $usr_id, $f_apIdToUpdate; global $calCurrentWeekNum, $calWeekDays; global $calMonthNames, $calMonthDays; $out = ""; for ($j = 1; $j <= 12; $j++) : $out .= "
" . $calMonthNames[$j - 1] . "
"; $out .= printAppointmentsOfOneMonth($selYear, $j, $csId); endfor; $out .= "
 
"; return $out; } function printAppointmentStatistic($csId = "", $cellCol = "FFFFFF") { global $db, $PHP_SELF; global $usr_id, $f_apIdToUpdate; global $calCurrentWeekNum, $calWeekDays; global $calMonthNames, $calMonthDays; global $f_day_from_apstat, $f_month_from_apstat, $f_year_from_apstat, $f_day_to_apstat, $f_month_to_apstat, $f_year_to_apstat; $out = "\n"; $out .= "
"; $out .= "\n"; $out .= "
" . getLngt("Von:") . "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; $out .= "  " . getLngt("bis:") . "\n"; $out .= "\n"; $out .= "\n"; $out .= "\n"; /* $out .= "\n"; $out .= "\n"; $out .= "\n"; $out .= "  "; $out .= "\n"; $out .= "\n"; $out .= "\n"; */ $out .= "

"; $out .= "
\n"; // $apArray = getAppointmentsFromDB($selYear, "1", "1", $selYear, $selMonth, $calMonthDays[$selMonth - 1]); $apArray = getAppointmentsFromDB($f_year_from_apstat, $f_month_from_apstat, $f_day_from_apstat, $f_year_to_apstat, $f_month_to_apstat, $f_day_to_apstat, $csId); $lenApArray = count($apArray); $statArray = array(); $statUserArray = array(); $statApCatArray = array(); // Init arrays for ($j = 0; $j < $lenApArray; $j++) : $statUserArray[$j] = 0; $statApCatArray[1][$j] = 0; $statApCatArray[2][$j] = 0; $statApCatArray[3][$j] = 0; $statApCatArray[4][$j] = 0; endfor; for ($j = 0; $j < $lenApArray; $j++) : $tmpId = $apArray[$j][0]; $tmpText = $apArray[$j][1]; $tmpText = nl2br($tmpText); $tmpExecDateTime = $apArray[$j][2]; $tmpExecDate = substr($tmpExecDateTime,8,2) . "." . substr($tmpExecDateTime,5,2) . "." . substr($tmpExecDateTime,0,4); $tmpExecTime = substr($tmpExecDateTime,11,5); $tmpCmpId = trim($apArray[$j][3]); $tmpCmpComp = trim($apArray[$j][4]); $tmpCmpComp2 = trim($apArray[$j][5]); $tmpCsId = $apArray[$j][6]; $tmpCsEid = $apArray[$j][7]; $tmpEndDateTime = $apArray[$j][8]; $tmpEndDate = substr($tmpEndDateTime,8,2) . "." . substr($tmpEndDateTime,5,2) . "." . substr($tmpEndDateTime,0,4); $tmpEndTime = substr($tmpEndDateTime,11,5); $tmpUsrId = trim($apArray[$j][9]); $tmpUsrFirstname = trim($apArray[$j][10]); $tmpUsrName = trim($apArray[$j][11]); $tmpParticipants = trim($apArray[$j][12]); $tmpParticipants = substr($tmpParticipants,1,-1); // Remove commata from db-field $tmpConfirmed = trim($apArray[$j][13]); $tmpConfirmed = substr($tmpConfirmed,1,-1); // Remove commata from db-field $tmpCsUsrName = trim($apArray[$j][14]); $tmpCsUsrFirstname = trim($apArray[$j][15]); $tmpCsUsrPhone = $apArray[$j][16]; $tmpCsUsrPhone2 = $apArray[$j][17]; $tmpApCat1 = $apArray[$j][18]; $tmpApCat2 = $apArray[$j][19]; $tmpApCat3 = $apArray[$j][20]; $tmpApCat4 = $apArray[$j][21]; /* $retArray[] = array($row["ap_id"], $row["ap_text"], $row["ap_execdate"], $row["cmp_id"], $row["cmp_comp"], $row["cmp_comp2"], $row["cs_id"], $row["cs_eid"], $row["ap_enddate"], $row["usr_id"], $row["usr_firstname"], $row["usr_name"], $row["ap_participants"], $row["ap_confirmed"], $row["pt_cmp_comp"], $row["pt_cmp_comp2"], $row["pt_cs_eid"], $row["pt_id"], $row["ap_category_1"], $row["ap_category_2"], $row["ap_category_3"], $row["ap_category_4"]); 1 alle Einträge 2 selbst erstellte Einträge 3 nur für mich sichtbar 4 nur für Teilnehmer sichtbar 5 für alle sichtbar 6 Einträge anderer Mitarbeiter 7 ich bin Teilnehmer 8 alle weiteren freigegebenen // $j = array_search($f_usr_id, $usrIdArray); // if ($j === FALSE) : */ if ($statArray[$tmpApCat1][$tmpApCat2][$tmpApCat3][$tmpApCat4] == "") : $statArray[$tmpApCat1][$tmpApCat2][$tmpApCat3][$tmpApCat4] = "0"; endif; $statArray[$tmpApCat1][$tmpApCat2][$tmpApCat3][$tmpApCat4]++; $statApCatArray[1][$tmpApCat1]++; $statApCatArray[2][$tmpApCat2]++; $statApCatArray[3][$tmpApCat3]++; $statApCatArray[4][$tmpApCat4]++; endfor; $tableEmptyLine = " \n"; $tableSpacerCol = "   "; $out .= "\n"; $out .= "" . $tableSpacerCol . "\n"; // All appointments // Iterate appointment categories for ($i = 1; $i <= 4; $i++) : $out .= $tableEmptyLine; $numOfRows = getCountOfTable("metatype", "mt_type = 'appointment_category_" . $i . "'"); for ($j = 0; $j <= $numOfRows; $j++) : $tmpOutText = getFieldValueFromClause("metatype","mt_value","mt_type = 'appointment_category_" . $i . "' AND mt_sort = '" . $j . "'"); // Check for existence of another output text defined by parameter $maskApCatx_y = getParameterValue("0", "MASK_AP_CAT_" . $i . "_" . $j, "0"); if ($maskApCatx_y != "") : $tmpOutText = $maskApCatx_y; endif; if ($tmpOutText != "") : $out .= "" . $tableSpacerCol . "\n"; endif; endfor; endfor; $maskApCat4_1 = getParameterValue("0", "MASK_AP_CAT_4_9", "0"); if ($maskApCat4_1 == "") : $maskApCat4_1 = getLngt("Deaktivierte Termine"); endif; $out .= "" . $tableSpacerCol . "\n"; // Deactivated appointments $out .= $tableEmptyLine; $out .= "
" . getLngt("Alle Termine") . "" . $lenApArray . "
" . getLngt($tmpOutText) . "" . $statApCatArray[$i][$j] . "
" . getLngt($maskApCat4_1) . "" . $statApCatArray[4][2] . "
\n"; return $out; } // *********** // * Actions * // *********** if ($f_act == "insertResubmissionAppointment") : if ($f_ap_resubmission_id != "") : $currentTime = getDateTime("0"); // Get data of the appointment to be resubmitted $tmpFields = getFieldsValueFromId("phoenix_group.appointment", "ap_id", $f_ap_resubmission_id, array("ap_participants","ap_text","cs_id","csc_id","pt_id")); $tmp_ap_participants = $tmpFields[0]; $tmp_ap_text = $tmpFields[1]; $tmp_cs_id = $tmpFields[2]; $tmp_csc_id = $tmpFields[3]; $tmp_pt_id = $tmpFields[4]; insertStmt("phoenix_group.appointment", array("usr_id", $usr_id, "hq_id", $hq_id, "ap_participants", $tmp_ap_participants, "ap_text", $tmp_ap_text, "ap_category_1", $f_ap_resubmission_category_1, "ap_category_2", $f_ap_resubmission_category_2, "ap_category_3", $f_ap_resubmission_category_3, "ap_category_4", $f_ap_resubmission_category_4, "ap_execdate", $f_ap_resubmission_execdate, "ap_enddate", $f_ap_resubmission_enddate, "ap_modifytime", $currentTime, "cs_id", $tmp_cs_id, "csc_id", $tmp_csc_id, "pt_id", $tmp_pt_id)); else: $statusMessage = getLngt("Der Termin kann nicht auf Wiedervorlage gelegt werden!"); endif; endif; if ($f_act == "insertAppointment" || $f_act == "updateAppointment") : if ($f_text != "") : if ($f_year != "" && $f_month != "" && $f_day != "" && $f_hour != "" && $f_minute != "" && $f_year_to != "" && $f_month_to != "" && $f_day_to != "" && $f_hour_to != "" && $f_minute_to != "" && date("YmdHis", mktime($f_hour,$f_minute,0,$f_month,$f_day,$f_year)) < date("YmdHis", mktime($f_hour_to,$f_minute_to,59,$f_month_to,$f_day_to,$f_year_to))) : $currentTime = getDateTime("0"); $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"); $csId = ""; $ptId = ""; if ($g_cs_eid != "") : $csId = getFieldValueFromId("customer", "cs_eid", $g_cs_eid, "cs_id"); endif; $f_usr_id_string = ""; if ($f_usr_id != "" && count($f_usr_id) > 0) : $f_usr_id_string = "," . implode(",", $f_usr_id) . ","; endif; // INSERT new appointment if ($f_act == "insertAppointment") : insertStmt("phoenix_group.appointment", array("usr_id", $usr_id, "hq_id", $hq_id, "ap_category_1", $f_ap_cat_1, "ap_category_2", $f_ap_cat_2, "ap_category_3", $f_ap_cat_3, "ap_category_4", $f_ap_cat_4, "ap_participants", $f_usr_id_string, "ap_text", $f_text, "ap_execdate", $execDatetime, "ap_enddate", $endDatetime, "ap_modifytime", $currentTime, "cs_id", $csId, "csc_id", "", "pt_id", $ptId)); // $ap_id_new = getLastInsertId(); endif; // UPDATE existing appointment if ($f_act == "updateAppointment") : if ($f_apIdToUpdate != "") : $f_text_update = ${"f_text_" . $f_apIdToUpdate}; updateStmt("phoenix_group.appointment", "ap_id", $f_apIdToUpdate, array("usr_id", $usr_id, "hq_id", $hq_id, "ap_category_1", $f_ap_cat_1, "ap_category_2", $f_ap_cat_2, "ap_category_3", $f_ap_cat_3,"ap_category_4", $f_ap_cat_4, "ap_participants", $f_usr_id_string, "ap_text", $f_text, "ap_execdate", $execDatetime, "ap_enddate", $endDatetime, "ap_modifytime", $currentTime, "cs_id", $csId, "csc_id", "", "pt_id", $ptId)); $f_apIdToUpdate = ""; // Reset ID else: $statusMessage = getLngt("Eine Aktualisierung fand nicht statt!"); endif; endif; // Send email to participants if requested if (($f_sendmail == "1" && $f_usr_id != "" && count($f_usr_id) > 0) || ($f_sendmail_cs == "1" && count($f_emailAdrCs) > 0)) : $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 email addresses of the participants (employees) $lenTmp = count($f_usr_id); for ($i = 0; $i < $lenTmp; $i++) : $toEmailAddress = getFieldValueFromId("user", "usr_id", $f_usr_id[$i], "usr_email"); if (checkEmailFormat($toEmailAddress)) : array_push($mailAddresses, $toEmailAddress); // else : // $statusMessage .= getLngt("Nicht alle Empfänger haben eine gültige Emailadresse!"); endif; endfor; // Check for external addresses if ($f_sendmail_cs == "1") : $mailAddresses = array_merge($mailAddresses, $f_emailAdrCs); endif; $mailAddressesString = implode(",", $mailAddresses); $mailObj = new htmlMimeMail(); // Format mailtext $mailtext = ""; $mailtext .= ""; $mailtext .= "

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

"; else : $mailtext .= "
" . $f_mail_salutation . "

"; endif; if ($f_text != "") : // $f_text = str_replace("\n", '
', $f_text); $f_text = str_replace("\r", '
', $f_text); endif; $mailtext .= "
" . $f_text . "

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

"; else : $mailtext .= "
" . $f_mail_greetings . "

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


"; endif; $mailtext .= ""; $mailObj->setHtml($mailtext, null, "./"); // $mailObj->setHtml($f_text, null, "./"); $mailObj->setFrom($fromEmailAddress); // $mailObj->setCc($mailCcAddress); // $mailObj->setBcc($mailBccAddress); $mailObj->setSubject("Neuer Termin: " . $execDatetime); $mailResult = $mailObj->send(array($mailAddressesString), 'smtp'); if (!$mailResult) : $statusMessage .= getLngt("Die Nachricht konnte nicht gesendet werden!") . " "; endif; $mailObj = NULL; endif; // Reset parameters $f_ap_cat_1 = "1"; $f_ap_cat_2 = "1"; $f_ap_cat_3 = "1"; $f_ap_cat_4 = "0"; if ($constMaskApCat4Preset == "1") : $f_ap_cat_4 = "1"; endif; else : $statusMessage = getLngt("Die Zeitangaben sind nicht korrekt!"); endif; else: $statusMessage = getLngt("Erfassen Sie bitte einen Text zum Termin!"); $displayState = "1"; endif; endif; if ($f_act == "removeAppointment") : if ($f_apIdToRemove != "") : // Get data of the appointment $tmpExecDatetime = getFieldValueFromId("phoenix_group.appointment", "ap_id", $f_apIdToRemove, "ap_execdate"); $tmpText = getFieldValueFromId("phoenix_group.appointment", "ap_id", $f_apIdToRemove, "ap_text"); $tmpParticipants = getFieldValueFromId("phoenix_group.appointment", "ap_id", $f_apIdToRemove, "ap_participants"); $tmpParticipants = substr($tmpParticipants,1,-1); // Remove commata from db-field $tmpParticipants = spliti(",", $tmpParticipants); // It has to be an array deleteStmt("phoenix_group.appointment","ap_id = ".$f_apIdToRemove); $f_apIdToRemove = ""; // Reset ID // Send email to participants if requested if ($f_sendmail == "1") : if ($tmpParticipants != "" && count($tmpParticipants) > 0) : $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 email addresses of the participants $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); // else : // $statusMessage .= getLngt("Nicht alle Empfänger haben eine gültige Emailadresse!"); endif; endfor; $mailAddressesString = implode(",", $mailAddresses); $mailObj = new htmlMimeMail(); // Format mailtext $mailtext = ""; $mailtext .= ""; $mailtext .= "

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

"; if ($tmpText != "") : // $f_text = str_replace("\n", '
', $f_text); $tmpText = str_replace("\r", '
', $tmpText); endif; $mailtext .= "
" . $tmpText . "

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

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


"; endif; $mailtext .= ""; $mailObj->setHtml($mailtext, null, "./"); $mailObj->setFrom($fromEmailAddress); // $mailObj->setCc($mailCcAddress); // $mailObj->setBcc($mailBccAddress); $mailObj->setSubject("Termin abgesagt: " . $tmpExecDatetime); $mailResult = $mailObj->send(array($mailAddressesString), 'smtp'); if (!$mailResult) : $statusMessage .= getLngt("Die Nachricht konnte nicht gesendet werden!") . " "; endif; $mailObj = NULL; else : $statusMessage = getLngt("Es sind keine Teilnehmer eingetragen!"); endif; endif; else: $statusMessage = getLngt("Es wurde kein Termin zum Löschen selektiert!"); endif; endif; if ($f_act == "confirmAppointment") : if ($f_apIdToConfirm != "") : // Get confirmation string from appointment $tmpApConfirmed = getFieldValueFromId("phoenix_group.appointment", "ap_id", $f_apIdToConfirm, "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", $f_apIdToConfirm, array("ap_confirmed", "," . implode(",", $tmpApConfirmed) . ",")); endif; $f_apIdToConfirm = ""; // Reset ID else: $statusMessage = getLngt("Die Teilnahme wurde nicht bestätigt!"); endif; endif; if ($f_act == "setAppointmentFinished") : if ($f_apId != "") : $doUpdate = true; $constMaskApWarningDisablingQuestion = getParameterValue("0", "MASK_AP_WARNING_DISABLE_QUESTION_NO_REPORT_OF_SAME_DAY", "0"); if ($constMaskApWarningDisablingQuestion == "1") : $tmpFields = getFieldsValueFromId("phoenix_group.appointment", "ap_id", $f_apId, array("cs_id","ap_category_1")); $tmp_cs_id = $tmpFields[0]; $tmp_ap_category_1 = $tmpFields[1]; if ($tmp_cs_id != "" && $tmp_cs_id != "0" && $tmp_ap_category_1 == "1") : $doUpdate = false; // Check for report entry of the current day $currentDate = getDateTime("3"); $tmp_rp_id = getFieldValueFromClause("phoenix_group.report_process","rp_id","rp_objtype = 'cs' AND rp_objid = '" . $tmp_cs_id . "' AND rp_createtime >= '" . $currentDate . " 00:00:00' AND rp_createtime <= '" . $currentDate . " 23:59:59'"); if ($tmp_rp_id != "" && $tmp_rp_id != "0") : $doUpdate = true; endif; endif; endif; // Set appointment done if ($doUpdate) : updateStmt("phoenix_group.appointment", "ap_id", $f_apId, array("ap_category_4", "2")); else : $statusMessage = getLngt("Legen Sie bitte erst einen Bericht an zu diesem Termin!"); endif; $f_apId = ""; // Reset ID else: $statusMessage = getLngt("Eine Deaktivierung konnte nicht stattfinden, weil keine Referenz zu einem Termin besteht!"); endif; endif; // Init time values $f_day = $selDay; $f_month = $selMonth; $f_year = $selYear; $f_day_to = $selDay; $f_month_to = $selMonth; $f_year_to = $selYear; // Output $js_date = ""; $js_date .= "\n"; $js_date .= "\n"; $js_date .= "\n"; ?> <?php echo $pageTitel ?>
  
Von:   Uhr

Bis:   Uhr  

  
: " . addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'appointment_category_1'",$f_ap_cat_1) . ""; ?>
: " . addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'appointment_category_2'",$f_ap_cat_2) . ""; ?>
: " . addOptionsFromTable("metatype","mt_sort","mt_value","mt_value","mt_type = 'appointment_category_3'",$f_ap_cat_3) . ""; ?>
: " . addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'appointment_category_4'",$f_ap_cat_4) . ""; ?>


\n"; endif; ?> \n"; endif; ?> \n"; endif; ?> \n"; endif; ?>
Ersteller, Teilnehmer:
\n" . addOptionsFromTable("user AS usr, headquarters AS hq","usr.usr_id","CONCAT(usr_name,', ',usr_firstname,' [',hq_mnemonic,']') AS usr_name","usr.usr_name","usr.usr_type = '1' AND usr.hq_id = hq.hq_id AND usr.hq_id IN " . getSQLMandatorArray($f_hq_id),$f_selUsrId) . ""; ?>
Status:
" . addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'appointment_category_1'",$f_ap_cat_search_1) . ""; ?>
Terminart:
" . addOptionsFromTable("metatype","mt_sort","mt_value","mt_value","mt_type = 'appointment_category_3'",$f_ap_cat_search_3) . ""; ?>
Sichtbarkeit:
", "", "1", "setAppointmentVisibilityConfig"); ?>


> \n"; $outDateFrom .= "\n"; $outDateFrom .= "\n"; $outDateTo = ""; $outDateTo .= "\n"; $outDateTo .= "\n"; $outDateTo .= "\n"; ?>
> Beginn:
  
> Ende:
  
> Status:
" . addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'appointment_category_1'",$f_ap_cat_1) . ""; ?>
>
" . addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'appointment_category_2'",$f_ap_cat_2) . ""; ?>
>
" . addOptionsFromTable("metatype","mt_sort","mt_value","mt_value","mt_type = 'appointment_category_3'",$f_ap_cat_3) . ""; ?>
>
" . addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'appointment_category_4'",$f_ap_cat_4) . ""; ?>
>
  
   
" . addOptionsFromTable("groups AS grp, employee AS emp","grp.grp_id","grp.grp_name","grp.grp_name","emp.emp_group like CONCAT('%,',grp.grp_id,',%') AND grp.hq_id IN " . getSQLMandatorArray($f_hq_id),$f_grp_id,"DISTINCT") . ""; ?> " ?>
"); ?> "); ?>
 
 
>
>