<?php
/*********************************************************************************
 * The contents of this file are subject to the TimeTrex Public License Version
 * 1.1.0 ("License"); You may not use this file except in compliance with the
 * License. You may obtain a copy of the License at http://www.TimeTrex.com/TPL
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * All copies of the Covered Code must include on each user interface screen:
 *    (i) the "Powered by TimeTrex" logo and
 *    (ii) the TimeTrex copyright notice
 * in the same form as they appear in the distribution.  See full license for
 * requirements.
 *
 * The Original Code is: TimeTrex Open Source
 * The Initial Developer of the Original Code is TimeTrex Payroll Services
 * Portions created by TimeTrex are Copyright (C) 2004-2007 TimeTrex Payroll Services;
 * All Rights Reserved.
 *
 ********************************************************************************/
/*
 * $Revision: 1246 $
 * $Id: InstallSchema_1000A.class.php 1246 2007-09-14 23:47:42Z ipso $
 * $Date: 2007-09-14 16:47:42 -0700 (Fri, 14 Sep 2007) $
 */
class InstallSchema_1000A extends InstallSchema_Base {

	function preInstall() {
		Debug::text('preInstall: '. $this->getVersion() , __FILE__, __LINE__, __METHOD__,9);

		return TRUE;
	}


	function postInstall() {
		global $config_vars;

		Debug::text('postInstall: '. $this->getVersion(), __FILE__, __LINE__, __METHOD__,9);

		$maint_base_path = Environment::getBasePath() . DIRECTORY_SEPARATOR .'maint'. DIRECTORY_SEPARATOR;
		if ( PHP_OS == 'WINNT' ) {
			$cron_job_base_command =  'php-win.exe '. $maint_base_path;
		} else {
			$cron_job_base_command =  'php '. $maint_base_path;
		}
		Debug::text('Cron Job Base Command: '. $cron_job_base_command, __FILE__, __LINE__, __METHOD__,9);

		// >> /dev/null 2>&1
		$cjf = new CronJobFactory();
		$cjf->setName('AddPayPeriod');
		$cjf->setMinute(0);
		$cjf->setHour(0);
		$cjf->setDayOfMonth('*');
		$cjf->setMonth('*');
		$cjf->setDayOfWeek('*');
		$cjf->setCommand($cron_job_base_command.'AddPayPeriod.php');
		$cjf->Save();

		$cjf = new CronJobFactory();
		$cjf->setName('AddUserDate');
		$cjf->setMinute(15);
		$cjf->setHour(0);
		$cjf->setDayOfMonth('*');
		$cjf->setMonth('*');
		$cjf->setDayOfWeek('*');
		$cjf->setCommand($cron_job_base_command.'AddUserDate.php');
		$cjf->Save();

		$cjf = new CronJobFactory();
		$cjf->setName('calcExceptions');
		$cjf->setMinute(30);
		$cjf->setHour(0);
		$cjf->setDayOfMonth('*');
		$cjf->setMonth('*');
		$cjf->setDayOfWeek('*');
		$cjf->setCommand($cron_job_base_command.'calcExceptions.php');
		$cjf->Save();

		$cjf = new CronJobFactory();
		$cjf->setName('AddRecurringPayStubAmendment');
		$cjf->setMinute(45);
		$cjf->setHour(0);
		$cjf->setDayOfMonth('*');
		$cjf->setMonth('*');
		$cjf->setDayOfWeek('*');
		$cjf->setCommand($cron_job_base_command.'AddRecurringPayStubAmendment.php');
		$cjf->Save();

		$cjf = new CronJobFactory();
		$cjf->setName('AddRecurringHoliday');
		$cjf->setMinute(55);
		$cjf->setHour(0);
		$cjf->setDayOfMonth('*');
		$cjf->setMonth('*');
		$cjf->setDayOfWeek('*');
		$cjf->setCommand($cron_job_base_command.'AddRecurringHoliday.php');
		$cjf->Save();

		$cjf = new CronJobFactory();
		$cjf->setName('UserCount');
		$cjf->setMinute(15);
		$cjf->setHour(1);
		$cjf->setDayOfMonth('*');
		$cjf->setMonth('*');
		$cjf->setDayOfWeek('*');
		$cjf->setCommand($cron_job_base_command.'UserCount.php');
		$cjf->Save();

		$cjf = new CronJobFactory();
		$cjf->setName('AddRecurringScheduleShift');
		$cjf->setMinute('20,50');
		$cjf->setHour('*');
		$cjf->setDayOfMonth('*');
		$cjf->setMonth('*');
		$cjf->setDayOfWeek('*');
		$cjf->setCommand($cron_job_base_command.'AddRecurringScheduleShift.php');
		$cjf->Save();

		$cjf = new CronJobFactory();
		$cjf->setName('CheckForUpdate');
		$cjf->setMinute( rand(0,59) ); //Random time once a day for load balancing
		$cjf->setHour( rand(0,23) ); //Random time once a day for load balancing
		$cjf->setDayOfMonth('*');
		$cjf->setMonth('*');
		$cjf->setDayOfWeek('*');
		$cjf->setCommand($cron_job_base_command.'CheckForUpdate.php');
		$cjf->Save();

		return TRUE;

	}
}
?>
