> This site is using 128bit Encryption. If you have any queries please phone +44 (0) 800 9174385 <<"; private $msgStd = ">> Welcome to Strafford Self-drive <<"; private $msgSubDetails = ">> Please enter/amend your details and click Proceed to continue. Click Cancel to exit without saving <<"; private $VAT = "";//GB620552277 private $weekendBookingDiscount; private $bookingSource; private $viewCategory; private $categories; private $pointerCategories; private $message; private $tmpDriver = null; function RentalManager($CID,$user,$bookingSource,$holidays,$appSettings){ parent::__construct($CID,$user,"service_rental",mysql_fetch_array($appSettings)); $this->bookingSource = $bookingSource; $this->loadAutoClasses(); $this->parseLinks(); //loads vehicle/group info //Sort any autogen objects that need it - eg Occupations foreach($this->occupation as $res) $sortAux[] = $res->getName(); array_multisort($sortAux,SORT_ASC,$this->occupation); //Extract branch closed dates $num = mysql_num_rows($holidays); for($i=0;$i<$num;$i++){ $data = mysql_fetch_array($holidays); array_push($this->closed_name, $data['n_name']); array_push($this->closed_start, $data['n_from']." 00:00"); array_push($this->closed_end, $data['n_to']." 23:59"); } $this->numColsVehicle = 5; if($bookingSource=="I") $this->numColsGroup = 5; else $this->numColsGroup = 2; $this->addBooking(); $this->currentBooking = 0; $this->position = 0; $this->positionReached = 0; $this->viewCategory = -1; $this->settings[0]->setOfficeOpenWk($this->fixDate($this->settings[0]->getOfficeOpenWk(),$this->settings[0]->getOfficeBuffer())); $this->settings[0]->setOfficeOpenSat($this->fixDate($this->settings[0]->getOfficeOpenSat(),$this->settings[0]->getOfficeBuffer())); $this->settings[0]->setOfficeOpenSun($this->fixDate($this->settings[0]->getOfficeOpenSun(),$this->settings[0]->getOfficeBuffer())); $this->settings[0]->setOfficeCloseWk($this->fixDate($this->settings[0]->getOfficeCloseWk(),$this->settings[0]->getOfficeBuffer())); $this->settings[0]->setOfficeCloseSat($this->fixDate($this->settings[0]->getOfficeCloseSat(),$this->settings[0]->getOfficeBuffer())); $this->settings[0]->setOfficeCloseSun($this->fixDate($this->settings[0]->getOfficeCloseSun(),$this->settings[0]->getOfficeBuffer())); } function outputError($sql){ $trace = debug_backtrace(); //var_dump(debug_backtrace()); echo "[[ MySQL Error ]]
" . "Database: ".$this->ConnDB."
" . "Function: ".$trace[1]['function']."() [line: ".$trace[0]['line']."]
" . "Calling Function: ".$trace[2]['function']."() [line: ".$trace[1]['line']."]
" . "SQL: ".$sql."
" . "Error: ".mysql_error()."
"; } //Returns the Settings object!! function getSettings(){ return $this->settings[0]; } //We should prob make this generic @ somepoint and add to Service // /*for($i=0;$icategories);$i++){ echo $this->categories[$i][0]->getName()."
"; for($j=0;$jcategories[$i][1]);$j++){ echo " ".$j." ".$this->categories[$i][1][$j][0][0]->getName()."{".count($this->categories[$i][1][$j][0][1])."}
"; for($k=0;$kcategories[$i][1][$j][0][1]);$k++){ echo " ".$j.".".$k." ".$this->categories[$i][1][$j][0][1][$k][0]->getMake()." ".$this->categories[$i][1][$j][0][1][$k][1]."
"; } } }*/ function parseLinks(){ //Create Categories array $this->categories = array(); $this->categories = $this->parseLink("2",$this->parseLink("1",$this->vehicle,$this->group),$this->category); } function parseLink($linkNum,$arraySource,$arrayGroup){ $items = array(); //Cycle Groups in Category for($i=0;$igetRID()." ".$arrayGroup[$i]->getName()."
"; } $link = "link".$linkNum; for($i=0;$i$link);$i++){ //if($i==90)$i++; //echo "{".$i."} Trying to Add LINK Source RID Entry ".$this->{$link}[$i]->getRIDSource()."..."; //echo "Success ".$arraySource[$this->{$link}[$i]->getRIDSource()-1]->getRegistrationNumber()." ".$arraySource[$this->{$link}[$i]->getRIDSource()-1]->getMake()." to ".$items[$this->{$link}[$i]->getRIDGroup()-1][0]->getName()."
"; //echo " :RID: ".$this->{$link}[$i]->getRIDSource().":".$this->{$link}[$i]->getRIDGroup()." ".$arrayPosSrc." ".$arrayPosGrp."
"; $arrayPosSrc = $this->{$link}[$i]->getRIDSource()-1; $arrayPosGrp = $this->{$link}[$i]->getRIDGroup()-1; /*echo "Adding $i ".$arraySource[$arrayPosSrc]->getRegistrationNumber()." ". $arraySource[$arrayPosSrc]->getMake()." to ". $items[$arrayPosGrp][0]->getName(). " :RID: ".$this->{$link}[$i]->getRIDSource().":".$this->{$link}[$i]->getRIDGroup()." ".$arrayPosSrc." ".$arrayPosGrp."
";*/ $element = array($arraySource[$arrayPosSrc],$this->{$link}[$i]->getPrimary()); array_push($items[$arrayPosGrp][1],$element); } return $items; } //Returns the Cat tree - used by Rental Booking function getCategories(){ return $this->categories; } //Need to recall vehicle Obj from tree //Used when recalling a booking from a database function getVehicle($reg,$grp){ $Conn = $this->getDBConn(); $dataVehicle = $Conn->getQuickDetails("a_vehicle","n_registration_number",$reg,"","",0,0); $rowVehicle = mysql_fetch_array($dataVehicle); $dataGroup = $Conn->getQuickDetails("a_group","n_name",$grp,"","",0,0); $rowGroup = mysql_fetch_array($dataGroup); //echo "looking for ".$reg." in ".$grp; //Cycle through data structure for($i=0;$icategories);$i++){ //Cycle through Groups for($j=0;$jcategories[$i][1]);$j++){ $groupEl = $this->categories[$i][1][$j]; if($groupEl[0][0]->getName()==$grp){ //Search for Vehicle for($k=0;$kcategories[$i][1][$j][0][1]);$k++){ $vehicle = $this->categories[$i][1][$j][0][1][$k][0]; if($vehicle->getRegistrationNumber()==$reg){ return $vehicle; //echo "FV:".$vehicle->getMake()." ".$vehicle->getRegistrationNumber(); } } } } } } function performActionAddBooking(){ $this->addBooking(); $this->selectBooking(count($this->bookings)-1); $this->setCurrentPos(0); $this->message = "Enter the details for Booking ".count($this->bookings); } function getCurrentPos(){ return $this->position; } function performActionRecallBooking(){ $this->selectBooking($_GET['num']); } function performActionDelBooking(){ $pos = ($_GET['num']!=""?$_GET['num']:$this->currentBooking); if($pos!=(count($this->bookings)-1)){ for($i=$pos;$i<(count($this->bookings)-1);$i++) $this->bookings[$i] = $this->bookings[$i+1]; } array_pop($this->bookings); //$num = 0; //($this->currentBooking>0?$this->currentBooking-1:) $this->selectBooking(0); } function performActionResetSystem(){ //preserve drivers!! $drivers = $this->bookings[0]->getDriverArray(); $this->bookings = array(); $this->addBooking(); $this->currentBooking = 0; $this->position = 0; $this->positionReached = 0; $this->bookings[0]->setDriverArray($drivers); } function getButtonNext(){ $max = count($this->steps)-2; //Do not show on sub page!! if($this->subPage!=""){ switch($this->subPage){ case "Details": $driver = $this->getCurrentBooking()->getCurrentDriver(); $isAdd = (isset($driver)?false:true); if($isAdd){ $button1Text = "Add New Driver"; //$button1Image = "http://".$_SERVER['HTTP_HOST']."/Resources/Rental/Button_AddDriver.gif"; }else{ $button1Text = "Update Driver Details"; //$button1Image = "http://".$_SERVER['HTTP_HOST']."/Resources/Rental/Button_SaveDriver.gif"; } $nextButton = ""; break; default: $nextButton = " "; break; } }else{ if($this->getStepNumber()<$max) $nextButton = ""; else $nextButton = " "; } return $nextButton; } function getButtonBack(){ //Do not show on sub page!! if($this->subPage!=""){ $backButton = " "; }else{ if($this->getStepNumber()>0) if($this->getStepNumber()>5) if($this->getStepNumber()>6) $backButton = ""; else $backButton = ""; else $backButton = ""; else{ if($this->getStepNumber()<6) $backButton = " "; } } return $backButton; } function addBooking(){ $booking = new RentalBooking($this,$this->settings[0]->getBookingBuffer(),$this->bookingSource); /*if(count($this->bookings)>0) $booking->setDriverArray($this->bookings[0]->getDriverArray());*/ array_push($this->bookings,$booking); } function selectBooking($num){ $this->currentBooking = $num; $this->position = 4; } /*function formatNumber($sign,$num){ return $sign.number_format($num, 2); }*/ function getCurrencyRates(){ return array($this->settings[0]->getRateEuro(),$this->settings[0]->getRateDollar); } // seed with microseconds /*function make_seed() { list($usec, $sec) = explode(' ', microtime()); return (float) $sec + ((float) $usec * 100000); }*/ function getStepNumber(){ return $this->position; } function fixDate($time, $booking_buffer){ $parts = explode(":",$time); if(($parts[1]+$booking_buffer) > 59) return ($parts[0]+1).":".(($parts[1]+$booking_buffer)-60); else if(($parts[1]+$booking_buffer) < 0) return ($parts[0]-1).":".(60+($parts[1]+$booking_buffer)); else return $parts[0].":".($parts[1]+$booking_buffer); } /*function getPagePrevious(){ if($this->position > 0) $this->position--; $func = "getPage".$this->steps[$this->position]; return $this->$func(); }*/ function goBack(){ if($this->position > 0) $this->position--; $this->clearSub(); } //Clears the sub page call function clearSub(){ $this->message = ""; $this->subPage = ""; } function performActionCancelDetails(){ $this->tmpDriver = null; $currentDRNum = ($this->getCurrentBooking()->getNumDrivers()==0?$this->getCurrentBooking()->getNumDrivers()+1:$this->getCurrentBooking()->getNumDrivers()); $this->getCurrentBooking()->setCurrentDriverNum($currentDRNum); //echo "NOC".$this->getCurrentBooking()->getNumDrivers(); $this->clearSub(); } function advance(){ $this->position++; if($this->position>$this->positionReached) $this->positionReached++; $this->clearSub(); } /*function getPageNext(){ $this->position++; if($this->position>$this->positionReached) $this->positionReached++; $func = "getPage".$this->steps[$this->position]; return $this->$func(); }*/ //Returns the current page function getPage(){ //Check to see if there is a subpage set - if so return it! if($this->subPage!="") $func = "getPage".$this->subPage; else $func = "getPage".$this->steps[$this->position]; return $this->$func(); } //Sets the position reached - needed for when booking through OMC (as otherwise fetching the location page //resets the dates! as pos=0) function setPositionReached($pos){ $this->positionReached = $pos; } function getPositionReached(){ return $this->positionReached; } function setCurrentPos($pos){ $this->position = $pos; } function getMessage(){ if($this->message!="") return "".$this->message.""; else{ if($this->subPage!=""){ switch($this->subPage){ case "Details": return "".$this->msgSubDetails.""; break; } } if($this->getStepNumber()>4) return "".$this->msgSSL.""; else return "".$this->msgStd.""; } } //Returns code for STEPS along top function getSteps(){ $pageHTML = ""; for($i=0;$isteps);$i++){ $protocol = "http"; if($i>4) $protocol = "https"; //$pageHTML .= "".($this->positionReached>=$i?"steps[$i]."';alert(document.rental.action);document.rental.submit();\">":"")."position==$i?" class=\"borderStep\"":"")." src=\"http://".$_SERVER['HTTP_HOST']."/Resources/Rental/Step".($i+1).($this->positionReached>=$i?"":"_faded").".gif\" border=0>".($this->positionReached>=$i?"":"").""; $pageHTML .= "position==$i?" class=\"borderStep\"":"")." src=\"http://".$_SERVER['HTTP_HOST']."/Resources/Rental/Step".($i+1).($this->positionReached>=$i?"":"_faded").".gif\" border=0>"; } return $pageHTML; } /*function getPageSteps(){ $dest = "getPage".$_GET[destpage]; $action = "performAction".$this->steps[$this->position]; $this->$action(); return $this->$dest(); }*/ //Returns code for STEPS along top function getPageThankYou(){ //$this->position = 7; $Conn = $this->getDBConn(); $pageHTML = "
Thank you for booking with Strafford On-line.

".$this->getCurrentBooking()->getQuoteOutput(true,false,"Your Booking Information"); $pageHTML .= "
Grand Total
".$this->getCRB()->formatNumber($this->getGTotal())."
"; //Add option for immediate CheckOut if OMC if($this->bookingSource=="W") $pageHTML .= "" . " " . "
getCurrentBooking()->getRID()."\">Check Vehicle Out Now
"; //Clean Bookings Array; //$this->resetSystem(); return $pageHTML; } function performActionPayment(){ $paymentMethod = $_POST['paymentMethod']; for($i=0;$ibookings);$i++) $this->bookings[$i]->setPaymentMethod($paymentMethod); if($paymentMethod=="CREDIT CARD"){ //Check From date has not passed $todayYear = date("Y"); $todayMonth = date("m"); //echo $todayMonth.$todayYear; if(($_POST['ccard_from_year']>$todayYear) || (($_POST['ccard_from_month']>$todayMonth)&&($_POST['ccard_from_year']==$todayYear))){ //header("Location: ".$_SERVER['PHP_SELF']."?rentalPage=".$this->steps[$this->position]."&msg=Please Enter: A valid From date"); $this->message = "Please Enter: A valid From date"; return; } //Check Expiry is later than From date if(($_POST['ccard_from_year']>$_POST['ccard_expiry_year']) || (($_POST['ccard_from_month']>$_POST['ccard_expiry_month'])&&($_POST['ccard_from_year']==$_POST['ccard_expiry_year']))){ //header("Location: ".$_SERVER['PHP_SELF']."?rentalPage=".$this->steps[$this->position]."&msg=Please Enter: A valid Expiry date"); $this->message = "Please Enter: A valid Expiry date"; return; } } //MAKE BOOKING $Conn = $this->getDBConn(); //ONLY do this if we are not Extending an existing booking!! if($this->getCRB()->getExtNum()==0){ //Get BookingID(s) - Lock Table $bookingID = "STR".$Conn->lockUpdate("a_settings"); $alpha = array("A","B","C","D","E"); for($i=0;$ibookings);$i++) $this->bookings[$i]->setBookingID($bookingID,$alpha[$i]); } //$Conn->updateItem("n_settings",array("n_next_booking_num"),array($row['n_next_booking_num']+1),""); //$Conn->unlockTable("n_settings"); $driver = $this->bookings[0]->getDriver(1); for($i=0;$ibookings);$i++) $this->bookings[$i]->saveBookingToDB($Conn,$driver->getEmail(),"",0); $cardType = $_POST['ccard_type']; $cardNumber = $_POST['ccard_number']; $CIVNumber = $_POST['ccard_civnumber']; $cardFrom = $_POST['ccard_from_month']."/".$_POST['ccard_from_year']; $cardExpiry = $_POST['ccard_expiry_month']."/".$_POST['ccard_expiry_year']; $cardIssue = $_POST['ccard_issue']; for($i=0;$ibookings);$i++){ $quote = $this->bookings[$i]->getQuoteOutput(true,false,"Your Booking Information"); $detailedQuote = $this->bookings[$i]->getQuoteOutput(true,true,"Your Booking Information"); $quoteCustomer = "" . "
Please ensure you have on collection or delivery of your hired vehicle:
  1. The valid drivers licence/licences that were submitted at the time of booking
  2. The credit/debit card they used to book for inspection
  3. Two other forms of identification other than drivers licences.
". $quote. "
". "
Deposit [authorisation only*]: ".$this->formatNumber($this->bookings[$i]->getBookingDeposit())."
*Deposits will be debited and then refunded for hire periods of 6+ days or where the Payment Method is: Switch, Solo or Electron.
" . "
".$this->tandc."
"; $quoteClient = "" . "
Please ensure you have on collection or delivery of your hired vehicle:
  1. The valid drivers licence/licences that were submitted at the time of booking
  2. The credit/debit card they used to book for inspection
  3. Two other forms of identification other than drivers licences.
". "
".$quote."".$detailedQuote."
". //Additional Information "
". "" . ($this->bookings[$i]->getRoadRisks()=="N"?"
Deposit [authorisation only*]: ".$this->formatNumber($this->bookings[$i]->getBookingDeposit())."
*Deposits will be debited and then refunded for hire periods of 6+ days or where the Payment Method is: Switch, Solo or Electron.
Customer has selected NO for ROAD RISKS Insurance (Sight of Insurance is REQUIRED on Collection/Delivery)
":""). "
".$this->tandc."
"; //Email Confirmation to Main Driver (customer) $toAddrs = array($driver->getEmail()); $this->email($toAddrs,"Your Booking Confirmation [".$this->bookings[$i]->getBookingID()."]",$quoteCustomer,false); //Email Confirmation + Payment details (encrypted) to Client $toAddrs = array("bookings@strafford.co.uk"); $subjectBC = "[".$this->bookings[$i]->getBookingID()."]".($this->bookingSource=='W'?" OMC":"")." Customer Booking Confirmation"; $subjectPI = "[".$this->bookings[$i]->getBookingID()."]".($this->bookingSource=='W'?" OMC:".$paymentMethod:"")." Customer Payment Information"; $this->email($toAddrs,$subjectBC,$quoteClient,false); $this->email($toAddrs,$subjectPI,$this->getCurrentBooking()->getBooking($paymentMethod,$cardType,$cardNumber,$CIVNumber,$cardFrom,$cardExpiry,$cardIssue), true); } $this->advance(); } function getPagePayment(){ //$this->position = 6; $startYear = date("Y",time()); $startDateBuf = 5; $paymentCards = array("VISA","Mastercard","Maestro","American Express","Solo","Electron","Diners Club"); //JS to handle multiple submit buttons $pageHTML = ""; //Re-assurance Message $pageHTML .= "" . "
OUR GUARANTEE TO YOU: This transaction is processed securely and safely through HSBC card processing and Strafford GB Ltd
We pride ourselves on customer security and peace of mind. We fully understand the importance of being able to speak to someone about any concerns; problems; mistakes; refunds; amendments immediately. This is why we insist on when you dial 0800 917 4385 free of charge Strafford self drive will answer the phone personally and without delay (during office hours) to rectify any payment card transactions or other concerns you may have with your account. This is all dealt with in house and you will not be transferred from person to person.

"; //Total Amount + Deposit Amount //- Deposit [authorisation only*]: �".number_format($this->getCurrentBooking()s[$this->currentBooking]->getBookingDeposit(),2)." //"*Deposits will be debited and then refunded for hire periods of 6+ days or where the Payment Method is: Switch, Solo or Electron. $GTotal = $this->getGTotal(); $pageHTML .= "" . "
Total Amount: ".$this->formatNumber($GTotal)." / €".number_format($GTotal*$this->settings[0]->getRateEuro(),2)."* / $".number_format($GTotal*$this->settings[0]->getRateDollar(),2)."*
*approximate equivalent values, booking transactions are carried out in Pound Sterling.

" . "
"; if($this->bookingSource=="W") $pageHTML .= "" . "
Payment Method
" . " Credit Card" . " Cash" . " Cheque" . " Account

"; else $pageHTML .= ""; $pageHTML .= "" . "" . "
Please enter your payment details
Select Card Type:
Card Number:
CIV Number: (last 3/4 digits on signature strip)
From Date: / (mm/yy)
Expiry date: / (mm/yy)

Issue number: (Maestro/Solo only)

" . "
I Agree to Strafford GB Ltd's Terms and Conditions

Authorise Transaction and Confirm Booking". // "
"; return $pageHTML; } //Fetches driver details from POST array //Added because both Page and Action of Personal needs this! function captureDriverDetails(){ //calculate database values - MYSQL DATES HAVE A SPECIFIC FORMAT!! $DOB = $_POST['DOB_year']."-".$_POST['DOB_month']."-".$_POST['DOB_day']; $expiry = $_POST['expiry_year']."-".$_POST['expiry_month']."-".$_POST['expiry_day']; $VATReceipt = ($_POST['VATReceipt']=="on"?"Y":"N"); $driver = new RentalDriver(); $driver->setDriverDetails($_POST['email'],$_POST['title'],$_POST['sex'],$_POST['first_name'],$_POST['last_name'],$_POST['occupation'], $_POST['address_1'],$_POST['address_2'],$_POST['postcode'],$_POST['town'], $_POST['county'],$_POST['country'],$_POST['tel'],$_POST['mobile'], $_POST['fax'],$_POST['nationality'],$DOB,strtoupper($_POST['licence_number']),$expiry, $_POST['held'],$_POST['licence_nationality'],$_POST['full_licence'],$_POST['accident_claim'], $_POST['disqualification'],$_POST['motor_insurance'],$_POST['medical_condition'],$VATReceipt); $driver->setPassword($_POST['password']); return $driver; } function performActionPersonal(){ $Conn = $this->getDBConn(); //check at least one driver has been entered for Each Booking for($i=0;$ibookings);$i++){ $bookNum = $i+1; $driver = $this->bookings[$i]->getDriver(1); if(!isset($driver)){ //$this->message = "Booking ".$bookNum.": You must enter the details of at least 1 driver!"; $this->getCurrentBooking()->setCurrentDriverNum(1); $this->subPage = "Details"; return; } //Check Driver over Minimum Group Age (if set) on Earliest From date (remember multiple bookings) //0 = No min age set $data = $Conn->getQuickDetails("a_group","n_name",$this->bookings[$i]->getGroup(),"","","",""); $row = mysql_fetch_array($data); $minAge = $row['n_minimum_age']; if($minAge!=0){ $earFrom = strtotime($this->bookings[$i]->getFromDate()); for($j=0;$j<$this->bookings[$i]->getNumDrivers();$j++){ $driverNum = $j+1; $driver = $this->bookings[$i]->getDriver($driverNum); $DOB = explode("-",$driver->DOB); $TSDOB = mktime(0,0,0,$DOB[1],$DOB[2],$DOB[0]+$minAge); //echo $earFrom."::".$TSDOB; if($TSDOB>$earFrom){ $this->message = "Booking ".$bookNum." | Driver ".$driver->getName().": You must be ".$minAge."+ to book this vehicle with Strafford online!"; return; } } } } $this->advance(); } //Stores driver(s) details function performActionDetails(){ //$driverNum = $_POST[driver_num]; $Conn = $this->getDBConn(); $this->tmpDriver = $this->captureDriverDetails(); //$dataSet = $Conn->getQuickItems("n_settings"); //$rowSet = mysql_fetch_array($dataSet); $this->message = ""; //Check the insurance questions have been answered! if(($_POST['full_licence']=="")||($_POST['disqualification']=="")||($_POST['motor_insurance']=="")||($_POST['medical_condition']=="")){ $this->message = "You must complete the motor insurance questions"; return; } if($_POST['full_licence']!="Y"){ $this->message = "You must have a Full Licence to book with Strafford online!"; return; } //Check Driving Licence is Valid if UK Customer /*if($_POST[licence_nationality]=="UNITED KINGDOM"){ $licence = strtoupper($_POST[licence_number]); $licenceCheck = ""; //(strlen($_POST[last_name])>4?5:strlen($_POST[last_name])); for($i=0;$i<5;$i++){ if(strlen($_POST[last_name])>$i) $licenceCheck .= strtoupper(substr($_POST[last_name],$i,1)); else $licenceCheck .= "9"; } $licenceCheck .= substr($_POST[DOB_year],2,1).($_POST[sex]=="M"?$_POST[DOB_month]:(substr($_POST[DOB_month],0,1)+5).substr($_POST[DOB_month],1,1)).$_POST[DOB_day].substr($_POST[DOB_year],3,1); $licenceCheck .= substr($_POST[first_name],0,1); $licenceCheck = strtoupper($licenceCheck); if(($licenceCheck!=substr($licence,0,12)) || (strlen($licence)!=16)){ header("Location: ".$_SERVER['PHP_SELF']."?rentalPage=".$this->steps[$this->position]."&driver_num=".$this->currentDriver."&msg=Driving Licence Number [".$_POST[licence_number]."] does not match your details!"); return; } }*/ //Check Required Fields are not empty... $requiredFields = array("first_name","last_name","occupation","address_1","postcode","county","tel","licence_number","DOB_year","DOB_month","DOB_day"); if($this->getCurrentBooking()->getCurrentDriverNum()==1) $requiredFields = array_push($requiredFields, "email","password","confirm_password"); $error = ""; for($i=0;$imessage = "Please Enter: ".$error; return; } //Check Driver over Minimum Age to Book $adjYear = $_POST['DOB_year']+$this->settings[0]->getMinimumAge(); $TSFrom = mktime(); //strtotime($this->bookings[0]->getFromDate()); $TSDOB = mktime(0,0,0,$_POST['DOB_month'],$_POST['DOB_day'],$adjYear); if($TSDOB>$TSFrom){ $this->message = "You must be ".$this->settings[0]->getMinimumAge()."+ to book with Strafford online!"; return; } //Update User //check password is correct for user - if they already exist! $data = $Conn->getItems("n_user",array("n_email"),array($_POST['email']),array(false,false),array("",""),"","","",false); $values = $this->tmpDriver->getDriverArray(); if(mysql_num_rows($data)!=0){ $data = $Conn->getItems("n_user",array("n_email","n_password"),array($_POST['email'],$_POST['password']),array(false,false),array("","AND"),"","","",false); if(mysql_num_rows($data)==0) $error = "Correct password for ".$_POST['email']."."; else{ $row = mysql_fetch_array($data); array_unshift($values,$row['x_RID']); $res = $Conn->updateItem("n_user",$Conn->getTableFields("n_user"),$values,$values[0]); //Set the RID here just incase they have entered the correct details on the Personal Page //but not logged in (hit Get Details) $this->tmpDriver->setRID($row['x_RID']); } }else{ $RID = $Conn->addItem("n_user",$values, false); $this->tmpDriver->setRID($RID); } //Success! OVERWRITE/ADD driver in DB //"CRYPT".$this->passwordKey. //Handle other drivers if($this->getCurrentBooking()->getCurrentDriverNum() < ($this->getCurrentBooking()->getExtraDriver()+1)){ //header("Location: ".$_SERVER['PHP_SELF']."?rentalPage=".$this->steps[$this->position]."&driver_num=".($this->currentDriver+1)); $this->message = ""; return; } //If there are no errors (empty message) then clear the sub page. if($this->message==""){ $this->subPage=""; $this->getCurrentBooking()->setDriver($_POST['driver_num'],$this->tmpDriver); $this->getCurrentBooking()->getCurrentDriver()->setPassword($_POST['password']); $this->tmpDriver = null; } //echo $this->message; //$this->advance(); } function performActionRemoveDriver(){ $this->getCurrentBooking()->removeDriver($_GET['driverNum']); } //Fetches driver details from DB //Works with either X_RID or email/password! function getDriverDetails($driverNum,$key,$password){ $Conn = $this->getDBConn(); $data = null; //echo "Fetching Driver:".$driverNum."::".$key; if(is_numeric($key)) $data = $Conn->getQuickDetails("n_user","x_RID",$key,"","","",1); else{ //Check they entered an email/password if(($key=="") || ($password=="")){ $this->message = "Please enter your Email and Password to recall your details!"; return; } $data = $Conn->getItems("n_user",array("n_email","n_password"),array($key,$password),array(false,false),array("","AND"),"","","",false); } if(mysql_num_rows($data)!=0){ $driverDetails = mysql_fetch_array($data); //include("/var/shares/websites/sitesculpt2.ssculpt.cxm/global/scripts/RentalDriver.inc"); $driver = new RentalDriver(); $driver->setDriverDetails($driverDetails['n_email'],$driverDetails['n_title'],$driverDetails['n_sex'],$driverDetails['n_first_name'],$driverDetails['n_last_name'],$driverDetails['n_occupation'], $driverDetails['n_address_1'],$driverDetails['n_address_2'],$driverDetails['n_postcode'],$driverDetails['n_town'], $driverDetails['n_county'],$driverDetails['n_country'],$driverDetails['n_tel'],$driverDetails['n_mobile'], $driverDetails['n_fax'],$driverDetails['n_nationality'],$driverDetails['n_DOB'],$driverDetails['n_licence_number'],$driverDetails['n_expiry_date'], $driverDetails['n_held_for'],$driverDetails['n_licence_nationality'],$driverDetails['c_full_licence'], $driverDetails['c_accident_claim'],$driverDetails['c_disqualification'], $driverDetails['c_motor_insurance'],$driverDetails['c_medical_condition'],$driverDetails['c_VAT_receipt']); $driver->setRID($driverDetails['x_RID']); $this->getCurrentBooking()->setDriver($driverNum,$driver); $this->getCurrentBooking()->getDriver($driverNum)->setPassword($password); $this->message = "Driver Recalled!"; }else{ //Username/password mis-match $this->message = "Email/Password entered was incorrect!"; return; } } function getDriverPassword($driverNum){ $email = $_POST['email'.$driverNum]; //Check they entered an email if($email==""){ $this->message = "Please enter your Email to recall your Password!"; return; } $Conn = $this->getDBConn(); $data = $Conn->getItems("n_user",array("n_email"),array($email),array(false,false),array("",""),"","","",false); if(mysql_num_rows($data)!=0){ $driverDetails = mysql_fetch_array($data); if($this->bookingSource=='I'){ $message = "Your password for Strafford On-line is: ".$driverDetails['n_password']; $this->email(array($email),"Your password for Strafford On-line",$message,false); $this->message = "Your Password has been emailed to ".$email." !"; }else $this->message = "Password for ".$email." is ".$driverDetails['n_password']; return; } $this->message = "You are not currently registered with Strafford On-line!"; return; } function getPagePersonal(){ //Recall driver details from database if($_POST['action_details']=="recall"){ $driverNum = $_POST['driverNum']; $email = $_POST['email'.$driverNum]; //Check driver hasnt already been added to this booking - email check $ok = true; for($i=0;$i<$this->getCurrentBooking()->getNumDrivers();$i++){ if($this->getCurrentBooking()->getDriver($i+1)->getEmail()==$email){ $ok = false; break; } } if($ok){ $password = $_POST['password'.$driverNum]; $this->getDriverDetails($driverNum,$email,$password); }else $this->message = "Drivers cannot be added twice!"; //Recall Password from Database }else if($_POST['action_details']=="password") $this->getDriverPassword($_POST['driverNum']); //Recalc Quotes (in case drivers have been added/removed) for($i=0;$ibookings);$i++) $this->bookings[$i]->getQuote($this->getDBConn()); //JS to handle multiple submit buttons $pageHTML = ""; $pageHTML .= "
" . ""; $bookNum = ($this->currentBooking+1); $pageHTML .= "" . "" . ""; //Add drivers for this booking $numDrivers = ($this->getCurrentBooking()->getNumDrivers()==0?1:$this->getCurrentBooking()->getNumDrivers()); for($j=0;$j<$numDrivers;$j++){ $driverNum = ($j+1); $driver = $this->getCurrentBooking()->getDriver($driverNum); $pageHTML .= ""; //Extension? if($this->getCurrentBooking()->getExtNum()>0) $pageHTML .= ""; else{ $pageHTML .= ""; if(isset($driver)) $pageHTML .= ""; else $pageHTML .= ""; //FIX: Add a later date!! //Multibook Only! Add drivers from other bookings - skip current booking (cant have same driver twice)!! /*if(count($this->bookings)>1){ $pageHTML .= ""; }else{*/ //$pageHTML .= ""; //} if(($this->getCurrentBooking()->getNumDrivers()==0) && ($driverNum==1)){ $pageHTML .= ""; }else $pageHTML .= ""; } } //echo $this->getCurrentBooking()->getNumDrivers()."::".$this->getCurrentBooking()->getCurrentDriverNum()."::".($this->getCurrentBooking()->getCurrentDriver()==NULL?"but NULL":""); //EXTRA DRIVER//Extension? if($this->getCurrentBooking()->getExtNum()==0){ if(($this->getCurrentBooking()->getNumDrivers()<5) && ($this->getCurrentBooking()->getCurrentDriver()!=NULL)){ $nextDriverNum = $this->getCurrentBooking()->getNumDrivers()+1; $pageHTML .= "" . "" . "" . ""; } } $pageHTML .= "
" . " " . " " . " " . "
Enter Drivers For Booking Number ".$bookNum."
NameRemove DriverRecall A Previous Registered Driver
[ ".$driver->getName()." ][ getName():"Click here to enter your main drivers details")."\">".(isset($driver)?$driver->getName():"Enter Details")." ]" . " ". " " . " " . //If OMC Side do password reveal else email to user " " . "
Email: Password: bookingSource=='W'?"Show Password":"Email my Password to me")."\" border=0 src=\"http://".$_SERVER['HTTP_HOST']."/Resources/Rental/Button_Password.gif\">
" . "
[ Click here to add an Extra Driver ]" . " " . " " . " " . " " . "
Email: Password:
" . "

"; //} return $pageHTML; } //Gets info from customer function getPageDetails(){ $this->subPage = "Details"; $startYear = date("Y",time()); $licenceExpiryBuf = 61; $titles = array("Mr","Mrs","Miss","Dr","Prof","Lord","Lady","Sir","Rev"); if($_GET['driverNum']!="") $this->getCurrentBooking()->setCurrentDriverNum($_GET['driverNum']); if($this->tmpDriver==null) $this->tmpDriver = $this->getCurrentBooking()->getCurrentDriver(); //If this driver has no Email then we are adding him! //$isAdd = ($this->getCurrentBooking()->getCurrentDriver()->getEmail()==""?true:false); $driver = $this->getCurrentBooking()->getCurrentDriver(); $isAdd = (isset($driver)?false:true); if($isAdd){ $button1Text = "Add New Driver"; $button1Image = "http://".$_SERVER['HTTP_HOST']."/Resources/Rental/Button_AddDriver.gif"; }else{ $button1Text = "Update Driver Details"; $button1Image = "http://".$_SERVER['HTTP_HOST']."/Resources/Rental/Button_SaveDriver.gif"; } if($_POST['action_details']=="postcode") $this->tmpDriver = $this->captureDriverDetails(); $driver = $this->tmpDriver; $DOB = null; if($driver->DOB==""){ //$DOBTS = mktime(0,0,0,date("m"),date("d"),date("Y")-40); $DOB = array("","",""); //date("Y",$DOBTS),date("m",$DOBTS),date("d",$DOBTS)); }else $DOB = explode("-",$driver->DOB); $expiry = explode("-",$driver->expiry); //JS to handle multiple submit buttons $pageHTML = ""; //displays selector for each extra driver $pageHTML .= ""; /* * "" . ""; for($i=0;$i<($this->getCurrentBooking()->getExtraDriver()+1);$i++){ $driverNum = ($i+1); if($this->getCurrentBooking()->getCurrentDriverNum()==$driverNum) $pageHTML .= ""; else $pageHTML .= ""; } $pageHTML .= "
Enter Details For Driver
CSSFaded." border=0 src=\"http://".$_SERVER['HTTP_HOST']."/Resources/Rental/Rental_Number".$driverNum.".gif\">

"; */ $pageHTML .= "" . "" . "
"; if($isAdd){ $pageHTML .= "" . "". "" . "" . "
Enter Email and Password for Driver
Email: email."\"Password: password."\">Confirm Password: password."\">
"; }else{ $pageHTML .= "" . "". "" . "" . "
Email and Password for Driver
Email: ".$driver->email."email."\"Password: password."\">Confirm Password: password."\">
"; } //ADD / CANCEL buttons $pageHTML .= "
" . "" .//onClick=\"actionClicked('addDriver');\" "" .// "
" . "

"; //Display main Information entry boxes $pageHTML .= "" . "" . "". ""; //Add hidden variable to indicate which DRIVER the form is for $pageHTML .= "
Enter Personal Details for Driver
" . "" . "" . ""; //DOB $pageHTML .= "" . ""; //Enter Postcode Lookup $doLookup = ($_POST['action_details']=="postcode"?true:false); $pageHTML .= $this->getAddressHTML($_POST['postcode'],$_POST['postcode_housenum'],$doLookup,$driver); $pageHTML .= "
title: Sex:
first name:first_name."\">
last name:last_name."\" >
main occupation:
DOB:
country:" . "
" . "" . "" . "" . "" . "" . "" . "
telephone:tel."\">
mobile [optional]:mobile."\">
fax [optional]:fax."\">
nationality:
[ driving licence information ]
licence number:licence_number."\">
licence nationality:
held for: year(s)
expiry date:
" . "" . "" . "" . "" . "" . "
do you hold a full licence?:Yfull_licence=="Y")?"CHECKED":"").">Nfull_licence=="N"?"CHECKED":"").">
has any accident of yours (during the last 2 years) resulted in a claim in excess of £2000?:Yaccident_claim=="Y"?"CHECKED":"").">Naccident_claim=="N")?"CHECKED":"").">
have you been disqualified from driving within the last 3 years?:Ydisqualification=="Y"?"CHECKED":"").">Ndisqualification=="N")?"CHECKED":"").">
have you been turned down for motor insurance within the last 3 years?:Ymotor_insurance=="Y"?"CHECKED":"").">Nmotor_insurance=="N")?"CHECKED":"").">
do you have any medical condition or disability that may affect your ability to drive?:Ymedical_condition=="Y"?"CHECKED":"").">Nmedical_condition=="N")?"CHECKED":"").">
getCurrentBooking()->getCurrentDriverNum()."\">" . "

" . "" . "" . "" . "
Business/Personal Client
I require VAT Receipts for BookingsVATReceipt=="Y"?" CHECKED":"").">
"; return $pageHTML; } function getAddressHTML($postcode,$housenum,$doLookup,$driver){ //echo "INFO".$postcode.$housenum; if($doLookup){ $str = trim(str_replace(" ","",$postcode)); //preg_replace('/\s\s+/', ' ', $_POST['pc']); //$numb = preg_replace('/\s\s+/', ' ', $_POST['numb']); $str = strtolower($str); if($housenum!="") $fp = fopen("http://services.postcodeanywhere.co.uk/xml.aspx?account_code=INDIV24297&license_code=ZZ24-WC71-UB99-HA31&action=fetch&postcode=".$str."&building=".$housenum."&style=simple", "r"); else $fp = fopen("http://services.postcodeanywhere.co.uk/xml.aspx?account_code=INDIV24297&license_code=ZZ24-WC71-UB99-HA31&action=lookup&postcode=".$str."&style=simple", "r"); $out = ""; $HTML = ""; while (!feof($fp)) { $out.= fread($fp, 128); } fclose($fp); $out = trim($out); $xml = SimpleXML_load_string($out); if($housenum!=""){ $HTML .= "postcode:Data->Item['postcode']."\"> Fetch My Address". "address:Data->Item['line1']."\">" . " Data->Item['line2']."\" SIZE=\"25\">" . "town:Data->Item['post_town']."\">" . "county:Data->Item['county']."\">"; }else{ if((string)$xml->Data['Items'] == 0) { $HTML = "postcode:postcode."\"> Fetch My Address". "address:address_1."\">" . " address_2."\" SIZE=\"25\">" . "town:town."\">" . "county:county."\">"; }else{ $HTML = "postcode:". "address:address_1."\">" . " address_2."\" SIZE=\"25\">" . "town:town."\">" . "county:county."\">"; } } }else{ $HTML = "postcode:postcode."\"> Fetch My Address". "address:address_1."\">" . " address_2."\" SIZE=\"25\">" . "town:town."\">" . "county:county."\">"; } return $HTML; } function performActionEQuote(){ $Conn = $this->getDBConn(); $quote = "
" . $this->getCurrentBooking()->getQuoteOutput(true,false,"Your Discounted Quote")."
".$this->tandc."
"; $toAddr = array("bookings@strafford.co.uk",$_POST[email]); $this->email($toAddr,"Your Quote from Strafford Self-Drive [".$this->getCurrentBooking()->getBookingID()."]", $quote, false); } function performActionRecallQuote(){ $Conn = $this->getDBConn(); $this->getCurrentBooking()->recallQuoteFromDB($Conn,$_GET['num']); } function performActionSaveQuote(){ $Conn = $this->getDBConn(); $quoteNum = $_POST['quote_num']; $email = $_POST['email1']; $password = $_POST['password1']; //Check Email and Password if(($password=="")||($email=="")){ $this->message = "You Must enter a valid Email and Password"; return; } //Check User exists and if so that password is correct $data = $Conn->getItems("n_user",array("n_email"),array($email),array(false,false),array(""),"","","",false); if(mysql_num_rows($data)!=0){ $row = mysql_fetch_array($data); if($password!=$row['n_password']){ $this->message = "Incorrect Password"; return; } $this->getDriverDetails(1,$email,$password); $this->getCurrentBooking()->saveBookingToDB($Conn,$email,"",$quoteNum); }else $this->getCurrentBooking()->saveBookingToDB($Conn,$email,$password,$quoteNum); } function performActionDeleteQuote(){ $Conn = $this->getDBConn(); $driver = $this->getCurrentBooking()->getDriver(1); $Conn->delQuote($driver->getRID(),$_GET['num']); } function performActionQuote(){ $this->advance(); } //Calcs the Grand Total -5th booking discount function getGTotal(){ $GTotal = 0; $cheapest = 0; //Calculate Grand Total for($i=0;$ibookings);$i++){ $GTotal += $this->bookings[$i]->getBookingTotal(); if($this->bookings[$i]->getBookingTotal()<$this->bookings[$cheapest]->getBookingTotal()) $cheapest = $i; } if(count($this->bookings)==5) $GTotal -= $this->bookings[$cheapest]->getBookingTotal(); return $GTotal; } function getPageQuote(){ $Conn = $this->getDBConn(); //HTTPS $secureHost = "https://".$_SERVER['HTTP_HOST']."/global/store/rental.php?action=Quote"; $this->getCurrentBooking()->getQuote($Conn); //FIX - Should make Logins GLOBAL - this is only here to allow a login on the Quote page :D $pageHTML = ""; $pageHTML .= "
" . "" . " " . " " . "
".str_replace("\n","
",$this->getCurrentBooking()->getQuoteOutput(true,true,"Your Quote in Detail"))."
Click HERE to Close this Window...
". "
"; $pageHTML .= "" . " "; //Add options $pageHTML .= "". "" . "" . "" . "
" . "
" . $this->getCurrentBooking()->getQuoteOutput(true,false,"Your Discounted Quote")."" . "
" . " " . "
[View Detailed Quote]
" . "
" . "
" . " " . " "; //Shopping Cart for($i=0;$ibookings);$i++){ if($i>0) $pageHTML .= " "; else $pageHTML .= " "; $pageHTML .= " "; } //Add Booking if(count($this->bookings)<5) $pageHTML .= ""; $pageHTML .= " "; $pageHTML .= "
Book On-line Now: Click Proceed
" . "
From: ".date("dS F Y",strtotime($this->bookings[$i]->getFromDate()))." | To: ".date("dS F Y",strtotime($this->bookings[$i]->getToDate()))." | Group: ".$this->bookings[$i]->getGroup()."
Booking Total: ".$this->getCurrentBooking()->formatNumber($this->bookings[$i]->getBookingTotal())."
Add Booking Number ".(count($this->bookings)+1)."
Grand Total: ".$this->getCRB()->formatNumber($this->getGTotal())."

"; //Login Code / Save Quotes $pageHTML .= "
" . "" . " "; //Recall driver details from database IF recall was selected (View Quotes) OR Login (Save Quote) if(($_POST['action_details']=="recall") || ($_POST['password']!="")){ $driverNum = 1; $email = $_POST['email'.$driverNum]; $password = $_POST['password'.$driverNum]; $this->getDriverDetails($driverNum,$email,$password); } $driver = $this->getCurrentBooking()->getDriver(1); if(isset($driver)){ $DBConn = $this->getDBConn(); //$data = $Conn->getItems("n_booking",array("n_TRID_user_0","n_booking_id"),array($driver->getRID(),0),array(false,false),array("","AND"),"","","",false); $data = $DBConn->getItems("n_booking",array("n_booking_id","x_link_4.x_RID_source","x_link_4.x_RID_group"),array(0,array("t2.x_RID",1),$driver->getRID()),array(0,0,0),array("","AND","AND"),"","","",false); $num = mysql_num_rows($data); //Delete Expired Quotes //Delete Quotes with Invalid (empty) reg number - as they wont work. for($i=0;$i<$num;$i++){ $row = mysql_fetch_array($data); $from = strtotime($row['n_date_from']); //FIX: We should merge this with booking->resetDates(); //Probably by adding member variables to Rental Manager storing the earliest booking times... $offset = 1; $earliestBooking = mktime(0, 00, 00, date("m"), date("d")+($this->settings[0]->getBookingBuffer()+$offset), date("Y")); while($this->checkDateOpen(date("Y-m-d H:i",$earliestBooking))!=""){ $offset++; $earliestBooking = mktime(0, 00, 00, date("m"), date("d")+($this->settings[0]->getBookingBuffer()+$offset), date("Y")); } if($from<$earliestBooking) $DBConn->delQuote($driver->getRID(),$row['n_quote_num']); } $quoteNums = array(); $nextQuoteNum = 1; $pageHTML .=""; if($num==0) $pageHTML .= ""; else{ //Reset result mysql_data_seek($data,0); //Generate the previous Quote View for($i=0;$i<$num;$i++){ $row = mysql_fetch_array($data); $from = strtotime($row['n_date_from']); $to = strtotime($row['n_date_to']); $toolTip = "Group: ".$row['n_group']." | Booking Total: ".$this->getCurrentBooking()->formatNumber($row['n_booking_total']); $itemText = "From: ".date("dS F Y",$from)." | To: ".date("dS F Y",$to); $pageHTML .= ""; array_push($quoteNums,$row['n_quote_num']); } } //Calc next avail quote num if(count($quoteNums)!=0){ sort($quoteNums); for($i=0;$i" . ""; }else $pageHTML .= ""; $pageHTML .= "
Save this Quote for later
Welcome back ".($driver->getName()!=""?$driver->getName():$driver->getEmail()). "getEmail()."\">" . "password."\">" . "
You currently have no saved Quotes
" . "" . " Quote: ".($i+1)." - ".$itemText . "" . "
[NOTE: Prices on recalled quotes are subject to change]
You already have 5 saved Quotes

"; }else{ $pageHTML .= "
Email: email."\"Password: password."\">" . "" . "
[NOTE: Prices on recalled quotes are subject to change]
"; } $pageHTML .= " " . ""; $pageHTML .= ""; return $pageHTML; } function performActionExtra(){ //Only Set Extras if this booking is NOT an Extension if($this->getCurrentBooking()->getExtNum()==0){ $endT = array($_POST['endT0'],$_POST['endT1'],$_POST['endT2']); $endV = array($_POST['endV0'],$_POST['endV1'],$_POST['endV2']); $this->getCurrentBooking()->setEndor($endT,$endV); $this->getCurrentBooking()->setStudent(($_POST['student']=="on"?"Y":"N")); $this->getCurrentBooking()->setEDW(($_POST['edw']=="on"?"Y":"N")); $this->getCurrentBooking()->setBabySeat(($_POST['babySeat']=="on"?"Y":"N")); $this->getCurrentBooking()->setTomtom(($_POST['tomtom']=="on"?"Y":"N")); $this->getCurrentBooking()->setRoadRisks(($_POST['roadRisks']=="on"?"Y":"N")); $this->getCurrentBooking()->setOverseasTravel(($_POST['overseasTravel']=="on"?"Y":"N")); $this->getCurrentBooking()->setAge($_POST['age']); } $this->advance(); } function getPageExtra(){ //$this->position = 3; $endT = $this->getCurrentBooking()->getEndorTitles(); $endV = $this->getCurrentBooking()->getEndorValues(); $pageHTML .= "
" . "
" . "" . "" . "" . "" . ""; $pageHTML .= "
Select Extras
Extra Damage Waiver (Reduces your deposit)getCurrentBooking()->getExtNum()>0?" DISABLED":"")." type=\"checkbox\" name=\"edw\"".($this->getCurrentBooking()->getEDW()=="Y"?" CHECKED":"").">
Road Risks Insurance*
(note by not selecting this cover you will be required to produce a valid comprehensive certificate of insurance at the time of hire clearly listing the vehicle you are intending to hire as at risk)
getCurrentBooking()->getExtNum()>0?" DISABLED":"")." type=\"checkbox\" name=\"roadRisks\"".($this->getCurrentBooking()->getRoadRisks()=="N"?"":" CHECKED").">
Overseas TravelgetCurrentBooking()->getExtNum()>0?" DISABLED":"")." type=\"checkbox\" name=\"overseasTravel\"".($this->getCurrentBooking()->getOverseasTravel()=="Y"?" CHECKED":"").">
Baby Seat RequiredgetCurrentBooking()->getExtNum()>0?" DISABLED":"")." type=\"checkbox\" name=\"babySeat\"".($this->getCurrentBooking()->getBabySeat()=="Y"?" CHECKED":"").">
Satellite Navigation With Safety Camera AlertsgetCurrentBooking()->getExtNum()>0?" DISABLED":"")." type=\"checkbox\" name=\"tomtom\"".($this->getCurrentBooking()->getTomtom()=="Y"?" CHECKED":"").">
" . "
" . "" . "
Discounts
I am a Student (proof required on pickup/delivery)getCurrentBooking()->getExtNum()>0?" DISABLED":"")." type=\"checkbox\" name=\"student\"".($this->getCurrentBooking()->getStudent()=="Y"?" CHECKED":"").">
Discount Code (optional):getCurrentBooking()->getExtNum()>0?" DISABLED":"")." TYPE=\"Text\" class=\"border\" name=\"discID\">
 

"; $Conn = $this->getDBConn(); $data = $Conn->getQuickItems("n_endorsement"); $num = mysql_num_rows($data); for($i=0;$i<3;$i++){ //Points Titles $pageHTML .= ""; } $pageHTML .= "
Please declare any endorsements you currently have
getCurrentBooking()->getExtNum()>0?" DISABLED":"")." class=\"border\" STYLE=\"width: 600px\" name=\"endT".$i."\">"; for($j=1;$j<$num;$j++){ $row = mysql_fetch_array($data); $pageHTML .= ""; } mysql_data_seek($data,0); //Points Values [0-10 points selectable for each offence] $pageHTML .= " Penalty Points Awarded: getCurrentBooking()->getExtNum()>0?" DISABLED":"")." class=\"border\" class=\"border\" name=\"endV".$i."\">"; for($j=0;$j<11;$j++) $pageHTML .= ""; $pageHTML .= "
We reserve the right to refuse hire to drivers with an excessive number of points on their licence.

Please select your age group:
"; //Add Age Selector for($i=0;$iages);$i++){ $pageHTML .= "getCurrentBooking()->getExtNum()>0?" DISABLED":"")." type=\"radio\" name=\"age\" value=\"".$this->ages[$i]."\""; //Sets right element CHECKED if((($this->getCurrentBooking()->getAge()=="NONE") AND ($i==2)) || ($this->getCurrentBooking()->getAge()==$this->ages[$i])) $pageHTML .= " checked"; $pageHTML .= "> ".$this->ages[$i].""; } $pageHTML .= "
"; return $pageHTML; } //Sets the vehicle (using a position in the vehicle array) for the current booking function setVehicle($pos){ $this->getCurrentBooking()->setVehicle($this->vehicle[$pos]); } //Handles data from the Select Vehicle page function performActionVehicle(){ $elementIndex = $_POST['vehiclePos']; $conflict = $_POST['conflict'][$elementIndex]; if($conflict!=""){ $newDate = strtotime($_POST['conflictDate'][$elementIndex]); $this->getCurrentBooking()->setDate($conflict,$this->getMySQLDate($newDate)); } $this->getCurrentBooking()->setVehicle($this->pointerCategories[0][1][$elementIndex][0]); $this->advance(); } //Returns Vehicle select page function getPageVehicle(){ //Use Tree Pointer $vehiclesInGroup = array(); for($i=0;$ipointerCategories[0][1]);$i++){ //Check Vehicle is available!! $vehicle = $this->pointerCategories[0][1][$i]; $availStatus = $this->isVehicleAvailable($vehicle[0]->getRegistrationNumber(),1); //echo "SD:".$vehicle[0]->getRegistrationNumber()."@@".$availStatus[0]."
"; if((($this->bookingSource=='I') && ($availStatus[0]==0)) || (($this->bookingSource=='W') && ($availStatus[0]>-1))){ //echo " [[ADD]] ".$vehicle[0]->getRegistrationNumber(); if($vehicle[2]=="Y") $exampleVehicle = $vehicle; $elementIndex = $i; array_push($vehiclesInGroup,array($vehicle,$elementIndex,$availStatus)); } } //Sort Data - Semi Available LAST! foreach($vehiclesInGroup as $res) $sortAux[] = $res[2]; array_multisort($sortAux,SORT_ASC,$vehiclesInGroup); $num = count($vehiclesInGroup); //echo "NUM".$num; $pageHTML = "". ""; if($this->bookingSource=='W') $pageHTML .= ""; $numRows = ceil($num/$this->numColsVehicle); $pictureRandomName = md5(time()); $IMGname = ""; for($i=0;$i<$numRows;$i++){ $pageHTML .= ""; $numOnRow = (($num-($this->numColsVehicle*$i))>$this->numColsVehicle?$this->numColsVehicle:($num-($this->numColsVehicle*$i))); for($j=0;$j<$numOnRow;$j++){ $pos = ($i*$this->numColsVehicle)+$j; $IMGname = $this->getImage($vehiclesInGroup[$pos][0][0]->getRID()); $checked = false; //Sets right element CHECKED if((($this->getCurrentBooking()->getVehicle()==NULL) AND ((($i+$j)==0))) || (($this->getCurrentBooking()->getVehicle()!=NULL) && ($this->getCurrentBooking()->getVehicle()->getRegistrationNumber()==$vehiclesInGroup[$pos][0][0]->getRegistrationNumber()))){ $checked = true; $IMGname = $this->getImage($vehiclesInGroup[$pos][0][0]->getRID()); } $pageHTML .= ""; } $pageHTML .= ""; } $pageHTML .= "
Select Preferred Vehicle from Group ".$this->getCRB()->getGroup()."
From:".$this->formatDatetime($this->getCurrentBooking()->getFromDate())." To:".$this->formatDatetime($this->getCurrentBooking()->getToDate())."
" . ""; //Add Warning if availability is in Doubt - ie > 0 switch($vehiclesInGroup[$pos][2][0]){ case 1: $pageHTML .= "" . ""; break; case 2: $pageHTML .= "" . ""; break; case 3: $pageHTML .= ""; break; case 4: $newDate = $vehiclesInGroup[$pos][2][2]." ".substr($this->getCurrentBooking()->getFromDate(),strpos($this->getCurrentBooking()->getFromDate(),' ')+1); $pageHTML .= "" . ""; break; } $pageHTML .= "" . ""; if($this->bookingSource=='W') $pageHTML .= ""; $pageHTML .= "
Conflict (date From) with ".$vehiclesInGroup[$pos][2][1]."
From date/time will be set to ".$this->formatDatetime($vehiclesInGroup[$pos][2][2])."
Conflict (date To) with ".$vehiclesInGroup[$pos][2][1]."
To date/time will be set to ".$this->formatDatetime($vehiclesInGroup[$pos][2][2])."
WARNING: Vehicle only has ".$vehiclesInGroup[$pos][2][1]." miles left until Defleet!
**VOR** Conflict (date From)
From date will be set to ".$this->formatDatetime($newDate)."
"; //Set hidden vars to adjust From/To times on Conflict Vehicles if(($vehiclesInGroup[$pos][2][0]>0) && ($vehiclesInGroup[$pos][2][0]<3)) $pageHTML .= "" . ""; else if($vehiclesInGroup[$pos][2][0]==4){ //VOR - Adjust Date but Not Time $newDate = $vehiclesInGroup[$pos][2][2]." ".substr($this->getCurrentBooking()->getFromDate(),strpos($this->getCurrentBooking()->getFromDate(),' ')+1); //echo $newDate; $pageHTML .= "" . ""; } $pageHTML .= $vehiclesInGroup[$pos][0][0]->getMake()." ".$vehiclesInGroup[$pos][0][0]->getModel()."
Description: ".$vehiclesInGroup[$pos][0][0]->getDescription()."
Engine Size: ".$vehiclesInGroup[$pos][0][0]->getEngineSize()."L
Engine Type: ".($vehiclesInGroup[$pos][0][0]->getIsPetrol()=='Y'?"Petrol":"Diesel")."
Aircon: ".$vehiclesInGroup[$pos][0][0]->getHasAircon()."
Colour: ".$vehiclesInGroup[$pos][0][0]->getColour()."
REG: ".$vehiclesInGroup[$pos][0][0]->getRegistrationNumber()."
"; return $pageHTML; } function getImage($RID){ $IMGname = "../clients/".$this->CID."/Rental/vehicle/".$RID."_0.jpg"; $file = @fopen($IMGname, "r"); if(!$file) $IMGname = "http://".$_SERVER['HTTP_HOST']."/global/controlpanel/Resources/Image_NA_".$this->imageRes.".jpg"; @fclose($file); return $IMGname; } //Handles data from the group page function performActionGroup(){ //$this->getCurrentBooking()->setGroup($_POST['group']); $elementIndex = explode(":",$_POST['group']); //$this->pointerCategories = $this->categories[$elementIndex[0]][1][$elementIndex[1]]; $this->setPointCat($elementIndex[0],$elementIndex[1]); $this->getCurrentBooking()->setGroup($this->pointerCategories[0][0]->getName()); $this->getCurrentBooking()->setVehicle(NULL); //Check Hire Unit is correct for group Booking /*$Conn = $this->getDBConn(); $data = $Conn->getQuickDetails("n_group","n_name",$this->getCRB()->getGroup(),"","",0,0); $row = mysql_fetch_array($data);*/ if(fmod($this->getCRB()->getBookingPeriod(),$this->pointerCategories[0][0]->getHireUnit())!=0){ $this->message = "VEHICLES IN GROUP:".$this->getCRB()->getGroup()." MUST BE BOOKED IN ROUND AMOUNTS OF ".$this->pointerCategories[0][0]->getHireUnit()." DAYS"; return; } //Set Grid pricing if walk in if($this->bookingSource=="W"){ //echo "GRID:".$_POST['gridMileage'].":".$_POST['gridDeposit']."
"; $this->getCurrentBooking()->setGridVals($_POST['gridDeposit'],$_POST['gridMileage']); }else $this->getCurrentBooking()->setMileage($this->getCurrentBooking()->getBaseMileage()); $this->advance(); } //Set the Cat TREE pointer (IE GROUP) function setPointCat($el1,$el2){ $this->pointerCategories = $this->categories[$el1][1][$el2]; } //Returns Cat TREE pointer function getPointCat(){ return $this->pointerCategories; } //Generates Group Page used by both Customer side and OMC //$callSource indicates which side called the routine function getPageGroup(){ $this->positionReached = 1; if($this->bookingSource=='W') $this->getCurrentBooking()->resetGRID(); //If Category is changed then we need to Reset Group/Vehicle!! if(($_POST['category']!="")&&($_POST['category']!=$this->viewCategory)){ $this->viewCategory = $_POST['category']; $this->getCurrentBooking()->setGroup("NONE"); } $Conn = $this->getDBConn(); //Generate Group Array (REPLACE BY OBJECTS) $groups = array(); //Cycle through data structure for($i=0;$icategories);$i++){ //Check Group is in current CATEGORY if(($this->categories[$i][0]->getRID()==$this->viewCategory) || ($this->viewCategory==-1)){ //Check there are vehicles available to hire in the Group (ie make sure it isn't EMPTY or FULLY BOOKED!!') //Check A Vehicle is available in THIS GROUP!! //Cycle through Groups for($j=0;$jcategories[$i][1]);$j++){ $groupEl = $this->categories[$i][1][$j]; //Check Group hasn't already been added (a Group can be in multiple CATS) $skip = false; for($k=0;$kgetName()==$groupEl[0][0]->getName()) $skip = true; if(!$skip){ //Cycle through Vehicles to Check there is at LEAST one available for($k=0;$kcategories[$i][1][$j][0][1]);$k++){ $vehicle = $this->categories[$i][1][$j][0][1][$k][0]; $availStatus = $this->isVehicleAvailable($vehicle->getRegistrationNumber(),1); //echo "SD: ".$groupEl[0][0]->getName()." ".$vehicle->getRegistrationNumber()."@@".$availStatus[0]."
"; if((($this->bookingSource=='I') && ($availStatus[0]==0)) || (($this->bookingSource=='W') && ($availStatus[0]>-1))){ $costPerDay = $this->getCurrentBooking()->getEffectiveDayPrice($Conn,$groupEl[0][0]->getName()); $elementIndex = $i.":".$j; array_push($groupEl,$costPerDay); array_push($groupEl,$elementIndex); array_push($groups,$groupEl); break; } } } } } } $num = count($groups); //Sort Group array by CPD - ONLY If we have some Data - otherwise errors!! if($num>0){ foreach($groups as $res) $sortAux[] = $res[2]; array_multisort($sortAux,SORT_ASC,$groups); } /*for($i=0;$igetName()."
"; }*/ $pictureRandomName = md5(time()); //Add category selector $pageHTML = "
" . "" . "
Select Vehicle Category to Show
".($this->bookingSource!='W'?"":"")."

". ""; if($this->bookingSource=='W') $pageHTML .= ""; $numRows = $num/$this->numColsGroup; //echo $numRows." ".$num." ".$this->numColsGroup; //Cycle ROWS for($i=0;$i<$numRows;$i++){ $pageHTML .= ""; $numOnRow = (($num-($this->numColsGroup*$i))>$this->numColsGroup?$this->numColsGroup:($num-($this->numColsGroup*$i))); //Cycle COLS for($j=0;$j<$numOnRow;$j++){ $pos = ($i*$this->numColsGroup)+$j; $exampleVehicle = null; //Generates alist of vehicles $vehiclesInGroup = array(); for($k=0;$kisVehicleAvailable($groups[$pos][0][1][$k][0]->getRegistrationNumber(),1); if((($this->bookingSource=='I') && ($availStatus[0]<1)) || (($this->bookingSource=='W') && ($availStatus[0]<3))){ //echo "CHECKING:".$pos; if($groups[$pos][1]=="Y") $exampleVehicle = $groups[$pos][0][1][$k]; array_push($vehiclesInGroup,$groups[$pos][0][1][$k]); } } if($exampleVehicle==null) $exampleVehicle = $vehiclesInGroup[0]; $numVehicles = count($vehiclesInGroup); //echo $numVehicles."::"; //Sets right element CHECKED $checked = false; if(($this->getCurrentBooking()->getGroup()=="NONE") && ((($i+$j)==0) && ($this->bookingSource=='I'))) $checked = true; else if($this->getCurrentBooking()->getGroup()==$groups[$pos][0][0]->getName()) $checked = true; if($numVehicles>0){ //Work out which PRICE to DISPLAY. If rental period is ONE DAY and it STARTS on a WE (FRI,SAT,SUN) //Generate for Customer side $exampleText = "Example: ".$exampleVehicle[0]->getMake()." ".$exampleVehicle[0]->getModel(); $IMGname = "../clients/".$this->CID."/Rental/group/".$groups[$pos][0][0]->getRID()."_0.jpg"; $file = @fopen($IMGname, "r"); if(!$file){ //If there isn't a Group IMG then use one from a vehicle in the Group. if($numVehicles>0){ //Use image for Primary vehicle in GRP $IMGname = "../clients/".$this->CID."/Rental/vehicle/".$exampleVehicle[0]->getRID()."_0.jpg"; $file = @fopen($IMGname, "r"); } //If there are NO IMG's then use a 'No Image...' if(!$file) $IMGname = "http://".$_SERVER['HTTP_HOST']."/global/controlpanel/Resources/Image_NA_".$this->imageRes.".jpg"; } @fclose($file); $pageHTML .= ""; } } $pageHTML .= ""; } $pageHTML .= "" . "" . "
".($num>0?"Select Group":"There are no Vehicles of this type Available to Hire")."
From:".$this->formatDatetime($this->getCurrentBooking()->getFromDate())." To:".$this->formatDatetime($this->getCurrentBooking()->getToDate())."
" . "" . ""; //Restrictions if($groups[$pos][0][0]->getHireUnit()>1) $pageHTML .= "[Must be Hired in Round Amounts of ".$groups[$pos][0][0]->getHireUnit()." Days]"; if($groups[$pos][0][0]->getMinimumAge()>0) $pageHTML .= "[Must be Aged ".$groups[$pos][0][0]->getMinimumAge()."+]"; $pageHTML .= "
"; $pageHTML .= "bookingSource=='W'?" style={visibility:hidden;}":"").">"; $pageHTML .= "Group: ".$groups[$pos][0][0]->getName()."
Per Day: ".$this->formatNumber($groups[$pos][2])." / €".(number_format($groups[$pos][2]*$this->settings[0]->getRateEuro(), 2))." / $".(number_format($groups[$pos][2]*$this->settings[0]->getRateDollar(), 2))." (estimated)
".$exampleText."
"; //ADD Multiprice Table - if Walk In if($this->bookingSource=='W'){ $pageHTML .= "
Default Mileage: "; switch($this->getCurrentBooking()->getMileageCat()){ case 0: $pageHTML .= $this->getSettings()->getMileageOneday(); break; case 1: $pageHTML .= $this->getSettings()->getMileageWeekend(); break; case 2: $pageHTML .= $this->getSettings()->getMileageDefault(); break; } $pageHTML .= "
"; $priceData = $this->getCurrentBooking()->getEffectiveDayArray($Conn,$groups[$pos][0][0]->getName()); //Read Col - MILE for($k=0;$k"; }else if ($mgetCurrentBooking()->getMileageCat()==2) $data = (550+$priceData[$k][$m-1])*$this->getCurrentBooking()->getBookingPeriod(); else{ $data = $this->getSettings()->getMileageOneday()+$priceData[$k][$m-1]; //echo $data."
"; } $pageHTML .= "
"; } }else if($m==0){ $deposit = $this->formatNumber($this->getCurrentBooking()->calcDeposit($priceData[$k][$m],$groups[$pos][0][0]->getName())); $pageHTML .= ""; }else $pageHTML .= ""; } $pageHTML .= ""; } $pageHTML .= "
".$data."".$deposit."".$this->formatNumber($priceData[$k][$m])."
"; } $pageHTML .= "
"; return $pageHTML; } /* * Dates Read from form variables into MySQL format */ function performActionLocation(){ //Added for EXT as they shouldn't read the From date - It's just a label anyway so it won't work!! if($this->getCurrentBooking()->getExtNum()>0) $from = $this->getCurrentBooking()->getFromDate(); else $from = ($_POST['booking_type']=="std"?$_POST['from_month']."-".$_POST['from_day']." ".$_POST['from_hour'].":".$_POST['from_min'].":00":date("Y-m-d",$_POST['location_wec'])." ".substr($this->settings[0]->getWeekendStart(),0,2).":".substr($this->settings[0]->getWeekendStart(),3,2).":00"); //echo $from.$_POST['booking_type']."
"; //Calcs End of WEC (weekend cheap rate) $from will be correct for this $toWECDate = mktime(0, 0, 0, date("m",strtotime($from)), date("d",strtotime($from))+3, date("Y",strtotime($from))); $to = ($_POST['booking_type']=="std"?$_POST['to_month']."-".$_POST['to_day']." ".$_POST['to_hour'].":".$_POST['to_min'].":00":date("Y-m-d",$toWECDate)." ".substr($this->settings[0]->getWeekendEnd(),0,2).":".substr($this->settings[0]->getWeekendEnd(),3,2).":00"); $TSFrom = strtotime($from); $TSTo = strtotime($to); //Checks for invalid dates if(!$this->getCurrentBooking()->setDate("from",$from) || !$this->getCurrentBooking()->setDate("to",$to)){ $this->message = "INVALID DATE"; return; } //Check for Hires Longer than 90 days (as they are contract) $fromTimePlus = mktime(0,0,0,date("m",$TSFrom),date("d",$TSFrom)+89,date("Y",$TSFrom)); if($fromTimePlusgetCRB()->getToDate())){ $this->message = "PLEASE CONTACT RESERVATIONS ON +44 (0) 800 9174385 FOR BOOKINGS OF 90 DAYS OR MORE"; return; } $this->getCurrentBooking()->setBookingType($_POST['booking_type']); $this->getCurrentBooking()->setCM($_POST['coll_method']); $this->getCurrentBooking()->setLocation($this->location[$_POST['del_loc']]); $diffNow = $this->getCurrentBooking()->getBufferPeriod(); //echo $diffNow."@@".$this->booking_buffer; $diffTime = $this->getCurrentBooking()->getBookingPeriod(); $fromDate = strtotime($this->getCurrentBooking()->getFromDate()); $toDate = strtotime($this->getCurrentBooking()->getToDate()); $fromTime = ($_POST['booking_type']=="std"?strtotime(date("H",$TSFrom).":".date("i",$TSFrom)):strtotime(substr($this->settings[0]->getWeekendStart(),0,5))); $toTime = ($_POST['booking_type']=="std"?strtotime(date("H",$TSTo).":".date("i",$TSTo)):strtotime(substr($this->settings[0]->getWeekendEnd(),0,5))); $now = strtotime("now"); //2nd Checks for invalid dates if($diffTime < 0){ $this->message = "TO DATE MUST BE LATER THAN FROM DATE"; return; }else if(($this->getCurrentBooking()->getExtNum()==0) && ($fromDate<$now)){ $this->getCurrentBooking()->resetDates($this->settings[0]->getBookingBuffer()); $this->message = "YOUR BOOKING FROM DATE HAS PASSED!"; return; }else if(($this->getCurrentBooking()->getExtNum()>0) && ($toDate<$now)){ $this->message = "YOUR BOOKING TO DATE HAS PASSED!"; return; }else if(($this->getCurrentBooking()->getExtNum()==0) && (($diffNow < $this->settings[0]->getBookingBuffer()) || ($diffNow < 0)) && ($this->bookingSource=="I")){ //Only check if Internet Booking $this->message = "YOUR BOOKING IS TOO IMMEDIATE, PLEASE PHONE"; return; }else if($_POST['coll_method']=="pickup"){ //If PICKUP is selected we need to check BOTH To and From times are within office hours $dayNumFrom = date("w",$fromDate); switch($dayNumFrom){ case 0: $officeOpen = $this->settings[0]->getOfficeOpenSun(); $officeClose = $this->settings[0]->getOfficeCloseSun(); break; case 6: $officeOpen = $this->settings[0]->getOfficeOpenSat(); $officeClose = $this->settings[0]->getOfficeCloseSat(); break; default: $officeOpen = $this->settings[0]->getOfficeOpenWk(); $officeClose = $this->settings[0]->getOfficeCloseWk(); break; } if(($fromTimestrtotime($officeClose))){ $this->message = "YOU CANNOT PICKUP YOUR RENTAL OUTSIDE OF OFFICE HOURS!"; return; } $dayNumTo = date("w",$toDate); switch($dayNumTo){ case 0: $officeOpen = $this->settings[0]->getOfficeOpenSun(); $officeClose = $this->settings[0]->getOfficeCloseSun(); break; case 6: $officeOpen = $this->settings[0]->getOfficeOpenSat(); $officeClose = $this->settings[0]->getOfficeCloseSat(); break; default: $officeOpen = $this->settings[0]->getOfficeOpenWk(); $officeClose = $this->settings[0]->getOfficeCloseWk(); break; } if(($toTimestrtotime($officeClose))){ //header("Location: ".$_SERVER['PHP_SELF']."?rentalPage=".$this->steps[$this->position]."&msg=YOU CANNOT RETURN YOUR RENTAL OUTSIDE OF OFFICE HOURS!"); $this->message = "YOU CANNOT RETURN YOUR RENTAL OUTSIDE OF OFFICE HOURS!"; return; } } //Checks if Branch is Closed on From/To dates $checkFrom = $this->checkDateOpen($this->getCurrentBooking()->getFromDate()); if($checkFrom!=""){ //header("Location: ".$_SERVER['PHP_SELF']."?rentalPage=".$this->steps[$this->position]."&msg=THE BRANCH IS CLOSED ".$checkFrom." [YOUR FROM DATE]"); $this->message = "THE BRANCH IS CLOSED ".$checkFrom." [YOUR FROM DATE]"; return; } $checkTo = $this->checkDateOpen($this->getCurrentBooking()->getToDate()); if($checkTo!=""){ //header("Location: ".$_SERVER['PHP_SELF']."?rentalPage=".$this->steps[$this->position]."&msg=THE BRANCH IS CLOSED ".$checkTo." [YOUR TO DATE]"); $this->message = "THE BRANCH IS CLOSED ".$checkTo." [YOUR TO DATE]"; return; } //Checks if Branch is Closed at