diff --git a/css/bts_office.css b/css/bts_office.css
index 058e340..2509c0a 100644
--- a/css/bts_office.css
+++ b/css/bts_office.css
@@ -220,6 +220,13 @@ div.peopleitem label:hover :checked + .card {
box-shadow: 0 20px 20px rgba(255,255,255,.2);
}
+div.peopleitem span.notes,
+div.peopleitem a.notes{
+ font-weight: 900;
+ color: white;
+ text-decoration: underline;
+}
+
/* end of hover box */
.satusbar {
position: relative;
diff --git a/html/staff.html b/html/staff.html
index a866f1a..d7d9fbd 100644
--- a/html/staff.html
+++ b/html/staff.html
@@ -3,23 +3,19 @@
{{unconfirmedjob}}
-
+ name='badge' class='badge blue'>
{{unconfirmedjob}}
+
${{wages}}
({{hour}}+{{OT}}hr)
petrol:{{petrol}} km
diff --git a/js/bts_office.js b/js/bts_office.js
index 7d18ac2..ade095c 100644
--- a/js/bts_office.js
+++ b/js/bts_office.js
@@ -46,7 +46,7 @@
//save it
$(this.selector).data({obj:this, data:data});
//draw rating star
- this.set_ratings(this.data.rating);
+ //this.set_ratings(this.data.rating);
this.set_unconfirmed_job(this.data.unconfirmedjob);
}
@@ -61,6 +61,12 @@
this.data.rating = num;
}
+ set_km(km)
+ {
+ var str = "petrol:" + km.toFixed(2) + " km";
+ $(this.selector + ' div[name="petrol"]').html(str);
+ }
+
set_unconfirmed_job(num){
if( num == 0 )
$(this.selector + " span[name='badge']").hide();
@@ -156,7 +162,6 @@
bts().staff_people[u.login] = staff_obj;
});
hide_loading_staff();
- calculate_total_hour_and_money();
}else{
alert('error getting staff list');
}
@@ -1868,24 +1873,14 @@
total: 0,
hours: 0,
};
+
$('.stafflist > div.peopleitem').each(function(i,e){
var people = $(this).data().obj;
people.reset_summary();
});
-
+
$('div.workspace > .divTable.jobTable:visible').each(function(i,e){
-
- var id = $(e).attr('data-id');
- var job = bts().job_map[id];
-
- if (id == ''){
- //is this a new Job without id?
- var newjob_id = $(e).attr('data-newjob_id');
- if ( typeof newjob_id != "undefined"){
- id = newjob_id;
- job = bts().job_map_new[newjob_id];
- }
- }
+ job = get_job_by_jobTable(e);
if (typeof job === 'undefined' || !job.is_job_valid() )
return;
@@ -1901,9 +1896,78 @@
});
set_wages(pays.total.toFixed(2));
set_working_hours(pays.hours.toFixed(2));
+ calculate_driving();
}
+ function get_job_by_jobTable(div)
+ {
+ var e = div;
+ var id = $(e).attr('data-id');
+ var job = bts().job_map[id];
+
+ if (id == ''){
+ //is this a new Job without id?
+ var newjob_id = $(e).attr('data-newjob_id');
+ if ( typeof newjob_id != "undefined"){
+ id = newjob_id;
+ job = bts().job_map_new[newjob_id];
+ }
+ }
+ return job;
+ }
+ function calculate_driving(){
+ var id = bts().driving;
+ var kms={};
+ $('div.jobTable[data-staff="' + id + '"]:visible').each(function(){
+ var el = this;
+ var matches = find_driving_partner_job(el);
+ console.assert(matches.length == 1); //only one match
+ if (matches.length != 1)
+ return;
+
+ var staff = $('#' + matches[0]).data().staff;
+ if (typeof kms[staff] =='undefined'){
+ kms[staff] = 0;
+ }
+ kms[staff] += convert_driving_to_km(el);
+ //console.log($(this).attr('id'), matches, kms);
+ bts().staff_people[staff].set_km(kms[staff]);
+ console.log(bts().staff_map[staff]);
+ ensure_visible(bts().staff_people[staff].selector);
+ });
+ //console.log(kms);
+ }
+
+ function find_driving_partner_job(selector){
+ var job = $(selector).data();
+ var start = new Date(job.start);
+ var client = job.client;
+ var matches = [];
+ $('div.workspace > .divTable.jobTable:visible').each(function(i,e){
+ var match = $(this).data();
+ staff = match.staff;
+ s = new Date(match.start);
+ c = match.client;
+ if ((start - s == 0) && (client == c) && staff != bts().driving){
+ matches.push($(this).attr('id'));
+ }
+ });
+ return matches;
+ }
+
+ function convert_driving_to_km(selector){
+ var data = $(selector).data();
+ var tos = data.tos;
+ var start = new Date(data.start);
+ var finish = new Date(data.finish);
+ var hours = Math.abs(finish - start) / 36e5; //in hours
+
+ var rate = parseFloat(bts().tos[tos].price);
+ var pay = hours * rate;
+ var km = pay / 1.2; //$1.2 per km
+ return km;
+ }
function find_staff(login)
{
diff --git a/ts.php b/ts.php
index b74c56f..8b0f1cd 100644
--- a/ts.php
+++ b/ts.php
@@ -434,6 +434,7 @@ class AcareOffice{
'userid'=> $this->bts_user_id,
'load_user_img'=> plugins_url('img/loading_user.gif', __FILE__),
'load_job_img'=> plugins_url('img/loading_job.gif', __FILE__),
+ 'driving' => "259ee8e8-a1e5-42e4-9c14-517543ecdc4b",
'high_pay_keywords' => ['sat ', 'sun ', 'high ', 'public holiday'], //space is important
) );
}