	<?php
    require_once(dirname(__FILE__).'/include.php');  
    require_once(dirname(__FILE__).'/WIP.element.class.php');     
        
    $nql = new Officity_Shell();
    
    try
    {  
    	$xml_node = new XML('<COMMAND><CONTACT /></COMMAND>');
    	$t = new ElementNode($xml_node->getElement('/'));
	   	$t->ren('COMMAND', 'SEARCH');
    	var_dump($t->toString()); echo '<br />'; echo '<br />';
    	
    	$c = $xml_node->getElement('/SEARCH/CONTACT');
    	$n = new ElementNode($c);
    	
    	$n->add('@ID', 3)->add('INFO')->add('DEPENDENCIES');
    	
    	$n->get('./INFO')->add(array(
    		'@creator_info' => 'true',
    		'@modifier_info' => 'true'
    	))->add('DENOMINATION', 'My company')->add('COUNTRYID', 'bel')->add(array(
    		'POSTALCODE' => '1000',
    		'CITY' => 'Brussels',
    		'ADDRESS' => ''
    	));
    	
    	$n->get('./DEPENDENCIES')->addXML('<DEPENDENCY type="contactWork"><CONTACT ID="123" /><CONTACT ID="456" /></DEPENDENCY>');

    	//
    	var_dump($n->toString()); echo '<br />'; echo '<br />';
    	$infos = $n->get('./INFO/*');
    	foreach ($infos as $i)
    	{    		
    		var_dump($i->toString()); echo '<br />';
    	}
    	echo '<br />';
    	var_dump($n->get('./DEPENDENCIES/DEPENDENCY')->val('CONTACT/@ID')); echo '<br />'; echo '<br />';
    	var_dump($n->exists('DEPENDENCIES/DEPENDENCY/@operator')); echo '<br />';
    	var_dump($n->exists('DEPENDENCIES/DEPENDENCY/CONTACT')); echo '<br />'; echo '<br />';
    	
    	$n->del('DEPENDENCIES');
		$n->get('./INFO')->del('@modifier_info')->add('@profile', 'tiny')->add('CONTACTTYPE', 'PM');
		
		//
    	var_dump($n->toString()); echo '<br />'; echo '<br />';
    	var_dump($n->val('INFO/DENOMINATION')); echo '<br />';
    	var_dump($n->val('INFO/@profile')); echo '<br />'; echo '<br />';
    	    	
    	$n->ren('INFO', 'CUSTOMINFO');
    	$n->get('./CUSTOMINFO')->add('@profile', 'small')->del('@ID');
    	
    	//
    	var_dump($n->toString()); echo '<br />'; echo '<br />';
    	//
    	var_dump($t->toString()); echo '<br />'; echo '<br />';
    	var_dump($t->get('//CUSTOMINFO[@profile="small"]')->toString()); echo '<br />'; echo '<br />';
    	
    	$t->del('//CUSTOMINFO[@profile="small"]');
    	var_dump($t->toString()); echo '<br />'; echo '<br />';
    	    	    	
    	/*
	    $e = new Element($nql);
	    $contact->addInfo('email', 'a@b.com')->('configxml', '<test>1</test><debug>0</debug>');
		$contact->dependency('dffdf', $sfdsf)->info('denomination', '123');
		$contact->command('GET');
		$contact->command('KILL');
		$contact->get('/KILL/CONTACT/INFO[2]')->info(ee, dd)->info(ddd, sdqsk);
		$nql->addCommand($contact);	    
	    $e->log_NQL();*/
    }
    catch (OfficityException $e)
    {
    	$m = $e->getMessage().'<br /><br />';
    	$traces = $e->getTrace();
    	foreach ($traces as $trace)
    	{
    		foreach ($trace as $key => $value)
    		{
    			$m .= '<strong>'.$key.':</strong> '.var_export($value, true).'<br />';
    		}
    		$m .= '<br />';
    	}
    	$nql->displayErrorPanel($m, 'Application error!');
    }
    
    die();
    
    
    
    /* *** */

    /*$nql = new Officity_Shell();
    $e = new Element('CONTACT');
    $e->addSearchCommands('test.php', $nql);

    $_POST['search-field-0'] = 'ipa:member-info-SEARCHTEXT-text';
    $_POST['search-operator-0'] = 'MATCH';
    $_POST['search-operand1-0'] = 'Smith';

    $_POST['search-field-1'] = 'ipa:member-info-GENDER-list_Genders';
    $_POST['search-operator-1'] = '=';
    $_POST['search-operand1-1'] = 'M';

    $_POST['search-field-2'] = 'ipa:member-info-CITY-text';
    $_POST['search-operator-2'] = 'starts-with';
    $_POST['search-operand1-2'] = 'Liè';

    $_POST['search-field-5'] = 'dependency-ipa:memberOf-ipa:society-info-DENOMINATION-text';
    $_POST['search-operator-5'] = 'contains';
    $_POST['search-operand1-5'] = 'Institute';

    $_POST['search-field-6'] = 'dependency-ipa:memberOf-ipa:society-info-BIRTHDAY-date';
    $_POST['search-operator-6'] = 'between';
    $_POST['search-operand1-6'] = '01/07/2009';
    $_POST['search-operand2-6'] = '31/07/2009';

    $_POST['search-field-9'] = 'dependency-ipa:memberOf-ipa:society-info-ACTIVE-boolean';
    $_POST['search-operator-9'] = '=';
    $_POST['search-operand1-9'] = '1';

    $_POST['search-field-11'] = 'dependency-ipa:addresses-ipa:address-info-COUNTRYID-systemList_Countries';
    $_POST['search-operator-11'] = '=';
    $_POST['search-operand1-11'] = 'bel';

    $_POST['search-field-4'] = 'dependency-ipa:languages-ipa:language-info-LANGUAGEID-systemList_Languages';
    $_POST['search-operator-4'] = '=';
    $_POST['search-operand1-4'] = 'fre';

    $_POST['search-field-3'] = 'dependency-ipa:societyRole-ipa:role-info-POSITION-int';
    $_POST['search-operator-3'] = '=';
    $_POST['search-operand1-3'] = '170';

    $_POST['search-field-7'] = 'dependency-ipa:roleInSociety-ipa:society-info-SEARCHTEXT-text';
    $_POST['search-operator-7'] = 'contains';
    $_POST['search-operand1-7'] = 'apsa';

    $e->advancedSearchParsing($_POST);

    $_POST['columns'] = 'INFO/LASTNAME,INFO/POSTALCODE,INFO/CITY';
    $_POST['order'] = 'ascending';
    $_POST['sort'] = 'INFO/DENOMINATION';
    $_POST['display'] = '10';
    $_POST['page'] = '1';

    $columns = explode(',', $_POST['columns']);
    $e->setReturn($columns);
    
    $e->setSort($_POST['sort'], $_POST['order']);
    $e->setPaginate($_POST['display'], $_POST['page']);

    $e->search(false);
    
    $e->logCommand();*/
?>