<?php
global $myUser;
if(!$myUser->connected()) throw new Exception("Vous devez être connecté pour accéder à cette fonctionnalité",401);
if(!$myUser->can('hackpoint','read')) throw new Exception("Vous n'avez pas la permission pour executer cette fonctionnalité",403);
require_once(__DIR__.SLASH.'Part.class.php');
?>

<div class="row">
    
    <div class="col-md-8">
        <select id="filters" data-type="filter" data-label="Recherche" data-function="hackpoint_part_search">
            <option value="label"   data-filter-type="text">Libellé</option>
        </select>
    </div>
    
	<div class="col-md-4">
		<?php if($myUser->can('hackpoint', 'edit')) : ?>
		<a href="index.php?module=hackpoint&page=sheet.part" class="btn btn-success right"><i class="fas fa-plus"></i> Ajouter</a>
		<?php endif; ?>
	</div>
</div>
<br/>
<div class="row">
	<!-- search results -->
	<div class="col-xl-12">
		<table id="parts" class="table table-striped " data-entity-search="hackpoint_part_search">
            <thead>
                <tr>
                    <th>#</th>
                    <th data-sortable="label">Libellé</th>
                    <th data-sortable="price">Prix moyen</th>
                    <th data-sortable="link">Lien</th>
                    <th data-sortable="brand">Marque</th>
                    <th></th>
                </tr>
            </thead>
            
            <tbody>
                <tr data-id="{{id}}" class="hidden">
	                <td>{{id}}</td>
	                <td>{{label}}</td>
	                <td>{{price}}</td>
	                <td>{{link}}</td>
	                <td>{{brand}}</td>
	                <td>
	                    <div class="btn-group btn-group-sm" role="group">
                            
                            <a class="btn btn-info" href="index.php?module=hackpoint&page=sheet.part&id={{id}}"><i class="fas fa-pencil-alt"></i></a>
                            
                            
                            <div class="btn btn-danger " onclick="hackpoint_part_delete(this);"><i class="far fa-trash-alt"></i></div>
	                    </div>
	                </td>
                </tr>
           </tbody>
        </table>

         <!-- Pagination -->
       
        <ul class="pagination">
            <li class="page-item hidden" data-value="{{value}}" title="Voir la page {{label}}" onclick="$(this).parent().find('li').removeClass('active');$(this).addClass('active');hackpoint_part_search();">
                <a class="page-link" href="#">{{label}}</a>
            </li>
        </ul>

	</div>
</div>
