1. Import

This commit is contained in:
2026-03-29 10:34:57 +02:00
parent b0e00c1259
commit a1129565af
4899 changed files with 3007593 additions and 0 deletions

View File

@@ -0,0 +1,166 @@
<?php
include_once ("../include/global.inc.php");
include_once ("../include/inc_calendar.inc.php");
include_once ("../groupware/calendar.php");
// Check HTTP-Parameters
getSecHttpVars("1",array("f_act", "customerId", "cscIdRoot", "cscIdCurrent", "statusMessage", "deactivateMenu", "grpId",
"mode", "apId", "f_selUsrId", "f_day", "f_month", "f_year", "f_day_to", "f_month_to", "f_year_to"));
if ($mode != "") :
header("Content-Type: text/html; charset=ISO-8859-1\n");
endif;
// echo "alert('" . $mode . "' + '" . $apId . "');";
if ($mode == "1") :
// Get appointment data
if ($apId != "") :
$sqlStmt = "SELECT ap.ap_id, ap.ap_text, ap.ap_confirmed, ap.ap_execdate, ap.ap_enddate,"
. " cmp.cmp_id, cmp.cmp_comp, cmp.cmp_comp2, cs.cs_id, cs.cs_eid,"
. " pt.pt_cmp_comp, pt.pt_cmp_comp2, pt.pt_cs_eid, pt.pt_id,"
. " ap.usr_id, usr.usr_firstname, usr.usr_name, ap.ap_participants,"
. " ap.ap_category_1, ap.ap_category_2, ap.ap_category_3, ap.ap_category_4"
. " FROM phoenix_group.appointment AS ap"
. " LEFT JOIN phoenix.customer AS cs ON ap.cs_id = cs.cs_id"
. " LEFT JOIN phoenix.company AS cmp ON cs.cmp_id = cmp.cmp_id"
. " LEFT JOIN phoenix.user AS usr ON ap.usr_id = usr.usr_id"
. " LEFT JOIN phoenix.prospect AS pt ON ap.pt_id = pt.pt_id"
. " WHERE ap.ap_id = '" . $apId . "'";
$result = $db->query($sqlStmt);
if (DB::isError($result)) die ("$PHP_SELF: <br>$sqlStmt<br>" . $result->getMessage());
$count = 0;
while ($row = $result->fetch_assoc()):
$tmpId = $row["ap_id"];
$tmpText = $row["ap_text"];
$tmpText = my_str_check_js($tmpText);
$tmpExecDateTime = $row["ap_execdate"];
$tmpExecDate = substr($tmpExecDateTime,8,2) . "." . substr($tmpExecDateTime,5,2) . "." . substr($tmpExecDateTime,0,4);
$tmpExecTime = substr($tmpExecDateTime,11,5);
$tmpExecYear = substr($tmpExecDateTime,0,4);
$tmpExecMonth = substr($tmpExecDateTime,5,2);
$tmpExecDay = substr($tmpExecDateTime,8,2);
$tmpExecHour = substr($tmpExecDateTime,11,2);
$tmpExecMinute = substr($tmpExecDateTime,14,2);
$tmpCmpId = trim($row["cmp_id"]);
$tmpCmpComp = trim($row["cmp_comp"]);
$tmpCmpComp2 = trim($row["cmp_comp2"]);
$tmpCsId = $row["cs_id"];
$tmpCsEid = $row["cs_eid"];
$tmpEndDateTime = $row["ap_enddate"];
$tmpEndDate = substr($tmpEndDateTime,8,2) . "." . substr($tmpEndDateTime,5,2) . "." . substr($tmpEndDateTime,0,4);
$tmpEndTime = substr($tmpEndDateTime,11,5);
$tmpEndYear = substr($tmpEndDateTime,0,4);
$tmpEndMonth = substr($tmpEndDateTime,5,2);
$tmpEndDay = substr($tmpEndDateTime,8,2);
$tmpEndHour = substr($tmpEndDateTime,11,2);
$tmpEndMinute = substr($tmpEndDateTime,14,2);
$tmpUsrId = trim($row["usr_id"]);
$tmpUsrFirstname = trim($row["usr_firstname"]);
$tmpUsrName = trim($row["usr_name"]);
$tmpApCategory1 = $row["ap_category_1"];
if ($tmpApCategory1 == "") : $tmpApCategory1 = "1"; endif;
$tmpApCategory2 = $row["ap_category_2"];
if ($tmpApCategory2 == "") : $tmpApCategory2 = "1"; endif;
$tmpApCategory3 = $row["ap_category_3"];
if ($tmpApCategory3 == "") : $tmpApCategory3 = "1"; endif;
$tmpApCategory4 = $row["ap_category_4"];
if ($tmpApCategory4 == "") : $tmpApCategory4 = "0"; endif;
$tmpParticipants = $row["ap_participants"];
$tmpParticipants = substr($tmpParticipants,1,-1); // Remove commata from db-field
$tmpConfirmed = trim($row["ap_confirmed"]);
$tmpConfirmed = substr($tmpConfirmed,1,-1); // Remove commata from db-field
$tmpPtCmpComp = trim($row["pt_cmp_comp"]);
$tmpPtCmpComp2 = trim($row["pt_cmp_comp2"]);
$tmpPtCsEid = $row["pt_cs_eid"];
$tmpPtId = $row["pt_id"];
$count++;
endwhile;
$result->free();
if ($count > 0) :
// Begin date fields
echo "setSelectedValue('f_day', " . $tmpExecDay . ");\n";
echo "setSelectedValue('f_month', " . $tmpExecMonth . ");\n";
echo "setSelectedValue('f_year', " . $tmpExecYear . ");\n";
echo "setSelectedValue('f_hour', " . $tmpExecHour . ");\n";
echo "setSelectedValue('f_minute', " . $tmpExecMinute . ");\n";
// End date fields
echo "setSelectedValue('f_day_to', " . $tmpEndDay . ");\n";
echo "setSelectedValue('f_month_to', " . $tmpEndMonth . ");\n";
echo "setSelectedValue('f_year_to', " . $tmpEndYear . ");\n";
echo "setSelectedValue('f_hour_to', " . $tmpEndHour . ");\n";
echo "setSelectedValue('f_minute_to', " . $tmpEndMinute . ");\n";
// Categories
echo "setSelectedValue('f_ap_cat_1', " . $tmpApCategory1 . ");\n";
echo "setSelectedValue('f_ap_cat_2', " . $tmpApCategory2 . ");\n";
echo "setSelectedValue('f_ap_cat_3', " . $tmpApCategory3 . ");\n";
echo "setSelectedValue('f_ap_cat_4', " . $tmpApCategory4 . ");\n";
// Participants
if ($tmpParticipants != "") :
$tmpParticipants = spliti(",", $tmpParticipants); // It has to be an array
$tmpParticipantsLen = count($tmpParticipants);
echo "participantsLen = document.getElementsByName('f_usr_id[]').length;";
echo "for (var i=0; i<participantsLen; i++) {";
echo " document.getElementsByName('f_usr_id[]')[i].checked = false;\n";
echo "};\n";
for ($k = 0; $k < $tmpParticipantsLen; $k++) :
echo "for (var i=0; i<participantsLen; i++) {";
echo " if (document.getElementsByName('f_usr_id[]')[i].value == '" . $tmpParticipants[$k] . "') {\n";
echo " document.getElementsByName('f_usr_id[]')[i].checked = true;\n";
echo " };\n";
echo "};\n";
endfor;
endif;
// Relations
echo "document.forms[0].g_cs_eid.value = '" . $tmpCsEid . "';\n";
// echo "document.forms[0].g_pt_cs_eid.value = '" . $tmpPtCsEid . "';\n";
// Text
echo "document.forms[0].f_text.value = '" . $tmpText . "';\n";
// Toggle to edit mode
echo "toggleDisplay('1');";
endif;
endif;
elseif ($mode == "2") :
// Get number of appointments
if ($f_selUsrId != "") :
if ($f_day != "" && $f_month != "" && $f_year != "") :
if ($f_day_to == "") : $f_day_to = $f_day; endif;
if ($f_month_to == "") : $f_month_to = $f_month; endif;
if ($f_year_to == "") : $f_year_to = $f_year; endif;
$tmpAppointments = getAppointmentsFromDB($f_year, $f_month, $f_day, $f_year_to, $f_month_to, $f_day_to);
$retValue = count($tmpAppointments);
echo "retValue = '" . $retValue . "';";
endif;
endif;
elseif ($mode == "3") :
// Get participants by group
$retValue = "";
$usrIdArray = getColVectorFromDB2ArrayByClause("employee", "usr_id", "emp_group LIKE '%," . $grpId . ",%'", "", "", "");
$usrIdArrayLen = count($usrIdArray);
if ($usrIdArrayLen > 0) :
$retValue = implode(",",$usrIdArray);
endif;
echo "retArray = Array(" . $retValue . ");";
elseif ($mode == "4") :
// ...
endif;
?>

View File

@@ -0,0 +1,68 @@
<?php
include_once ("../include/global.inc.php");
include_once ("../include/inc_metafield.inc.php");
// Check HTTP-Parameters
// Stocks
getSecHttpVars("1",array("f_act", "customerId", "cscIdRoot", "cscIdCurrent", "statusMessage", "deactivateMenu",
"ft", "category", "presetFields", "searchValue"));
if ($ft != "") :
header("Content-Type: text/html; charset=ISO-8859-1\n");
endif;
// echo "alert('" . $ft . " | ' + '" . $searchValue . " | ' + '" . $presetFields . " | ' + '" . $category . " ');";
if ($ft == "co2cs") :
// Get contact preset with cutomer data
if ($category != "" && $presetFields != "" && $searchValue != "") :
$remObjId = $objId;
$objId = getFieldValueFromId("customer", "cs_eid", $searchValue, "cs_id");
$presetFields = urldecode($presetFields);
$presetFieldsArray = getKeyValueArrayFromString($presetFields);
$tmpKeys = array_keys($presetFieldsArray);
$tmpKeysLen = count($tmpKeys);
// Remember the problem if an address has been entered first before selection of the co2cs relation:
// Should the (address, phone, etc.) data be overwritten...? Presently it always will be overwritten by co2cs selection!
echo "var overwriteWithPreset = true;\n";
echo "var atLeastOnePresetFieldIsOccupied = false;\n";
for ($i = 0; $i < $tmpKeysLen; $i++) :
// Check for field to be checked is NOT type of "co2cs", because it would be set before associating a new customer
$tmpFieldType = getFieldValueFromId("metafieldkey", "mtfk_id", $tmpKeys[$i], "mtfk_type");
if ($tmpFieldType != $ft) :
echo "if (document.forms[0].f_mtfv_" . $category . "_" . $tmpKeys[$i] . ") {\n";
echo " if (trim(document.forms[0].f_mtfv_" . $category . "_" . $tmpKeys[$i] . ".value) != '') {\n";
echo " atLeastOnePresetFieldIsOccupied = true;\n";
echo " };\n";
echo "};\n";
endif;
endfor;
echo "if (atLeastOnePresetFieldIsOccupied) {\n";
echo " overwriteWithPreset = false;\n";
echo " if (confirm('" . getLngt("Möchten Sie die bestehenden Felder mit den neuen Vorbelegungen überschreiben?") . "')) {\n";
echo " overwriteWithPreset = true;\n";
echo " };\n";
echo "};\n";
echo "if (overwriteWithPreset) {\n";
for ($i = 0; $i < $tmpKeysLen; $i++) :
// Remember the problem if an address has been entered first before selection of the co2cs relation:
// Should the (address, phone, etc.) data be overwritten...? Presently it always will be overwritten by co2cs selection!
echo " if (document.forms[0].f_mtfv_" . $category . "_" . $tmpKeys[$i] . ") {\n";
echo " if (overwriteWithPreset) {\n";
echo " document.forms[0].f_mtfv_" . $category . "_" . $tmpKeys[$i] . ".value='" . getFieldValueBySpecialCall($presetFieldsArray[$tmpKeys[$i]]) . "';\n";
echo " };\n";
echo " };\n";
endfor;
echo "};\n";
$objId = $remObjId;
endif;
elseif ($ft == "2") :
//
elseif ($ft == "3") :
//
endif;
?>

File diff suppressed because it is too large Load Diff

581
html/groupware/calendar.php Normal file
View File

@@ -0,0 +1,581 @@
<?php
/*=======================================================================
*
* calendar.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
// include_once ("../include/auth.inc.php");
include_once ("../include/html.inc.php");
include_once ("../include/inc_filters.inc.php");
// Check for authentication access and granted rights
// $usrAccessArray["hq"] = "1";
// authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
// authCheckEmployeeRights($emp_id, "0", "1");
// authCheckEmployeeRights($emp_id, "11", "1");
getSecHttpVars("1", array("f_act", "selYear", "selMonth", "selDay", "workMode",
"apId", "f_hour", "f_minute", "f_hour_to", "f_minute_to"));
// Initialisations
if ($selYear == "") : $selYear = date("Y"); endif;
if ($selMonth == "") : $selMonth = date("m"); endif;
if ($selDay == "") : $selDay = date("d"); endif;
if ($workMode == "") : $workMode = "0"; endif; // rules the output and meaning of e.g. day links of the calendar
// Definiton of global parameters
include_once ("../include/inc_calendar.inc.php");
getLanguage(__FILE__);
// Functions
// Prints the headline with the selected month and the selected year
// $selYear : Selected year
// $selMonth : Selected month
// $cellWidth : Static width of the table cell
// $cellCol : Colour of the cell
function printMonthYearHeader($selYear, $selMonth, $cellWidth = "80", $cellCol = "FF7777") {
global $calMonthNames;
$out = "<tr>";
// $out .= "<td colspan=\"4\" width=\"" . $cellWidth . "\" align=\"center\" bgcolor=\"#" . $cellCol . "\"><b>" . $calMonthNames[$selMonth - 1] . "</b></td>";
// $out .= "<td colspan=\"2\" align=\"center\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
// $out .= "<td colspan=\"4\" width=\"" . $cellWidth . "\" align=\"center\" bgcolor=\"#" . $cellCol . "\"><b>" . $selYear . "</b></td>";
$out .= "<td colspan=\"8\" align=\"center\" bgcolor=\"#" . $cellCol . "\"><b>" . $calMonthNames[$selMonth - 1] . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" . $selYear . "</b></td>";
$out .= "</tr>";
return $out;
}
// Prints the headline with the day names
// $outArray : List with names (Monday, Tuesday, ... or Montag, Dienstag, ... etc.)
// $outMode : Only the first letter of a day name will be displayed (= 1)
// $cellWidth : Static width of the table cell
// $cellCol : Colour of the cell
function printWeekDayHeader($outArray, $outMode = "", $cellWidth = "40", $cellCol = "7777FF") {
global $calCurrentWeekName;
$lenOutArray = count($outArray);
$out = "<tr>";
$out .= "<td width=\"" . $cellWidth . "\" align=\"center\" bgcolor=\"#77FF77\">" . $calCurrentWeekName . "</td>";
for ($j = 0; $j < $lenOutArray; $j++) :
if ($outMode == "1") : $outArray[$j] = substr($outArray[$j],0,2); endif;
$out .= "<td width=\"" . $cellWidth . "\" align=\"center\" bgcolor=\"#" . $cellCol . "\">" . $outArray[$j] . "</td>";
endfor;
$out .= "</tr>";
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 = "", $cscId = "", $apType = "") {
global $db, $PHP_SELF;
global $emp_id, $usr_id, $f_selUsrId, $f_hq_id;
global $f_ap_visibility_search, $f_ap_cat_search_1, $f_ap_cat_search_2, $f_ap_cat_search_3, $f_ap_cat_search_4;
$retArray = array();
if (!is_array($f_ap_visibility_search)) : $f_ap_visibility_search = array(); endif;
$dayStringFrom = $selYearFrom . "-" . pad($selMonthFrom,2,"0") . "-" . pad($selDayFrom,2,"0");
$dayStringTo = $selYearTo . "-" . pad($selMonthTo,2,"0") . "-" . pad($selDayTo,2,"0");
if ($selYearTo == "" || $selMonthTo == "" || $selDayTo == "") :
$dayStringTo = $dayStringFrom;
endif;
// Filter to display appointments of other users
$whereClauseCreatorFilter = " AND (ap.usr_id = '" . $f_selUsrId . "' OR ap.ap_participants LIKE '%," . $f_selUsrId . ",%') ";
if ($f_selUsrId == "0") :
$whereClauseCreatorFilter = "";
endif;
// Filter to display appointments of special type
$whereClauseApType = "";
if ($apType != "" && is_numeric($apType) && $apType > 0) :
$whereClauseApType = " AND ap.ap_type = '" . $apType . "' ";
endif;
// Filter according to selected categories
$whereClauseCategoryFilter = "";
// State: Business, private
if ($f_ap_cat_search_1 != "") : $whereClauseCategoryFilter .= " AND ap.ap_category_1 = '" . $f_ap_cat_search_1 . "' "; endif;
// ...
// if ($f_ap_cat_search_2 != "") : $whereClauseCategoryFilter .= " AND ap.ap_category_2 = '" . $f_ap_cat_search_2 . "' "; endif;
// Kind: Misc., Meeting, conference, visit, ...
if ($f_ap_cat_search_3 != "") : $whereClauseCategoryFilter .= " AND ap.ap_category_3 = '" . $f_ap_cat_search_3 . "' "; endif;
// Deadline monitoring
if ($f_ap_cat_search_4 != "") : $whereClauseCategoryFilter .= " AND ap.ap_category_4 = '" . $f_ap_cat_search_4 . "' "; endif;
// Visibility
/*
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
1 nur für Teilnehmer
2 nur für mich
3 für alle
*/
$whereClauseVisibilityFilter = "";
$whereClauseVisibilityFilterArray = array();
$lenApVisibilitySearch = count($f_ap_visibility_search);
if ($lenApVisibilitySearch > 0) :
for ($i = 0; $i < $lenApVisibilitySearch; $i++) :
$tmpApVisibilityArray[$f_ap_visibility_search[$i]] = "1";
endfor;
if (!($tmpApVisibilityArray[3] == "1" && $tmpApVisibilityArray[4] == "1" && $tmpApVisibilityArray[5] == "1" &&
$tmpApVisibilityArray[7] == "1" && $tmpApVisibilityArray[8])) :
if ($tmpApVisibilityArray[3] == "1") :
$whereClauseVisibilityFilterArray[] = " (ap.usr_id = '" . $usr_id . "' AND ap.ap_category_2 = '2') ";
endif;
if ($tmpApVisibilityArray[4] == "1") :
$whereClauseVisibilityFilterArray[] = " (ap.usr_id = '" . $usr_id . "' AND ap.ap_category_2 = '1') ";
endif;
if ($tmpApVisibilityArray[5] == "1") :
$whereClauseVisibilityFilterArray[] = " (ap.usr_id = '" . $usr_id . "' AND ap.ap_category_2 = '3') ";
endif;
if ($tmpApVisibilityArray[7] == "1") :
$whereClauseVisibilityFilterArray[] = " (ap.usr_id != '" . $usr_id . "' AND ap.ap_participants LIKE '%," . $usr_id . ",%') ";
endif;
if ($tmpApVisibilityArray[8] == "1") :
$whereClauseVisibilityFilterArray[] = " (ap.usr_id != '" . $usr_id . "' AND NOT (ap.ap_participants LIKE '%," . $usr_id . ",%')) ";
endif;
$whereClauseVisibilityFilter = " AND (" . implode(" OR ", $whereClauseVisibilityFilterArray) . ") ";
endif;
endif;
// Check for special customer
$whereClauseCs = "";
if ($csId != "" && is_numeric($csId)) :
$whereClauseCs = " AND ap.cs_id = '" . $csId . "' ";
endif;
// Check for special costcenter
$whereClauseCsc = "";
if ($cscId != "" && is_numeric($cscId)) :
$whereClauseCsc = " AND ap.csc_id = '" . $cscId . "' ";
endif;
// Check for headquarters
$whereClauseHq = "";
if (count($f_hq_id) > 0) :
$whereClauseHq = " AND ap.hq_id IN " . getSQLMandatorArray($f_hq_id) . " ";
endif;
$sqlStmt = "SELECT ap.ap_id, ap.ap_type, ap.ap_text, ap.ap_confirmed, 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, ap.csc_id,"
. " ap.ap_category_1, ap.ap_category_2, ap.ap_category_3, ap.ap_category_4,"
. " cs_usr.usr_firstname AS cs_usr_firstname, cs_usr.usr_name AS cs_usr_name,"
. " cs_usr.usr_phone AS cs_usr_phone, cs_usr.usr_phone2 AS cs_usr_phone2"
. " FROM phoenix_group.appointment AS ap"
. " LEFT JOIN phoenix.customer AS cs ON ap.cs_id = cs.cs_id"
. " LEFT JOIN phoenix.company AS cmp ON cs.cmp_id = cmp.cmp_id"
. " LEFT JOIN phoenix.user AS usr ON ap.usr_id = usr.usr_id"
. " LEFT JOIN phoenix.employee AS cs_emp ON cs.cs_admin = cs_emp.emp_id"
. " LEFT JOIN phoenix.user AS cs_usr ON cs_emp.usr_id = cs_usr.usr_id"
. " WHERE ((ap.ap_execdate >= ' " . $dayStringFrom . " 00:00:00' AND"
. " ap.ap_execdate <= ' " . $dayStringTo . " 23:59:59') OR"
. " (ap.ap_execdate < ' " . $dayStringFrom . " 00:00:00' AND"
. " ap.ap_enddate >= ' " . $dayStringFrom . " 00:00:00'))"
. $whereClauseCategoryFilter . $whereClauseVisibilityFilter . $whereClauseCreatorFilter . $whereClauseCs . $whereClauseCsc . $whereClauseHq . $whereClauseApType
. " ORDER BY ap.ap_execdate";
// echo $sqlStmt . "<br>";
$result = $db->dbQ($sqlStmt);
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"], $row["ap_confirmed"], $row["cs_usr_firstname"], $row["cs_usr_name"], $row["cs_usr_phone"], $row["cs_usr_phone2"], $row["ap_category_1"], $row["ap_category_2"], $row["ap_category_3"], $row["ap_category_4"], $row["csc_id"], $row["ap_type"]);
endwhile;
$result->free();
return $retArray;
}
// 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) {
$tmpApArray = array();
$lenApArray = count($apArray);
for ($i = 0; $i < $lenApArray; $i++) :
$tmpExecDate = substr($apArray[$i][2],0,10);
$tmpExecTime = substr($apArray[$i][2],11,5);
$tmpEndDateTime = $apArray[$i][8];
$tmpEndDate = substr($apArray[$i][8],0,10);
if ($tmpExecDate == $tmpEndDate) :
if ($lowerRangeDate <= $tmpExecDate && $tmpExecDate <= $upperRangeDate) :
$tmpApArray[] = $apArray[$i]; // Start day of the appointment
endif;
else :
$apArray[$i][8] = $tmpExecDate . " 23:59:59";
if ($lowerRangeDate <= $tmpExecDate && $tmpExecDate <= $upperRangeDate) :
$tmpApArray[] = $apArray[$i]; // Start day of the appointment
endif;
while ($tmpExecDate != $tmpEndDate) :
$tmpExecDate = date("Y-m-d", mktime(0,0,0,substr($tmpExecDate,5,2),substr($tmpExecDate,8,2)+1,substr($tmpExecDate,0,4)));
$apArray[$i][2] = $tmpExecDate . " 00:00:00";
$apArray[$i][21] = "0"; // Do not display "alarm"
if ($tmpExecDate == $tmpEndDate) :
$apArray[$i][8] = $tmpEndDateTime;
else :
$apArray[$i][8] = $tmpExecDate . " 23:59:59";
endif;
if ($lowerRangeDate <= $tmpExecDate && $tmpExecDate <= $upperRangeDate) :
$tmpApArray[] = $apArray[$i];
endif;
endwhile;
endif;
endfor;
// Sort $tmpApArray[] per "ExecDate" and restore to $apArray
$apArray = array(); // First reset $apArray
$lenTmpApArray = count($tmpApArray);
for ($i = 0; $i < $lenTmpApArray; $i++) :
$minDate = "2100-12-31 23:59:59";
for ($j = 0; $j < $lenTmpApArray; $j++) :
if ($tmpApArray[$j] != "") :
$minDate = min($minDate, $tmpApArray[$j][2]);
endif;
endfor;
for ($j = 0; $j < $lenTmpApArray; $j++) :
if ($tmpApArray[$j] != "") :
if ($tmpApArray[$j][2] == $minDate) :
$apArray[] = $tmpApArray[$j];
$tmpApArray[$j] = "";
endif;
endif;
endfor;
endfor;
return $apArray;
}
// Gets the appointments of one day
function getAppointmentsOfOneDay($selYear, $selMonth, $selDay, $csId = "") {
$apArray = getAppointmentsFromDB($selYear, $selMonth, $selDay, $selYear, $selMonth, $selDay, $csId);
return $apArray;
}
// Gets the appointments of one week
function getAppointmentsOfOneWeek($selWeek, $selYear, $selMonth, $selDay, $csId = "") {
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), $csId);
// Modifies array according to the appointments starting and ending on different days
$apArray = modifyIntervalAppointments2SingleDayAppointments($apArray, $weekBeginDate, $weekEndDate);
return $apArray;
}
// Gets the appointments of one month
function getAppointmentsOfOneMonth($selYear, $selMonth, $csId = "") {
global $calCurrentWeekNum, $calWeekDays, $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], $csId);
$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);
return $apArray;
}
// Gets the appointments of one year
function getAppointmentsOfOneYear($selYear, $csId = "") {
global $calCurrentWeekNum, $calWeekDays;
global $calMonthNames, $calMonthDays;
$apArray = array();
for ($j = 1; $j <= 12; $j++) :
$apArray = array_merge($apArray, getAppointmentsOfOneMonth($selYear, $j, $csId));
endfor;
return $apArray;
}
// Gets an array with days of a specified month (and year), where there is at least one appointment per day
function getDaysWithAppointments($selYear, $selMonth, $csId = "") {
global $db, $PHP_SELF;
global $emp_id, $usr_id, $calMonthDays, $f_selUsrId;
$dayArray = array();
if ($f_selUsrId == "") : $f_selUsrId = $usr_id; endif;
if (substr($selMonth,0,1) == "0") : $selMonth = substr($selMonth,-1); endif; // kind of typecast
$tmpArray = getAppointmentsFromDB($selYear, $selMonth, 1, $selYear, $selMonth, $calMonthDays[$selMonth - 1], $csId);
// Iterate all days of the current month displayed
for ($i = 1; $i <= $calMonthDays[$selMonth - 1]; $i++) :
$tmpDate = date("Y-m-d", mktime(0,0,0,$selMonth,$i,$selYear));
$tmpArrayLen = count($tmpArray);
for ($j = 0; $j < $tmpArrayLen; $j++) :
$tmpExecdate = substr($tmpArray[$j][2],0,10);
$tmpEnddate = substr($tmpArray[$j][8],0,10);
if ($tmpExecdate <= $tmpDate && $tmpDate <= $tmpEnddate) :
mcArrIsSet($dayArray, $i);
$dayArray[$i] = "1"; // appointment does exist on this day
endif;
endfor;
endfor;
return $dayArray;
}
// Generates the output of all days of the selected month and year
// $selYear : Selected year
// $selMonth : Selected month
// $cellWidth : Static width of the table cell
// $cellCol : Colour of the cell
// $appointmentLink : If equals "" then only display the day without link according any logic (usage as "normal calendar")
// $checkExistingAppointments : If equals "" then do NOT check for appointments (usage as "normal calendar")
function printWeekDays($selYear, $selMonth ,$cellWidth = "40", $cellCol = "AAAAFF", $appointmentLink = "", $checkExistingAppointments = "", $csId = "") {
global $calMonthDays;
global $f_selUsrId, $f_ap_cat_search_1, $f_ap_cat_search_2, $f_ap_cat_search_3, $f_ap_cat_search_4;
// 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);
// Checks existence of appointments of the selected month if requested
if ($checkExistingAppointments != "") :
$dayArray = getDaysWithAppointments($selYear, $selMonth, $csId);
endif;
$dayCounter = 1;
$out = "<tr>";
for ($i = 1; $i < 7; $i++) :
// Display the calendar week
$out .= "<td width=\"" . $cellWidth . "\" align=\"center\" bgcolor=\"#AAFFAA\">";
if ($appointmentLink == "1") :
$tmpSelYearOnlyForDisplay = $selYear;
// Only for the link adapt the year ...
if ($selMonth == 12 && $calFirstWeekNumofTheMonth <= 2) :
$tmpSelYearOnlyForDisplay++;
elseif ($selMonth == 1 && $calFirstWeekNumofTheMonth >= 52) :
$tmpSelYearOnlyForDisplay--;
endif;
/*
$out .= "<a href=\"../groupware/appointment.php?viewMode=" . ec("2") . "&selWeek=" . ec($calFirstWeekNumofTheMonth) . "&selYear=" . ec($tmpSelYearOnlyForDisplay) . "&selMonth=" . ec($selMonth) .
"&f_selUsrId=" . $f_selUsrId .
"&f_ap_cat_search_1=" . ec($f_ap_cat_search_1) . "&f_ap_cat_search_2=" . ec($f_ap_cat_search_2) . "&f_ap_cat_search_3=" . ec($f_ap_cat_search_3) .
"\" target=\"_self\">" . $calFirstWeekNumofTheMonth . "</a>";
*/
$out .= "<a href=\"javascript:finishPageCalendarWeekLink('" . ec($calFirstWeekNumofTheMonth) . "','" . ec($tmpSelYearOnlyForDisplay) . "');\">" . $calFirstWeekNumofTheMonth . "</a>";
// elseif ($appointmentLink == "2") :
// $out .= $calFirstWeekNumofTheMonth;
else :
$out .= $calFirstWeekNumofTheMonth;
endif;
$out .= "</td>";
// 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
else :
if ($checkExistingAppointments != "") :
// if (!(array_search($dayCounter, $dayArray) === FALSE)) :
mcArrIsSet($dayArray, $dayCounter);
if ($dayArray[$dayCounter] == "1") :
$cellCol2 = "FFAAAA"; // Pink
endif;
endif;
endif;
$out .= "<td width=\"" . $cellWidth . "\" align=\"center\" bgcolor=\"#" . $cellCol2 . "\">";
if ($appointmentLink == "1") :
/*
$out .= "<a href=\"../groupware/appointment.php?viewMode=" . ec("0") . "&selYear=" . ec($selYear) . "&selMonth=" . ec($selMonth) . "&selDay=" . ec($dayCounter) .
"&f_selUsrId=" . $f_selUsrId .
"&f_ap_cat_search_1=" . ec($f_ap_cat_search_1) . "&f_ap_cat_search_2=" . ec($f_ap_cat_search_2) . "&f_ap_cat_search_3=" . ec($f_ap_cat_search_3) .
"\" target=\"_self\">" . $dayCounter . "</a>";
*/
$out .= "<a href=\"javascript:finishPageCalendarDayLink('" . ec($dayCounter) . "');\">" . $dayCounter . "</a>";
elseif ($appointmentLink == "2") :
// $out .= "<a href=\"javascript:setResubmissionDate('" . $selYear . "','" . $selMonth . "','" . $dayCounter . "');\">" . $dayCounter . "</a>";
$out .= "<a href=\"javascript:finishPageCalendarDayLink('" . ec($dayCounter) . "');\">" . $dayCounter . "</a>";
else :
$out .= $dayCounter;
endif;
$out .= "</td>";
$dayCounter++;
else :
$out .= "<td width=\"" . $cellWidth . "\" align=\"center\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
endif;
endfor;
if ($i < 6) : $out .= "</tr><tr>"; 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 .= "</tr>";
return $out;
}
// Prints the action fields to select a special month and a special year
// $selYear : Selected year
// $selMonth : Selected month
// $cellWidth : Static width of the table cell
// $cellCol : Colour of the cell
function printActionFields($selYear, $selMonth, $cellWidth = "80", $cellCol = "FF7777") {
global $calMonthNames;
$monthsToSelect = "<select class=\"f8np1\" name=\"selMonth\">" . addOptionsFromTable("metatype","mt_sort","mt_value","mt_sort","mt_type = 'cal_months'",(int)$selMonth) . "</select>";
$yearToSelect = "<select class=\"f8np1\" name=\"selYear\">" . addOptionsFromRange(1971, (date("Y") + 10), $selYear) . "</select>";
// $yearToSelect = "<input type=\"text\" name=\"selYear\" value=\"" . $selYear . "\" size=\"4\" maxlength=\"4\">";
$out = "<tr>";
$out .= "<td colspan=\"3\" width=\"" . $cellWidth . "\" align=\"center\" bgcolor=\"#" . $cellCol . "\">" . $monthsToSelect . "</td>";
// $out .= "<td colspan=\"2\" align=\"center\" bgcolor=\"#" . $cellCol . "\"><input type=\"submit\" name=\"action\" value=\"Anz.\"></td>";
$out .= "<td colspan=\"2\" align=\"center\" bgcolor=\"#" . $cellCol . "\">" . defineButtonType10(getLngt("Anz."), "action_show", "finishPage();", "60", "", "") . "</td>";
$out .= "<td colspan=\"3\" width=\"" . $cellWidth . "\" align=\"center\" bgcolor=\"#" . $cellCol . "\">" . $yearToSelect . "</td>";
$out .= "</tr>";
return $out;
}
// ************************
// *** REPORT FUNCTIONS ***
// ************************
// Gets a report list according to a special customer
function getReportListStatement ($fromDateRange, $toDateRange, $rpObjType = "cs", $rpObjId = "", $rpType = "", $isMeta = "0", $csParentIdArray = array()) {
global $db, $PHP_SELF;
global $f_hq_id, $emp_id, $usr_id, $limitOfRowsDisplayed;
if ($limitOfRowsDisplayed == "") : $limitOfRowsDisplayed = "50"; endif;
if ($fromDateRange == "") :
$currentMonth = getDateTime("month");
if ($currentMonth >= 7) :
$fromDateRange = getDateTime("year") . "-07-01" . " 00:00:00";
else :
$fromDateRange = getDateTime("year") . "-01-01" . " 00:00:00";
endif;
endif;
if ($toDateRange == "") :
$toDateRange = getDateTime("3") . " 23:59:59";
endif;
$fieldClause = "rp.rp_id, rp.hq_id, rp.rp_objid, rp.usr_id, rp.rp_reporttype, rp.rp_text, rp.rp_confidential, rp.rp_createtime, "
. "usr.usr_firstname, usr.usr_name, usr.usr_phone, "
. "CONCAT(usr.usr_firstname,'<br>',usr.usr_name,'<br>',usr.usr_phone) AS usr_data, CONCAT(rp.rp_id,',',rp.usr_id,',',rp.rp_reporttype,',',rp.rp_confidential) AS rp_actions, hq.hq_name";
$whereClause = "";
$whereClauseRp = "";
if ($rpObjType == "cs") :
$fieldClause .= ", cmp.cmp_comp, cmp.cmp_comp2, cs.cs_eid AS eid";
$fieldClause .= ", CONCAT(cmp.cmp_comp,',',cmp.cmp_comp2,',',cs.cs_eid) AS rp_data ";
$fromClause = "phoenix.customer AS cs, phoenix.company AS cmp, ";
if ($rpObjId != "") :
$whereClauseRp = " rp.rp_objtype = '" . $rpObjType . "' AND rp.rp_objid = '" . $rpObjId . "' AND ";
if ($isMeta == "1") :
$whereClauseRp = " rp.rp_objtype = '" . $rpObjType . "' AND rp.rp_objid IN (" . implode($csParentIdArray, ",") . ") AND ";
endif;
endif;
$whereClause = "rp.rp_objid = cs.cs_id AND cs.cmp_id = cmp.cmp_id AND ";
elseif ($rpObjType == "cr") :
$fieldClause .= ", cmp.cmp_comp, cmp.cmp_comp2, cr.cr_eid AS eid";
$fieldClause .= ", CONCAT(cmp.cmp_comp,',',cmp.cmp_comp2,',',cr.cr_eid) AS rp_data ";
$fromClause = "phoenix.courier AS cr, phoenix.company AS cmp, ";
if ($rpObjId != "") :
$whereClauseRp = " rp.rp_objtype = '" . $rpObjType . "' AND rp.rp_objid = '" . $rpObjId . "' AND ";
if (FALSE && $isMeta == "1") :
$whereClauseRp = " rp.rp_objtype = '" . $rpObjType . "' AND rp.rp_objid IN (" . implode($crParentIdArray, ",") . ") AND ";
endif;
endif;
$whereClause = "rp.rp_objid = cr.cr_id AND cr.cmp_id = cmp.cmp_id AND ";
endif;
$fromClause .= "phoenix.headquarters AS hq, phoenix_group.report_process AS rp "
. "LEFT JOIN phoenix.user AS usr ON rp.usr_id = usr.usr_id ";
$whereClause .= $whereClauseRp
. $whereClause
. "rp.hq_id IN " . getSQLMandatorArray($f_hq_id) . " AND rp.hq_id = hq.hq_id AND "
. "rp.rp_createtime >= '$fromDateRange' AND rp.rp_createtime <= '$toDateRange'";
// Filter report type
if (is_numeric($rpType) && $rpType > "0") :
$whereClause .= " AND rp.rp_reporttype = '" . $rpType . "' ";
endif;
// Confidential check
/*
if (!authCheckEmployeeRights($emp_id, "10")) :
$whereClause .= " AND (rp.rp_confidential = '0' OR rp.usr_id = '" . $usr_id . "') ";
endif;
*/
$tmpSortField = "rp.rp_createtime";
if ($f_sort != "") :
if ($fieldArray[$f_sort] == "rp_actions") :
$tmpSortField = "rp.rp_reporttype";
else :
$tmpSortField = $fieldArray[$f_sort];
endif;
endif;
$orderByClause = $tmpSortField . " DESC LIMIT 0," . $limitOfRowsDisplayed;
$sqlquery = generateStatement($fieldClause,$fromClause,$whereClause,$orderByClause);
return $sqlquery;
}
// Gets a report list according to a special customer
function getReportStatement ($rpId, $rpObjType = "cs") {
global $db, $PHP_SELF;
global $f_hq_id, $emp_id, $usr_id, $limitOfRowsDisplayed;
$fieldClause = "rp.rp_id, rp.hq_id, rp.rp_objid, rp.usr_id, rp.rp_reporttype, rp.rp_text, rp.rp_confidential, rp.rp_createtime, "
. "usr.usr_firstname, usr.usr_name, usr.usr_phone, "
. "CONCAT(usr.usr_firstname,'<br>',usr.usr_name,'<br>',usr.usr_phone) AS usr_data, CONCAT(rp.rp_id,',',rp.usr_id,',',rp.rp_reporttype,',',rp.rp_confidential) AS rp_actions, hq.hq_name";
$whereClause = "";
$orderByClause = "";
if ($rpObjType == "cs") :
$fieldClause .= ", cmp.cmp_comp, cmp.cmp_comp2, cs.cs_eid AS eid";
$fieldClause .= ", CONCAT(cmp.cmp_comp,',',cmp.cmp_comp2,',',cs.cs_eid) AS rp_data ";
$fromClause = "phoenix.customer AS cs, phoenix.company AS cmp, ";
$whereClause = "rp.rp_objid = cs.cs_id AND cs.cmp_id = cmp.cmp_id AND ";
elseif ($rpObjType == "cr") :
$fieldClause .= ", cmp.cmp_comp, cmp.cmp_comp2, cr.cr_eid AS eid";
$fieldClause .= ", CONCAT(cmp.cmp_comp,',',cmp.cmp_comp2,',',cr.cr_eid) AS rp_data ";
$fromClause = "phoenix.courier AS cr, phoenix.company AS cmp, ";
$whereClause = "rp.rp_objid = cr.cr_id AND cr.cmp_id = cmp.cmp_id AND ";
endif;
$fromClause .= "phoenix.headquarters AS hq, phoenix_group.report_process AS rp "
. "LEFT JOIN phoenix.user AS usr ON rp.usr_id = usr.usr_id ";
$whereClause .= " rp.rp_objtype = '" . $rpObjType . "' AND rp.rp_id = '" . $rpId . "' AND "
. $whereClause
. "rp.hq_id = hq.hq_id ";
$sqlquery = generateStatement($fieldClause,$fromClause,$whereClause,$orderByClause);
return $sqlquery;
}
?>

18
html/groupware/index.html Normal file
View File

@@ -0,0 +1,18 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="de">
<head>
<title>votian</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="votian"> <meta name="keywords" content="votian">
<meta http-equiv="refresh" content="0; URL=../index.php">
<link rel="stylesheet" type="text/css" href="css/phoenix.css">
</head>
<body bgcolor="#FFFFFA" leftmargin="1" topmargin="1" marginwidth="0" marginheight="0" link="#990000" vlink="#990000" alink="#990000">
<a href="../index.php">Bitte hier klicken, wenn Sie nicht automatisch weitergeleitet werden...</a>
</body>
</html>

1297
html/groupware/report.php Normal file

File diff suppressed because it is too large Load Diff

553
html/groupware/task.php Normal file
View File

@@ -0,0 +1,553 @@
<?php
/*=======================================================================
*
* task.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
include_once ("../include/auth.inc.php");
include_once ("../include/html.inc.php");
include_once ("../include/inc_filters.inc.php");
include_once ('../include/email/htmlMimeMail.php');
// Check for authentication access and granted rights
$usrAccessArray["hq"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
authCheckEmployeeRights($emp_id, "0", "1");
authCheckEmployeeRights($emp_id, "11", "1");
getSecHttpVars("1", array("f_act", "viewMode", "selYear", "selMonth", "selDay",
"f_text", "f_hour", "f_minute", "f_hour_to", "f_minute_to",
"f_apIdToRemove", "f_apIdToUpdate", "f_usr_id", "f_selUsrId",
"f_hq_id", "g_cs_eid", "f_sendmail"));
getSecHttpVars("1", array("f_text_" . $f_apIdToUpdate));
// Initialisations
if ($selYear == "") : $selYear = date("Y"); endif;
if ($selMonth == "") : $selMonth = date("m"); endif;
if ($selDay == "") : $selDay = date("d"); endif;
if ($viewMode == "") : $viewMode = "1"; endif; // Only the selected day (= 1), the selected week (= 2)
// Definiton of global parameters
include_once ("../include/inc_calendar.inc.php");
// Current number of headquarters of the mandator
$numOfHq = getCountOfTable("mandatorheadquarters", "md_id = '" . $md_id . "'");
// 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;
$f_text = trim($f_text);
$g_cs_eid = trim($g_cs_eid);
if ($f_selUsrId == "") : $f_selUsrId = $usr_id; endif;
// Flag email to participants
if ($f_sendmail == "" || count($f_sendmail) == 0) :
$f_sendmail = "0";
else:
$f_sendmail = "1";
endif;
// Functions
// Prints the headline with the current day
// $selYear : Selected year
// $selMonth : Selected month
// $selDay : Selected day
// $cellCol : Colour of the cell
function printAppointmentCurrentDayHeader($selYear, $selMonth, $selDay, $cellCol = "77FF77") {
global $calWeekDays,$calCurrentDayNumOfTheWeek, $calMonthNames;
global $calCurrentWeekNum, $calCurrentWeekName, $calCurrentDayNumOfTheYear;
$out = "<tr>";
$out .= "<td align=\"left\" bgcolor=\"#" . $cellCol . "\"><b>";
$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 .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$out .= $calCurrentWeekName . " " . $calCurrentWeekNum; // calendar week (E.g.: "KW 26")
$out .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
$out .= $calCurrentDayNumOfTheYear . ". Tag des Jahres";
$out .= "</b></td>";
$out .= "</tr>";
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 = "<tr>";
$out .= "<td width=\"50\" align=\"center\" bgcolor=\"#" . $cellCol . "\"><b>Beginn</b></td>";
$out .= "<td width=\"50\" align=\"center\" bgcolor=\"#" . $cellCol . "\"><b>Ende</b></td>";
$out .= "<td width=\"150\" align=\"left\" bgcolor=\"#" . $cellCol . "\"><b>Ersteller</b></td>";
$out .= "<td width=\"150\" align=\"left\" bgcolor=\"#" . $cellCol . "\"><b>Teilnehmer</b></td>";
$out .= "<td align=\"left\" bgcolor=\"#" . $cellCol . "\"><b>Beschreibung</b></td>";
$out .= "<td width=\"200\" align=\"left\" bgcolor=\"#" . $cellCol . "\"><b>Kunde</b></td>";
$out .= "<td width=\"80\" align=\"center\" bgcolor=\"#" . $cellCol . "\"><b>Aktion</b></td>";
$out .= "</tr>";
if (authCheckEmployeeRights($emp_id, "10")) :
$out .= "<tr>";
$out .= "<td width=\"50\" align=\"center\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
$out .= "<td width=\"50\" align=\"center\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
$out .= "<td width=\"150\" align=\"left\" bgcolor=\"#" . $cellCol . "\"><select name=\"f_selUsrId\" onChange=\"submit();\"><option value=\"all\">Alle</option>\n" . addOptionsFromTable("user","usr_id","CONCAT(usr_name,', ',usr_firstname)","usr_name","usr_type = '1' AND hq_id IN " . getSQLMandatorArray($f_hq_id),$f_selUsrId) . "</select></td>";
$out .= "<td width=\"150\" align=\"left\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
$out .= "<td align=\"left\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
$out .= "<td width=\"200\" align=\"left\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
$out .= "<td width=\"80\" align=\"center\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
$out .= "</tr>";
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 . "<br>";
$result = $db->query($sqlStmt);
if (DB::isError($result)) die ("$PHP_SELF: <br>$sqlStmt<br>" . $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 = "<tr>";
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 .= "<td width=\"50\" align=\"center\" valign=\"center\" bgcolor=\"#" . $cellCol . "\"><b>" . $tmpExecDate . "</b></td>";
if ($tmpEndDate != "00:00") :
$out .= "<td width=\"50\" align=\"center\" valign=\"center\" bgcolor=\"#" . $cellCol . "\"><b>" . $tmpEndDate . "</b></td>";
else :
$out .= "<td width=\"50\" align=\"left\" valign=\"center\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
endif;
// User
if ($tmpUsrId != "") :
$out .= "<td width=\"150\" align=\"left\" valign=\"center\" bgcolor=\"#" . $cellCol . "\">" . $tmpUsrFirstname . "<br>" . $tmpUsrName . "</td>";
else :
$out .= "<td width=\"150\" align=\"left\" valign=\"center\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
endif;
// Participants
$out .= "<td width=\"150\" align=\"left\" valign=\"center\" bgcolor=\"#" . $cellCol . "\">";
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 . "<br>";
endfor;
else :
$out .= "&nbsp;";
endif;
$out .= "</td>";
// Text (Edit, read only)
if ($f_apIdToUpdate == $tmpId) :
$out .= "<td align=\"left\" valign=\"center\" bgcolor=\"#" . $cellCol . "\"><textarea name=\"f_text_" . $tmpId . "\" cols=\"50\" rows=\"5\">" . $tmpText . "</textarea></td>";
else :
$out .= "<td align=\"left\" valign=\"center\" bgcolor=\"#" . $cellCol . "\">" . $tmpText . "</td>";
endif;
// Potential customer relation (Company name and EID)
if ($tmpCsId != "") :
$out .= "<td width=\"200\" align=\"left\" valign=\"center\" bgcolor=\"#" . $cellCol . "\">" . $tmpCmpComp . "<br>" . ($tmpCmpComp2 != "" ? $tmpCmpComp2 . "<br>" : "") . $tmpCsEid . "<br>"
. "<input type=\"button\" name=\"action\" value=\"Details\" onClick=\"openCustomerSpecial('" . $tmpCmpId . "');\">"
. "<input type=\"button\" name=\"action\" value=\"Historie\" onClick=\"getCsHistory('" . $tmpCsEid . "');\">"
. "<input type=\"button\" name=\"action\" value=\"Statistik\" onClick=\"openCustomerStatistics('" . $tmpCsEid . "');\">"
. "</td>";
else :
$out .= "<td width=\"200\" align=\"left\" valign=\"center\" bgcolor=\"#" . $cellCol . "\">&nbsp;</td>";
endif;
// Actions
$out .= "<td width=\"80\" align=\"center\" valign=\"center\" bgcolor=\"#" . $cellCol . "\">";
if ($f_apIdToUpdate == $tmpId) :
$out .= "<input type=\"button\" name=\"action\" value=\"Speichern\" onClick=\"updateAppointmentFinishPage('" . $tmpId . "');\">";
else :
$out .= "<input type=\"button\" name=\"action\" value=\"Bearbeiten\" onClick=\"updateAppointment('" . $tmpId . "');\">";
endif;
$out .= "<br>";
$out .= "<input type=\"button\" name=\"action\" value=\"Entfernen\" onClick=\"removeAppointmentFinishPage('" . $tmpId . "');\">";
$out .= "</td>";
if ($j < $lenApArray - 1) : $out .= "</tr><tr>"; endif;
endfor;
$out .= "</tr>";
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;
?>
<html>
<head>
<title>Appointments</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
var statusMessage = "<?php echo $statusMessage ?>";
function displayStatusMessage() {
if (statusMessage != "") {
alert(statusMessage);
}
};
function finishPage() {
document.forms[0].submit();
};
function removeAppointmentFinishPage(apIdToRemove) {
if (confirm('Möchten Sie den Termin wirklich löschen?')) {
document.forms[0].f_act.value='removeAppointment';
document.forms[0].f_apIdToRemove.value=apIdToRemove;
document.forms[0].submit();
}
};
function insertAppointmentFinishPage() {
// if (confirm('Möchten Sie den Termin wirklich einfügen?')) {
document.forms[0].f_act.value='insertAppointment';
document.forms[0].submit();
// }
};
function updateAppointmentFinishPage(apIdToUpdate) {
if (confirm('Änderungen wirklich speichern?')) {
document.forms[0].f_act.value='updateAppointment';
document.forms[0].f_apIdToUpdate.value=apIdToUpdate;
document.forms[0].submit();
}
}
function updateAppointment(apIdToUpdate) {
document.forms[0].f_apIdToUpdate.value=apIdToUpdate;
document.forms[0].submit();
};
function searchCsCsc() {
var f_act = 'search';
var widthPopupWin = 950;
var heightPopupWin = 600;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../admin/cs_csc_list.php?f_act=" + f_act + "&generic=0000000000001",
"","dependent=yes,width=" + widthPopupWin + ",height=" +
heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin +
",scrollbars=yes");
};
function clearSpecialCustomer() {
document.forms[0].g_cs_eid.value='';
};
function hqCheckAll(numOfHq) {
for (i = 0; i < numOfHq; i++) {
document.getElementsByName('f_hq_id[]')[i].checked = true;
}
}
function hqUncheckAll(numOfHq) {
for (i = 0; i < numOfHq; i++) {
document.getElementsByName('f_hq_id[]')[i].checked = false;
}
}
function getCsHistory(gCsEid) {
if (gCsEid == '') {
gCsEid = document.forms[0].g_cs_eid.value;
};
if (gCsEid != '') {
var widthPopupWin = 1024;
var heightPopupWin = 768;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../groupware/cs_process.php?g_cs_eid=" + gCsEid,
"","dependent=yes,width=" + widthPopupWin + ",height=" +
heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin +
",scrollbars=yes");
} else {
alert('Wählen Sie bitte einen Kunden aus!');
};
};
function openCustomerStatistics(gCsEid) {
if (gCsEid == '') {
gCsEid = document.forms[0].g_cs_eid.value;
};
if (gCsEid != '') {
// Current date
var now = new Date();
var currentDay = now.getDate();
var currentMonth = now.getMonth();
var currentYear = now.getFullYear();
// Popup
var widthPopupWin = 900;
var heightPopupWin = 700;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../statistic/statistic.php?f_act=calculate&f_category=3&f_statistic=61&g_cs_eid=" + gCsEid + "&day_from=01&month_from=01&year_from=2004&day_to=" + currentDay + "&month_to=" + currentMonth + "&year_to=" + currentYear + "&noStatisticMenu=1&outputColumnMode=0&outputTitle=Kundenstatistik&specialAligns=l,l,l,l","","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
} else {
alert('Wählen Sie bitte einen Kunden aus!');
}
}
function openCustomerSpecial(cmpId) {
var widthPopupWin = 900;
var heightPopupWin = 700;
var leftPopupWin = (screen.width / 2) - (widthPopupWin / 2) - 12;
var topPopupWin = (screen.height / 2) - (heightPopupWin / 2) - 50;
var popupWin;
popupWin = window.open("../admin/customer_special.php?companyId=" + cmpId ,"","dependent=yes,width=" + widthPopupWin + ",height=" + heightPopupWin +",left=" + leftPopupWin + ",top=" + topPopupWin + ",scrollbars=yes");
};
-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="displayStatusMessage();">
<form action="../groupware/appointment.php" method="post">
<input type="hidden" name="f_act" value="">
<input type="hidden" name="selYear" value="<?php echo ec($selYear) ?>">
<input type="hidden" name="selMonth" value="<?php echo ec($selMonth) ?>">
<input type="hidden" name="selDay" value="<?php echo ec($selDay) ?>">
<input type="hidden" name="f_apIdToRemove" value="">
<input type="hidden" name="f_apIdToUpdate" value="">
<center>
<table align="left" border="0" width="100%">
<tr>
<td>
<table align="left" bgcolor="#000000" border="0" width="100%">
<?php
echo printAppointmentCurrentDayHeader($selYear, $selMonth, $selDay);
?>
</table>
</td>
</tr>
<?php if (authCheckEmployeeRights($emp_id, "10")) : ?>
<tr>
<td valign="center">&nbsp;Niederlassungen:&nbsp;&nbsp;&nbsp;
<?php echo addCheckboxesFromTable("f_hq_id","headquarters","hq_id","hq_name","hq_name","",$f_hq_id, "&nbsp;&nbsp;&nbsp;"); ?>&nbsp;
<input type="button" name="f_hq_check_all" value="Alle" onClick="hqCheckAll(<?php echo $numOfHq; ?>);">&nbsp;
<input type="button" name="f_hq_uncheck_all" value="Keine" onClick="hqUncheckAll(<?php echo $numOfHq; ?>);">&nbsp;&nbsp;&nbsp;
<input type="button" name="action" value="Aktualisieren" onClick="finishPage();">
<br><br>
</td>
</tr>
<?php endif; ?>
<tr>
<td>
<table align="left" bgcolor="#000000" border="0" width="100%">
<?php
echo printAppointmentTitle("FFFFFF");
echo printAppointmentsOfOneDay($selYear, $selMonth, $selDay);
?>
</table>
</td>
</tr>
<tr>
<td>
<br><br>
</td>
</tr>
<tr>
<td>
<table align="left" bgcolor="#FFFFFF" border="0" width="100%">
<tr>
<td colspan="2">
<b><u>Termin erstellen</u></b><br><br>
</td>
</tr>
<tr>
<td align="left" valign="top">
<b>Zeiten:</b><br><br>
Von:
<select name="f_hour"> <?php echo addOptionsFromRange(0, 23, date("H"), "", 2, "0"); ?> </select>&nbsp;
<select name="f_minute"> <?php echo addOptionsFromRange(0, 59, date("i"), "", 2, "0"); ?> </select> Uhr<br><br>
Bis: &nbsp;
<select name="f_hour_to"> <?php echo addOptionsFromRange(0, 23, "", "1", 2, "0"); ?> </select>&nbsp;
<select name="f_minute_to"> <?php echo addOptionsFromRange(0, 59, "", "1", 2, "0"); ?> </select> Uhr&nbsp;&nbsp;
</td>
<td align="left" valign="top">
<b>Teilnehmer:</b><br><br>
<?php // echo addCheckboxesFromTable("f_usr_id","user","usr_id","CONCAT(usr_name,', ',usr_firstname)","usr_name","usr_type = '1' AND hq_id IN " . getSQLMandatorArray($f_hq_id) ,"", "<br>"); ?>
<?php echo addCheckboxesFromTable("f_usr_id","user AS usr, headquarters AS hq","usr.usr_id","CONCAT(usr_name,', ',usr_firstname,' [',hq_name,']')","usr.usr_name","usr.usr_type = '1' AND usr.hq_id = hq.hq_id AND usr.hq_id IN " . getSQLMandatorArray($f_hq_id) ,"", "<br>"); ?>
</td>
<td align="center" valign="top">
<b>Text:</b><br><br>
<textarea name="f_text" cols="50" rows="5"></textarea>
</td>
<td align="center" valign="top">
<b>Kunde zuordnen:</b><br><br>
<input type="text" name="g_cs_eid" value="" size="10" readonly>
<input class="smaller" type="button" value="..." onClick="searchCsCsc();">
<a href="javascript:clearSpecialCustomer();" tabindex="340"><img src="../images/waste.png" border="0" height="15" width="12"></a>
<br><br>
<!-- <input type="button" name="action" value="Details" onClick="openCustomerSpecial('');"> -->
<input type="button" name="action" value="Historie" onClick="getCsHistory('');">
<input type="button" name="action" value="Statistik" onClick="openCustomerStatistics('');">
<br><br><br>
<input type="button" name="action" value="Termin einfügen" onClick="insertAppointmentFinishPage();">
<br><br>
Email an Teilnehmer versenden&nbsp;<input type="checkbox" name="f_sendmail[]" value="1">
</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
</form>
</body>
</html>

View File

@@ -0,0 +1,862 @@
<?php
/**************************************************************************\
* eGroupWare API - VCard import/export class *
* This file written by Miles Lott <milos@groupwhere.org> *
* Parse vcards->contacts class fields, and vice-versa *
* Copyright (C) 2001-2004 Miles Lott *
* ------------------------------------------------------------------------ *
* Patch: 07.12.2010 M. Vollmann *
\**************************************************************************/
class vcard
{
var $import = array(
'n' => 'n',
'sound' => 'sound',
'bday' => 'bday',
'note' => 'note',
'tz' => 'tz',
'geo' => 'geo',
'url' => 'url',
'pubkey' => 'pubkey',
'org' => 'org',
'title' => 'title',
'adr' => 'adr',
'label' => 'label',
'tel' => 'tel',
'email' => 'email'
);
var $export = array(
'fn' => 'FN',
'n_given' => 'N;GIVEN',
'n_family' => 'N;FAMILY',
'n_middle' => 'N;MIDDLE',
'n_prefix' => 'N;PREFIX',
'n_suffix' => 'N;SUFFIX',
'sound' => 'SOUND',
'bday' => 'BDAY',
'note' => 'NOTE',
'tz' => 'TZ',
'geo' => 'GEO',
'url' => 'URL',
'pubkey' => 'PUBKEY',
'org_name' => 'ORG;NAME',
'org_unit' => 'ORG;UNIT',
'title' => 'TITLE',
'adr_one_type' => 'ADR;TYPE;WORK',
'adr_two_type' => 'ADR;TYPE;HOME',
'tel_prefer' => 'TEL;PREFER',
'email_type' => 'EMAIL;TYPE;WORK',
'email_home_type' => 'EMAIL;TYPE;HOME',
'adr_one_street' => 'ADR;WORK;STREET',
'adr_one_locality' => 'ADR;WORK;LOCALITY',
'adr_one_region' => 'ADR;WORK;REGION',
'adr_one_postalcode' => 'ADR;WORK;POSTALCODE',
'adr_one_countryname' => 'ADR;WORK;COUNTRYNAME',
'address2' => 'EXT',
'label' => 'LABEL',
'adr_two_street' => 'ADR;HOME;STREET',
'adr_two_locality' => 'ADR;HOME;LOCALITY',
'adr_two_region' => 'ADR;HOME;REGION',
'adr_two_postalcode' => 'ADR;HOME;POSTALCODE',
'adr_two_countryname' => 'ADR;HOME;COUNTRYNAME',
'tel_work' => 'TEL;WORK',
'tel_home' => 'TEL;HOME',
'tel_voice' => 'TEL;VOICE',
'tel_fax' => 'TEL;FAX',
'tel_msg' => 'TEL;MSG',
'tel_cell' => 'TEL;CELL',
'tel_pager' => 'TEL;PAGER',
'tel_bbs' => 'TEL;BBS',
'tel_modem' => 'TEL;MODEM',
'tel_car' => 'TEL;CAR',
'tel_isdn' => 'TEL;ISDN',
'tel_video' => 'TEL;VIDEO',
'email' => 'EMAIL;WORK',
'email_home' => 'EMAIL;HOME',
'url_work' => 'URL;WORK',
'url_home' => 'URL;HOME'
);
var $names = array(
'family' => 'family',
'given' => 'given',
'middle' => 'middle',
'prefix' => 'prefix',
'suffix' => 'suffix'
);
function vcard()
{
/* _debug_array($this); */
}
/*
This now takes the upload filename
and parses using the class string and array processors.
The return is a contacts class entry, ready for add.
*/
function in_file($filename='')
{
if(!$filename)
{
return array();
}
$buffer = array();
$fp = fopen($filename,'r');
while($data = fgets($fp,8000))
{
list($name,$value,$extra) = explode(':', $data);
if(substr($value,0,5) == 'http')
{
$value = $value . ':'.$extra;
}
if($name && $value)
{
foreach($this->import as $fname => $fvalue)
{
if(strstr(strtolower($name), $this->import[$fname]))
{
$value = trim($value);
$value = str_replace('=0D=0A',"\n",$value);
$buffer += array($name => $value);
}
}
}
}
fclose($fp);
$entry = $this->in($buffer);
/* _debug_array($entry);exit; */
return $entry;
}
/* Try to decode strings that may be base64 encoding, otherwise assume they are QUOTED-PRINTABLE */
function decode($string)
{
$tmp = base64_decode($string);
if(base64_encode($tmp) == $string)
{
return $tmp;
}
else
{
return(str_replace('=0D=0A',"\n",$string));
}
}
function encode($string, $type='qp')
{
$out = '';
switch($type)
{
case 'qp':
$out = str_replace("\r\n",'=0D=0A',$string);
$out = str_replace("\n",'=0D=0A',$out);
break;
case 'base64':
$out = base64_encode($string);
}
return $out;
}
/*
This is here to match the old in() function, now called _parse_in().
It is called now also by in_file() above.
It takes a pre-parsed file using the methods in in_file(), returns a clean contacts class array.
*/
function in($buffer)
{
$buffer = $this->_parse_in($buffer);
return $buffer; // Patch MC
/*
$contacts = CreateObject('phpgwapi.contacts'); // RB 2001/05/08 Lotus Organizer uses/needs extrafields from edit.php
$all_fields = $contacts->stock_contact_fields + array(
'ophone' => 'ophone',
'address2' => 'address2',
'address3' => 'address3'
);
foreach($all_fields as $fname => $fvalue)
{
if($buffer[$fname])
{
$entry[$fname] = $buffer[$fname];
// echo '<br>'.$fname.' = "'.$entry[$fname].'"'."\n";
}
}
return $entry;
*/
}
/*
Pass this an associative array of fieldnames and values
returns a clean array based on contacts class std fields
This array can then be passed via $phpgw->contacts->add($ownerid,$buffer)
*/
function _parse_in($buffer)
{
/* Following is a lot of pain and little magic */
settype($buffer,'array');
foreach($buffer as $name => $value)
{
$field = explode(';',$name);
$field[0] = ereg_replace("A\.",'',$field[0]);
$field[0] = ereg_replace("B\.",'',$field[0]);
$field[0] = ereg_replace("C\.",'',$field[0]);
$field[0] = ereg_replace("D\.",'',$field[0]);
$values = explode(';',$value);
if($field[1])
{
//echo $field[0];
switch($field[0])
{
case 'LABEL':
$entry['label'] = $this->decode($values[0]);
break;
case 'NOTE':
$entry['note'] = $this->decode($values[0]);
break;
case 'ADR':
switch($field[1])
{
case 'INTL':
switch($field[2])
{
case 'WORK':
if(!stristr($buffer['adr_one_type'],$field[1]))
{
$entry['adr_one_type'] .= 'intl;';
}
if(!$buffer['adr_one_street'])
{
$entry['address2'] = $values[1];
$entry['adr_one_street'] = $values[2];
$entry['adr_one_locality'] = $values[3];
$entry['adr_one_region'] = $values[4];
$entry['adr_one_postalcode'] = $values[5];
$entry['adr_one_countryname'] = $values[6];
}
break;
case 'HOME':
if(!stristr($buffer['adr_two_type'],$field[1]))
{
$entry['adr_two_type'] .= 'intl;';
}
if(!$buffer['adr_two_street'])
{
$entry['adr_two_street'] = $values[2];
$entry['adr_two_locality'] = $values[3];
$entry['adr_two_region'] = $values[4];
$entry['adr_two_postalcode'] = $values[5];
$entry['adr_two_countryname'] = $values[6];
}
break;
default:
break;
}
break;
case 'DOM':
switch($field[2])
{
case 'WORK':
if(!stristr($buffer['adr_one_type'],$field[1]))
{
$entry['adr_one_type'] .= 'dom;';
}
if(!$buffer['adr_one_street'])
{
$entry['address2'] = $values[1];
$entry['adr_one_street'] = $values[2];
$entry['adr_one_locality'] = $values[3];
$entry['adr_one_region'] = $values[4];
$entry['adr_one_postalcode'] = $values[5];
$entry['adr_one_countryname'] = $values[6];
}
break;
case 'HOME':
if(!stristr($buffer['adr_two_type'],$field[1]))
{
$entry['adr_two_type'] .= 'dom;';
}
if(!$buffer['adr_two_street'])
{
$entry['adr_two_street'] = $values[2];
$entry['adr_two_locality'] = $values[3];
$entry['adr_two_region'] = $values[4];
$entry['adr_two_postalcode'] = $values[5];
$entry['adr_two_countryname'] = $values[6];
}
break;
default:
break;
}
break;
case 'PARCEL':
switch($field[2])
{
case 'WORK':
if(!stristr($buffer['adr_one_type'],$field[1]))
{
$entry['adr_one_type'] .= 'parcel;';
}
if(!$buffer['adr_one_street'])
{
$entry['address2'] = $values[1];
$entry['adr_one_street'] = $values[2];
$entry['adr_one_locality'] = $values[3];
$entry['adr_one_region'] = $values[4];
$entry['adr_one_postalcode'] = $values[5];
$entry['adr_one_countryname'] = $values[6];
}
break;
case 'HOME':
if(!stristr($buffer['adr_two_type'],$field[1]))
{
$entry['adr_two_type'] .= 'parcel;';
}
if(!$buffer['adr_two_street'])
{
$entry['adr_two_street'] = $values[2];
$entry['adr_two_locality'] = $values[3];
$entry['adr_two_region'] = $values[4];
$entry['adr_two_postalcode'] = $values[5];
$entry['adr_two_countryname'] = $values[6];
}
break;
default:
break;
}
break;
case 'POSTAL':
switch($field[2])
{
case 'WORK':
if(!stristr($buffer['adr_one_type'],$field[1]))
{
$entry['adr_one_type'] .= 'postal;';
}
if(!$buffer['adr_one_street'])
{
$entry['address2'] = $values[1];
$entry['adr_one_street'] = $values[2];
$entry['adr_one_locality'] = $values[3];
$entry['adr_one_region'] = $values[4];
$entry['adr_one_postalcode'] = $values[5];
$entry['adr_one_countryname'] = $values[6];
}
break;
case 'HOME':
if(!stristr($buffer['adr_two_type'],$field[1]))
{
$entry['adr_two_type'] .= 'postal;';
}
if(!$buffer['adr_two_street'])
{
$entry['adr_two_street'] = $values[2];
$entry['adr_two_locality'] = $values[3];
$entry['adr_two_region'] = $values[4];
$entry['adr_two_postalcode'] = $values[5];
$entry['adr_two_countryname'] = $values[6];
}
break;
default:
break;
}
break;
case 'WORK':
if(!$buffer['adr_one_street'])
{
$entry['address2'] = $values[1];
$entry['adr_one_street'] = $values[2];
$entry['adr_one_locality'] = $values[3];
$entry['adr_one_region'] = $values[4];
$entry['adr_one_postalcode'] = $values[5];
$entry['adr_one_countryname'] = $values[6];
}
break;
case 'HOME':
$entry['adr_two_street'] = $values[2];
$entry['adr_two_locality'] = $values[3];
$entry['adr_two_region'] = $values[4];
$entry['adr_two_postalcode'] = $values[5];
$entry['adr_two_countryname'] = $values[6];
break;
default:
if(!$buffer['adr_one_street'])
{
$entry['address2'] = $values[1];
$entry['adr_one_street'] = $values[2];
$entry['adr_one_locality'] = $values[3];
$entry['adr_one_region'] = $values[4];
$entry['adr_one_postalcode'] = $values[5];
$entry['adr_one_countryname'] = $values[6];
}
break;
}
break;
case 'TEL': // RB 2001/05/07 added for Lotus Organizer ueses TEL;{WORK|HOME};{VOICE|FAX}[;PREF]
if($field[2] == 'FAX' && ($field[1] == 'WORK' || $field[i] == 'HOME'))
{
array_shift($field); // --> ignore the WORK or HOME if FAX follows, HOME;FAX and HOME;TEL are maped later
}
switch($field[1])
{
case 'PREF':
//echo $field[2].' is preferred';
if($field[2])
{
$buffer['tel_prefer'] .= strtolower($field[2]) . ';';
}
break;
case 'WORK': // RB don't overwrite TEL;WORK;VOICE (main nr.) with TEL;WORK, TEL;WORK --> tel_isdn
$entry[$buffer['tel_work'] ? 'tel_isdn' : 'tel_work'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'HOME': // RB don't overwrite TEL;HOME;VOICE (main nr.) with TEL;HOME, TEL;HOME --> ophone
$entry[$buffer['tel_home'] ? 'ophone' : 'tel_home' ] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'VOICE':
$entry['tel_voice'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'FAX':
if($entry['tel_fax'])
{
// RB don't overwrite TEL;WORK;FAX with TEL;HOME;FAX, TEL;HOME;FAX --> ophone
$entry['ophone'] = $values[0] . ' Fax';
break;
}
$entry['tel_fax'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'MSG':
$entry['tel_msg'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'CELL':
$entry['tel_cell'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'PAGER':
$entry['tel_pager'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'BBS':
$entry['tel_bbs'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'MODEM':
$entry['tel_modem'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'CAR':
$entry['tel_car'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'ISDN':
$entry['tel_isdn'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
case 'VIDEO':
$entry['tel_video'] = $values[0];
if($field[2] == 'PREF')
{
$entry['tel_prefer'] .= strtolower($field[1]) . ';';
}
break;
default:
break;
}
break;
case 'EMAIL':
switch($field[1])
{
case 'WORK':
$entry['email'] = $values[0];
$entry['email_type'] = $field[2];
break;
case 'HOME':
$entry['email_home'] = $values[0];
$entry['email_home_type'] = $field[2];
break;
default:
if($buffer['email'])
{
$entry['email_type'] = $field[2];
}
elseif(!$buffer['email'])
{
$entry['email'] = $values[0];
$entry['email_type'] = $field[1];
}
break;
}
break;
case 'URL': // RB 2001/05/08 Lotus Organizer uses URL;WORK and URL;HOME (URL;HOME droped if both)
$entry['url'] = $values[0];
break;
default:
break;
}
}
else
{
switch($field[0])
{
case 'N':
$j=0;
foreach($this->names as $myname => $myval)
{
$namel = 'n_' . $myname;
$entry[$namel] = $values[$j];
$j++;
}
break;
case 'FN':
$entry['fn'] = $values[0];
break;
case 'TITLE':
$entry['title'] = $values[0];
break;
case 'TZ':
$entry['tz'] = $values[0];
break;
case 'GEO':
$entry['geo'] = $values[0];
break;
case 'URL':
$entry['url'] = $values[0];
break;
case 'NOTE':
$entry['note'] = $this->decode($values[0]);
break;
case 'KEY':
$entry['key'] = $this->decode($values[0]);
break;
case 'LABEL':
$entry['label'] = $this->decode($values[0]);
break;
case 'BDAY': #1969-12-31
if(strlen($values[0]) == 8)
{
$entry['bday'] = substr($values[0],4,2) . '/' . substr($values[0],6,2) . '/' . substr($values[0],0,4);
}
else
{
$tmp = explode('-',$values[0]);
if($tmp[0])
{
$entry['bday'] = $tmp[1] . '/' . $tmp[2] . '/' . $tmp[0];
}
}
break;
case 'ORG': // RB 2001/05/07 added for Lotus Organizer: ORG:Company;Department
$entry['org_name'] = $values[0];
$entry['org_unit'] = $values[1];
break;
}
}
}
$entry['tel_prefer'] = substr($buffer['tel_prefer'],0,-1);
$entry['adr_one_type'] = substr($buffer['adr_one_type'],0,-1);
$entry['adr_two_type'] = substr($buffer['adr_two_type'],0,-1);
if(count($street = explode("\r*\n",$buffer['adr_one_street'],3)) > 1)
{
$entry['adr_one_street'] = $street[0]; // RB 2001/05/08 added for Lotus Organizer to split multiline adresses
$entry['address2'] = $street[1];
$entry['address3'] = $street[2];
}
return $entry;
}
// Takes an array of contacts class fields/values, turns it into a vcard string:
//
// for($i=0;$i<count($buffer);$i++)
// {
// $vcards .= $this->vcard->out($buffer[$i]);
// }
//
function out($buffer)
{
$entry = '';
$header = 'BEGIN:VCARD' . "\n";
$header .= 'VERSION:2.1' . "\n";
// $header .= 'X-EGROUPWARE-FILE-AS:eGroupWare.org' . "\n";
foreach($this->export as $name => $value)
{
// if(!empty($buffer[$value]))
$content = $buffer[$name]; // Patch MC (parameter for substitution)
if(!empty($content)) // Patch MC
{
$mult = explode(';',$value);
if(!$mult[1])
{ // Normal
if(strstr($content,"\r\n") || strstr($content,"\n"))
{
$buffer[$name] = $this->encode($content); // Patch MC
$entry .= $value . ';QUOTED-PRINTABLE:' . $content."\n";
}
elseif($value == 'BDAY')
{
$tmp = explode('/',$content); # 12/31/1969 -> 1969-12-31
if($tmp[0])
{
if(strlen($tmp[0]) == 1) { $tmp[0] = '0'.$tmp[0]; }
if(strlen($tmp[1]) == 1) { $tmp[1] = '0'.$tmp[1]; }
$entry .= 'BDAY:' . $tmp[2] . '-' . $tmp[0] . '-' . $tmp[1] . "\n";
}
}
else
{
$entry .= $value . ':' . $content . "\n";
}
}
else
{
switch($mult[0])
{
case 'N':
switch($mult[1])
{
case 'PREFIX':
$prefix = ';' . $content;
break;
case 'GIVEN':
$firstname = ';' . $content;
break;
case 'MIDDLE':
$middle = ';' . $content;
break;
case 'FAMILY':
$lastname = $content;
break;
case 'SUFFIX':
$suffix = ';' . $content;
break;
}
break;
case 'ORG':
switch($mult[1])
{
case 'NAME':
$org_name = $content;
break;
case 'UNIT':
$org_unit = ';' . $content;
break;
}
break;
case 'ADR':
switch($mult[1])
{
case 'TYPE':
$types = explode(';',$content);
if($types[1])
{
while($type = each($types))
{
$typei[$i][$mult[2]] .= ';' . strtoupper($type[1]);
}
}
elseif($types[0])
{
$typei[$i][$mult[2]] .= ';' . strtoupper($types[0]);
}
else
{
$typei[$i][$mult[2]] .= ';' . strtoupper($content);
}
//echo "TYPE=".$typei[$i][$mult[2]];
break;
case 'WORK':
$workaddr .= $content . ';';
$workattr = $mult[0] . ';' . $mult[1] . $typei[$i][$mult[1]];
break;
case 'HOME':
$homeaddr .= $content . ';';
$homeattr = $mult[0] . ';' . $mult[1] . $typei[$i][$mult[1]];
break;
default:
break;
}
break;
case 'TEL':
switch($mult[1])
{
case 'PREFER':
$prefer = explode(';',$content);
if($prefer[1])
{
while($pref = strtoupper(each($prefer)))
{
$prefi[$i][$pref] = ';PREF';
}
//echo 'PREF1';
}
elseif($prefer[0])
{
$prefi[$i][strtoupper($prefer[0])] = ';PREF';
//echo 'PREF='.strtoupper($prefer[0]);
}
elseif($content)
{
$prefi[$i][$content] = ';PREF';
//echo 'PREF3';
}
break;
case 'WORK':
// Wow, this is fun!
$entry .= 'A.' . $mult[0] . ';' . $mult[1] . $prefi[$i][$mult[1]] . ':' . $content . "\n";
break;
case 'HOME':
$entry .= 'B.' . $mult[0] . ';' . $mult[1] . $prefi[$i][$mult[1]] . ':' . $content . "\n";
break;
default:
$entry .= $mult[0] . ';' . $mult[1] . $prefi[$i][$mult[1]] . ':' . $content . "\n";
break;
}
break;
case 'EMAIL':
switch($mult[1])
{
case 'TYPE':
if($mult[2] == 'WORK') { $emailtype = ';' . $content; }
if($mult[2] == 'HOME') { $hemailtype = ';' . $content; }
break;
case 'WORK':
$newval = 'A.'.$value;
$entry .= $newval . $emailtype . ':' . $content . "\n";
break;
case 'HOME':
$newval = 'B.' . $value;
$entry .= $newval . $hemailtype . ':' . $content . "\n";
break;
default:
break;
}
break;
case 'URL':
switch($mult[1])
{
case 'WORK':
$entry .= $value . ':' . $content . "\n";
break;
case 'HOME':
break;
default:
break;
}
break;
default:
break;
} //end switch($mult[0])
} //end else
} //end if(!empty)
} //end while
if($lastname && $firstname)
{
$entries .= $header;
$entries .= 'N:' . $lastname . $firstname . $middle . $prefix . $suffix . "\n";
$entries .= $entry;
if(!$buffer['FN'])
{
if($lastname || $firstname)
{
$entries .= 'FN:' . substr($firstname,1) . ' ' . $lastname . "\n";
}
}
if($org_name || $org_unit)
{
$entries .= 'ORG:' . $org_name . $org_unit . "\n";
}
$workattr = str_replace('ADR;','',$workattr);
$homeattr = str_replace('ADR;','',$homeattr);
if(!$buffer['EXT']) { $buffer['EXT'] = ';'; }
if($workaddr)
{
$work = 'A.ADR;' . $workattr . ':;' . $buffer['EXT'] . substr($workaddr,0,-1) . "\n";
if(!$buffer['LABEL'])
{
$wlabel = substr($workaddr,0,-1);
$wlabel = str_replace(';','=0D=0A',$wlabel);
//$wlabel = str_replace('(',',',$wlabel);
//$wlabel = str_replace(')',',',$wlabel);
$wlabel = 'LABEL;WORK;QUOTED-PRINTABLE:' . $wlabel . "\n";
}
}
if($homeaddr)
{
$home = 'B.ADR;'.$homeattr.':;;'.substr($homeaddr,0,-1)."\n";
$hlabel = substr($homeaddr,0,-1);
$hlabel = str_replace(';','=0D=0A',$hlabel);
//$hlabel = str_replace('(',',',$hlabel);
//$hlabel = str_replace(')',',',$hlabel);
$hlabel = 'LABEL;HOME;QUOTED-PRINTABLE:' . $hlabel . "\n";
}
$entries = str_replace('PUBKEY','KEY',$entries);
$entries .= $work . $home . $wlabel . $hlabel . 'END:VCARD' . "\n";
$entries .= "\n";
$buffer = $entries;
return $buffer;
}
else
{
return;
}
} //end function
} //end class
?>

View File

@@ -0,0 +1,18 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="de">
<head>
<title>votian</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="description" content="votian"> <meta name="keywords" content="votian">
<meta http-equiv="refresh" content="0; URL=../index.php">
<link rel="stylesheet" type="text/css" href="css/phoenix.css">
</head>
<body bgcolor="#FFFFFA" leftmargin="1" topmargin="1" marginwidth="0" marginheight="0" link="#990000" vlink="#990000" alink="#990000">
<a href="../index.php">Bitte hier klicken, wenn Sie nicht automatisch weitergeleitet werden...</a>
</body>
</html>