Parcourir la source

staff list works fine

master
patrick il y a 6 ans
Parent
révision
a0cea9ccea
5 fichiers modifiés avec 90 ajouts et 29 suppressions
  1. +5
    -3
      Xero.php
  2. +2
    -2
      css/bts_timesheet.css
  3. +4
    -4
      html/peopleitem.html
  4. +42
    -19
      js/bts_timesheet.js
  5. +37
    -1
      ts.php

+ 5
- 3
Xero.php Voir le fichier

@@ -78,7 +78,7 @@ class Xero {
$this->logConsole($msg);
try{
$this->sync_clients();
//$this->sync_clients();
$this->sync_employees();
}catch(RateLimitExceededException $e){
$msg= "Xero API rate limit exceeded, please try again later, existing sync within 600 seconds will by passed automatically\n";
@@ -157,6 +157,7 @@ class Xero {
$args['ID'] = $user->ID;
unset($args['user_pass']);
wp_update_user($args);
update_user_meta($user->ID, 'mobile', $args['mobile']);
}
$this->mark_updated($user->ID);
}
@@ -170,6 +171,7 @@ class Xero {
'first_name' => $e->getFirstName(),
'last_name' => $e->getLastName(),
'nickname' => $e->getFirstName(),
'mobile' => $e->getMobile(),
'role' => 'staff',
];
return $args;
@@ -180,8 +182,8 @@ class Xero {
}
private function get_last_sync($userid){
$lastsync = get_user_meta($userid, 'lastsync');
return (int)($lastsync[0]);
$lastsync = get_user_meta($userid, 'lastsync', true);
return (int)($lastsync);
}
private function is_too_close_to_sync($user){

+ 2
- 2
css/bts_timesheet.css Voir le fichier

@@ -111,7 +111,7 @@ body {
position: relative;
margin-top: 10px;
margin-bottom: 10px;
height: 100px;
height: 120px;
background: transparent;
}

@@ -123,7 +123,7 @@ div.peopleitem > label {
transform-style: preserve-3d;
display: block;
width: 100%;
height: 100px;
height: 100%;
position: absolute;
left: 50%;
top: 50%;

+ 4
- 4
html/peopleitem.html Voir le fichier

@@ -1,17 +1,17 @@

<label class='peopleitem' data-id=p{{login}} > <input type="checkbox" checked/>
<label class='peopleitem' data-id=p{{login}} > <input type="checkbox"/>
<div class="card">
<div class="front">
<span name='iccon' class='ticon ticon-user'></span> <span
name='badge' class='badge blue'>{{unconfirmedjob}}</span>
name='badge' class='badge blue'><a href="/pending-jobs/{{login}}"></a>{{unconfirmedjob}}</span>
<div name='title'><a href='/user/{{login}}' target="_blank"> {{firstname}},{{lastname}} </a></div>
<div name='wages'>${{wages}} ({{hour}}hr + {{OT}}hr)</div>
<div name='patrol'>petrol:{{petrol}} km</div>
</div>
<div class="back">
<span name='badge' class='badge pink'>{{unconfirmedjob}}</span> <span
<span name='badge' class='badge pink'><a href="/pending-jobs/{{login}}">{{unconfirmedjob}}</a></span> <span
class='ticon ticon-fax'>-{{firstname}},{{lastname}}</span>
<div name='mobile'>{{phone}}</div>
<div name='mobile'>{{mobile}}</div>
<div name='email'>{{email}}</div>
<div name='rating'>
<span class="ticon ticon-star checked"></span> <span

+ 42
- 19
js/bts_timesheet.js Voir le fichier

@@ -1,5 +1,6 @@
(function ($) {
$(function () {
/*____________________________________________________________________________________*/
class People{
constructor(selector, data){
this.selector = selector;
@@ -59,24 +60,46 @@
return r;
}
for (var i=1; i<100; i++){
var sample_people = {
login: '01515b52-6936-46b2-a000-9ad4cd7a5b50' +i,
firstname: "first"+i,
lastname: "last",
phone: '041122221' +i,
email: 'abc@gmail.com' + i,
wages: 0,
hour: i,
OT: 3,
petrol: 50 +i,
rating: Math.floor(Math.random() * Math.floor(5)),
unconfirmedjob: Math.floor(Math.random() * Math.floor(30))
};
var html = bts_people_html(sample_people);
jQuery('div.stafflist').append(html);
new People("#p" + sample_people.login, sample_people);
}
function sample_staff(){
for (var i=1; i<100; i++){
var sample_people = {
login: '01515b52-6936-46b2-a000-9ad4cd7a5b50' +i,
firstname: "first"+i,
lastname: "last",
mobile: '041122221' +i,
email: 'abc@gmail.com' + i,
wages: 0,
hour: i,
OT: 3,
petrol: 50 +i,
rating: Math.floor(Math.random() * Math.floor(5)),
unconfirmedjob: Math.floor(Math.random() * Math.floor(30)),
};
var html = bts_people_html(sample_people);
jQuery('div.stafflist').append(html);
new People("#p" + sample_people.login, sample_people);
}
}
function list_staff() {
$.post(bts().ajax_url, { // POST request
_ajax_nonce: bts().nonce, // nonce
action: "list_staff", // action
}, function(response, status, xhr){
if (response.status =='success'){
response.staff.forEach(function(staff){
var html = bts_people_html(staff);
jQuery('div.stafflist').append(html);
new People("#p" + staff.login, staff);
});
}else{
alert('error getting staff list');
}
});
}
function init_ts(){
list_staff();
}
init_ts();
/*________________________________________________________________________*/
});
})(jQuery);

+ 37
- 1
ts.php Voir le fichier

@@ -30,6 +30,9 @@ class AcareOffice{
add_shortcode( 'ts-sync-users', array($this, 'sync_users'));
add_shortcode( 'bts_people_item', array($this, 'bts_people_item'));
add_action('wp_ajax_list_staff', array($this,'list_staff' ));
}
/**
@@ -95,7 +98,7 @@ class AcareOffice{
public function sync_users()
{
$a=1;
//dummy sync
return;
}
@@ -121,6 +124,39 @@ class AcareOffice{
$text .= '</script>';
return $text;
}
function list_staff(){
check_ajax_referer('acaresydney');
// Handle the ajax request
$response = array(
'status' =>'error',
'staff' => [],
);
//search all users that are staff
$staffq = new \WP_User_Query(array('role'=>'staff'));
$staff = $staffq->get_results();
if (! empty($staff)){
$response['status'] = 'success';
foreach( $staff as $s){
$response['staff'][] = array(
'login' => $s->user_login,
'firstname'=> $s->first_name,
'lastname'=> $s->last_name,
'mobile'=> get_user_meta($s->ID, 'mobile', true),
'email'=> $s->user_email,
'wages'=> 0,
'hour' => 0 ,
'OT' => 0 ,
'petrol'=> 0 ,
'rating'=> 0,
'unconfirmedjob'=> 0,
);
}
}
wp_send_json($response);
wp_die();
}
}

$bb = new AcareOffice();

Chargement…
Annuler
Enregistrer