Skip to content

Commit

Permalink
PDF für alle Mitarbeiter anzeigen und erstellen
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Heizmann authored and Michael Heizmann committed Dec 1, 2016
1 parent 591b172 commit 53cf261
Show file tree
Hide file tree
Showing 13 changed files with 515 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,6 +3,7 @@

#Codelobster - IDE
*.clpprj
*.csprj

# Can also ignore all directories and files in a directory.
Data/*
Expand Down
4 changes: 2 additions & 2 deletions Data/administrator/Timetable/total.txt
@@ -1,2 +1,2 @@
0
3.33
-1980.5
20
2 changes: 1 addition & 1 deletion Data/administrator/userdaten.txt
@@ -1,5 +1,5 @@
Administrator
1477954800
1451633309
100
42.5
0
Expand Down
25 changes: 23 additions & 2 deletions admin.php
Expand Up @@ -2,7 +2,7 @@
/********************************************************************************
* Small Time
/*******************************************************************************
* Version 0.9.001
* Version 0.9.004
* Author: IT-Master GmbH
* www.it-master.ch / info@it-master.ch
* Copyright (c), IT-Master GmbH, All rights reserved
Expand Down Expand Up @@ -84,7 +84,8 @@ function my_session_start()
include_once ('./include/class_rapport.php');
include_once ('./include/class_show.php');
include_once ('./include/class_settings.php');
require_once ('./include/class_table.php');
include_once ('./include/class_pdfgenerate.php');
require_once('./include/class_table.php');
include ("./include/time_funktionen.php");
// ----------------------------------------------------------------------------
// Im Admin - Bereich bis zum gewählten Monat berechnen
Expand Down Expand Up @@ -171,6 +172,24 @@ function my_session_start()
// Controller Templatedarstellung
// ----------------------------------------------------------------------------
switch($_action){
case "pdfgenerate":
if(isset($_POST['jahr']) && isset($_POST['monat'])){
$_pdfgenerate= new pdfgenerate($_POST['monat'],$_POST['jahr'], $_users);
}else{
$_jahr = date("Y", time());
$_monat = date("m", time());
$_pdfgenerate= new pdfgenerate($_monat, $_jahr,$_users);
}
if(isset($_GET['function'])){
$_template->_ajaxhtml = $_pdfgenerate->output();
}else{
$_infotext = getinfotext("PDF für alle Mitarbeiter anzeigen und erstellen","td_background_top");
$_template->_user01 = "sites_admin/admin01.php";
$_template->_user02 = "sites_admin/admin02.php";
$_template->_user04 = "sites_admin/admin04_pdfgenerate.php";
$_template->_user03 = "sites_admin/admin03.php";
}
break;
case "edit_ausz":
$auszahlung = new auszahlung($_GET['monat'],$_GET['jahr']);
$_template->_user04 = "sites_admin/admin04_auszahlung.php";
Expand Down Expand Up @@ -658,6 +677,8 @@ function setLoginForm(){
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=". $_datei);
include($_template->get_user04());
}elseif(isset($_GET['function'])){
echo $_template->_ajaxhtml;
}else{
include ($_template->get_template());
}
3 changes: 2 additions & 1 deletion changelog.txt
Expand Up @@ -2,4 +2,5 @@
* Small Time - Changelog
/********************************************************************************
V 0.9.001 28.10.2016 -> Ferien nur bis heute in den Settings eingestellt, BUG in der Anzeige
V 0.9.002 28.10.2016 -> user04_year.php -> Yahr - Anzeige kann bei alten gew�hlten Monaten falsch dargestellt werden
V 0.9.002 28.10.2016 -> user04_year.php -> Yahr - Anzeige kann bei alten gew�hlten Monaten falsch dargestellt werden
V 0.9.004 01.12.2016 -> Neues Admin Menue: PDF (anzeigen und erstellen von PDF)
4 changes: 3 additions & 1 deletion fpdf/fpdf.php
Expand Up @@ -73,7 +73,9 @@ class FPDF
* Public methods *
* *
*******************************************************************************/
function FPDF($orientation='P', $unit='mm', $size='A4')
/* Methods with the same name as their class will not be constructors in a future version of PHP
/* function FPDF($orientation='P', $unit='mm', $size='A4')*/
function __construct($orientation='P', $unit='mm', $size='A4')
{
// Some checks
$this->_dochecks();
Expand Down
90 changes: 90 additions & 0 deletions include/class_pdfgenerate.php
@@ -0,0 +1,90 @@
<?php
/*******************************************************************************
*PDF für alle Mitarbeiter generieren und anzeigen
/*******************************************************************************
* Version 0.9.004
* Author: IT-Master GmbH
* www.it-master.ch / info@it-master.ch
* Copyright (c), IT-Master GmbH, All rights reserved
*******************************************************************************/
class pdfgenerate{
public $_monat= NULL;
public $_jahr = NULL;
public $_html = NULL;
public $_users = NULL;

function __construct($monat, $jahr, $users){
$this->_monat = $monat;
$this->_jahr = $jahr;
$this->_users = $users;
$this->_html = "constructor - TEXT von pdfgenerate";
if(isset($_GET['function'])){
//wenn GET - function = createpdf -> pdf vom gewählen Monat erstellen und json übermitteln -> alle MA generieren wurde noch nicht realisiert
if($_GET['function']=='createpdf'){
$this->create_pdf($this->_monat ,$this->_jahr);
}else{
//wenn GET - function = getpdf -> pdf vom gewählen Monat anzeigen (json übermitteln)
$this->get_pdf($this->_monat , $this->_jahr);
}
}else{
//wenn nix angegeben wurde , getpdf
$this->get_pdf($this->_monat , $this->_jahr);
}
}
function create_pdf(){
//$_POST = json_decode(file_get_contents('php://input'),true);
$this->_html = "create pdf: ". $this->_monat . "." . $this->_jahr ;
}
function get_pdf(){
$arr = array();
$i=0;
unset($this->_users->_array[0]);
foreach($this->_users->_array as $user){
//Dokumenten - Pfad und Loginname
$arr[$i]['pfad'] = './Data/' . $user['0'] . '/';
$arr[$i]['pfad'] = $user['0'];
$arr[$i]['name'] = $user['1'];
// Anzeigename des Mitarbeiters
$userdata = file( './Data/' . $user['0'] . '/userdaten.txt');
$z=0;
foreach($userdata as $temp){
$userdata[$z] = trim($temp);
$z++;
}
$arr[$i]['username'] = $userdata[0];
$arr[$i]['userstart'] = $userdata[1];
$arr[$i]['userstartmonat'] = date("m", $userdata[1]);
$arr[$i]['userstartjahr'] = date("Y",$userdata[1]);
$arr[$i]['pdflink'] = './Data/' . $user['0'] . '/Dokumente/' . $this->_jahr . '.' . $this->_monat . '.pdf';
$arr[$i]['pdflinkcreate'] =' ';
$arr[$i]['pdfexist'] = '0';
// check ob file existiert
if(file_exists($arr[$i]['pdflink'] )){
$arr[$i]['pdfexist'] = '1';
// Link zum PDF
$arr[$i]['pdflink'] ='
<a id="pdfhref" href="' . $arr[$i]['pdflink'] . '" target="_new">
<img src="images/icons/page_white_acrobat.png" border="0" > -
./Data/' . $user['0'] . '/Dokumente/' . $this->_jahr . '.' . $this->_monat . '.pdf
</a>';
}else{
if( $this->_jahr < $arr[$i]['userstartjahr'] ){
$arr[$i]['pdflink'] = "vor Anstellungsbeginn";
}elseif($this->_jahr == $arr[$i]['userstartjahr'] && $this->_monat < $arr[$i]['userstartmonat']){
$arr[$i]['pdflink'] = "vor Anstellungsbeginn";
}else{
$arr[$i]['pdfexist'] = '1';
$temptime = mktime(0, 0, 0, $this->_monat, 1, $this->_jahr);
// Link um ein PDF zu erstellen
$arr[$i]['pdflinkcreate'] = '<p onclick="create('.($i+1).','.$temptime.')" class=" pdfcreate btn btn-danger">PDF erstellen</p>';
}
}
$i++;
}
$this->_html = json_encode($arr);
}
function output(){
return $this->_html;
}

}
7 changes: 4 additions & 3 deletions include/class_template.php
Expand Up @@ -18,14 +18,15 @@ class time_template{
public $_user02 = "sites_user/user02.php";
public $_user03 = "sites_user/user03.php";
public $_user04 = "sites_user/user04.php";
public $_plugin = "modules/sites_plugin/plugin_null.php";
public $_mobile = "sites_mobile/mobile.php";
public $_plugin = "modules/sites_plugin/plugin_null.php";
public $_mobile = "sites_mobile/mobile.php";
public $_modulpfad = "modules/";
public $_modal = false;
public $_jquery = false;
public $_bootstrap = false;
public $_bootstrap = false;
public $_portal_admin = false;
public $_portal_user = false;
public $_ajaxhtml = "";

function __construct($_start){
if($_COOKIE["designname"]){
Expand Down
1 change: 1 addition & 0 deletions include/defaultheader.php
Expand Up @@ -19,6 +19,7 @@
<script type="text/javascript" src="js/smalltime.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/jput.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="css/bootstrap.css">
<link rel="stylesheet" type="text/css" media="screen" href="css/jquery.ui.css">
<link rel="stylesheet" type="text/css" media="screen" href="css/bootstrap-datetimepicker.min.css">
147 changes: 147 additions & 0 deletions js/jput.js
@@ -0,0 +1,147 @@
/*
* jQuery jPut Plug-in 2.0.2
* http://plugins.jquery.com/jput/
* Develope By : Shabeer Ali M
* Home Page : http://shabeer-ali-m.github.io/jPut/
* last Update: Multiple Expression
*/
var jPut = [];
jPut.auto = !0,
function($) {
$.fn.jPut = function(options) {
function json_value(t, a) {
if ("" == t) return a;
if (-1 == t.indexOf(".")) return a[t];
t = t.split(".");
for (var e = 0; e < t.length; e++) a = a[t[e]];
return a
}

function ajax(t) {
$.ajax({
url: t.ajax_url,
data: t.ajax_data,
dataType: t.ajax_dataType,
jsonpCallback: t.ajax_jsonpCallback,
type: t.ajax_type,
success: function(a) {
-1 != t.new_data ? t.jsonData = a : t.new_data = a, process(t)
},
error: function() {}
})
}

function process(options) {
1 == options.clear && main.html("");
var arr = options.jsonData;
if ("undefined" != typeof options.new_data && -1 != options.new_data) arr = options.new_data;
else {
if ("object" != typeof arr && (arr = $.parseJSON(options.jsonData)), "object" != typeof arr) throw "Invalid JSON data!";
if (0 == options.jrepeat && null == arr) throw "JSON data is empty!";
null == arr && (arr = []), 0 != options.limit && (arr = arr.slice(0, options.limit)), options.jsonData = arr, (1 == options.singleData || "true" == options.singleData) && (arr = [arr])
}
"" != options.dataName && (arr = json_value(options.dataName, options.jsonData)), $.each(arr, function(i, json) {
"undefined" != typeof options.new_data && -1 != options.new_data ? (0 == options.prepend ? options.jsonData.push(json) : options.jsonData.unshift(json), index = options.jsonData.length - 1) : index = i, "" == options.template ? (el1 = el.clone(), options.template = el1) : el1 = options.template, jrepeat = el.find("[jrepeat]").not("[jrepeat] [jrepeat]"), jrepeat.length > 0 && jrepeat.each(function() {
$(this).attr("jrepeat-" + i, $(this).attr("jrepeat"))
}), el1_jrepeat = el1.find("[jrepeat]"), el1_jrepeat.length > 0 && el1_jrepeat.each(function() {
$(this).remove()
});
var matches = el1.html().match(regExp);
html = el.html(), null != matches && $.each(matches, function(aindex, value) {
value = $("<div/>").html(value).text();
var reg = new RegExp(value);
t = "exp1" == options.expression ? value.replace(/{{|}}/g, "") : value.replace(/{[|]}/g, "");
try {
html = html.replace(value, eval(t))
} catch (e) {
html = html.replace(value, ""), console.log("jPut:" + e.message)
}
}), html = html.replace("jsrc", "src"), 0 == options.prepend ? main.append(html) : main.prepend(html), jrepeat.length > 0 && jrepeat.each(function() {
$("[jrepeat-" + i + '="' + $(this).attr("jrepeat") + '"]').jPut({
jsonData: json[$(this).attr("jrepeat")],
name: $(this).attr("jrepeat"),
jrepeat: !0,
error: function(t) {
throw t
}
})
})
}), $.isFunction(options.done) && options.done.call(this, options.jsonData)
}
Object.defineProperty(this, "data", {
get: function() {
return options.jsonData
},
set: function(t) {
options.jsonData = t, options.new_data = -1, options.clear = !0, process(options)
}
}), this.insertAt = function(t, a) {
options.jsonData.splice(t, 0, a), process(options)
}, this.update = function(t, a) {
options.new_data = -1, options.clear = !0, options.jsonData[t] = a, process(options)
}, this.remove = function(t) {
options.clear = !0, options.jsonData.splice(t, 1), options.new_data = -1, process(options)
}, this.append = function(t) {
options.clear = !1, options.new_data = [t], process(options)
}, this.prepend = function(t) {
options.clear = !1, options.prepend = !0, options.new_data = [t], process(options)
}, this.clear = function() {
options.new_data = -1, options.clear = !0, options.jsonData = [], process(options)
}, this.bind = function() {
process(options)
}, this.call_ajax = function(t) {
options.clear = !1, options = $.extend(options, t), options.new_data = -1, ajax(options)
};
var defaults = {
name: "",
expression: "exp1",
jsonData: [],
dataName: "",
limit: 0,
prepend: !1,
clear: !0,
singleData: !1,
jrepeat: !1,
ajax_url: "",
ajax_data: "",
ajax_type: "GET",
ajax_dataType: "json",
ajax_jsonpCallback: "",
template: "",
done: function() {},
error: function() {}
},
options = $.extend({}, defaults, options),
html;
try {
var main = $(this),
el = "" == options.name ? $("[jput]").clone() : $('[jput="' + options.name + '"]').clone();
if (0 == el.length) throw "Cant find the jPut template (" + options.name + ")!";
if ("exp1" == options.expression) var regExp = /\{{([^}}]+)\}}/g;
else var regExp = /\{\[([^}}]+)\]\}/g;
var matches = el.html().match(regExp),
$this = this;
"" != options.ajax_url ? ajax(options) : process(options)
} catch (err) {
$.isFunction(options.error) && options.error.call(this, err)
}
return this.getValue = function(t) {
return options.jsonData[t]
}, this.each(function() {})
}, $.jPut = function(t) {
jPut[t.name] = $("#users").jPut(t)
}
}(jQuery), $(document).ready(function() {
if (1 == jPut.auto) {
var t = ["jsonData", "dataName", "singleData"],
a = ["jsondata", "dataname", "singledata"];
$("[jput]").each(function(e, n) {
var o = [];
el = $(n).attr("jput"), o.name = el, $(n).each(function() {
$.each(this.attributes, function() {
this.specified && (s_index = $.inArray(this.name.replace("jput-", ""), a), -1 != s_index ? o[t[s_index]] = this.value : -1 != this.name.search("jput-") && (o[this.name.replace("jput-", "")] = this.value))
})
}), jPut[el] = $(n).jPut(o)
})
}
});
1 change: 1 addition & 0 deletions modules/sites_admin/admin01.php
Expand Up @@ -20,6 +20,7 @@
<li<?php echo $_action=="import" ? ' class="active"':''; ?>><a id="Import" title="Import von csv" href="?action=import">CSV Import</a></li>
<li<?php echo $_action=="debug_info" ? ' class="active"':''; ?>><a id="Status" title="Status / Meldungen" href="?action=debug_info">Status</a></li>
<li<?php echo $_action=="idtime-generate" ? ' class="active"':''; ?>><a id="Codes" title="QR-Codes" href="?action=idtime-generate">QR-Codes</a></li>
<li<?php echo $_action=="pdfgenerate" ? ' class="active"':''; ?>><a id="pdfgenerate" title="pdfgenerate" href="?action=pdfgenerate">PDF</a></li>
<li<?php echo $_action=="logout" ? ' class="active"':''; ?>><a id="Logout" title="Logout" href="?action=logout">Logout</a></li>
</ul>
<?php
Expand Down

0 comments on commit 53cf261

Please sign in to comment.