|
|
|
@@ -17,6 +17,7 @@ require_once (ABSPATH . 'wp-includes/pluggable.php'); |
|
|
|
|
|
|
|
|
|
|
|
class AcareOffice{ |
|
|
|
private $acare_ndis_registration = "4050024758"; |
|
|
|
private $nonce; //for ajax verification |
|
|
|
private $pages = array('time-sheets', 'user-list'); |
|
|
|
private $bts_user_id = 0; |
|
|
|
@@ -29,6 +30,7 @@ class AcareOffice{ |
|
|
|
private $addr_table; |
|
|
|
private $ndis_table; |
|
|
|
private $apiv1; |
|
|
|
private $ndis_price; |
|
|
|
|
|
|
|
public function __construct() { |
|
|
|
$this->setup_db_name(); |
|
|
|
@@ -64,7 +66,6 @@ class AcareOffice{ |
|
|
|
add_shortcode( 'bts_client_invoice_template', array($this, 'bts_client_invoice_template')); |
|
|
|
add_shortcode( 'bts_csv_template', array($this, 'bts_csv_template')); |
|
|
|
add_shortcode( 'bts_invoiced_client', array($this, 'bts_invoiced_client')); |
|
|
|
|
|
|
|
//user profile page |
|
|
|
add_shortcode( 'bts_user_name', array($this,'bts_user_name')); |
|
|
|
|
|
|
|
@@ -184,25 +185,33 @@ class AcareOffice{ |
|
|
|
exit(); |
|
|
|
} |
|
|
|
|
|
|
|
private function get_ndis_price() |
|
|
|
{//help to ensure ndis_price is only build once per call |
|
|
|
if ( ! $this->ndis_price instanceof NdisPrice ) |
|
|
|
$this->ndis_price = new NdisPrice(); |
|
|
|
return $this->ndis_price; |
|
|
|
} |
|
|
|
|
|
|
|
private function ndis_csv_line($record) |
|
|
|
{ |
|
|
|
$str = ""; |
|
|
|
|
|
|
|
$registration = "4500000"; |
|
|
|
$price = $price = $this->get_ndis_price(); |
|
|
|
$registration = $this->acare_ndis_registration; |
|
|
|
$ndisnumber = $this->get_client_ndis_account($record->client); |
|
|
|
$date = new \DateTime($record->start); |
|
|
|
$start = $date->format("Y-m-d"); |
|
|
|
$date = new \Datetime($record->finish); |
|
|
|
$finish = $date->format("Y-m-d"); |
|
|
|
$quantity = 0; |
|
|
|
$hours = 0; |
|
|
|
$unitprice = 0; |
|
|
|
$quantity = $this->get_job_hours($record->start, $record->finish); |
|
|
|
$hours = $quantity; |
|
|
|
$unitprice = $this->get_ndis_price()->get_tos_price($record->tos); |
|
|
|
$authorizedby="helen"; |
|
|
|
$participant_approved = ""; |
|
|
|
$in_kind_program =""; |
|
|
|
$GST = $this->get_client_GST($record->client); |
|
|
|
$in_kind_program = $this->get_client_in_kind_program($record->client); |
|
|
|
$ClaimType = "";// standard; |
|
|
|
$CancellationReason=""; |
|
|
|
return "$registration,$ndisnumber,$start,$finish,$record->tos,REC_{$record->id},$quantity,$hours,$unitprice,P1,$authorizedby,$participant_approved,$in_kind_program,$ClaimType,$CancellationReason\n"; |
|
|
|
return "$registration,$ndisnumber,$start,$finish,$record->tos,REC_{$record->id},$quantity,$hours,$unitprice,$GST,$authorizedby,$participant_approved,$in_kind_program,$ClaimType,$CancellationReason\n"; |
|
|
|
} |
|
|
|
|
|
|
|
private function get_client_ndis_account($client) |
|
|
|
@@ -211,6 +220,20 @@ class AcareOffice{ |
|
|
|
return get_user_meta($user->ID,'account',true); |
|
|
|
} |
|
|
|
|
|
|
|
private function get_client_in_kind_program($client) |
|
|
|
{ |
|
|
|
$user = get_user_by('login', $client); |
|
|
|
return get_user_meta($user->ID,'in_kind_prog',true); |
|
|
|
} |
|
|
|
private function get_client_GST($client) |
|
|
|
{ |
|
|
|
$user = get_user_by('login', $client); |
|
|
|
$str = get_user_meta($user->ID,'gst',true); |
|
|
|
if ($str == "") |
|
|
|
return "P2"; |
|
|
|
return $str; |
|
|
|
} |
|
|
|
|
|
|
|
//init database |
|
|
|
public function db_install () { |
|
|
|
global $wpdb; |
|
|
|
@@ -758,15 +781,19 @@ class AcareOffice{ |
|
|
|
|
|
|
|
public function bts_invoiced_client($attr) |
|
|
|
{ |
|
|
|
$attr = shortcode_atts([ |
|
|
|
'preferred' => 'true', |
|
|
|
], $attr); |
|
|
|
|
|
|
|
$result = ""; |
|
|
|
$users = $users = get_users(array('role' => 'client')); |
|
|
|
$row = <<<ZOT |
|
|
|
<tr id="nameonly_%s" data-client-id='%s' class="invoice_nameonly_row"> |
|
|
|
<tr id="nameonly_%s" data-client-id='%s' class="invoice_nameonly_row %s"> |
|
|
|
<td class="client_nameonly" data-client-id='%s'> |
|
|
|
<i class="vc_tta-icon fa fa-plus-square"></i> %s |
|
|
|
</td> |
|
|
|
</tr> |
|
|
|
<tr id="dummyui_%s" data-client-id='%s' class="invoice_nameonly_row_dummy"> |
|
|
|
<tr id="dummyui_%s" data-client-id='%s' class="invoice_nameonly_row_dummy %s"> |
|
|
|
<td class="client_nameonly" data-client-id='%s'> |
|
|
|
<i class="vc_tta-icon fa fa-plus-square"></i> %s is loading .... please wait... |
|
|
|
</td> |
|
|
|
@@ -775,13 +802,27 @@ ZOT; |
|
|
|
foreach ($users as $u) |
|
|
|
{ |
|
|
|
$payment = get_user_meta($u->ID, 'payment', true); |
|
|
|
if( $payment != 'invoice' ) |
|
|
|
continue; //bypass |
|
|
|
$result .= sprintf($row, $u->user_login, $u->user_login, $u->user_login, $u->display_name, |
|
|
|
$u->user_login, $u->user_login, $u->user_login, $u->display_name); |
|
|
|
|
|
|
|
if ( $attr['preferred'] == 'true' ){ |
|
|
|
if( $payment == 'invoice' ){ |
|
|
|
$invoice_preferred = "invoice_preferred"; |
|
|
|
$result .= sprintf($row, |
|
|
|
$u->user_login, $u->user_login, $invoice_preferred, $u->user_login, $u->display_name, |
|
|
|
$u->user_login, $u->user_login, $invoice_preferred, $u->user_login, $u->display_name); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
$invoice_preferred = ""; |
|
|
|
if( $payment != 'invoice' ){ |
|
|
|
$result .= sprintf($row, |
|
|
|
$u->user_login, $u->user_login, $invoice_preferred, $u->user_login, $u->display_name, |
|
|
|
$u->user_login, $u->user_login, $invoice_preferred, $u->user_login, $u->display_name); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return $result; |
|
|
|
} |
|
|
|
|
|
|
|
//generate template based on html file |
|
|
|
private function template($id, $file) |
|
|
|
{ |
|
|
|
@@ -865,8 +906,7 @@ ZOT; |
|
|
|
'status' =>'success', |
|
|
|
'tos' => [], |
|
|
|
); |
|
|
|
|
|
|
|
$price = new NdisPrice();//current year; |
|
|
|
$price = $this->get_ndis_price(); |
|
|
|
$response['tos']= $price->get_tos_array(); |
|
|
|
wp_send_json($response); |
|
|
|
} |
|
|
|
@@ -1244,7 +1284,7 @@ ZOT; |
|
|
|
$days=[]; |
|
|
|
$d = new \DateTime($start); |
|
|
|
for ($i=1; $i<=14; $i++){ |
|
|
|
$days["days_$i"] = $d->format("d/F"); |
|
|
|
$days["days_$i"] = $d->format("d/M"); |
|
|
|
$d->modify("+1 day"); |
|
|
|
} |
|
|
|
|
|
|
|
@@ -1369,7 +1409,7 @@ ZOT; |
|
|
|
'jobs'=>[], |
|
|
|
'err'=>'' |
|
|
|
]; |
|
|
|
$price = new NdisPrice();//current year; |
|
|
|
$price = $this->get_ndis_price(); |
|
|
|
$summary=[];// by ndis code |
|
|
|
foreach($rows as $r){ |
|
|
|
$quantity = $this->get_job_hours($r->start, $r->finish); |
|
|
|
@@ -1404,7 +1444,7 @@ ZOT; |
|
|
|
$response['summary'][] = array( |
|
|
|
'ndis' => $key, |
|
|
|
'tos' => $price->get_tos_full_str($key), |
|
|
|
'Hours'=> $val, |
|
|
|
'Hours'=> sprintf("%0.2f", $val), |
|
|
|
); |
|
|
|
} |
|
|
|
if (count($summary) > 0){ |
|
|
|
@@ -1448,9 +1488,9 @@ ZOT; |
|
|
|
$user = get_user_by('login', $client_login); |
|
|
|
if ( !$this->is_client($user) ) |
|
|
|
return NULL; |
|
|
|
$payment = get_user_meta($user->ID, "payment", true); |
|
|
|
if ($payment != "invoice") |
|
|
|
return NULL; |
|
|
|
// $payment = get_user_meta($user->ID, "payment", true); |
|
|
|
// if ($payment != "invoice") |
|
|
|
// return NULL; |
|
|
|
|
|
|
|
$sql = "SELECT * from $this->table_name WHERE tos != '00_000_0000_0_0' and start>='$start 00:00:00' and start<='$finish 23:59:59' and client='$client_login' ORDER BY start"; |
|
|
|
$rows = $this->db->get_results($sql); |
|
|
|
@@ -1566,7 +1606,7 @@ By Carer : %s', |
|
|
|
$f = strtotime($finish); |
|
|
|
$diff = $f- $s; |
|
|
|
$hours = ($diff * 1.0 / 3600); //can be float; |
|
|
|
return $hours; |
|
|
|
return sprintf('%0.2f', $hours); |
|
|
|
} |
|
|
|
|
|
|
|
public function feedback_url() |