%PDF- %PDF-
| Direktori : /home/riacommer/public_html/admin/ |
| Current File : /home/riacommer/public_html/admin/product_ce.php |
<?php
include_once("api/security.php");
include_once("api/db.php");
include_once("api/util.php");
include_once("constants.php");
$act='create';
$id='';
$section_id='';
$brand_id='';
$product_category_id = '';
$product_code = '';
$product_name='';
$product_image = '';
$product_image_url = '';
$product_desp = '';
$extra_image1 = '';
$extra_image1_url = '';
$extra_image2 = '';
$extra_image2_url = '';
$extra_image3 = '';
$extra_image3_url = '';
$meta_title = '';
$meta_keywords = '';
$meta_desp = '';
$publish = '1';
//validation
$isImageRequired=' required="required"';
if(isset($_GET["id"])){
$id = $_GET["id"];
$sql = "SELECT * FROM sa_product WHERE id='$id'";
$mysql_result = mysql_query($sql, $connection);
$num_rows = mysql_num_rows($mysql_result);
if($num_rows>=1){
$act='update';
while($row = mysql_fetch_array($mysql_result)){
$section_id = $row["section_id"];
$brand_id = $row["brand_id"];
$product_category_id = $row["product_category_id"];
$product_code = $row["product_code"];
$product_name = $row["product_name"];
$product_image = $row["product_image"];
if($product_image!=""){
$product_image_url = '../contents/products/thumb_'.urlencode($product_image);
if(!file_exists($product_image_url)){
$product_image_url = '../contents/products/'.urlencode($product_image);
}
}
$product_desp = strip_tags(str_replace('</LI>',PHP_EOL,$row["product_desp"]));
$extra_image1 = $row["extra_image1"];
if($extra_image1!=""){
$extra_image1_url = '../contents/products/'.urlencode($extra_image1);
}
$extra_image2 = $row["extra_image2"];
if($extra_image2!=""){
$extra_image2_url = '../contents/products/'.urlencode($extra_image2);
}
$extra_image3 = $row["extra_image3"];
if($extra_image3!=""){
$extra_image3_url = '../contents/products/'.urlencode($extra_image3);
}
$meta_title = $row["meta_title"];
$meta_keywords = $row["meta_keywords"];
$meta_desp = $row["meta_desp"];
$publish = $row["publish"];
}
} else {
header("Location: http://" .$_SERVER['HTTP_HOST'] . str_replace("\\", "", dirname($_SERVER['PHP_SELF'])) ."/400.php");
}
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Product - <?php echo $app_title; ?></title>
<link href="css/application.min.css" rel="stylesheet">
<!-- as of IE9 cannot parse css files with more that 4K classes separating in two files -->
<!--[if IE 9]>
<link href="css/application-ie9-part2.css" rel="stylesheet">
<![endif]-->
<link rel="shortcut icon" href="favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="description" content="">
<meta name="author" content="">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<script>
</script>
</head>
<body>
<?php include_once("sidebar.php"); ?>
<?php include_once("topbar.php");?>
<!--CONTENT START HERE-->
<div class="content-wrap">
<!-- main page content. the place to put widgets in. usually consists of .row > .col-md-* > .widget. -->
<main id="content" class="content" role="main">
<h1 class="page-title">Product</span></h1>
<section class="widget">
<header>
<?php
if($act=="update"){
echo '<h4>Edit Product</h4>';
} else {
echo '<h4>Create Product</h4>';
}
?>
</header>
<div class="widget-body">
<form class="form-horizontal" role="form" method="post" action="api/product.php" enctype="multipart/form-data"
id="validation-form"
data-parsley-priority-enabled="false"
novalidate="novalidate">
<input type="hidden" value="<?php echo $act; ?>" id="act" name="act" />
<input type="hidden" value="<?php echo $id; ?>" id="id" name="id" />
<fieldset>
<legend><strong>Product Details</strong></legend>
<div class="form-group">
<label for="section_id" class="col-sm-4 control-label">Section</label>
<div class="col-sm-7">
<select data-placeholder="" id="section_id" name="section_id"
data-width="auto"
data-minimum-results-for-search="10"
required="required"
tabindex="-1"
class="select2 form-control">
<option value="">Select Section...</option>
<?php
$sql = "SELECT * FROM sa_section ORDER BY section";
$mysql_result = mysql_query($sql, $connection);
$num_rows = mysql_num_rows($mysql_result);
if($num_rows>=1){
while($row = mysql_fetch_array($mysql_result)){
echo '<option value="'.$row["id"].'"';
echo dropItem($row["id"], $section_id);
echo '>'.$row["section"].'</option>';
}
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="brand_id" class="col-sm-4 control-label">Brand</label>
<div class="col-sm-7">
<select data-placeholder="" id="brand_id" name="brand_id"
data-width="auto"
data-minimum-results-for-search="10"
required="required"
tabindex="-1"
class="select2 form-control">
<option value="">Select Brand...</option>
<?php
$sql = "SELECT * FROM sa_brand ORDER BY brand";
$mysql_result = mysql_query($sql, $connection);
$num_rows = mysql_num_rows($mysql_result);
if($num_rows>=1){
while($row = mysql_fetch_array($mysql_result)){
echo '<option value="'.$row["id"].'"';
echo dropItem($row["id"], $brand_id);
echo '>'.$row["brand"].'</option>';
}
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="product_category_id" class="col-sm-4 control-label">Product Category</label>
<div class="col-sm-7">
<select data-placeholder="" id="product_category_id" name="product_category_id"
data-width="auto"
data-minimum-results-for-search="10"
required="required"
tabindex="-1"
class="select2 form-control">
<option value="">Select Product Category...</option>
<?php
$sql = "SELECT * FROM sa_product_category ORDER BY product_category";
$mysql_result = mysql_query($sql, $connection);
$num_rows = mysql_num_rows($mysql_result);
if($num_rows>=1){
while($row = mysql_fetch_array($mysql_result)){
echo '<option value="'.$row["id"].'"';
echo dropItem($row["id"], $product_category_id);
echo '>'.$row["product_category"].'</option>';
}
}
?>
</select>
</div>
</div>
<div class="form-group">
<label for="product_code" class="col-sm-4 control-label">Product Code</label>
<div class="col-sm-7">
<input type="text" class="form-control" id="product_code" name="product_code"
value="<?php echo $product_code; ?>"
autocomplete="off"
/>
</div>
</div>
<div class="form-group">
<label for="product_name" class="col-sm-4 control-label">Product Name</label>
<div class="col-sm-7">
<input type="text" class="form-control" id="product_name" name="product_name"
value="<?php echo $product_name; ?>"
autocomplete="off"
required="required"
/>
</div>
</div>
<div class="form-group">
<label for="product_image" class="col-sm-4 control-label">Product Image</label>
<div class="col-sm-7">
<strong>600 w x 600 h</strong><br />
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
<?php if($product_image_url!=""){
$isImageRequired = '';
?>
<img data-src="" alt="..." src="<?php echo $product_image_url; ?>">
<?php } else { ?>
<img data-src="holder.js/100%x100%" alt="..." src="">
<?php } ?>
</div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;">
</div>
<div>
<span class="btn btn-default btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span><input type="file" name="product_image" id="product_image"<?php echo $isImageRequired; ?>></span>
<a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="product_desp" class="col-sm-4 control-label">Product Description</label>
<div class="col-sm-7">
<textarea rows="12" id="product_desp" name="product_desp" class="autogrow form-control transition-height" id="elastic-textarea"><?php echo $product_desp; ?></textarea>
</div>
</div>
<!--for supporting image document x3 upload image-->
<div class="form-group">
<label for="product_image" class="col-sm-4 control-label">Additional Product Image 1:</label>
<div class="col-sm-7">
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
<?php if($extra_image1_url!=""){
$isImageRequired = '';
?>
<img data-src="" alt="..." src="<?php echo $extra_image1_url; ?>">
<?php } else {
$isImageRequired = '';
?>
<img data-src="holder.js/100%x100%" alt="..." src="">
<?php } ?>
</div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;">
</div>
<div>
<span class="btn btn-default btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span><input type="file" name="extra_image1" id="extra_image1"<?php echo $isImageRequired; ?>></span>
<a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="product_image" class="col-sm-4 control-label">Additional Product Image 2:</label>
<div class="col-sm-7">
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
<?php if($extra_image2_url!=""){
$isImageRequired = '';
?>
<img data-src="" alt="..." src="<?php echo $extra_image2_url; ?>">
<?php } else {
$isImageRequired = '';
?>
<img data-src="holder.js/100%x100%" alt="..." src="">
<?php } ?>
</div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;">
</div>
<div>
<span class="btn btn-default btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span><input type="file" name="extra_image2" id="extra_image2"<?php echo $isImageRequired; ?>></span>
<a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
</div>
</div>
</div>
</div>
<div class="form-group">
<label for="product_image" class="col-sm-4 control-label">Additional Product Image 3:</label>
<div class="col-sm-7">
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="fileinput-new thumbnail" style="width: 200px; height: 150px;">
<?php if($extra_image3_url!=""){
$isImageRequired = '';
?>
<img data-src="" alt="..." src="<?php echo $extra_image3_url; ?>">
<?php } else {
$isImageRequired = '';
?>
<img data-src="holder.js/100%x100%" alt="..." src="">
<?php } ?>
</div>
<div class="fileinput-preview fileinput-exists thumbnail" style="max-width: 200px; max-height: 150px;">
</div>
<div>
<span class="btn btn-default btn-file"><span class="fileinput-new">Select image</span><span class="fileinput-exists">Change</span><input type="file" name="extra_image3" id="extra_image3"<?php echo $isImageRequired; ?>></span>
<a href="#" class="btn btn-default fileinput-exists" data-dismiss="fileinput">Remove</a>
</div>
</div>
</div>
</div>
<!--end for supporting image document x3 upload image-->
<div class="form-group">
<label for="meta_title" class="col-sm-4 control-label">Meta Title</label>
<div class="col-sm-7">
<input type="text" class="form-control" id="meta_title" name="meta_title"
value="<?php echo $meta_title; ?>"
autocomplete="off"
/>
</div>
</div>
<div class="form-group">
<label for="meta_keywords" class="col-sm-4 control-label">Meta Keywords</label>
<div class="col-sm-7">
<input type="text" class="form-control" id="meta_keywords" name="meta_keywords"
value="<?php echo $meta_keywords; ?>"
autocomplete="off"
/>
</div>
</div>
<div class="form-group">
<label for="meta_desp" class="col-sm-4 control-label">Meta Description</label>
<div class="col-sm-7">
<textarea rows="3" id="meta_desp" name="meta_desp" class="autogrow form-control transition-height" id="elastic-textarea"></textarea>
</div>
</div>
<div class="form-group">
<label for="publish" class="col-sm-4 control-label">Publish</label>
<div class="col-sm-7">
<div class="checkbox-inline">
<label for="publish">
<input type="checkbox" class="js-switch" id="publish" name="publish" <?php echo ($publish=='1')?'checked':''; ?> value="1">
</label>
</div>
</div>
</fieldset>
<div class="form-actions">
<div class="row">
<div class="col-sm-offset-4 col-sm-7">
<button type="submit" class="btn btn-primary">Save Changes</button>
<button type="button" class="btn btn-inverse" onClick="javascript:document.location.href='product.php';">Cancel</button>
</div>
</div>
</div>
</form>
</div>
</section>
</main>
</div>
<!--CONTENT END HERE-->
<!-- The Loader. Is shown when pjax happens -->
<div class="loader-wrap hiding hide">
<i class="fa fa-circle-o-notch fa-spin-fast"></i>
</div>
<!-- common libraries. required for every page-->
<script src="vendor/jquery/dist/jquery.min.js"></script>
<script src="vendor/jquery-pjax/jquery.pjax.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/transition.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/collapse.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/dropdown.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/button.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/tooltip.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/alert.js"></script>
<script src="vendor/jQuery-slimScroll/jquery.slimscroll.min.js"></script>
<script src="vendor/widgster/widgster.js"></script>
<script src="vendor/pace.js/pace.min.js"></script>
<script src="vendor/jquery-touchswipe/jquery.touchSwipe.js"></script>
<script src="vendor/jquery-touchswipe/jquery.touchSwipe.js"></script>
<!-- common app js -->
<script src="js/settings.js"></script>
<script src="js/app.js"></script>
<!-- page specific libs -->
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/tooltip.js"></script>
<script src="vendor/bootstrap-sass/vendor/assets/javascripts/bootstrap/modal.js"></script>
<script src="vendor/bootstrap-select/bootstrap-select.min.js"></script>
<script src="vendor/jquery-autosize/jquery.autosize.min.js"></script>
<script src="vendor/bootstrap3-wysihtml5/lib/js/wysihtml5-0.3.0.min.js"></script>
<script src="vendor/bootstrap3-wysihtml5/src/bootstrap3-wysihtml5.js"></script>
<script src="vendor/select2/select2.min.js"></script>
<script src="vendor/switchery/dist/switchery.min.js"></script>
<script src="vendor/moment/min/moment.min.js"></script>
<script src="vendor/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<script src="vendor/mjolnic-bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
<script src="vendor/jasny-bootstrap/js/inputmask.js"></script>
<script src="vendor/jasny-bootstrap/js/fileinput.js"></script>
<script src="vendor/holderjs/holder.js"></script>
<script src="vendor/dropzone/downloads/dropzone.min.js"></script>
<script src="vendor/markdown/lib/markdown.js"></script>
<script src="vendor/bootstrap-markdown/js/bootstrap-markdown.js"></script>
<script src="vendor/seiyria-bootstrap-slider/dist/bootstrap-slider.min.js"></script>
<script src="vendor/parsleyjs/dist/parsley.min.js"></script>
<!-- page specific js -->
<script type="text/javascript">
//var elem = document.querySelector('.js-switch');
//var init = new Switchery(elem);
var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
elems.forEach(function(html) {
var switchery = new Switchery(html);
});
</script>
<script src="js/form-validation.js"></script>
<script type="text/javascript">
function validChars(e, goods) {
var key, keychar;
key = (window.event) ? window.event.keyCode : ((e) ? e.which : null);
if (key == null) return true;
keychar = String.fromCharCode(key);
keychar = keychar.toLowerCase();
goods = goods.toLowerCase();
if (goods.indexOf(keychar) != -1)
return true;
if (key==null || key==0 || key==8 || key==9 || key==13 || key==27)
return true;
return false;
}
</script>
</body>
</html>