<?php
	require_once( $GLOBALS["site_root"]."/includes/pages/DefaultFrontend.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/widgets/AdminHtmlEdit2.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/widgets/CaptchaHtmlHide.inc.php" );

	require_once( $GLOBALS["site_root"]."/includes/models/Job.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/models/Member.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/models/TemplateMail.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/models/Constants.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/models/Status.inc.php" );
	require_once( $GLOBALS["site_root"]."/includes/models/Blueboard.inc.php" );

	/*
	// notification email
			$this->jm = new JobModel();
			$this->mm = new MemberModel();
			$this->um = new UserModel();
			$this->sm = new StatusModel();
			
			// $this->captcha = new CaptchaHtmlHide( "content_widget" , $this );

			$member_id = 785;
			
			$member = $this->mm->getMemberFromMemberId( $member_id );
			$newstatus = $this->sm->getNewMemberStatus( $member );
			FNTH_da( $newstatus );

				$tmm = new TemplateMailModel( "sys_job_notification_to_translators" );
				$tmm->setHtml( true );
				$tmm->setPlain( true );
				$cm = new ConstantsModel( $tmm );
				$cm->addSystemParametersToTemplate();
				$cm->addJobConstantsToTemplate( $job["job_id"] , "job" , $job );
				$cm->addMemberConstantsToTemplate( $member["member_id"] , "member" , $member );
				$cm->addUserConstantsToTemplate( $member["user_id"] , "user" , $user );
				$tmm->sendMail( $user["email"] );
			exit();
	*/

	/*
	// member job recipient test
			$user = $this->um->getUserFromUserId( $member["user_id"] );
			$this->jm->isMemberJobRecipient( $member , $job );
	*/

	/*
	// unknown test
			require_once( $GLOBALS["site_root"] . "/includes/models/Job.inc.php" );
			$jm = new JobModel();
			FNTH_da( $jm->generateJobRecipients( 5 ) );



			$this->oTestEditor = new AdminHtmlEdit2( "content_widget" , $this );
			$this->oTestEditor->setValue( "hello <span class=\"rmpvideo\">[{video width=300 height=200}]/valami.flv[{/video}]</span> world" );
			$this->oTestEditor->setWidth( 700 );
	*/
			/*
			// autologin
			require_once( $GLOBALS["site_root"] . "/includes/widgets/LoginBox.inc.php" );
			$test = new LoginBox( "content_widget" , $this );
			$test->setUserAutoLogin();
			*/

	/*
	// testlevel
	$this->jm = new JobModel();
	$this->mm = new MemberModel();

	$job_id= 6746;
	$job = $this->jm->getJobFromId( $job_id , true );

	$member_id = 275;
	$member = $this->mm->getMemberFromMemberId( $member_id , true );

	FNTH_da( $this->jm->isMemberJobRecipient( $member , $job ) );
	*/

	/*
	// benkkartya
	$comment = "fordit.hu előfizetés vásárlása";

	require_once( $GLOBALS["site_root"]."/includes/models/CreditCard.inc.php" );
	$ccm = new CreditCardModel();
	$ccm->startTransaction( 259 , 100 , "huf" , $comment );

	require_once( $GLOBALS["site_root"]."/includes/models/Otp.inc.php" );
	$om = new OtpModel();
	$om->startNewTransaction( 100 , "huf" , "fordít.hu előfizetés vásárlása" );
	FNTH_da( $om->getNextTransactionId() );

			require_once( $GLOBALS["site_root"]."/includes/models/CreditCard.inc.php" );
			$ccm = new CreditCardModel();
			$ccm->finishTransaction( 2 );
			FNTH_da( "vegeztunk" );
	*/

	class TestPage extends DefaultFrontend {
		protected $oTestEditor;

		public function __construct( $id = "TestPage" , $parent = null , $pagetype = "request_a_quote"  ) {
			parent::__construct( $id , $parent , $pagetype );

		
			/*	
			// member aliasname regen
			require_once( $GLOBALS["site_root"]."/includes/models/Member.inc.php" );
			require_once( $GLOBALS["site_root"] . "/includes/models/Globals.inc.php" );
			$mm = new MemberModel();

			$query = sprintf( "select member_id from members where current_status not in %s order by member_id",
				GlobalsModel::statuses( array( STATUS_NEW_USER_DELETED , STATUS_DELETED ) ) );
			$member_ids = FNTH_db_get_column( $query , "member_id" );
			foreach ($member_ids as $member_id) $mm->updateMemberAliasname( $member_id );
			FNTH_da( "done" );
			*/

			/*
			require_once( $GLOBALS["site_root"]."/includes/models/Status.inc.php" );
			$mm = new MemberModel();
			$sm = new StatusModel();
			$member = $mm->getMemberFromMemberId( 637 );
			FNTH_da( $member , false );
			$new_status = $sm->getNewMemberStatus( $member );
			FNTH_da( $new_status );

			*/


		}

		public function handleEvents() {
			/*
			if (!isset( $this->aG["otpfinish"] )) return parent::handleEvents();
			require_once( $GLOBALS["site_root"]."/includes/models/CreditCard.inc.php" );
			$ccm = new CreditCardModel();
			$ccm->finishTransaction( $this->aG["otpfinish"] );
			FNTH_da( "vegeztunk" );
			*/
		}
		public function render() {
			$user_ids = FNTH_db_get_column( "select user_id from users" , "user_id" );
			$bbm = new BlueboardModel();
			foreach ($user_ids as $user_id) {
				$bbm->recalculateUserAverage( $user_id );
			}
			return parent::render();
		}

	}
?>
