-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functionality to services in backend.
- Add functionallity to categorize a one or more services under one service group. Partial fix for #7 and #90. (Frontend code to be done) - Add description field to service to be displayed as a help text on front page. Partial fix for #51 (Frontend code to be done)
- Loading branch information
Showing
9 changed files
with
515 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
if (isset($_GET['new'])) | ||
{ | ||
ServiceGroup::add(); | ||
} | ||
|
||
if (isset($_GET['edit'])) | ||
{ | ||
ServiceGroup::edit(); | ||
} | ||
|
||
if (isset($_GET['delete'])) | ||
{ | ||
ServiceGroup::delete(); | ||
} | ||
|
||
$boolEdit = false; | ||
$group_value = isset($_POST['group']) ? $_POST['group'] : ''; | ||
$description_value = isset($_POST['description']) ? $_POST['description'] : ''; | ||
$visibility_id_value = isset($_POST['visibility_id']) ? $_POST['visibility_id'] : ''; | ||
|
||
if ( isset($_GET['id']) && !isset($_POST['id']) ) { | ||
$group_id = (int) $_GET['id']; | ||
$boolEdit = true; | ||
$stmt = $mysqli->prepare("SELECT * FROM services_groups WHERE id LIKE ?"); | ||
$stmt->bind_param("i", $group_id); | ||
$stmt->execute(); | ||
$query = $stmt->get_result(); | ||
$data = $query->fetch_assoc(); | ||
$group_value = $data['name']; | ||
$description_value = $data['description']; | ||
$visibility_id_value = $data['visibility']; | ||
} | ||
|
||
|
||
if (!$boolEdit) { | ||
|
||
Template::render_header(_("New service group"), true); ?> | ||
<div class="text-center"> | ||
<h2><?php echo _("Add new service group");?></h2> | ||
</div> | ||
<?php | ||
$form_url = WEB_URL .'/admin/?do=new-service-group&new=group'; | ||
|
||
} else { | ||
Template::render_header(_("Edit service group"), true); ?> | ||
<div class="text-center"> | ||
<h2><?php echo _("Edit service group");?></h2> | ||
</div> | ||
<?php | ||
$form_url = WEB_URL .'/admin/?do=edit-service-group&edit&id='.$group_id; | ||
|
||
} | ||
?> | ||
|
||
<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 | ||
} ?> | ||
<div class="form-group"> | ||
<div class="col-sm-6"><label for="group"><?php echo _("Service Group Name");?>: </label><input type="text" maxlength="50" name="group" value="<?php echo ((isset($_POST['group']))?htmlspecialchars($_POST['group'],ENT_QUOTES):$group_value);?>" id="group" placeholder="<?php echo _("service group name");?>" class="form-control" required></div> | ||
<div class="col-sm-6"><label for="description"><?php echo _("Description");?>: </label><input type="text" maxlength="100" name="description" value="<?php echo ((isset($_POST['description']))?htmlspecialchars($description_value,ENT_QUOTES):$description_value);?>" id="description" placeholder="<?php echo _("Description");?>" class="form-control"></div> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-sm-6"> | ||
<label for="visibility_id"><?php echo _("Visibility");?>: </label> | ||
<select name="visibility_id" id="visibility_id" class="form-control"> | ||
<?php | ||
if (!empty($visibility_id_value)) | ||
{ | ||
$visibility_id = $visibility_id_value; | ||
} | ||
else | ||
{ | ||
$visibility_id = null; | ||
} | ||
//$visibilitys = Service::get_groups(); | ||
foreach ($visibility as $key => $value) { | ||
if ($visibility_id == $key) | ||
{ | ||
echo '<option value="'.$key.'" selected>'.$value.'</option>'; | ||
} | ||
else{ | ||
echo '<option value="'.$key.'">'.$value.'</option>'; | ||
} | ||
} | ||
?> | ||
</select> | ||
</div> | ||
</div> | ||
<?php | ||
if ( $boolEdit ) { | ||
echo '<input type="hidden" id="id" name="id" value="'.$group_id.'">'; | ||
} | ||
?> | ||
<button type="submit" class="btn btn-primary pull-right"><?php echo _("Submit");?></button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?php | ||
if (isset($_GET['new'])) | ||
{ | ||
Service::add(); | ||
} | ||
|
||
if (isset($_GET['edit'])) | ||
{ | ||
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'] : ''; | ||
|
||
if ( isset($_GET['id']) && !isset($_POST['id']) ) { | ||
$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); | ||
$service_value = $data['name']; | ||
$description_value = $data['description']; | ||
$group_id_value = $data['group_id']; | ||
} | ||
|
||
|
||
if (!$boolEdit) { | ||
|
||
Template::render_header(_("New service"), true); ?> | ||
<div class="text-center"> | ||
<h2><?php echo _("Add new service");?></h2> | ||
</div> | ||
<?php | ||
$form_url = WEB_URL . '/admin/?do=new-service&new=service'; | ||
} else { | ||
Template::render_header(_("New service"), true); ?> | ||
<div class="text-center"> | ||
<h2><?php echo _("Add new service");?></h2> | ||
</div> | ||
<?php | ||
$form_url = WEB_URL . '/admin/?do=edit-service&edit&id='.$service_id; | ||
} | ||
?> | ||
<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 | ||
} ?> | ||
<div class="form-group"> | ||
<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> | ||
</div> | ||
<div class="form-group"> | ||
<div class="col-sm-6"> | ||
<label for="group_id"><?php echo _("Service Group");?>: </label> | ||
<select name="group_id" id="group_id" class="form-control"> | ||
<?php | ||
if (!empty($group_id_value)) | ||
{ | ||
$group_id = $group_id_value; | ||
} | ||
else | ||
{ | ||
$group_id = null; | ||
} | ||
$groups = ServiceGroup::get_groups(); | ||
foreach ($groups as $key => $value) { | ||
if ($group_id == $key) | ||
{ | ||
echo '<option value="'.$key.'" selected>'.$value.'</option>'; | ||
} | ||
else{ | ||
echo '<option value="'.$key.'">'.$value.'</option>'; | ||
} | ||
} | ||
?> | ||
</select> | ||
</div> | ||
</div> | ||
<?php | ||
if ( $boolEdit ) { | ||
echo '<input type="hidden" id="id" name="id" value="'.$service_id.'">'; | ||
} | ||
?> | ||
<button type="submit" class="btn btn-primary pull-right"><?php echo _("Submit");?></button> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.