Preview: grocery-offer-page.php
Size: 24.52 KB
/home/godevadmin/public_html/admin/grocery-offer-page.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'){
$section_id=$_POST['section'];
$sql2d=$obj->query("select * from tbl_section where id='".$section_id."'");
$lined=$obj->fetchNextObject($sql2d);
$section_slug=$lined->section_slug;
$store_id=$_POST['store_id'];
$sql2dd=$obj->query("select * from stores where storeid='".$store_id."'");
$linedd=$obj->fetchNextObject($sql2dd);
$store_slug=$linedd->slug;
$status=$_POST['status'];
$display_order=$_POST['display_order'];
$link_type=$_POST['link_type'];
$title=$_POST['title'];
$subtitle=$_POST['subtitle'];
$bg_color=$_POST['bg_color'];
$btn_label=$_POST['btn_label'];
$btn_bg_color=$_POST['btn_bg_color'];
$btn_text_color=$_POST['btn_text_color'];
$post_url=$_POST['post_url'];
$pid=$_POST['pid'];
$is_nationwide=$_POST['is_nationwide'];
$display_page_secid=$_POST['display_page_secid'];
if($_FILES['fileImg']>0 && $_FILES['fileImg']['error']==''){
$Image= new SimpleImage();
$filename = $_FILES['fileImg']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$img=time()."-main-".$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("3.133.214.148") or die("Error in FTP connection - Live");
$login_status = ftp_login($conn_id, "[email protected]", "n3At8hv3LZKCiF6") or die("Error in FTP login - Live");
ftp_pasv($conn_id, true);
$destination_file = "upload_images/grocery-page-offer/".$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/grocery-page-offer/".$img);
}
else{
$img=$_POST['tempimg'];
}
if($_FILES['fileImgn']>0 && $_FILES['fileImgn']['error']==''){
$Image= new SimpleImage();
$filenamen = $_FILES['fileImgn']['name'];
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$imgn=time()."-mainapp-".$filenamen;
// 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("3.133.214.148") or die("Error in FTP connection - Live");
$login_status = ftp_login($conn_id, "[email protected]", "n3At8hv3LZKCiF6") or die("Error in FTP login - Live");
ftp_pasv($conn_id, true);
$destination_file = "upload_images/grocery-page-offer/".$imgn;
$upload_status = ftp_put($conn_id, $destination_file, $_FILES['fileImgn']['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/grocery-page-offer/".$imgn);
}
else{
$imgn=$_POST['tempimgn'];
}
if($_POST['id']=='')
{
$obj->query("insert into tbl_grocery_offer set photo='".$img."',mob_photo='".$imgn."',section_id='".$section_id."',section_slug='".$section_slug."',store_id='".$store_id."',store_slug='".$store_slug."',status='".$status."',is_nationwide='".$is_nationwide."',link_type='".$link_type."',title='".$title."',subtitle='".$subtitle."',bg_color='".$bg_color."',btn_label='".$btn_label."',btn_bg_color='".$btn_bg_color."',btn_text_color='".$btn_text_color."',post_url='".$post_url."',display_page_secid='".$display_page_secid."',display_order='".$display_order."',pid='".$pid."',created_at=now()");
$_SESSION['sess_msg']='Data added sucessfully';
}
else
{
$obj->query("update tbl_grocery_offer set photo='".$img."',mob_photo='".$imgn."',section_id='".$section_id."',section_slug='".$section_slug."',store_id='".$store_id."',store_slug='".$store_slug."',status='".$status."',is_nationwide='".$is_nationwide."',link_type='".$link_type."',title='".$title."',subtitle='".$subtitle."',bg_color='".$bg_color."',btn_label='".$btn_label."',btn_bg_color='".$btn_bg_color."',btn_text_color='".$btn_text_color."',post_url='".$post_url."',display_page_secid='".$display_page_secid."',display_order='".$display_order."',pid='".$pid."' where id='".$_POST['id']."'");
$_SESSION['sess_msg']='Data added sucessfully';
}
header("location:grocery-offer-page.php");
exit();
}
if(isset($_GET['delid']))
{
$obj->query("delete from tbl_grocery_offer where id='".$_GET['delid']."'");
$_SESSION['sess_msg']='Data deleted sucessfully';
header("location:grocery-offer-page.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" />
<style>
.external,.externallinnnk,.externalpro {
display:none;
}
.external.active,.externallinnnk.active {
display:table-row;
}
.externalpro.active {
display:table-row;
}
</style>
<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']))
{
$sql2ddd=$obj->query("select * from tbl_grocery_offer where id='".$_GET['id']."'");
$cardrow=$obj->fetchNextObject($sql2ddd);
}
?>
<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="id" value="<?=@$_GET['id']?>">
<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">Display ads on</td>
<td width="82%" align="left" class="paddBot11">
<select name="display_page_secid" id="display_page_secid" style="width: 14%;">
<option value="1" <?php if(@$cardrow->display_page_secid==1){ echo "selected"; } ?>>On Grocery listing page</option>
<option value="39" <?php if(@$cardrow->display_page_secid==39){ echo "selected"; } ?>>On Food listing page</option>
</select>
</td>
</tr>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Section</td>
<td width="82%" align="left" class="paddBot11">
<select name="section" id="sections_id" onchange="getStores(this.value)" style="width: 14%;" onchange="getStores(this.value);">
<option value="0">Select Section</option>
<?php
$sql2=$obj->query("select * from tbl_section where status=1");
while($line=$obj->fetchNextObject($sql2))
{
?>
<option value="<?=$line->id?>" <?php if(@$cardrow->section_id==$line->id){ echo "selected"; } ?>><?=$line->section_name?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Store</td>
<td width="82%" align="left" class="paddBot11">
<select name="store_id" id="stores_id" style="width: 14%;" >
<option value="0">Select Store</option>
<?php
$sql2dds=$obj->query("select * from stores where storeid='".$cardrow->store_id."'");
$linedds=$obj->fetchNextObject($sql2dds);
?>
<option value="<?=$linedds->storeid?>" <?php if($linedds->storeid!=0){ echo "selected"; } ?>><?=$linedds->storename?></option>
</select>
</td>
</tr>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Photo(450*250)</td>
<td width="82%" align="left" class="paddBot11">
<input type="file" name="fileImg" accept="image/png" <?php if($_GET['id']==""){ ?>required<?php } ?>>
</td>
</tr>
<?php
if(@$cardrow->photo!='')
{
?>
<tr>
<td></td>
<td> <img src="<?=$BASE_URL."/upload_images/grocery-page-offer/".@$cardrow->photo?>" style="width:100px; height:100px;float:left"></td>
<input type="hidden" name="tempimg" value="<?=$cardrow->photo?>">
</tr>
<?php
}
?>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Photo Mob(310*300)</td>
<td width="82%" align="left" class="paddBot11">
<input type="file" name="fileImgn" accept="image/png" <?php if($_GET['id']==""){ ?>required<?php } ?>>
</td>
</tr>
<?php
if(@$cardrow->mob_photo!='')
{
?>
<tr>
<td></td>
<td> <img src="<?=$BASE_URL."/upload_images/grocery-page-offer/".@$cardrow->mob_photo?>" style="width:100px; height:100px;float:left"></td>
<input type="hidden" name="tempimgn" value="<?=$cardrow->mob_photo?>">
</tr>
<?php
}
?>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14">Main Heading</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 Heading</td>
<td width="82%" align="left" class="paddBot11">
<input type="text" name="subtitle" value="<?=$cardrow->subtitle?>" required>
</td>
</tr>
<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">Background color</td>
<td width="82%" align="left" class="paddBot11">
<input type="text" name="bg_color" value="<?=$cardrow->bg_color?>" required>
</td>
</tr>
<tr >
<td width="18%" align="right" class="paddBot11 paddRt14"> Link Type</td>
<td width="82%" align="left" class="paddBot11">
<select name="link_type" onchange="linktype(this)" required>
<option value="">Select Link Type</option>
<option value="No Link" <?php if(@$cardrow->link_type=='No Link'){ echo "selected"; } ?>>No Link</option>
<option value="External" <?php if(@$cardrow->link_type=='External'){ echo "selected"; } ?>>External</option>
<option value="Store Page" <?php if(@$cardrow->link_type=='Store Page'){ echo "selected"; } ?>>Store Page</option>
<option value="Section Page" <?php if(@$cardrow->link_type=='Section Page'){ echo "selected"; } ?>>Section Page</option>
<option value="Product Page" <?php if(@$cardrow->link_type=='Product Page'){ echo "selected"; } ?>>Product Page</option>
</select>
</td>
</tr>
<tr class="externalpro <?php if(@$cardrow->link_type=='Product Page'){ echo "active"; } ?>">
<td width="18%" align="right" class="paddBot11 paddRt14">Product ID</td>
<td width="82%" align="left" class="paddBot11">
<input type="text" name="pid" value="<?=$cardrow->pid?>">
</td>
</tr>
<tr class="externallinnnk <?php if(@$cardrow->link_type=='External'){ echo "active"; } ?>">
<td width="18%" align="right" class="paddBot11 paddRt14">External Link</td>
<td width="82%" align="left" class="paddBot11">
<input type="text" name="post_url" value="<?=$cardrow->post_url?>">
</td>
</tr>
<tr class="external">
<td width="18%" align="right" class="paddBot11 paddRt14"> Button Label</td>
<td width="82%" align="left" class="paddBot11">
<input type="text" name="btn_label" value="<?=$cardrow->btn_label?>">
</td>
</tr>
<tr class="external">
<td width="18%" align="right" class="paddBot11 paddRt14"> Button Background color</td>
<td width="82%" align="left" class="paddBot11">
<input type="text" name="btn_bg_color" value="<?=$cardrow->btn_bg_color?>">
</td>
</tr>
<tr class="external">
<td width="18%" align="right" class="paddBot11 paddRt14"> Button Text color</td>
<td width="82%" align="left" class="paddBot11">
<input type="text" name="btn_text_color" value="<?=$cardrow->btn_text_color?>">
</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">Is nationwide</td>
<td width="82%" align="left" class="paddBot11">
<select name="is_nationwide" required>
<option value="">Select type</option>
<option value="1" <?php if(@$cardrow->is_nationwide==1){ echo "selected"; } ?>>Yes</option>
<option value="0" <?php if(@$cardrow->is_nationwide==0){ echo "selected"; } ?>>No</option>
</select>
</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 tbl_grocery_offer");
$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>Section</strong></td>
<td width="5%" align="center" bgcolor="#f3f4f6" class="padd5"><strong>Store</strong></td>
<td width="8%" align="left" bgcolor="#f3f4f6" class="padd5"><strong>Photo</strong></td>
<td width="8%" align="left" bgcolor="#f3f4f6" class="padd5"><strong>Title</strong></td>
<td width="8%" align="left" bgcolor="#f3f4f6" class="padd5"><strong>Display On</strong></td>
<td width="8%" align="left" bgcolor="#f3f4f6" class="padd5"><strong>Link On</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>
</tr>
<?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; ?>.</strong></td>
<td class="padd5"><?php echo $line->section_slug; ?></td>
<td class="padd5">
<?php
$sql2dd=$obj->query("select * from stores where storeid='".$line->store_id."'");
$linedd=$obj->fetchNextObject($sql2dd);
echo $linedd->storename;
?>
</td>
<td class="padd5">
<?php
if($line->photo!='')
{
?>
<img src="<?=$BASE_URL."/upload_images/grocery-page-offer/".$line->photo?>" style="width:50%;">
<?php
}
?>
</td>
<td class="padd5"><?php if($line->title){ echo "<span style='color:black;'>".$line->title."</span>"; } ?></td>
<td class="padd5"><?php if($line->display_page_secid==1){ echo "<span style='color:green;'>Grocery Landing Page</span>"; }else{ echo "<span style='color:green;'>Food Landing Page</span>"; } ?></td>
<td class="padd5"><?php if($line->link_type){ echo "<span style='color:black;'>".$line->link_type."</span>"; } ?></td>
<td class="padd5"><?php if($line->status==1){ echo "<span style='color:green;'>Active</span>"; }else{ echo "<span style='color:red;'>Deactive</span>"; } ?></td>
<td class="padd5"><a href="?delid=<?=$line->id?>" style="color: red;" onclick="return confirm('Are you sure?')">Delete</a> / <a href="?id=<?=$line->id?>">Edit</a> </td>
</tr>
<?php
}
?>
</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 getStores(section_id)
{
$.ajax({
url: 'ajax-get-store.php',
type: 'post',
data: { "sectionid": section_id},
success: function(response) {
$("#stores_id").html(response);
}
});
}
function linktype(INK){
if($(INK).val()=='External'){
$('.externallinnnk').addClass('active');
} else {
$('.externallinnnk').removeClass('active');
}
if($(INK).val()=='No Link'){
$('.external').addClass('active');
} else {
$('.external').removeClass('active');
}
if($(INK).val()=='Product Page'){
$('.externalpro').addClass('active');
} else {
$('.externalpro').removeClass('active');
}
}
</script>
</table>
</body>
</html>
Directory Contents
Dirs: 10 × Files: 414