From 015af666b2b02d850427c62911e30a17ce838198 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Thu, 30 Apr 2015 12:14:04 +0200 Subject: [PATCH 01/12] cloned seach bar in preparation for easy tracker --- templates/standard/easy-tracker.tpl | 26 ++++++++++++++++++++++++++ templates/standard/sidebar-a.tpl | 4 +++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 templates/standard/easy-tracker.tpl diff --git a/templates/standard/easy-tracker.tpl b/templates/standard/easy-tracker.tpl new file mode 100644 index 00000000..a2f87632 --- /dev/null +++ b/templates/standard/easy-tracker.tpl @@ -0,0 +1,26 @@ +
+ + + {*Easy Tracker*} +
+

{#search#}

+ + +
+ {*Easy Tracker End*} + +
diff --git a/templates/standard/sidebar-a.tpl b/templates/standard/sidebar-a.tpl index 448114fd..a833584e 100644 --- a/templates/standard/sidebar-a.tpl +++ b/templates/standard/sidebar-a.tpl @@ -88,4 +88,6 @@ {/literal} - \ No newline at end of file + + +{include file="easy-tracker.tpl"} From 13c78a465c04a9960799b3a64896829c50f24330 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Thu, 30 Apr 2015 14:00:30 +0200 Subject: [PATCH 02/12] preparing for easy timetracking --- include/js/ajax.php | 15 +++++++++++++ language/de/lng.conf | 5 +++++ managetimetracker.php | 10 +++++++++ templates/standard/easy-tracker.tpl | 22 +++++-------------- .../theme/standard/css/style_main.css | 17 ++++++++++++-- 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/include/js/ajax.php b/include/js/ajax.php index 7e2139f9..af75e31f 100644 --- a/include/js/ajax.php +++ b/include/js/ajax.php @@ -680,3 +680,18 @@ classNames : { if(typeof (Control)=="undefined"){Control={};}Control.Modal=Class.create();Object.extend(Control.Modal,{loaded:false,loading:false,loadingTimeout:false,overlay:false,container:false,current:false,ie:false,effects:{containerFade:false,containerAppear:false,overlayFade:false,overlayAppear:false},targetRegexp:/#(.+)$/,imgRegexp:/\.(jpe?g|gif|png|tiff?)$/,overlayStyles:{position:"fixed",top:0,left:0,width:"100%",height:"100%",zIndex:9998},overlayIEStyles:{position:"absolute",top:0,left:0,zIndex:9998},disableHoverClose:false,load:function(){if(!Control.Modal.loaded){Control.Modal.loaded=true;Control.Modal.ie=!(typeof document.body.style.maxHeight!="undefined");Control.Modal.overlay=$(document.createElement("div"));Control.Modal.overlay.id="modal_overlay";Object.extend(Control.Modal.overlay.style,Control.Modal["overlay"+(Control.Modal.ie?"IE":"")+"Styles"]);Control.Modal.overlay.hide();Control.Modal.container=$(document.createElement("div"));Control.Modal.container.id="modal_container";Control.Modal.container.hide();Control.Modal.loading=$(document.createElement("div"));Control.Modal.loading.id="modal_loading";Control.Modal.loading.hide();var _1=document.getElementsByTagName("body")[0];_1.appendChild(Control.Modal.overlay);_1.appendChild(Control.Modal.container);_1.appendChild(Control.Modal.loading);Control.Modal.container.observe("mouseout",function(_2){if(!Control.Modal.disableHoverClose&&Control.Modal.current&&Control.Modal.current.options.hover&&!Position.within(Control.Modal.container,Event.pointerX(_2),Event.pointerY(_2))){Control.Modal.close();}});}},open:function(_3,_4){_4=_4||{};if(!_4.contents){_4.contents=_3;}var _5=new Control.Modal(false,_4);_5.open();return _5;},close:function(_6){if(typeof (_6)!="boolean"){_6=false;}if(Control.Modal.current){Control.Modal.current.close(_6);}},attachEvents:function(){Event.observe(window,"load",Control.Modal.load);Event.observe(window,"unload",Event.unloadCache,false);},center:function(_7){if(!_7._absolutized){_7.setStyle({position:"absolute"});_7._absolutized=true;}var _8=_7.getDimensions();Position.prepare();var _9=(Position.deltaX+Math.floor((Control.Modal.getWindowWidth()-_8.width)/2));var _a=(Position.deltaY+((Control.Modal.getWindowHeight()>_8.height)?Math.floor((Control.Modal.getWindowHeight()-_8.height)/2):0));_7.setStyle({top:((_8.height<=Control.Modal.getDocumentHeight())?((_a!=null&&_a>0)?_a:"0")+"px":0),left:((_8.width<=Control.Modal.getDocumentWidth())?((_9!=null&&_9>0)?_9:"0")+"px":0)});},getWindowWidth:function(){return (self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0);},getWindowHeight:function(){return (self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0);},getDocumentWidth:function(){return Math.min(document.body.scrollWidth,Control.Modal.getWindowWidth());},getDocumentHeight:function(){return Math.max(document.body.scrollHeight,Control.Modal.getWindowHeight());},onKeyDown:function(_b){if(_b.keyCode==Event.KEY_ESC){Control.Modal.close();}}});Object.extend(Control.Modal.prototype,{mode:"",html:false,href:"",element:false,src:false,imageLoaded:false,ajaxRequest:false,initialize:function(_c,_d){this.element=$(_c);this.options={beforeOpen:Prototype.emptyFunction,afterOpen:Prototype.emptyFunction,beforeClose:Prototype.emptyFunction,afterClose:Prototype.emptyFunction,onSuccess:Prototype.emptyFunction,onFailure:Prototype.emptyFunction,onException:Prototype.emptyFunction,beforeImageLoad:Prototype.emptyFunction,afterImageLoad:Prototype.emptyFunction,autoOpenIfLinked:true,contents:false,loading:false,fade:false,fadeDuration:0.75,image:false,imageCloseOnClick:true,hover:false,iframe:false,iframeTemplate:new Template(""),evalScripts:true,requestOptions:{},overlayDisplay:true,overlayClassName:"",overlayCloseOnClick:true,containerClassName:"",opacity:0.3,zIndex:1000,width:null,height:null,offsetLeft:0,offsetTop:0,position:"absolute"};Object.extend(this.options,_d||{});var _e=false;var _f=false;if(this.element){_e=Control.Modal.targetRegexp.exec(this.element.href);_f=Control.Modal.imgRegexp.exec(this.element.href);}if(this.options.position=="mouse"){this.options.hover=true;}if(this.options.contents){this.mode="contents";}else{if(this.options.image||_f){this.mode="image";this.src=this.element.href;}else{if(_e){this.mode="named";var x=$(_e[1]);this.html=x.innerHTML;x.remove();this.href=_e[1];}else{this.mode=(this.options.iframe)?"iframe":"ajax";this.href=this.element.href;}}}if(this.element){if(this.options.hover){this.element.observe("mouseover",this.open.bind(this));this.element.observe("mouseout",function(_11){if(!Position.within(Control.Modal.container,Event.pointerX(_11),Event.pointerY(_11))){this.close();}}.bindAsEventListener(this));}else{this.element.onclick=function(_12){this.open();Event.stop(_12);return false;}.bindAsEventListener(this);}}var _13=Control.Modal.targetRegexp.exec(window.location);this.position=function(_14){if(this.options.position=="absolute"){Control.Modal.center(Control.Modal.container);}else{var xy=(_14&&this.options.position=="mouse"?[Event.pointerX(_14),Event.pointerY(_14)]:Position.cumulativeOffset(this.element));Control.Modal.container.setStyle({position:"absolute",top:xy[1]+(typeof (this.options.offsetTop)=="function"?this.options.offsetTop():this.options.offsetTop)+"px",left:xy[0]+(typeof (this.options.offsetLeft)=="function"?this.options.offsetLeft():this.options.offsetLeft)+"px"});}if(Control.Modal.ie){Control.Modal.overlay.setStyle({height:Control.Modal.getDocumentHeight()+"px",width:Control.Modal.getDocumentWidth()+"px"});}}.bind(this);if(this.mode=="named"&&this.options.autoOpenIfLinked&&_13&&_13[1]&&_13[1]==this.href){this.open();}},showLoadingIndicator:function(){if(this.options.loading){Control.Modal.loadingTimeout=window.setTimeout(function(){var _16=$("modal_image");if(_16){_16.hide();}Control.Modal.loading.style.zIndex=this.options.zIndex+1;Control.Modal.loading.update("");Control.Modal.loading.show();Control.Modal.center(Control.Modal.loading);}.bind(this),250);}},hideLoadingIndicator:function(){if(this.options.loading){if(Control.Modal.loadingTimeout){window.clearTimeout(Control.Modal.loadingTimeout);}var _17=$("modal_image");if(_17){_17.show();}Control.Modal.loading.hide();}},open:function(_18){if(!_18&&this.notify("beforeOpen")===false){return;}if(!Control.Modal.loaded){Control.Modal.load();}Control.Modal.close();if(!this.options.hover){Event.observe($(document.getElementsByTagName("body")[0]),"keydown",Control.Modal.onKeyDown);}Control.Modal.current=this;if(!this.options.hover){Control.Modal.overlay.setStyle({zIndex:this.options.zIndex,opacity:this.options.opacity});}Control.Modal.container.setStyle({zIndex:this.options.zIndex+1,width:(this.options.width?(typeof (this.options.width)=="function"?this.options.width():this.options.width)+"px":null),height:(this.options.height?(typeof (this.options.height)=="function"?this.options.height():this.options.height)+"px":null)});if(Control.Modal.ie&&!this.options.hover){$A(document.getElementsByTagName("select")).each(function(_19){_19.style.visibility="hidden";});}Control.Modal.overlay.addClassName(this.options.overlayClassName);Control.Modal.container.addClassName(this.options.containerClassName);switch(this.mode){case "image":this.imageLoaded=false;this.notify("beforeImageLoad");this.showLoadingIndicator();var img=document.createElement("img");img.onload=function(img){this.hideLoadingIndicator();this.update([img]);if(this.options.imageCloseOnClick){$(img).observe("click",Control.Modal.close);}this.position();this.notify("afterImageLoad");img.onload=null;}.bind(this,img);img.src=this.src;img.id="modal_image";break;case "ajax":this.notify("beforeLoad");var _1c={method:"post",onSuccess:function(_1d){this.hideLoadingIndicator();this.update(_1d.responseText);this.notify("onSuccess",_1d);this.ajaxRequest=false;}.bind(this),onFailure:function(){this.notify("onFailure");}.bind(this),onException:function(){this.notify("onException");}.bind(this)};Object.extend(_1c,this.options.requestOptions);this.showLoadingIndicator();this.ajaxRequest=new Ajax.Request(this.href,_1c);break;case "iframe":this.update(this.options.iframeTemplate.evaluate({href:this.href,id:"modal_iframe"}));break;case "contents":this.update((typeof (this.options.contents)=="function"?this.options.contents():this.options.contents));break;case "named":this.update(this.html);break;}if(!this.options.hover){if(this.options.overlayCloseOnClick&&this.options.overlayDisplay){Control.Modal.overlay.observe("click",Control.Modal.close);}if(this.options.overlayDisplay){if(this.options.fade){if(Control.Modal.effects.overlayFade){Control.Modal.effects.overlayFade.cancel();}Control.Modal.effects.overlayAppear=new Effect.Appear(Control.Modal.overlay,{queue:{position:"front",scope:"Control.Modal"},to:this.options.opacity,duration:this.options.fadeDuration/2});}else{Control.Modal.overlay.show();}}}if(this.options.position=="mouse"){this.mouseHoverListener=this.position.bindAsEventListener(this);this.element.observe("mousemove",this.mouseHoverListener);}this.notify("afterOpen");},update:function(_1e){if(typeof (_1e)=="string"){Control.Modal.container.update(_1e);}else{Control.Modal.container.update("");(_1e.each)?_1e.each(function(_1f){Control.Modal.container.appendChild(_1f);}):Control.Modal.container.appendChild(node);}if(this.options.fade){if(Control.Modal.effects.containerFade){Control.Modal.effects.containerFade.cancel();}Control.Modal.effects.containerAppear=new Effect.Appear(Control.Modal.container,{queue:{position:"end",scope:"Control.Modal"},to:1,duration:this.options.fadeDuration/2});}else{Control.Modal.container.show();}this.position();Event.observe(window,"resize",this.position,false);Event.observe(window,"scroll",this.position,false);},close:function(_20){if(!_20&&this.notify("beforeClose")===false){return;}if(this.ajaxRequest){this.ajaxRequest.transport.abort();}this.hideLoadingIndicator();if(this.mode=="image"){var _21=$("modal_image");if(this.options.imageCloseOnClick&&_21){_21.stopObserving("click",Control.Modal.close);}}if(Control.Modal.ie&&!this.options.hover){$A(document.getElementsByTagName("select")).each(function(_22){_22.style.visibility="visible";});}if(!this.options.hover){Event.stopObserving(window,"keyup",Control.Modal.onKeyDown);}Control.Modal.current=false;Event.stopObserving(window,"resize",this.position,false);Event.stopObserving(window,"scroll",this.position,false);if(!this.options.hover){if(this.options.overlayCloseOnClick&&this.options.overlayDisplay){Control.Modal.overlay.stopObserving("click",Control.Modal.close);}if(this.options.overlayDisplay){if(this.options.fade){if(Control.Modal.effects.overlayAppear){Control.Modal.effects.overlayAppear.cancel();}Control.Modal.effects.overlayFade=new Effect.Fade(Control.Modal.overlay,{queue:{position:"end",scope:"Control.Modal"},from:this.options.opacity,to:0,duration:this.options.fadeDuration/2});}else{Control.Modal.overlay.hide();}}}if(this.options.fade){if(Control.Modal.effects.containerAppear){Control.Modal.effects.containerAppear.cancel();}Control.Modal.effects.containerFade=new Effect.Fade(Control.Modal.container,{queue:{position:"front",scope:"Control.Modal"},from:1,to:0,duration:this.options.fadeDuration/2,afterFinish:function(){Control.Modal.container.update("");this.resetClassNameAndStyles();}.bind(this)});}else{Control.Modal.container.hide();Control.Modal.container.update("");this.resetClassNameAndStyles();}if(this.options.position=="mouse"){this.element.stopObserving("mousemove",this.mouseHoverListener);}this.notify("afterClose");},resetClassNameAndStyles:function(){Control.Modal.overlay.removeClassName(this.options.overlayClassName);Control.Modal.container.removeClassName(this.options.containerClassName);Control.Modal.container.setStyle({height:null,width:null,top:null,left:null});},notify:function(_23){try{if(this.options[_23]){return [this.options[_23].apply(this.options[_23],$A(arguments).slice(1))];}}catch(e){if(e!=$break){throw e;}else{return false;}}}});if(typeof (Object.Event)!="undefined"){Object.Event.extend(Control.Modal);}Control.Modal.attachEvents(); +function startEasyTracking(){ + new Ajax.Request('managetimetracker.php?action=starteasytracking', { + method: 'get', + onSuccess: function(payload) { + if (payload.responseText == "ok"){ + alert('ok'); + } + } + }); +} + +function stopEasyTracking(pid){ + alert('not implemented, yet!'); +} + diff --git a/language/de/lng.conf b/language/de/lng.conf index 06447fac..7ed482cd 100644 --- a/language/de/lng.conf +++ b/language/de/lng.conf @@ -459,3 +459,8 @@ was = wurde were = wurden yes = Ja zipexport = ZIP + +# Easy Tracker +easytracker = Zeiterfassung +starttracking = START +stoptracking = STOP diff --git a/managetimetracker.php b/managetimetracker.php index e60c16e2..ac80a920 100644 --- a/managetimetracker.php +++ b/managetimetracker.php @@ -391,6 +391,16 @@ $template->assign("tracker", $track); SmartyPaginate::assign($template); $template->display("tracker_project.tpl"); +} elseif ($action == 'starteasytracking'){ + if (!$userpermissions["timetracker"]["add"]) { + $template->assign("errortext", "Permission denied."); + $template->assign("mode", "error"); + $template->display("error.tpl"); + die(); + } + +// store beginning time here + echo 'ok'; } ?> diff --git a/templates/standard/easy-tracker.tpl b/templates/standard/easy-tracker.tpl index a2f87632..175f3f63 100644 --- a/templates/standard/easy-tracker.tpl +++ b/templates/standard/easy-tracker.tpl @@ -3,23 +3,11 @@ {*Easy Tracker*}
-

{#search#}

- - +

{#easytracker#}

+
{*Easy Tracker End*} diff --git a/templates/standard/theme/standard/css/style_main.css b/templates/standard/theme/standard/css/style_main.css index 3438f73c..1e53d906 100644 --- a/templates/standard/theme/standard/css/style_main.css +++ b/templates/standard/theme/standard/css/style_main.css @@ -378,7 +378,7 @@ td.message ul { width: 220px; min-height: 20px; background: url(../images/color-a.png) repeat 0 0; - margin: 0 0 0 0; + margin: 0 0 10px 0; padding: 0 0 23px 0; float: left; color: #6d7f93; @@ -2905,4 +2905,17 @@ span.info { -/* ## Footer ## end ## */ \ No newline at end of file +/* ## Footer ## end ## */ + +#tracker{ + padding-top: 8px; +} + +#tracker .button{ + background-color: #3C556E; + padding: 4px; + margin-right: 4px; + margin-top: 2px; + color: #001e40; + font-weight: bold; +} From 589e48304be8f1b09af2b14918438b44632ba667 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Thu, 30 Apr 2015 14:32:38 +0200 Subject: [PATCH 03/12] working on easy time tracker storage functions --- include/class.timetracker.php | 40 +++++++++++++++++++++++++++++++++++ include/js/ajax.php | 4 +--- managetimetracker.php | 12 +++++++++-- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/include/class.timetracker.php b/include/class.timetracker.php index 6274d546..77e4617b 100644 --- a/include/class.timetracker.php +++ b/include/class.timetracker.php @@ -12,6 +12,46 @@ class timetracker { + /** + * Start new timetracking + */ + function openTracking($user, $project = 0, $task =0){ + global $conn; + + $opentrack = $this->getOpenTrackId(); + if ($opentrack != 0){ + return 'open track existing'; + } + + $username = $_SESSION['username']; + $started = time(); + $ended=0; + $hours=0; + $comment = 'pending timetrack'; + + $insStmt = $conn->prepare("INSERT INTO timetracker (user,project,task,comment,started,ended,hours,pstatus) VALUES (?,?,?,?,?,?,?,0)"); + $ins = $insStmt->execute(array((int) $user, (int) $project, (int) $task, $comment, $started, $ended, $hours)); + + if ($ins) { + $insid = $conn->lastInsertId(); + $title = $username . " " . $hours . "h"; + + return $insid; + } else { + return false; + } + } + + function getOpenTrackId(){ + global $conn; + $sel = $conn->query("SELECT ID FROM timetracker WHERE ended=0"); + $track = array(); + $track = $sel->fetch(); + if (empty($track)){ + return 0; + } + return $track['ID']; + } /** * Add timetracker entry diff --git a/include/js/ajax.php b/include/js/ajax.php index af75e31f..59704eb0 100644 --- a/include/js/ajax.php +++ b/include/js/ajax.php @@ -684,9 +684,7 @@ function startEasyTracking(){ new Ajax.Request('managetimetracker.php?action=starteasytracking', { method: 'get', onSuccess: function(payload) { - if (payload.responseText == "ok"){ - alert('ok'); - } + alert(payload.responseText); } }); } diff --git a/managetimetracker.php b/managetimetracker.php index ac80a920..bda1866a 100644 --- a/managetimetracker.php +++ b/managetimetracker.php @@ -399,8 +399,16 @@ die(); } -// store beginning time here - echo 'ok'; + $pid = 0; // TODO: read, if set + $tid = 0; // TODO: read, if set + $result = $tracker->openTracking($userid, $pid, $tid); + if ($result === false){ + echo 'failed'; + } elseif ($result == 'open track existing'){ + echo $result; + } else { + echo 'ok'; + } } ?> From d6cc0ad30b2467488fcd4ebb86b5fb93214e51fb Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 1 May 2015 01:47:03 +0200 Subject: [PATCH 04/12] added user to open task selector --- include/class.timetracker.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/include/class.timetracker.php b/include/class.timetracker.php index 77e4617b..a3eeafb1 100644 --- a/include/class.timetracker.php +++ b/include/class.timetracker.php @@ -17,8 +17,7 @@ class timetracker { */ function openTracking($user, $project = 0, $task =0){ global $conn; - - $opentrack = $this->getOpenTrackId(); + $opentrack = $this->getOpenTrackId($user); if ($opentrack != 0){ return 'open track existing'; } @@ -34,17 +33,16 @@ function openTracking($user, $project = 0, $task =0){ if ($ins) { $insid = $conn->lastInsertId(); - $title = $username . " " . $hours . "h"; - return $insid; } else { return false; } } - function getOpenTrackId(){ + function getOpenTrackId($user){ global $conn; - $sel = $conn->query("SELECT ID FROM timetracker WHERE ended=0"); + $sel = $conn->prepare("SELECT ID FROM timetracker WHERE ended=0 and user=?"); + $selStmt = $sel->execute(array((int) $user)); $track = array(); $track = $sel->fetch(); if (empty($track)){ From 14e66c142a77e3df7184a48e90bc8b6705506b85 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 1 May 2015 03:03:52 +0200 Subject: [PATCH 05/12] finish basic functions of easy time tracker --- include/class.timetracker.php | 35 +++++++++++++++++++++++++++-- include/js/ajax.php | 4 ---- managetimetracker.php | 18 ++++++++++++--- templates/standard/easy-tracker.tpl | 8 ++++++- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/include/class.timetracker.php b/include/class.timetracker.php index a3eeafb1..c3a4d29c 100644 --- a/include/class.timetracker.php +++ b/include/class.timetracker.php @@ -22,7 +22,6 @@ function openTracking($user, $project = 0, $task =0){ return 'open track existing'; } - $username = $_SESSION['username']; $started = time(); $ended=0; $hours=0; @@ -39,9 +38,41 @@ function openTracking($user, $project = 0, $task =0){ } } + function finishTracking($user, $pid = 0, $tid =0){ + global $conn; + $opentrack = $this->getOpenTrackId($user); + if ($opentrack == 0){ + return false; + } + $ended = time(); + + $sel = $conn->prepare("SELECT started,project,task FROM timetracker WHERE ended=0 AND user=?"); + $selStmt = $sel->execute(array((int) $user)); + $track = array(); + $track = $sel->fetch(); + if (empty($track)){ + return false; + } + $hours = ($ended - $track['started']) / 3600; + if ($pid == 0){ + $pid = $task['project']; + } + if ($task == 0){ + $tid = $task['task']; + } + + $updStmt = $conn->prepare("UPDATE timetracker SET project=?, task=?, ended=?, hours=? WHERE ID=?"); + $upd = $updStmt->execute(array((int)$pid,(int)$tid,(int)$ended,$hours,(int)$opentrack)); + + if ($upd){ + return $opentrack; + } + return false; + } + function getOpenTrackId($user){ global $conn; - $sel = $conn->prepare("SELECT ID FROM timetracker WHERE ended=0 and user=?"); + $sel = $conn->prepare("SELECT ID FROM timetracker WHERE ended=0 AND user=?"); $selStmt = $sel->execute(array((int) $user)); $track = array(); $track = $sel->fetch(); diff --git a/include/js/ajax.php b/include/js/ajax.php index 59704eb0..e1d28825 100644 --- a/include/js/ajax.php +++ b/include/js/ajax.php @@ -689,7 +689,3 @@ function startEasyTracking(){ }); } -function stopEasyTracking(pid){ - alert('not implemented, yet!'); -} - diff --git a/managetimetracker.php b/managetimetracker.php index bda1866a..4297dc1b 100644 --- a/managetimetracker.php +++ b/managetimetracker.php @@ -399,9 +399,7 @@ die(); } - $pid = 0; // TODO: read, if set - $tid = 0; // TODO: read, if set - $result = $tracker->openTracking($userid, $pid, $tid); + $result = $tracker->openTracking($userid, $id, $tid); if ($result === false){ echo 'failed'; } elseif ($result == 'open track existing'){ @@ -409,6 +407,20 @@ } else { echo 'ok'; } +} elseif ($action == 'finisheasytracking'){ + if (!$userpermissions["timetracker"]["add"]) { + $template->assign("errortext", "Permission denied."); + $template->assign("mode", "error"); + $template->display("error.tpl"); + die(); + } + if ($id){ + $track_id=$tracker->finishTracking($userid,$id,$tid); + if ($track_id){ + $loc = 'managetimetracker.php?action=editform&tid='.$tracker_id.'&id='.$id; + header("Location: ".$loc); + } + } } ?> diff --git a/templates/standard/easy-tracker.tpl b/templates/standard/easy-tracker.tpl index 175f3f63..195a2b66 100644 --- a/templates/standard/easy-tracker.tpl +++ b/templates/standard/easy-tracker.tpl @@ -6,7 +6,13 @@

{#easytracker#}

{#starttracking#} - {#stoptracking#} + {if $project.ID} + {if $task.ID} + {#stoptracking#} + {else} + {#stoptracking#} + {/if} + {/if}
{*Easy Tracker End*} From 99ed3abfc6bf896877fad4728e6c60df2c0039bc Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 1 May 2015 03:09:27 +0200 Subject: [PATCH 06/12] fixed typo --- managetimetracker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/managetimetracker.php b/managetimetracker.php index 4297dc1b..a6784aa9 100644 --- a/managetimetracker.php +++ b/managetimetracker.php @@ -417,7 +417,7 @@ if ($id){ $track_id=$tracker->finishTracking($userid,$id,$tid); if ($track_id){ - $loc = 'managetimetracker.php?action=editform&tid='.$tracker_id.'&id='.$id; + $loc = 'managetimetracker.php?action=editform&tid='.$track_id.'&id='.$id; header("Location: ".$loc); } } From e866b9718a6e9d6932ffd31c535ef011fc658d2b Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 1 May 2015 03:27:58 +0200 Subject: [PATCH 07/12] improved function --- include/class.timetracker.php | 2 ++ include/class.user.php | 5 +++++ init.php | 2 ++ templates/standard/easy-tracker.tpl | 15 +++++++++------ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/include/class.timetracker.php b/include/class.timetracker.php index c3a4d29c..d241a8db 100644 --- a/include/class.timetracker.php +++ b/include/class.timetracker.php @@ -32,6 +32,7 @@ function openTracking($user, $project = 0, $task =0){ if ($ins) { $insid = $conn->lastInsertId(); + $_SESSION['opentrack'] = $insid; return $insid; } else { return false; @@ -65,6 +66,7 @@ function finishTracking($user, $pid = 0, $tid =0){ $upd = $updStmt->execute(array((int)$pid,(int)$tid,(int)$ended,$hours,(int)$opentrack)); if ($upd){ + $_SESSION['opentrack'] = 0; return $opentrack; } return false; diff --git a/include/class.user.php b/include/class.user.php index 7446cb4e..4e1d07b2 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -293,6 +293,11 @@ function login($user, $pass) $_SESSION["userpermissions"] = $rolesobj->getUserRole($chk["ID"]); $userid = $_SESSION['userid']; + + $tracker = new timetracker(); + $_SESSION['opentrack'] = $tracker->getOpenTrackId($userid); + + $seid = session_id(); $staylogged = getArrayVal($_POST, 'staylogged'); diff --git a/init.php b/init.php index 2b3ffda3..baec1b5a 100644 --- a/init.php +++ b/init.php @@ -67,6 +67,7 @@ $gender = $_SESSION["usergender"]; // what the user may or may not do $userpermissions = $_SESSION["userpermissions"]; + $opentrack = $_SESSION['opentrack']; // update user lastlogin for the onlinelist $mynow = time(); $upd = $conn->exec("UPDATE user SET lastlogin='$mynow' WHERE ID = $userid"); @@ -76,6 +77,7 @@ $template->assign("lastlogin", $lastlogin); $template->assign("usergender", $gender); $template->assign("userpermissions", $userpermissions); + $template->assign('opentrack',$opentrack); $template->assign("loggedin", 1); }else { $template->assign("loggedin", 0); diff --git a/templates/standard/easy-tracker.tpl b/templates/standard/easy-tracker.tpl index 195a2b66..2fb8902f 100644 --- a/templates/standard/easy-tracker.tpl +++ b/templates/standard/easy-tracker.tpl @@ -5,13 +5,16 @@

{#easytracker#}

- {#starttracking#} - {if $project.ID} - {if $task.ID} - {#stoptracking#} - {else} - {#stoptracking#} + {if $opentrack} + {if $project.ID} + {if $task.ID} + {#stoptracking#} + {else} + {#stoptracking#} + {/if} {/if} + {else} + {#starttracking#} {/if}
From 084a6c48923865b12d820ecc34e2b966bc7f5681 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 1 May 2015 03:32:43 +0200 Subject: [PATCH 08/12] fixed bug preventig right task to be set in timetrack --- include/class.timetracker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/class.timetracker.php b/include/class.timetracker.php index d241a8db..d6c4e608 100644 --- a/include/class.timetracker.php +++ b/include/class.timetracker.php @@ -58,7 +58,7 @@ function finishTracking($user, $pid = 0, $tid =0){ if ($pid == 0){ $pid = $task['project']; } - if ($task == 0){ + if ($tid == 0){ $tid = $task['task']; } From e66b61aaf74f79901cfb3bd99eb99a13f049909f Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 1 May 2015 04:08:20 +0200 Subject: [PATCH 09/12] implemented cancel button, hiding of pressed buttons --- include/class.timetracker.php | 5 +++++ include/class.user.php | 1 - include/js/ajax.php | 21 ++++++++++++++++++++- language/de/lng.conf | 5 +++-- managetimetracker.php | 10 ++++++++++ templates/standard/easy-tracker.tpl | 1 + 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/include/class.timetracker.php b/include/class.timetracker.php index d6c4e608..c0359dc2 100644 --- a/include/class.timetracker.php +++ b/include/class.timetracker.php @@ -39,6 +39,11 @@ function openTracking($user, $project = 0, $task =0){ } } + function cancelTracking($tid){ + $this->del($tid); + $_SESSION['opentrack']=0; + } + function finishTracking($user, $pid = 0, $tid =0){ global $conn; $opentrack = $this->getOpenTrackId($user); diff --git a/include/class.user.php b/include/class.user.php index 4e1d07b2..cfb17458 100644 --- a/include/class.user.php +++ b/include/class.user.php @@ -297,7 +297,6 @@ function login($user, $pass) $tracker = new timetracker(); $_SESSION['opentrack'] = $tracker->getOpenTrackId($userid); - $seid = session_id(); $staylogged = getArrayVal($_POST, 'staylogged'); diff --git a/include/js/ajax.php b/include/js/ajax.php index e1d28825..9a0ef63f 100644 --- a/include/js/ajax.php +++ b/include/js/ajax.php @@ -684,8 +684,27 @@ function startEasyTracking(){ new Ajax.Request('managetimetracker.php?action=starteasytracking', { method: 'get', onSuccess: function(payload) { - alert(payload.responseText); + if (payload.responseText == 'ok'){ + var div=document.getElementById('tracker'); + while (div.hasChildNodes()){ + div.removeChild(div.lastChild); + } + } else { + alert(payload.responseText); + } } }); } +function cancelEasyTracking(){ + new Ajax.Request('managetimetracker.php?action=canceleasytracking',{ + method: 'get', + onSuccess: function(payload) { + var div=document.getElementById('tracker'); + while (div.hasChildNodes()){ + div.removeChild(div.lastChild); + } + } + }); +} + diff --git a/language/de/lng.conf b/language/de/lng.conf index 7ed482cd..792d319c 100644 --- a/language/de/lng.conf +++ b/language/de/lng.conf @@ -462,5 +462,6 @@ zipexport = ZIP # Easy Tracker easytracker = Zeiterfassung -starttracking = START -stoptracking = STOP +starttracking = Starten +stoptracking = Abschließen +canceltracking = Verwerfen diff --git a/managetimetracker.php b/managetimetracker.php index a6784aa9..25a1bc69 100644 --- a/managetimetracker.php +++ b/managetimetracker.php @@ -421,6 +421,16 @@ header("Location: ".$loc); } } +} elseif ($action == 'canceleasytracking'){ + if (!$userpermissions["timetracker"]["add"]) { + $template->assign("errortext", "Permission denied."); + $template->assign("mode", "error"); + $template->display("error.tpl"); + die(); + } + if ($opentrack != 0){ + $tracker->cancelTracking($opentrack); + } } ?> diff --git a/templates/standard/easy-tracker.tpl b/templates/standard/easy-tracker.tpl index 2fb8902f..e0927038 100644 --- a/templates/standard/easy-tracker.tpl +++ b/templates/standard/easy-tracker.tpl @@ -13,6 +13,7 @@ {#stoptracking#} {/if} {/if} + {#canceltracking#} {else} {#starttracking#} {/if} From eb819907dd2ca443019ff7b6b9754639293d9a67 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 1 May 2015 04:11:49 +0200 Subject: [PATCH 10/12] added README.easy-track.MD --- README.easy-track.MD | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.easy-track.MD diff --git a/README.easy-track.MD b/README.easy-track.MD new file mode 100644 index 00000000..41402a28 --- /dev/null +++ b/README.easy-track.MD @@ -0,0 +1 @@ +this branch adds a start-stop timetracker function, which doesn't require you to stay logged in all the time. From 0c28cac0cd6bf451a228dde3109f6856163d8f39 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Fri, 1 May 2015 16:51:12 +0200 Subject: [PATCH 11/12] improved design. removed duplicate div with id content-left in managetask. --- templates/standard/easy-tracker.tpl | 4 +--- templates/standard/projecttasks.tpl | 8 +++----- templates/standard/sidebar-a.tpl | 5 ++++- templates/standard/theme/standard/css/style_main.css | 12 +++++++++++- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/templates/standard/easy-tracker.tpl b/templates/standard/easy-tracker.tpl index e0927038..1de3ef4e 100644 --- a/templates/standard/easy-tracker.tpl +++ b/templates/standard/easy-tracker.tpl @@ -1,7 +1,6 @@ -
- {*Easy Tracker*} +

{#easytracker#}

@@ -21,4 +20,3 @@
{*Easy Tracker End*} -
diff --git a/templates/standard/projecttasks.tpl b/templates/standard/projecttasks.tpl index 8fc57d2c..877c12ad 100644 --- a/templates/standard/projecttasks.tpl +++ b/templates/standard/projecttasks.tpl @@ -285,15 +285,11 @@
{*Tasks END*} {*content-left-in END*} - {*content-left END*} {* current tasklists end*} -{*right sidebar*} -{include file="sidebar-a.tpl"} {if $oldlists[0][0]} {*only show the block if there are closed tasklists*} {*Done Tasklists*}
{*closed tasklists*} -

{$projectname|truncate:45:"...":true}/ {#donetasklists#}

@@ -388,6 +384,8 @@ {/if} {*Done Tasklists End*} +{*right sidebar*} +{include file="sidebar-a.tpl"} -{include file="footer.tpl"} \ No newline at end of file +{include file="footer.tpl"} diff --git a/templates/standard/sidebar-a.tpl b/templates/standard/sidebar-a.tpl index a833584e..ee3f99d2 100644 --- a/templates/standard/sidebar-a.tpl +++ b/templates/standard/sidebar-a.tpl @@ -88,6 +88,9 @@ {/literal} -
+
{include file="easy-tracker.tpl"} + +
+ diff --git a/templates/standard/theme/standard/css/style_main.css b/templates/standard/theme/standard/css/style_main.css index 1e53d906..c691e913 100644 --- a/templates/standard/theme/standard/css/style_main.css +++ b/templates/standard/theme/standard/css/style_main.css @@ -366,6 +366,10 @@ td.message ul { height: 27px; } +#content-left>.content-spacer{ + background-color: #28648b; +} + .content-spacer-b { clear: both; width: 100%; @@ -2916,6 +2920,12 @@ span.info { padding: 4px; margin-right: 4px; margin-top: 2px; - color: #001e40; + color: white; font-weight: bold; } + +.space{ + background-color: #28648b; + margin-top: 50px; + height: 23px; +} From 53a06a490f3ebc0e3f0fde444f55993569379df6 Mon Sep 17 00:00:00 2001 From: Stephan Richter Date: Thu, 7 May 2015 09:46:02 +0200 Subject: [PATCH 12/12] corrected indentation --- templates/standard/projecttasks.tpl | 687 ++++++++++++++-------------- 1 file changed, 344 insertions(+), 343 deletions(-) diff --git a/templates/standard/projecttasks.tpl b/templates/standard/projecttasks.tpl index 8fc57d2c..f434545a 100644 --- a/templates/standard/projecttasks.tpl +++ b/templates/standard/projecttasks.tpl @@ -2,392 +2,393 @@ {include file="tabsmenue-project.tpl" taskstab = "active"}
-
-
- - {*System Message*} - - - {literal} - - {/literal}{*/System Message*} - -

{$projectname|truncate:45:"...":true}/ {#tasklists#}

- - {if $userpermissions.tasks.add} - - {/if} - - {if $userpermissions.tasks.add} {*Add Tasklist*} - - {/if} {*Add Tasklist END*} - - {*Tasks*} - {if $lists[0][0]} - {section name=list loop=$lists} -
- +
+
+ {*System Message*} + - -
- - {*Add Task*} - {if $userpermissions.tasks.add} - - {/if} + {if $userpermissions.tasks.add} {*Add Tasklist*} + + {/if} {*Add Tasklist END*} + + {*Tasks*} + {if $lists[0][0]} + {section name=list loop=$lists} +
+ + +
+ {if $userpermissions.tasks.close} + {#close#} + {/if} + {if $userpermissions.tasks.edit} + {#edit#} + {/if} + {if $userpermissions.tasks.del} + {#delete#} + {/if} + {if $userpermissions.tasks.add} + {#addtask#} + {/if} +
+ +

+ {$lists[list].name|truncate:70:"...":true} +

+
{*wintools*} + +
+ + {*Add Task*} + {if $userpermissions.tasks.add} + + {/if} + +
+ + + + + + + + + + + + + + + + + + {section name=task loop=$lists[list].tasks} + {*Color-Mix*} + {if $smarty.section.task.index % 2 == 0} + + {else} + + {/if} + + + + + + + + + + + + + {literal} + + {/literal} + {/section} {*task section*} +
{#tasks#}{#user#}{#daysleft#}  
+ {if $userpermissions.tasks.close} + + {/if} + + + + {section name=theusers loop=$lists[list].tasks[task].users} + {$lists[list].tasks[task].users[theusers].name|truncate:30:"...":true} + {/section} + {$lists[list].tasks[task].daysleft}   + + {if $userpermissions.tasks.edit} + + {/if} + {if $userpermissions.tasks.del} + + {/if} +
+
+
+
+
+ {$lists[list].tasks[task].text|nl2br} +
+
+
+
+ + {*Tasks donetasks*} + {*done_block End*} +
{*smooth End*} + +
+
+ {if $userpermissions.tasks.add} + {#addtask#} + {/if} + {#donetasks#} +
+
+
{*block END*} + +
+ {/section} {*Tasks End*} + {/if} {*if $lists[0][0] END*} + + {if !$lists[0][0] and !$oldlists[0][0]} + + + + {#notasklists#} + + + + {/if} -
- + {*Tasks div END*} + {*content-left-in END*} + {*content-left END*} +{* current tasklists end*} - - - - - - - - - +{*right sidebar*} +{include file="sidebar-a.tpl"} - - - - - +{if $oldlists[0][0]} {*only show the block if there are closed tasklists*} {*Done Tasklists*} +
+ {*closed tasklists*} +
+
+
+

{$projectname|truncate:45:"...":true}/ {#donetasklists#}

+ +
+ +

+ +

+
- {section name=task loop=$lists[list].tasks} - {*Color-Mix*} - {if $smarty.section.task.index % 2 == 0} -
- {else} - - {/if} - - - - - - - + {* Closed tasklists *} +
+
+
{#tasks#}{#user#}{#daysleft#}  
- {if $userpermissions.tasks.close} - - {/if} - - - - {section name=theusers loop=$lists[list].tasks[task].users} - {$lists[list].tasks[task].users[theusers].name|truncate:30:"...":true} - {/section} - {$lists[list].tasks[task].daysleft}   - {if $userpermissions.tasks.edit} - - {/if} - {if $userpermissions.tasks.del} - - {/if} -
- - + + + + + + + - - {literal} - - {/literal} - {/section} -
-
-
-
-
- {$lists[list].tasks[task].text|nl2br} -
-
-
-
{#tasklist#}
- - {*Tasks donetasks*} - {*done_block End*} -
{*smooth End*} - -
-
- {if $userpermissions.tasks.add} - {#addtask#} - {/if} - {#donetasks#} -
-
-
{*block END*} - -
- {/section} {*Tasks End*} -{/if} {*if $lists[0][0]*} -{if !$lists[0][0] and !$oldlists[0][0]} - - - - {#notasklists#} - - - -{/if} - -
{*Tasks END*} -
{*content-left-in END*} -
{*content-left END*} -{* current tasklists end*} -{*right sidebar*} -{include file="sidebar-a.tpl"} -{if $oldlists[0][0]} {*only show the block if there are closed tasklists*} {*Done Tasklists*} -
-{*closed tasklists*} -
-
-
-

{$projectname|truncate:45:"...":true}/ {#donetasklists#}

+
+
{*dones End*} +
{*block End*} -
- -

- -

-
+
+ {literal} + + {/literal} -{* Closed tasklists *} -
-
- - - - - - - - - - - - - - - - - - - {section name = oldlist loop=$oldlists} - {*Color-Mix*} - {if $smarty.section.oldlist.index % 2 == 0} - - {else} - - {/if} - - - - - - - - - - - - - {/section} -
{#tasklist#}
{if $userpermissions.tasks.close}{/if} - - {$oldlists[oldlist].daysleft} - {if $userpermissions.tasks.del} - - {/if} -
-
-
-
-
- {$oldlists[oldlist].desc|nl2br} -
-
-
-
- -
-
{*dones End*} -
{*block End*} - -
- - {literal} - - {/literal} - -
{*Tasks END*} -
{*content-left-in END*} -
{*content-left END*} +
{*Tasks END*} +
{*content-left-in END*} + {*content-left END*} {/if} {*Done Tasklists End*} - - {include file="footer.tpl"} \ No newline at end of file