[Labels] Added edit/delete paper type
这个提交包含在:
		
							父节点
							
								
									b419e804bb
								
							
						
					
					
						当前提交
						206c10f80a
					
				
					共有  4 个文件被更改,包括 119 次插入 和 83 次删除
				
			
		|  | @ -43,6 +43,8 @@ class Labels extends CI_Controller { | ||||||
| 
 | 
 | ||||||
| 		$data['labels'] = $this->labels_model->fetchLabels($this->session->userdata('user_id')); | 		$data['labels'] = $this->labels_model->fetchLabels($this->session->userdata('user_id')); | ||||||
| 
 | 
 | ||||||
|  | 		$data['papertypes'] = $this->labels_model->fetchPapertypes($this->session->userdata('user_id')); | ||||||
|  | 
 | ||||||
| 		$data['qsos'] = $this->labels_model->fetchQsos($this->session->userdata('user_id')); | 		$data['qsos'] = $this->labels_model->fetchQsos($this->session->userdata('user_id')); | ||||||
| 
 | 
 | ||||||
| 		$footerData = []; | 		$footerData = []; | ||||||
|  | @ -351,4 +353,32 @@ class Labels extends CI_Controller { | ||||||
| 		$data['stationid'] = xss_clean($this->input->post('stationid')); | 		$data['stationid'] = xss_clean($this->input->post('stationid')); | ||||||
| 		$this->load->view('labels/startatform', $data); | 		$this->load->view('labels/startatform', $data); | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	public function editPaper($id) { | ||||||
|  | 		$this->load->model('labels_model'); | ||||||
|  | 
 | ||||||
|  | 		$cleanid = $this->security->xss_clean($id); | ||||||
|  | 
 | ||||||
|  | 		$data['paper'] = $this->labels_model->getPaper($cleanid); | ||||||
|  | 
 | ||||||
|  | 		$data['page_title'] = "Edit Paper"; | ||||||
|  | 
 | ||||||
|  | 		$this->load->view('interface_assets/header', $data); | ||||||
|  | 		$this->load->view('labels/editpaper'); | ||||||
|  | 		$this->load->view('interface_assets/footer'); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public function updatePaper($id) { | ||||||
|  | 		$this->load->model('labels_model'); | ||||||
|  | 		$this->labels_model->updatePaper($id); | ||||||
|  | 		$this->session->set_flashdata('message', 'Paper was saved.'); | ||||||
|  | 		redirect('labels'); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	public function deletePaper($id) { | ||||||
|  | 		$this->load->model('labels_model'); | ||||||
|  | 		$this->labels_model->deletePaper($id); | ||||||
|  | 		$this->session->set_flashdata('warning', 'Paper was deleted.'); | ||||||
|  | 		redirect('labels'); | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -87,6 +87,13 @@ class Labels_model extends CI_Model { | ||||||
|         return $query->result(); |         return $query->result(); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	function fetchPapertypes($user_id) { | ||||||
|  |         $this->db->where('user_id', $user_id); | ||||||
|  | 		$query = $this->db->get('paper_types'); | ||||||
|  | 
 | ||||||
|  |         return $query->result(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  	function fetchQsos($user_id) { |  	function fetchQsos($user_id) { | ||||||
| 
 | 
 | ||||||
| 		$qsl = "select count(*) count, station_profile.station_profile_name, station_profile.station_callsign, station_profile.station_id, station_profile.station_gridsquare
 | 		$qsl = "select count(*) count, station_profile.station_profile_name, station_profile.station_callsign, station_profile.station_id, station_profile.station_gridsquare
 | ||||||
|  | @ -159,4 +166,35 @@ class Labels_model extends CI_Model { | ||||||
| 
 | 
 | ||||||
|         return $query; |         return $query; | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  | 	function updatePaper($id) { | ||||||
|  |         $data = array( | ||||||
|  | 			'user_id' 		=> $this->session->userdata('user_id'), | ||||||
|  |             'paper_name' 	=> xss_clean($this->input->post('paper_name', true)), | ||||||
|  |             'metric' 		=> xss_clean($this->input->post('measurementType', true)), | ||||||
|  |             'width' 		=> xss_clean($this->input->post('width', true)), | ||||||
|  |             'height' 		=> xss_clean($this->input->post('height', true)), | ||||||
|  |             'last_modified' => date('Y-m-d H:i:s'), | ||||||
|  | 		); | ||||||
|  | 
 | ||||||
|  |         $cleanid = $this->security->xss_clean($id); | ||||||
|  | 
 | ||||||
|  |         $this->db->where('user_id', $this->session->userdata('user_id')); | ||||||
|  |         $this->db->where('id', $cleanid); | ||||||
|  |         $this->db->update('paper_types', $data); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     function deletePaper($id) { | ||||||
|  |         $cleanid = xss_clean($id); | ||||||
|  | 
 | ||||||
|  |         $this->db->delete('paper_types', array('id' => $cleanid, 'user_id' => $this->session->userdata('user_id'))); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 	function getPaper($id) { | ||||||
|  |         $this->db->where('user_id', $this->session->userdata('user_id')); | ||||||
|  |         $this->db->where('id', $id); | ||||||
|  | 		$query = $this->db->get('paper_types'); | ||||||
|  | 
 | ||||||
|  |         return $query->row(); | ||||||
|  |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ | ||||||
| 
 | 
 | ||||||
| <?php echo validation_errors(); ?>
 | <?php echo validation_errors(); ?>
 | ||||||
| 
 | 
 | ||||||
| <form method="post" action="<?php echo site_url('labels/updateLabel/' . $label->id); ?>" name="create_label_type"> | <form method="post" action="<?php echo site_url('labels/updatePaper/' . $paper->id); ?>" name="create_label_type"> | ||||||
| 
 | 
 | ||||||
| 	<div class="card"> | 	<div class="card"> | ||||||
| 		<h2 class="card-header"><?php echo $page_title; ?></h2>
 | 		<h2 class="card-header"><?php echo $page_title; ?></h2>
 | ||||||
|  | @ -18,99 +18,36 @@ | ||||||
| 		<div class="card-body"> | 		<div class="card-body"> | ||||||
| 
 | 
 | ||||||
| 			<!-- Label Name Input --> | 			<!-- Label Name Input --> | ||||||
| 	    	<div class="form-group"> |  | ||||||
| 			    <label for="LabelName">Label Name</label> |  | ||||||
| 			    <input name="label_name" type="text" class="form-control" id="LabelName" aria-describedby="label_nameHelp" placeholder="Code 925041 6x3 Generic Label Sheet" value="<?php if(isset($label->label_name)) { echo $label->label_name; } ?>"> |  | ||||||
| 			    <small id="label_nameHelp" class="form-text text-muted">Label name used for display purposes so pick something meaningful perhaps the label style.</small> |  | ||||||
| 			</div> |  | ||||||
| 
 |  | ||||||
| 	    	<div class="form-group row"> | 	    	<div class="form-group row"> | ||||||
|     			<label class="col-sm-2 col-form-label" for="paperType">Paper Type</label> | 			<label class= "col-sm-2 col-form-label" for="PaperName">Paper Type Name</label> | ||||||
| 				<div class="col-sm-4"> | 				<div class="col-sm-4"> | ||||||
| 				    <select name="paper_type" class="form-control" id="paperType"> | 			    	<input name="paper_name" type="text" class="form-control" id="PaperName" aria-describedby="paper_nameHelp" value="<?php if(isset($paper->paper_name)) { echo $paper->paper_name; } ?>"> | ||||||
| 						<option value="a4" <?php if($label->paper_type == "a4") { echo "selected=\"selected\""; } ?>>A4</option>
 | 			    	<small id="paper_nameHelp" class="form-text text-muted">Paper name used for display purposes, so pick something meaningful.</small> | ||||||
| 						<option value="letter" <?php if($label->paper_type == "letter") { echo "selected=\"selected\""; } ?>>Letter</option>
 |  | ||||||
| 					</select> |  | ||||||
| 				</div> | 				</div> | ||||||
| 
 |  | ||||||
|     				<label class="col-sm-2 col-form-label" for="measurementType">Measurement used</label> |     				<label class="col-sm-2 col-form-label" for="measurementType">Measurement used</label> | ||||||
| 			    	<div class="col-sm-4"> | 			    	<div class="col-sm-4"> | ||||||
| 				    <select name="measurementType" class="form-control" id="measurementType"> | 				    <select name="measurementType" class="form-control" id="measurementType"> | ||||||
| 						<option value="mm" <?php if($label->metric == "mm") { echo "selected=\"selected\""; } ?>>Millimeters</option>
 | 						<option value="mm" <?php if($paper->metric == "mm") { echo "selected=\"selected\""; } ?>>Millimeters</option>
 | ||||||
| 						<option value="in" <?php if($label->metric == "in") { echo "selected=\"selected\""; } ?>>Inches</option>
 | 						<option value="in" <?php if($paper->metric == "in") { echo "selected=\"selected\""; } ?>>Inches</option>
 | ||||||
| 					</select> | 					</select> | ||||||
| 			    </div> | 			    </div> | ||||||
|   			</div> |   			</div> | ||||||
| 
 | 
 | ||||||
| 			<div class="form-group row"> | 			<div class="form-group row"> | ||||||
|     			<label class="col-sm-2 col-form-label" for="marginTop">Margin Top</label> |     			<label class="col-sm-2 col-form-label" for="width">Width of paper</label> | ||||||
| 			    <div class="col-sm-4"> | 			    <div class="col-sm-4"> | ||||||
| 				    <input name="marginTop" type="text" class="form-control" id="marginTop" aria-describedby="marginTopHelp" value="<?php if(isset($label->margintop)) { echo $label->margintop; } ?>"> | 				    <input name="width" type="text" class="form-control" id="width" aria-describedby="widthHelp" value="<?php if(isset($paper->width)) { echo $paper->width; } ?>"> | ||||||
| 			    	<small id="marginTopHelp" class="form-text text-muted">Top margin of labels</small> | 			    	<small id="widthHelp" class="form-text text-muted">Total width of paper.</small> | ||||||
| 			    </div> | 			    </div> | ||||||
| 
 | 
 | ||||||
|     			<label class="col-sm-2 col-form-label" for="marginLeft">Margin Left</label> |     			<label class="col-sm-2 col-form-label" for="height">Height of paper</label> | ||||||
| 			    <div class="col-sm-4"> | 			    <div class="col-sm-4"> | ||||||
| 				    <input name="marginLeft" type="text" class="form-control" id="marginLeft" aria-describedby="marginLeftHelp" value="<?php if(isset($label->marginleft)) { echo $label->marginleft; } ?>"> | 				    <input name="height" type="text" class="form-control" id="height" aria-describedby="heightHelp" value="<?php if(isset($paper->height)) { echo $paper->height; } ?>"> | ||||||
| 			    	<small id="marginLeftHelp" class="form-text text-muted">Left margin of labels.</small> | 			    	<small id="heightHelp" class="form-text text-muted">Total width of paper.</small> | ||||||
| 			    </div> | 			    </div> | ||||||
|   			</div> |   			</div> | ||||||
| 
 | 
 | ||||||
|   			<div class="form-group row"> |  			<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> Save Paper Type</button> | ||||||
|     			<label class="col-sm-2 col-form-label" for="NX">Labels horizontally</label> |  | ||||||
| 			    <div class="col-sm-4"> |  | ||||||
| 				    <input name="NX" type="number" min="1" max="40" step="1" class="form-control" id="NX" aria-describedby="NXHelp" value="<?php if(isset($label->nx)) { echo $label->nx; } ?>"> |  | ||||||
| 			    	<small id="NXHelp" class="form-text text-muted">Number of labels horizontally across the page.</small> |  | ||||||
| 			    </div> |  | ||||||
| 
 |  | ||||||
|     			<label class="col-sm-2 col-form-label" for="NY">Labels vertically</label> |  | ||||||
| 			    <div class="col-sm-4"> |  | ||||||
| 				    <input name="NY" type="number" min="1" max="40" step="1" class="form-control" id="NY" aria-describedby="NYHelp" value="<?php if(isset($label->ny)) { echo $label->ny; } ?>"> |  | ||||||
| 			    	<small id="NYHelp" class="form-text text-muted">Number of labels vertically across the page.</small> |  | ||||||
| 			    </div> |  | ||||||
|   			</div> |  | ||||||
| 
 |  | ||||||
|   			<div class="form-group row"> |  | ||||||
|     			<label class="col-sm-2 col-form-label" for="SpaceX">Horizontal space</label> |  | ||||||
| 			    <div class="col-sm-4"> |  | ||||||
| 				    <input name="SpaceX" type="text" class="form-control" id="SpaceX" value="<?php if(isset($label->spacex)) { echo $label->spacex; } ?>"> |  | ||||||
| 					<small id="NYHelp" class="form-text text-muted">Horizontal space between 2 labels.</small> |  | ||||||
| 			    </div> |  | ||||||
| 
 |  | ||||||
|     			<label class="col-sm-2 col-form-label" for="SpaceY">Vertical space</label> |  | ||||||
| 			    <div class="col-sm-4"> |  | ||||||
| 				    <input name="SpaceY" type="text" class="form-control" id="SpaceY" value="<?php if(isset($label->spacey)) { echo $label->spacey; } ?>"> |  | ||||||
| 					<small id="NYHelp" class="form-text text-muted">Vertical space between 2 labels.</small> |  | ||||||
| 			    </div> |  | ||||||
|   			</div> |  | ||||||
| 
 |  | ||||||
| 			<div class="form-group row"> |  | ||||||
|     			<label class="col-sm-2 col-form-label" for="width">Width of label</label> |  | ||||||
| 			    <div class="col-sm-4"> |  | ||||||
| 				    <input name="width" type="text" class="form-control" id="width" aria-describedby="widthHelp" value="<?php if(isset($label->width)) { echo $label->width; } ?>"> |  | ||||||
| 			    	<small id="widthHelp" class="form-text text-muted">Total width of one label.</small> |  | ||||||
| 			    </div> |  | ||||||
| 
 |  | ||||||
|     			<label class="col-sm-2 col-form-label" for="height">Height of label</label> |  | ||||||
| 			    <div class="col-sm-4"> |  | ||||||
| 				    <input name="height" type="text" class="form-control" id="height" aria-describedby="heightHelp" value="<?php if(isset($label->height)) { echo $label->height; } ?>"> |  | ||||||
| 			    	<small id="heightHelp" class="form-text text-muted">Total height of one label</small> |  | ||||||
| 			    </div> |  | ||||||
|   			</div> |  | ||||||
| 
 |  | ||||||
|   			<div class="form-group row"> |  | ||||||
|     			<label class="col-sm-2 col-form-label" for="font_size">Font Size</label> |  | ||||||
| 			    <div class="col-sm-4"> |  | ||||||
| 				    <input name="font_size" type="number" min="1" max="40" step="1" class="form-control" id="font_size" aria-describedby="font_sizeHelp" value="<?php if(isset($label->font_size)) { echo $label->font_size; } ?>"> |  | ||||||
| 			    	<small id="font_sizeHelp" class="form-text text-muted">Font size used on the label don't go too big.</small> |  | ||||||
| 			    </div> |  | ||||||
| 
 |  | ||||||
|     			<label class="col-sm-2 col-form-label" for="font_size">QSOs on label</label> |  | ||||||
| 			    <div class="col-sm-4"> |  | ||||||
| 				    <input name="label_qsos" type="number" min="1" max="40" step="1" class="form-control" id="label_qsos" aria-describedby="font_sizeHelp" value="<?php if(isset($label->qsos)) { echo $label->qsos; } ?>"> |  | ||||||
| 			    </div> |  | ||||||
|   			</div> |  | ||||||
|   			<button type="submit" class="btn btn-primary"><i class="fas fa-plus-square"></i> Save Label Type</button> |  | ||||||
| 		</div> | 		</div> | ||||||
| 	</div> | 	</div> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -28,10 +28,41 @@ | ||||||
| 	<div class="card-body"> | 	<div class="card-body"> | ||||||
| 	<a href="<?php echo site_url('labels/create'); ?>" class="btn btn-outline-primary btn-sm">Create New Label Type</a> | 	<a href="<?php echo site_url('labels/create'); ?>" class="btn btn-outline-primary btn-sm">Create New Label Type</a> | ||||||
| 	<a href="<?php echo site_url('labels/createpaper'); ?>" class="btn btn-outline-primary btn-sm">Create New Paper Type</a> | 	<a href="<?php echo site_url('labels/createpaper'); ?>" class="btn btn-outline-primary btn-sm">Create New Paper Type</a> | ||||||
|  | <br><br> | ||||||
|  | 	<?php if ($papertypes) { ?>
 | ||||||
|  | 		<h4>Paper types</h4> | ||||||
|  | 						<table style="width:100%" class="table-sm labeltable table-bordered table-hover table-striped table-condensed text-center"> | ||||||
|  | 						<thead> | ||||||
|  | 							<tr> | ||||||
|  | 								<th>Name</th> | ||||||
|  | 								<th>Measurement</th> | ||||||
|  | 								<th>Width</th> | ||||||
|  | 								<th>Height</th> | ||||||
|  | 								<th>Last Modified</th> | ||||||
|  | 								<th>Edit</th> | ||||||
|  | 								<th>Delete</th> | ||||||
|  | 							</tr> | ||||||
|  | 						</thead> | ||||||
|  | 						<tbody> | ||||||
|  | 						<?php | ||||||
|  | 		foreach($papertypes as $paper) { ?>
 | ||||||
|  | 			<tr class='label_<?php echo $paper->id ?>'> | ||||||
|  | 			<td><?php echo $paper->paper_name; ?></td>
 | ||||||
|  | 			<td><?php echo $paper->metric; ?></td>
 | ||||||
|  | 			<td><?php echo $paper->width; ?></td>
 | ||||||
|  | 			<td><?php echo $paper->height; ?></td>
 | ||||||
|  | 			<td><?php echo $paper->last_modified; ?></td>
 | ||||||
|  | 			<td><a href="<?php echo site_url('labels/editpaper/' . $paper->id); ?>" class="btn btn-outline-primary btn-sm"><i class="fas fa-edit"></i></a></td> | ||||||
|  | 			<td><a href="<?php echo site_url('labels/deletepaper/' . $paper->id); ?>" class="btn btn-outline-danger btn-sm"><i class="fas fa-trash-alt"></i></a></td> | ||||||
|  | 			</tr> | ||||||
| 
 | 
 | ||||||
|  | 		<?php } | ||||||
|  | 		echo '</tbody></table>'; | ||||||
|  | 	} ?>
 | ||||||
| 
 | 
 | ||||||
| 	<?php if ($labels) { | 	<?php if ($labels) { ?>
 | ||||||
| 		echo '<br/><br/>';?>
 | 		<br> | ||||||
|  | 		<h4>Label types</h4> | ||||||
| 						<table style="width:100%" class="table-sm labeltable table-bordered table-hover table-striped table-condensed text-center"> | 						<table style="width:100%" class="table-sm labeltable table-bordered table-hover table-striped table-condensed text-center"> | ||||||
| 						<thead> | 						<thead> | ||||||
| 							<tr> | 							<tr> | ||||||
|  |  | ||||||
		正在加载…
	
		在新工单中引用