office = $office; $this->job_table = $job_table; add_shortcode( 'bts_jobv1_item', array($this, 'bts_jobv1_item')); add_action('wp_ajax_list_jobv1', array($this,'list_job' )); } public function bts_jobv1_item($attr){ $html =$this->template('jobv1_item', 'jobv1.html'); //$html = str_replace('[bts-tos-options]', $this->bts_tos_options([]), $html); $html = do_shortcode($html); return $html; } //generate template based on html file private function template($id, $file) { $text = ''; return $text; } //ajax browse job with different filters function list_job(){ global $wpdb; check_ajax_referer('acaresydney'); $start = $_POST['start'] . " 00:00:00"; $finish = $_POST['finish']. " 23:59:59"; $response = array( 'status'=>'success', 'jobs' => [], 'job_maps' =>[], ); $sql = "SELECT * FROM $this->job_table WHERE start>='%s' and start <='%s' order by start ASC ,staff ASC"; //$sql = "SELECT * FROM $this->job_table order by start ASC ,staff ASC"; $query = $wpdb->prepare ($sql, array($start, $finish)); $response['sql'] = $query; $jobs = $wpdb->get_results($query); if (! empty($jobs)){ $response['status'] = 'success'; foreach( $jobs as $s){ $data = array( 'id' => $s->id, 'tos' => $s->tos, 'start'=> $s->start, 'finish'=> $s->finish, 'rate'=> $s->rate, 'staff'=> $s->staff, 'client'=> $s->client, 'ack' => $s->ack, 'rating' =>$s->rating, ); $response['jobs'][] = $data; $response['jobs_maps'][$s->id] = $data; } } wp_send_json($response); } }