Hi,

This might be too much to ask, but can someone help make sure this php file code always saves current date to my "lastupdate" field of "ReservationDetailsTmp'" table?

Would be great to receive response asap.
Thanks a lot in advance! :)

<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

class WbrsControllerModify extends JController  
{
	function __construct( $config = array() )
	{
		parent::__construct( $config );
	}
	function display()
	{
		parent::display();
	}
	function modify(){
		$mysession = JFactory::getSession();
		if ($this->search()) {
			$orig = $mysession->get('cartid');		
			$db = JFactory::getDBO();
			//JRequest::setVar('layout','modify');
			/**
			 * @uses load reservation batch info
			 */
			$query = "select * from wrsreservationbatch where cartid=".$mysession->get('cartid');
			$db->setQuery($query);
			$rs = $db->loadAssoc();
			/**
			 * @uses transfer reservation batch to temporary table
			 */
			$row = JTable::getInstance('reservationbatchtmp','table');
			$row->bind($rs);
			$row->cartid=0;
			$row->store();
			// bind new cart id
			$cartid=$row->cartid;			
			/** eof **/
			/**
			 * @uses transfer client profile to temporary table
			 */
			$query = "select * from wrsclient where cartid=".$mysession->get('cartid');
			$db->setQuery($query);
			$rs = $db->loadAssoc();
			$row = JTable::getInstance('clienttmp','table');
			$row->bind($rs);
			$row->clientid=0;
			$row->cartid=$cartid;
			$row->store();			
			/** eof **/
			/**
			 * @uses transfer reservation header to temporary table
			 */
			$query = "select * from wrsreservationheader where cartid=".$mysession->get('cartid');
			$db->setQuery($query);
			$rs = $db->loadAssocList();
			$header = JTable::getInstance('reservationheadertmp','table');
			$details = JTable::getInstance('reservationdetailstmp','table');
			for ($i=0;$i<count($rs);$i++){
				$header->bind($rs[$i]);
				$header->reservation_number=0;
				$header->cartid=$cartid;
				$header->store();							
				/**
				 * @uses transfer details to temporary table
				 */
				$query = "select * from wrsreservationdetails where reservation_number=".$rs[$i]['reservation_number'];
				$db->setQuery($query);
				$hrs = $db->loadAssocList();
				for ($j=0;$j<count($hrs);$j++){
					$details->bind($hrs[$j]);
					$details->id=0;
					$details->reservation_number=$header->reservation_number;
					$details->cartid=$cartid;
					if (!$details->store()) {
						JError::raiseError($details->getErrorMsg());
					}
				}
			}
			/** eof **/
			/**
			 * @uses transfer services to temporary table
			 */
			$query = "select * from wrsreservationservices where cartid=".$mysession->get('cartid');
			$db->setQuery($query);
			$rs = $db->loadAssocList();
			$row = JTable::getInstance('tmpservices','table');
			for ($i=0;$i<count($rs);$i++){
				$row->bind($rs[$i]);
				$row->cartid=$cartid;
				$row->id=0;
				$row->store();			
			}
			/** eof **/
			$mysession->set('cartid',$cartid);
			$mysession->set('original',$orig);		
			$this->setRedirect(JRoute::_("index.php?option=com_wbrs&view=modify&layout=modify"));
		} else {
			$mysession = JFactory::getSession();
			$this->setRedirect(JRoute::_('index.php?option=com_wbrs&view=modify&hotelid='.$mysession->get('hotelid')),'Sorry... No valid records matched your request.','error');
		}
	}
	function search(){
		$db = JFactory::getDBO();
		$mysession = JFactory::getSession();
		$hotelid = $mysession->get('hotelid');
		$action = JRequest::getVar('action');
		switch ($action) {
			case 'option1':
				$cartid = JRequest::getVar('cartid1');
				$lastname = JRequest::getVar('lastname');
				$query = "select hotelid from wrsreservationbatch where confirmed<>3 and paid=1 and cartid=$cartid and lastname like '$lastname' and hotelid=$hotelid";
				break;
			case 'option2':
				$cartid = JRequest::getVar('cartid2');
				$firstname = JRequest::getVar('firstname');
				$query = "select hotelid from wrsreservationbatch where confirmed<>3 and paid=1 and cartid=$cartid and firstname like '$firstname' and hotelid=$hotelid";
				break;
			case 'option3':
				$cartid = JRequest::getVar('cartid3');
				$email = JRequest::getVar('email');
				$query = "select hotelid from wrsreservationbatch where confirmed<>3 and paid=1 and cartid=$cartid and email like '$email' and hotelid=$hotelid";
				break;
		}
		$db->setQuery($query);
		if ($res = $db->loadResult()){
			/**
			 * @todo validate modification policy period
			 */
			$policy = JTable::getInstance('policy','table');
			$policy->load($res);
			$arrival = ReservationHelper::getFirstArrivalDate($cartid);
			$arrival .= " ".$policy->ci.":00:00";
//			$modifydate = date_add($arrival,date('Y-m-d'),'DAY');
			$allowed = date_diff(date('Y-m-d H:i:s'),date('Y-m-d',strtotime($arrival)));
//			$allowed = 0;
			if ($allowed>0) {
				$batch = JTable::getInstance('reservationbatch','Table');
				$batch->load($cartid);
				$cartid = $mysession->set('cartid',$batch->cartid);
				$hotelid = $mysession->set('hotelid',$batch->hotelid);
				$corpcode = $mysession->set('corpcode',$batch->corpcode);
				return true;
			}else {
				JError::raiseNotice(500,"Sorry but this reservation has exceeded the allowed reservation period.");
				#$cartid = $mysession->set('cartid',null);
				#$hotelid = $mysession->set('hotelid',null);
				#$corpcode = $mysession->set('corpcode',null);
				return false;
			}
		}else {
			$cartid = $mysession->set('cartid',null);
//			$hotelid = $mysession->set('hotelid',null);
			$corpcode = $mysession->set('corpcode',null);
			return false;
		};
	}
	function check(){
		//$this->setRedirect('index.php?option=com_wbrs&view=reservation&layout=step2');
		global $mainframe;
		$mysession = JFactory::getSession();
		$arrivaldate = JRequest::getVar('cidate');
		$departuredate = JRequest::getVar('codate');
		$roomnights = ReservationHelper::dateDiff($arrivaldate,$departuredate);
		$diff = ReservationHelper::dateDiff2($arrivaldate,$departuredate);
		$noofrooms = JRequest::getVar('numofrooms');
		$noofadults = JRequest::getVar('numofadults');
		$noofchildren = JRequest::getVar('numofchildren');
		$corpcode = JRequest::getVar('corpcode',0);
		$hotelid = $mysession->get('hotelid');
		/**
		 * @uses Check CorpCope Validity
		 */
		$isvalid  = ReservationHelper::validateCorpCode($corpcode);
		if (!$isvalid and $corpcode<>'') {
			$mainframe->redirect(JRoute::_("index.php?option=com_wbrs&view=modify&layout=step2"),"Invalid Corporate Code! Please try again.","error");
		}			
		if ($arrivaldate<>$departuredate and $roomnights==1 and $diff<>1) {
			echo "<script> alert('Invalid departure date');
				window.history.go(-1); </script>\n";
		} 
		//parent::display();
		$mainframe->redirect(JRoute::_("index.php?option=com_wbrs&view=modify&layout=step2&cidate=$arrivaldate&codate=$departuredate&numofrooms=$noofrooms&numofadults=$noofadults&numofchildren=$noofchildren&corpcode=$corpcode"));			
	}
	function cancel(){
		$mysession = JFactory::getSession();
		$cartid = $mysession->get('original');
		$row = JTable::getInstance('reservationbatch','Table');
		$row->load($cartid);
		$row->confirmed = 3;
		$row->acknowledged =0;
		$row->locked =0;
		$row->datecancelled = date('Y-m-d H:i:s');
		$row->store();
		/**
		 * @uses compute cancellation charges
		 */
		
		WbrsControllerModify::compute_cancellation_charges($cartid);
		
		MailHelper::sendLetter($cartid,EMAIL_EVENT_CANCELLATION);
		
		$this->setRedirect(JRoute::_("index.php?option=com_wbrs&view=modify&layout=cancel"));
	}
	function compute_cancellation_charges($cartid){
		$mysession = JFactory::getSession();
		$allowed = WPolicy::get_early_cancel_date($cartid,"Y-m-d")." 00:00";
		$early = unix_date_diff(date('Y-m-d H:i'),$allowed);
		$rmc = WPolicy::get_total_room_charges($cartid);
		if ($early>0) {
			/**
			 * @uses compute early cancellation charge
			 */
//			$payables = WPolicy::get_total_charges($cartid)-ModifyHelper::getPreviousPayment($cartid);
			$payables = WPolicy::get_total_charges($cartid);
			$gl = JTable::getInstance('gl','Table');
			$gl->id=0;
			$gl->cartid=$cartid;
			$gl->amount= $payables;
			$gl->datepaid = date('Y-m-d');
			$gl->lastupdated = date('Y-m-d H:i:s');
			$gl->tmpcartid=$mysession->get('cartid');
			$gl->remarks="Reverse Total Charges";
			$gl->store();
			
			$payables = -WPolicy::get_cancellation_charge($cartid);
			$gl = JTable::getInstance('gl','Table');
			$gl->id=0;
			$gl->cartid=$cartid;
			$gl->amount=$payables;
			$gl->datepaid = date('Y-m-d');
			$gl->lastupdated = date('Y-m-d H:i:s');
			$gl->tmpcartid=$mysession->get('cartid');
			$gl->remarks= "Cancellation Charge";
			$gl->store();
		}else {
			/**
			 * @uses compute late cancellation charges
			 */
//			$payables = WPolicy::get_total_charges($cartid)-ModifyHelper::getPreviousPayment($cartid);
			$payables = WPolicy::get_total_charges($cartid);
			$gl = JTable::getInstance('gl','Table');
			$gl->id=0;
			$gl->cartid=$cartid;
			$gl->amount= $payables;
			$gl->datepaid = date('Y-m-d');
			$gl->lastupdated = date('Y-m-d H:i:s');
			$gl->tmpcartid=$mysession->get('cartid');
			$gl->remarks="Reverse Total Charges";
			$gl->store();
			
			$payables = -WPolicy::get_cancellation_charge($cartid);
			$gl = JTable::getInstance('gl','Table');
			$gl->id=0;
			$gl->cartid=$cartid;
			$gl->amount=$payables;
			$gl->datepaid = date('Y-m-d');
			$gl->lastupdated = date('Y-m-d H:i:s');
			$gl->tmpcartid=$mysession->get('cartid');
			$gl->remarks= "Cancellation Charges";
			$gl->store();			
		}
	
	}
	function book(){
		JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
		$db = JFactory::getDBO();
		$mysession = JFactory::getSession();
		$corpcode = $mysession->get('corpcode');
		$corpid = ReservationHelper::getCorporateID($corpcode);
		$arrivaldate = JRequest::getVar('arrivaldate');
		$departuredate = JRequest::getVar('departuredate');
		$noofadults = JRequest::getVar('numofadults');
		$noofrooms = JRequest::getVar('noofrooms');
		$extrapersonrate = JRequest::getVar('extrapersonrate');
		$roomnights = hoteldb::dateDiff($arrivaldate,$departuredate);
		$hotelid = $mysession->get('hotelid');
		$roomid = JRequest::getVar('roomid');
		/**
		 * @uses start saving batch
		 */
		$batch =& JTable::getInstance('ReservationBatchTmp','Table');
		
		$post = JRequest::get('post');
		if (!$batch->bind( $post )) {
			return JError::raiseWarning( 500, $batch->getError() );
		}

		if (JRequest::getVar('cartid')==0) {
			$batch->datecreated =date('Y-m-d H:i:s');		
		}
		$batch->lastupdated=date('Y-m-d H:i:s');	
		$batch->clientip = $_SERVER['REMOTE_ADDR'];
		$batch->clientbrowser = $_SERVER['HTTP_USER_AGENT'];
		$batch->corpid = $corpid;
		if (!$batch->store()) {
			return JError::raiseWarning( 500, $batch->getError() );
		}
		$cartid = $batch->cartid;
		
		/**
		 * @uses start saving header
		 */
		$header =& JTable::getInstance('ReservationHeaderTmp','Table');
		
		$post = JRequest::get('post');		
		if (!$header->bind( $post )) {
			return JError::raiseWarning( 500, $header->getError() );
		}

		$header->cartid = $cartid;
		if (JRequest::getVar('reservation_number')==0) {
			$header->datecreated =date('Y-m-d H:i:s');		
		}
		
		$header->lastupdated=date('Y-m-d H:i:s');			
		$header->roomnights = $roomnights;

		if (!$header->store()) {
			return JError::raiseWarning( 500, $header->getError() );
		}
		
		/**
		 * @uses start saving details
		 */
		$reservation_number = $header->reservation_number;
		
		$details = & JTable::getInstance('ReservationDetailsTmp','Table');
		$available = hoteldb::isRoomAvailable($hotelid,$roomid,$arrivaldate,$roomnights,$noofrooms,$extrapersonrate);

		if ($available) {			
//			$breakdown = ReservationHelper::getDailyRate($hotelid,$roomid,$arrivaldate,$roomnights,$noofrooms);
			$breakdown = ReservationHelper::getDailyRateWithDorm($hotelid,$roomid,$arrivaldate,$roomnights,$noofrooms,$noofadults,$extrapersonrate);
			$total =0;
			for ($j=0;$j<$roomnights;$j++){
				$x = $breakdown[$j];
				$from = array('id'=>0,
						'reservation_number'=>$reservation_number,
						'cartid'=>$cartid,
						'hotelid'=>$hotelid,
						'roomid'=>$roomid,
						'reservationdate'=>$x['date'],
						'ratetype'=>$x['ratetype'],
						'rateid'=>$x['rateid'],
						'qty'=>$x['numofrooms'],
						'roomrate'=>$x['rate'],
						'total'=>$x['total'] ,
						'remarks'=>$x['remarks'],
						'extrapersonrate'=>$x['extrapersonrate'],
						'max'=>$x['maximumallowed'],
						'adult'=>$noofadults
					);
				if (!$details->bind( $from )) {
					return JError::raiseWarning( 500, $details->getError() );
				}
				$excess = $noofadults - $details->max ;
				$excess = ($excess>0)?$excess:0;
				$details->total += $details->extrapersonrate * ($excess); 
				if (!$details->store()) {
					return JError::raiseWarning( 500, $details->getError() );
				}
				$total += $details->total;
			}
			/**
			 * update header total
			 */
			$header->total = $total;
			if (!$header->store()) {
				return JError::raiseWarning( 500, $header->getError() );
			}
		}
		/**
		 * end saving details
		 */
		//$mysession = JFactory::getSession();
		//$mysession->set('cartid',$cartid);
		$this->setRedirect(JRoute::_('index.php?option=com_wbrs&view=modify&layout=step3'));
	}
	function unbook(){
		$db = JFactory::getDBO();
		$mysession = JFactory::getSession();
		$query = "select count(*) from wrsreservationheadertmp where cartid=".$mysession->get('cartid');
		$db->setQuery($query);		
		if ($db->loadResult()<=1) {
			$this->setRedirect(JRoute::_('index.php?option=com_wbrs&view=modify&layout=step3'),"Unable to remove this booking. Please book another room first before deleting this room reservation.","error");					
		}else {
			$query = "delete from wrsreservationheadertmp where reservation_number=".JRequest::getVar('reservation_number');
			$db->setQuery($query);
			$db->query();
	
			$query = "delete from wrsreservationdetailstmp where reservation_number=".JRequest::getVar('reservation_number');
			$db->setQuery($query);
			$db->query();
			//parent::display();
			$this->setRedirect(JRoute::_('index.php?option=com_wbrs&view=modify&layout=step3'));	
		}		
	}
	function addservice(){
		JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
		$row = JTable::getInstance('tmpservices','Table');
		$mysession = JFactory::getSession();
		$cartid = $mysession->get('cartid');
		$post = JRequest::get('post');
		if (!$row->bind( $post )) {
			return JError::raiseWarning( 500, $row->getError() );
		}
		$row->cartid = $cartid;
		if (!$row->store()) {
			return JError::raiseWarning( 500, $row->getError() );
		}
		//parent::display();
		$this->setRedirect(JRoute::_('index.php?option=com_wbrs&view=modify&layout=step4'));
	}
	function deleteservice(){
		$db = JFactory::getDBO();
		$query = "delete from wrstmpservices where id=".JRequest::getVar('id');
		$db->setQuery($query);
		$db->query();
		$this->setRedirect(JRoute::_('index.php?option=com_wbrs&view=modify&layout=step4'));		
	}
	function saveprofile(){
		JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
		$row = JTable::getInstance('clienttmp','Table');
		$mysession = JFactory::getSession();
		$cartid = $mysession->get('cartid');
		$post = JRequest::get('post');
		if (!$row->bind( $post )) {
			return JError::raiseWarning( 500, $row->getError() );
		}
		$row->cartid = $cartid;
		if (!$row->store()) {
			return JError::raiseWarning( 500, $row->getError() );
		}
		$batchtmp = JTable::getInstance('reservationbatchtmp','table');
		$batchtmp->load($cartid);
		$batchtmp->bind($post);
		$batchtmp->store();
		$this->setRedirect(JRoute::_('index.php?option=com_wbrs&view=modify&layout=step4'));				
	}
	function confirmpayment(){
		JRequest::setVar('tmpl','component');
		$mysession = JFactory::getSession();
		$cartid = $mysession->get('cartid');
		$payables= $mysession->get('payables');
		$newcartid = $mysession->get('original');
		define('PESOPAY_AMOUNT',$payables);
		define('PESOPAY_REF',$newcartid);
		WHelper::loadPesoPay(0);
	}
	function savereservation(){
		$this->bookingconfirmed();
		$this->success(1);
		$this->setRedirect(JRoute::_("index.php?option=com_wbrs&view=modify&layout=success"));
	}
	function payment(){
		$this->saveprofile();
		if (JRequest::getVar('pickup')) {
			$this->remove_pickup(JFactory::getSession()->get('cartid'));								
			$this->add_pickup(JFactory::getSession()->get('cartid'),JRequest::getVar('serviceid'));				
		}else {
			$this->remove_pickup(JFactory::getSession()->get('cartid'));								
		}
		$this->setRedirect(JRoute::_("index.php?option=com_wbrs&view=modify&layout=step5"));		
	}
	function payment2(){
		$error = $this->validate();
		if ($error<>'') {
			echo "<script> alert('".$error."');
				window.history.go(-1); </script>\n";
			//$this->setRedirect('index.php?option=com_wbrs&view=reservation&layout=step3',$error,'error');			
		} else {
			$this->saveprofile();
			if (JRequest::getVar('pickup')) {
				$this->remove_pickup(JFactory::getSession()->get('cartid'));								
				$this->add_pickup(JFactory::getSession()->get('cartid'),JRequest::getVar('serviceid'));				
			}else {
				$this->remove_pickup(JFactory::getSession()->get('cartid'));								
			}
			$this->updateBatchInfo();
			$this->checkRoomReservation();
			$this->setRedirect(JRoute::_('index.php?option=com_wbrs&view=reservation&layout=step5'));			
		}			
	}
	function add_pickup($cartid, $serviceid){
		$service = JTable::getInstance('services','table');
		$tmpservice = JTable::getInstance('tmpservices','table');
		$service->load($serviceid);
		$tmpservice->cartid = $cartid;
		$tmpservice->serviceid = $serviceid;
		$tmpservice->qty = 1;
		$tmpservice->servicerate = $service->servicerate;
		$tmpservice->total = $service->servicerate;
		$tmpservice->catid = $service->catid;
		if (!$tmpservice->store()){
			JError::raiseError(500,$tmpservice->getErrorMsg());
		}
	}
	function remove_pickup($cartid){
		$db = JFactory::getDBO();
		$query = "delete from wrstmpservices where cartid=$cartid";
		$db->setQuery($query);
		$db->query();		
	}
	function failed(){
		$this->setRedirect(JRoute::_("index.php?option=com_wbrs&view=modify&layout=step5"),"Payment process failed. Please try again!");				
	}
	function success($save=0){
		global $mainframe;
		$mysession = JFactory::getSession();
		$sessioncart = $mysession->get('cartid');
		if (!$sessioncart>0) {
			global $mainframe;
			$mainframe->redirect('index.php','Sorry, Your session has expired.\n I\'m afraid you have to go through the process again.');
		}

		$cartid = JRequest::getVar('Ref'); 
		if ($save==1) {
			$cartid = $mysession->get('original');			
		}
		$batch->load($cartid);
		$batch->confirmed = 2;
		$batch->paid = 1;
		$batch->store();
				
		JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
		$row = JTable::getInstance('reservationbatch','table');
		$row->load($cartid);
		$name = ucfirst($row->firstname).' '.ucfirst($row->lastname);
		/**
		 * @uses update payment records
		 */
		$roomcharge = ModifyHelper::getRoomCharge($sessioncart);
		$servicecharge = ModifyHelper::getServiceCharge($sessioncart);
		$previous = ModifyHelper::getPreviousPayment($cartid);			
		$total = $roomcharge + $servicecharge;
		$paynow = WPolicy::get_payable($sessioncart);
		$payables =  $paynow - $previous;
		$payables = ($payables<=0)?0:$payables;
		if ($payables==0) {
			$receivables = $total - $previous;			
		}else {
			$receivables = $total - $paynow;
		}		
		
		$gl = JTable::getInstance('gl','Table');
		$gl->id=0;
		$gl->cartid=$cartid;
		$gl->amount=$payables;
		$gl->datepaid = date('Y-m-d');
		$gl->lastupdated = date('Y-m-d H:i:s');
		$gl->tmpcartid=$sessioncart;
		$gl->remarks="Modification Charges";
		$gl->store();

		$this->bookingconfirmed();
		MailHelper::sendLetter($cartid,EMAIL_EVENT_MODIFY);
		
		/**
		 * @uses Run Availability Alert
		 */
		//ReservationHelper::checkAvailabilityAlert();
		$mainframe->redirect(JRoute::_("index.php?option=com_wbrs&view=modify&layout=success"));
	}
	function bookingconfirmed(){
		$db = JFactory::getDBO();
		$mysession = JFactory::getSession();
		/**
		 * @uses transfer reservation temp batch to activity list
		 */
		$cartid = $mysession->get('cartid');
		JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
		$batch = JTable::getInstance('reservationbatch','Table');
		$batchtmp = JTable::getInstance('reservationbatchtmp','Table');
		$batchtmp->load($cartid);
		$batch->load($mysession->get('original'));
		$from = array('sessionid'=>$batchtmp->sessionid,
				'hotelid'=>$batchtmp->hotelid,
				'clientip'=>$batchtmp->clientip,
				'clientbrowser'=>$batchtmp->clientbrowser,
				'datecreated'=>$batchtmp->datecreated,
				'lastupdated'=>$batchtmp->lastupdated,
				'lastname'=>$batchtmp->lastname,
				'firstname'=>$batchtmp->firstname,
				'middlename'=>$batchtmp->middlename,
				'contactno'=>$batchtmp->contactno,
				'email'=>$batchtmp->email,
				'tmpcartid'=>$batchtmp->cartid,
				'confirmed'=>2,
				'paid'=>1,
				'acknowledged'=>0,
				'agent'=>$batchtmp->agent,
				'agentcontactno'=>$batchtmp->agentcontactno,
				'agentdept'=>$batchtmp->agentdept,
				'corpid'=>$batchtmp->corpid
			);
		/**
		 * @uses Save New Batch Record
		 */
		$batch->bind($from);
		$batch->store();
		/**
		 * @uses Update temporary Batch Record
		 */
		$batchtmp->confirmedcartid = $batch->cartid;
		$batchtmp->store();
			
		/**
		 * @uses Delete existing reservation header batch to activity list
		 */
		$query = 'delete from wrsreservationheader where cartid='.$batch->cartid;
		$db->setQuery($query);
		$db->query();		
		/**
		 * @uses Transfer reservation header batch to activity list
		 */
		$fields = 'hotelid,roomid,arrivaldate,departuredate,roomnights,qty,noofadults,noofchildren,minrate,maxrate,total,cancelled,datecreated,lastupdated';
		$query = "insert into wrsreservationheader (cartid,$fields,tmpreservation_number) ";
		$query .= "select $batch->cartid, $fields,reservation_number from wrsreservationheadertmp where cartid=$cartid";
		$db->setQuery($query);
		$db->query();
		/**
		 * @uses Delete existing client profile
		 */
		$query = 'delete from wrsclient where cartid='.$batch->cartid;
		$db->setQuery($query);
		$db->query();	
		/**
		 * @uses Save Client Profile
		 */		
		$fields = 'lastname,firstname,middlename,email,contactno,hotelarrival,flightarrival,carrier,pickup,country,sourceofinfo,guesttype,request,serviceid';
		$query = "insert into wrsclient (cartid,$fields) ";
		$query .= "select $batch->cartid, $fields from wrsclienttmp where cartid=$cartid";
		$db->setQuery($query);
		$db->query();
		/**
		 * @uses Delete existing reservation details batch to activity list
		 * 
		 */
		$query = 'delete from wrsreservationdetails where cartid='.$batch->cartid;
		$db->setQuery($query);
		$db->query();		
		//Load Reservation Header ------------------------------------------------------------		
		$query = 'select reservation_number, tmpreservation_number from wrsreservationheader where cartid='.$batch->cartid;
		$db->setQuery($query);
		$rs = $db->loadObjectList();
		//------------------------------------------------------------------------------------
		for ($i=0;$i<count($rs);$i++){
			$row = $rs[$i];
			/**
			 * @uses transfer reservation details to activity list
			 */
			$fields = 'hotelid,roomid,reservationdate,qty,ratetype,rateid,roomrate,total,remarks,adult';
			$query = "insert into wrsreservationdetails (reservation_number,cartid,$fields) ";
			$query .= "select $row->reservation_number, $batch->cartid, $fields from wrsreservationdetailstmp where cartid=$cartid and reservation_number=$row->tmpreservation_number";
			$db->setQuery($query);
			$db->query();
		}

		/**
		 * @uses delete existing services
		 */
		$query = 'delete from wrsreservationservices where cartid='.$batch->cartid;
		$db->setQuery($query);
		$db->query();	
		/**
		 * @uses Save Services
		 */
		$fields = 'serviceid,qty,servicerate,total,catid';
		$query = "insert into wrsreservationservices (cartid,$fields) ";
		$query .= "select $batch->cartid, $fields from wrstmpservices where cartid=$cartid";
		$db->setQuery($query);
		$db->query();
		/**
		 * @uses Return new Cart ID
		 */
		return $batch->cartid;
	}
	
	function cancelled(){
		global $mainframe;
		$view = JRequest::getVar('view');
		$mainframe->redirect(JRoute::_("index.php?option=com_wbrs&view=modify&layout=step5"),"You have cancelled the Payment Process. Confirm Reservation to proceed to payment again.");
		//parent::display();
	}
}

Yes, I think it is too much to ask.

Member Avatar for Zagga

Hi cyberjorge,

Thats a lot of code to look through (and to be honest, I didn't), but if you just want a database field that holds the latest update time, you can simply change the "lastupdate" field in your database have a few specific attributes.

If you make the type of the field "timestamp" and add the attribute "on update CURRENT_TIMESTAMP" then it will automatically store the update time whenever any of the other fields are updated (You won't need to manually update it anymore).

You can use the following SQL as an example of how the field should look

`lastupdated` timestamp NOT NULL default '0000-00-00 00:00:00' on update CURRENT_TIMESTAMP

This will store the date as 0000-00-00 00:00:00 as default and change to YYYY-MM-DD HH:MM:SS once the record has been updated.


Hope this helps
Zagga

sql/mysql/mssql/postgresql now()
php date()

functions already exist
text format dates are stupid

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.