|
Server : LiteSpeed System : Linux terra.hostitbro.com 5.14.0-611.54.3.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu May 7 16:31:24 EDT 2026 x86_64 User : outerorb ( 1091) PHP Version : 8.1.34 Disable Function : mail Directory : /home/outerorb/dev.outerorbittech.com/oot/admin/ | |
|
Path: //home/outerorb/dev.outerorbittech.com/oot/admin/addeditlocation.php
Size: 5.48 KB
Permissions: 0644
<?php
include_once("../include/main.inc.php");
check_session('MyCpanel','index.php');
@extract($_REQUEST);
$start = (intval($start) == 0 or $start == "") ? $start = 0 : $start;
$pagesize = intval($pagesize) == 0 ? $pagesize = 100 : $pagesize;
if (empty($catID)) {
$heading="Add New Location";
}
else {
$heading="Edit Location";
}
$res=getResult("admin_details"," where user_type='admin'");
$record_type="Location";
$script_name="addeditlocation.php";
$redirect_script_name="manage-location.php";
$table_name="location_tbl";
#################### Add Record ##################
if($_REQUEST['action']=="add_record" && $catName!="") {
$numCnt=getCount($table_name," where locationName='$catName' and parentID='$parentID' and locationID!='$catID' and locationType='$catgType' ");
if($numCnt>0) {
$_SESSION['session_message']='<div class="btn btn-warning">'.$record_type.' already exist</div>';
}
else{
$maxRes=db_fetch_array(db_query("select max(locationOrder) from $table_name where parentID='$parentID'"));
$catOrder=$maxRes[0]+1;
$sql=db_query("insert into $table_name set parentID='$parentID',locationurl='$catUrl',locationName='$catName', locationType='$catgType',locationOrder='$catOrder'");
$_SESSION['session_message']='<div class="btn btn-success">'.$record_type.' has been added successfully</div>';
header("Location: ".SITE_ADMIN_URL."/".$redirect_script_name."?start=".$start."&parentID=".$parentID."&locationID=".$catID."&pagesize=".$pagesize);
exit;
}
}
################ Update Record ##################
if($_REQUEST['action']=="update_record" && $catName!="" ) {
if ($catUrl != $catOldUrl) {
$catOldUrlUp = $catOldUrl;
} else {
$catOldUrlUp = $catOldUrlCheck;
}
$numCnt=getCount($table_name," where locationName='$catName' and parentID='$parentID' and locationID!='$catID' and locationType='$catgType'");
if($numCnt>0) {
$_SESSION['session_message']='<div class="btn btn-success">'.$record_type.' already exist</div>';
header("Location: ".SITE_ADMIN_URL."/".$script_name."?start=".$start."&parentID=".$parentID."&locationID=".$catID."&pagesize=".$pagesize);
exit;
}
updateTable($table_name," locationName='$catName',locationurl='$catUrl', locationType='$catgType' where locationID='$catID'");
$_SESSION['session_message']='<div class="btn btn-warning">'.$record_type.' has been updated successfully</div>';
header("Location: ".SITE_ADMIN_URL."/".$redirect_script_name."?start=".$start."&parentID=".$parentID."&locationID=".$catID."&pagesize=".$pagesize);
exit;
}
########################################################
admin_header();
$res=getResult($table_name," where locationID='$catID'");
?>
<div class="content-wrapper">
<div class="page-header">
<h3 class="page-title">
<?=$heading;?>
</h3>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="nav-item d-none d-lg-flex">
<a class="nav-link" href="<?=$redirect_script_name?>">
<span class="btn btn-primary">Go Back</span>
</a>
</li>
</ol>
</nav>
</div>
<div class="row">
<div class="col-12 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<form class="forms-sample" method="POST" action="" enctype="multipart/form-data">
<div class="form-group">
<label>Location Name</label>
<input class="typeahead" type="text" name="catName" id="locName" value="<?=$res['locationName']?>" placeholder="location Name">
</div>
<div class="form-group">
<label for="exampleTextarea1">Location URL*</label>
<input class="typeahead" type="text" id="catUrl" name="catUrl" readonly
value="<?= $res['locationurl']; ?>" placeholder="Location URL">
<input class="typeahead" type="hidden" id="catOldUrl" name="catOldUrl" readonly
value="<?= $res['locationurl']; ?>" placeholder="Location Old URL">
<input class="typeahead" type="hidden" id="catOldUrlCheck" name="catOldUrlCheck" readonly
value="<?= $res['catOldUrl']; ?>" placeholder="Location Old URL Pass">
</div>
<?php
if($res['locationID']=="") {
?>
<button type="submit" class="btn btn-primary mr-2" name="add_record">Submit</button>
<input type="hidden" name="action" value="add_record">
<?php
} else {
?>
<button type="submit" name="update_record" class="btn btn-primary mr-2" value="Update <?=$record_type;?>">Update</button>
<input type="hidden" name="action" value="update_record">
<?php
}
?>
<button class="btn btn-light" onclick="javascript: window.location.href = '<?=SITE_ADMIN_URL;?>/<?= $redirect_script_name; ?>?parentID=<?= $parentID; ?>&catID=<?= $catID; ?>'">Cancel</button>
</form>
</div>
</div>
</div>
</div>
</div>
<?php
admin_footer();
?>
<script>
$(document).ready(function() {
$('#locName').on('input blur', function() {
let input = $(this).val();
let inputResponse = removeSpecialChars(input);
$('#catUrl').val(inputResponse);
});
});
</script>