<?php

define('RENDER_MODE', 'catalyz');

$node = $page->getNode();

use_helper('Form');

$properties = array();
$properties['page'] = $page;
$properties['node'] = $node;
$properties['ContentTree'] = $ContentTree;

use_javascript('catalyz/jquery-1.3.2.min.js', 'last');

ob_start();

?>
<div id="transfer_holder">
<h1>Faire un virement</h1>

<?php
$current_amount = sfContext::getInstance()->getUser()->getAttribute('katao_user_instance')->getKataoMember()->getCurrentAmountSol();
if ($current_amount > 0):
 ?>

<?php use_helper('Validation') ?>
<table>
<?php echo form_tag('@sol_violette_transfer', array('class'=>'solViolette')) ?>

<tr valign="top">
<th align="left"><?php echo $form['search']->renderLabel() ?></th>
</tr>
<tr valign="top">
        <td>
          <?php echo $form['search'] ?>
		  		<?php echo $form['search']->renderError() ?>
        </td>
      </tr>
</table>

<input type="submit" class="submit" value="Rechercher" id="form_submit" name="form_submit"/>
</form>

<?php
if (is_array($results)) {
	if (count($results) > 0) {
		printf('<p>Plusieurs adhérents correspondent à votre recherche:</p><ul>');

		foreach ($results as /*(KataoMember)*/ $result){
			printf('<li><a class="listen" id="element_%1$s" href="javascript://">%2$s %3$s</a>
<div class="listen_element" id="listen_element_%1$s">',
				$result->getId(),
				$result->getFirstName(),
				$result->getLastName()
				);

			echo '<table cellpadding="0" cellspacing="0" border="0">';
				printf('<tr><th width="150">%s</th><td>%s</td></tr>', 'Nom', $result->getLastName());
				printf('<tr><th width="150">%s</th><td>%s</td></tr>', 'Prénom', $result->getFirstName());
				printf('<tr><th width="150">%s</th><td>%s</td></tr>', 'Téléphone', $result->getFirstKataoUser()->getPhone());
				printf('<tr><th width="150">%s</th><td>%s</td></tr>', 'Carte', $result->getCardNumberSol());
			echo '</table>';

			printf('<a href="%s">Faire un virement à %s</a>', url_for('@sol_violette_transfer_step_1?id='.$result->getId()), $result->getFullName());

			echo '</div></li>';
		}

		echo '</ul>';
	}else{
		printf('<p>%s</p>', __('Aucun résultat ne correspond à votre recherche.'));
	}
} ?>



<?php else: ?>
<?php printf('<p>Vous ne possedez pas assez de Sols pour réaliser de virement.</p>') ?>
<?php endif ?>
</div>


<script type="text/javascript">
/* <![CDATA[ */

	$(document).ready(function () {
	  $(".listen").live("click", function(){
		  $(".listen").removeClass('open');
			$(this).addClass('open');
			var id = $(this).attr('id');
		  $(".listen_element").hide();
		  $(this).parents('li').too
		  $("#listen_"+id).show();
		});
	});

/* ]]> */
</script>


	<?php

	$content = ob_get_contents();

ob_end_clean();
$properties['layout_family'] = 'katao';
$properties['layout_name'] = 'layoutv2';
$properties['content'] = $content;

include_component($properties['layout_family'], $properties['layout_name'], $properties);

?>