From 575ac9781856518294e6da6ed074e8fe9037190b Mon Sep 17 00:00:00 2001 From: patrick Date: Tue, 10 Sep 2019 19:52:39 +1000 Subject: [PATCH] download csv first skeleton workded --- css/xeroc.css | 3 ++- js/bts_office.js | 2 +- js/xeroc.js | 18 ++++++++++++++++++ ts.php | 21 ++++++++++++++------- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/css/xeroc.css b/css/xeroc.css index e5ae754..bd458fd 100644 --- a/css/xeroc.css +++ b/css/xeroc.css @@ -15,7 +15,8 @@ } #cstart, #cfinish, #paydate, -#invoice_start, #invoice_finish{ +#invoice_start, #invoice_finish, +#ndis_start, #ndis_finish{ width:100%; border:none; text-align: center; diff --git a/js/bts_office.js b/js/bts_office.js index 951dc23..5d1f912 100644 --- a/js/bts_office.js +++ b/js/bts_office.js @@ -1934,7 +1934,7 @@ //console.log(kms); for (var staff in kms ){ bts().staff_people[staff].set_km(kms[staff]); - console.log(bts().staff_map[staff]); + //console.log(bts().staff_map[staff]); ensure_visible(bts().staff_people[staff].selector); } } diff --git a/js/xeroc.js b/js/xeroc.js index 7e01fd8..c840708 100644 --- a/js/xeroc.js +++ b/js/xeroc.js @@ -1,3 +1,4 @@ +function on_download_ndis_csv (){} (function ($) { $(function () { /*_____________________________________________*/ @@ -315,6 +316,23 @@ datebox(); setup_invoice_start_finish(); + on_download_ndis_csv = do_download_ndis; + function do_download_ndis(){ + var form = $('#ndis'); + $('input[name="start"]').attr('value', "start中"); + $('input[name="finish"]').attr('value', "finish文"); + + var clients = ["client1", "client2", "client3", "client4"]; + clients.forEach(function(e,i){ + if ( $('#e' + i).length == 0 ){ + var input = $(''); + form.append(input); + }else{ + $('#e' + i).attr('value', e); + } + }); + form.submit(); + } /*_____________________________________________*/ }); })(jQuery); diff --git a/ts.php b/ts.php index 1d0c179..462abb4 100644 --- a/ts.php +++ b/ts.php @@ -33,7 +33,7 @@ class AcareOffice{ $this->setup_db_name(); $this->class_loader(); $this->apiv1 = new Apiv1($this, $this->job_table); - + //$this->check_csv_download(); add_option( "acare_ts_db_version", "1.0" ); register_activation_hook( __FILE__, array($this, 'db_install') ); @@ -145,13 +145,18 @@ class AcareOffice{ public function check_csv_download() { + $method = $_SERVER['REQUEST_METHOD']; + if ( $method != "POST") + return; + + global $wpdb; $url = $_SERVER['REQUEST_URI']; - $matches=[]; - preg_match("/\/ndiscsv\/start-([^\/]+)\/finish-([^\/]+)\/?$/", $url, $matches); - if ( $matches !=3 || $_SERVER['REQUEST_URI'] != $matches[0] ) + if ($url != "/ndiscsv/"){ return; - $start = $matches[1]; - $finish = $matches[2]; + } + $clients= $_POST['clients']; + $start = $_POST['start'];; + $finish = $_POST['finish'];; $filename="{$start}___{$finish}.csv"; header("Expires: 0"); @@ -162,7 +167,8 @@ class AcareOffice{ header("Content-Disposition:attachment; filename=$filename"); header("Content-Type: application/force-download"); //readfile(dirname(__FILE__) . "/img/circle.png"); - echo "content of this file"; + + echo "content of this file " . print_r($clients, true) . print_r($_POST, true); exit(); } @@ -802,6 +808,7 @@ ZOT; 'email'=> $s->user_email, 'account'=> get_user_meta($s->ID, 'account', true), 'address' => get_user_meta($s->ID, 'address', true), + 'paymemt'=>get_user_meta($s->ID, 'payment', true), 'rating'=> 0, 'unconfirmedjob'=> 0, );