stc

a simple time card webapp
git clone _git@git.brennen.work:stc.git
Log | Files | Refs | README

commit 0fe971f2800747d914d5ea9622cc1978e9e1d6b4
parent 0da3c42ee753c4cc4af12b589134b88a0adaa95b
Author: Youth Employment Program Production <youthemployment22@gmail.com>
Date:   Sun,  9 Jul 2023 20:34:20 -0600

print setup and user display refinement

Diffstat:
Mapp/routes.py | 33++++++++++++++++++++++++++++++---
Mapp/static/css/main.css | 27+++++++++++++++++++++++++++
Mapp/templates/admin/total_timedata_report/widget.html | 87++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 137 insertions(+), 10 deletions(-)

diff --git a/app/routes.py b/app/routes.py @@ -1299,7 +1299,7 @@ def time_bound_report(startday,endday): }, { "$group": { - "_id":{"projectId": "$project"}, + "_id":"$project", "laborHoursWorked": { "$sum": { "$subtract": [{"$last":"$clock_out"}, {"$last":"$clock_in"}] } }, "lunchCount": { "$sum" : { '$cond':["$lunch",1,0] } }, "perdiemCount": { "$sum" :{'$cond':["$perdiem",1,0] } } @@ -1317,6 +1317,11 @@ def time_bound_report(startday,endday): ptl = mongo.db.time_collection.aggregate( [ { + "$match": { + "$and":[{"date":{"$gte":begin}},{"date":{"$lt":end}}] + } + }, + { "$lookup":{ # TODO TODO TODO THIS WILL REQUIRE CHANGING ALL DB WRITES TO time_collection['project'] TO BECOME ObjectId() OBJECTS THIS WILL LIKELY BREAK THINGS!!!! NEED TO ITERATE THROUGH DB ENTRIES AS WELL AS ENSURE READ OPERATIONS STILL GUNCTION PROPERLY AFTERWARDS 'from':'projects_collection', 'localField':'project', @@ -1325,12 +1330,34 @@ def time_bound_report(startday,endday): } }, { + "$addFields": { + "totalTime": { "$sum": { "$subtract": [{"$last":"$clock_out"}, {"$last":"$clock_in"}] } }, + "lunchCount": { "$sum" : { '$cond':["$lunch",1,0] } }, + "perdiemCount": { "$sum" :{'$cond':["$perdiem",1,0] } } + } + }, + { + "$addFields": { + "totalHoursWorked": {"$subtract":[ "$totalTime", {"$multiply":["$lunchCount", 30 * 60 * 1000]}] } + } + }, + { "$sort": {'date': -1} } ] ) + by_project = {} + by_user ={} + for time in ptl: + if time['modified_by'][0] not in by_user: + by_user[time['modified_by'][0]]=[time] + else: + by_user[time['modified_by'][0]].append(time) + if time['project_data'][0]['project_name'] not in by_project: + by_project[time['project_data'][0]['project_name']]=[time] + else: + by_project[time['project_data'][0]['project_name']].append(time) - - return render_template ('admin/reports/total_timedata_report.html', usertimes=usertimes, allhours=allhours, hours=hours, tspp=tspp, projectlookup=ptl, ORGNAME=OrganizationName) + return render_template ('admin/reports/total_timedata_report.html', by_project=by_project, by_user=by_user, usertimes=usertimes, allhours=allhours, hours=hours, tspp=tspp, projectlookup=ptl, ORGNAME=OrganizationName) ####### TESTING END ####### @app.route('/admin/reports/pay-period', methods=['GET']) diff --git a/app/static/css/main.css b/app/static/css/main.css @@ -84,6 +84,33 @@ a,a.visited,a.hover { header, #doc, .reportswidget, .permissions, .activeusers { display:none !important; } + .admin-grid { + display:block !important; + } + .agreements,.admin-content { + padding: 0px !important; + margin: 0px !important; + background-color: #fff !important; + width:100vw !important; + } + @media (max-width:720px),@media (min-width:720px),@media (max-width: 414px),@media (min-width: 415px) { + .pagebreak { + clear:both; + page-break-after:always; + } + header, #doc, .reportswidget, .permissions, .activeusers { + display:none !important; + } + .admin-grid { + display:block !important; + } + .agreements,.admin-content { + padding: 0px !important; + margin: 0px !important; + background-color: #fff !important; + width:100vw !important; + } + } } /***EndingPr***/ #messagebanner p { diff --git a/app/templates/admin/total_timedata_report/widget.html b/app/templates/admin/total_timedata_report/widget.html @@ -17,7 +17,7 @@ <th>Per Diem(#)</th> <th>Billable(hrs)</th> </tr> - {% for entry in hours %} + {# {% for entry in hours %} <tr> <td><a href="{{url_for('hours',username=entry._id)}}">{{ entry['_id'] }}</a></td> <td><a href="{{url_for('hours',username=entry._id)}}">{{ (entry['totalTime']/(1000*60*60))|round(2) }}</a></td> @@ -25,7 +25,7 @@ <td><a href="{{url_for('hours',username=entry._id)}}">{{ entry['perdiemCount'] }}</a></td> <td><a href="{{url_for('hours',username=entry._id)}}">{{ (entry['totalHoursWorked']/(1000*60*60))|round(2) }}</a></td> </tr> - {% endfor %} + {% endfor %} #} </table> </div> <div class="employee-hours"> @@ -48,7 +48,7 @@ {% endfor %} </table> </div> - <div class="employee-hours"> + <!--{#<div class="employee-hours"> <table> <tr> <th>Employee</th> @@ -67,17 +67,90 @@ </tr> {% endfor %} </table> - </div> - <div>Test Div + </div>#}--> + <!--{#<div>Test Div</br> {% for elmnt in usors %} {{elmnt}}</br> {% endfor %} - </div> - <div>Projours Div + </div>#}--> + <!--{#<div>Projours Div</br> {% for elmnt in projours %} {{elmnt}}</br> {% endfor %} + </div>#}--> + <!--{#<div>Project Lookup Div</br> + {% for elmnt in projectlookup %} + {{elmnt['modified_by'][0]}} + {{elmnt['date']}} + {{elmnt['project_data'][0]['project_name']}} + {{elmnt}}</br></br> + {% endfor %} + </div>#}--> + <div><h2>Reports by User</h2></br> + {% for user, times in by_user.items() %} + <h3>{{ user }}</h3> + <div class="user-summarp"> + {% for entry in hours %} + {% if entry['_id'] == user %} + Total Hours(hrs)<a href="{{url_for('hours',username=entry._id)}}">{{ (entry['totalHoursWorked']/(1000*60*60))|round(2) }}</a> + {% endif %} + {% endfor %} + </div> + <table> + <tr> + <th>Date</th> + <th>Project</th> + <th>Clocked In</th> + <th>Clocked Out</th> + <th>Lunch</th> + <th>Per Diem</th> + <th>Time(hrs)</th> + </tr> + {% for time in times %} + <tr> + <td>{{time['date'].date().isoformat()}}</td> + <td>{{time['project_data'][0]['project_name']}}</td> + <td>{{time['clock_in'][-1].time().isoformat(timespec="minutes")}}</td> + <td>{{time['clock_out'][-1].time().isoformat(timespec="minutes")}}</td> + <td>{{time['lunchCount']}}</td> + <td>{{time['perdiemCount']}}</td> + <td><a href="{{url_for('hours',username=time['modified_by'][0])}}">{{ (time['totalHoursWorked']/(1000*60*60))|round(2) }}</a></td> + </tr> + {% endfor %} + </table> + <!--<div class="pagebreak"></div>--> + {% endfor %} + </div> + <!--<div class="pagebreak"></div>--> + <div><h2>Reports by Project</h2></br> + {% for project, times in by_project.items() %} + <h3>{{ project }}</h3> + <table> + <tr> + <th>Date</th> + <th>Employee</th> + <th>Clocked In</th> + <th>Clocked Out</th> + <th>Lunch</th> + <th>Per Diem</th> + </tr> + {% for time in times %} + <tr> + <td>{{time['date'].date().isoformat()}}</td> + <td>{{time['modified_by'][0]}}</td> + <td>{{time['clock_in'][-1].time().isoformat(timespec="minutes")}}</td> + <td>{{time['clock_out'][-1].time().isoformat(timespec="minutes")}}</td> + <td>{{time['lunchCount']}}</td> + <td>{{time['perdiemCount']}}</td> + </tr> + {% endfor %} + </table> + <!--<div class="pagebreak"></div>--> + {% endfor %} + {#{% for elmnt in by_project %} + {{elmnt}}</br> + {% endfor %}#} </div> </section> <section id="data-by-project">