<?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">
	<?php $categories = array() ?>
<?php foreach(KataoProductCategoryPeer::getAll() as $katao_product_category_id => $katao_product_category): ?>
	<?php $categories[$katao_product_category_id] = $katao_product_category['name'] ?>
<?php endforeach ?>

	<?php $suppliers = array() ?>
	<?php $suppliers_order_min_amount = array() ?>
<?php foreach(KataoSupplierPeer::getAllJoinCart() as $katao_supplier_id => $katao_supplier): ?>
	<?php $suppliers[$katao_supplier_id] = $katao_supplier['name'] ?>
	<?php $suppliers_order_min_amount[$katao_supplier_id] = $katao_supplier['order_min_amount'] ?>
<?php endforeach ?>

	<?php echo form_tag('@katao_ajustements') ?>
		<br />Rayon : <?php echo select_tag('category_id', options_for_select($categories, $default_category_id, array('include_custom' => '&mdash;&nbsp;tous&nbsp;&mdash;'))) ?>
		<br /><br />Fournisseur : <?php echo select_tag('supplier_id', options_for_select($suppliers, $default_supplier_id, array('include_custom' => '&mdash;&nbsp;tous&nbsp;&mdash;'))) ?>
	<?php if ($default_supplier_id && !empty($suppliers_order_min_amount[$default_supplier_id])): ?>
		<?php $total_order_supplier = KataoCartPeer::sumForSupplier($default_supplier_id) ?>
		<br /><?php echo image_tag(($total_order_supplier < $suppliers_order_min_amount[$default_supplier_id])?'actions/bullet_red.png':'actions/bullet_green.png', array('align' => 'top', 'title' => '')) ?>Total commandes adhérents : <b><?php echo Utils::formatCurrencyEuro($total_order_supplier) ?></b> / Minimum fournisseur : <b><?php echo Utils::formatCurrencyEuro($suppliers_order_min_amount[$default_supplier_id]) ?></b>
	<?php endif ?>
		<br /><br /><?php echo submit_tag('Voir les produits') ?>
	</form>

	<br><br /><div class="heading01"><h1>Produits dont le colisage est incomplet </h1></div>
<?php if ($default_category_id || $default_supplier_id): ?>
	<?php include_partial('katao/products', array('pager' => KataoProductPeer::getPagerForAll($default_category_id, $default_supplier_id), 'url' => '', 'katao_product_category' => '', 'katao_product_family' => '')) ?>
<?php else: ?>
	<p><i>Merci de sélectionner un rayon et/ou un fournisseur ci-dessus.</i></p>
<?php endif ?>
</div>

<?php

    $content = ob_get_contents();

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

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

?>