File: /var/www/vhosts/creativefellows.nl/okaycolor.creativefellows.nl/views/admin/products.php
<?php
/*
* Header & Sidebar
*/
require_once __DIR__ . '/inc/header.inc.php';
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.new",["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 small-12">';
/*
* View
*/
if($active_item !== null)
{
//d($active_item);
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();
}
echo '<input type="hidden" name="_METHOD" value="PATCH"/>';
echo '<button type="submit" class="button hollow primary">Opslaan</button>';
echo '<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 '<a href="'. $router->pathFor("admin.product.duplicate",["id" => $active_item->getId() ]) .'" class="button duplicate align-right"><i class="fal fa-copy"></i></a>';
echo '</form>';
}
/*
* List items
*/
else
{
echo '<ul class="vertical menu">';
foreach($data["items"] as $item)
{
echo '<li><a href="'. $router->pathFor("admin.section.view",["section" => $data["current"], "id" => $item->getId() ]) .'">'. $item->getName() .'</a></li>';
}
echo '</ul>';
}
echo '</div>';
echo '</div>';
/*
* Show pagination if exists
*/
require_once __DIR__ . '/inc/pagination.inc.php';
echo '</div>';
echo '</div>';
echo '</div>';
// End of content
/*
* Footer
*/
require_once __DIR__ . '/inc/footer.inc.php';
//d( $active_item );
//echo count($data["items"]);
?>