<?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">
        <ul  id="parts" data-entity-search="hackpoint_part_search">
                        <li data-id="{{id}}" data-part="{{part}}" class="hidden">
                            <div class="part">
                                <input type="text" data-type="part" data-force="false" placeholder="Nom du composant" value="{{label}}" class="form-control label">
                                <div class="part-image" data-label="Image" style="height:220px;background : url(data:{{picture}}) 0% 0% / cover" data-stream="{{picture}}"></div>
                                <input class="hidden" type="file">
                                
                                <div class="price w-100 mt-2">
                                    <div class="input-group">
                                     <div class="input-group-prepend">
                                        <span class="input-group-text">Prix</span>
                                      </div>
                                      <input class="form-control" type="text" value="{{price}}">
                                      <div class="input-group-append">
                                        <span class="input-group-text">€</span>
                                      </div>
                                    </div>
                                </div>

                                <div class="brand w-100 mt-2 mb-3">
                                    <div class="input-group">
                                     <div class="input-group-prepend">
                                        <span class="input-group-text">Marque</span>
                                      </div>
                                      <input class="form-control" type="text" value="{{brand}}"/>
                                    </div>
                                </div>
                              
                               
                              
                                 <a onclick="hackpoint_part_find(this)" title="Chercher sur le net" class="link"><i class="fas fa-globe-americas pointer"></i></a>
                                 <div class="btn btn-delete" onclick="hackpoint_part_delete(this);"><i class="far fa-trash-alt"></i></div>
                                 <div class="clear"></div>
                                 <div class="btn btn-dark w-100 mb-3 btn-save-part" onclick="hackpoint_part_save(this)"><i class="far fa-check-circle"></i>Valider</div>
                             </div>
                        </li>
                    </ul>
		

         <!-- 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>
