| } | } | ||||
| textarea.addr{ | textarea.addr{ | ||||
| padding-top:15px; | padding-top:15px; | ||||
| min-height: 100px; | |||||
| min-height: 150px; | |||||
| font-weight: bold; | font-weight: bold; | ||||
| color: blue; | color: blue; | ||||
| resize: none; | resize: none; | ||||
| .tt-suggestion p { | .tt-suggestion p { | ||||
| margin: 0; | margin: 0; | ||||
| } | } | ||||
| #pickupcontact, #pickupwechat, #pickuptime { | |||||
| margin-left: 10px; | |||||
| margin-right: 10px; | |||||
| border: none; | |||||
| color: blue; | |||||
| font-weight: bold; | |||||
| text-align: center; | |||||
| } | |||||
| </style> | </style> |
| <div class="success" style="width:300px;height:300px;text-align:center;margin:auto"> | |||||
| <table style="min-height:150px;"> | |||||
| <tr><td style="text-align:center; vertical-align:middle;"> | |||||
| <h1>#NAME# 纪念章签收</h1> | |||||
| </td></tr> | |||||
| <tr><td style="text-align:center; vertical-align:middle;"> | |||||
| <img src="#SRC#" > | |||||
| </td></tr> | |||||
| </table> | |||||
| </div> |
| <table class="details"> | <table class="details"> | ||||
| <tr><td colspan=2> | <tr><td colspan=2> | ||||
| <span>Postal Address</span> <br> | <span>Postal Address</span> <br> | ||||
| <textarea class=addr> | |||||
| 33 Valerie Ave | |||||
| Baulk Ham Hills, | |||||
| NSW, Australia 2153 | |||||
| <textarea class=addr id='postaladdr' disabled> | |||||
| No valid addr | |||||
| </textarea> | </textarea> | ||||
| <button id=changeaddr>Change Address</button> | |||||
| <!-- button id=changeaddr>Change Address</button --> | |||||
| </td></tr> | </td></tr> | ||||
| <tr> | <tr> | ||||
| <td>State in Australia</td> | <td>State in Australia</td> | ||||
| <td class="left"> | <td class="left"> | ||||
| <select name="states" class=fullwidth id="states"> | |||||
| <select name="states" class=fullwidth id="states" disabled> | |||||
| <option value="NSW">NSW</option> | <option value="NSW">NSW</option> | ||||
| <option value="ACT">ACT</option> | <option value="ACT">ACT</option> | ||||
| <option value="WA">WA</option> | <option value="WA">WA</option> | ||||
| <option value="SA">SA</option> | <option value="SA">SA</option> | ||||
| <option value="QLD">QLD</option> | |||||
| <option value="NT">NT</option> | <option value="NT">NT</option> | ||||
| <option value="TAS">TAS</option> | <option value="TAS">TAS</option> | ||||
| <option value="VIC">VIC</option> | <option value="VIC">VIC</option> | ||||
| <option value="na">Unknown</option> | |||||
| </select> | </select> | ||||
| </td> | </td> | ||||
| <tr> | <tr> | ||||
| <td>Delivery:</td> | <td>Delivery:</td> | ||||
| <td class="left"> | <td class="left"> | ||||
| <input type=radio name="delivery" > N/A <br> | |||||
| <input type=radio name="delivery" > Direct Post <br> | |||||
| <input type=radio name="delivery" checked> Pick up from <span id=collector> Patrick Sun </span> | |||||
| <input type=radio name="delivery" value="na"> N/A <br> | |||||
| <input type=radio name="delivery" value="dp"> Direct Post <br> | |||||
| <input type=radio name="delivery" value="pp" checked> Pick up from <span class="collector"> </span> | |||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td style="vertical-align:middle"> | <td style="vertical-align:middle"> | ||||
| <input id="medal" type=checkbox checked onclick="return false;"><br> | <input id="medal" type=checkbox checked onclick="return false;"><br> | ||||
| <label for="medal" id='medalstatus'>Received in AU</labe> | |||||
| <label for="medal" id='medalstatus'></labe> | |||||
| </td> | </td> | ||||
| <td > | <td > | ||||
| <img src="https://via.placeholder.com/150" > | |||||
| From Alma mater to AU | |||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| <tr id=tracking1> | <tr id=tracking1> | ||||
| <td id=date1 style="vertical-align:middle"> | |||||
| 2020-12-10 | |||||
| <td style="vertical-align:middle"> | |||||
| <input id="posted" type=checkbox checked onclick="return false;"> | |||||
| </td> | </td> | ||||
| <td> | <td> | ||||
| Send out from Sydney | |||||
| Posted | |||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| <tr id=tracking2> | |||||
| <tr id=tracking2 class=pp> | |||||
| <td id=date1 style="vertical-align:middle"> | <td id=date1 style="vertical-align:middle"> | ||||
| 2020-12-10 | |||||
| <input id="received" type=checkbox onclick="return false;"> | |||||
| </td> | </td> | ||||
| <td> | <td> | ||||
| Send out from Sydney | |||||
| Received by : <span class="collector"> </span> | |||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| <tr id=tracking3> | |||||
| <tr id=tracking3 class='pp'> | |||||
| <td id=date1 style="vertical-align:middle"> | <td id=date1 style="vertical-align:middle"> | ||||
| 2020-12-10 | |||||
| <input id=readyforpickup type=checkbox onclick="return false;"> | |||||
| </td> | </td> | ||||
| <td> | <td> | ||||
| Send out from Sydney | |||||
| Ready for Pickup | |||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| <tr id=tracking4> | |||||
| <td id="done" style="vertical-align:middle"> | |||||
| <input id="delivered" type=checkbox onclick="return false;"> | |||||
| </td> | |||||
| <td> | |||||
| Delivered | |||||
| </td> | |||||
| </tr> | |||||
| <tr id=tracking5 class=contact> | |||||
| <td id=contact colspan=2> | |||||
| Pickup Phone: | |||||
| <input id=pickupcontact value=""> | |||||
| </td> | |||||
| </tr> | |||||
| <tr class=contact> | |||||
| <td id=contact colspan=2> | |||||
| Pickup Wechat: | |||||
| <input id=pickupwechat value=""> | |||||
| </td> | |||||
| </tr> | |||||
| <tr class=contact> | |||||
| <td id=contact colspan=2> | |||||
| Pickup Location: | |||||
| <textarea id='pickuplocation' disabled class='addr'> | |||||
| </textarea> | |||||
| </td> | |||||
| </tr> | |||||
| <tr class=contact> | |||||
| <td id=contact colspan=2> | |||||
| Pickup time: | |||||
| <input id=pickuptime value=""> | |||||
| </td> | |||||
| </tr> | |||||
| </table> | </table> | ||||
| </div> | </div> | ||||
| <div class="success"> | <div class="success"> | ||||
| <table style="min-height:150px;"> | <table style="min-height:150px;"> | ||||
| <tr><td style="text-align:center; vertical-align:middle;"> | <tr><td style="text-align:center; vertical-align:middle;"> |
| $("#loading90").attr('src', mm.loading); | $("#loading90").attr('src', mm.loading); | ||||
| $("#done").attr('src', mm.done); | $("#done").attr('src', mm.done); | ||||
| $(':radio:not(:checked)').attr('disabled', true); | |||||
| $("span.collector").text("Pactrick"); | |||||
| init_clientname_input("#username"); | init_clientname_input("#username"); | ||||
| }); | }); | ||||
| function onUpdateClientID (e, suggestion) | function onUpdateClientID (e, suggestion) | ||||
| { | { | ||||
| mm.current_user = suggestion.userid; | mm.current_user = suggestion.userid; | ||||
| $('#details').hide(); | |||||
| $.post(mm.ajax_url, { // POST request | $.post(mm.ajax_url, { // POST request | ||||
| _ajax_nonce: mm.nonce, // nonce | _ajax_nonce: mm.nonce, // nonce | ||||
| action: "list_users", // action | action: "list_users", // action | ||||
| _ajax_nonce: mm.nonce, // nonce | _ajax_nonce: mm.nonce, // nonce | ||||
| action: "list_users", // action | action: "list_users", // action | ||||
| client : mm.current_user, | client : mm.current_user, | ||||
| name : input, | |||||
| }, function(response, status, xhr){ | }, function(response, status, xhr){ | ||||
| step2_verify_user(response); | step2_verify_user(response); | ||||
| }).fail(function(){ | }).fail(function(){ | ||||
| $("#errVerify").text("Incorrect, please try again"); | $("#errVerify").text("Incorrect, please try again"); | ||||
| } | } | ||||
| $("#postaladdr").val(response.addr); | |||||
| $("#states").val(response.state); | |||||
| $("span.collector").text(response.pickup); | |||||
| $("#pickupcontact").val(response.pp); | |||||
| $("#pickupwechat").val(response.ppwechat); | |||||
| $("#pickuplocation").val(response.loc); | |||||
| $("#pickuptime").val(response.time); | |||||
| $(':radio:not(:checked)').attr('disabled', false); | |||||
| $(':radio:checked').attr('disabled', false); | |||||
| //set delivery | |||||
| switch(response.delivery) | |||||
| { | |||||
| case 'pp': | |||||
| $('input:radio[name=delivery]:nth(2)').prop('checked',true); | |||||
| $('tr.pp').show(); | |||||
| break; | |||||
| case 'dp': | |||||
| $('tr.pp').hide(); | |||||
| $('input:radio[name=delivery]:nth(1)').prop('checked',true); | |||||
| break; | |||||
| default: | |||||
| $('tr.pp').hide(); | |||||
| $('input:radio[name=delivery]:nth(0)').prop('checked',true); | |||||
| } | |||||
| $(':radio:not(:checked)').attr('disabled', true); | |||||
| $(':radio:checked').attr('disabled', false); | |||||
| //steps | |||||
| $("#medal").prop("checked", response.step >= 1); | |||||
| $("#posted").prop("checked", response.step >= 2); | |||||
| $("#received").prop("checked", response.step >= 3); | |||||
| $("#readyforpickup").prop("checked", response.step >= 4); | |||||
| $("#delivered").prop("checked", response.step >= 5); | |||||
| } | } | ||||
| //apply card | //apply card |
| Copyright: All rights reserved. | Copyright: All rights reserved. | ||||
| */ | */ | ||||
| namespace Member; | namespace Member; | ||||
| use function Nextgenthemes\ARVE\Common\Admin\label_text; | |||||
| //require_once(dirname(__FILE__) . '/autoload.php'); | //require_once(dirname(__FILE__) . '/autoload.php'); | ||||
| require_once (ABSPATH . 'wp-includes/pluggable.php'); | require_once (ABSPATH . 'wp-includes/pluggable.php'); | ||||
| public function shortcode_token($attrs) { | public function shortcode_token($attrs) { | ||||
| $token = get_query_var( 'token' ); | $token = get_query_var( 'token' ); | ||||
| if (trim($token) == "") | |||||
| return ""; | |||||
| $user = $this->getUserByToken($token); | $user = $this->getUserByToken($token); | ||||
| return "<h1 id='test'> ok ok " . $user[0]->display_name . " </h1>"; | |||||
| update_user_meta($user->ID, "hit100collected", "5"); | |||||
| $subject = file_get_contents(plugin_dir_path(__FILE__) . "/html/medal_received.html"); | |||||
| $subject = str_replace("#NAME#", $user->display_name, $subject); | |||||
| $result = str_replace("#SRC#", plugins_url('img/done.gif', __FILE__), $subject); | |||||
| return $result; | |||||
| } | } | ||||
| 'search_user' => plugins_url('img/loading_user.gif', __FILE__), | 'search_user' => plugins_url('img/loading_user.gif', __FILE__), | ||||
| 'anonymous' => !is_user_logged_in(), | 'anonymous' => !is_user_logged_in(), | ||||
| 'user' => $this->getUserByToken($this->token), | 'user' => $this->getUserByToken($this->token), | ||||
| 'imgurl' => plugins_url('img/box/', __FILE__), | |||||
| ) ); | ) ); | ||||
| } | } | ||||
| function ajax_list_users() | function ajax_list_users() | ||||
| { | { | ||||
| //check_ajax_referer('medal'); | |||||
| check_ajax_referer('medal'); | |||||
| $client = $_POST['client']; | $client = $_POST['client']; | ||||
| $name = $_POST['name']; | $name = $_POST['name']; | ||||
| public function ajax_search_users() | public function ajax_search_users() | ||||
| { | { | ||||
| //check_ajax_referer('medal'); | |||||
| check_ajax_referer('medal'); | |||||
| $pattern = $_GET['pattern']; | $pattern = $_GET['pattern']; | ||||
| $args= array( | $args= array( | ||||
| 'search' => "*$pattern*", // or login or nicename in this example | 'search' => "*$pattern*", // or login or nicename in this example | ||||
| 'search_fields' => array('display_name'), | 'search_fields' => array('display_name'), | ||||
| 'role__in' => array('subscriber') | |||||
| ); | ); | ||||
| $users = new \WP_User_Query($args); | $users = new \WP_User_Query($args); | ||||
| public function ajax_verify_user() | public function ajax_verify_user() | ||||
| { | { | ||||
| //check_ajax_referer('medal'); | |||||
| check_ajax_referer('medal'); | |||||
| $client = $_POST['client']; | $client = $_POST['client']; | ||||
| $verifycode = $_POST['verifycode']; | $verifycode = $_POST['verifycode']; | ||||
| wp_send_json($response); | wp_send_json($response); | ||||
| } | } | ||||
| $pickup = $this->get_pickup($user); | |||||
| $response = array( | $response = array( | ||||
| 'status' => 'success', | 'status' => 'success', | ||||
| 'userID' => $user->ID, | 'userID' => $user->ID, | ||||
| 'pass' => $this->verify_code($method, $verifycode, $user), | 'pass' => $this->verify_code($method, $verifycode, $user), | ||||
| 'addr' => $this->getUserPostalAddress($user), | |||||
| 'state' =>$this->getUserState($user), | |||||
| 'delivery'=> $this->get_delivery($this->getUserState($user)), | |||||
| 'pickup' => $pickup["name"], | |||||
| 'pp' => $pickup["phone"], | |||||
| 'ppwechat'=>$pickup["wechat"], | |||||
| 'loc' =>$pickup["loc"], | |||||
| 'time' =>$pickup["time"], | |||||
| 'step' => get_user_meta($client, "hit100collected", true), | |||||
| ); | ); | ||||
| wp_send_json($response); | |||||
| } | |||||
| private function get_delivery($state) | |||||
| { | |||||
| switch ($state){ | |||||
| case "na": | |||||
| return "na"; //not available | |||||
| case "NT": | |||||
| case "TAS": | |||||
| case "ACT": | |||||
| case "SA": | |||||
| return "dp"; //direct post | |||||
| case "NSW": | |||||
| case "VIC": | |||||
| case "QLD": | |||||
| case "WA": | |||||
| return "pp"; | |||||
| } | |||||
| } | |||||
| private function get_pickup($user) | |||||
| { | |||||
| $state = $this->getUserState($user); | |||||
| switch ($state){ | |||||
| case "na": | |||||
| case "NT": | |||||
| case "TAS": | |||||
| case "ACT": | |||||
| case "SA": | |||||
| return array( | |||||
| "name" => "n/a", | |||||
| "phone"=>"n/a", | |||||
| "wechat" =>"n/a", | |||||
| "loc" => "n/a", | |||||
| "time" => "n/a", | |||||
| ); | |||||
| case "NSW": | |||||
| return array( | |||||
| "name" => "孙鹏", | |||||
| "phone" => "0422896020", | |||||
| "wechat" => "lawipac", | |||||
| "loc" => "2020-12-13 15:30 - 18:00 : QVB Level 2 Coffee Shop, Sydney.\n" . | |||||
| "2020-12-15 17:00 - 18:00 : Strathfield Station Exit (Square). \n" . | |||||
| "2020-12-19 15:30 - 18:00 : Central Station Main Exit", | |||||
| "time" => "2020-12-13 ~ 19", | |||||
| ); | |||||
| case "VIC": | |||||
| return array( | |||||
| "name" => "杨欧", | |||||
| "phone" => "0450673987", | |||||
| "wechat" => "yangou627478", | |||||
| "loc" => "n/a", | |||||
| "time" => "n/a", | |||||
| ); | |||||
| case "QLD": | |||||
| return array( | |||||
| "name" => "于启华", | |||||
| "phone" => "0405928939", | |||||
| "wechat" => "cloudfisher321", | |||||
| "loc" => "n/a", | |||||
| "time" => "n/a", | |||||
| ); | |||||
| case "WA": | |||||
| return array( | |||||
| "name" => "赵健 (Perth-15-外语)", | |||||
| "phone" => "0452008130", | |||||
| "wechat" => "Shmilyxiaorenyu", | |||||
| "loc" => "n/a", | |||||
| "time" => "n/a", | |||||
| ); | |||||
| } | |||||
| } | |||||
| private function getUserPostalAddress($user) | |||||
| { | |||||
| $addr = get_user_meta($user->ID, 'postal-address', true); | |||||
| if ( $addr == "" ) | |||||
| return "No valid address provided"; | |||||
| else{ | |||||
| return str_replace("," , "\r\n", $addr); | |||||
| } | |||||
| } | |||||
| private function getUserState($user) | |||||
| { | |||||
| $valid = array("NSW", "VIC", "TAS", "NT", "WA", "SA", "ACT", "QLD"); | |||||
| $s = get_user_meta($user->ID, 'state', true); | |||||
| $s = strtoupper($s); | |||||
| if (in_array($s, $valid) ) | |||||
| { | |||||
| return $s; | |||||
| }else { | |||||
| return "na"; | |||||
| } | |||||
| wp_send_json($response); | |||||
| } | } | ||||
| private function verify_code($method, $verifycode, $user) | private function verify_code($method, $verifycode, $user) | ||||
| 'meta_key' => 'token', | 'meta_key' => 'token', | ||||
| 'meta_value' => "$token" | 'meta_value' => "$token" | ||||
| )); | )); | ||||
| return $user; | |||||
| return $user[0]; | |||||
| } | } | ||||
| public function test() | public function test() | ||||
| { | { | ||||
| $this->ajax_list_users(); | |||||
| //$this->ajax_list_users(); | |||||
| } | } | ||||
| public function house_keeping() | public function house_keeping() | ||||
| { | { | ||||
| return; | |||||
| $args= array( | $args= array( | ||||
| 'search' => "**", // or login or nicename in this example | 'search' => "**", // or login or nicename in this example | ||||
| 'search_fields' => array('display_name'), | 'search_fields' => array('display_name'), | ||||
| $count = $users->get_total(); | $count = $users->get_total(); | ||||
| foreach ( $users->results as $u ) { | foreach ( $users->results as $u ) { | ||||
| $card = 0; | |||||
| $post_addr = get_user_meta($u->ID, 'postal-address', true); | $post_addr = get_user_meta($u->ID, 'postal-address', true); | ||||
| $card = trim($post_addr) == ""? -1: 0; | $card = trim($post_addr) == ""? -1: 0; | ||||
| $medal = 1; | |||||
| $country = get_user_meta($u->ID, 'country', true); | $country = get_user_meta($u->ID, 'country', true); | ||||
| if ($country != "Australia") | |||||
| $medal = 0; | |||||
| $step = ($country != "Australia") ? 0: 2; | |||||
| $this->db->update('sp_medal_100', array( | |||||
| 'medal' => $medal, | |||||
| 'card' => $card, | |||||
| 'card_posted' =>0, | |||||
| 'card_delivered' => 0, | |||||
| 'medal_delivered' => 0, | |||||
| ),array( | |||||
| 'uid' => $u->ID, | |||||
| )); | |||||
| $state = get_user_meta($u->ID, 'state', true); | |||||
| $step = (strtoupper($state) == "NSW") ? 4: $step; | |||||
| update_user_meta($u->ID, "hit100collected", $step); | |||||
| } | } | ||||
| } | } | ||||