<?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">
          <br /><input type="submit" value="Sauver" /> ou <?php echo 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['name']->renderLabel() ?></th>
        <td>
          <?php echo $form['name'] ?>
		  <?php echo $form['name']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['email']->renderLabel() ?></th>
        <td>
          <?php echo $form['email'] ?>
		  <?php echo $form['email']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['phone']->renderLabel() ?></th>
        <td>
          <?php echo $form['phone'] ?>
		  <?php echo $form['phone']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['fax']->renderLabel() ?></th>
        <td>
          <?php echo $form['fax'] ?>
		  <?php echo $form['fax']->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['address1']->renderLabel() ?></th>
        <td>
          <?php echo $form['address1'] ?>
		  <?php echo $form['address1']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['address2']->renderLabel() ?></th>
        <td>
          <?php echo $form['address2'] ?>
		  <?php echo $form['address2']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['zip']->renderLabel() ?> / <?php echo $form['city']->renderLabel() ?></th>
        <td>
          <?php echo $form['zip'] ?>
          <?php echo $form['city'] ?>
		  <?php echo $form['zip']->renderError() ?>
		  <?php echo $form['city']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['website']->renderLabel() ?></th>
        <td>
          <?php echo $form['website'] ?>
		  <?php echo $form['website']->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>Informations complémentaires</u></td>
	  </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['siret_number']->renderLabel() ?></th>
        <td>
          <?php echo $form['siret_number'] ?>
		  <?php echo $form['siret_number']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
        <th align="left"><?php echo $form['order_min_amount']->renderLabel() ?></th>
        <td>
          <?php echo $form['order_min_amount'] ?>
		  <?php echo $form['order_min_amount']->renderError() ?>
        </td>
      </tr>
      <tr valign="top">
	  	<td colspan="2" align="left"><br /><u>Présentation</u></td>
	  </tr>
	  <tr valign="top">
        <td colspan="2">
          <?php echo $form['presentation'] ?>
		  <?php echo $form['presentation']->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_order)): ?>
<br />
<div class="heading01"><h1>Historique de mes commandes</h1></div>
<table class="profile-list">
<tr>
	<th nowrap="nowrap" width="1%">Date</th>
	<th nowrap="nowrap" width="1%">N°</th>
	<th nowrap="nowrap" width="1%">Montant</th>
	<th>Période</th>
	<th>Noeud</th>
</tr>
<?php foreach ($history_order as $id => $order): ?>
<tr valign="top">
	<td nowrap="nowrap" width="1%"><?php echo CatalyzDate::formatShort($order['date']) ?></td>
	<td nowrap="nowrap" width="1%"><?php echo link_to($order['number'], '@katao_supplier_order?id=' . $id, array('title' => 'Télécharger la commande en PDF')) ?></td>
	<td nowrap="nowrap" width="1%"><?php echo Utils::formatCurrencyEuro($order['amount_euro']) ?> dont <?php echo Utils::formatCurrencySol($order['amount_sol']) ?></td>
	<td><?php echo $order['period'] ?></td>
	<td><?php echo $order['node'] ?></td>
</tr>
<?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);

?>