Preview: home-page-settings.php
Size: 24.37 KB
/home/godevadmin/public_html/admin/home-page-settings.php
<?php
session_start();
include("../include/config.php");
include("../include/simpleimage.php");
include("../include/functions.php");
//$BASE_URL = 'https://www.dev.goquicklly.com';
$BASE_URL ='https://www.quicklly.com';
validate_admin();
if($_REQUEST['submitForm']=='yes'){
$id=$_POST['id'];
$sec_type=$_POST['sec_type'];
$sections=$_POST['sections'];
$arr=explode(",",$sections);
$section='';
$slug='';
$cateid='';
if($arr[0]!='')
{
if($arr[0]=="might-also")
{
$section='';
$slug="might-also";
$cateid="";
}
else if($arr[0]=="popular")
{
$section='';
$slug="popular";
$cateid="";
}
else if($arr[0]=="buy-it-again")
{
$section='';
$slug="buy-it-again";
$cateid="";
}
else if($arr[0]=="deals")
{
$section='';
$slug="deals";
$cateid="";
}
}
$section_id=$_POST['section_id'];
if($section_id!='')
{
if($section_id=="Fresh Produce")
{
$section=1;
$slug="grocery";
$cateid="4337";
}
else if($section_id=="Meat and Poultry")
{
$section=1;
$slug="grocery";
$cateid="4320";
}
else if($section_id=="17")
{
$section=17;
$slug="sweet-snacks-list";
$cateid="";
}
else
{
$secArr=$obj->query("SELECT id, section_name,section_slug FROM tbl_section where id='".$section_id."'ORDER by section_name");
$sec=$obj->fetchNextObject($secArr);
$section=$section_id;
$slug=$sec->section_slug;
$cateid="";
}
}
$title=mysqli_real_escape_string($GLOBALS['conn'],$_POST['title']);
$sub_title=mysqli_real_escape_string($GLOBALS['conn'],$_POST['sub_title']);
$display_order=$_POST['display_order'];
$status=$_POST['status'];
$bgcolor=$_POST['bgcolor'];
$store_id=$_POST['store_id'];
if($_FILES['fileImg']>0 && $_FILES['fileImg']['error']==''){
$Image= new SimpleImage();
$filename = $_FILES['fileImg']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$img=time()."-".$filename;
// Upload to main website FTP
$url = SITE_URL;
if($url ==MAINSITE_URL || $url==DEVSITE_URL ||
$url==UATSITE_URL){
if($url ==MAINSITE_URL){
$conn_id = ftp_connect("quicklly.com") or die("Error in FTP connection - Live");
$login_status = ftp_login($conn_id, "[email protected]", "n3At8hv3LZKCiF6") or die("Error in FTP login - Live");
}
else {
$conn_id = ftp_connect("92.204.135.155") or die("Error in FTP connection");
ftp_pasv($conn_id, true);
if($url==UATSITE_URL)
$login_status = ftp_login($conn_id, "devgoquicklly", "7ZcS58nmn_MH31") or die("Error in FTP login");
else
$login_status = ftp_login($conn_id, "[email protected]", "1}PG%zK}Ymvi") or die("Error in FTP login");
}
$destination_file = "upload_images/prods-deals/".$img;
$upload_status = ftp_put($conn_id, $destination_file, $_FILES['fileImg']['tmp_name'], FTP_BINARY);
if (!$upload_status)
echo "Something went wrong, Contact to site administrator.";
ftp_close($conn_id);
}
// Upload locally to admin
move_uploaded_file($_FILES['fileImg']['tmp_name'],"../upload_images/prods-deals/".$img);
//$Image->load("../upload_images/prods-deals/".$img);
//$Image->resize(300,300);
//$Image->save("../upload_images/prods-deals/".$img);
//CompressImage('../upload_images/prods-deals/'.$img, '../upload_images/prods-deals/'.$img, 50);
$img = 'upload_images/prods-deals/' . $img;
}
else
{
$img=$_POST['img_tmp'];
}
if($id=='')
{
$obj->query("insert into home_page_setting set sec_type='".$sec_type."',title='".$title."',sub_title='".$sub_title."',cat_id='".@$cateid."',sec_id='".$section."',section_slug='".$slug."',
display_order='".$display_order."',photo='$img',status='".$status."',bgcolor='".$bgcolor."',sectionType='".$_POST['sectionType']."',display_page='".$_POST['display_page']."',store_id='$store_id',created_at=now(),updated_at=now()");
$_SESSION['sess_msg']='Data added sucessfully';
}
else
{
$obj->query("update home_page_setting set sec_type='".$sec_type."',title='".$title."',sub_title='".$sub_title."',cat_id='".@$cateid."',sec_id='".$section."',section_slug='".@$slug."',
display_order='".$display_order."',photo='$img',status='".$status."',bgcolor='".$bgcolor."',sectionType='".$_POST['sectionType']."',display_page='".$_POST['display_page']."',store_id='$store_id',updated_at=now() where id='$id'");
$_SESSION['sess_msg']='Data updated sucessfully';
}
header("location:home-page-settings.php");
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SITE_TITLE; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/admin.css" rel="stylesheet" type="text/css" />
<script>
function checkall(objForm)
{
len = objForm.elements.length;
var i=0;
for( i=0 ; i<len ; i++){
if (objForm.elements[i].type=='checkbox')
objForm.elements[i].checked=objForm.check_all.checked;
}
}
function del_prompt(frmobj,comb)
{
//alert(comb);
if(comb=='Delete'){
if(confirm ("Are you sure you want to delete record(s)"))
{
frmobj.action = "home-page-del.php";
frmobj.what.value="Delete";
frmobj.submit();
}
else{
return false;
}
}
else if(comb=='Deactivate'){
frmobj.action = "home-page-del.php";
frmobj.what.value="Deactivate";
frmobj.submit();
}
else if(comb=='Activate'){
frmobj.action = "home-page-del.php";
frmobj.what.value="Activate";
frmobj.submit();
}
}
</script>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<?php include("header.php");
if(isset($_GET['id']))
{
$cardsname = $obj->query("SELECT * FROM home_page_setting where id='".$_GET['id']."'");
$cardrow = $obj->fetchNextObject($cardsname);
}
?>
<tr>
<td align="right" class="paddRtLt70" valign="top">
<table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="right" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<!------------ Search Section ----------------->
<tr>
<td align="left" valign="middle" class="bodr" style="padding-bottom:20px;">
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr><td height="10"></td></tr>
<tr>
<td>
<td height="100" align="left" valign="top" bgcolor="#f3f4f6" class="bodr">
<form name="frm" method="POST" enctype="multipart/form-data" action="">
<input type="hidden" name="submitForm" value="yes" />
<input type="hidden" name="display_page" value="2">
<input type="hidden" name="id" value="<?php echo $_REQUEST['id'];?>" />
<input type="hidden" name="img_tmp" value="<?=@$cardrow->photo?>">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center" colspan="2" class="paddRt14 paddBot11">
<font color="#FF0000"><strong><?php echo $_SESSION['sess_msg']; $_SESSION['sess_msg']='';?></strong></font></td>
</tr>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Section Type</td>
<td width="82%" align="left" class="paddBot11">
<select class="form-control" name="sectionType" required>
<option value="">--Select--</option>
<option value="slider" <?php if(@$cardrow->sectionType=="slider"){ echo "selected"; } ?>>Slider Display</option>
<option value="banner" <?php if(@$cardrow->sectionType=="banner"){ echo "selected"; } ?>>Banner Display</option>
<option value="stores" <?php if(@$cardrow->sectionType=="stores"){ echo "selected"; } ?>>Stores Display</option>
</select>
</td>
</tr>
<tr>
<td width="18%" align="right" class="paddBot11 paddRt14"> Data Type:</td>
<td width="82%" align="left" class="paddBot11">
<select name="sec_type" id="source_id" required onchange="get_type(this.value)">
<option value="">Select Type</option>
<option value="predefined" <?php if(@$cardrow->sec_type=="predefined"){ echo "selected"; } ?>>Predefined</option>
<option value="custom" <?php if(@$cardrow->sec_type=="custom"){ echo "selected"; } ?>>Custom</option>
</select>
</td>
</tr>
<tr <?php if(@$cardrow->sec_type=="predefined") {?>style=""<?php }else{ ?>style="display:none;"<?php } ?> id="type">
<td width="18%" align="right" class="paddBot11 paddRt14"> Predefined List</td>
<td width="82%" align="left" class="paddBot11">
<select name="sections" id="sections">
<option value="">Select Type</option>
<option value="buy-it-again,buy-it-again,buy-it-again" <?php if(@$cardrow->section_slug=="buy-it-again"){ echo "selected"; }?>>Buy it again</option>
<option value="deals,deals,deals" <?php if(@$cardrow->section_slug=="deals"){ echo "selected"; }?>>Deals</option>
<option value="might-also,might-also,might-also" <?php if(@$cardrow->section_slug=="might-also"){ echo "selected"; }?>>Might also like products</option>
<option value="popular,popular,popular" <?php if(@$cardrow->section_slug=="popular"){ echo "selected"; }?>>Popular in your area products</option>
</select>
</td>
</tr>
<tr <?php if(@$cardrow->sec_type=="custom") {?>style=""<?php }else{ ?>style="display:none;"<?php } ?> id="section_id">
<td width="18%" align="right" class="paddBot11 paddRt14"> Section</td>
<td width="82%" align="left" class="paddBot11">
<select name="section_id" id="sections_id" onchange="getStores(this.value);">
<option value="">Select Section</option>
<option value="Fresh Produce" <?php if(@$cardrow->cat_id=="4337"){ echo "selected"; } ?>>Fresh Produce</option>
<option value="Meat and Poultry" <?php if(@$cardrow->cat_id=="4320"){ echo "selected"; } ?>>Meat and Poultry</option>
<?php
$sql2=$obj->query("select * from tbl_section where status=1");
while($line=$obj->fetchNextObject($sql))
{
?>
<option value="<?=$line->id?>" <?php if($cardrow->sec_id==$line->id and $cardrow->cat_id==''){ echo "selected"; } ?>><?=$line->section_name?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr <?php if(@$cardrow->sec_type=="custom") {?>style=""<?php }else{ ?>style="display:none;"<?php } ?> id="store_id">
<td width="18%" align="right" class="paddBot11 paddRt14"> Store</td>
<td width="82%" align="left" class="paddBot11">
<select name="store_id" id="stores_id" >
<option value="">Select Store</option>
<?php
$storesArr=$obj->query("SELECT storeid, storename FROM stores where storeid='".@$cardrow->store_id."' ORDER BY sectionid, storename");
while($store=$obj->fetchNextObject($storesArr)){
?>
<option value="<?=$store->storeid?>" selected><?=$store->storename?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Title</td>
<td width="82%" align="left" class="paddBot11">
<input type="text" name="title" value="<?=@$cardrow->title?>" required>
</td>
</tr>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Sub Title</td>
<td width="82%" align="left" class="paddBot11">
<input type="text" name="sub_title" value="<?=@$cardrow->sub_title?>" >
</td>
</tr>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Photo</td>
<td width="82%" align="left" class="paddBot11">
<input type="file" name="fileImg" accept="image/png" >
</td>
</tr>
<?php
if(@$cardrow->photo!='')
{
?>
<tr>
<td></td>
<td> <img src="<?=$BASE_URL."/".@$cardrow->photo?>" style="width:100px; height:100px;float:left"></td>
</tr>
<?php
}
?>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Display Order</td>
<td width="82%" align="left" class="paddBot11">
<input type="number" name="display_order" value="<?=@$cardrow->display_order?>" required>
</td>
</tr>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Status</td>
<td width="82%" align="left" class="paddBot11">
<select name="status" required>
<option value="">Select Status</option>
<option value="1" <?php if(@$cardrow->status=="1"){ echo "selected"; } ?>>Active</option>
<option value="0" <?php if(@$cardrow->status=="0"){ echo "selected"; } ?>>Deactive</option>
</select>
</td>
</tr>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Section Color</td>
<td width="82%" align="left" class="paddBot11">
<input type="color" name="bgcolor" value="<?=@$cardrow->bgcolor?>" required>
</td>
</tr>
<tr>
<td width="18%" align="right" class="paddRt14 paddBot11"> </td>
<td width="82%" align="left" class="paddBot11">
<input type="submit" name="submit" value="Submit" class="submit" border="0"/>
<input name="Reset" type="reset" id="Reset" value="Reset" class="submit" border="0" /></td>
</tr>
</table></form>
</td>
</td>
</tr>
</table>
</td>
</tr>
<tr><td height="10"></td></tr>
<!----- Search End --------->
<tr>
<td align="left" valign="middle" class="headingbg bodr text14">
<em><img src="images/arrow2.gif" width="21" height="21" hspace="10" align="absmiddle" /></em>
<span style="float:right; padding-right:10px;">
</span>
</td>
</tr>
<form name="frm" method="post" action="#" enctype="multipart/form-data">
<tr>
<td height="100" align="left" valign="top" bgcolor="#FFFFFF" class="bodr">
<table width="100%" cellpadding="0" cellspacing="0">
<?php if($_SESSION['sess_msg']){ ?>
<tr><td align="center"><font color="#FF0000"><strong><?php echo $_SESSION['sess_msg'];$_SESSION['sess_msg']='';?></strong></font></td></tr>
<?php }?>
<tr>
<td align="left">
<?php
$sql2=$obj->query("select * from home_page_setting where display_page='2' order by display_order");
$reccnt=$obj->numRows($sql2);
if($reccnt==0)
{
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="middle"><font face="Arial, Helvetica, sans-serif" color="#FF0000" size="+1">No Record</font></td>
</tr>
</table>
<?php
}
else
{
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td align="center" colspan="15"><strong><?php echo $reccnt; ?> Record Found.</strong></td></tr>
<tr>
<td width="2%" align="left" class="padd5" bgcolor="#f3f4f6"><strong>S No.</strong></td>
<td width="2%" align="left" class="padd5" bgcolor="#f3f4f6"><strong>Display Order</strong></td>
<td width="2%" align="left" class="padd5" bgcolor="#f3f4f6"><strong>Section Type</strong></td>
<td width="5%" align="left" class="padd5" bgcolor="#f3f4f6"><strong>Data Type</strong></td>
<td width="5%" align="center" bgcolor="#f3f4f6" class="padd5"><strong>Title</strong></td>
<td width="10%" align="center" bgcolor="#f3f4f6" class="padd5"><strong>Sub Title</strong></td>
<td width="8%" align="left" bgcolor="#f3f4f6" class="padd5"><strong>Photo</strong></td>
<td width="9%" align="center" bgcolor="#f3f4f6" class="padd5"><strong>Manage Product</strong></td>
<td width="9%" align="center" bgcolor="#f3f4f6" class="padd5"><strong>Status</strong></td>
<td width="4%" align="center" class="padd5" bgcolor="#f3f4f6"><strong>Action</strong></td>
<td width="14%" align="center" bgcolor="#f3f4f6" class="padd5" > <input name="check_all" type="checkbox" id="check_all" onclick="checkall(this.form)" value="check_all" /></td>
</tr><form method="post">
<?php
$i=0;
while($line=$obj->fetchNextObject($sql2))
{
$i++;
if($i%2==0)
{
$bgcolor = "#f3f4f6";
}
else
{
$bgcolor = "";
}
?>
<tr bgcolor="<?php echo $bgcolor;?>">
<td class="padd5"><strong><?php echo $i+$start; ?>.</strong></td>
<td class="padd5"><input type="text" name="display_order[<?php echo $i; ?>]" value="<?php echo $line->display_order; ?>"> <input type="hidden" value="<?=$line->id?>" name="id[<?php echo $i; ?>]"> </td> <td class="padd5"><?php echo $line->sectionType; ?></td>
<td class="padd5"><?php echo $line->sec_type; ?></td>
<td class="padd5"><?php echo $line->title; ?></td>
<td class="padd5"><?php echo $line->sub_title; ?></td>
<td class="padd5">
<?php
if($line->photo!='')
{
?>
<img src="<?=$BASE_URL."/".$line->photo?>" style="width:100px; height:100px;">
<?php
}
?>
</td>
<td align="center" valign="middle" class="padd5"><?php if($line->sec_type=="custom" AND $line->sectionType=="slider"){ ?><a href='home-page-custom-prods.php?id=<?php echo $line->id;?>'>Manage Product</a><?php } ?></td>
<td align="center" valign="middle" class="padd5">
<?php if($line->status==1){?><img src="images/enable.gif" border="0" title="Activated" /> <?php } else{ ?><img src="images/disable.gif" border="0" title="Deactivated" /><?php }?> </td>
<td align="center" valign="middle" class="padd5">
<a href="home-page-settings.php?id=<?php echo $line->id;?>" ><img src="images/edit3.gif" border="0" title="Edit" /></a><br/>
</td>
<td align="center" valign="middle" class="padd5">
<input type="checkbox" name="ids[]" value="<?php echo $line->id;?>" /> </td>
</tr>
<?php
}
?> <tr></tr> <tr> <td colspan="5"><button class="button" type="submit">Change Display Order</button></td> </tr></form>
<tr>
<td valign="top" colspan="15" align="right"> </td> </tr>
<tr>
<td valign="top" colspan="15" align="right" class="dark_red" style="padding-right:150px;"><?php include("../include/paging.inc.php"); ?></td> </tr>
<tr>
<td align="right" style="padding-right:80px;" colspan="15"> </td>
</tr>
<tr>
<td align="right" style="padding-right:80px;" colspan="15"> </td>
</tr>
<tr><td align="right" style="padding-right:80px;" colspan="15"> <input type="hidden" name="what" value="what" />
<input type="submit" name="Submit" value="Activate" class="button" onclick="return del_prompt(this.form,this.value)" />
<input type="submit" name="Submit" value="Deactivate" class="button" onclick="return del_prompt(this.form,this.value)" />
<input type="submit" name="Submit" value="Delete" class="button" onclick="return del_prompt(this.form,this.value)" /></td></tr>
</table>
<?php }?>
</td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr><td height="100"></td></tr>
<?php include('footer.php'); ?>
<script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
function get_type(a)
{
if(a=='predefined'){
$("#type").show();
$("#sections").prop('required',true);
$("#section_id").hide();
$("#store_id").hide();
}else
{
$("#sections").prop('required',false);
$("#type").hide();
$("#section_id").show();
$("#store_id").show();
}
}
function getStores(section_id)
{
$.ajax({
url: 'ajax-get-store.php',
type: 'post',
data: { "sectionid": section_id},
success: function(response) {
$("#stores_id").html(response);
}
});
}
</script>
</table>
</body>
</html>
Directory Contents
Dirs: 10 × Files: 414