<?php
/*
Officity - Web application platform - Version 6.0 - 2011-07-05

François Dispaux, Boris Verdeyen, Thomas Hermant,
Jérémie Roy, Grégory Meurice, Abdelila Harbi, 
Marc Mignonsin, Jonathan Sanchez, Julien Gonzalez, Pierre Fouchez

Sushee and Officity is © Copyright 2011 Nectil SA.

`/var/www/installer/public_html/officity-source/apps/system/tools/report/pdf/reporting.php` is part of Officity.

Sushee is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Officity and Sushee are distributed in the hope that they will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Sushee. If not, see <http://www.gnu.org/licenses/>.
*/
    require_once(dirname(__FILE__).'/../include.php');

    $_GET['template'] = 2;

    /* *** */

    $nql = new Officity_Shell();

    $nql->addCommand('
        <GET name="user">
					<CONTACT ID="visitor" />
					<RETURN>
						<INFO>
							<FIRSTNAME/><LASTNAME/><EMAIL1/><DENOMINATION/>
						</INFO>
					</RETURN>
				</GET>

				<GET name="original-template">
					<OFFICITY:REPORT ID="8" />
					<RETURN>
                        <DESCRIPTIONS/>
					</RETURN>
				</GET>

				<RESULTS name="template" static="true"><INFO><ID>8</ID><ACTIVITY>1</ACTIVITY><MODULE>officity:task</MODULE><MODEL>1</MODEL><APPLY>search</APPLY><FIXED>0</FIXED><TYPE>pdf</TYPE><QUERYXML/><DISPLAYXML><RETURN><INFO><TYPE order="1"/><TITLE order="2"/><STATUS order="3"/><STARTDATE order="4"/><DUEDATE order="5"/><COMPLETED order="6"/><ROOT order="7"/></INFO></RETURN><SORT select="INFO/TYPE" order="descending"/><PAGINATE display="250" page="1"/></DISPLAYXML><TEMPLATE/><FILE/><ISLOCKED>0</ISLOCKED><CREATORID>2</CREATORID><OWNERID>2</OWNERID><GROUPID>0</GROUPID><MODIFIERID>2</MODIFIERID><CREATIONDATE>0000-00-00 00:00:00</CREATIONDATE><MODIFICATIONDATE>0000-00-00 00:00:00</MODIFICATIONDATE><TITLE>Basic Report</TITLE><DATE>2010-03-05</DATE><HEADER/><FOOTER/><FONTSIZE>100</FONTSIZE><FORMAT>A4</FORMAT><ORIENTATION>portrait</ORIENTATION></INFO><DESCRIPTIONS/><CATEGORIES/><DEPENDENCIES/></RESULTS><RESULTS name="search-config" static="true">
    <MODULE>officity:task</MODULE>
    <MODULEDESC>Tasks</MODULEDESC>
    <DEFAULTFIELD>STATUS</DEFAULTFIELD>
    <DEFAULTOPERATOR>=</DEFAULTOPERATOR>
    <DEFAULTOPERANDS></DEFAULTOPERANDS>
    <DEPENDENCIES>
        <DEPENDENCY order="0">
            <TYPE>officity:contexts</TYPE>
            <MODULE>officity:context</MODULE>
            <MODULEDESC>Contexts</MODULEDESC>
            <DESC>Is within a context which...</DESC>
            <DEFAULTFIELD>SEARCHTEXT</DEFAULTFIELD>
            <DEFAULTOPERATOR>MATCH</DEFAULTOPERATOR>
            <DEFAULTOPERANDS></DEFAULTOPERANDS>
        </DEPENDENCY>
        <DEPENDENCY order="1">
            <TYPE>officity:childtasks</TYPE>
            <MODULE>officity:task</MODULE>
            <MODULEDESC>Child tasks</MODULEDESC>
            <DESC>Has a child task which...</DESC>
            <DEFAULTFIELD>STATUS</DEFAULTFIELD>
            <DEFAULTOPERATOR>=</DEFAULTOPERATOR>
            <DEFAULTOPERANDS></DEFAULTOPERANDS>
        </DEPENDENCY>
        <DEPENDENCY order="2">
            <TYPE>officity:parenttasks</TYPE>
            <MODULE>officity:task</MODULE>
            <MODULEDESC>Parent tasks</MODULEDESC>
            <DESC>Has a parent task which...</DESC>
            <DEFAULTFIELD>STATUS</DEFAULTFIELD>
            <DEFAULTOPERATOR>=</DEFAULTOPERATOR>
            <DEFAULTOPERANDS></DEFAULTOPERANDS>
        </DEPENDENCY>
    </DEPENDENCIES>
</RESULTS>
				<RESULTS name="search-filter" static="true"><INFO><ACTIVITY>1</ACTIVITY><USAGE>user</USAGE><DEFAULT>1</DEFAULT><MODULE>officity:task</MODULE><DENOMINATION>Your last search filter</DENOMINATION><ISQUERY>1</ISQUERY><QUERYXML><OFFICITY:TASK><INFO><SEARCHTEXT operator="MATCH"/></INFO></OFFICITY:TASK></QUERYXML><ISDISPLAY>1</ISDISPLAY><DISPLAYXML><RETURN><INFO><ID order="1"/><TYPE order="2"/><TITLE order="3"/><STATUS order="4"/><STARTDATE order="5"/><DUEDATE order="6"/><COMPLETED order="7"/><ROOT order="8"/></INFO></RETURN><SORT select="INFO/TYPE" order="descending"/><PAGINATE display="250" page="1"/></DISPLAYXML><SEARCH>1</SEARCH><COUNT>0</COUNT><ISLOCKED>0</ISLOCKED><CREATORID>4558</CREATORID><OWNERID>4558</OWNERID><GROUPID>0</GROUPID><MODIFIERID>4558</MODIFIERID><CREATIONDATE>2010-02-03 12:19:19</CREATIONDATE><MODIFICATIONDATE>2010-03-05 12:01:16</MODIFICATIONDATE></INFO><DESCRIPTIONS/><CATEGORIES/><DEPENDENCIES/></RESULTS><GET refresh="daily" name="TaskTypes"><LIST name="TaskTypes"/></GET><GET  refresh="daily" name="TaskStatus"><LIST name="TaskStatus"/></GET><SEARCH refresh="daily"><FIELD><INFO><MODULE operator="=">officity:task</MODULE><DENOMINATION operator="=">ID</DENOMINATION></INFO><INFO><MODULE operator="=">officity:task</MODULE><DENOMINATION operator="=">TYPE</DENOMINATION></INFO><INFO><MODULE operator="=">officity:task</MODULE><DENOMINATION operator="=">TITLE</DENOMINATION></INFO><INFO><MODULE operator="=">officity:task</MODULE><DENOMINATION operator="=">STATUS</DENOMINATION></INFO><INFO><MODULE operator="=">officity:task</MODULE><DENOMINATION operator="=">STARTDATE</DENOMINATION></INFO><INFO><MODULE operator="=">officity:task</MODULE><DENOMINATION operator="=">DUEDATE</DENOMINATION></INFO><INFO><MODULE operator="=">officity:task</MODULE><DENOMINATION operator="=">COMPLETED</DENOMINATION></INFO><INFO><MODULE operator="=">officity:task</MODULE><DENOMINATION operator="=">ROOT</DENOMINATION></INFO></FIELD><RETURN><INFO><MODULE/><DENOMINATION/><TYPE/><LISTNAME/><TARGETMODULE/><TARGETFIELD /><DISPLAYLENGTH/></INFO><DESCRIPTION><TITLE/><SUMMARY/></DESCRIPTION></RETURN></SEARCH>
				<GET refresh="monthly">
					<ENUM>
						<START>1</START>
						<END>20</END>
					</ENUM>
				</GET>
			<SEARCH name="data"><OFFICITY:TASK><INFO><SEARCHTEXT operator="MATCH"/></INFO></OFFICITY:TASK><RETURN><INFO><ID order="1"/><TYPE order="2"/><TITLE order="3"/><STATUS order="4"/><STARTDATE order="5"/><DUEDATE order="6"/><COMPLETED order="7"/><ROOT order="8"/></INFO></RETURN><SORT select="INFO/TYPE" order="descending"/><PAGINATE display="2500" page="1"/></SEARCH>
    ');

    $out = $_GET['output'];    
    $template = SYSTEM_TOOLS_PATH.'report/pdf/reporting.xsl';
    //$template = SYSTEM_TOOLS_PATH.'report/pdf/stickers_avery.xsl';

    if ($out == 'xml')
    {
        $nql->outputXML();
    }
    else if ($out == 'fo')
    {
        xml_out($nql->transform($template));
    }
    else if ($out == 'path')
    {
        echo $nql->transformToPDF($template, false);
    }
    else
    {
        $nql->transformToPDF($template, true);
    }
?>