[Station Logbook] Improved edit interface
这个提交包含在:
		
							父节点
							
								
									234ec52f1b
								
							
						
					
					
						当前提交
						87d5c8e1b0
					
				
					共有  3 个文件被更改,包括 101 次插入 和 25 次删除
				
			
		|  | @ -63,10 +63,12 @@ class Logbooks extends CI_Controller { | ||||||
| 
 | 
 | ||||||
| 		$data['station_logbook_details'] = $station_logbook_details_query->row(); | 		$data['station_logbook_details'] = $station_logbook_details_query->row(); | ||||||
| 		$data['station_locations_list'] = $this->stations->all(); | 		$data['station_locations_list'] = $this->stations->all(); | ||||||
|  | 
 | ||||||
|  | 		$data['station_locations_linked'] = $this->logbooks_model->list_logbooks_linked($station_logbook_id); | ||||||
| 		 | 		 | ||||||
| 		$data['page_title'] = "Edit Station Logbook"; | 		$data['page_title'] = "Edit Station Logbook"; | ||||||
| 
 | 
 | ||||||
| 		$this->form_validation->set_rules('station_logbook_name', 'Station Logbook Name', 'required'); | 		$this->form_validation->set_rules('station_logbook_id', 'Station Logbook Name', 'required'); | ||||||
| 
 | 
 | ||||||
|         if ($this->form_validation->run() == FALSE) |         if ($this->form_validation->run() == FALSE) | ||||||
|         { |         { | ||||||
|  | @ -76,23 +78,22 @@ class Logbooks extends CI_Controller { | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|         { |         { | ||||||
|             $this->logbooks_model->edit(); |  | ||||||
| 
 | 
 | ||||||
|             $data['notice'] = "Station Logbooks ".$this->security->xss_clean($this->input->post('station_logbook_name', true))." Updated"; |             $data['notice'] = "Station Logbooks ".$this->security->xss_clean($this->input->post('station_logbook_name', true))." Updated"; | ||||||
| 
 | 
 | ||||||
| 			foreach ($this->input->post('SelectedStationLocations') as $selectedOption){  | 			if($this->input->post('SelectedStationLocation') != "") { | ||||||
| 				// Check if theres already a link between logbook and location
 | 				if($this->logbooks_model->relationship_exists($this->input->post('station_logbook_id'), $this->input->post('SelectedStationLocation')) != TRUE) { | ||||||
| 				if($this->logbooks_model->relationship_exists($this->input->post('station_logbook_id'), $selectedOption) != TRUE) { |  | ||||||
| 					// If no link exisits create
 | 					// If no link exisits create
 | ||||||
| 					$this->logbooks_model->create_logbook_location_link($this->input->post('station_logbook_id'), $selectedOption); | 					$this->logbooks_model->create_logbook_location_link($this->input->post('station_logbook_id'), $this->input->post('SelectedStationLocation')); | ||||||
|  | 					echo "linked"; | ||||||
| 				} else { | 				} else { | ||||||
| 					echo "Already Linked"; | 					echo "Already Linked"; | ||||||
| 				} | 				} | ||||||
| 
 | 			} else { | ||||||
| 				// Delete link if removed
 | 				$this->logbooks_model->edit(); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|             redirect('logbooks'); |             redirect('logbooks/edit/'.$this->input->post('station_logbook_id')); | ||||||
|         } |         } | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -111,4 +112,11 @@ class Logbooks extends CI_Controller { | ||||||
| 		redirect('logbooks'); | 		redirect('logbooks'); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	public function delete_relationship($logbook_id, $station_id) { | ||||||
|  | 		$this->load->model('logbooks_model'); | ||||||
|  | 		$this->logbooks_model->delete_relationship($logbook_id, $station_id); | ||||||
|  | 		 | ||||||
|  | 		redirect('logbooks/edit/'.$logbook_id); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| } | } | ||||||
|  | @ -108,5 +108,40 @@ class Logbooks_model extends CI_Model { | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	function list_logbooks_linked($logbook_id) { | ||||||
|  | 
 | ||||||
|  | 		$relationships_array = array(); | ||||||
|  | 
 | ||||||
|  | 		$this->db->where('station_logbook_id', $logbook_id); | ||||||
|  | 		$query = $this->db->get('station_logbooks_relationship'); | ||||||
|  | 		 | ||||||
|  | 
 | ||||||
|  | 		if ($query->num_rows() > 0){ | ||||||
|  | 			foreach ($query->result() as $row) | ||||||
|  | 			{ | ||||||
|  | 				array_push($relationships_array, $row->station_location_id); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			$this->db->where_in('station_id', $relationships_array); | ||||||
|  | 			$query = $this->db->get('station_profile'); | ||||||
|  | 			 | ||||||
|  | 			return $query; | ||||||
|  | 		} | ||||||
|  | 		else{ | ||||||
|  | 			return false; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	function delete_relationship($logbook_id, $station_id) { | ||||||
|  | 		// Clean ID
 | ||||||
|  | 		$clean_logbook_id = $this->security->xss_clean($logbook_id); | ||||||
|  | 		$clean_station_id = $this->security->xss_clean($station_id); | ||||||
|  | 
 | ||||||
|  | 		// Delete QSOs
 | ||||||
|  | 		$this->db->where('station_logbook_id', $clean_logbook_id); | ||||||
|  | 		$this->db->where('station_location_id', $clean_station_id); | ||||||
|  | 		$this->db->delete('station_logbooks_relationship');  | ||||||
|  | 	} | ||||||
| } | } | ||||||
| ?>
 | ?>
 | ||||||
|  | @ -18,47 +18,80 @@ | ||||||
| 
 | 
 | ||||||
| 	<?php echo validation_errors(); ?>
 | 	<?php echo validation_errors(); ?>
 | ||||||
| 
 | 
 | ||||||
| 	<form method="post" action="<?php echo site_url('logbooks/edit/'); ?><?php echo $station_logbook_details->logbook_id; ?>" name="create_profile"> |  | ||||||
| 
 |  | ||||||
| 	<input type="hidden" name="logbook_id" value="<?php echo $station_logbook_details->logbook_id; ?>"> |  | ||||||
| 
 |  | ||||||
| 	<div class="row"> | 	<div class="row"> | ||||||
| 		<div class="col-md"> | 		<div class="col-md"> | ||||||
| 			<div class="card"> | 			<div class="card"> | ||||||
| 				<div class="card-header"><?php echo $page_title; ?>: <?php echo $station_logbook_details->logbook_name; ?></div>
 | 				<div class="card-header"><?php echo $page_title; ?>: <?php echo $station_logbook_details->logbook_name; ?></div>
 | ||||||
| 				<div class="card-body"> | 				<div class="card-body"> | ||||||
| 				 | 					<form method="post" action="<?php echo site_url('logbooks/edit/'); ?><?php echo $station_logbook_details->logbook_id; ?>" name="create_profile"> | ||||||
| 					<div class="form-group"> | 						<input type="hidden" name="logbook_id" value="<?php echo $station_logbook_details->logbook_id; ?>"> | ||||||
| 						<label for="stationLogbookNameInput">Station Logbook Name</label> | 
 | ||||||
| 						<input type="text" class="form-control" name="station_logbook_name" id="stationLogbookNameInput" aria-describedby="stationLogbookNameInputHelp" value="<?php if(set_value('station_logbook_name') != "") { echo set_value('station_logbook_name'); } else { echo $station_logbook_details->logbook_name; } ?>" required> | 						<div class="form-group"> | ||||||
| 						<small id="stationLogbookNameInputHelp" class="form-text text-muted">Shortname for the station location. For example: Home (IO87IP)</small> | 							<label for="stationLogbookNameInput">Station Logbook Name</label> | ||||||
| 					</div> | 							<input type="text" class="form-control" name="station_logbook_name" id="stationLogbookNameInput" aria-describedby="stationLogbookNameInputHelp" value="<?php if(set_value('station_logbook_name') != "") { echo set_value('station_logbook_name'); } else { echo $station_logbook_details->logbook_name; } ?>" required> | ||||||
|  | 							<small id="stationLogbookNameInputHelp" class="form-text text-muted">Shortname for the station location. For example: Home (IO87IP)</small> | ||||||
|  | 						</div> | ||||||
|  | 
 | ||||||
|  | 						<input type="hidden" class="form-control" name="station_logbook_id" value="<?php echo $station_logbook_details->logbook_id; ?>" required>	 | ||||||
|  | 
 | ||||||
|  | 						<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> Update Station Logbook Name</button> | ||||||
|  | 					</form> | ||||||
| 				</div> | 				</div> | ||||||
| 			</div> | 			</div> | ||||||
| 		</div> | 		</div> | ||||||
| 
 | 
 | ||||||
|  | 		 | ||||||
| 		<div class="col-md"> | 		<div class="col-md"> | ||||||
| 			<div class="card"> | 			<div class="card"> | ||||||
| 				<div class="card-header">Station Locations</div> | 				<div class="card-header">Station Locations</div> | ||||||
| 				<div class="card-body"> | 				<div class="card-body"> | ||||||
|  | 					<form method="post" action="<?php echo site_url('logbooks/edit/'); ?><?php echo $station_logbook_details->logbook_id; ?>" name="create_profile"> | ||||||
|  | 					<input type="hidden" name="logbook_id" value="<?php echo $station_logbook_details->logbook_id; ?>"> | ||||||
|  | 
 | ||||||
| 					<div class="form-group"> | 					<div class="form-group"> | ||||||
| 						<label for="StationLocationsSelect">Select Available Station Locations</label> | 						<label for="StationLocationsSelect">Select Available Station Locations</label> | ||||||
| 						<select name="SelectedStationLocations[]" class="form-control" id="StationLocationsSelect" multiple aria-describedby="StationLocationSelectHelp"> | 						<select name="SelectedStationLocation" class="form-control" id="StationLocationSelect" aria-describedby="StationLocationSelectHelp"> | ||||||
| 							<?php foreach ($station_locations_list->result() as $row) { ?>	
 | 							<?php foreach ($station_locations_list->result() as $row) { ?>	
 | ||||||
| 								<option value="<?php echo $row->station_id;?>" <?php if ($station_locations_array != FALSE && in_array($row->station_id, $station_locations_array)) { echo "selected"; } ?>><?php echo $row->station_profile_name;?> (Callsign: <?php echo $row->station_callsign;?> DXCC: <?php echo $row->station_country;?>)</option>
 | 								<option value="<?php echo $row->station_id;?>"><?php echo $row->station_profile_name;?> (Callsign: <?php echo $row->station_callsign;?> DXCC: <?php echo $row->station_country;?>)</option>
 | ||||||
| 							<?php } ?>
 | 							<?php } ?>
 | ||||||
| 						</select> | 						</select> | ||||||
| 						<small id="StationLocationSelectHelp" class="form-text text-muted">Hold down the Ctrl (windows) or Command (Mac) button to select multiple options.</small> |  | ||||||
| 					</div> | 					</div> | ||||||
|  | 
 | ||||||
|  | 					<input type="hidden" class="form-control" name="station_logbook_id" value="<?php echo $station_logbook_details->logbook_id; ?>" required>	 | ||||||
|  | 
 | ||||||
|  | 					<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> Link Location</button> | ||||||
|  | 
 | ||||||
| 				</div> | 				</div> | ||||||
| 			</div> | 			</div> | ||||||
| 		</div> | 		</div> | ||||||
| 	</div> | 	</div> | ||||||
| 
 | 
 | ||||||
| 	<input type="hidden" class="form-control" name="station_logbook_id" value="<?php echo $station_logbook_details->logbook_id; ?>" required>	 | 	<div class="card"> | ||||||
|  | 		<div class="card-header"> | ||||||
|  | 			Linked Locations | ||||||
|  | 		</div> | ||||||
| 
 | 
 | ||||||
| 	<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> Update Station Logbook</button> | 	    <div class="table-responsive"> | ||||||
|  | 			<table class="table table-hover"> | ||||||
|  | 				<thead class="thead-light"> | ||||||
|  | 					<tr> | ||||||
|  | 				 		<th scope="col">Location Name</th> | ||||||
|  | 						<th scope="col"></th> | ||||||
|  | 				    </tr> | ||||||
|  | 				</thead> | ||||||
|  | 				  | ||||||
| 
 | 
 | ||||||
| 	</form> | 				<tbody> | ||||||
|  | 					<?php foreach ($station_locations_linked->result() as $row) { ?>
 | ||||||
|  | 					<tr> | ||||||
|  | 						<td><?php echo $row->station_profile_name;?> (Callsign: <?php echo $row->station_callsign;?> DXCC: <?php echo $row->station_country;?>)</td>
 | ||||||
|  | 						<td><a href="<?php echo site_url('logbooks/delete_relationship/'); ?><?php echo $station_logbook_details->logbook_id; ?>/<?php echo $row->station_id;?>" class="btn btn-danger"><i class="fas fa-trash-alt"></i></a></td> | ||||||
|  | 					</tr> | ||||||
|  | 					<?php } ?>
 | ||||||
|  | 				</tbody> | ||||||
|  | 			</table> | ||||||
|  | 		</div> | ||||||
|  | 
 | ||||||
|  | 	</div> | ||||||
| 
 | 
 | ||||||
| </div> | </div> | ||||||
		正在加载…
	
		在新工单中引用