From 7d2850b3ceb3115092f9fad36b452d27aaca2a21 Mon Sep 17 00:00:00 2001 From: patrick Date: Wed, 11 Sep 2019 03:56:46 +1000 Subject: [PATCH] cvs download done --- css/xeroc.css | 4 ++++ ts.php | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/css/xeroc.css b/css/xeroc.css index ef77b20..afbcf8d 100644 --- a/css/xeroc.css +++ b/css/xeroc.css @@ -208,6 +208,10 @@ td.invoice_summary_header{ font-weight:900; } +.select_client_check_box span.client_attr{ + padding-left:60px; +} + #checkall_clients { font-size: 1.5em; padding-top: 20px; diff --git a/ts.php b/ts.php index ddb2356..e571ec6 100644 --- a/ts.php +++ b/ts.php @@ -10,6 +10,7 @@ namespace Biukop; use XeroPHP\Models\Accounting\Address; +use XeroPHP\Models\Accounting\Payment; require_once(dirname(__FILE__) . '/autoload.php'); require_once (ABSPATH . 'wp-includes/pluggable.php'); @@ -166,11 +167,48 @@ class AcareOffice{ header("Content-type: text/csv"); header("Content-Disposition:attachment; filename=$filename"); header("Content-Type: application/force-download"); + + //readfile(dirname(__FILE__) . "/img/circle.png"); + $clients_in = "'" . implode("','", $clients) . "'"; + $sql = "SELECT * from $this->table_name WHERE client in ($clients_in) and start >='$start 00:00:00' and start<='$finish 23:59:59'"; + $results = $wpdb->get_results($sql); + $csv_header = "RegistrationNumber,NDISNumber,SupportsDeliveredFrom,SupportsDeliveredTo,SupportNumber,ClaimReference,Quantity,Hours,UnitPrice,GSTCode,AuthorisedBy,ParticipantApproved,InKindFundingProgram,ClaimType,CancellationReason\n"; - echo "$csv_header" . print_r($clients, true) . print_r($_POST, true); + echo $csv_header; + foreach($results as $r) + { + echo $this->ndis_csv_line($r); + } + //echo $sql; exit(); - + } + + private function ndis_csv_line($record) + { + $str = ""; + + $registration = "4500000"; + $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; + $authorizedby="helen"; + $participant_approved = ""; + $in_kind_program =""; + $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"; + } + + private function get_client_ndis_account($client) + { + $user = get_user_by('login', $client); + return get_user_meta($user->ID,'account',true); } //init database