<?xml version="1.0" encoding="utf-8"?>
<module>
	<name>AdvancedReports</name>
	<label>Advanced Reporting</label>
	<parent>Support</parent>
		<version>2.1.209</version>
	<dependencies>
		<vtiger_version>6.0.0</vtiger_version>
	</dependencies>
	<type>extension</type>
	<license>
		<file>legal.txt</file>
	</license>

	<tables>
		<table>
			<name>vtiger_advancedreports</name>
			<sql>
			<![CDATA[CREATE TABLE `vtiger_advancedreports` (
				 `id` int(11) NOT NULL AUTO_INCREMENT,
				 `category_id` int(19) NOT NULL,
				 `sequence` int(10) NOT NULL,
				 `module` varchar(255) NOT NULL,
				 `related_data` blob NOT NULL,
				 `fields` blob NOT NULL,
				 `filters` mediumblob NOT NULL,
				 `grouping` mediumblob NOT NULL,
				 `aggregates` mediumblob NOT NULL,
				 `totalAggregates` blob NULL DEFAULT NULL,
				 `title` varchar(255) NOT NULL,
				 `description` text,
				 `options` blob NOT NULL,
				 `labels` mediumblob NOT NULL,
				 `chart` blob NOT NULL,
				 `owner` int(11) NOT NULL,
				 `shared` int(11) NOT NULL,
				 `sharedlevel` int(11) NOT NULL DEFAULT '0',
				 `iscombined` int(11) NOT NULL DEFAULT '0',
				 `combinedfields` blob,
				 `visible` INT(1) NOT NULL DEFAULT '1',
				 `calcFields` mediumblob,
				 `deleted` int(1) DEFAULT '0',
				 `columnstate` mediumblob NULL DEFAULT NULL,
				 `calculatedColumns` blob NULL DEFAULT NULL,
				 PRIMARY KEY (`id`)
			) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_advancedreports_categories</name>
			<sql>
			<![CDATA[CREATE TABLE `vtiger_advancedreports_categories` (
				 `id` int(19) NOT NULL AUTO_INCREMENT,
				 `parent_id` int(19) DEFAULT NULL,
				 `sequence` int(10) NOT NULL,
				 `title` varchar(255) DEFAULT NULL,
				 `description` varchar(255) DEFAULT NULL,
				 `visible` INT(1) NOT NULL DEFAULT '1',
				 PRIMARY KEY (`id`)
			) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_advancedreports_sharedgroups</name>
			<sql>
			<![CDATA[CREATE TABLE `vtiger_advancedreports_sharedgroups` (
				 `object_id` varchar(36) NOT NULL,
				 `group_id` int(11) NOT NULL,
				 `level` int(11) NOT NULL,
				 UNIQUE KEY `idx` (`object_id`,`group_id`),
				 KEY `object_id` (`object_id`),
				 KEY `user_id` (`group_id`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_advancedreports_sharedusers</name>
			<sql>
			<![CDATA[CREATE TABLE `vtiger_advancedreports_sharedusers` (
				 `object_id` varchar(36) NOT NULL,
				 `user_id` int(11) NOT NULL,
				 `level` int(11) NOT NULL,
				 UNIQUE KEY `idx` (`object_id`,`user_id`),
				 KEY `object_id` (`object_id`),
				 KEY `user_id` (`user_id`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_advancedreports_schedule</name>
			<sql>
			<![CDATA[CREATE TABLE `vtiger_advancedreports_schedule` (
				`object_id` varchar(36) NOT NULL,
				`interval` int(11) NOT NULL,
				`interval_options` varchar(5) NOT NULL,
				`time` varchar(5) NOT NULL,
				`status` VARCHAR(10) NULL DEFAULT NULL,
				`starttime` datetime NULL DEFAULT NULL,
				`endtime` datetime NULL DEFAULT NULL,
				`nexttime` datetime NOT NULL,
				`formats` blob NOT NULL,
				`emails` blob NULL DEFAULT NULL,
				`object_type` char(1) NOT NULL DEFAULT 'R',
				UNIQUE KEY `uniqui` (`object_id`, `object_type`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_advancedreports_schedule_g</name>
			<sql>
			<![CDATA[CREATE TABLE `vtiger_advancedreports_schedule_g` (
				`object_id` varchar(36) NOT NULL,
				`group` varchar(36) NOT NULL,
				UNIQUE KEY `report_idx` (`object_id`,`group`),
				KEY `group` (`group`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_advancedreports_schedule_r</name>
			<sql>
			<![CDATA[CREATE TABLE `vtiger_advancedreports_schedule_r` (
				`object_id` varchar(36) NOT NULL,
				`role` varchar(36) NOT NULL,
				UNIQUE KEY `report_idx` (`object_id`,`role`),
				KEY `role` (`role`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_advancedreports_schedule_u</name>
			<sql>
			<![CDATA[CREATE TABLE `vtiger_advancedreports_schedule_u` (
				`object_id` varchar(36) NOT NULL,
				`user` varchar(36) NOT NULL,
				UNIQUE KEY `report_idx` (`object_id`,`user`),
				KEY `user` (`user`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_advancedreports_config</name>
			<sql>
			<![CDATA[CREATE TABLE `vtiger_advancedreports_config` (
		        `id` varchar(32) DEFAULT NULL,
        		`value` text,
        		UNIQUE KEY `id` (`id`)
    		) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_advancedreports_templates</name>
			<sql>
				<![CDATA[CREATE TABLE `vtiger_advancedreports_templates` (
				`id` int(11) NOT NULL AUTO_INCREMENT,
		        `name` varchar(255) NOT NULL,
        		`file` BLOB NULL DEFAULT NULL,
				`file_checksum` varchar(40) DEFAULT NULL,
				`worksheets` text NULL DEFAULT NULL,
        		PRIMARY KEY (`id`)
    		) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_homewidget_url</name>
			<sql>
			<![CDATA[CREATE TABLE `vtiger_homewidget_url` (
				`widgetid` int(19) unsigned NOT NULL,
				`url` varchar(255) NOT NULL,
				PRIMARY KEY (`widgetid`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
		<table>
			<name>vtiger_advancedreports_jobs</name>
			<sql>
				<![CDATA[CREATE TABLE `vtiger_advancedreports_jobs` (
				`id` int(11) NOT NULL AUTO_INCREMENT,
		        `name` varchar(255) NOT NULL,
		        `description` varchar(255) NOT NULL,
		        `active` tinyint(1) NOT NULL,
		        `type` varchar(255) NOT NULL,
        		`descriptor` blob NOT NULL,
            	`state` blob NOT NULL,
				`status` VARCHAR(10) NULL DEFAULT NULL,
				`max_time` VARCHAR(15) NULL DEFAULT NULL,
				`max_memory` VARCHAR(15) NULL DEFAULT NULL,
        		PRIMARY KEY (`id`)
    		) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
        <table>
            <name>vtiger_advancedreports_dashboards</name>
            <sql>
                <![CDATA[CREATE TABLE `vtiger_advancedreports_dashboards` (
                `id` char(36) NOT NULL,
                `category_id` int(11) NOT NULL,
                `visible` int(1) NOT NULL DEFAULT '1',
                `sequence` int(10) NOT NULL,
                `title` varchar(255) NOT NULL,
                `description` text NOT NULL,
                `filters` mediumblob,
                `owner` varchar(36) NOT NULL,
                `shared` int(1) NOT NULL,
                `sharedlevel` int(1) NOT NULL DEFAULT '0',
                 PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
            </sql>
        </table>
        <table>
            <name>vtiger_advancedreports_widgets</name>
            <sql>
                <![CDATA[CREATE TABLE `vtiger_advancedreports_widgets` (
                `id` char(36) NOT NULL,
                `dashboard_id` char(36) NOT NULL,
                `report_id` int(11) NOT NULL,
                `type` varchar(50) NOT NULL,
                `positionx` int(5) NOT NULL,
                `positiony` int(5) NOT NULL,
                `width` int(5) NOT NULL,
                `height` int(5) NOT NULL,
                `settings` TEXT,
                 PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
            </sql>
        </table>
        <table>
            <name>vtiger_advancedreports_table_mapping</name>
            <sql>
                <![CDATA[CREATE TABLE IF NOT EXISTS `vtiger_advancedreports_table_mapping` (
                `id` int(11) NOT NULL AUTO_INCREMENT,
                `original_name` varchar(255) NOT NULL,
                `hashed_name` varchar(255) NOT NULL,
                PRIMARY KEY (`id`),
                INDEX `mapping_orgin_name_idx` (`original_name`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
            </sql>
        </table>
        <table>
            <name>vtiger_advancedreports_logs</name>
            <sql>
                <![CDATA[CREATE TABLE IF NOT EXISTS `vtiger_advancedreports_logs` (
                `id` int(11) NOT NULL AUTO_INCREMENT,
                `created` datetime NOT NULL,
                `level` varchar(10) NOT NULL,
                `memory_usage` varchar(30) NOT NULL,
				`time_taken` varchar(30) NOT NULL,
				`class_name` varchar(200) NULL DEFAULT NULL,
				`method_name` varchar(100) NULL DEFAULT NULL,
                `message` text NOT NULL,
                `vars` text,
                PRIMARY KEY (`id`)
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
            </sql>
        </table>
		<table>
			<name>vtiger_advancedreports_intervals</name>
			<sql>
				<![CDATA[CREATE TABLE IF NOT EXISTS vtiger_advancedreports_intervals (
				`id` int(11) NOT NULL AUTO_INCREMENT,
				`object_id` varchar(36) NOT NULL,
				`object_type` varchar(15) NOT NULL,
				`interval_type` varchar(15) NOT NULL,
				`interval_options` varchar(15) NOT NULL,
				`interval_hours` varchar(2) NOT NULL,
				`interval_minutes` varchar(2) NOT NULL,
				`nexttime` datetime NOT NULL,
				`created` datetime NOT NULL,
				`modified` datetime NOT NULL,
				PRIMARY KEY (`id`)
			) ENGINE=InnoDB DEFAULT CHARSET=utf8;]]>
			</sql>
		</table>
    </tables>
</module>
