| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | if (isset($_GET['new'])) { | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 	Service::add(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | if (isset($_GET['edit'])) { | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 	Service::edit(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*if (isset($_GET['delete'])) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Service::delete(); | 
					
						
							|  |  |  | }*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $boolEdit 				 = false; | 
					
						
							|  |  |  | $service_value 		 = isset($_POST['service']) ? $_POST['service'] : ''; | 
					
						
							|  |  |  | $description_value = isset($_POST['description']) ? $_POST['description'] : ''; | 
					
						
							|  |  |  | $group_id_value    = isset($_POST['group_id']) ? $_POST['group_id'] : ''; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | if (isset($_GET['id']) && !isset($_POST['id'])) { | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 	$service_id = (int) $_GET['id']; | 
					
						
							|  |  |  | 	$boolEdit = true; | 
					
						
							|  |  |  | 	$stmt = $mysqli->prepare("SELECT * FROM services WHERE id LIKE ?"); | 
					
						
							|  |  |  | 	$stmt->bind_param("i", $service_id); | 
					
						
							|  |  |  | 	$stmt->execute(); | 
					
						
							|  |  |  | 	$query = $stmt->get_result(); | 
					
						
							|  |  |  | 	$data = $query->fetch_assoc(); | 
					
						
							|  |  |  | 	//print_r($data);
 | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | 	$service_value     = $data['name']; | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 	$description_value = $data['description']; | 
					
						
							|  |  |  | 	$group_id_value    = $data['group_id']; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (!$boolEdit) { | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-19 19:38:54 +01:00
										 |  |  | 	Template::render_header(_("New service"), "service", true); ?>
 | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | 	<div class="text-center"> | 
					
						
							|  |  |  | 		<h2><?php echo _("Add new service"); ?></h2>
 | 
					
						
							|  |  |  | 	</div> | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | 	$form_url = WEB_URL . '/admin/?do=new-service&new=service'; | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | } else { | 
					
						
							| 
									
										
										
										
											2021-03-19 19:38:54 +01:00
										 |  |  | 	Template::render_header(_("New service"), "service", true); ?>
 | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 	<div class="text-center"> | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | 		<h2><?php echo _("Add new service"); ?></h2>
 | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 	</div> | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | <?php | 
					
						
							|  |  |  | 	$form_url = WEB_URL . '/admin/?do=edit-service&edit&id=' . $service_id; | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | } | 
					
						
							|  |  |  | ?>
 | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | <form action="<?php echo $form_url; ?>" method="POST" class="form-horizontal"> | 
					
						
							|  |  |  | 	<?php if (isset($message)) { ?>
 | 
					
						
							|  |  |  | 		<p class="alert alert-danger"><?php echo $message ?></p>
 | 
					
						
							|  |  |  | 	<?php | 
					
						
							|  |  |  | 	} ?>
 | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 	<div class="form-group"> | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | 		<div class="col-sm-6"><label for="service"><?php echo _("Service"); ?>: </label><input type="text" maxlength="50" name="service" value="<?php echo ((isset($_POST['service'])) ? htmlspecialchars($_POST['service'], ENT_QUOTES) : $service_value); ?>" id="service" placeholder="<?php echo _("service"); ?>" class="form-control" required></div>
 | 
					
						
							|  |  |  | 		<div class="col-sm-6"><label for="description"><?php echo _("Description"); ?>: </label><input type="text" maxlength="200" name="description" value="<?php echo ((isset($_POST['description'])) ? htmlspecialchars($_POST['description'], ENT_QUOTES) : $description_value); ?>" id="description" placeholder="<?php echo _("Description"); ?>" class="form-control"></div>
 | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 	</div> | 
					
						
							|  |  |  | 	<div class="form-group"> | 
					
						
							|  |  |  | 		<div class="col-sm-6"> | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | 			<label for="group_id"><?php echo _("Service Group"); ?>: </label>
 | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 			<select name="group_id" id="group_id" class="form-control"> | 
					
						
							|  |  |  | 				<?php | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | 				if (!empty($group_id_value)) { | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 					$group_id = $group_id_value; | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 					$group_id = null; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				$groups = ServiceGroup::get_groups(); | 
					
						
							|  |  |  | 				foreach ($groups as $key => $value) { | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | 					if ($group_id == $key) { | 
					
						
							|  |  |  | 						echo '<option value="' . $key . '" selected>' . $value . '</option>'; | 
					
						
							|  |  |  | 					} else { | 
					
						
							|  |  |  | 						echo '<option value="' . $key . '">' . $value . '</option>'; | 
					
						
							| 
									
										
										
										
											2020-11-05 16:54:04 +03:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				?>
 | 
					
						
							|  |  |  | 			</select> | 
					
						
							|  |  |  | 		</div> | 
					
						
							|  |  |  | 	</div> | 
					
						
							|  |  |  | 	<?php | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | 	if ($boolEdit) { | 
					
						
							|  |  |  | 		echo '<input type="hidden" id="id" name="id" value="' . $service_id . '">'; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	?>
 | 
					
						
							| 
									
										
										
										
											2021-03-18 23:20:41 +01:00
										 |  |  | 	<button type="submit" class="btn btn-primary float-end><?php echo _("Submit"); ?></button>
 | 
					
						
							| 
									
										
										
										
											2021-03-18 18:26:03 +01:00
										 |  |  | </form> |