| $this->logConsole($msg); | $this->logConsole($msg); | ||||
| try{ | try{ | ||||
| $this->sync_clients(); | |||||
| //$this->sync_clients(); | |||||
| $this->sync_employees(); | $this->sync_employees(); | ||||
| }catch(RateLimitExceededException $e){ | }catch(RateLimitExceededException $e){ | ||||
| $msg= "Xero API rate limit exceeded, please try again later, existing sync within 600 seconds will by passed automatically\n"; | $msg= "Xero API rate limit exceeded, please try again later, existing sync within 600 seconds will by passed automatically\n"; | ||||
| $args['ID'] = $user->ID; | $args['ID'] = $user->ID; | ||||
| unset($args['user_pass']); | unset($args['user_pass']); | ||||
| wp_update_user($args); | wp_update_user($args); | ||||
| update_user_meta($user->ID, 'mobile', $args['mobile']); | |||||
| } | } | ||||
| $this->mark_updated($user->ID); | $this->mark_updated($user->ID); | ||||
| } | } | ||||
| 'first_name' => $e->getFirstName(), | 'first_name' => $e->getFirstName(), | ||||
| 'last_name' => $e->getLastName(), | 'last_name' => $e->getLastName(), | ||||
| 'nickname' => $e->getFirstName(), | 'nickname' => $e->getFirstName(), | ||||
| 'mobile' => $e->getMobile(), | |||||
| 'role' => 'staff', | 'role' => 'staff', | ||||
| ]; | ]; | ||||
| return $args; | return $args; | ||||
| } | } | ||||
| private function get_last_sync($userid){ | 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){ | private function is_too_close_to_sync($user){ |
| position: relative; | position: relative; | ||||
| margin-top: 10px; | margin-top: 10px; | ||||
| margin-bottom: 10px; | margin-bottom: 10px; | ||||
| height: 100px; | |||||
| height: 120px; | |||||
| background: transparent; | background: transparent; | ||||
| } | } | ||||
| transform-style: preserve-3d; | transform-style: preserve-3d; | ||||
| display: block; | display: block; | ||||
| width: 100%; | width: 100%; | ||||
| height: 100px; | |||||
| height: 100%; | |||||
| position: absolute; | position: absolute; | ||||
| left: 50%; | left: 50%; | ||||
| top: 50%; | top: 50%; |
| <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="card"> | ||||
| <div class="front"> | <div class="front"> | ||||
| <span name='iccon' class='ticon ticon-user'></span> <span | <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='title'><a href='/user/{{login}}' target="_blank"> {{firstname}},{{lastname}} </a></div> | ||||
| <div name='wages'>${{wages}} ({{hour}}hr + {{OT}}hr)</div> | <div name='wages'>${{wages}} ({{hour}}hr + {{OT}}hr)</div> | ||||
| <div name='patrol'>petrol:{{petrol}} km</div> | <div name='patrol'>petrol:{{petrol}} km</div> | ||||
| </div> | </div> | ||||
| <div class="back"> | <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> | class='ticon ticon-fax'>-{{firstname}},{{lastname}}</span> | ||||
| <div name='mobile'>{{phone}}</div> | |||||
| <div name='mobile'>{{mobile}}</div> | |||||
| <div name='email'>{{email}}</div> | <div name='email'>{{email}}</div> | ||||
| <div name='rating'> | <div name='rating'> | ||||
| <span class="ticon ticon-star checked"></span> <span | <span class="ticon ticon-star checked"></span> <span |
| (function ($) { | (function ($) { | ||||
| $(function () { | $(function () { | ||||
| /*____________________________________________________________________________________*/ | |||||
| class People{ | class People{ | ||||
| constructor(selector, data){ | constructor(selector, data){ | ||||
| this.selector = selector; | this.selector = selector; | ||||
| return r; | 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); | })(jQuery); |
| add_shortcode( 'ts-sync-users', array($this, 'sync_users')); | add_shortcode( 'ts-sync-users', array($this, 'sync_users')); | ||||
| add_shortcode( 'bts_people_item', array($this, 'bts_people_item')); | add_shortcode( 'bts_people_item', array($this, 'bts_people_item')); | ||||
| add_action('wp_ajax_list_staff', array($this,'list_staff' )); | |||||
| } | } | ||||
| /** | /** | ||||
| public function sync_users() | public function sync_users() | ||||
| { | { | ||||
| $a=1; | |||||
| //dummy sync | |||||
| return; | return; | ||||
| } | } | ||||
| $text .= '</script>'; | $text .= '</script>'; | ||||
| return $text; | 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(); | $bb = new AcareOffice(); |