Example #1
0
    print getUser();
}
?>
			</p>
		</div>

		<div id="header">
			<h1 id="title">Editing <?php 
print getPage();
?>
</h1>
		</div>

		<div id="form">
			<form method="post" action="<?php 
print getPostURL();
?>
">
				<p><textarea name="data" cols="80" rows="20" style="width: 100%"><?php 
print getRawData();
?>
</textarea></p>
				<p><input type="submit" value="publish" /></p>
			</form>
		</div>

		<div id="footer" style='text-align: left;'>
			<p class='syntax'>
				<span style='font-weight: bold;'>Syntax:</span> Besides normal HTML
				code (e.g. <code>&lt;b&gt;Bold&lt;/b&gt;</code>), the following 
				markup is available as well:
    function productview($pid)
    {
        function currenturl()
        {
            $_SESSION['curr_url'] = $_SERVER["REQUEST_URI"];
        }
        ?>
		<script type="text/javascript" src="components/com_dealcatalog/js/jquery1.7.js"></script>
		<script type="text/javascript" src="components/com_dealcatalog/js/jquery.fancybox.js"></script>		
		<link rel="stylesheet" type="text/css" href="components/com_dealcatalog/js/jquery.fancybox.css" media="screen" />
		<script type="text/javascript">
			$(document).ready(function() {
				$(".fancybox").fancybox();
			});
		</script>
		<script language="javascript" type="text/javascript">
			function sent_coupon()
			{
				document.coupon.submit();
			}
			function current_url()
			{
				b = "<?php 
        currenturl();
        ?>
";
			}
		</script>
		<?php 
        $user =& JFactory::getUser();
        $userid = $user->id;
        $username = $user->name;
        $useremail = $user->email;
        $db =& JFactory::getDBO();
        $today_date = date('Y-m-d');
        $query = "select a.*,b.product_name,b.product_code,b.product_image1,b.product_thumbimage1,b.product_desc,c.category_name,d.manufacturer_name,e.company_name,e.address1,e.address2,e.email_id,e.Contact_number,e.city,e.states,e.location_map from #__deal_productslisting_deals as a,#__deal_products as b,#__deal_productcategories as c,#__deal_manufacturer as d,#__deal_merchants as e where a.id='{$pid}' and a.stock_in='1' and a.product_id=b.id and b.category_id=c.id and b.manufacturer_id=d.id and a.vendor_id=e.id and a.listingstart_date <= '{$today_date}' and a.listingend_date >= '{$today_date}'";
        $db->setQuery($query);
        $product = $db->loadAssocList();
        foreach ($product as $row) {
            //values of product list
            $productlistid = $row['id'];
            $product_id = $row['product_id'];
            $vendor_id = $row['vendor_id'];
            $product_name = $row['product_name'];
            $product_code = $row['product_code'];
            $category = $row['category_name'];
            $manufacturer = $row['manufacturer_name'];
            $company = $row['company_name'];
            $address = $row['address1'] . " " . $row['address2'] . " , " . $row['city'] . " " . $row['states'];
            $contact_number = $row['Contact_number'];
            $email = $row['email_id'];
            $location = $row['location_map'];
            $price = $row['price'];
            $discount_price = $row['discount_price'];
            $product_close = $row['listingend_date'];
            $isdeal = $row['is_deal'];
            $deal_price = $row['deal_price'];
            $dealstart = $row['dealstart_date'];
            $dealclose = $row['dealend_date'];
            $product_desc = $row['product_desc'];
            $merchant_desc = $row['merchantproduct_desc'];
            $pimage = $row['product_image1'];
            $pimage1 = $row['product_thumbimage1'];
            $merchantimage = $row['merchantproduct_image1'];
            $merchantimage1 = $row['merchantproduct_thumbimage1'];
            //Product Image
            if ($merchantimage != '') {
                $image = substr($merchantimage, 3);
                $thumb_image = substr($merchantimage1, 3);
            } else {
                $image = substr($pimage, 3);
                $thumb_image = substr($pimage1, 3);
            }
            //Product Description
            if ($merchant_desc != '') {
                $desc = $merchant_desc;
            } else {
                $desc = $product_desc;
            }
            //Price difference
            if ($deal_price != 0.0) {
                $deal = $price - $deal_price;
            } else {
                $deal = 0.0;
            }
            if ($discount_price != 0.0) {
                $discount = $price - $discount_price;
            } else {
                $discount = 0.0;
            }
            //Deal and Discount percentage
            if ($deal_price != 0.0) {
                $per = $price - $deal_price;
                $per = $per / $price * 100;
                $per = round($per, 2);
                $per = $per . "%";
            } else {
                $per = "0%";
            }
            if ($discount_price != 0.0) {
                $per1 = $price - $discount_price;
                $per1 = $per1 / $price * 100;
                $per1 = round($per1, 2);
                $per1 = $per1 . "%";
            } else {
                $per1 = "0%";
            }
            //date comparison
            $today = strtotime($today_date);
            $dealstarts = strtotime($dealstart);
            $dealends = strtotime($dealclose);
            //Facebook Code
            function getPostURL()
            {
                $postURL = 'http';
                if ($_SERVER["HTTPS"] == "on") {
                    $postURL .= "s";
                }
                $postURL .= "://";
                if ($_SERVER["SERVER_PORT"] != "80") {
                    $postURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
                } else {
                    $postURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
                }
                return $postURL;
            }
            $postURL = getPostURL();
            //Coupon code
            $query = "select coupon_code from #__deal_coupons where users_userid='{$userid}' and product_id='{$product_id}'";
            $db->setQuery($query);
            $copon = $db->loadRow();
            $codes = $copon[0];
            if ($codes != '') {
                $coupon = $codes;
            } else {
                $characters = '5';
                $possible = '23456789bcdfghjkmnpqrstvwxyzBCDEFGHIJKLMNPQURSTUVWXYZ';
                $code = '';
                $i = 0;
                while ($i < $characters) {
                    $code .= substr($possible, mt_rand(0, strlen($possible) - 1), 1);
                    $i++;
                }
                $coupon = $code;
            }
            //product count
            $query = "select product_viewcount from #__deal_productcounts where product_id='{$product_id}' and vendor_id='{$vendor_id}'";
            $db->setQuery($query);
            $ct = $db->loadRow();
            $cts = $ct[0];
            if ($cts == 0) {
                $cts = $cts + 1;
                $query = "insert into #__deal_productcounts (`product_id`, `vendor_id`, `product_viewcount`, `product_couponcount`) values ('{$product_id}', '{$vendor_id}', '{$cts}', '')";
                $db->setQuery($query);
                $db->query();
            } else {
                $cts = $cts + 1;
                $query = "update #__deal_productcounts set `product_viewcount`='{$cts}' where product_id='{$product_id}' and vendor_id='{$vendor_id}'";
                $db->setQuery($query);
                $db->query();
            }
            ?>
			<div id="single_product">
				<div id="product_head">
					<div class="head1">
						<div class="head_text"> Customer Choice </div>
						<div class="choice"> <img src="components/com_dealcatalog/icon_7.png"> </div> 
						<div class="choice_image"> <img src="<?php 
            echo $thumb_image;
            ?>
">  </div> 
					</div>
					<div class="head2">
						<div> <b> <h2> <?php 
            echo $product_name;
            ?>
 </h2> </b> </div>
						<div> Checkout this product with  <b> Deal </b> or <b> Discount </b> price and signup to get if Deal Coupon code exits</div>
					</div>
				</div>
				<div class="back1">
					<a href="javascript:history.back()">Go back</a> 
				</div>
				<div class="back">
					<a href='index.php?option=com_dealcatalog&task=productslisting&Itemid=<?php 
            echo $_REQUEST['Itemid'];
            ?>
'> View Product Listings </a>
				</div>
				<div class="phead">
					<?php 
            if ($isdeal == 1 && ($dealstarts <= $today && $dealends >= $today) && $deal > $discount) {
                ?>
						<h2> <?php 
                echo $product_name;
                ?>
  <?php 
                echo $per;
                ?>
 Deal off from <?php 
                echo $company;
                ?>
 </h2>
					<?php 
            } else {
                if ($deal == 0 && $discount == 0.0) {
                    ?>
							<h2> <?php 
                    echo $product_name;
                    ?>
  from <?php 
                    echo $company;
                    ?>
 </h2>
						<?php 
                } else {
                    ?>
							<h2> <?php 
                    echo $product_name;
                    ?>
  <?php 
                    echo $per1;
                    ?>
 Discount off from <?php 
                    echo $company;
                    ?>
 </h2>
						<?php 
                }
            }
            ?>
				</div>
				<div id="image_fb">
					<div class="big_image">
						<a class="fancybox" href="<?php 
            echo $image;
            ?>
" title="<?php 
            echo $product_name;
            ?>
">
							<img src="<?php 
            echo $thumb_image;
            ?>
" />
						</a>
					</div>
					<div class="fb_like">
						<?php 
            echo '<iframe src="http://www.facebook.com/widgets/like.php?href=' . $postURL . '"
								scrolling="no" frameborder="0"
								style="border:none; width:450px; height:40px"></iframe>';
            ?>
					</div>
					<?php 
            if ($isdeal == 1 && ($dealstarts <= $today && $dealends >= $today)) {
                ?>
						<div id="coupon">
							<?php 
                if ($userid == 0) {
                    ?>
									Coupon Code &nbsp;&nbsp; <a class="fancybox" href="#customerlogin" title="Customer Login"> Login </a>&nbsp; / &nbsp;&nbsp;&nbsp;<a href="index.php?option=com_dealcatalog&task=customerregister&Itemid=<?php 
                    echo $_REQUEST['Itemid'];
                    ?>
" onClick="current_url();"> Register </a>
									<div id="customerlogin" style="display:none;">
										<?php 
                    $document =& JFactory::getDocument();
                    $renderer = $document->loadRenderer('modules');
                    $options = array('style' => 'xhtml');
                    $position = 'customerlogin';
                    echo $renderer->render($position, $options, null);
                    ?>
									 </div>
									<?php 
                } else {
                    ?>
									<form name="coupon" action="index.php?option=com_dealcatalog&task=coupon_email&Itemid=<?php 
                    echo $_REQUEST['Itemid'];
                    ?>
" method="post">
										<?php 
                    if ($codes != '') {
                        ?>
											<span class="coupon_text" onClick="sent_coupon();"> Sent the Coupon code again </span>
											<?php 
                    } else {
                        ?>
											<span class="coupon_text" onClick="sent_coupon();"> Email the Coupon Code </span>
											<?php 
                    }
                    ?>
										<input type="hidden" name="action" value="<?php 
                    echo $_SERVER["REQUEST_URI"];
                    ?>
">
										<input type="hidden" name="customername" value="<?php 
                    echo $username;
                    ?>
">
										<input type="hidden" name="customeremail" value="<?php 
                    echo $useremail;
                    ?>
">
										<input type="hidden" name="couponcode" value="<?php 
                    echo $coupon;
                    ?>
">
										<input type="hidden" name="vendorcompany" value="<?php 
                    echo $company;
                    ?>
">
										<input type="hidden" name="vendoremail" value="<?php 
                    echo $email;
                    ?>
">
										<input type="hidden" name="productname" value="<?php 
                    echo $product_name;
                    ?>
">
										<input type="hidden" name="vendor_id" value="<?php 
                    echo $vendor_id;
                    ?>
">
										<input type="hidden" name="product_id" value="<?php 
                    echo $product_id;
                    ?>
">
										<input type="hidden" name="users_userid" value="<?php 
                    echo $userid;
                    ?>
">
									</form>
									<?php 
                }
                ?>
						</div>
					<?php 
            }
            ?>
				</div>
				<div id="product_details">
					<div class="details_view">
						<div class="details_title">
							Merchant Name
						</div>
						<div class="details_names">
							<?php 
            echo $company;
            ?>
						</div>
						<div class="details_title1">
							Product Name
						</div>
						<div class="details_names1">
							<?php 
            echo $product_name;
            ?>
						</div>
						<div class="details_title">
							Category Name
						</div>
						<div class="details_names">
							<?php 
            echo $category;
            ?>
						</div>
						<div class="details_title1">
							Manufacturer Name
						</div>
						<div class="details_names1">
							<?php 
            echo $manufacturer;
            ?>
						</div>
						<div class="details_title">
							Price
						</div>
						<div class="details_names">
							<?php 
            echo $price;
            ?>
						</div>
						<?php 
            if ($deal > $discount && ($dealstarts <= $today && $dealends >= $today) && $isdeal == 1) {
                ?>
							<div class="details_title1">
								Deal Price
							</div>
							<div class="details_names12">
								<?php 
                echo $deal_price;
                ?>
							</div>
							<?php 
            } else {
                if ($deal == 0 && $discount == 0.0) {
                    ?>
								<div class="details_title1">
									Offers
								</div>
								<div class="details_names12">
									<?php 
                    echo "---";
                    ?>
								</div>
								<?php 
                } else {
                    ?>
								<div class="details_title1">
									Discount Price
								</div>
								<div class="details_names12">
									<?php 
                    echo $discount_price;
                    ?>
								</div>
								<?php 
                }
            }
            ?>
						<div class="details_title">
							Address
						</div>
						<div class="details_names">
							<?php 
            echo $address;
            ?>
						</div>
						<div class="details_title1">
							Contact Number
						</div>
						<div class="details_names1">
							<?php 
            echo $contact_number;
            ?>
						</div>
						<div class="details_title">
							Purchase Mode
						</div>
						<div class="details_names">
							Instore Online
						</div>
						<div class="details_title1">
							Product Description
						</div>
						<div class="details_names1">
							<?php 
            echo $desc;
            ?>
						</div>
					</div>
					<div class="location">
						<?php 
            echo $row['location_map'];
            ?>
					</div>
				</div>
			</div>
			<?php 
        }
    }