[OQRS] Now added option to search in all station locations with active OQRS
这个提交包含在:
		
							父节点
							
								
									e0a04cbe41
								
							
						
					
					
						当前提交
						0142209022
					
				
					共有  8 个文件被更改,包括 301 次插入 和 67 次删除
				
			
		|  | @ -255,7 +255,7 @@ class Options extends CI_Controller { | |||
| 		function oqrs() { | ||||
| 
 | ||||
| 			$data['page_title'] = "Cloudlog Options"; | ||||
| 			$data['sub_heading'] = "OQRS Global text"; | ||||
| 			$data['sub_heading'] = "OQRS Options"; | ||||
| 
 | ||||
| 			$this->load->view('interface_assets/header', $data); | ||||
| 			$this->load->view('options/oqrs'); | ||||
|  | @ -265,7 +265,7 @@ class Options extends CI_Controller { | |||
| 		function oqrs_save() { | ||||
| 
 | ||||
| 		$data['page_title'] = "Cloudlog Options"; | ||||
| 		$data['sub_heading'] = "OQRS Global text"; | ||||
| 		$data['sub_heading'] = "OQRS Options"; | ||||
| 
 | ||||
| 		$this->load->helper(array('form', 'url')); | ||||
| 
 | ||||
|  | @ -273,8 +273,10 @@ class Options extends CI_Controller { | |||
| 
 | ||||
| 		$global_oqrs_text = $this->optionslib->update('global_oqrs_text', $this->input->post('global_oqrs_text'), null); | ||||
| 
 | ||||
| 		$global_oqrs_text = $this->optionslib->update('groupedSearch', $this->input->post('groupedSearch'), null); | ||||
| 
 | ||||
| 		if($global_oqrs_text == TRUE) { | ||||
| 			$this->session->set_flashdata('success', 'OQRS Global text has been saved.'); | ||||
| 			$this->session->set_flashdata('success', 'OQRS options have been saved.'); | ||||
| 		} | ||||
| 
 | ||||
| 		redirect('/options/oqrs'); | ||||
|  |  | |||
|  | @ -22,7 +22,7 @@ class Oqrs extends CI_Controller { | |||
| 		$data['stations'] = $this->oqrs_model->get_oqrs_stations(); | ||||
| 		$data['page_title'] = "Log Search & OQRS"; | ||||
| 		$data['global_oqrs_text'] = $this->optionslib->get_option('global_oqrs_text'); | ||||
| 
 | ||||
| 		$data['groupedSearch'] = $this->optionslib->get_option('groupedSearch'); | ||||
| 
 | ||||
| 		$this->load->view('visitor/layout/header', $data); | ||||
| 		$this->load->view('oqrs/index'); | ||||
|  | @ -50,11 +50,19 @@ class Oqrs extends CI_Controller { | |||
| 		$this->load->view('oqrs/result', $data); | ||||
| 	} | ||||
| 
 | ||||
| 	public function get_qsos_grouped() { | ||||
| 		$this->load->model('oqrs_model'); | ||||
| 		$data['result'] = $this->oqrs_model->getQueryDataGrouped($this->input->post('callsign')); | ||||
| 		$data['callsign'] = $this->security->xss_clean($this->input->post('callsign')); | ||||
| 
 | ||||
| 		$this->load->view('oqrs/request_grouped', $data); | ||||
| 	} | ||||
| 
 | ||||
| 	public function not_in_log() { | ||||
| 		$data['page_title'] = "Log Search & OQRS"; | ||||
| 		 | ||||
| 		$this->load->model('bands'); | ||||
| 		$data['bands'] = $this->bands->get_worked_bands_oqrs($this->security->xss_clean($this->input->post('station_id'))); | ||||
| 		// $data['bands'] = $this->bands->get_worked_bands_oqrs($this->security->xss_clean($this->input->post('station_id')));
 | ||||
| 
 | ||||
| 		$this->load->view('oqrs/notinlogform', $data); | ||||
| 	} | ||||
|  | @ -103,8 +111,15 @@ class Oqrs extends CI_Controller { | |||
| 	public function save_oqrs_request() { | ||||
| 		$postdata = $this->input->post(); | ||||
| 		$this->load->model('oqrs_model'); | ||||
| 		$this->oqrs_model->save_oqrs_request($postdata); | ||||
| 		$this->alert_oqrs_request($postdata); | ||||
| 		$station_ids = $this->oqrs_model->save_oqrs_request($postdata); | ||||
| 		$this->alert_oqrs_request($postdata, $station_ids); | ||||
| 	} | ||||
| 
 | ||||
| 	public function save_oqrs_request_grouped() { | ||||
| 		$postdata = $this->input->post(); | ||||
| 		$this->load->model('oqrs_model'); | ||||
| 		$station_ids = $this->oqrs_model->save_oqrs_request_grouped($postdata); | ||||
| 		$this->alert_oqrs_request($postdata, $station_ids); | ||||
| 	} | ||||
| 
 | ||||
| 	public function delete_oqrs_line() { | ||||
|  | @ -134,14 +149,15 @@ class Oqrs extends CI_Controller { | |||
| 		$this->load->view('oqrs/qsolist', $data); | ||||
| 	} | ||||
| 
 | ||||
| 	public function alert_oqrs_request($postdata) { | ||||
| 	public function alert_oqrs_request($postdata, $station_ids) { | ||||
| 		foreach ($station_ids as $id) { | ||||
| 			$this->load->model('user_model'); | ||||
| 			 | ||||
| 		$email = $this->user_model->get_email_address($this->session->userdata('user_id')); | ||||
| 			$email = $this->user_model->get_email_address($id); | ||||
| 	 | ||||
| 			$this->load->model('oqrs_model'); | ||||
| 						 | ||||
| 		$sendEmail = $this->oqrs_model->getOqrsEmailSetting($this->security->xss_clean($this->input->post('station_id'))); | ||||
| 			$sendEmail = $this->oqrs_model->getOqrsEmailSetting($id); | ||||
| 	 | ||||
| 			if($email != "" && $sendEmail == "1") { | ||||
| 							 | ||||
|  | @ -180,6 +196,7 @@ class Oqrs extends CI_Controller { | |||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	public function mark_oqrs_line_as_done() { | ||||
| 		$this->load->model('oqrs_model'); | ||||
|  |  | |||
|  | @ -42,6 +42,18 @@ class Oqrs_model extends CI_Model { | |||
| 		return $result; | ||||
| 	} | ||||
| 
 | ||||
| 	 | ||||
|     function get_qsos_grouped($callsign){ | ||||
| 
 | ||||
| 		// Populating array with worked band/mode combinations
 | ||||
| 		$worked = $this->getQueryData($station_id, $callsign); | ||||
| 
 | ||||
| 		$result['qsocount'] = count($worked); | ||||
| 		$result['qsoarray'] = $resultArray; | ||||
| 
 | ||||
| 		return $result; | ||||
| 	} | ||||
| 
 | ||||
| 	/* | ||||
| 	 * Builds query depending on what we are searching for | ||||
| 	 */ | ||||
|  | @ -57,6 +69,26 @@ class Oqrs_model extends CI_Model { | |||
|         return $query->result(); | ||||
| 	} | ||||
| 
 | ||||
| 	/* | ||||
| 	 * Builds query depending on what we are searching for | ||||
| 	 */ | ||||
| 	function getQueryDataGrouped($callsign) { | ||||
|         $callsign = $this->security->xss_clean($callsign); | ||||
|         $sql = 'select lower(col_mode) col_mode, coalesce(col_submode, "") col_submode, col_band, station_callsign, station_profile_name, l.station_id from ' . $this->config->item('table_name') . ' as l join station_profile on l.station_id = station_profile.station_id where station_profile.oqrs = "1" and l.col_call ="' . $callsign . '" and l.col_prop_mode != "SAT"'; | ||||
| 
 | ||||
| 		$sql .= ' union all select lower(col_mode) col_mode, coalesce(col_submode, "") col_submode, "SAT" col_band, station_callsign, station_profile_name, l.station_id from ' .  | ||||
| 			$this->config->item('table_name') . ' l' .  | ||||
| 			' join station_profile on l.station_id = station_profile.station_id where station_profile.oqrs = "1" and col_call ="' . $callsign . '" and col_prop_mode = "SAT"'; | ||||
| 
 | ||||
|         $query = $this->db->query($sql); | ||||
| 
 | ||||
| 		if ($query) { | ||||
| 			return $query->result(); | ||||
| 		} | ||||
| 
 | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	/* | ||||
| 	 * Get's the worked modes from the log | ||||
| 	 */ | ||||
|  | @ -92,6 +124,7 @@ class Oqrs_model extends CI_Model { | |||
| 	} | ||||
| 
 | ||||
| 	function save_oqrs_request($postdata) { | ||||
| 		$station_ids = array(); | ||||
| 		$qsos = $postdata['qsos']; | ||||
| 		foreach($qsos as $qso) { | ||||
| 			$data = array( | ||||
|  | @ -115,9 +148,47 @@ class Oqrs_model extends CI_Model { | |||
| 			} | ||||
| 	 | ||||
| 			$this->db->insert('oqrs', $data); | ||||
| 			if(!in_array(xss_clean($postdata['station_id']), $station_ids)){ | ||||
| 				array_push($station_ids, xss_clean($postdata['station_id'])); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		return $station_ids; | ||||
| 	} | ||||
| 
 | ||||
| 	function save_oqrs_request_grouped($postdata) { | ||||
| 		$station_ids = array(); | ||||
| 		$qsos = $postdata['qsos']; | ||||
| 		foreach($qsos as $qso) { | ||||
| 			$data = array( | ||||
| 				'date' 				=> xss_clean($qso[0]), | ||||
| 				'time'	 			=> xss_clean($qso[1]), | ||||
| 				'band' 				=> xss_clean($qso[2]), | ||||
| 				'mode' 				=> xss_clean($qso[3]), | ||||
| 				'requestcallsign' 	=> xss_clean($postdata['callsign']), | ||||
| 				'station_id' 		=> xss_clean($qso[4]), | ||||
| 				'note' 				=> xss_clean($postdata['message']), | ||||
| 				'email' 			=> xss_clean($postdata['email']), | ||||
| 				'qslroute' 			=> xss_clean($postdata['qslroute']), | ||||
| 				'status' 			=> '0', | ||||
| 			); | ||||
| 
 | ||||
| 			$qsoid = $this->check_oqrs($data); | ||||
| 
 | ||||
| 			if ($qsoid > 0) { | ||||
| 				$data['status'] = '2'; | ||||
| 				$data['qsoid'] = $qsoid; | ||||
| 			} | ||||
| 	 | ||||
| 			$this->db->insert('oqrs', $data); | ||||
| 			 | ||||
| 			if(!in_array(xss_clean($qso[4]), $station_ids)){ | ||||
| 				array_push($station_ids, xss_clean($qso[4])); | ||||
| 			} | ||||
| 		} | ||||
| 		return $station_ids; | ||||
| 	} | ||||
| 
 | ||||
| 	function delete_oqrs_line($id) { | ||||
|         $sql = 'delete from oqrs where id =' . xss_clean($id); | ||||
| 
 | ||||
|  | @ -178,7 +249,6 @@ class Oqrs_model extends CI_Model { | |||
| 
 | ||||
| 	// Set Paper to requested
 | ||||
| 	function paperqsl_requested($qso_id, $method) { | ||||
| 
 | ||||
| 		$data = array( | ||||
| 				'COL_QSLSDATE' => date('Y-m-d H:i:s'), | ||||
| 				'COL_QSL_SENT' => 'R', | ||||
|  |  | |||
|  | @ -76,8 +76,9 @@ class User_Model extends CI_Model { | |||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	function get_email_address($userid) { | ||||
| 		$this->db->where('user_id', $userid); | ||||
| 	function get_email_address($station_id) { | ||||
| 		$this->db->where('station_id', $station_id); | ||||
| 		$this->db->join('station_profile', 'station_profile.user_id = '.$this->config->item('auth_table').'.user_id'); | ||||
| 		$query = $this->db->get($this->config->item('auth_table')); | ||||
| 		 | ||||
| 		$ret = $query->row(); | ||||
|  |  | |||
|  | @ -35,9 +35,18 @@ | |||
|                     <?php echo form_open('options/oqrs_save'); ?>
 | ||||
| 
 | ||||
|                         <div class="form-group"> | ||||
|                             <label for="globalSearch">OQRS Global text</label> | ||||
|                             <p>This text is an optional text that can be displayed on top of the OQRS page.</p> | ||||
|                             <label for="globalSearch">Global text</label> | ||||
|                             <input type="text" name="global_oqrs_text" class="form-control" id="global_oqrs_text" aria-describedby="global_oqrs_text" value="<?php echo $this->optionslib->get_option('global_oqrs_text'); ?>"> | ||||
|                             <small id="global_oqrs_text_help" class="form-text text-muted">This text is an optional text that can be displayed on top of the OQRS page.</small> | ||||
|                         </div> | ||||
| 
 | ||||
|                         <div class="form-group"> | ||||
|                             <label for="groupedSearch">Grouped search</label> | ||||
|                             <select name="groupedSearch" class="form-control" id="groupedSearch"> | ||||
|                                 <option value="off" <?php if($this->optionslib->get_option('groupedSearch') == "off") { echo "selected=\"selected\""; } ?>>Off</option>
 | ||||
|                                 <option value="on" <?php if($this->optionslib->get_option('groupedSearch') == "on") { echo "selected=\"selected\""; } ?>>On</option>
 | ||||
|                             </select> | ||||
|                             <small id="groupedSearchHelp" class="form-text text-muted">When this is on, all station locations with OQRS active, will be searched at once.</small> | ||||
|                         </div> | ||||
| 
 | ||||
|                         <!-- Save the Form --> | ||||
|  |  | |||
|  | @ -14,8 +14,15 @@ | |||
| 		<?php | ||||
| 		if ($global_oqrs_text) { | ||||
| 			echo $global_oqrs_text; | ||||
| 			echo '<br />'; | ||||
| 			echo '<br /><br />'; | ||||
| 		} | ||||
| 		if ($groupedSearch == 'on') { | ||||
| 			echo 'This search will search in all station locations where OQRS is active.<br /><br /><form class="form-inline" onsubmit="return false;"><label class="my-1 mr-2" for="oqrssearch">Enter your callsign: </label> | ||||
| 			<input class="form-control mr-sm-2" id="oqrssearch" type="search" name="callsign" placeholder="Search Callsign" aria-label="Search" required="required"> | ||||
| 			<button onclick="searchOqrsGrouped();" class="btn btn-sm btn-primary" id="stationbuttonsubmit" type="button"><i class="fas fa-search"></i> Search</button> | ||||
| 			</form>'; | ||||
| 			echo '<div class="searchinfo"></div>'; | ||||
| 			} else { | ||||
| 		  echo '<div class="resulttable">'; | ||||
| 		  if ($stations->result() != NULL) { ?>
 | ||||
| 
 | ||||
|  | @ -31,11 +38,13 @@ | |||
| 
 | ||||
| 			<div class="stationinfo"></div> | ||||
| 			<div class="searchinfo"></div> | ||||
| 			<?php  | ||||
| 		} | ||||
| 
 | ||||
| 			<?php } | ||||
| 		else { | ||||
| 			echo 'No stations found that are using Cloudlog OQRS.'; | ||||
| 		} | ||||
| 	} | ||||
| 		?>
 | ||||
| 
 | ||||
|         </div> | ||||
|  |  | |||
|  | @ -0,0 +1,68 @@ | |||
| <br /> | ||||
| <?php if ($result) { ?>
 | ||||
| The following QSO(s) were found. Please fill out the date and time and submit your request. | ||||
| <table style="width:100%" class="result-table table-sm table table-bordered table-hover table-striped table-condensed text-center"> | ||||
|     <thead> | ||||
|         <tr> | ||||
|             <th>#</th>
 | ||||
|             <th>Date</th> | ||||
|             <th>Time (UTC)</th> | ||||
|             <th class="center"><span class="larger_font band">Band</th> | ||||
|             <th class="center">Mode</th> | ||||
|             <th class="center">Callsign</th> | ||||
|             <th class="center">Name</th> | ||||
|         </tr> | ||||
|     </thead> | ||||
|     <tbody> | ||||
|         <?php | ||||
|         $i = 1; | ||||
|             foreach ($result as $qso) { | ||||
|                 echo '<tr stationid="'. $qso->station_id.'">'; | ||||
|                     echo '<td>'. $i++ .'</td>'; | ||||
|                     echo '<td><input class="form-control" type="date" name="date" value="" id="date" placeholder="YYYY-MM-DD"></td>'; | ||||
|                     echo '<td><input class="form-control qsotime" type="text" name="time" value="" id="time" maxlength="5" placeholder="HH:MM"></td>'; | ||||
|                     echo '<td id="band">'. $qso->col_band .'</td>'; | ||||
|                     echo '<td id="mode">'; echo $qso->col_submode == null ? strtoupper($qso->col_mode) : strtoupper($qso->col_submode);  echo '</td>';       | ||||
|                     echo '<td>'. $qso->station_callsign .'</td>'; | ||||
|                     echo '<td>'. $qso->station_profile_name .'</td>'; | ||||
|                 echo '</tr>'; | ||||
|             } | ||||
|         ?>
 | ||||
|     </tbody> | ||||
| </table> | ||||
| <br /> | ||||
| 
 | ||||
| <form> | ||||
|     <div class="form-check form-check-inline"> | ||||
|         <label class="form-check-label">QSL Route</label> | ||||
|     </div> | ||||
| 
 | ||||
|     <div class="form-check form-check-inline"> | ||||
|         <input class="form-check-input" type="radio" name="qslroute" id="bureau" value="B" checked/> | ||||
|         <label class="form-check-label" for="bureau">Bureau</label> | ||||
|     </div> | ||||
| 
 | ||||
|     <div class="form-check form-check-inline"> | ||||
|         <input class="form-check-input" type="radio" name="qslroute" id="direct" value="D" /> | ||||
|         <label class="form-check-label" for="direct">Direct (write address in message below)</label> | ||||
|     </div> | ||||
|     <br /><br /> | ||||
|     <div class="form-group"> | ||||
|         <label for="message">Message</label> | ||||
|         <textarea name="message" class="form-control" id="messageInput" rows="3" aria-describedby="messageHelp"></textarea> | ||||
|         <small id="messageHelp" class="form-text text-muted">Any extra information we need to know about?</small> | ||||
|     </div> | ||||
| 
 | ||||
|     <div class="form-group"> | ||||
|         <label for="emailInput">E-mail</label> | ||||
|         <input type="text" class="form-control" name="mode" id="emailInput" aria-describedby="emailInputHelp" required> | ||||
|         <small id="emailInputHelp" class="form-text text-muted">Your e-mail address where we can contact you</small> | ||||
|     </div> | ||||
| 
 | ||||
|     <button type="button" onclick="submitOqrsRequestGrouped(this.form);" class="btn btn-sm btn-primary"><i | ||||
|             class="fas fa-plus-square"></i> Submit request</button> | ||||
| </form> | ||||
| <?php } else { | ||||
| 	echo 'No QSOs found in the log.<br />'; | ||||
| } | ||||
| 	?>
 | ||||
|  | @ -41,6 +41,18 @@ function searchOqrs() { | |||
|     }); | ||||
| } | ||||
| 
 | ||||
| function searchOqrsGrouped() { | ||||
|     $(".searchinfo").empty(); | ||||
|     $.ajax({ | ||||
|         url: base_url+'index.php/oqrs/get_qsos_grouped', | ||||
|         type: 'post', | ||||
|         data: {'callsign': $("#oqrssearch").val().toUpperCase()}, | ||||
|         success: function (data) { | ||||
|             $(".searchinfo").append(data); | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| 
 | ||||
| function notInLog() { | ||||
|     $.ajax({ | ||||
|         url: base_url + 'index.php/oqrs/not_in_log', | ||||
|  | @ -206,6 +218,52 @@ function submitOqrsRequest() { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| function submitOqrsRequestGrouped() { | ||||
|     $(".alertinfo").remove(); | ||||
|     if ($("#emailInput").val() == '') { | ||||
|         $(".searchinfo").prepend('<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You need to fill out an email address!</div></div>'); | ||||
|     } else { | ||||
|         const qsos = []; | ||||
|         $(".result-table tbody tr").each(function(i) { | ||||
|             var data = []; | ||||
|             var stationid = this.getAttribute('stationid');; | ||||
|             var datecell = $("#date", this).val(); | ||||
|             var timecell = $("#time", this).val(); | ||||
|             var bandcell = $("#band", this).text(); | ||||
|             var modecell = $("#mode", this).text(); | ||||
|             if (datecell != "" && timecell != "") { | ||||
|                 data.push(datecell); | ||||
|                 data.push(timecell); | ||||
|                 data.push(bandcell); | ||||
|                 data.push(modecell); | ||||
|                 data.push(stationid); | ||||
|                 qsos.push(data); | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         if (qsos.length === 0) { | ||||
|             $(".searchinfo").prepend('<div class="alertinfo"><br /><div class="alert alert-warning"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>You need to fill the QSO information before submitting a request!</div></div>'); | ||||
|         } else { | ||||
|             $.ajax({ | ||||
|                 url: base_url+'index.php/oqrs/save_oqrs_request_grouped', | ||||
|                 type: 'post', | ||||
|                 data: { | ||||
|                         'callsign': $("#oqrssearch").val().toUpperCase(), | ||||
|                         'email': $("#emailInput").val(), | ||||
|                         'message': $("#messageInput").val(), | ||||
|                         'qsos': qsos, | ||||
|                         'qslroute': $('input[name="qslroute"]:checked').val() | ||||
|                 }, | ||||
|                 success: function (data) { | ||||
|                     $(".stationinfo").empty(); | ||||
|                     $(".searchinfo").empty(); | ||||
|                     $(".searchinfo").append('<br /><div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Your QSL request has been saved!</div>'); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| function searchLog(callsign) { | ||||
|     $.ajax({ | ||||
|         url: base_url + 'index.php/oqrs/search_log', | ||||
|  |  | |||
		正在加载…
	
		在新工单中引用