Bläddra i källkod

sync xero client to user, succeed

master
patrick 6 år sedan
förälder
incheckning
9eec35a6d1
5 ändrade filer med 149 tillägg och 20 borttagningar
  1. +12
    -1
      Xero.php
  2. +76
    -14
      css/bts_timesheet.css
  3. +12
    -1
      js/bts_timesheet.js
  4. +1
    -1
      js/ts.js
  5. +48
    -3
      ts.php

+ 12
- 1
Xero.php Visa fil

public function __construct(){ public function __construct(){
$this->xero = new PrivateApplication($this->office_config()); $this->xero = new PrivateApplication($this->office_config());
}
public function getClients($contact_group_id){
$xero = $this->xero;
$cg = $xero->loadByGUID("Accounting\\ContactGroup", $contact_group_id);
$contacts = $cg->getContacts();
return $contacts;
}
public function getContact($id){
$user = $this->xero->loadByGUID("Accounting\\Contact",$id);
return $user;
} }
} }

+ 76
- 14
css/bts_timesheet.css Visa fil

@CHARSET "UTF-8";

html, html,
body { body {
margin: 0px !important; margin: 0px !important;
box-shadow: 1px 1px 10px black; box-shadow: 1px 1px 10px black;
} }


div.peopleitem .card div {
div.peopleitem .card > div {
position: absolute; position: absolute;
height: 100%; height: 100%;
width: 100%; width: 100%;
padding-right: 10px; padding-right: 10px;
} }


div.week1:after, div.week2:after{
div.week1:after,
div.week2:after {
content: ''; content: '';
display: inline-block; display: inline-block;
width: 100%; width: 100%;
left: 10px; left: 10px;
} }


div.week1 > div, div.week2 > div{
div.week1 > div,
div.week2 > div {
display: inline-block; display: inline-block;
text-align: center; text-align: center;
width: 10%; width: 10%;
font-weight: bolder; font-weight: bolder;
} }


div.week1 > div{
div.week1 > div {
box-shadow: 0px 0px 10px white inset; box-shadow: 0px 0px 10px white inset;
} }
div.week2 > div{

div.week2 > div {
background-color: dodgerblue; background-color: dodgerblue;
box-shadow: 0px 0px 10px white inset; box-shadow: 0px 0px 10px white inset;
} }


div.sheettableheader{
div.sheettableheader {
margin-top: 0px; margin-top: 0px;
height: 30px; height: 30px;
background-color: lightgrey; background-color: lightgrey;
overflow-y: scroll; overflow-y: scroll;
} }


div.bday, div.bdate, div.btos, div.bstart, div.bfinish, div.bhours, div.bstaff, div.bclients, div.bconfirmed, div.bdelete{
div.bday,
div.bdate,
div.btos,
div.bstart,
div.bfinish,
div.bhours,
div.bstaff,
div.bclients,
div.bconfirmed,
div.bdelete {
display: block; display: block;
float: left; float: left;
background-color: black; background-color: black;
font-weight: bolder; font-weight: bolder;
font-size: 20px; font-size: 20px;
color: white; color: white;

/* box-shadow: 1px 1px 10px black; */ /* box-shadow: 1px 1px 10px black; */
width:10%;
width: 10%;
height: 30px; height: 30px;
} }
div.bdelete, div.bconfirmed{

div.bdelete,
div.bconfirmed {
width: 5%; width: 5%;
} }
div.btos{

div.btos {
width: 20%; width: 20%;
} }


div.assignment > div{
color:navy;
div.assignment > div {
color: navy;
background-color: white; background-color: white;
font-size: 20px; font-size: 20px;
font-weight: lighter; font-weight: lighter;
border: 1px dotted lightgrey; border: 1px dotted lightgrey;
} }

/* peple item card*/
.peopleitem div span.checked {
color:orange;
}
.peopleitem div.card div.front > div[name="title"] {
height: auto;
text-align: center;
background-color: lightgrey;
}
div.front > span[name='icon'] {
width: 100%;
height: 15px;
background-color: dimgrey;
color: white;
}

div.back > span.icon{
width: 100%;
background-color: lightgrey;
color: dimgrey
}


div.front > span.badge, div.back > span.badge {
border-radius: 50%;
display: inline-block;
padding-left: 8px;
padding-right: 8px;
text-align: center;
position:absolute;
right : -5px;
top: -5px;
}

span.badge.blue{
color: #fff;
box-shadow: 1px 1px 10px black;
background-color: black;
}

span.badge.pink{
color: black;
box-shadow: 1px 1px 10px white;
background-color: white;
}


+ 12
- 1
js/bts_timesheet.js Visa fil

(function ($) { (function ($) {
$(function () { $(function () {
console.log("in timesheets %o", bts());
class People{
function constructor(selector){
}
}//end of class People
var sample_people{
firstname: "first",
lastname: "last"
}
}); });
})(jQuery); })(jQuery);

+ 1
- 1
js/ts.js Visa fil



(function ($) { (function ($) {
$(function () { $(function () {
console.log("%o", bts());
}); });
})(jQuery); })(jQuery);

+ 48
- 3
ts.php Visa fil

private $nonce; //for ajax verification private $nonce; //for ajax verification
private $pages = array('time-sheets', 'user-list'); private $pages = array('time-sheets', 'user-list');
private $acaresydney_userid = 0; private $acaresydney_userid = 0;
private $clientgroup="48646f3d-cf5e-4fea-8c8b-5812bd540e1b";
private $xero ;
public function __construct() { public function __construct() {
add_action('init', array($this, 'class_loader')); add_action('init', array($this, 'class_loader'));
add_action('wp_enqueue_scripts', array($this, 'register_js_css'), 99); add_action('wp_enqueue_scripts', array($this, 'register_js_css'), 99);
add_filter('show_admin_bar', '__return_false'); add_filter('show_admin_bar', '__return_false');
add_shortcode( 'ts-sync-users', array($this, 'sync_users'));
} }
/** /**
// Add our namespace and the folder it maps to // Add our namespace and the folder it maps to
$loader->addNamespace('\XeroPHP', dirname(__FILE__) . '/xero-php-master/src/XeroPHP'); $loader->addNamespace('\XeroPHP', dirname(__FILE__) . '/xero-php-master/src/XeroPHP');
$loader->addNamespace('\Biukop', dirname(__FILE__) . '/' ); $loader->addNamespace('\Biukop', dirname(__FILE__) . '/' );


$n = new Xero();
$this->xero = new Xero();
} }


wp_enqueue_script( 'bts_ts', plugins_url('js/bts_timesheet.js', __FILE__), array( 'jquery' , 'bts' )); wp_enqueue_script( 'bts_ts', plugins_url('js/bts_timesheet.js', __FILE__), array( 'jquery' , 'bts' ));
} }
//sync users to wordpress system
public function sync_users(){
$this->sync_clients();
$this->sync_employees();
}
private function sync_clients(){
$contacts = $this->xero->getClients($this->clientgroup);
foreach ($contacts as $c){
$this->ensure_contact_exists($c);
}
}
private function sync_employees(){
}
private function ensure_contact_exists($contact){
$login = $contact->getContactID();
$xero_contact = $this->xero->getContact($login);
$args = $this->xero_contact_profile($xero_contact);
$user = get_user_by('login', $login);
if ($user === false){
wp_insert_user($args);
}else{//update user
$args['ID'] = $user->ID;
wp_update_user($args);
}
}
private function xero_contact_profile($c){
$args = [
'user_login' => $username = $c->getContactID(),
'user_pass' => md5(uniqid(rand() + time(), true)),
'display_name' =>$c->getName(),
'user_email' => $c->getEmailAddress(),
'first_name' => $c->getFirstName(),
'last_name' => $c->getLastName(),
'nickname' => $c->getName(),
'role' => 'client',
];
return $args;
}
} }


new AcareOffice(); new AcareOffice();

Laddar…
Avbryt
Spara