include_once("../common/includes/settings.php"); require_once('settings/config.php'); include_once("../common/classes/Carbon.php"); $sandbox_mode=false; require_once('settings/paypal_config.php'); use Carbon\Carbon; $reg_end_date = Carbon::createFromFormat('Y-m-d H:i:s', '2016-02-22 00:00:00'); // Redirect to index when registration period ends if(Carbon::now() >= $reg_end_date) { header("Location: ".$GLOBAL_HOSTHTTP_URL."/togo810/index.php"); exit; } ## Redirect if not Login if (!isInSession()) { header ("Location: ".$GLOBAL_HOSTHTTP_URL."/members/login.php?cb=".urlencode($THISURL->getUrl())); exit; } $user = new User(getSessionUserid()); if ($user->isBanned()) { header ("Location: ".$GLOBAL_HOSTHTTP_URL."/common/logout.php"); exit; } $db->where('userid', getSessionUserid()); if($db->has('challenge_users')) { header("Location: ".$GLOBAL_HOSTHTTP_URL."/togo810/thank-you.php"); exit; } $registration_limit = 1000; $challenge_users = ChallengeUser::get(); $waiting = count($challenge_users) > $registration_limit ? true : false; $populate = false; $user_waiting = ChallengeSignupWaitingList::where('userid', getSessionUserid())->get(); if(count($user_waiting) > 0) { $populate = true; if($waiting) { header ("Location: ".$GLOBAL_HOSTHTTP_URL."/togo810/registration_waiting_list.php"); exit; } } $challengeDetail = ChallengeDetail::byId(1); //Togoparts 810 $now=date('Y-m-d H:i:s'); //to replace mysql NOW() //Process Form if(isset($_POST['Submit'])) { $dob = Carbon::parse($_POST['dob']); if($waiting) { //PUT TO WAITING LIST $ChallengeSignup = new ChallengeSignupWaitingList; } else { //SIGNUP $ChallengeSignup = new ChallengeSignup; } //Check for form validation //populate $ChallengeSignup $ChallengeSignup->cid = $challengeDetail->cid; //1 Togo810 $ChallengeSignup->userid = getSessionUserid(); $ChallengeSignup->first_name = $_POST['first_name']; $ChallengeSignup->last_name = $_POST['last_name']; $ChallengeSignup->gender = $_POST['gender']; $ChallengeSignup->email = $_POST['email']; $ChallengeSignup->mobile = $_POST['mobile']; $ChallengeSignup->address = $_POST['address']; $ChallengeSignup->city = $_POST['city']; $ChallengeSignup->country = $_POST['country']; $ChallengeSignup->postal_code = $_POST['postal_code']; $ChallengeSignup->jersey_size = $_POST['jersey_size']; $ChallengeSignup->axa = isset($_POST['axa']) ? 1 : 0; $ChallengeSignup->nric = isset($_POST['nric']) ? $_POST['nric'] : ""; $ChallengeSignup->dob = $dob->format('Y-m-d'); $ChallengeSignup->date_created = $now; $ChallengeSignup->date_modified = $now; $sid = $ChallengeSignup->save(); if(!$sid>0) { //echo('Signup insertion error'); sendErrorEmail('Togo810 Registration Error', 'Signup insertion error'); //exit; } else { //echo "Registration Successful."; } //echo('sid='.$sid.''); if($waiting) { $message = $ChallengeSignup->first_name . ' ' . $ChallengeSignup->last_name . ' has been put on the waiting list.'; $header = "MIME-Version: 1.0\n"; $header .= "Content-type: text/html; charset=\"iso-8859-1\"\n"; $header .= "Bcc: marvin.baga@oneshift.com\r\n"; $header .= "From: togo810@togoparts.com \n"; $header .= "X-Sender: \n"; $header .= "X-Mailer: PHP\n"; //mailer $header .= "X-Priority: 3\n"; $header .= "Return-Path: \n"; @mail('togo810@togoparts.com', 'TOGO810 Waiting List Signup', $message, $header); header ("Location: ".$GLOBAL_HOSTHTTP_URL."/togo810/registration_waiting_list.php"); exit; } //PayPal log $paypalLog = new PayPalLog; $paypalLog->item = $challengeDetail->name; $paypalLog->currency = 'SGD'; $paypalLog->amount = $challengeDetail->price; $paypalLog->userid = getSessionUserid(); $paypalLog->reference = ''; //store paypal receipt_ID, empty first $paypalLog->status = 0; $paypalLog->transactiondate = $now; //now $paypalLog->transactiondate_rtn = $now; //now $paypalLog->date_created = $now; //now $paypal_log_id = $paypalLog->save(); //insert first to get the id to passback to signup //echo('ppid='.$paypal_log_id.''); if(!$paypal_log_id>0) { error_log('Paypal Log insertion error'); sendErrorEmail('Togo810 Registration Error', 'Paypal Log insertion error'); //exit; } //https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/ $ppAmount = $challengeDetail->price; //test users if(getSessionUserid()==31788) { //$ppAmount=0.5; } $paypalParams = '?cmd=_xclick'; $paypalParams .= '&business='.urlencode($togoparts_reciever_email); $paypalParams .= '&item_name='.urlencode($challengeDetail->name); $paypalParams .= '&item_number='.urlencode($challengeDetail->name); $paypalParams .= '&amount='.urlencode($ppAmount); $paypalParams .= '¬ify_url='.urlencode($CHALLENGE_NOTIFY_URL); $paypalParams .= '&return='.urlencode($CHALLENGE_SUCCESS_URL); $paypalParams .= '&cancel_return='.urlencode($CHALLENGE_CANCEL_URL); $paypalParams .= '&cpp_header_image='.urlencode($CHALLENGE_HEADER_IMG); $paypalParams .= '&custom='.urlencode($paypal_log_id); $paypalParams .= '&rm=2'; //Return method - the buyer's browser is redirected to the return URL by using the POST method, and all payment variables are included $paypalParams .= '&city=Singapore'; $paypalParams .= '&country=SG'; $paypalParams .= '&cpp_headerback_color='.urlencode('#FFFFFF'); $paypalParams .= '&cpp_headerborder_color='.urlencode('#FFFFFF'); $paypalParams .= '&display=1'; $paypalParams .= '&image_url='.urlencode('http://www.togoparts.com/images/togoparts_logo_pp_150x150.gif'); $paypalParams .= '&shipping=0.00'; $paypalParams .= '&no_shipping=1'; $paypalParams .= '&no_note=1'; $paypalParams .= '¤cy_code=SGD'; $paypalParams .= '&tax=0.00'; $paypalParams .= '&lc=SG'; $paypalParams .= '&bn=PP-BuyNowBF'; $payPalSubmit = $paypal_url.$paypalParams; //Update paypal_log wiht message - get params $ppMessage = 'GET VARS: '.$paypalParams; $updateArray = array('message'=>$ppMessage); $db->where('id', $paypal_log_id); $db->update('paypal_log', $updateArray); //Update signup with paypal_id to prepare for IPN notifiy $updateArray = array('paypal_log_id'=>$paypal_log_id); $db->where('sid', $sid); $db->update('challenge_signup', $updateArray); //echo($payPalSubmit); exit; header("Location: ".$payPalSubmit); exit; } ## Fill in the following for SEO $canonical_url = 'http://www.togoparts.com/pages/index.php'; $WEBPAGE_TITLE = "TOGO810 Registration | ".$GLOBAL_PORTAL_NAME; $meta_description = "Register for the TOGO810 Challenge"; $meta_keywords = ""; $canonical_url = ""; //for canonical meta rel tag if applicable $noSitetakeover = true; ?> require_once ($GLOBAL_ABSOLUTE_PATH."/common/includes/htmlheader-new.inc.php");?> // Facebook Pixel Code ?> // End Facebook Pixel Code ?> Home ยป Registration Registration First Name Last Name / Surname: Date of Birth: Gender: - Male Female View Sizing Chart Email $userEmail = $user->getEmail(); ?> Mobile Number: Address: City: Country: GlobalGenSelectCountrySelector($country, "single","form-control", $popCountry); ?> Postal Code: Jersey Size: Jersey Size XXS XS S M L XL XXL XXXL View Sizing Chart /* I wish to receive a complimentary Personal Accident Insurance from AXA worth $50,000 - limited to first 200 participants only. I agree to allow a representative of AXA Life Insurance to contact me for a follow up NRIC: Insurance is applicable for Singaporeans or PR residing in Singapore only. */ ?> Terms & Conditions Completion of the entry form confirms the Participants' agreement to abide by the Rules & Regulations of the Togoparts810. Read the Rules & Regulations here. Liability and Disclaimers I fully understand and acknowledge the risks involved in my participation in the Event and I accept full responsibility and assume all such risks. I Agree with the Terms & Conditions. You have to agree to our terms and conditions. /* */ ?> if($waiting) { ?> We have reached our limit of participants. You may register your interest to be in our priority waiting list, and we will notify you if we increase the number of participants. Go on the Waitlist } else { ?> Checkout } ?> include_once "terms-modal-inc.php"; ?> include_once('../common/includes/google_analytics.php'); ?>