Tweaking of logging form. Added some logic in javascript, and started on a function for saving the qso in the controller.
这个提交包含在:
		
							父节点
							
								
									e83e7340f5
								
							
						
					
					
						当前提交
						e557d92c47
					
				
					共有  3 个文件被更改,包括 250 次插入 和 53 次删除
				
			
		|  | @ -99,6 +99,48 @@ class QSO extends CI_Controller { | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	/* | ||||||
|  | 	 * This is used for contest-logging and the ajax-call | ||||||
|  | 	 */ | ||||||
|  | 	public function saveqso() { | ||||||
|  |         $this->load->model('logbook_model'); | ||||||
|  |         // Add QSO
 | ||||||
|  |         // $this->logbook_model->add();
 | ||||||
|  |         //change to create_qso function as add and create_qso duplicate functionality
 | ||||||
|  |         $this->logbook_model->create_qso(); | ||||||
|  | 
 | ||||||
|  |         // Store Basic QSO Info for reuse
 | ||||||
|  |         // Put data in an array first, then call set_userdata once.
 | ||||||
|  |         // This solves the problem of CI dumping out the session
 | ||||||
|  |         // cookie each time set_userdata is called.
 | ||||||
|  |         // For more info, see http://bizhole.com/codeigniter-nginx-error-502-bad-gateway/
 | ||||||
|  |         $qso_data = array( | ||||||
|  |             'start_date' => $this->input->post('start_date'), | ||||||
|  |             'start_time' => $this->input->post('start_time'), | ||||||
|  |             'time_stamp' => time(), | ||||||
|  |             'band' => $this->input->post('band'), | ||||||
|  |             'freq' => $this->input->post('freq_display'), | ||||||
|  |             'freq_rx' => $this->input->post('freq_display_rx'), | ||||||
|  |             'mode' => $this->input->post('mode'), | ||||||
|  |             'sat_name' => $this->input->post('sat_name'), | ||||||
|  |             'sat_mode' => $this->input->post('sat_mode'), | ||||||
|  |             'prop_mode' => $this->input->post('prop_mode'), | ||||||
|  |             'radio' => $this->input->post('radio'), | ||||||
|  |             'station_profile_id' => $this->input->post('station_profile'), | ||||||
|  |             'transmit_power' => $this->input->post('transmit_power') | ||||||
|  |         ); | ||||||
|  | 
 | ||||||
|  |         setcookie("radio", $qso_data['radio'], time()+3600*24*99); | ||||||
|  |         setcookie("station_profile_id", $qso_data['station_profile_id'], time()+3600*24*99); | ||||||
|  | 
 | ||||||
|  |         $this->session->set_userdata($qso_data); | ||||||
|  | 
 | ||||||
|  |         // If SAT name is set make it session set to sat
 | ||||||
|  |         if($this->input->post('sat_name')) { | ||||||
|  |             $this->session->set_userdata('prop_mode', 'SAT'); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 	 | ||||||
| 	function edit() { | 	function edit() { | ||||||
| 	 | 	 | ||||||
| 		$this->load->model('logbook_model'); | 		$this->load->model('logbook_model'); | ||||||
|  |  | ||||||
|  | @ -4,31 +4,40 @@ | ||||||
| 
 | 
 | ||||||
|         <div class="col-sm-12 col-md-12"> |         <div class="col-sm-12 col-md-12"> | ||||||
|             <div class="card"> |             <div class="card"> | ||||||
| 
 |                 <div class="card-header"><h5 class="card-title">Logging form</h5></div> | ||||||
|  |                 <div class="card-body"> | ||||||
|                     <form id="qso_input" name="qsos"> |                     <form id="qso_input" name="qsos"> | ||||||
| 
 | 
 | ||||||
|                                 <!-- HTML for Date/Time --> |                             <div class="form-group row"> | ||||||
|  | 
 | ||||||
|  |                                     <label class="col-md-2 control-label" for="radio">Exchange type</label> | ||||||
|  |                                     <div class="col-md-9"> | ||||||
|  |                                         <div class="form-check form-check-inline"> | ||||||
|  |                                             <input class="form-check-input" type="radio" name="exchangeradio" id="serial" value="serial" checked> | ||||||
|  |                                             <label class="form-check-label" for="serial"> | ||||||
|  |                                                 Serial | ||||||
|  |                                             </label> | ||||||
|  |                                         </div> | ||||||
|  |                                         <div class="form-check form-check-inline"> | ||||||
|  |                                             <input class="form-check-input" type="radio" name="exchangeradio" id="other" value="other"> | ||||||
|  |                                             <label class="form-check-label" for="other"> | ||||||
|  |                                                 Other | ||||||
|  |                                             </label> | ||||||
|  |                                         </div> | ||||||
|  |                                     </div> | ||||||
|  |                                 </div> | ||||||
|  | 
 | ||||||
|                                 <div class="form-row"> |                                 <div class="form-row"> | ||||||
|                                     <div class="form-group col-md-3"> |                                     <div class="form-group col-md-2"> | ||||||
|                                         <label for="start_date">Date</label> |                                         <label for="start_date">Date</label> | ||||||
|                                         <input type="text" class="form-control form-control-sm input_date" name="start_date" id="start_date" value="<?php if (($this->session->userdata('start_date') != NULL && ((time() - $this->session->userdata('time_stamp')) < 24 * 60 * 60))) { echo $this->session->userdata('start_date'); } else { echo date('d-m-Y');}?>"> |                                         <input type="text" class="form-control form-control-sm input_date" name="start_date" id="start_date" value="<?php if (($this->session->userdata('start_date') != NULL && ((time() - $this->session->userdata('time_stamp')) < 24 * 60 * 60))) { echo $this->session->userdata('start_date'); } else { echo date('d-m-Y');}?>"> | ||||||
|                                     </div> |                                     </div> | ||||||
| 
 | 
 | ||||||
|                                     <div class="form-group col-md-2"> |                                     <div class="form-group col-md-1"> | ||||||
|                                         <label for="start_time">Time</label> |                                         <label for="start_time">Time</label> | ||||||
|                                         <input type="text" class="form-control form-control-sm input_time" name="start_time" id="start_time" value="<?php if (($this->session->userdata('start_time') != NULL && ((time() - $this->session->userdata('time_stamp')) < 24 * 60 * 60))) { echo $this->session->userdata('start_time'); } else {echo date('H:i'); } ?>" size="7"> |                                         <input type="text" class="form-control form-control-sm input_time" name="start_time" id="start_time" value="<?php if (($this->session->userdata('start_time') != NULL && ((time() - $this->session->userdata('time_stamp')) < 24 * 60 * 60))) { echo $this->session->userdata('start_time'); } else {echo date('H:i'); } ?>" size="7"> | ||||||
|                                     </div> |                                     </div> | ||||||
| 
 | 
 | ||||||
|                                 </div> |  | ||||||
| 
 |  | ||||||
|                                 <div class="form-row"> |  | ||||||
| 
 |  | ||||||
|                                     <div class="form-group col-md-4"> |  | ||||||
|                                         <label for="callsign">Callsign</label> |  | ||||||
|                                         <input type="text" class="form-control form-control-sm" id="callsign" name="callsign" required> |  | ||||||
|                                         <small id="callsign_info" class="badge badge-secondary"></small> <small id="lotw_info" class="badge badge-light"></small> |  | ||||||
|                                     </div> |  | ||||||
| 
 |  | ||||||
|                                     <div class="form-group col-md-2"> |                                     <div class="form-group col-md-2"> | ||||||
|                                         <label for="mode">Mode</label> |                                         <label for="mode">Mode</label> | ||||||
|                                         <select id="mode" class="form-control mode form-control-sm" name="mode"> |                                         <select id="mode" class="form-control mode form-control-sm" name="mode"> | ||||||
|  | @ -81,76 +90,87 @@ | ||||||
|                                         </select> |                                         </select> | ||||||
|                                     </div> |                                     </div> | ||||||
| 
 | 
 | ||||||
|                                     <div class="form-group col-md-2"> |                                 </div> | ||||||
|  | 
 | ||||||
|  |                                 <div class="form-row"> | ||||||
|  | 
 | ||||||
|  |                                     <div class="form-group col-md-3"> | ||||||
|  |                                         <label for="callsign">Callsign</label> | ||||||
|  |                                         <input type="text" class="form-control form-control-sm" id="callsign" name="callsign" required> | ||||||
|  |                                         <small id="callsign_info" class="badge badge-secondary"></small> <small id="lotw_info" class="badge badge-light"></small> | ||||||
|  |                                     </div> | ||||||
|  | 
 | ||||||
|  |                                     <div class="form-group col-md-1"> | ||||||
|                                         <label for="rst_sent">RST (S)</label> |                                         <label for="rst_sent">RST (S)</label> | ||||||
|                                         <input type="text" class="form-control form-control-sm" name="rst_sent" id="rst_sent" value="59"> |                                         <input type="text" class="form-control form-control-sm" name="rst_sent" id="rst_sent" value="59"> | ||||||
|                                     </div> |                                     </div> | ||||||
| 
 | 
 | ||||||
|                                     <div class="form-group col-md-2"> |                                     <div class="form-group col-md-1"> | ||||||
|  |                                         <label for="exch_sent">Exch (S)</label> | ||||||
|  |                                         <input type="text" class="form-control form-control-sm" name="exch_sent" id="exch_sent" value=""> | ||||||
|  |                                     </div> | ||||||
|  | 
 | ||||||
|  |                                     <div class="form-group col-md-1"> | ||||||
|                                         <label for="rst_recv">RST (R)</label> |                                         <label for="rst_recv">RST (R)</label> | ||||||
|                                         <input type="text" class="form-control form-control-sm" name="rst_recv" id="rst_recv" value="59"> |                                         <input type="text" class="form-control form-control-sm" name="rst_recv" id="rst_recv" value="59"> | ||||||
|                                     </div> |                                     </div> | ||||||
|  | 
 | ||||||
|  |                                     <div class="form-group col-md-1"> | ||||||
|  |                                         <label for="exch_recv">Exch (R)</label> | ||||||
|  |                                         <input type="text" class="form-control form-control-sm" name="exch_recv" id="exch_recv" value=""> | ||||||
|                                     </div> |                                     </div> | ||||||
| 
 | 
 | ||||||
|                                 <!-- Signal Report Information --> |                                 </div> | ||||||
|                                 <div class="form-row"> |                                 <div class="form-row"> | ||||||
| 
 |                                         <div class="form-group col-md-5"> | ||||||
|                                 </div> |                                             <label for="name">Name</label> | ||||||
|                                     <div class="form-group row"> |  | ||||||
|                                         <label for="name" class="col-sm-3 col-form-label">Name</label> |  | ||||||
|                                         <div class="col-sm-9"> |  | ||||||
|                                             <input type="text" class="form-control form-control-sm" name="name" id="name" value=""> |                                             <input type="text" class="form-control form-control-sm" name="name" id="name" value=""> | ||||||
|                                         </div> |                                         </div> | ||||||
|                                     </div> |  | ||||||
| 
 | 
 | ||||||
|                                     <div class="form-group row"> |                                         <div class="form-group col-md-5"> | ||||||
|                                         <label for="comment" class="col-sm-3 col-form-label">Comment</label> |                                             <label for="comment">Comment</label> | ||||||
|                                         <div class="col-sm-9"> |  | ||||||
|                                             <input type="text" class="form-control form-control-sm" name="comment" id="comment" value=""> |                                             <input type="text" class="form-control form-control-sm" name="comment" id="comment" value=""> | ||||||
|                                         </div> |                                         </div> | ||||||
|                                 </div> |                                 </div> | ||||||
| 
 |                             <button type="reset" class="btn btn-sm btn-warning" onclick="reset_log_fields()">Reset</button> | ||||||
| 
 |                             <button type="button" class="btn btn-sm btn-primary" onclick="logQso();"><i class="fas fa-save"></i> Log QSO</button> | ||||||
|  |                             </div> | ||||||
| 
 | 
 | ||||||
|                         </div> |                         </div> | ||||||
| 
 | 
 | ||||||
|                         <div class="info"> |  | ||||||
|                             <input size="20" id="country" type="hidden" name="country" value="" /> |  | ||||||
|                         </div> |  | ||||||
| <br/> |  | ||||||
|                         <button type="reset" class="btn btn-sm btn-light" onclick="reset_fields()">Reset</button> |  | ||||||
|                         <button type="submit" class="btn btn-sm btn-primary"><i class="fas fa-save"></i> Log QSO</button> |  | ||||||
|                         </div> |                         </div> | ||||||
|                     </form> |                     </form> | ||||||
|             </div> |             </div> | ||||||
| 
 | 
 | ||||||
| <br/> |             <br/> | ||||||
|             <div class="card callsign-suggest"> |             <div class="card callsign-suggest"> | ||||||
|                 <div class="card-header"><h4 class="card-title">Callsign Suggestions</h4></div> |                 <div class="card-header"><h5 class="card-title">Callsign Suggestions</h5></div> | ||||||
| 
 | 
 | ||||||
|                 <div class="card-body callsign-suggestions"></div> |                 <div class="card-body callsign-suggestions"></div> | ||||||
|             </div> |             </div> | ||||||
| 
 | 
 | ||||||
|             <div class="card previous-qsos"> |             <div class="card log"> | ||||||
|                 <div class="card-header"><h4 class="card-title">Logbook (for this session)</h4></div> |                 <div class="card-header"><h5 class="card-title">Logbook (for this logging session)</h5></div> | ||||||
| 
 |  | ||||||
|                 <div id="partial_view"></div> |  | ||||||
| 
 | 
 | ||||||
|                 <div id="qso-last-table"> |                 <div id="qso-last-table"> | ||||||
| 
 | 
 | ||||||
|                     <div class="table-responsive"> |                     <div class="table-responsive"> | ||||||
|                         <table class="table table-sm"> |                         <table class="table-sm table qsotable table-bordered table-hover table-striped table-condensed text-center"> | ||||||
|  |                             <thead> | ||||||
|                             <tr class="log_title titles"> |                             <tr class="log_title titles"> | ||||||
|                                 <td>Date/Time</td> |                                 <th>Date/Time</th> | ||||||
|                                 <td>Call</td> |                                 <th>Call</th> | ||||||
|                                 <td>Mode</td> |                                 <th>Band</th> | ||||||
|                                 <td>RST s</td> |                                 <th>Mode</th> | ||||||
|                                 <td>RST r</td> |                                 <th>RST (S)</th> | ||||||
|                                 <td>Exch S</td> |                                 <th>RST (R)</th> | ||||||
|                                 <td>Exch R</td> |                                 <th>Exch S</th> | ||||||
|                                 <td>Band</td> |                                 <th>Exch R</th> | ||||||
|                             </tr> |                             </tr> | ||||||
|  |                             </thead> | ||||||
|  |                             <tbody> | ||||||
| 
 | 
 | ||||||
|  |                             </tbody> | ||||||
|                         </table> |                         </table> | ||||||
|                     </div> |                     </div> | ||||||
|                 </div> |                 </div> | ||||||
|  | @ -158,6 +178,7 @@ | ||||||
|         </div> |         </div> | ||||||
|     </div> |     </div> | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| </div> | </div> | ||||||
| 
 | 
 | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
|  | @ -2436,5 +2436,139 @@ function deleteQsl(id) { | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| </script> | </script> | ||||||
|  | <?php if ($this->uri->segment(1) == "contesting") { ?>
 | ||||||
|  |     <script> | ||||||
|  | 
 | ||||||
|  |         // We don't want spaces to be written in callsign
 | ||||||
|  |         $(function() { | ||||||
|  |             $('#callsign').on('keypress', function(e) { | ||||||
|  |                 if (e.which == 32){ | ||||||
|  |                     //console.log('Space Detected');
 | ||||||
|  |                     return false; | ||||||
|  |                 } | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|  |         // We don't want spaces to be written in exchange
 | ||||||
|  |         $(function() { | ||||||
|  |             $('#exch_recv').on('keypress', function(e) { | ||||||
|  |                 if (e.which == 32){ | ||||||
|  |                     //console.log('Space Detected');
 | ||||||
|  |                     return false; | ||||||
|  |                 } | ||||||
|  |             }); | ||||||
|  |         }); | ||||||
|  | 
 | ||||||
|  |         // Here we capture keystrokes fo execute functions
 | ||||||
|  |         document.onkeyup = function(e) { | ||||||
|  |         // ALT-W wipe
 | ||||||
|  |         if (e.altKey && e.which == 87) { | ||||||
|  |             reset_log_fields(); | ||||||
|  |         } else if ((e.keyCode == 10 || e.keyCode == 13) && (e.ctrlKey || e.metaKey)) { | ||||||
|  |             logQso(); | ||||||
|  |         } else if (e.ctrlKey && e.altKey && e.which == 89) { | ||||||
|  |             alert("Ctrl + Alt + Y shortcut combination was pressed"); | ||||||
|  |         } else if (e.ctrlKey && e.altKey && e.shiftKey && e.which == 85) { | ||||||
|  |             alert("Ctrl + Alt + Shift + U shortcut combination was pressed"); | ||||||
|  |         // Space to jump to either callsign or sent exchange
 | ||||||
|  |         } else if (e.which == 32) { | ||||||
|  |             if ($(document.activeElement).attr("id") == "callsign") { | ||||||
|  |                 $("#exch_recv").focus(); | ||||||
|  |                 return false; | ||||||
|  |             } else if ($(document.activeElement).attr("id") == "exch_recv") { | ||||||
|  |                 $("#callsign").focus(); | ||||||
|  |                 return false; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |     }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     // On Key up check and suggest callsigns
 | ||||||
|  |     $("#callsign").keyup(function() { | ||||||
|  |         var call = $(this).val(); | ||||||
|  |     if (call.length >= 3) { | ||||||
|  |       $.get('lookup/scp/' + call.toUpperCase(), function(result) { | ||||||
|  |         $('.callsign-suggestions').text(result); | ||||||
|  |         highlight(call.toUpperCase()); | ||||||
|  |       }); | ||||||
|  |     } | ||||||
|  |        else if (call.length <= 2) { | ||||||
|  |         $('.callsign-suggestions').text(""); | ||||||
|  |     } | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     function reset_log_fields() { | ||||||
|  |         $('#name').val(""); | ||||||
|  |         $('.callsign-suggestions').text(""); | ||||||
|  |         $('#callsign').val(""); | ||||||
|  |         $('#comment').val(""); | ||||||
|  |         $('#exch_recv').val(""); | ||||||
|  |         $("#callsign").focus(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     function logQso() { | ||||||
|  |         if ($("#callsign").val().length > 0) { | ||||||
|  | 
 | ||||||
|  |             $('.callsign-suggestions').text(""); | ||||||
|  |             $(".qsotable tbody").prepend('<tr>' + | ||||||
|  |                 '<td>'+$("#start_date").val()+ ' ' + $("#start_time").val() + '</td>' + | ||||||
|  |                 '<td>'+$("#callsign").val()+'</td>' + | ||||||
|  |                 '<td>'+$("#band").val()+'</td>' + | ||||||
|  |                 '<td>'+$("#mode").val()+'</td>' + | ||||||
|  |                 '<td>'+$("#rst_sent").val()+'</td>' + | ||||||
|  |                 '<td>'+$("#rst_recv").val()+'</td>' + | ||||||
|  |                 '<td>'+$("#exch_sent").val()+'</td>' + | ||||||
|  |                 '<td>'+$("#exch_recv").val()+'</td>' + | ||||||
|  |                 '</tr>'); | ||||||
|  | 
 | ||||||
|  |             $('#name').val(""); | ||||||
|  | 
 | ||||||
|  |             $('#callsign').val(""); | ||||||
|  |             $('#comment').val(""); | ||||||
|  |             $('#exch_recv').val(""); | ||||||
|  |             if ($('input[name=exchangeradio]:checked', '#qso_input').val() == "serial") { | ||||||
|  |                 $("#exch_sent").val(+$("#exch_sent").val() + 1); | ||||||
|  |             } | ||||||
|  |             $("#callsign").focus(); | ||||||
|  | 
 | ||||||
|  |             var baseURL= "<?php echo base_url();?>"; | ||||||
|  |             var formdata = new FormData(document.getElementById("qso_input")); | ||||||
|  |             $.ajax({ | ||||||
|  |                 url: baseURL + 'index.php/qso/saveqso', | ||||||
|  |                 type: 'post', | ||||||
|  |                 data: formdata, | ||||||
|  |                 processData: false, | ||||||
|  |                 contentType: false, | ||||||
|  |                 enctype: 'multipart/form-data', | ||||||
|  |                 success: function (html) { | ||||||
|  |                     alert("logged"); | ||||||
|  |                 } | ||||||
|  |             }); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     RegExp.escape = function(text) { | ||||||
|  |         return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     function highlight(term, base) { | ||||||
|  |         if (!term) return; | ||||||
|  |         base = base || document.body; | ||||||
|  |         var re = new RegExp("(" + RegExp.escape(term) + ")", "gi"); | ||||||
|  |         var replacement = "<span class=\"text-primary\">" + term + "</span>"; | ||||||
|  |         $(".callsign-suggestions", base).contents().each( function(i, el) { | ||||||
|  |             if (el.nodeType === 3) { | ||||||
|  |                 var data = el.data; | ||||||
|  |                 if (data = data.replace(re, replacement)) { | ||||||
|  |                     var wrapper = $("<span>").html(data); | ||||||
|  |                     $(el).before(wrapper.contents()).remove(); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         }); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     </script> | ||||||
|  | <?php } ?>
 | ||||||
|   </body> |   </body> | ||||||
| </html> | </html> | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用