[guadec-web] adds persistent storage in a separate table - props Saumya Dwivedi (dvd)



commit 39c980102696e5e30d1b8d01cb2e7674c999270e
Author: Fabiana Simões <fabianapsimoes gmail com>
Date:   Fri Jul 4 14:37:16 2014 +0200

    adds persistent storage in a separate table - props Saumya Dwivedi (dvd)

 guadec/js/calculate-total.js |   13 +++++
 guadec/page-4865.php         |  119 +++++++++++++++++++++++++++---------------
 guadec/page-4903.php         |   69 ++++++++++++++++++++++++
 guadec/style.css             |    5 ++
 4 files changed, 163 insertions(+), 43 deletions(-)
---
diff --git a/guadec/js/calculate-total.js b/guadec/js/calculate-total.js
index bb8c947..34f3056 100644
--- a/guadec/js/calculate-total.js
+++ b/guadec/js/calculate-total.js
@@ -85,6 +85,7 @@ function enableDisableL(obj) {
 $(function() {
        
        /*Dropdown triggered event*/
+
        $('#arrive').on('change' , function(){
                callAccomCalculate();
        })
@@ -126,6 +127,7 @@ $(function() {
           $(this).val(sanitized);
 
        });
+       //Enable Disable Accomodation and Lunch Selection
        $(document).ready(function() {
                enableDisableA(this);
                $("[name=accommodation]").click(function() {
@@ -138,5 +140,16 @@ $(function() {
                        enableDisableL(this);   
                });
        });
+       // Enable Disable the submit button
+       $('input[type="submit"]').attr('disabled','disabled');
+     $('input[name="policy"]').click(function() {
+        if($(this).is(':checked')) {
+           $('input[type="submit"]').removeAttr('disabled');
+        }
+        else {
+               $('input[type="submit"]').attr('disabled','disabled');
+               
+        }
+     });
 });
 
diff --git a/guadec/page-4865.php b/guadec/page-4865.php
index 82108bb..3d8548f 100644
--- a/guadec/page-4865.php
+++ b/guadec/page-4865.php
@@ -1,6 +1,9 @@
 <?php
+//require_once('../../../wp-load.php')
 
 $application_submitted = false;
+$mailContent = '';
+global $wpdb;
 
 if (!empty($_POST)) {
 
@@ -9,12 +12,15 @@ if (!empty($_POST)) {
 
        $name = trim(stripslashes($_POST['contact_name']));
        $email = trim(stripslashes($_POST['contact_email']));
-       $irc = trim(stripslashes($_POST['irc']));
-       $gender = trim(stripslashes($_POST['contact_gender']));
-       $entry = trim(stripslashes($_POST['entry-fee']));
-       $lamount = ($_POST['lfee']);
-       $aamount = ($_POST['afee']);
-       $tamount = ($_POST['tfee']);
+       $irc = (isset($_POST['irc']))?(trim(stripslashes($_POST['irc']))) : 'NA';
+       $gender = (isset($_POST['contact_gender']))?(trim(stripslashes($_POST['contact_gender']))) : 'NA';
+       $country = (isset($_POST['contact_country']))?(trim(stripslashes($_POST['contact_country']))) : 'NA';
+       $diet = (isset($_POST['diet']))?(trim(stripslashes($_POST['diet']))) : 'NA';
+       
+       $entry = (isset($_POST['entry-fee']))?($_POST['entry-fee']):'0';
+       $lamount = (isset($_POST['lfee']))?($_POST['lfee']):'0';
+       $aamount = (isset($_POST['lfee']))?($_POST['afee']):'0';
+       $tamount = (isset($_POST['lfee']))?($_POST['tfee']):'0';
 
        $obfuscated_email = str_replace("@", " AT ", $email);
        
@@ -30,39 +36,53 @@ if (!empty($_POST)) {
                $arrive = $_POST['arrival'];
                $depart = $_POST['departure'];
        }
-       $lunch_days = " ";
+       $lunch_days = "";
        $x = 0;
        if(isset($_POST['lunch'])){
                foreach($_POST['lentry-fee'] as $value){
-                       $lunch_days = $lunch_days . " " . $value . "--\n";
+                       $lunch_days = $lunch_days." ".$value;
                        $x = $x + 1;
                }
        }
        $sponsor_check = ($_POST['sponsored'] == true)?"YES":"NA";
+       $payment = ($tamount > 0)?"Pending":"NoPayment-0";
+       $accom = ($_POST['accommodation'] == true)?"YES":"NA";
        if ($errors == false) {
-
-               $registerInfo = "Contact Information\n" .
-               "-------------------\r\n\r\n" .
-
-               " Name: " . $name . "\n".
-               " Email:     " . $obfuscated_email . "\n\n" .
-               " IRC nick " . $irc . "\n".
-               " Gender     " . $gender . "\n\n" .
-               " [Registration received at " . date("D M j G:i:s Y") . " (Eastern time)]" . "\n\n".
-               " Accomodation\n" ."\r\n".
-               " Arrival     :  ". $arrive . "\r\n".
-               " Departure     :  ". $depart . "\r\n".
-               " Sponsorship Status   : ". $sponsor_check . "\r\n".
-               " Lunch    : ".$x." days  [". $lunch_days ."]". "\r\n".
-               " Entry Fees    : ". $entry ."\r\n".
-               " Lunch Amount   : ".$lamount."\r\n".
-               " Accomodation Amount   : ".$aamount."\r\n".
-               " Total Amount   : ".$tamount."\r\n"
+               /* This variable not be changed: goes to a restricted field to Paypal API */
+               $registerInfo = 
+               "Name: " . $name . "\n".
+               "Email: " . $obfuscated_email . "\n" .
+               "Arrive :  ". $arrive . "\n".
+               "Depart:  ". $depart . "\n".
+               "Sponsored: ". $sponsor_check . "\n".
+               "Lunch Days: ". $x. "\n".
+               "Entry Fee: ". $entry ."\n".
+               "Lunch Fee: ".$lamount."\n".
+               "Accom Fee: ".$aamount."\n".
+               "Total Fee: ".$tamount."\n"
                ;
+               $mailContent .= $registerInfo;
+       
+               $table_name = "registered";
+               $wpdb->insert($table_name, array('name' => $name,
+                                'email' => $email,
+                                'accom' => $accom,
+                                'arrive' => $arrive,
+                                'depart' => $depart,
+                                'sponsored' => $sponsor_check,
+                                'lunchdays' => $lunch_days,
+                                'dietrestrict' => $diet,
+                                'entryfee' => $entry,
+                                'lunchfee' => $lamount,
+                                'accomfee' => $aamount,
+                                'totalfee' => $tamount,
+                                'irc' => $irc,
+                                'gender' => $gender,
+                                'country' => $country,
+                                'payment_status' => $payment));        
        }
-
 }
-
+       
 ?>
 <?php require_once("header.php"); ?>
 
@@ -71,22 +91,35 @@ if (!empty($_POST)) {
        <div> "Invalid Submission. Please go through registration page first."</div>
 <?php else: ?>
        <?php if ($errors == true): ?>
-       <div> "Invalid name or email. Please check."<a href=""> Go back to Registration </a>
-       <?php else: ?>  
-               <form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr"; method="post">
-           <input type="hidden" name="cmd" value="_xclick">
-           <input type="hidden" name="business" value="saumya zero-facilitator gmail com">
-           <input type="hidden" name="currency_code" value="GBP">
-           <input type="hidden" name="item_name" value="Digital Download">
-           <input type="hidden" name="amount" value="<?php echo $tamount; ?>">
-           <input type="hidden" name="return" value="https://www.guadec.org/?page_id=1323&preview=true";>
-           <input type="hidden" name="custom" value="<?php echo $registerInfo; ?>">
-           <input type="hidden" name="notify_url" value="http://web.iiit.ac.in/~saumya.dwivedi/test/ipn.php";>
-           <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif"; border="0" 
name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
-               </form>
-<?php $_POST['contact_name']; ?>
+       <div> "Invalid name or email. Please check."<a href="http://localhost/wordpress/?page_id=4787";> Go 
back to Registration </a>
+       <?php else: ?>
+               <?php echo $registerInfo; ?>
+               <?php if ($tamount > 0): ?>
+                       <div>Your details have been stored. Proceed to pay.</div>
+                               
+                       <form name="_xclick" action="https://www.sandbox.paypal.com/cgi-bin/webscr"; 
method="post">
+                   <input type="hidden" name="cmd" value="_xclick">
+                   <input type="hidden" name="business" value="saumya zero-facilitator gmail com">
+                   <input type="hidden" name="currency_code" value="EUR">
+                   <input type="hidden" name="item_name" value="Digital Download">
+                   <input type="hidden" name="amount" value="<?php echo $tamount; ?>">
+                   <!-- Redirect to thank you after successful payment -->
+                   <input type="hidden" name="return" value="http://localhost/wordpress/?page_id=4823";>
+                   <input type="hidden" name="custom" value="<?php echo $registerInfo; ?>">
+
+                       <!-- <Address of notification url. Can not be localhost      -->
+                   <input type="hidden" name="notify_url" 
value="http://web.iiit.ac.in/~saumya.dwivedi/test/ipn.php";>
 
-<?php echo $registerInfo; ?>
+                   <!-- Redirect to thank you after cancelled payment -->
+                   <input type="hidden" name="cancel_return" 
value="http://localhost/wordpress/?page_id=4823";>
+                   
+                   <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_buynow_LG.gif"; border="0" 
name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
+                       </form>
+               <?php else: ?>
+                       <div>Your details have been stored. An email confirming your registration will be 
sent to you shortly. Thank you.</div>
+                       <!-- Send a confirm registration mail to the registered -->
+                       <?php mail($email, $mailContent); ?>
+               <?php endif; ?>
        <?php endif; ?>
 <?php endif; ?>        
 </div>
diff --git a/guadec/page-4903.php b/guadec/page-4903.php
new file mode 100644
index 0000000..b1680c3
--- /dev/null
+++ b/guadec/page-4903.php
@@ -0,0 +1,69 @@
+<?php
+// Restricted Admin Access. View Registration details.
+global $wpdb;
+function display_result($result){
+       echo "<table class='regtable'><tr><th>ID</th><th>Name</th>
+                               <th>Email</th><th>Gender</th>
+                               <th>Arrival</th><th>Departure</th>
+                               <th>Sponsored</th><th>Lunch-Days</th>
+                               <th>EntryFee</th>
+                               <th>LunchFee</th><th>AccomFee</th>
+                               <th>TotalFee</th>
+                               <th>Payment Status</th></tr>";
+       foreach($result as $results){
+               echo "<tr>";
+               echo "<td>"; echo $results['id']; echo "</td>";
+               echo "<td>"; echo $results['name']; echo "</td>";
+               echo "<td>"; echo $results['email']; echo "</td>";
+               echo "<td>"; echo $results['gender']; echo "</td>";
+               echo "<td>"; echo $results['arrive']; echo "</td>";
+               echo "<td>"; echo $results['depart']; echo "</td>";
+               echo "<td>"; echo $results['sponsored']; echo "</td>";
+               echo "<td>"; echo $results['lunchdays']; echo "</td>";
+               echo "<td>"; echo $results['entryfee']; echo "</td>";
+               echo "<td>"; echo $results['lunchfee']; echo "</td>";
+               echo "<td>"; echo $results['accomfee']; echo "</td>";
+               echo "<td>"; echo $results['totalfee']; echo "</td>";
+               echo "<td>"; echo $results['payment_status']; echo "</td>";
+               echo "</tr>";
+       }
+       echo "</table>";
+}
+require_once("header.php");
+ if( !(current_user_can( 'administrator' ) )){
+       echo "You are not authorised to view this page.";
+ }
+else{
+       echo "<form method='post' action=''>
+               <div><select id='viewtype' name='viewtype'>
+       <option value='showall' selected='selected'>Show All Entries</option>
+       <option value='showcomplete'>Only Completed Registration</option>
+               </select></div>
+               <input type='submit' value='Go' />
+               </form>";
+
+       if(isset($_POST['viewtype']) && !empty($_POST['viewtype'])) {
+           $action = $_POST['viewtype'];
+           switch($action) {
+
+               case 'showall' :
+                   $result = $wpdb->get_results('SELECT * FROM registered', ARRAY_A);
+                       echo display_result($result);
+                       break;
+               case 'showcomplete' :
+                       $result = $wpdb->get_results("SELECT * FROM registered WHERE payment_status = 
'Completed' OR payment_status ='NoPayment-0'", ARRAY_A);
+                       echo display_result($result);
+                       break;
+                   
+                   default :
+                       $result = 'Error';
+               break;
+               
+           }
+       }
+       else{
+               echo 'Select an option';
+       }
+}
+require_once("footer.php");
+?>
\ No newline at end of file
diff --git a/guadec/style.css b/guadec/style.css
index 1a54625..34ba52e 100755
--- a/guadec/style.css
+++ b/guadec/style.css
@@ -126,6 +126,11 @@ h1, h2, h3, h4, h5, h6 {
     }
 }
 
+/* View Registered Table */
+.regtable {
+    border: 5;
+    width: 100%;
+}
 /*
  * Footer
  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]