"; $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 . ". Tag des Jahres"; $out .= ""; $out .= ""; 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; $out = ""; $out .= "Beginn"; $out .= "Ende"; $out .= "Ersteller"; $out .= "Teilnehmer"; $out .= "Beschreibung"; $out .= "Kunde"; $out .= "Aktion"; $out .= ""; if (authCheckEmployeeRights($emp_id, "10")) : $out .= ""; $out .= " "; $out .= " "; $out .= ""; $out .= " "; $out .= " "; $out .= " "; $out .= " "; $out .= ""; endif; return $out; } // Gets exactly the value of one specified field from the specified row by key of a certain table function getAppointmentsFromDB($selYearFrom, $selMonthFrom, $selDayFrom, $selYearTo = "", $selMonthTo = "", $selDayTo = "", $csId = "") { global $db, $PHP_SELF; global $emp_id, $f_selUsrId, $f_hq_id; $retArray = array(); $dayStringFrom = $selYearFrom . "-" . pad($selMonthFrom,2,"0") . "-" . pad($selDayFrom,2,"0"); $dayStringTo = $selYearTo . "-" . pad($selMonthTo,2,"0") . "-" . pad($selDayTo,2,"0"); if ($selYearTo == "" || $selYearTo == "" || $selYearTo == "") : $dayStringTo = $dayStringFrom; endif; // Filter to display appointments of other users $whereClauseCreatorFilter = " AND ap.usr_id = '" . $f_selUsrId . "'"; if (authCheckEmployeeRights($emp_id, "10") && $f_selUsrId == "all") : $whereClauseCreatorFilter = ""; endif; $sqlStmt = "SELECT ap.ap_id, ap.ap_text, ap.ap_execdate, ap.ap_enddate," . " cmp.cmp_id, cmp.cmp_comp, cmp.cmp_comp2, cs.cs_id, cs.cs_eid," . " ap.usr_id, usr.usr_firstname, usr.usr_name, ap.ap_participants" . " FROM phoenix_group.appointment AS ap" . " LEFT JOIN customer AS cs ON ap.cs_id = cs.cs_id" . " LEFT JOIN company AS cmp ON cs.cmp_id = cmp.cmp_id" . " LEFT JOIN user AS usr ON ap.usr_id = usr.usr_id" . " WHERE ap.ap_execdate >= ' " . $dayStringFrom . " 00:00:00' AND" . " ap.ap_execdate <= ' " . $dayStringTo . " 23:59:59'" . $whereClauseCreatorFilter . " AND" . " ap.hq_id IN " . getSQLMandatorArray($f_hq_id) . " ORDER BY ap.ap_execdate"; // echo $sqlStmt . "
"; $result = $db->query($sqlStmt); if (DB::isError($result)) die ("$PHP_SELF:
$sqlStmt
" . $result->getMessage()); while ($row = $result->fetch_assoc()): $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"]); endwhile; $result->free(); return $retArray; } // 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, $cellCol = "FFFFFF", $csId = "") { global $db, $PHP_SELF; global $f_apIdToUpdate; $apArray = getAppointmentsFromDB($selYear, $selMonth, $selDay); $lenApArray = count($apArray); $out = ""; for ($j = 0; $j < $lenApArray; $j++) : $tmpId = $apArray[$j][0]; $tmpText = $apArray[$j][1]; $tmpExecDate = 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],11,5); $tmpUsrId = trim($apArray[$j][9]); $tmpUsrFirstname = trim($apArray[$j][10]); $tmpUsrName = trim($apArray[$j][11]); $tmpParticipants = trim($apArray[$j][12]); // Dates (From, To) $out .= "" . $tmpExecDate . ""; if ($tmpEndDate != "00:00") : $out .= "" . $tmpEndDate . ""; else : $out .= " "; endif; // User if ($tmpUsrId != "") : $out .= "" . $tmpUsrFirstname . "
" . $tmpUsrName . ""; else : $out .= " "; endif; // Participants $out .= ""; if ($tmpParticipants != "") : $tmpParticipants = spliti(",", $tmpParticipants); // It has to be an array $tmpParticipantsLen = count($tmpParticipants); for ($k = 0; $k < $tmpParticipantsLen; $k++) : $participantName = $db->getOne("SELECT CONCAT(usr_name,', ',usr_firstname) AS name FROM user WHERE usr_id = '" . $tmpParticipants[$k] . "'"); $out .= $participantName . "
"; endfor; else : $out .= " "; endif; $out .= ""; // Text (Edit, read only) if ($f_apIdToUpdate == $tmpId) : $out .= ""; else : $out .= "" . $tmpText . ""; endif; // Potential customer relation (Company name and EID) if ($tmpCsId != "") : $out .= "" . $tmpCmpComp . "
" . ($tmpCmpComp2 != "" ? $tmpCmpComp2 . "
" : "") . $tmpCsEid . "
" . "" . "" . "" . ""; else : $out .= " "; endif; // Actions $out .= ""; if ($f_apIdToUpdate == $tmpId) : $out .= ""; else : $out .= ""; endif; $out .= "
"; $out .= ""; $out .= ""; if ($j < $lenApArray - 1) : $out .= ""; endif; endfor; $out .= ""; return $out; } // *********** // * Actions * // *********** if ($f_act == "insertAppointment") : if ($f_text != "") : $currentTime = getDateTime("0"); $execDatetime = getDateTime("format",array($f_hour,$f_minute,0,$selMonth,$selDay,$selYear),"Y-m-d H:i:s"); $endDatetime = getDateTime("format",array($f_hour_to,$f_minute_to,0,$selMonth,$selDay,$selYear),"Y-m-d H:i:s"); $csId = ""; if ($g_cs_eid != "") : $csId = getFieldValueFromId("customer", "cs_eid", $g_cs_eid, "cs_id"); endif; insertStmt("phoenix_group.appointment", array("usr_id", $usr_id, "hq_id", $hq_id, "ap_participants", implode(",", $f_usr_id), "ap_text", $f_text, "ap_execdate", $execDatetime, "ap_enddate", $endDatetime, "ap_modifytime", $currentTime, "cs_id", $csId, "csc_id", "")); $ap_id_new = getLastInsertId(); // Send email to participants if requested if ($f_sendmail == "1" && $f_usr_id != "" && count($f_usr_id) > 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($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 .= "Nicht alle Empfänger haben eine gültige Emailadresse!"; endif; endfor; $mailAddressesString = implode(",", $mailAddresses); $mailObj = new htmlMimeMail(); $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 .= "Die Nachricht konnte nicht gesendet werden! "; endif; $mailObj = NULL; endif; else: $statusMessage = "Erfassen Sie bitte einen Text zum Termin!"; endif; endif; if ($f_act == "removeAppointment") : if ($f_apIdToRemove != "") : deleteStmt("phoenix_group.appointment","ap_id = ".$f_apIdToRemove); $f_apIdToRemove = ""; // Reset ID else: $statusMessage = "Es wurde kein Termin zum Löschen selektiert!"; endif; endif; 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, "ap_text", $f_text_update)); $f_apIdToUpdate = ""; // Reset ID else: $statusMessage = "Eine Aktualisierung fand nicht statt!"; endif; endif; ?> Appointments
 Niederlassungen:           



Termin erstellen

Zeiten:

Von:   Uhr

Bis:     Uhr  
Teilnehmer:

"); ?> "); ?>
Text:

Kunde zuordnen:








Email an Teilnehmer versenden