Merge branch 'spidev' into 'master'

Kalender Updates

See merge request fronk/thetool!949
This commit is contained in:
Daniel Spitzer
2025-01-27 08:33:03 +00:00
10 changed files with 408 additions and 85 deletions
+9 -1
View File
@@ -493,11 +493,19 @@ class AddressModel {
if (array_key_exists("Controller!", $filter)) {
$termstring = trim($filter['search_term!']);
$xinon= $filter['xinon'];
$termExplode = explode(" ", $termstring);
if ($xinon == 1) {
foreach ($termExplode as $term) {
$wherestring .= " AND (`customer_number` LIKE '%" . $term . "%' OR `company` LIKE '%" . $term . "%' OR `firstname` LIKE '%" . $term . "%' OR `lastname` LIKE '%" . $term . "%' OR `street` LIKE '%" . $term . "%' OR `zip` LIKE '%" . $term . "%' OR `city` LIKE '%" . $term . "%') ";
}
$where .= " AND customer_number > 0 $wherestring";
$where .= " AND customer_number > 0 $wherestring";
} else {
foreach ($termExplode as $term) {
$wherestring .= " AND (`company` LIKE '%" . $term . "%' OR `firstname` LIKE '%" . $term . "%' OR `lastname` LIKE '%" . $term . "%' OR `street` LIKE '%" . $term . "%' OR `zip` LIKE '%" . $term . "%' OR `city` LIKE '%" . $term . "%') ";
}
$where .= " AND customer_number is NULL $wherestring";
}
}
// var_dump($filter, $where);exit;
+32 -2
View File
@@ -85,7 +85,10 @@ class CalendarController extends mfBaseController
case "getAddress":
$r = $this->request;
$this->getAddress($r);
die();
case "getTicket";
$r = $this->request;
$this->getTicket($r);
die();
case "insertCalendarEvent":
$r = $this->request;
@@ -247,7 +250,8 @@ class CalendarController extends mfBaseController
private function getAddress($r)
{
$address = AddressModel::search(array("Controller!" => 'Calendar', "search_term!" => $r->term), array('count' => '20'));
$xinon = $r->xinon;
$address = AddressModel::search(array("Controller!" => 'Calendar', "search_term!" => $r->term, "xinon" => $xinon), array('count' => '20'));
$mobiles = CalendarModel::$austrian_mobile_prefixes;
$prefixes = array('0043', '43 ', '43', '0');
foreach ($address as $key => $value) {
@@ -323,6 +327,32 @@ class CalendarController extends mfBaseController
echo trim($json);
die();
}
private function getTicket($r)
{
$project = new XinonProject();
$data=$project->searchSupportTickets($r->term);
foreach ($data as $key => $value) {
$rows[] = array(
'id' => $value['id'],
'text' => 'Ticket: '.$value['id']." ".$value['subject'],
'subject' => $value['subject'],
'mail' => $value['customField5'],
'mobilenumber' => $value['customField4'],
'location' => $value['customField3'],
'name' => $value['customField2']
);
}
$json['incomplete_results'] = false;
$json['total_count'] = count($rows);
$json['items'] = $rows;
$json = json_encode($json);
echo trim($json);
die();
}
protected function indexAction()
{
+47 -9
View File
@@ -42,7 +42,12 @@ class CalendarModel
'#dbbeb3', '#e9aebc', '#b5cae7', '#dec2d4', '#aebbd5',
'#e2baaf', '#b6ebd5', '#a9c4bb', '#d7d2c5', '#d7e3d4'
];
public static $eventCategories = array(
2 => 'Gelbe Kategorie', //Xinon IBN
3 => 'Grüne Kategorie', //ESTMK IBN
4 => 'Lila Kategorie', //Snopp IBN
5 => 'Rote Kategorie', //Störung
);
public static $specialCalendarColors = array(997 => '#bd0000', 998 => '#8000A3', 999 => '#08769b');
public static function convertToSummertime($timestamp)
@@ -174,10 +179,16 @@ class CalendarModel
$where = "";
}
$visibleCalendars = $r->visibleCalendars;
$visibleCalendarTypes = $r->visibleCalendarTypes;
if ($visibleCalendars) {
$where .= " AND calendar_id IN (" . implode(",", $visibleCalendars) . ")";
$whereTimeRecording = " AND `Calendar`.`go_calendar_id` IN (" . implode(",", $visibleCalendars) . ")";
}
if ($visibleCalendarTypes) {
$where .= " AND event_type IN (" . implode(",", $visibleCalendarTypes) . ")";
}
$sql = "SELECT `cal_events`.id,`cal_events`.categories, uuid, calendar_id, `cal_events`.user_id, start_time, end_time, timezone, all_day_event, `cal_events`.name,`cal_calendars`.name calendar_name, description, location, repeat_end_time, reminder, ctime,cname, mtime,mname, muser_id, busy, status, resource_event_id, private, rrule, `cal_events`.background, `cal_events`.files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, is_organizer,event_type,busy,recurrence,rrule_events FROM cal_events INNER JOIN `cal_calendars` ON (`cal_calendars`.`id`=`cal_events`.`calendar_id`) WHERE 1=1 $where ";
$res = $dbcal->query($sql);
@@ -407,11 +418,10 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
$sql = "SELECT `id`,`name`,`customer_info_send`,`start_time`,`end_time`,`event_type` FROM `cal_events` WHERE `customer_info_reminder`= 1 AND `customer_info_send` IS NOT NULL AND `event_type` > 1 AND `start_time` BETWEEN $timecalcstart AND $timecalcend";
$res = $dbcal->query($sql);
while ($data = $dbcal->fetch_array($res))
{
while ($data = $dbcal->fetch_array($res)) {
$rows[] = array(
'id' => $data['id'],
'name' => $data['name'],
'name' => $data['name'],
'customer_info_send' => $data['customer_info_send'],
'start_time' => $data['start_time'],
'end_time' => $data['end_time'],
@@ -608,13 +618,15 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
header('Content-Type: application/json');
$db = self::dbKalender();
$sql = "SELECT `cal_events`.id,microsoft_id,uuid,ms_user_id FROM `cal_events` INNER JOIN `cal_calendars` ON (`cal_calendars`.`id`=`cal_events`.`calendar_id`) WHERE `cal_events`.id = '" . $id . "' LIMIT 1";
$sql = "SELECT `cal_events`.id,microsoft_id,uuid,ms_user_id,categories FROM `cal_events` INNER JOIN `cal_calendars` ON (`cal_calendars`.`id`=`cal_events`.`calendar_id`) WHERE `cal_events`.id = '" . $id . "' LIMIT 1";
$res = $db->query($sql);
if ($db->num_rows($res)) {
$result = $db->fetch_object($res);
$microsoft_id = $result->microsoft_id;
$cal_events_id = $result->uuid;
$microsoft_user_id = $result->ms_user_id;
$categories = json_decode($result->categories, true);
}
$updateArray['start_time'] = $start;
@@ -643,13 +655,31 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
else
$updateArray['reminder'] = $reminder;
}
if ($type)
if ($type) {
$updateArray['event_type'] = $type;
$calEventCategories = self::$eventCategories;
foreach ($calEventCategories as $key => $value) {
$arraykey = array_search($value, $categories);
if (!empty($arraykey || $arraykey === 0)) {
unset($categories[$arraykey]);
}
}
if ($type > 1) {
$categories[] = $calEventCategories[$type];
$categories = array_values($categories);
}
if ($categories) {
$updateArray['categories'] = json_encode($categories);
} else
$updateArray['categories'] = NULL;
}
if (isset($busy))
$updateArray['busy'] = $busy;
if ($type == 2) {
if ($type == 2 || $type == 3 || $type == 4) {
if ($r->customer)
$updateArray['customer'] = $r->customer;
else
@@ -815,7 +845,15 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
if ($reminder == 'NULL') {
$reminder = NULL;
}
if ($type == 2) {
$calEventCategories = self::$eventCategories;
if ($type > 1) {
$categories[] = $calEventCategories[$type];
}
if ($categories) {
$categories = json_encode($categories);
} else
$categories = NULL;
if ($type == 2 || $type == 3 || $type == 4) {
$customer = $r->customer;
$customer_info_type = $r->customer_info_type;
$customer_info_text = $r->customer_info_text;
@@ -836,7 +874,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda
$customer_info_send = NULL;
}
$dataarray = array("start_time" => $start, 'end_time' => $end, 'name' => $title, 'description' => $description, 'location' => $location, 'calendar_id' => $user_id, 'uuid' => "a5eb79b3-fca7-5378-a09e-" . rand(100000000000, 999999999999), 'user_id' => 1, 'timezone' => 'Europe/Amsterdam', 'all_day_event' => 0, 'repeat_end_time' => 0, 'reminder' => $reminder, 'ctime' => time(), 'cname' => $me->name, 'mtime' => time(), 'mname' => $me->name, 'user_id' => 1, 'busy' => $busy, 'status' => 'CONFIRMED', 'resource_event_id' => 0, 'private' => $privateflag, 'rrule' => '', 'background' => 'EBF1E2', 'files_folder_id' => 0, 'read_only' => 0, 'exception_for_event_id' => 0, 'recurrence_id' => 0, 'is_organizer' => 1, 'event_type' => $type, 'customer' => $customer, 'customer_info' => $customer_info, 'customer_info_send' => $customer_info_send, 'customer_info_reminder' => $customer_info_reminder_check);
$dataarray = array("start_time" => $start, 'end_time' => $end, 'name' => $title, 'description' => $description, 'location' => $location, 'calendar_id' => $user_id, 'uuid' => "a5eb79b3-fca7-5378-a09e-" . rand(100000000000, 999999999999), 'user_id' => 1, 'timezone' => 'Europe/Amsterdam', 'all_day_event' => 0, 'repeat_end_time' => 0, 'reminder' => $reminder, 'ctime' => time(), 'cname' => $me->name, 'mtime' => time(), 'mname' => $me->name, 'user_id' => 1, 'busy' => $busy, 'status' => 'CONFIRMED', 'resource_event_id' => 0, 'private' => $privateflag, 'rrule' => '', 'background' => 'EBF1E2', 'files_folder_id' => 0, 'read_only' => 0,'categories'=>$categories, 'exception_for_event_id' => 0, 'recurrence_id' => 0, 'is_organizer' => 1, 'event_type' => $type, 'customer' => $customer, 'customer_info' => $customer_info, 'customer_info_send' => $customer_info_send, 'customer_info_reminder' => $customer_info_reminder_check);
$db->insert("cal_events", $dataarray);
$event_id = $dataarray['uuid'];
@@ -9,7 +9,7 @@ class CalendarTemplateModel
public static $calendarTemplateEventTypes=array(
"1"=>"Termin",
"2"=>"IBN",
"2"=>"IBN Xinon",
"3"=>"IBN E-Stmk",
"4"=>"IBN Snopp",
"5"=>"Störungen"