<?php

class Upgrade_Report extends Upgrade {
	
	var $platfom = 'lms';
	
	var $mname = 'report';
	
	/**
	 * upgrade the module version
	 * @param string 	$start_version 	the start version, automaticaly prooceed to the next
	 *
	 * @return mixed 	true if the version jump was successful, else an array with an error code and an error message
	 * 					array( 'error_code', 'error_msg' )
	 **/
	function oneStepUpgrade($start_version) {
		
		switch($start_version) {
			case "2.0.4" : {
				
				$query = "
				CREATE TABLE `learning_report` (
				  `id_report` int(11) NOT NULL auto_increment,
				  `report_name` varchar(255) NOT NULL default '',
				  `class_name` varchar(255) NOT NULL default '',
				  `file_name` varchar(255) NOT NULL default '',
				  `use_user_selection` enum('true','false') NOT NULL default 'true',
				  PRIMARY KEY  (`id_report`)
				);";
				if(!$this->db_man->query($query)) return $this->_getErrArray($start_version, 1);
				
				$query = "INSERT INTO `learning_report` VALUES (1, 'general_report', 'Report_General', 'class.report_general.php', 'true');
				INSERT INTO `learning_report` VALUES (2, 'user_report', 'Report_User', 'class.report_user.php', 'true');";
				if(!$this->db_man->query($query)) return $this->_getErrArray($start_version, 2);
				
				$this->end_version = '3.0';
				return true;
			};break;
			
		}
		return true;
	}
	
}

?>