Add schema.sql to create database, add php files and templates for index, entries, exits and search.

This commit is contained in:
JBthePenguin 2021-06-02 15:17:34 +02:00
parent 16f10215e9
commit 4448a9bde1
21 changed files with 147 additions and 56 deletions

View File

@ -4,7 +4,7 @@ Cette extension permet de gérer les matériels de l'association: stock, entrée
## Installation ## Installation
- Télécharger le fichier materiels.tar.gz et l'ajouter dans le répertoire garradin/plugins. - Télécharger le fichier [materiels.tar.gz](https://gitlab.com/JBthePenguin/garradin-plugin-materiels/-/raw/main/materiels.tar.gz) et l'ajouter dans le répertoire garradin/plugins.
- Installer le plugin via le menu "Configuration > Extensions" de Garradin. - Installer le plugin via le menu "Configuration > Extensions" de Garradin.
## Utilisation - Fonctionnalités ## Utilisation - Fonctionnalités

Binary file not shown.

View File

@ -0,0 +1,5 @@
<?php
namespace Garradin;
$db->import(__DIR__ . '/schema.sql');

57
src/schema.sql Normal file
View File

@ -0,0 +1,57 @@
CREATE TABLE IF NOT EXISTS plugin_materiels_category (
id integer NOT NULL PRIMARY KEY autoincrement,
name varchar(100) NOT NULL,
CONSTRAINT u_category_name UNIQUE ( name )
);
CREATE TABLE IF NOT EXISTS plugin_materiels_location (
id integer NOT NULL PRIMARY KEY autoincrement,
name varchar(100) NOT NULL,
CONSTRAINT u_location_name UNIQUE ( name )
);
CREATE TABLE IF NOT EXISTS plugin_materiels_equipment (
id integer NOT NULL PRIMARY KEY autoincrement,
category_id integer NOT NULL,
designation varchar(255) NOT NULL,
localisation_id integer NOT NULL,
current_value decimal NOT NULL DEFAULT 0,
number_of_materiels integer NOT NULL DEFAULT 1,
CONSTRAINT u_equipment_designation UNIQUE ( designation ),
FOREIGN KEY ( category_id ) REFERENCES plugin_materiels_category( id ) ON DELETE RESTRICT ON UPDATE CASCADE,
FOREIGN KEY ( localisation_id ) REFERENCES plugin_materiels_location( id ) ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS plugin_materiels_entry (
id integer NOT NULL PRIMARY KEY autoincrement,
kind varchar(20) NOT NULL,
equipment_id integer NOT NULL,
date_of_entry date NOT NULL,
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_equipment( id ) ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS plugin_materiels_temporary_entry (
id integer NOT NULL PRIMARY KEY autoincrement,
kind varchar(20) NOT NULL,
equipment_id integer NOT NULL,
start_date date NOT NULL,
end_date date,
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_equipment( id ) ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS plugin_materiels_output (
id integer NOT NULL PRIMARY KEY autoincrement,
kind varchar(20) NOT NULL,
equipment_id integer NOT NULL,
output_date date NOT NULL,
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_entry( equipment_id ) ON DELETE RESTRICT ON UPDATE CASCADE
);
CREATE TABLE IF NOT EXISTS plugin_materiels_temporary_output (
id integer NOT NULL PRIMARY KEY autoincrement,
kind varchar(20) NOT NULL,
equipment_id integer NOT NULL,
start_date date NOT NULL,
end_date date,
FOREIGN KEY ( equipment_id ) REFERENCES plugin_materiels_entry( equipment_id ) ON DELETE RESTRICT ON UPDATE CASCADE
);

10
src/templates/_nav.tpl Normal file
View File

@ -0,0 +1,10 @@
<nav class="tabs">
<ul>
<li class="{if $current == 'index'}current{/if}"><a href="{plugin_url}">Matériels en stock</a></li>
<li class="{if $current == 'entrees_definitives'}current{/if}"><a href="{plugin_url file="entrees_definitives.php"}"><b>Entrées définitives</b></a></li>
<li class="{if $current == 'entrees_provisoires'}current{/if}"><a href="{plugin_url file="entrees_provisoires.php"}">Entrées provisoires</a></li>
<li class="{if $current == 'sorties_definitives'}current{/if}"><a href="{plugin_url file="sorties_definitives.php"}">Sorties définitives</a></li>
<li class="{if $current == 'sorties_provisoires'}current{/if}"><a href="{plugin_url file="sorties_provisoires.php"}">Sorties provisoires</a></li>
<li class="{if $current == 'recherche'}current{/if}"><a href="{plugin_url file="recherche.php"}">Recherche</a></li>
</ul>
</nav>

View File

@ -1,20 +0,0 @@
{include file="admin/_head.tpl" title="Configuration — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
{form_errors}
<form method="post" action="{$self_url}">
<fieldset>
<legend>Configuration</legend>
<dl>
{input type="checkbox" name="display_hello" value="1" default=$plugin.config label="Afficher un message de coucou"}
</dl>
</fieldset>
<p class="submit">
{csrf_field key="config_plugin_%s"|args:$plugin.id}
{button type="submit" class="main" name="save" label="Enregistrer" shape="right"}
</p>
</form>
{include file="admin/_foot.tpl"}

View File

@ -0,0 +1,5 @@
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
{include file="%s_nav.tpl"|args:$plugin_tpl current="entrees_definitives"}
{include file="admin/_foot.tpl"}

View File

@ -0,0 +1,5 @@
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
{include file="%s_nav.tpl"|args:$plugin_tpl current="entrees_provisoires"}
{include file="admin/_foot.tpl"}

View File

@ -1,12 +1,5 @@
{include file="admin/_head.tpl" title="Extension — %s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id} {include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
<p class="alert block">Gestion du materiel de l'association</p>
{if $plugin.config.display_hello}
<h3>L'affichage du message de bienvenue est activé</h3>
{else}
<h3>L'affichage du message de bienvenue est désactivé&nbsp;!</h3>
{/if}
{include file="%s_nav.tpl"|args:$plugin_tpl current="index"}
{include file="admin/_foot.tpl"} {include file="admin/_foot.tpl"}

View File

@ -0,0 +1,5 @@
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
{include file="%s_nav.tpl"|args:$plugin_tpl current="recherche"}
{include file="admin/_foot.tpl"}

View File

@ -0,0 +1,5 @@
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
{include file="%s_nav.tpl"|args:$plugin_tpl current="sorties_definitives"}
{include file="admin/_foot.tpl"}

View File

@ -0,0 +1,5 @@
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
{include file="%s_nav.tpl"|args:$plugin_tpl current="sorties_provisoires"}
{include file="admin/_foot.tpl"}

0
src/upgrade.php Normal file
View File

5
src/www/admin/_inc.php Normal file
View File

@ -0,0 +1,5 @@
<?php
namespace Garradin;
$tpl->assign('plugin_tpl', PLUGIN_ROOT . '/templates/');

View File

@ -1,26 +0,0 @@
<?php
namespace Garradin;
$session->requireAccess($session::SECTION_CONFIG, $session::ACCESS_ADMIN);
if (f('save'))
{
$form->check('config_plugin_' . $plugin->id(), [
'display_hello' => 'boolean',
]);
if (!$form->hasErrors())
{
try {
$plugin->setConfig('display_hello', (bool) f('display_hello'));
utils::redirect(utils::plugin_url());
}
catch (UserException $e)
{
$form->addError($e->getMessage());
}
}
}
$tpl->display(PLUGIN_ROOT . '/templates/config.tpl');

View File

@ -0,0 +1,7 @@
<?php
namespace Garradin;
require_once __DIR__ . '/_inc.php';
$tpl->display(PLUGIN_ROOT . '/templates/entrees_definitives.tpl');

View File

@ -0,0 +1,7 @@
<?php
namespace Garradin;
require_once __DIR__ . '/_inc.php';
$tpl->display(PLUGIN_ROOT . '/templates/entrees_provisoires.tpl');

View File

@ -2,4 +2,11 @@
namespace Garradin; namespace Garradin;
if ($plugin->needUpgrade())
{
$plugin->upgrade();
}
require_once __DIR__ . '/_inc.php';
$tpl->display(PLUGIN_ROOT . '/templates/index.tpl'); $tpl->display(PLUGIN_ROOT . '/templates/index.tpl');

View File

@ -0,0 +1,7 @@
<?php
namespace Garradin;
require_once __DIR__ . '/_inc.php';
$tpl->display(PLUGIN_ROOT . '/templates/recherche.tpl');

View File

@ -0,0 +1,7 @@
<?php
namespace Garradin;
require_once __DIR__ . '/_inc.php';
$tpl->display(PLUGIN_ROOT . '/templates/sorties_definitives.tpl');

View File

@ -0,0 +1,7 @@
<?php
namespace Garradin;
require_once __DIR__ . '/_inc.php';
$tpl->display(PLUGIN_ROOT . '/templates/sorties_provisoires.tpl');