File: /var/www/vhosts/creativefellows.nl/okaycolor.creativefellows.nl/views/admin/categories.php
<?php
/*
* Header
*/
require_once __DIR__ . '/inc/header.inc.php';
/*
* Sidebar
*/
require_once __DIR__ . '/inc/sidebar.inc.php';
/*
* Content
*/
echo '<div class="cell auto content">';
echo '<div class="grid-x">';
echo '<div class="cell small-12">';
echo '<h2>'. ucfirst($data["current"]) .'<a href="'. $router->pathFor("admin.section",["section" => $data["current"]]) .'" class="button primary align-right">Nieuw</a></h2>';
echo '<div class="grid-x grid-padding-x block-white">';
echo '<div class="cell ssmall-12 medium-3">';
echo '<ul class="vertical menu">';
foreach($data["items"] as $section)
{
if($section->type() == 2) continue;
echo '<li>';
echo '<a href="'. $router->pathFor("admin.section.view",["section" => $data["current"], "id" => $section->getId() ]) .'" class="'. $current .'">'. $section->getName() .'</a>';
echo '<ul class="menu vertical subitems">';
foreach( $section->getCategories() as $category )
{
$link = $router->pathFor("admin.section.view",["section" => $data["current"], "id" => $category->getId() ]);
echo '<li><a href="'. $link .'">'. $category->getName() .'</a></li>';
}
echo '</ul>';
echo '</li>';
}
echo '</ul>';
echo '</div>';
echo '<div class="cell small-12 medium-9">';
/*
* view selected
*/
if($active_item !== null)
{
echo '<form class="default-form" action="'. $router->pathFor("admin.section.patch",["section" => $data["current"], "id" => $active_item->getId() ]) .'" method="post" enctype="multipart/form-data">';
echo '<h3>'. $active_item->getName() .'</h3>';
foreach($data["fields"] as $field)
{
$value = $active_item->getValue( $field->getName() );
$field->setValue( $value );
echo $field->getInput();
}
// Product order
echo '<label for="position" class="input-name">Volgorde producten</label>';
echo '<ul class="no-bullet draggable list">';
foreach($active_item->getProducts() as $product){
echo '<li class="item" id="'. $product["product_id"] .'">';
echo ''. $product["name"] .'';
echo '<span class="handle-draggable float-right"><i class="fal fa-grip-lines"></i></span>';
echo '</li>';
}
echo '</ul>';
echo '<input type="hidden" name="element_order" id="element_order" value="" />';
echo '<input type="hidden" name="_METHOD" value="PATCH"/>';
echo '<button type="submit" class="button hollow primary">Opslaan</button> <a href="'. $router->pathFor("admin.section.delete",["section" => $data["current"], "id" => $active_item->getId() ]) .'" class="button delete align-right"><i class="fal fa-trash-alt"></i></a>';
echo '</form>';
// d($active_item->getProducts() );
}
/*
* New item
*/
else
{
echo '<form class="default-form" action="'. $router->pathFor("admin.section.post",["section" => $data["current"]]) .'" method="post" enctype="multipart/form-data">';
echo '<h3>Nieuw</h3>';
foreach($data["fields"] as $field)
{
echo $field->getInput();
}
echo '<button type="submit" class="button hollow primary">Toevoegen</button>';
echo '</form>';
}
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
echo '</div>';
// End of content
/*
* Footer
*/
require_once __DIR__ . '/inc/footer.inc.php';
?>