Save and Update Macros from the Database
这个提交包含在:
		
							父节点
							
								
									65b780e2f3
								
							
						
					
					
						当前提交
						43bacdc62a
					
				
					共有  4 个文件被更改,包括 191 次插入 和 12 次删除
				
			
		|  | @ -152,11 +152,59 @@ class QSO extends CI_Controller { | |||
| 	} | ||||
| 
 | ||||
|     function winkeysettings() { | ||||
|         $this->load->view('qso/components/winkeysettings'); | ||||
| 
 | ||||
|         // Load model Winkey
 | ||||
|         $this->load->model('winkey'); | ||||
| 
 | ||||
|         // call settings from model winkey
 | ||||
|         $data['result'] = $this->winkey->settings($this->session->userdata('user_id'), $this->session->userdata('station_profile_id')); | ||||
| 
 | ||||
|         if ($data['result'] == false) { | ||||
|             $this->load->view('qso/components/winkeysettings', $data); | ||||
|         } else { | ||||
|             $this->load->view('qso/components/winkeysettings_results', $data); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     function cwmacrosave(){ | ||||
|         echo "lets save!"; | ||||
|         // Get the data from the form
 | ||||
|         $function1_name = xss_clean($this->input->post('function1_name')); | ||||
|         $function1_macro = xss_clean($this->input->post('function1_macro')); | ||||
| 
 | ||||
|         $function2_name = xss_clean($this->input->post('function2_name')); | ||||
|         $function2_macro = xss_clean($this->input->post('function2_macro')); | ||||
| 
 | ||||
|         $function3_name = xss_clean($this->input->post('function3_name')); | ||||
|         $function3_macro = xss_clean($this->input->post('function3_macro')); | ||||
| 
 | ||||
|         $function4_name = xss_clean($this->input->post('function4_name')); | ||||
|         $function4_macro = xss_clean($this->input->post('function4_macro')); | ||||
| 
 | ||||
|         $function5_name = xss_clean($this->input->post('function5_name')); | ||||
|         $function5_macro = xss_clean($this->input->post('function5_macro')); | ||||
| 
 | ||||
|         $data = [ | ||||
|             'user_id' => $this->session->userdata('user_id'), | ||||
|             'station_location_id' => $this->session->userdata('station_profile_id'), | ||||
| 			'function1_name'  => $function1_name, | ||||
|             'function1_macro' => $function1_macro, | ||||
|             'function2_name'  => $function2_name, | ||||
|             'function2_macro' => $function2_macro, | ||||
|             'function3_name'  => $function3_name, | ||||
|             'function3_macro' => $function3_macro, | ||||
|             'function4_name'  => $function4_name, | ||||
|             'function4_macro' => $function4_macro, | ||||
|             'function5_name'  => $function5_name, | ||||
|             'function5_macro' => $function5_macro, | ||||
| 		]; | ||||
| 
 | ||||
|         // Load model Winkey
 | ||||
|         $this->load->model('winkey'); | ||||
| 
 | ||||
|         // save the data
 | ||||
|         $this->winkey->save($data); | ||||
| 
 | ||||
|         echo "Macros Saved, Press Close and lets get sending!"; | ||||
|     } | ||||
| 
 | ||||
|     function edit_ajax() { | ||||
|  |  | |||
							
								
								
									
										34
									
								
								application/models/Winkey.php
									
									
									
									
									
										普通文件
									
								
							
							
						
						
									
										34
									
								
								application/models/Winkey.php
									
									
									
									
									
										普通文件
									
								
							|  | @ -0,0 +1,34 @@ | |||
| <?php | ||||
| 
 | ||||
| class Winkey extends CI_Model | ||||
| { | ||||
|     public function settings($user_id, $station_location_id) | ||||
|     { | ||||
|         $this->db->where('user_id', $user_id); | ||||
|         $this->db->where('station_location_id', $station_location_id); | ||||
|         $query = $this->db->get('cwmacros'); | ||||
|          | ||||
|         if ($query->num_rows() > 0) { | ||||
|             return $query->row(); | ||||
|         } else { | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public function save($data) | ||||
|     { | ||||
|         $this->db->where('user_id', $data['user_id']); | ||||
|         $this->db->where('station_location_id', $data['station_location_id']); | ||||
|         $query = $this->db->get('cwmacros'); | ||||
| 
 | ||||
|         if ($query->num_rows() > 0) { | ||||
|             $this->db->where('user_id', $data['user_id']); | ||||
|             $this->db->where('station_location_id', $data['station_location_id']); | ||||
|             $this->db->update('cwmacros', $data); | ||||
|         } else { | ||||
|             $this->db->insert('cwmacros', $data); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
|  | @ -6,18 +6,19 @@ | |||
| 		<div class="modal-header"> | ||||
| 		  <h5 class="modal-title">Winkey Macros</h5> | ||||
| 		</div> | ||||
| 
 | ||||
| 		<div class="modal-body"> | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function1_name" class="col-sm-5 col-form-label">Function 1 - Name</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input type="text" class="form-control" id="function1_name" maxlength="6"> | ||||
| 						<input name="function1_name" type="text" class="form-control" id="function1_name" maxlength="6"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function1_macro" class="col-sm-5 col-form-label">Function 1 - Macro</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input type="text" class="form-control" id="function1_macro"> | ||||
| 						<input name="function1_macro" type="text" class="form-control" id="function1_macro"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
|  | @ -26,14 +27,14 @@ | |||
| 				<div class="form-group row"> | ||||
|     				<label for="function2_name" class="col-sm-5 col-form-label">Function 2 - Name</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input type="text" class="form-control" id="function2_name" maxlength="6"> | ||||
| 						<input name="function2_name" type="text" class="form-control" id="function2_name" maxlength="6"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function2_macro" class="col-sm-5 col-form-label">Function 2 - Macro</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input type="text" class="form-control" id="function2_macro"> | ||||
| 						<input name="function2_macro" type="text" class="form-control" id="function2_macro"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
|  | @ -42,14 +43,14 @@ | |||
| 				<div class="form-group row"> | ||||
|     				<label for="function3_name" class="col-sm-5 col-form-label">Function 3 - Name</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input type="text" class="form-control" id="function3_name" maxlength="6"> | ||||
| 						<input name="function3_name" type="text" class="form-control" id="function3_name" maxlength="6"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function3_macro" class="col-sm-5 col-form-label">Function 3 - Macro</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input type="text" class="form-control" id="function3_macro"> | ||||
| 						<input name="function3_macro" type="text" class="form-control" id="function3_macro"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
|  | @ -58,14 +59,14 @@ | |||
| 				<div class="form-group row"> | ||||
|     				<label for="function4_name" class="col-sm-5 col-form-label">Function 4 - Name</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input type="text" class="form-control" id="function4_name" maxlength="6"> | ||||
| 						<input name="function4_name" type="text" class="form-control" id="function4_name" maxlength="6"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function4_macro" class="col-sm-5 col-form-label">Function 4 - Macro</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input type="text" class="form-control" id="function4_macro"> | ||||
| 						<input name="function4_macro" type="text" class="form-control" id="function4_macro"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
|  | @ -74,14 +75,14 @@ | |||
| 				<div class="form-group row"> | ||||
|     				<label for="function5_name" class="col-sm-5 col-form-label">Function 5 - Name</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input type="text" class="form-control" id="function5_name" maxlength="6"> | ||||
| 						<input name="function5_name" type="text" class="form-control" id="function5_name" maxlength="6"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function5_macro" class="col-sm-5 col-form-label">Function 5 - Macro</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input type="text" class="form-control" id="function5_macro"> | ||||
| 						<input name="function5_macro" type="text" class="form-control" id="function5_macro"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 		</div> | ||||
|  |  | |||
|  | @ -0,0 +1,96 @@ | |||
| <div id="modal-backdrop" class="modal-backdrop fade show" style="display:block;"></div> | ||||
| <div id="modal" class="modal fade show" tabindex="-1" style="display:block;"> | ||||
| <form hx-post="/index.php/qso/cwmacrosave" hx-target=".modal-body"> | ||||
| 	<div class="modal-dialog modal-dialog-centered"> | ||||
| 	  <div class="modal-content"> | ||||
| 		<div class="modal-header"> | ||||
| 		  <h5 class="modal-title">Winkey Macros</h5> | ||||
| 		</div> | ||||
| 
 | ||||
| 		<div class="modal-body"> | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function1_name" class="col-sm-5 col-form-label">Function 1 - Name</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input name="function1_name" type="text" class="form-control" id="function1_name" maxlength="6" value="<?php echo $result->function1_name; ?>"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function1_macro" class="col-sm-5 col-form-label">Function 1 - Macro</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input name="function1_macro" type="text" class="form-control" id="function1_macro" value="<?php echo $result->function1_macro; ?>"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<hr> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function2_name" class="col-sm-5 col-form-label">Function 2 - Name</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input name="function2_name" type="text" class="form-control" id="function2_name" maxlength="6" value="<?php echo $result->function2_name; ?>"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function2_macro" class="col-sm-5 col-form-label">Function 2 - Macro</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input name="function2_macro" type="text" class="form-control" id="function2_macro" value="<?php echo $result->function2_macro; ?>"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<hr> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function3_name" class="col-sm-5 col-form-label">Function 3 - Name</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input name="function3_name" type="text" class="form-control" id="function3_name" maxlength="6" value="<?php echo $result->function3_name; ?>"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function3_macro" class="col-sm-5 col-form-label">Function 3 - Macro</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input name="function3_macro" type="text" class="form-control" id="function3_macro" value="<?php echo $result->function3_macro; ?>"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<hr> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function4_name" class="col-sm-5 col-form-label">Function 4 - Name</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input name="function4_name" type="text" class="form-control" id="function4_name" maxlength="6" value="<?php echo $result->function4_name; ?>"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function4_macro" class="col-sm-5 col-form-label">Function 4 - Macro</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input name="function4_macro" type="text" class="form-control" id="function4_macro" value="<?php echo $result->function4_macro; ?>"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<hr> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function5_name" class="col-sm-5 col-form-label">Function 5 - Name</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input name="function5_name" type="text" class="form-control" id="function5_name" maxlength="6" value="<?php echo $result->function5_name; ?>"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 
 | ||||
| 				<div class="form-group row"> | ||||
|     				<label for="function5_macro" class="col-sm-5 col-form-label">Function 5 - Macro</label> | ||||
|     				<div class="col-sm-7"> | ||||
| 						<input name="function5_macro" type="text" class="form-control" id="function5_macro" value="<?php echo $result->function5_macro; ?>"> | ||||
| 					</div> | ||||
|   				</div> | ||||
| 		</div> | ||||
| 		<div class="modal-footer"> | ||||
| 			<button type="submit" class="btn btn-primary">Save</button> | ||||
| 			<button type="button" class="btn btn-secondary" onclick="closeModal()">Close</button> | ||||
| 		</div> | ||||
| 	  </div> | ||||
| 	</div> | ||||
| 	</form> | ||||
| </div> | ||||
		正在加载…
	
		在新工单中引用