<?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/csv/generic-csv.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');

    $nql = new Officity_Shell();

    $nql_command = '
        <SEARCH refresh="daily">
            <FIELD>
                <INFO>
                    <MODULE operator="=">contact</MODULE>
                    <DENOMINATION operator="=">ID</DENOMINATION>
                </INFO>
                <INFO>
                    <MODULE operator="=">contact</MODULE>
                    <DENOMINATION operator="=">FIRSTNAME</DENOMINATION>
                </INFO>
                <INFO>
                    <MODULE operator="=">contact</MODULE>
                    <DENOMINATION operator="=">LASTNAME</DENOMINATION>
                </INFO>
                <INFO>
                    <MODULE operator="=">contact</MODULE>
                    <DENOMINATION operator="=">EMAIL1</DENOMINATION>
                </INFO>
                <INFO>
                    <MODULE operator="=" />
                    <DENOMINATION>DENOMINATION</DENOMINATION>
                </INFO>
                <INFO>
                    <MODULE operator="=" />
                    <DENOMINATION>ADDRESS</DENOMINATION>
                </INFO>
                <INFO>
                    <MODULE operator="=" />
                    <DENOMINATION>POSTALCODE</DENOMINATION>
                </INFO>
                <INFO>
                    <MODULE operator="=" />
                    <DENOMINATION>CITY</DENOMINATION>
                </INFO>
                <INFO>
                    <MODULE operator="=" />
                    <DENOMINATION>COUNTRYID</DENOMINATION>
                </INFO>
            </FIELD>
            <RETURN>
                <INFO>
                    <MODULE />
                    <DENOMINATION />
                    <TYPE />
                    <LISTNAME />
                    <TARGETMODULE />
                    <TARGETFIELD />
                    <DISPLAY />
                </INFO>
                <DESCRIPTION>
                    <TITLE />
                    <SUMMARY />
                </DESCRIPTION>
            </RETURN>
        </SEARCH>
        <GET refresh="monthly">
            <ENUM>
                <START>1</START>
                <END>20</END>
            </ENUM>
        </GET>
        <RESULTS static="true" name="data">
            <CONTACT depth="1" ID="2">
                <INFO>
                    <ID>2</ID>
                    <FIRSTNAME>François</FIRSTNAME>
                    <LASTNAME>Dispaux</LASTNAME>
                    <EMAIL1>francois@nectil.com</EMAIL1>
                </INFO>
                <DEPENDENCIES>
                    <DEPENDENCY type="contactWork" module="contact" hits="1">
                        <CONTACT depth="2" ID="1969">
                            <INFO>
                                <DENOMINATION>Nectil</DENOMINATION>
                                <ADDRESS>Rue Charles Demeer, 21A</ADDRESS>
                                <POSTALCODE>1000</POSTALCODE>
                                <CITY>Bruxelles</CITY>
                                <COUNTRYID>bel</COUNTRYID>
                            </INFO>
                            <DEPINFO />
                            <COMMENT />
                        </CONTACT>
                    </DEPENDENCY>
                </DEPENDENCIES>
            </CONTACT>
            <CONTACT depth="1" ID="1857">
                <INFO>
                    <ID>1857</ID>
                    <FIRSTNAME>Boris</FIRSTNAME>
                    <LASTNAME>Verdeyen</LASTNAME>
                    <EMAIL1>boris@nectil.com</EMAIL1>
                </INFO>
                <DEPENDENCIES>
                    <DEPENDENCY type="contactWork" module="contact" hits="1">
                        <CONTACT depth="2" ID="1969">
                            <INFO>
                                <DENOMINATION>Nectil</DENOMINATION>
                                <ADDRESS>Rue Charles Demeer, 21A</ADDRESS>
                                <POSTALCODE>1000</POSTALCODE>
                                <CITY>Bruxelles</CITY>
                                <COUNTRYID>bel</COUNTRYID>
                            </INFO>
                            <DEPINFO />
                            <COMMENT />
                        </CONTACT>
                    </DEPENDENCY>
                </DEPENDENCIES>
            </CONTACT>
            <CONTACT depth="1" ID="4558">
                <INFO>
                    <ID>4558</ID>
                    <FIRSTNAME>Marc</FIRSTNAME>
                    <LASTNAME>Mignonsin</LASTNAME>
                    <EMAIL1>marc@nectil.com</EMAIL1>
                </INFO>
                <DEPENDENCIES>
                    <DEPENDENCY type="contactWork" module="contact" hits="1">
                        <CONTACT depth="2" ID="1969">
                            <INFO>
                                <DENOMINATION>Nectil</DENOMINATION>
                                <ADDRESS>Rue Charles Demeer, 21A</ADDRESS>
                                <POSTALCODE>1000</POSTALCODE>
                                <CITY>Bruxelles</CITY>
                                <COUNTRYID>bel</COUNTRYID>
                            </INFO>
                            <DEPINFO />
                            <COMMENT />
                        </CONTACT>
                    </DEPENDENCY>
                </DEPENDENCIES>
            </CONTACT>
            <CONTACT depth="1" ID="4591">
                <INFO>
                    <ID>4591</ID>
                    <FIRSTNAME>Jonathan</FIRSTNAME>
                    <LASTNAME>Sanchez</LASTNAME>
                    <EMAIL1>jonathan@nectil.com</EMAIL1>
                </INFO>
                <DEPENDENCIES>
                    <DEPENDENCY type="contactWork" module="contact" hits="1">
                        <CONTACT depth="2" ID="1969">
                            <INFO>
                                <DENOMINATION>Nectil</DENOMINATION>
                                <ADDRESS>Rue Charles Demeer, 21A</ADDRESS>
                                <POSTALCODE>1000</POSTALCODE>
                                <CITY>Bruxelles</CITY>
                                <COUNTRYID>bel</COUNTRYID>
                            </INFO>
                            <DEPINFO />
                            <COMMENT />
                        </CONTACT>
                    </DEPENDENCY>
                </DEPENDENCIES>
            </CONTACT>
            <CONTACT depth="1" ID="4867">
                <INFO>
                    <ID>4867</ID>
                    <FIRSTNAME>Julien</FIRSTNAME>
                    <LASTNAME>Gonzalez</LASTNAME>
                    <EMAIL1>julien@nectil.com</EMAIL1>
                </INFO>
                <DEPENDENCIES>
                    <DEPENDENCY type="contactWork" module="contact" hits="1">
                        <CONTACT depth="2" ID="1969">
                            <INFO>
                                <DENOMINATION>Nectil</DENOMINATION>
                                <ADDRESS>Rue Charles Demeer, 21A</ADDRESS>
                                <POSTALCODE>1000</POSTALCODE>
                                <CITY>Bruxelles</CITY>
                                <COUNTRYID>bel</COUNTRYID>
                            </INFO>
                            <DEPINFO />
                            <COMMENT />
                        </CONTACT>
                    </DEPENDENCY>
                </DEPENDENCIES>
            </CONTACT>
        </RESULTS>
        <RESULTS static="true" name="search-filter">
            <INFO>
                <ACTIVITY>1</ACTIVITY>
                <USAGE>user</USAGE>
                <DEFAULT>1</DEFAULT>
                <MODULE>contact</MODULE>
                <DENOMINATION>Your last search filter</DENOMINATION>
                <ISQUERY>1</ISQUERY>
                <QUERYXML>
                    <CONTACT>
                        <INFO>
                            <SEARCHTEXT operator="MATCH" />
                        </INFO>
                        <DEPENDENCIES>
                            <DEPENDENCY type="contactWork">
                                <CONTACT>
                                    <INFO>
                                        <DENOMINATION operator="contains">nectil</DENOMINATION>
                                    </INFO>
                                </CONTACT>
                            </DEPENDENCY>
                        </DEPENDENCIES>
                    </CONTACT>
                </QUERYXML>
                <ISDISPLAY>1</ISDISPLAY>
                <DISPLAYXML>
                    <RETURN>
                        <INFO>
                            <ID order="1" />
                            <FIRSTNAME order="2" />
                            <LASTNAME order="3" />
                            <EMAIL1 order="4" />
                        </INFO>
                        <DEPENDENCIES>
                            <DEPENDENCY type="contactWork" max="1">
                                <INFO>
                                    <DENOMINATION order="5" />
                                    <ADDRESS order="6" />
                                    <POSTALCODE order="7" />
                                    <CITY order="8" />
                                    <COUNTRYID order="9" />
                                </INFO>
                            </DEPENDENCY>
                        </DEPENDENCIES>
                    </RETURN>
                    <SORT select="INFO/ID" order="ascending" />
                    <PAGINATE display="250" page="1" />
                </DISPLAYXML>
                <SEARCH>1</SEARCH>
                <COUNT>0</COUNT>
                <ISLOCKED>0</ISLOCKED>
                <CREATORID>0</CREATORID>
                <OWNERID>4558</OWNERID>
                <GROUPID>0</GROUPID>
                <MODIFIERID>4558</MODIFIERID>
                <CREATIONDATE>2009-12-14 15:35:56</CREATIONDATE>
                <MODIFICATIONDATE>2010-03-01 15:52:30</MODIFICATIONDATE>
            </INFO>
        </RESULTS>
        <RESULTS name="csv-config" static="true">
            <SEPCHAR>;</SEPCHAR>
        </RESULTS>
    ';

    $nql->addCommand($nql_command);

    echo $nql->transform(dirname(__FILE__).'/generic-csv-export.xsl');
?>