diff --git a/Xero.php b/Xero.php index a0423c3..fc6df94 100644 --- a/Xero.php +++ b/Xero.php @@ -129,7 +129,7 @@ class Xero { $employees = $this->getEmployees(); //add new staff foreach ( $employees as $e){ - $login = $e->getContactID(); + $login = $e->getEmployeeID(); $user = get_user_by('login', $login); if ($user === false){ $this->add_new_staff($e); @@ -166,6 +166,8 @@ class Xero { }else{ $msg = "==(Add Client failed)=="; $this->logConsole($msg); + $msg = sprintf("ADD Client name=[%s] {%s} Failed\n", $contact->getName(), $contact->getContactID()); + error_log("ACARE add client failed: $msg"); } } } @@ -265,6 +267,12 @@ class Xero { }else{ $msg = "==(Add staff failed)=="; $this->logConsole($msg); + + $msg = sprintf("ADD employee name=[%s %s] {%s} Failed\n", + $employee->getFirstName(), + $employee->getLastName(), + $employee->getEmployeeID()); + error_log("ACARE add employee failed: $msg"); } } } @@ -378,7 +386,7 @@ class Xero { } private function add_new_client(){ - if ($this->too_close_to_add_employee()){ + if ($this->too_close_to_add_client()){ return; } update_option('bts_add_client_last_sync', time()); @@ -386,11 +394,11 @@ class Xero { } private function add_new_employee(){ - if ($this->too_close_to_add_client()){ + if ($this->too_close_to_add_employee()){ return; } update_option('bts_add_employee_last_sync', time()); - $this->sync_employee(true);//add new only; + $this->sync_employees(true);//add new only; } private function sync_payroll_calendar() @@ -462,19 +470,19 @@ class Xero { $lastsync = get_option('bts_add_employee_last_sync', 0); $now = time(); $diff = $now - (int) $lastsync; - return $diff < 1.1 * $this->minimum_sync_interval_in_seconds; //default 1.1 * 10 minutes + return $diff < 1.5 * $this->minimum_sync_interval_in_seconds; //default 1.1 * 10 minutes } private function too_close_to_add_client(){ $lastsync = get_option('bts_add_client_last_sync', 0); $now = time(); $diff = $now - (int) $lastsync; - return $diff < 1.2 * $this->minimum_sync_interval_in_seconds; //default 1.2 * 10 minutes + return $diff < 2.0 * $this->minimum_sync_interval_in_seconds; //default 1.2 * 10 minutes } private function too_close_to_sync_payroll_calendar(){ $lastsync = get_option('bts_pay_roll_calendar_last_sync', 0); $now = time(); $diff = $now - (int) $lastsync; - return $diff < 1.3 * $this->minimum_sync_interval_in_seconds; //default 1.3 * 10 minutes + return $diff < 3.0 * $this->minimum_sync_interval_in_seconds; //default 1.3 * 10 minutes } public function get_payroll_calendar()