<?php
define('RENDER_MODE', 'catalyz');

$node = $page->getNode();

use_helper('Form');

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

ob_start();
use_helper('I18N');

$allLanguages = sfConfig::get('app_translations_available_languages');
$default = sfConfig::get('app_translations_default_language');
// $existing_languages = $node->getAvailableTranslations();
$allLanguages = Catalyz::getAllTranslations();
unset($allLanguages[$default]);
// $perms = array();
// $available_languages = array();
// foreach($allLanguages as $iso => $name) {
// if (!isset($existing_languages[$iso])) {
// $available_languages[$iso] = ucfirst($name);
// }
// $perms[$iso]['edit'] = true;
// $perms[$iso]['delete'] = ($iso != $default);
// }
// include_partial('catalyz/header');

?>

<div class="content-add01">
	<div class="heading01"><h1>Mon compte</h1></div>

<?php echo form_tag('@katao_profile_update') ?>
  <table>
    <tfoot>
      <tr>
        <td colspan="2">
          <?php echo $form['id'] ?>
          <br /><input type="submit" value="Sauver" />
				  <?php //echo 'ou '.link_to('annuler', $sf_request->getReferer()) ?>
        </td>
      </tr>
    </tfoot>
    <tbody>
      <?php echo $form->renderGlobalErrors() ?>
	  <tr valign="top">
	  	<td colspan="2" align="left"><u>Informations personnelles</u></td>
	  </tr>
	  <tr valign="top">
        <th align="left"><?php echo $form['first_name']->renderLabel() ?></th>
        <td>
          <?php echo $form['first_name'] ?>
		  <?php echo $form['first_name']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['last_name']->renderLabel() ?></th>
        <td>
          <?php echo $form['last_name'] ?>
		  <?php echo $form['last_name']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['user_email']->renderLabel() ?></th>
        <td>
          <?php echo $form['user_email'] ?>
		  <?php echo $form['user_email']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['user_phone']->renderLabel() ?></th>
        <td>
          <?php echo $form['user_phone'] ?>
		  <?php echo $form['user_phone']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['user_fax']->renderLabel() ?></th>
        <td>
          <?php echo $form['user_fax'] ?>
		  <?php echo $form['user_fax']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['card_number_sol']->renderLabel() ?></th>
        <td>
          <?php echo $form['card_number_sol'] ?>
		  <?php echo $form['card_number_sol']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['is_anonymous']->renderLabel() ?></th>
        <td>
          <?php echo $form['is_anonymous'] ?>
		  <?php echo $form['is_anonymous']->renderError() ?>
        </td>
      </tr>
	  <tr valign="top">
	  	<td colspan="2" align="left"><br /><u>Adresse</u></td>
	  </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['user_address1']->renderLabel() ?></th>
        <td>
          <?php echo $form['user_address1'] ?>
		  <?php echo $form['user_address1']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['user_address2']->renderLabel() ?></th>
        <td>
          <?php echo $form['user_address2'] ?>
		  <?php echo $form['user_address2']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['user_zip']->renderLabel() ?></th>
        <td>
          <?php echo $form['user_zip'] ?>
		  <?php echo $form['user_zip']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['user_city']->renderLabel() ?></th>
        <td>
          <?php echo $form['user_city'] ?>
		  <?php echo $form['user_city']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <td colspan="2">
          <?php echo $form['update_gmap'] ?>
          <?php echo $form['update_gmap']->renderLabel() ?>
          <br />ou <a href="<?php echo url_for(('@katao_profile_gmap')) ?>">modifier ma position manuellement sur la carte</a>
		  <?php echo $form['update_gmap']->renderError() ?>
        </td>
      </tr>
	  <tr valign="top">
	  	<td colspan="2" align="left"><br /><u>Accès application</u></td>
	  </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['user_login']->renderLabel() ?></th>
        <td>
          <?php echo $form['user_login'] ?>
		  <?php echo $form['user_login']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['user_password']->renderLabel() ?></th>
        <td>
          <?php echo $form['user_password'] ?>
		  <?php echo $form['user_password']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['user_password_confirmation']->renderLabel() ?></th>
        <td>
          <?php echo $form['user_password_confirmation'] ?>
		  <?php echo $form['user_password_confirmation']->renderError() ?>
        </td>
      </tr>
    </tbody>
  </table>
</form>

<?php if (0 < count($history_euro)): ?>
<br />
<div class="heading01"><h1>Historique de mes transactions en €</h1></div>
<table class="profile-list">
<tr>
	<th nowrap="nowrap" width="1%">Date</th>
	<th>Nature</th>
	<th nowrap="nowrap" width="1%">Montant</th>
	<th nowrap="nowrap" width="1%">Solde</th>
</tr>
<?php $is_firt = true ?>
<?php foreach ($history_euro as $history): ?>
<tr valign="top">
	<td nowrap="nowrap" width="1%"><?php echo CatalyzDate::formatShort($history['date']) ?></td>
	<td><?php echo $history['summary'] ?></td>
	<td nowrap="nowrap" width="1%" style="text-align: right!important"><?php echo ('initial' != $history['type'])?Utils::formatCurrencyEuro($history['amount']):'' ?></td>
	<td nowrap="nowrap" width="1%" style="text-align: right!important"<?php echo $is_firt?' class="bold"':'' ?>><?php echo Utils::formatCurrencyEuro($history['account']) ?></td>
</tr>
	<?php $is_firt = false ?>
<?php endforeach ?>
</table>
<?php endif ?>

<?php if (0 < count($history_sol)): ?>
<br />
<div class="heading01"><h1>Historique de mes transactions en <?php echo wpConfig::getAdditionalCurrencyName() ?></h1></div>
<table class="profile-list">
<tr>
	<th nowrap="nowrap" width="1%">Date</th>
	<th>Nature</th>
	<th nowrap="nowrap" width="1%">Montant</th>
	<th nowrap="nowrap" width="1%">Solde</th>
</tr>
<?php $is_firt = true ?>
<?php foreach ($history_sol as $history): ?>
<tr valign="top">
	<td nowrap="nowrap" width="1%"><?php echo CatalyzDate::formatShort($history['date']) ?></td>
	<td><?php echo $history['summary'] ?></td>
	<td nowrap="nowrap" width="1%" style="text-align: right!important"><?php echo ('initial' != $history['type'])?Utils::formatCurrencySol($history['amount']):'' ?></td>
	<td nowrap="nowrap" width="1%" style="text-align: right!important"<?php echo $is_firt?' class="bold"':'' ?>><?php echo Utils::formatCurrencySol($history['account']) ?></td>
</tr>
	<?php $is_firt = false ?>
<?php endforeach ?>
</table>
<?php endif ?>

</div>

<?php

    $content = ob_get_contents();

ob_end_clean();
// $layout = LayoutManager::instance()->getCatalyzTemplate($ContentTreeNode->getCurrentLayoutNameForAction());
$properties['layout_family'] = 'katao';
$properties['layout_name'] = 'layoutv2';
$properties['content'] = $content;

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

?>