<?php
//Eklavya publications order form
//Following will make the script cacheable for 10 minutes after the request so that
//if the user hits the 'back' button, they won't be resubmitting the request
Header("Cache-Control: max-age=600, must-revalidate");
//Declare all variables here
$books_r = array();
$no_of_titles = 0;
include ("global.inc.php");
define ('SCIKIT', 'Science kit');
define ('BOOKS_HINDI', 'Written by Children (Hindi)');
define ('BOOKS_URDU', 'Poems for children (Urdu)');
define ('BOOKS_ENGLISH', 'Poems for children (English)');
//Fetch the book list (book category, book name, price) into an array-----------
include ("books.inc.php");
//get_book_details($books_r);
$numBooks = count($books_r);
//Display HTML page with book list. Quantity is an input field and Amount is a display-only field
display_page_header("Eklavya Publications Order Form");
//added by seena 30/07/2009
//links for languages
$name = (isset($_REQUEST['name']) ? $_REQUEST['name'] : '');
$name1 = (isset($_REQUEST['name1']) ? $_REQUEST['name1'] : '');
$cbse=(isset($_REQUEST['cbse']) ? $_REQUEST['cbse'] : '');
$order = (isset($_REQUEST['order']) ? $_REQUEST['order'] : '');
if($cbse=='1')
{
for($l=0;$l<$numBooks;$l++)
{
if($books_r[$l]['cbse'] == '1')
$no_of_titles++;
}
}
else{ //calculate the no of books of particular language
if($name == 'A' or $name == '')
{
$no_of_titles = $numBooks;
}
else
{
for($l=0;$l<$numBooks;$l++)
{
if($books_r[$l]['language'] == $name or $books_r[$l]['language'] == $name1)
$no_of_titles++;
}
}
}
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-36950695-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<div id="content_box">
<h3>Eklavya Publications - Order Form</h3>
<noscript>
<div style="border: 2px solid red; padding: 3px 0;">
<p style="color: red; font-weight: bold; font-size: 1em;">
To use some nice features on this page, please enable JavaScript in your browser!
</p>
<div style="text-align: left; margin-left: 17em; color: blue; font-size: .7em;">
<p style="color: blue; font-size: 1.2em;">
Here is how to enable JavaScript in your browser:
</p>
<span style="font-weight: bold; text-decoration: underline;">Internet Explorer 6 or 7</span><br>
<ol>
<li>Click the Tools menu.
<li>Select Internet Options.
<li>Click the Security tab.
<li>Click the Custom Level button.
<li>Scroll down until you see the 'Scripting' section.<br>
Select the 'Enable' radio button for 'Active Scripting.'
<li>Click the OK button.
<li>Click the Yes button in the confirmation window.
</ol>
<span style="font-weight: bold; text-decoration: underline;">Firefox 2 or 3</span><br>
<ol>
<li>Click the Tools menu.
<li>Select Options.
<li>Click the Contents tab.
<li>Select the 'Enable JavaScript' checkbox.
<li>Click the OK button.
</ol>
<span style="font-weight: bold; text-decoration: underline;">Safari 2 or 3</span><br>
<ol>
<li>Click the Safari menu.
<li>Select Preferences.
<li>Click the Security tab.
<li>Select the 'Enable JavaScript' checkbox.
</ol>
</div>
</div>
<br>
</noscript>
<!--div style="text-align:center; font-size:.8em; background-color:#666633; color:#ffff66; width:100%; margin:auto; padding-top:8px; padding-bottom:8px; margin-bottom:15px;"-->
<div id="header" style="text-align:center;font-size:.8em; color:#ffff66; width:100%; ">
<ul>
<b style="color:#000;">Select items </b>
<?php
if(($name == 'A' OR $name == '')AND($cbse==''))
{ ?>
<li><a href="index.php?name=A" style="background-color: #393;">All Items</a><?php
}
else
{?>
<li><a href="index.php?name=A">All Items</a><?php
}
if($name == 'H')
{ ?>
<li><a href="index.php?name=H&name1=B" style="background-color: #393;">Hindi</a><?php
}
else
{?>
<li><a href="index.php?name=H&name1=B">Hindi</a><?php
}
if($name == 'E')
{?>
<li><a href="index.php?name=E&name1=B" style="background-color: #393;">English</a><?php
}
else
{?>
<li><a href="index.php?name=E&name1=B">English</a><?php
}
if($name == 'U')
{?>
<li><a href="index.php?name=U" style="background-color: #393;">Urdu</a><?php
}
else
{?>
<li><a href="index.php?name=U">Urdu</a><?php
}
if($cbse=='1')
{?>
<li><a href="index.php?cbse=1" style="background-color: #393;">CBSE Recommended</a><?php
}
else
{?>
<li><a href="index.php?cbse=1">CBSE Recommended</a><?php
}?>
<span style="font-size:.9em;color:#000;"> No of items: <?php print $no_of_titles ?></span>
</ul>
</div>
<br />
<?php if($cbse=='')
{?>
<div id="sub_header" style="text-align:center;font-size:.8em; width:100%; ">
<?php
if($name == 'A' || $name == '')
{
$selected_a = '';
$selected_e = '';
$selected_h = '';
$selected_u = '';
$selected_c='';
switch($order)
{
case 'A': $selected_a = 'checked';break;
case 'E': $selected_e = 'checked';break;
case 'H': $selected_h = 'checked';break;
case 'U': $selected_u = 'checked';break;
case 'C': $selected_c = 'checked';break;
}
?><b style="color:#000;">Order full set of books and magazines </b>
<input type="radio" name="one_set" id="one_set_all" value="A" <?php echo $selected_a; ?> onclick="self.location='index.php?name=A&order=A'"/> <label for="one_set_all">All Items</label>
<input type="radio" name="one_set" id="one_set_hindu" value="H" <?php echo $selected_h; ?> onclick="self.location='index.php?name=H&name1=B&order=H'"/> <label for="one_set_hindu">Hindi</label>
<input type="radio" name="one_set" id="one_set_english" value="E" <?php echo $selected_e; ?> onclick="self.location='index.php?name=E&name1=B&order=E'"/> <label for="one_set_english">English</label>
<input type="radio" name="one_set" id="one_set_urdu" value="U" <?php echo $selected_u; ?> onclick="self.location='index.php?name=U&order=U'"/> <label for="one_set_urdu">Urdu</label>
<input type="radio" name="one_set" id="one_set_cbse" value="C" <?php echo $selected_c; ?> onclick="self.location='index.php?cbse=1&order=C'"/> <label for="one_set_cbse">CBSE</label>
<?php
}else if($name == 'H')
{
if($order == 'H')
{// href="index.php?name='.$name.'&name1='.$name1.'&order=H"
echo '<ul><li> <a style="background-color: #cc6600;">Full set selected</a>';
}else
{
echo '<ul><li><a href="index.php?name='.$name.'&name1='.$name1.'&order=H">Order this full set</a>';
}
}else if($name == 'U')
{
if($order == 'U')
{//href="index.php?name='.$name.'&name1='.$name1.'&order=U"
echo '<ul><li><a style="background-color: #cc6600;">Full set selected</a>';
}else
{
echo '<ul><li><a href="index.php?name='.$name.'&name1='.$name1.'&order=U">Order this full set</a>';
}
}else if($name == 'E')
{
if($order == 'E')
{ //href="index.php?name='.$name.'&name1='.$name1.'&order=E"
echo '<ul><li><a style="background-color: #cc6600;">Full set selected</a>';
}else
{
echo '<ul><li><a href="index.php?name='.$name.'&name1='.$name1.'&order=E">Order this full set</a>';
}
}
else if($cbse==1)
{
if($order == 'C')
{ //href="index.php?name='.$name.'&name1='.$name1.'&order=E"
echo '<ul><li><a style="background-color: #cc6600;">Full set selected</a>';
}else
{
echo '<ul><li><a href="index.php?cbse=1&order=C">Order this full set</a>';
}
}
?>
</div>
<?php }
else
{ ?> <div id="sub_header" style="text-align:center;font-size:.8em; width:100%; ">
<?php if($order == 'C')
{ //href="index.php?name='.$name.'&name1='.$name1.'&order=E"
echo '<ul><li><a style="background-color: #cc6600;">Full set selected</a>';
}else
{
echo '<ul><li><a href="index.php?cbse=1&order=C">Order this full set</a>';
}
?>
</div>
<?php }?>
<form enctype="multipart/form-data" action="total.php" method="post"
name="orderForm" style="margin-top: 0;" onsubmit="return verifyNoBlankForm(this, <?php print $numBooks ?>);" onKeyPress="return disableEnterKey(event)">
<!--overflow:auto;height:400px;width:700px;-->
<div style="margin:auto;overflow-x:hidden">
<table cellspacing="2" cellpadding="2" style="border:0px solid blue;width:100%;">
<?php
$cat_prev = ""; //previous category
$i = 0; //counter for qty field
$catnum = 0; //counter for category
$sum = 0; //Total amount
//Iterate thru' the books array and print book list.
foreach($books_r as $key=>$book)
{
if($cbse=='1')
{
if($book["cbse"]=='1')
{
$cat_curr = $book["category"];
if ($cat_curr != $cat_prev) {
if($cat_curr == MAGAZINES){
?>
<tr><td colspan='4' style="background-color: #ffffff; padding: 0;">
<img src="eklavya-magazines.jpg" alt="Eklavya magazines" title="Eklavya magazines"
style="margin: 0; display: block;">
</td></tr><?php
} else if($cat_curr == SCIKIT) {
?>
<tr><td colspan='4' style="background-color: #ffffff; padding: 0;">
<img src="kit.jpg" alt="Science kit" title="Science kit"
style="margin-top: 14px; display: block;">
</td></tr>
<tr>
<th>Item</th>
<th>Price (Rs.)</th>
<th>Quantity</th>
<th>Amount (Rs.)</th>
</tr>
<?php
} else if($cat_curr == BOOKS_HINDI || ($cat_curr == BOOKS_URDU && $name == 'U') || ($cat_curr == BOOKS_ENGLISH && $name == 'E') ) {
//Following TR is actually the bottom note for Magazines category
if($name != 'U' && $name != 'E')
{
?>
<tr><td colspan="4" style="background: #fff;">
<span class="fp_note">There is no postage for magazine subscriptions</span>
</td></tr>
<?php
}
?>
<tr><td colspan='4' style="background-color: #ffffff; padding: 0;">
<img src="books.jpg" alt="Books" title="Books"
style="margin-top: 14px; display: block;">
</td></tr> <?php
}
$catnum++; //This way we'll start with cat1
$j = 0; //Book counter in each category
?><tr><td class='categ'><?php print $cat_curr ?></td>
<td colspan='3' class="categ" style="font-weight: normal; font-size: .85em;">
<!--input type="checkbox" onclick="javascript:selectSet(cat<?php print $catnum ?>, this)">Order this entire set-->
<script language="JavaScript" type="text/javascript">
<!--
var selectList = '<select onchange="javascript:selectSet(cat<?php print $catnum ?>, this)" ><option value=0> </option>';
for(var k=1;k<=20;k++) {
selectList += '<option value='+k+'>'+k+'</option>';
}
selectList += '</select>';
//document.write('Order '+'<select onchange="javascript:selectSet(cat<?php print $catnum ?>, this)" ><?php for($k=0;$k<=20;$k++) { ?><option value =<?php print $k;?> > <?php print $k; ?> </option><?php } ?> </select> copies from entire set');
document.write('Order '+ selectList + ' copies of entire set');
//-->
</script>
</td>
</tr>
<script language="JavaScript" type="text/javascript">
<!--
//Create a new array (cat1, cat2...) for each category.
//This will store the qty field names in each category
var cat<?php print $catnum ?> = new Array();
//-->
</script>
<?php $cat_prev = $cat_curr; }?>
<tr title='<?php print $book["description"]?>'>
<td style='padding-left: 20px;'><?php
print $book["title"];
if ($book['isnew'] == 1) {
?> <img src="new_book.gif" alt="New item icon" title="New item"><?php ;}?>
</td>
<td align='center'><?php print $book['price'] ?></td>
<td align='center'>
<?php
if ($book["price"] == '' or $book["price"] == 0) {
$value = '';
$price = '';
?>
<input disabled name='qty[<?php print $i ?>]' type='text' size='3' maxlength='3'>
<?php
} else {
$value = '';
$price = '';
if($order=='C' )
{
if($book["book_type"] == 'INS' || $book["book_type"] == 'S')
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($book["book_type"] == 'BAL' && $book["language"] == "E" && ($name == 'A' || $name == ''))
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($book["book_type"] == 'SKIT')
{
if($book["language"] == 'H' && ($name == 'A' || $name == ''))
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($name == 'E' || $name == 'H' || $name == 'U')
{
$value = 1;
$price = $book["price"];
$sum += $price;
}
}
}
?>
<input name='qty[<?php print $i ?>]' type='text' size='3' maxlength='3' value="<?php echo $value;?>"
onchange='return calcAmt(document.orderForm.amt<?php print $key ?>, <?php print $book["price"] ?>, this, <?php print $numBooks ?>)'>
<script language="JavaScript" type="text/javascript">
<!--
//Store the current qty field name in the array
cat<?php print $catnum ?>[<?php print $j++ ?>] = 'qty[<?php print $i ?>]';
//-->
</script>
<?php
}
?>
</td>
<?php $i++ ?>
<td align='center'>
<input disabled type='text' name='amt<?php print $key ?>' size='4' style='text-align: right;' value="<?php echo $price;?>">
</td>
</tr>
<?php }
//keep the records hidden which do not match the selected language
else
{
if ($book["price"] == '' or $book["price"] == 0) {
?>
<input disabled name='qty[<?php print $i ?>]' type='hidden' size='3' maxlength='3'>
<?php
} else {
$value = '';
$price = '';
if($book["language"] == $order ||($book["language"] == "B" && $order != 'U' && $order != '')|| $order == 'A')
{
if($book["book_type"] == 'INS' || $book["book_type"] == 'S')
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($book["book_type"] == 'BAL' && $book["language"] == "E" && ($name == 'A' || $name == ''))
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($book["book_type"] == 'SKIT')
{
if($book["language"] == 'H' && ($name == 'A' || $name == ''))
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($name == 'E' || $name == 'H' || $name == 'U')
{
$value = 1;
$price = $book["price"];
$sum += $price;
}
}
}
?>
<input name='qty[<?php print $i ?>]' type='hidden' size='3' maxlength='3' value="<?php echo $value;?>"
onchange='return calcAmt(document.orderForm.amt<?php print $key ?>, <?php print $book["price"] ?>, this, <?php print $numBooks ?>)'>
<?php }
$i++ ?>
<input disabled type='hidden' name='amt<?php print $key ?>' size='4' style='text-align: right;'><?php
}
}
else
//display books as per selection of language
if(($book["language"] == $name) OR ($book["language"] == $name1) OR ($name == 'A') OR ($name == ''))
{
$cat_curr = $book["category"];
if ($cat_curr != $cat_prev) {
if($cat_curr == MAGAZINES){
?>
<tr><td colspan='4' style="background-color: #ffffff; padding: 0;">
<img src="eklavya-magazines.jpg" alt="Eklavya magazines" title="Eklavya magazines"
style="margin: 0; display: block;">
</td></tr> <?php
} else if($cat_curr == SCIKIT) {
?>
<tr><td colspan='4' style="background-color: #ffffff; padding: 0;">
<img src="kit.jpg" alt="Science kit" title="Science kit"
style="margin-top: 14px; display: block;">
</td></tr>
<tr>
<th>Item</th>
<th>Price (Rs.)</th>
<th>Quantity</th>
<th>Amount (Rs.)</th>
</tr>
<?php
} else if($cat_curr == BOOKS_HINDI || ($cat_curr == BOOKS_URDU && $name == 'U') || ($cat_curr == BOOKS_ENGLISH && $name == 'E') ) {
//Following TR is actually the bottom note for Magazines category
if($name != 'U' && $name != 'E')
{
?>
<tr><td colspan="4" style="background: #fff;">
<span class="fp_note">There is no postage for magazine subscriptions</span>
</td></tr>
<?php
}
?>
<tr><td colspan='4' style="background-color: #ffffff; padding: 0;">
<img src="books.jpg" alt="Books" title="Books"
style="margin-top: 14px; display: block;">
</td></tr> <?php
}
$catnum++; //This way we'll start with cat1
$j = 0; //Book counter in each category
?><tr><td class='categ'><?php print $cat_curr ?></td>
<td colspan='3' class="categ" style="font-weight: normal; font-size: .85em;">
<!--input type="checkbox" onclick="javascript:selectSet(cat<?php print $catnum ?>, this)">Order this entire set-->
<script language="JavaScript" type="text/javascript">
<!--
var selectList = '<select onchange="javascript:selectSet(cat<?php print $catnum ?>, this)" ><option value=0> </option>';
for(var k=1;k<=20;k++) {
selectList += '<option value='+k+'>'+k+'</option>';
}
selectList += '</select>';
//document.write('Order '+'<select onchange="javascript:selectSet(cat<?php print $catnum ?>, this)" ><?php for($k=0;$k<=20;$k++) { ?><option value =<?php print $k;?> > <?php print $k; ?> </option><?php } ?> </select> copies from entire set');
document.write('Order '+ selectList + ' copies of entire set');
//-->
</script>
</td>
</tr>
<script language="JavaScript" type="text/javascript">
<!--
//Create a new array (cat1, cat2...) for each category.
//This will store the qty field names in each category
var cat<?php print $catnum ?> = new Array();
//-->
</script>
<?php $cat_prev = $cat_curr; }?>
<tr title='<?php print $book["description"]?>'>
<td style='padding-left: 20px;'><?php
print $book["title"];
if ($book['isnew'] == 1) {
?> <img src="new_book.gif" alt="New item icon" title="New item"><?php ;}?>
</td>
<td align='center'><?php print $book['price'] ?></td>
<td align='center'>
<?php
if ($book["price"] == '' or $book["price"] == 0) {
$value = '';
$price = '';
?>
<input disabled name='qty[<?php print $i ?>]' type='text' size='3' maxlength='3'>
<?php
} else {
$value = '';
$price = '';
if($book["language"] == $order ||($book["language"] == "B" && $order != 'U' && $order != '' )|| $order == 'A')
{
if($book["book_type"] == 'INS' || $book["book_type"] == 'S')
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($book["book_type"] == 'BAL' && $book["language"] == "E" && ($name == 'A' || $name == ''))
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($book["book_type"] == 'SKIT')
{
if($book["language"] == 'H' && ($name == 'A' || $name == ''))
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($name == 'E' || $name == 'H' || $name == 'U')
{
$value = 1;
$price = $book["price"];
$sum += $price;
}
}
}
?>
<input name='qty[<?php print $i ?>]' type='text' size='3' maxlength='3' value="<?php echo $value;?>"
onchange='return calcAmt(document.orderForm.amt<?php print $key ?>, <?php print $book["price"] ?>, this, <?php print $numBooks ?>)'>
<script language="JavaScript" type="text/javascript">
<!--
//Store the current qty field name in the array
cat<?php print $catnum ?>[<?php print $j++ ?>] = 'qty[<?php print $i ?>]';
//-->
</script>
<?php
}
?>
</td>
<?php $i++ ?>
<td align='center'>
<input disabled type='text' name='amt<?php print $key ?>' size='4' style='text-align: right;' value="<?php echo $price;?>">
</td>
</tr><?php }
//keep the records hidden which do not match the selected language
else
{
if ($book["price"] == '' or $book["price"] == 0) {
?>
<input disabled name='qty[<?php print $i ?>]' type='hidden' size='3' maxlength='3'>
<?php
} else {
$value = '';
$price = '';
if($book["language"] == $order ||($book["language"] == "B" && $order != 'U' && $order != '')|| $order == 'A')
{
if($book["book_type"] == 'INS' || $book["book_type"] == 'S')
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($book["book_type"] == 'BAL' && $book["language"] == "E" && ($name == 'A' || $name == ''))
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($book["book_type"] == 'SKIT')
{
if($book["language"] == 'H' && ($name == 'A' || $name == ''))
{
$value = 1;
$price = $book["price"];
$sum += $price;
}else if($name == 'E' || $name == 'H' || $name == 'U')
{
$value = 1;
$price = $book["price"];
$sum += $price;
}
}
}
?>
<input name='qty[<?php print $i ?>]' type='hidden' size='3' maxlength='3' value="<?php echo $value;?>"
onchange='return calcAmt(document.orderForm.amt<?php print $key ?>, <?php print $book["price"] ?>, this, <?php print $numBooks ?>)'>
<?php }
$i++ ?>
<input disabled type='hidden' name='amt<?php print $key ?>' size='4' style='text-align: right;'><?php
}
} //end-foreach background-color:#996;color:#ffffff;
?>
</table>
</div>
<br>
<div class="fp_note">
<ul>
Please note:
<li>For orders upto Rs. 300/- postage Rs. 30/- will be charged and orders
upto Rs. 500/- postage Rs. 50/- will be charged
<li>This order will be sent to pitara email address at Eklavya
</ul>
</div>
<br />
<br />
</div><!-- content_box -->
<p> </p>
<p> </p>
<?php
/*
Added by - kaustubh dated 31 Jan 11
fix the position of div
*/
?>
<!--[if gte IE 5.5]>
<![if lte IE 7]>
<style type="text/css">
div#Sticky {
/* IE5.5+/Win - this is more specific than the IE 5.0 version */
right: auto; bottom: auto;
left: expression( ( 0 - Sticky.offsetWidth + ( document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth ) + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
top: expression( ( 0 - Sticky.offsetHeight + ( document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
}
</style>
<![endif]>
<![endif]-->
<div id="Sticky">
<div id="innerSticky">
<input type=submit value='Submit Form'>
<input type=reset value='Reset Form'>
Order Total (Rs.)
<input type="text" name='total' id="txtName" size=6 class="textBoxSticky" value="<?php echo ceil($sum); ?>" readonly="readonly" style="text-align:right;padding-right:10px;margin-right:10px;border:solid 1px;"/>
</div>
</div>
</form>
</body>
</html>
<?php
//When SUBMIT button is clicked, validate input using JavaScript, then proceed to orderSummary page
?>