<?php 
    defined('_JEXEC') or die('Restricted access');
    ARTIOFusionChartsHelper::importMultiSeriesJS();
?>
<fieldset class="adminform">
    <legend><?php echo JText::_('Chart Data'); ?></legend>
    <div style="width: 1024px; overflow-x:scroll;">
    <div id="chartToolbar">
    	<a href="javascript:MultiSeries.addCategory()" class="addCat"><?php echo JText::_('Add Category')?></a>
    	<a href="javascript:MultiSeries.removeCategories()" class="removeCat"><?php echo JText::_('Remove Categories')?></a>
    	<a href="javascript:MultiSeries.addDataset()" class="addDat"><?php echo JText::_('Add Dataset')?></a>
    	<a href="javascript:MultiSeries.removeDatasets()" class="removeDat"><?php echo JText::_('Remove Datasets')?></a>
    	<div class="cleaner"></div>
    </div>
    <table class="admintable">
    	<tbody id="chart-data">
    		<tr>
    			<td></td>
    			<td class="chart" colspan="<?php echo count($this->chart->categories); ?>" style="text-align: center;">
    				<strong><?php echo JText::_('Categories'); ?></strong>
    				<img src="<?php echo ARTIOFUSIONCHARTS_SET_IMAGE; ?>" class="setImage"  onclick="MultiSeries.setParams('categories-params','maskCategories')" alt="<?php echo JText::_('Config'); ?>"/>
    				<input type="hidden" id="categories-params" name="categoryParams" value="<?php echo $this->chart->categoryParams; ?>"/>
    			</td>
    		</tr>
    		<tr id="categories">
    			<td></td>
    			<td id="category-cont-0" style="display: none"></td>
    			<?php foreach ($this->chart->categories as $i=>$category) { ?>
    				<?php JFilterOutput::objectHTMLSafe($category, ENT_QUOTES); ?>
    			    <?php $categoryId = $i + 1; ?>							
    				<td id="category-cont-<?php echo $categoryId; ?>" class="chart">
    					<input type="checkbox" id="category-checkbox-<?php echo $categoryId; ?>" name="category-checkbox-<?php echo $categoryId; ?>" value="<?php echo $categoryId; ?>" class="checkbox"/>
    					<input type="text" id="category-<?php echo $categoryId; ?>" name="chart-category[]" value="<?php echo $category->value; ?>" size="15"/>
    					<img src="<?php echo ARTIOFUSIONCHARTS_SET_IMAGE; ?>" class="setImage"  onclick="MultiSeries.setParams('category-<?php echo $categoryId; ?>-params','maskCategory')" alt="<?php echo JText::_('Config'); ?>"/>
    					<input type="hidden" id="category-<?php echo $categoryId; ?>-params" name="chart-category-params[]" value="<?php echo $category->params; ?>"/>
    				</td>		
    			<?php } ?>			
    		</tr>
    		<tr id="dataset-0" style="display: none"></tr>
    		<?php foreach ($this->chart->datasets as $i=>$dataset) { ?>
    			<?php JFilterOutput::objectHTMLSafe($dataset, ENT_QUOTES); ?>
    			<?php $dataSetId = $i+1; ?>
    			<tr id="dataset-<?php echo $dataSetId; ?>">
    				<td class="chart">
    					<input type="checkbox" id="dataset-checkbox-<?php echo $dataSetId; ?>" name="dataset-checkbox-<?php echo $dataSetId; ?>" value="<?php echo $dataSetId; ?>" class="checkbox"/>
    					<input type="text" id="dataset-name-<?php echo $dataSetId; ?>" name="dataset[<?php echo $dataSetId; ?>]" value="<?php echo $dataset->value; ?>" size="15"/>
    					<img src="<?php echo ARTIOFUSIONCHARTS_SET_IMAGE; ?>" class="setImage"  onclick="MultiSeries.setParams('dataset-<?php echo $dataSetId; ?>-params','maskDataset')" alt="<?php echo JText::_('Config'); ?>"/>
    					<input type="hidden" id="dataset-<?php echo $dataSetId; ?>-params" name="dataset-params[<?php echo $dataSetId; ?>]" value="<?php echo $dataset->params; ?>"/>
    				</td>
    				<td id="dataset-<?php echo $i+1; ?>-value-0" style="display: none"></td>
    				<?php foreach ($dataset->sets as $j=>$set) { ?>
    				    <?php JFilterOutput::objectHTMLSafe($set, ENT_QUOTES); ?>
    					<?php $setId = $j+1; ?>
    					<td id="dataset-<?php echo $dataSetId; ?>-value-<?php echo $setId; ?>" class="chart">
    						<input type="text" id="dataset-<?php echo $dataSetId; ?>-name-<?php echo $setId; ?>" name="dataset-<?php echo $dataSetId; ?>-values[]" value="<?php echo $set->value; ?>" size="15"/>
    						<img src="<?php echo ARTIOFUSIONCHARTS_SET_IMAGE; ?>" class="setImage"  onclick="MultiSeries.setParams('dataset-<?php echo $dataSetId; ?>-value-<?php echo $setId; ?>-params','maskSet')" alt="<?php echo JText::_('Config'); ?>"/>
    						<input type="hidden" id="dataset-<?php echo $dataSetId; ?>-value-<?php echo $setId; ?>-params" name="dataset-<?php echo $dataSetId; ?>-value-params[]" value="<?php echo $set->params; ?>"/>
    					</td>
    				<?php } ?>	
    			</tr>
    		<?php } ?>
    	</tbody>	
    </table>
    <?php if(!$this->chart->id && (int) $this->config->get('sample_data_mc', 1)) { ?>
    	<p class="sampleDataInfo"><?php echo JText::_('The chart was rendered by sample data'); ?></p>
    <?php } ?>
    </div>
</fieldset>

<?php
    ARTIOFusionChartsHelper::exportParamsInJs($this->chart->paramsCategoriesSource,'maskCategories');
    ARTIOFusionChartsHelper::exportParamsInJs($this->chart->paramsCategorySource,'maskCategory');
    ARTIOFusionChartsHelper::exportParamsInJs($this->chart->paramsDatasetSource,'maskDataset');
    ARTIOFusionChartsHelper::exportParamsInJs($this->chart->paramsSetSource,'maskSet');
?>


