Преглед на файлове

added Calendar for Grafik pracy

Piotr Labudda преди 9 години
родител
ревизия
91e28c4ebc
променени са 5 файла, в които са добавени 143 реда и са изтрити 0 реда
  1. 1 0
      SE/se-lib/ProcesMenu.php
  2. 75 0
      SE/se-lib/Route/UrlAction/Calendar.php
  3. 58 0
      SE/static/calendar.js
  4. 4 0
      SE/static/fullcalendar.min.css
  5. 5 0
      SE/static/fullcalendar.min.js

+ 1 - 0
SE/se-lib/ProcesMenu.php

@@ -797,6 +797,7 @@ jQuery(document).ready(function() {
 							<?php endif; ?>
 
 							<li><a href="procesy5.php?task=USER" title="<?php echo User::getName(); ?>"><i class="glyphicon glyphicon-user"></i> Profil</a></li>
+							<li><a href="index.php?_route=UrlAction_Calendar"><i class="glyphicon glyphicon-calendar"></i> Grafik pracy</a></li>
 							<li><a href="index.php?_route=UserMsgs" title="Wiadomości systemowe"><i class="glyphicon glyphicon-envelope"></i> Wiadomości</a></li>
 							<li><a href="index.php?_route=Notify" title="Powiadomienia"><i class="glyphicon glyphicon-bell"></i> Powiadomienia</a></li>
 							<li><a href="index.php?_route=Users&_task=reloadPerms" title="Przeładuj uprawnienia"><i class="glyphicon glyphicon-refresh"></i> Przeładuj uprawnienia</a></li>

+ 75 - 0
SE/se-lib/Route/UrlAction/Calendar.php

@@ -0,0 +1,75 @@
+<?php
+
+Lib::loadClass('RouteBase');
+Lib::loadClass('Config');
+Lib::loadClass('UI');
+Lib::loadClass('Request');
+Lib::loadClass('ProcesHelper');
+
+class Route_UrlAction_Calendar extends RouteBase {// TODO: UrlActionBase @see Route_UrlAction
+
+	public function handleAuth() {
+		if (!User::logged()) {
+			//throw new HttpException('Unauthorized', 401);
+			User::authByRequest();
+		}
+	}
+
+	public function defaultAction() {
+		UI::gora();
+		UI::menu();
+		try {
+			$userLogin = V::get('USER_ID', '', $_REQUEST, 'string');
+			if (empty($userLogin)) {
+				$userLogin = User::getLogin();
+			}
+			$this->showCalendar($userLogin);
+		} catch (Exception $e) {
+			UI::alert('danger', "Error: " . $e->getMessage());
+		}
+		UI::dol();
+	}
+
+	public function showCalendar($userLogin) {
+		echo "<div class=container-fluid>";
+		echo "<div class=row>";
+		echo "<div class=col-md-12 >";
+		echo "<div id=calendar style=margin-top:15px;></div>";
+		echo "</div>";
+		echo "</div>";
+		echo "<script>var BASE_URL = '".Request::getPathUri()."';var USER='".$userLogin."';var TableId=".ProcesHelper::getZasobTableID('GRAFIK_PRACY').";</script>";
+		//echo "<script>var BASE_URL = '".Request::getPathUri()."';var TASK = ".$userLogin.";var USER = '".User::getLogin()."';var TYPE='".$type."'; var ProblemsTableId=".ProcesHelper::getZasobTableID('PROBLEMS').";var ProjectsTableId=".ProcesHelper::getZasobTableID('IN7_MK_BAZA_DYSTRYBUCJI')."</script>";
+		echo '<script src="static/sweetalert2.min.js"></script>';
+		echo '<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">';
+		echo '<script src="static/fullcalendar.min.js"></script>';
+		echo '<link rel="stylesheet" href="static/fullcalendar.min.css" type="text/css" />';
+		echo '<script src="static/calendar.js?10"></script>';
+		$this->showCss();
+		//echo '<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.9.0/fullcalendar.print.css">';
+	}
+
+	public function showCss(){
+		?>
+		<style>
+		.workingHours{
+			padding:10px;
+			text-align:center;
+			font-size:1.3em;
+		}
+		.empty{
+			padding:10px;
+			text-align:center;
+			color:black;
+			opacity:0.8;
+			font-size:1.3em;
+			background-color:#ededed;
+		}
+		.empty:hover{
+			opacity:1;
+			color:black;
+		}
+		</style>
+		<?php
+	}
+
+}

+ 58 - 0
SE/static/calendar.js

@@ -0,0 +1,58 @@
+$(document).ready(function() {
+		var cached = {};
+		$('#calendar').fullCalendar({
+			header: {
+				left: 'prev,next today',
+				center: 'title',
+				right: ''
+			},
+      editable: false,
+      lang: "pl",
+			titleFormat: "MMMM YYYY [("+USER+")]",
+			editable: false,
+			viewRender: function (view, element) {
+				getWorkingHours(moment(view.start).format("YYYY-MM"));
+			},
+			eventLimit: true, // allow "more" link when too many events
+			/*events: [
+				{
+					title: '10:00 - 16:00',
+					start: '2016-08-01',
+          className: 'workingHours'
+				}
+			],*/
+		});
+
+    function getWorkingHours(date){
+			if(cached[date] != true){
+			cached[date] = true;
+			var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:GRAFIK_PRACY&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:PropertyIsLike wildCard="*" singleChar="^" escapeChar="!"><ogc:PropertyName>DATE</ogc:PropertyName><ogc:Literal>'+date+'-*</ogc:Literal></ogc:PropertyIsLike><ogc:PropertyIsEqualTo><ogc:PropertyName>L_APPOITMENT_USER</ogc:PropertyName><ogc:Literal>' + USER + '</ogc:Literal></ogc:PropertyIsEqualTo></ogc:And></ogc:Filter>';
+			//console.log(link);
+
+			$.get(link, function(data){
+				$.each($(data).find("featureMember"), function(){
+					if($(this).find("ID").text() == "0"){
+						return;
+					}
+					var source = {};
+					if(moment($(this).find("START_WORK_HOUR").text(), "HH:mm:ss").format("HH:mm") != "00:00"){
+						source["title"] = moment($(this).find("START_WORK_HOUR").text(), "HH:mm:ss").format("HH:mm")+" - "+moment($(this).find("END_WORK_HOUR").text(), "HH:mm:ss").format("HH:mm");
+						source["className"] = 'workingHours';
+					}else {
+						source["title"] = "Uzupełnij";
+						source["className"] = 'empty';
+					}
+					source["start"] = $(this).find("DATE").text();
+
+					source["url"] = BASE_URL + 'index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID='+TableId+'#EDIT/'+$(this).find("ID").text();
+
+					$('#calendar').fullCalendar( 'renderEvent', source, true );
+
+
+				});
+
+			});
+		}
+    }
+
+	});

Файловите разлики са ограничени, защото са твърде много
+ 4 - 0
SE/static/fullcalendar.min.css


Файловите разлики са ограничени, защото са твърде много
+ 5 - 0
SE/static/fullcalendar.min.js


Някои файлове не бяха показани, защото твърде много файлове са промени