#!/usr/bin/perl -w
use CGI qw/:all/;
use CGI::Carp qw(fatalsToBrowser);
use DBI;
#my $dbh=DBI->connect('dbi:mysql:parc_demog:localhost:3306','root','root') or die "Unable to connect: $DBI::errstr\n";
my $dbh=DBI->connect('dbi:mysql:parc_demog:localhost','parcdemog','parc9904')or die "Couldn't connect to database: " . DBI->errstr;

my $shID= param('shID');
my $cityName=param('cityName');
my $conCode=param('conCode');

$strCond="";

if ($strCond eq "")
{
	$strLOC="SELECT locCode,locName,cityName,typeCode FROM cf_location  WHERE conCode='$conCode' order by cityName,locName";
	#$strLOC="SELECT locCode,locName FROM cf_location  WHERE conCode='$conCode' order by locName";
}
$sthL=$dbh->prepare($strLOC);
$sthL->execute;
$cont=$sthL->rows;

print <<blk1;
content-type: text/html

<!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>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>PAN ARAB RESEARCH CENETER - Mystery Shopping</title>
<link href="srch.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

function dosave()
{
	document.frmMain.method="post";
    document.frmMain.action="http://www.arabdemog.com/cf/visits/visit.pl";
	document.frmMain.submit();
}
</script>
</head>

<body style="background-color: #666666;color: inherit;">
<table class="TBL">
<tr>
<td style="width:4%;background-color:#666666">&nbsp;</td>


<td style="width:92%;background-color: #5f7287">
<div style='height:70px;padding-top: 15px;padding-bottom: 5px;line-height: 3px;'><h1 style='padding-left: 30px;color: #ffffff;padding-right: 30px;font-size:1.5em;'>PAN ARAB RESEARCH CENTER</h1>
<p style='padding-left: 30px;color: #ffffff;padding-right: 30px;font-size:1.2em;'>Mystery Shopping - Search</p>
</div>
<div id="navbar">&nbsp; </div>
<div id="content" >
<form method="post" name="frmMain">

<font size='2'color='#ffffff'>


<table width="100%" align='center' class="Mtable1" id="tbl">
<tr height='25' bgcolor='#5f7287'>

<!--  Place Store List here -->


<td  class="Mtd1" width='45%' style="font-size:0.86em;padding-left: 2px;">
<table width="100%" align='center' class="Mtable1">

blk1

my $i= 0;
while ($visit=$sthL->fetchrow_hashref())
   	{
$i = $i + 1;
my $n1 = "r".$i;
my $n2 = "s".$i;
my $n3 = "t".$i;
my $n4 = "u".$i;

my $lcode ="$visit->{'locCode'}";
my $lname ="$visit->{'locName'}";
my $cname ="$visit->{'cityName'}";
my $type ="$visit->{'typeCode'}";

if($type==1)
{
	$htmstr=$htmstr."<tr><td class='Mtd' width='2%' style='font-size:0.86em;padding-left: 2px;'><input type='checkbox'  value='".$lcode."'name='".$n1."' id='".$n1."'/></td><td class='Mtd' width='68%' style='font-size:1.1em;padding-left: 2px;'>".$lname."</td><td class='Mtd' width='30%'>".$cname."</td></tr>";
	$FLGA=1;
}
elsif($type==2)
{
	$htmstr1=$htmstr1."<tr><td class='Mtd' width='2%' style='font-size:0.86em;padding-left: 2px;'><input type='checkbox'  value='".$lcode."'name='".$n1."' id='".$n1."'/></td><td class='Mtd' width='68%' style='font-size:1.1em;padding-left: 2px;'>".$lname."</td><td class='Mtd' width='30%'>".$cname."</td></tr>";
	$FLGB=1;
}
}

if($FLGA==1)
{
$htmstr = "<tr><td class='Mtd4' colspan='3'><b>HyperMarket<b></td></tr>".$htmstr;
}
if($FLGB==1)
{
	$htmstr1 = "<tr><td class='Mtd3' colspan='3'><b>Carrefour Market<b></td></tr>".$htmstr1;
}
$finlstr=$htmstr.$htmstr1;
print <<blk2;
$finlstr
<tr><td colspan='2' class="Mtd2"><td></tr>
<tr><td colspan='2' class="Mtd2" align='center'><input type="button" onclick="dosave();" value="Next" name="Next" /><td></tr>

</table>

</td>

<!--  END Store List here -->

<!--  Description Contents here -->

<td class="Mtd2"  width='55%' style="vertical-align:top;font-size:1em;padding-top: 40px;padding-left: 20px;padding-right:20px;">
<div>
Select the location(s) for which you intend to do Visit(s) and click next button to display the Visit Plan<br><br><br><br>

1. <i>In case you will not do the Visit as per you requested, Please email back to <b> parcdxb@emirates.net.ae </b> prior the requested date.</i><br><br>

2. <i>If you did not Fill the Questionnaire within Two days, The link will be automatically disabled and the Visit will become Invalid.</i><br><br>

3. <i> Maximum Number Visits Allowed </i><br><br>

<pre>
	Total per shopper =25 times <br><br>
	Same Hyper Market = 4 times <br><br>
	Same Carrefour Market = 2 times <br><br>
</pre>

4. <i> Please notice the Cashier Name and Tilt Number even though these are available in the Receipt </i><br><br>

5. <i> Avoid going to same Counter again, in case you do shopping at the same Location </i><br><br>

</div>

</td>


<!-- END Description Contents here -->

</tr>

</table>
</font>
<input type="hidden" name="conCode" id="conCode" value="$conCode">
<input type="hidden" id="shID" name="shID" value="$shID"/>
<input type="hidden" id="fromLocation" name="fromLocation" value="1"/>
<input type="hidden" id="cityName" name="cityName" value="$cityName"/>
<input type="hidden" id="cont" name="cont" value="$cont"/>

</form>
</div>

<div id="footer">
<p class="footerpmiddle"><br /></p>
</div>	
</td>

<td style="width:4%;background-color:#666666"></td>
</tr>
</table>

</body>
</html>
blk2
