<?php

defined ( '_JEXEC' ) or die ( 'Restricted access' );
/*
 * @component Calc Builder 
 * @copyright Copyright (C) January 2017. 
 * @license GPL 3.0 
 * This program 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. 
 * This program is distributed in the hope that it 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. 
 * See <http://www.gnu.org/licenses/>. 
 * More info www.moonsoft.es 
 * gestion@moonsoft.es
 */
?>
<calculator> <utility>  
  	<?php foreach ($this->utility as $key=>$value){ ?>
  	<<?php echo $key;?>><![CDATA[<?php echo $value;?>]]></<?php echo $key;?>>
  	<?php } ?>  	
  </utility> <fields>
  	<?php foreach ($this->fields as $field){ ?>
  	<field>
  		<?php foreach ($field as $key=>$value){?>
	  	<<?php echo $key;?>><![CDATA[<?php echo $value;?>]]></<?php echo $key;?>>
	  	<?php } ?>	  	
		<multivalues>
			<?php
				
foreach ( $this->multivalues as $multivalue ) {
					if ($multivalue->idfield != $field->id)
						continue;
					?>
		  	<multivalue> <name><![CDATA[<?php echo $multivalue->name;?>]]></name>
<value><![CDATA[<?php echo $multivalue->value;?>]]></value> </multivalue>
		  	<?php } ?>
		</multivalues> </field>  	
  	<?php } ?>  	
  </fields> <matrices>
  	<?php foreach ($this->matrices as $matrix){ ?>
  	<matrix>
  		<?php foreach ($matrix as $key=>$value){?>
	  	<<?php echo $key;?>><![CDATA[<?php echo $value;?>]]></<?php echo $key;?>>
	  	<?php } ?>
  	</matrix>
  	<?php } ?>
  </matrices> <sections>
  	<?php foreach ($this->sections as $section){ ?>
  	<section>
  		<?php foreach ($section as $key=>$value){?>
	  	<<?php echo $key;?>><![CDATA[<?php echo $value;?>]]></<?php echo $key;?>>
	  	<?php } ?>
  		<section_field>
  		<?php
				$section_fields = explode ( ',', $section->fields );
				foreach ( $section_fields as $section_field ) {
					?>
  				<sf> <idfield><![CDATA[<?php echo $section_field;?>]]></idfield> </sf>		  	
	  	<?php } ?>
	  	</section_field>
</section>
  	<?php } ?>
  </sections>
  <?php if(isset($this->excel['excel'])):?>
  <excel>
  	<?php foreach ($this->excel['excel'] as $key=>$value):?>
  		<<?php echo $key;?>><![CDATA[<?php echo $value;?>]]></<?php echo $key;?>>
  	<?php endforeach;?>
  </excel>  
  <excelmapping>
  	<?php foreach ($this->excel['mapping'] as $mapping):?>
  		<mapping>
  		<?php foreach ($mapping as $key=>$value):?>
  			<<?php echo $key;?>><![CDATA[<?php echo $value;?>]]></<?php echo $key;?>>
  		<?php endforeach;?>
  		</mapping>
  	<?php endforeach;?>
  </excelmapping>
  <?php endif;?>
  </calculator>
