ok for movement, delete old entry and output
This commit is contained in:
parent
0b97418682
commit
27c9d653f7
BIN
materiels.tar.gz
BIN
materiels.tar.gz
Binary file not shown.
@ -1,91 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin\Plugin\Materiels;
|
||||
|
||||
use Garradin\DB;
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Plugin\Materiels\Output;
|
||||
|
||||
class Entry
|
||||
{
|
||||
public function listKinds()
|
||||
{
|
||||
return array(
|
||||
'Achat',
|
||||
'Don',
|
||||
'Récupération',
|
||||
'Location / Prêt',
|
||||
);
|
||||
}
|
||||
|
||||
public function add($data = [])
|
||||
{
|
||||
DB::getInstance()->insert('plugin_materiels_entry', $data);
|
||||
}
|
||||
|
||||
public function get($id)
|
||||
{
|
||||
return DB::getInstance()->first('SELECT * FROM plugin_materiels_entry WHERE id = ?;', $id);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
DB::getInstance()->delete('plugin_materiels_entry', 'id = ' . $id);
|
||||
}
|
||||
|
||||
public function listAll()
|
||||
{
|
||||
return DB::getInstance()->get('SELECT * FROM plugin_materiels_entry ORDER BY entry_date DESC;');
|
||||
}
|
||||
|
||||
public function listAllByEquipment($eqmt_id)
|
||||
{
|
||||
return DB::getInstance()->get('SELECT * FROM plugin_materiels_entry WHERE equipment_id = ? ORDER BY entry_date DESC;', $eqmt_id);
|
||||
}
|
||||
|
||||
public function PossibilityRentEqmtEntry($id, $eqmt_number, $date)
|
||||
{
|
||||
$after_entry_dates = DB::getInstance()->get(
|
||||
"SELECT entry_date FROM plugin_materiels_entry WHERE kind = 'Retour de location / prêt' AND equipment_id = '{$id}' AND entry_date > '{$date}';");
|
||||
$entry_dates = array($date);
|
||||
foreach ($after_entry_dates as $row)
|
||||
{
|
||||
array_push($entry_dates, $row->entry_date);
|
||||
}
|
||||
$eqmt = new Equipment;
|
||||
foreach ($entry_dates as $entry_date) {
|
||||
$out_of_stock_eqmt = $eqmt->CalculateOutOfStockByDate($id, $entry_date);
|
||||
if ($out_of_stock_eqmt - $eqmt_number < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function PossibilityDeleteEntry($entry)
|
||||
{
|
||||
$output = new Output;
|
||||
if ($entry->kind == 'Location / Prêt')
|
||||
{
|
||||
return $output->PossibilityNoOwnedEqmtOutput(
|
||||
$entry->equipment_id, $entry->equipment_number, $entry->entry_date);
|
||||
} else
|
||||
{
|
||||
return $output->PossibilityOwnedEqmtOutput(
|
||||
$entry->equipment_id, $entry->equipment_number, $entry->entry_date);
|
||||
}
|
||||
}
|
||||
|
||||
public function AllDatesByEquipment($eqmt_id)
|
||||
{
|
||||
$entry_dates = DB::getInstance()->get(
|
||||
'SELECT DISTINCT entry_date FROM plugin_materiels_entry WHERE equipment_id = ? ORDER BY entry_date DESC;', $eqmt_id);
|
||||
$entry_dates_array = array();
|
||||
foreach ($entry_dates as $row)
|
||||
{
|
||||
array_push($entry_dates_array, $row->entry_date);
|
||||
}
|
||||
return $entry_dates_array;
|
||||
}
|
||||
}
|
@ -223,14 +223,20 @@ class Equipment
|
||||
}
|
||||
|
||||
public function ListAllBorrowedByCategory()
|
||||
// return list of borrowed equipments ordered by category
|
||||
{
|
||||
// get the list of all equipments ordered by category
|
||||
$eqmts_by_cat = $this->listAllByCategory();
|
||||
// construct list of equipments borrowed for all categories
|
||||
$eqmts_borrowed_by_cat = array();
|
||||
foreach ($eqmts_by_cat as $cat => $eqmts) {
|
||||
// construct list of equipments borrowed for one category
|
||||
$eqmts_borrowed = array();
|
||||
foreach ($eqmts as $eqmt) {
|
||||
// for each equipment calculte number of borrowed
|
||||
$borrowed = $this->CalculateNoOwned($eqmt->id);
|
||||
if ($borrowed) {
|
||||
// add to the list if at least one is borrowed
|
||||
$eqmt->borrowed = $borrowed;
|
||||
array_push($eqmts_borrowed, $eqmt);
|
||||
}
|
||||
|
@ -1,106 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin\Plugin\Materiels;
|
||||
|
||||
use Garradin\DB;
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Plugin\Materiels\Entry;
|
||||
|
||||
class Output
|
||||
{
|
||||
public function listKinds()
|
||||
{
|
||||
return array(
|
||||
'Vente',
|
||||
'Don',
|
||||
'Besoin',
|
||||
'Autre (perte, vol, ...)',
|
||||
'Location / Prêt',
|
||||
);
|
||||
}
|
||||
|
||||
public function add($data = [])
|
||||
{
|
||||
DB::getInstance()->insert('plugin_materiels_output', $data);
|
||||
}
|
||||
|
||||
public function get($id)
|
||||
{
|
||||
return DB::getInstance()->first('SELECT * FROM plugin_materiels_output WHERE id = ?;', $id);
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
DB::getInstance()->delete('plugin_materiels_output', 'id = ' . $id);
|
||||
}
|
||||
|
||||
public function listAll()
|
||||
{
|
||||
return DB::getInstance()->get('SELECT * FROM plugin_materiels_output ORDER BY output_date DESC;');
|
||||
}
|
||||
|
||||
public function PossibilityOwnedEqmtOutput($id, $eqmt_number, $date)
|
||||
{
|
||||
$after_output_dates = DB::getInstance()->get(
|
||||
"SELECT output_date FROM plugin_materiels_output WHERE kind IN (
|
||||
'Vente', 'Don', 'Besoin', 'Autre (perte, vol, ...)',
|
||||
'Location / Prêt') AND equipment_id = '{$id}' AND output_date > '{$date}';");
|
||||
$output_dates = array($date);
|
||||
foreach ($after_output_dates as $row)
|
||||
{
|
||||
array_push($output_dates, $row->output_date);
|
||||
}
|
||||
$eqmt = new Equipment;
|
||||
foreach ($output_dates as $output_date) {
|
||||
$available_eqmt = $eqmt->CalculateAvailableByDate($id, $output_date);
|
||||
if ($available_eqmt - $eqmt_number < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function PossibilityNoOwnedEqmtOutput($id, $eqmt_number, $date)
|
||||
{
|
||||
$after_output_dates = DB::getInstance()->get(
|
||||
"SELECT output_date FROM plugin_materiels_output WHERE kind = 'Retour de location / prêt' AND equipment_id = '{$id}' AND output_date > '{$date}';");
|
||||
$output_dates = array($date);
|
||||
foreach ($after_output_dates as $row)
|
||||
{
|
||||
array_push($output_dates, $row->output_date);
|
||||
}
|
||||
$eqmt = new Equipment;
|
||||
foreach ($output_dates as $output_date) {
|
||||
$borrowed_eqmt = $eqmt->CalculateNoOwnedByDate($id, $output_date);
|
||||
if ($borrowed_eqmt - $eqmt_number < 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function PossibilityDeleteOutput($output)
|
||||
{
|
||||
$entry = new Entry;
|
||||
if ($output->kind == 'Location / Prêt')
|
||||
{
|
||||
return $entry->PossibilityRentEqmtEntry(
|
||||
$output->equipment_id, $output->equipment_number, $output->output_date);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function AllDatesByEquipment($eqmt_id)
|
||||
{
|
||||
$output_dates = DB::getInstance()->get(
|
||||
'SELECT DISTINCT output_date FROM plugin_materiels_output WHERE equipment_id = ? ORDER BY output_date DESC;', $eqmt_id);
|
||||
$output_dates_array = array();
|
||||
foreach ($output_dates as $row)
|
||||
{
|
||||
array_push($output_dates_array, $row->output_date);
|
||||
}
|
||||
return $output_dates_array;
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
<!-- title -->
|
||||
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
|
||||
<!-- -->
|
||||
<!-- nav bar -->
|
||||
<nav class="tabs">
|
||||
<ul>
|
||||
<li class="{if $current_nav == 'index'}current{/if}"><a href="{plugin_url}">Inventaire</a></li>
|
||||
<li class="{if $current_nav == 'categories'}current{/if}"><a href="{plugin_url file="categories/index.php"}">Catégories</a></li>
|
||||
<li class="{if $current_nav == 'entrees_old'}current{/if}"><a href="{plugin_url file="entrees/index.php"}">Entrées (old)</a></li>
|
||||
<li class="{if $current_nav == 'sorties_old'}current{/if}"><a href="{plugin_url file="sorties/index.php"}">Sorties (old)</a></li>
|
||||
<li class="{if $current_nav == 'entrees'}current{/if}"><a href="{plugin_url file="mouvements/entrees/index.php"}">Entrées</a></li>
|
||||
<li class="{if $current_nav == 'sorties'}current{/if}"><a href="{plugin_url file="mouvements/sorties/index.php"}">Sorties</a></li>
|
||||
</ul>
|
||||
|
@ -1,33 +0,0 @@
|
||||
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="entrees_old"}
|
||||
|
||||
<form method="post" action="{$self_url}">
|
||||
<fieldset>
|
||||
<legend>Ajouter une entrée d'un matériel {$legend_part}</legend>
|
||||
{form_errors}
|
||||
<dl>
|
||||
{if $tpl_materiel_name != 'retour'}
|
||||
<dt><label for="f_kind">Type</label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="kind" id="f_kind">
|
||||
{foreach from=$kinds item="kind"}
|
||||
<option value="{$kind}"{if $selected_kind == $kind} selected="selected"{/if}>{$kind}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
{/if}
|
||||
{input type="date" name="entry_date" default=$default_date label="Date d'entrée" required=true }
|
||||
{input type="number" name="equipment_number" label="Nombre" required=true step="1" min="1" default=$default_number}
|
||||
</dl>
|
||||
{include file="%sentrees/{$tpl_materiel_name}.tpl"|args:$plugin_tpl}
|
||||
<dl>
|
||||
{input type="textarea" name="additional_comment" label="Remarques" placeholder="ex: don reçu de la part de..." default=$default_comment maxlength="255" rows=4 cols=30}
|
||||
</dl>
|
||||
</fieldset>
|
||||
<p class="submit">
|
||||
{csrf_field key=$csrf_key}
|
||||
{button type="submit" name="save" label="Enregistrer" shape="right" class="main"}
|
||||
{linkbutton label="Annuler" shape="export" href=$cancel_link}
|
||||
</p>
|
||||
</form>
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
@ -1,37 +0,0 @@
|
||||
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="entrees_old"}
|
||||
|
||||
<fieldset>
|
||||
<legend>Ajouter une entrée pour du </legend>
|
||||
{linkbutton shape="plus" label="Matériel répertorié" href="repertorie.php"}
|
||||
{linkbutton shape="plus" label="Matériel non répertorié" href="non_repertorie.php"}
|
||||
{linkbutton shape="plus" label="Matériel en retour de location / prêt" href="retour.php"}
|
||||
</fieldset>
|
||||
|
||||
{if $entries}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<th><b>Date</b></th>
|
||||
<th><b>Type</b></th>
|
||||
<th><b>Nombre</b></th>
|
||||
<th><b>Matériel</b></th>
|
||||
<th><b>Remarques</b></th>
|
||||
<th></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$entries item="entry"}
|
||||
<tr>
|
||||
<td>{$entry.entry_date|date_format:'%d/%m/%y'}</td>
|
||||
<td>{$entry.kind}</td>
|
||||
<td>{$entry.equipment_number}</td>
|
||||
<td>{$entry.equipment}</td>
|
||||
<td>{$entry.additional_comment}</td>
|
||||
<td class="actions">
|
||||
{linkbutton shape="delete" label="Supprimer" href="supprimer_entree.php?id=%d"|args:$entry.id}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
@ -1,14 +0,0 @@
|
||||
<fieldset>
|
||||
<legend><h3>Matériel</h3></legend>
|
||||
<dl>
|
||||
<dt><label for="f_cat">Catégorie</label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="category_id" id="f_cat">
|
||||
{foreach from=$cats item="cat"}
|
||||
<option value="{$cat.id}"{if $selected_cat == $cat.id} selected="selected"{/if}>{$cat.name}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
{input type="text" name="designation" label="Désignation" required=true maxlength="255"}
|
||||
</dl>
|
||||
</fieldset>
|
@ -1,19 +0,0 @@
|
||||
<fieldset>
|
||||
<legend><h3>Matériel</h3></legend>
|
||||
<dl>
|
||||
<dt><label for="f_eqmt"></label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="equipment_id" id="f_eqmt">
|
||||
{foreach from=$eqmts_by_cat key='cat' item="eqmts"}
|
||||
{if $eqmts}
|
||||
<optgroup label="-- {$cat} --">
|
||||
{foreach from=$eqmts item="eqmt"}
|
||||
<option value="{$eqmt.id}">{$eqmt.designation}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
@ -1,19 +0,0 @@
|
||||
<fieldset>
|
||||
<legend><h3>Matériel</h3></legend>
|
||||
<dl>
|
||||
<dt><label for="f_eqmt"></label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="equipment_id" id="f_eqmt">
|
||||
{foreach from=$eqmts_by_cat key='cat' item="eqmts"}
|
||||
{if $eqmts}
|
||||
<optgroup label="-- {$cat} --">
|
||||
{foreach from=$eqmts item="eqmt"}
|
||||
<option value="{$eqmt.id}"{if ($selected_eqmt !== "") && ($selected_eqmt == $eqmt.id)} selected="selected"{/if}>{$eqmt.designation} - sortie: {$eqmt.released}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
@ -1,9 +0,0 @@
|
||||
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="entrees_old"}
|
||||
|
||||
{include file="%scommon/delete_form.tpl"|args:$plugin_tpl
|
||||
legend="Supprimer cette entrée de matériels ?"
|
||||
warning="Êtes-vous sûr de vouloir supprimer l'entrée de « %s » ?"|args:$entry_string
|
||||
alert="Attention, la suppression de cette entrée supprimera le matériel « %s » du répertoire s'il n'a pas d'autre entrée."|args:$eqmt_name
|
||||
}
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
@ -1,9 +1,10 @@
|
||||
<!-- nav bar -->
|
||||
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="index"}
|
||||
|
||||
<!-- -->
|
||||
<h2 style="text-align: center;">Matériel dont l'association est propriétaire</h2>
|
||||
|
||||
<br>
|
||||
|
||||
<!-- tables for equipments owned -->
|
||||
{foreach from=$eqmts_owned_by_cat key='cat' item="eqmts"}
|
||||
{if $eqmts}
|
||||
<table class="list">
|
||||
@ -36,7 +37,7 @@
|
||||
</table>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
<!-- -->
|
||||
<br>
|
||||
|
||||
<hr>
|
||||
@ -46,7 +47,7 @@
|
||||
<h2 style="text-align: center;">Matériel dont l'association n'est pas propriétaire (emprunté)</h2>
|
||||
|
||||
<br>
|
||||
|
||||
<!-- tables for equipments no owned -->
|
||||
{foreach from=$eqmts_no_owned_by_cat key='cat' item="eqmts"}
|
||||
{if $eqmts}
|
||||
<table class="list">
|
||||
@ -75,7 +76,7 @@
|
||||
</table>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
<!-- -->
|
||||
<br>
|
||||
|
||||
<hr>
|
||||
@ -85,7 +86,7 @@
|
||||
<h2 style="text-align: center;">Matériel dont l'association n'est plus en possession</h2>
|
||||
|
||||
<br>
|
||||
|
||||
<!-- tables for equipments just listed -->
|
||||
{foreach from=$eqmts_just_listed_by_cat key='cat' item="eqmts"}
|
||||
{if $eqmts}
|
||||
<table class="list">
|
||||
@ -112,5 +113,7 @@
|
||||
</table>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
<!-- -->
|
||||
<!-- footer -->
|
||||
{include file="admin/_foot.tpl"}
|
||||
<!-- -->
|
||||
|
@ -1,7 +1,7 @@
|
||||
{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="index"}
|
||||
|
||||
<!-- nav bar -->
|
||||
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="index"}
|
||||
<!-- -->
|
||||
<!-- edit form -->
|
||||
<form method="post" action="{$self_url}" data-focus="1">
|
||||
{form_errors}
|
||||
<fieldset>
|
||||
@ -15,7 +15,7 @@
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
{input type="text" name="designation" label="Désignation" required=true source=$eq maxlength="255"}
|
||||
{input type="text" name="designation" label="Désignation" required=true source=$eqmt_requested maxlength="255"}
|
||||
</dl>
|
||||
</fieldset>
|
||||
<p class="submit">
|
||||
@ -24,5 +24,7 @@
|
||||
{linkbutton label="Annuler" shape="export" href=$cancel_link}
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<!-- -->
|
||||
<!-- footer -->
|
||||
{include file="admin/_foot.tpl"}
|
||||
<!-- -->
|
||||
|
@ -1,33 +0,0 @@
|
||||
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="sorties_old"}
|
||||
|
||||
<form method="post" action="{$self_url}">
|
||||
<fieldset>
|
||||
<legend>Ajouter une sortie d'un matériel {$legend_part}</legend>
|
||||
{form_errors}
|
||||
<dl>
|
||||
{if $tpl_materiel_name != 'emprunte'}
|
||||
<dt><label for="f_kind">Type</label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="kind" id="f_kind">
|
||||
{foreach from=$kinds item="kind"}
|
||||
<option value="{$kind}"{if $selected_kind == $kind} selected="selected"{/if}>{$kind}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
{/if}
|
||||
{input type="date" name="output_date" default=$default_date label="Date de sortie" required=true }
|
||||
{input type="number" name="equipment_number" label="Nombre" required=true step="1" min="1" default="1"}
|
||||
</dl>
|
||||
{include file="%ssorties/{$tpl_materiel_name}.tpl"|args:$plugin_tpl}
|
||||
<dl>
|
||||
{input type="textarea" name="additional_comment" label="Remarques" placeholder="ex: don fait à..." default=$default_comment maxlength="255" rows=4 cols=30}
|
||||
</dl>
|
||||
</fieldset>
|
||||
<p class="submit">
|
||||
{csrf_field key=$csrf_key}
|
||||
{button type="submit" name="save" label="Enregistrer" shape="right" class="main"}
|
||||
{linkbutton label="Annuler" shape="export" href=$cancel_link}
|
||||
</p>
|
||||
</form>
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
@ -1,17 +0,0 @@
|
||||
<fieldset>
|
||||
<legend><h3>Matériel</h3></legend>
|
||||
<dl>
|
||||
<dt><label for="f_eqmt"></label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="equipment_id" id="f_eqmt">
|
||||
{foreach from=$eqmts_by_cat key='cat' item="eqmts"}
|
||||
<optgroup label="-- {$cat} --">
|
||||
{foreach from=$eqmts item="eqmt"}
|
||||
<option value="{$eqmt.id}"{if ($selected_eqmt !== "") && ($selected_eqmt == $eqmt.id)} selected="selected"{/if}>{$eqmt.designation} - emprunt: {$eqmt.borrowed}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
@ -1,36 +0,0 @@
|
||||
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="sorties_old"}
|
||||
|
||||
<fieldset>
|
||||
<legend>Ajouter une sortie pour du </legend>
|
||||
{linkbutton shape="plus" label="Matériel en stock disponible" href="stock_disponible.php"}
|
||||
{linkbutton shape="plus" label="Matériel emprunté" href="emprunte.php"}
|
||||
</fieldset>
|
||||
|
||||
{if $outputs}
|
||||
<table class="list">
|
||||
<thead>
|
||||
<th><b>Date</b></th>
|
||||
<th><b>Type</b></th>
|
||||
<th><b>Nombre</b></th>
|
||||
<th><b>Matériel</b></th>
|
||||
<th><b>Remarques</b></th>
|
||||
<th></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$outputs item="output"}
|
||||
<tr>
|
||||
<td>{$output.output_date|date_format:'%d/%m/%y'}</td>
|
||||
<td>{$output.kind}</td>
|
||||
<td>{$output.equipment_number}</td>
|
||||
<td>{$output.equipment}</td>
|
||||
<td>{$output.additional_comment}</td>
|
||||
<td class="actions">
|
||||
{linkbutton shape="delete" label="Supprimer" href="supprimer_sortie.php?id=%d"|args:$output.id}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
@ -1,17 +0,0 @@
|
||||
<fieldset>
|
||||
<legend><h3>Matériel</h3></legend>
|
||||
<dl>
|
||||
<dt><label for="f_eqmt"></label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="equipment_id" id="f_eqmt">
|
||||
{foreach from=$eqmts_by_cat key='cat' item="eqmts"}
|
||||
<optgroup label="-- {$cat} --">
|
||||
{foreach from=$eqmts item="eqmt"}
|
||||
<option value="{$eqmt.id}"{if ($selected_eqmt !== "") && ($selected_eqmt == $eqmt.id)} selected="selected"{/if}>{$eqmt.designation} - dispo: {$eqmt.available}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
@ -1,9 +0,0 @@
|
||||
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="sorties_old"}
|
||||
|
||||
{include file="%scommon/delete_form.tpl"|args:$plugin_tpl
|
||||
legend="Supprimer cette sortie de matériels ?"
|
||||
warning="Êtes-vous sûr de vouloir supprimer la sortie de « %s » ?"|args:$output_string
|
||||
alert=""
|
||||
}
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
// edit a specific category
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
@ -7,7 +9,6 @@ require_once __DIR__ . '/_inc.php';
|
||||
use Garradin\Utils;
|
||||
|
||||
// get the category requested
|
||||
|
||||
$cat_requested = $cat->get((int) qg('id'));
|
||||
|
||||
if (!$cat_requested) {
|
||||
@ -15,7 +16,6 @@ if (!$cat_requested) {
|
||||
}
|
||||
|
||||
// check if edit form is submitted
|
||||
|
||||
$csrf_key = 'edit_category_' . $cat_requested->id;
|
||||
|
||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
@ -42,8 +42,7 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'categories/index.php';
|
||||
|
||||
// send to template the category requested
|
||||
|
||||
// send all to template
|
||||
$tpl->assign(compact('cat_requested', 'csrf_key', 'cancel_link'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/categories/modifier_categorie.tpl');
|
||||
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Plugin\Materiels\Entry;
|
||||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$eqmt = new Equipment;
|
||||
$entry = new Entry;
|
||||
|
||||
$entries = $entry->listAll();
|
||||
|
||||
foreach ($entries as $key => $value) {
|
||||
$entry_eqmt = $eqmt->get($value->equipment_id);
|
||||
$entries[$key]->equipment = $entry_eqmt->designation;
|
||||
}
|
||||
|
||||
$tpl->assign(compact('entries'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/entrees/index.tpl');
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\Plugin\Materiels\Entry;
|
||||
use Garradin\Plugin\Materiels\Category;
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Utils;
|
||||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$entry = new Entry;
|
||||
|
||||
$kinds = $entry->listKinds();
|
||||
$selected_kind = $kinds[0];
|
||||
|
||||
$date = new \DateTime;
|
||||
$date->setTimestamp(time());
|
||||
$default_date = $date;
|
||||
|
||||
$default_number = "1";
|
||||
$default_comment = "";
|
||||
|
||||
$cat = new Category;
|
||||
$cats = $cat->listAll();
|
||||
$selected_cat = $cats[0]->id;
|
||||
|
||||
$csrf_key = 'add_entry';
|
||||
|
||||
if (f('save'))
|
||||
{
|
||||
$selected_kind = f('kind');
|
||||
$default_date = f('entry_date');
|
||||
$default_number = f('equipment_number');
|
||||
$selected_cat = f('category_id');
|
||||
$default_comment = f('additional_comment');
|
||||
|
||||
if ($form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
try
|
||||
{
|
||||
$eqmt = new Equipment;
|
||||
$eqmt_id = $eqmt->add([
|
||||
'category_id' => (int) f('category_id'),
|
||||
'designation' => ucfirst(strtolower(f('designation'))),
|
||||
]);
|
||||
$entry_date_format = date_create_from_format(
|
||||
"d/m/Y", f('entry_date'))->format("Y-m-d");
|
||||
$entry->add([
|
||||
'kind' => f('kind'),
|
||||
'equipment_number' => (int) f('equipment_number'),
|
||||
'equipment_id' => $eqmt_id,
|
||||
'entry_date' => $entry_date_format,
|
||||
'additional_comment' => f('additional_comment'),
|
||||
]);
|
||||
Utils::redirect(PLUGIN_URL . 'entrees/index.php');
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
if (strstr($e->getMessage(), 'UNIQUE constraint failed'))
|
||||
{
|
||||
$form->addError('Un matériel avec cette désignation est déjà répertorié.');
|
||||
} else
|
||||
{
|
||||
$form->addError($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'entrees/index.php';
|
||||
$legend_part = "non répertorié";
|
||||
$tpl_materiel_name = "non_repertorie";
|
||||
|
||||
|
||||
$tpl->assign(compact(
|
||||
'kinds', 'cats', 'selected_kind', 'default_date',
|
||||
'default_number', 'default_comment', 'selected_cat',
|
||||
'cancel_link', 'legend_part', 'tpl_materiel_name', 'csrf_key'
|
||||
));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/entrees/ajouter_entree.tpl');
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\Plugin\Materiels\Entry;
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Utils;
|
||||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$entry = new Entry;
|
||||
|
||||
$csrf_key = 'add_entry';
|
||||
|
||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$entry = new Entry;
|
||||
$entry_date_format = date_create_from_format(
|
||||
"d/m/Y", f('entry_date'))->format("Y-m-d");
|
||||
$entry->add([
|
||||
'kind' => f('kind'),
|
||||
'equipment_number' => (int) f('equipment_number'),
|
||||
'equipment_id' => f('equipment_id'),
|
||||
'entry_date' => $entry_date_format,
|
||||
'additional_comment' => f('additional_comment'),
|
||||
]);
|
||||
Utils::redirect(PLUGIN_URL . 'entrees/index.php');
|
||||
}
|
||||
|
||||
$eqmt = new Equipment;
|
||||
$eqmts_by_cat = $eqmt->listAllByCategory();
|
||||
|
||||
$kinds = $entry->listKinds();
|
||||
$selected_kind = $kinds[0];
|
||||
|
||||
$date = new \DateTime;
|
||||
$date->setTimestamp(time());
|
||||
$default_date = $date;
|
||||
|
||||
$default_number = "1";
|
||||
$default_comment = "";
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'entrees/index.php';
|
||||
$legend_part = "répertorié";
|
||||
$tpl_materiel_name = "repertorie";
|
||||
|
||||
|
||||
$tpl->assign(compact(
|
||||
'kinds', 'eqmts_by_cat', 'selected_kind', 'default_date',
|
||||
'default_number', 'default_comment', 'cancel_link',
|
||||
'legend_part', 'tpl_materiel_name', 'csrf_key'
|
||||
));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/entrees/ajouter_entree.tpl');
|
@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\Plugin\Materiels\Entry;
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Utils;
|
||||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$entry = new Entry;
|
||||
$eqmt = new Equipment;
|
||||
|
||||
$eqmts_by_cat = $eqmt->listAllReleasedRentByCategory();
|
||||
$selected_eqmt = "";
|
||||
|
||||
$date = new \DateTime;
|
||||
$date->setTimestamp(time());
|
||||
$default_date = $date;
|
||||
|
||||
$default_comment = "";
|
||||
|
||||
$csrf_key = 'add_entry';
|
||||
|
||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$eqmt_id = f('equipment_id');
|
||||
$eqmt_number = (int) f('equipment_number');
|
||||
$entry_date_format = date_create_from_format(
|
||||
"d/m/Y", f('entry_date'))->format("Y-m-d");
|
||||
if ($entry->PossibilityRentEqmtEntry($eqmt_id, $eqmt_number, $entry_date_format))
|
||||
{
|
||||
$entry->add([
|
||||
'kind' => 'Retour de location / prêt',
|
||||
'equipment_number' => $eqmt_number,
|
||||
'equipment_id' => $eqmt_id,
|
||||
'entry_date' => $entry_date_format,
|
||||
'additional_comment' => f('additional_comment'),
|
||||
]);
|
||||
Utils::redirect(PLUGIN_URL . 'entrees/index.php');
|
||||
} else
|
||||
{
|
||||
$entry_date = f('entry_date');
|
||||
$selected_eqmt = $eqmt_id;
|
||||
$default_date = $entry_date;
|
||||
$default_comment = f('additional_comment');
|
||||
|
||||
$equiment = $eqmt->get($eqmt_id);
|
||||
$form->addError(
|
||||
"Il est impossible de rentrer " . (string) $eqmt_number . " " . $equiment->designation . " à la date du " . (string) $entry_date . '.');
|
||||
}
|
||||
}
|
||||
|
||||
$default_number = "1";
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'entrees/index.php';
|
||||
$legend_part = "en retour de location / prêt";
|
||||
$tpl_materiel_name = "retour";
|
||||
|
||||
$tpl->assign(compact(
|
||||
'eqmts_by_cat', 'default_date', 'default_number',
|
||||
'default_comment', 'cancel_link', 'legend_part',
|
||||
'tpl_materiel_name', 'csrf_key', 'selected_eqmt',
|
||||
));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/entrees/ajouter_entree.tpl');
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
use Garradin\Plugin\Materiels\Entry;
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Utils;
|
||||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$entry = new Entry;
|
||||
|
||||
$e_to_delete = $entry->get((int) qg('id'));
|
||||
$eqmt = new Equipment;
|
||||
|
||||
if (!$e_to_delete)
|
||||
{
|
||||
throw new UserException("Cette entrée n'existe pas.");
|
||||
}
|
||||
|
||||
$csrf_key = 'delete_entry_' . $e_to_delete->id;
|
||||
|
||||
if (f('delete') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$entry->delete($e_to_delete->id);
|
||||
try
|
||||
{
|
||||
$eqmt->delete($e_to_delete->equipment_id);
|
||||
}
|
||||
catch (\RuntimeException $e){
|
||||
}
|
||||
Utils::redirect(PLUGIN_URL . 'entrees/index.php');
|
||||
}
|
||||
|
||||
$equipment = $eqmt->get($e_to_delete->equipment_id);
|
||||
|
||||
if ($entry->PossibilityDeleteEntry($e_to_delete))
|
||||
{
|
||||
$cancel_link = PLUGIN_URL . 'entrees/index.php';
|
||||
|
||||
$entry_string = (string) $e_to_delete->equipment_number . " " . $equipment->designation . " à la date du " . date_create_from_format(
|
||||
"Y-m-d", $e_to_delete->entry_date)->format("d/m/y");
|
||||
|
||||
$eqmt_name = $equipment->designation;
|
||||
|
||||
$tpl->assign(compact('entry_string', 'eqmt_name', 'csrf_key', 'cancel_link'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/entrees/supprimer_entree.tpl');
|
||||
|
||||
} else {
|
||||
throw new UserException(
|
||||
"Cette entrée ne peut pas être supprimée car ça rendrait impossible l'historique des entrées et sorties de « " . $equipment->designation . " ». --- plus de sorties que d'entrées ! ---");
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
// lists of all equiments owned, no owned and just listed
|
||||
// ordered by category for each one.
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
if ($plugin->needUpgrade())
|
||||
@ -7,16 +10,18 @@ if ($plugin->needUpgrade())
|
||||
$plugin->upgrade();
|
||||
}
|
||||
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
|
||||
$eqmt = new Equipment;
|
||||
|
||||
// get all lists
|
||||
list(
|
||||
$eqmts_owned_by_cat, $eqmts_no_owned_by_cat,
|
||||
$eqmts_just_listed_by_cat) = $eqmt->AllListsAllByCategory();
|
||||
|
||||
// send lists to template
|
||||
$tpl->assign(compact(
|
||||
'eqmts_owned_by_cat', 'eqmts_no_owned_by_cat',
|
||||
'eqmts_just_listed_by_cat'
|
||||
|
@ -1,31 +1,37 @@
|
||||
<?php
|
||||
|
||||
// edit a specific equipment
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Plugin\Materiels\Category;
|
||||
use Garradin\Utils;
|
||||
|
||||
require_once __DIR__ . '/_inc.php';
|
||||
|
||||
// get the equipment requested
|
||||
$eqmt = new Equipment;
|
||||
$eqmt_requested = $eqmt->get((int) qg('id'));
|
||||
|
||||
$eq = $eqmt->get((int) qg('id'));
|
||||
|
||||
if (!$eq) {
|
||||
if (!$eqmt_requested) {
|
||||
throw new UserException("Ce matériel n'existe pas.");
|
||||
}
|
||||
|
||||
// get all categories and set the selected one
|
||||
$cat = new Category;
|
||||
$cats = $cat->listAll();
|
||||
$selected_cat = $eq->category_id;
|
||||
$selected_cat = $eqmt_requested->category_id;
|
||||
|
||||
$csrf_key = 'edit_equipment_' . $eq->id;
|
||||
// check if edit form is submitted
|
||||
$csrf_key = 'edit_equipment_' . $eqmt_requested->id;
|
||||
|
||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
// try to edit equipment selected and if error catched add it in form
|
||||
try
|
||||
{
|
||||
$eqmt->edit($eq->id, [
|
||||
$eqmt->edit($eqmt_requested->id, [
|
||||
'category_id' => (int) f('category_id'),
|
||||
'designation' => ucfirst(strtolower(f('designation'))),
|
||||
]);
|
||||
@ -45,6 +51,7 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'index.php';
|
||||
|
||||
$tpl->assign(compact('eq', 'cats', 'selected_cat', 'csrf_key', 'cancel_link'));
|
||||
// send all to template
|
||||
$tpl->assign(compact('eqmt_requested', 'cats', 'selected_cat', 'csrf_key', 'cancel_link'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/modifier_materiel.tpl');
|
||||
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\Plugin\Materiels\Output;
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Utils;
|
||||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$output = new Output;
|
||||
$eqmt = new Equipment;
|
||||
|
||||
$selected_eqmt = "";
|
||||
|
||||
$date = new \DateTime;
|
||||
$date->setTimestamp(time());
|
||||
$default_date = $date;
|
||||
|
||||
$default_comment = "";
|
||||
|
||||
$csrf_key = 'add_output';
|
||||
|
||||
$eqmts_by_cat = $eqmt->ListAllBorrowedByCategory();
|
||||
|
||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$eqmt_id = f('equipment_id');
|
||||
$eqmt_number = (int) f('equipment_number');
|
||||
$output_date_format = date_create_from_format(
|
||||
"d/m/Y", f('output_date'))->format("Y-m-d");
|
||||
if ($output->PossibilityNoOwnedEqmtOutput($eqmt_id, $eqmt_number, $output_date_format))
|
||||
{
|
||||
$output->add([
|
||||
'kind' => 'Retour de location / prêt',
|
||||
'equipment_number' => $eqmt_number,
|
||||
'equipment_id' => $eqmt_id,
|
||||
'output_date' => $output_date_format,
|
||||
'additional_comment' => f('additional_comment'),
|
||||
]);
|
||||
Utils::redirect(PLUGIN_URL . 'sorties/index.php');
|
||||
} else
|
||||
{
|
||||
$output_date = f('output_date');
|
||||
$selected_eqmt = $eqmt_id;
|
||||
$default_date = $output_date;
|
||||
$default_comment = f('additional_comment');
|
||||
|
||||
$equiment = $eqmt->get($eqmt_id);
|
||||
$form->addError(
|
||||
"Il est impossible de sortir " . (string) $eqmt_number . " " . $equiment->designation . " à la date du " . (string) $output_date . '.');
|
||||
}
|
||||
}
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'sorties/index.php';
|
||||
$legend_part = "emprunté";
|
||||
$tpl_materiel_name = "emprunte";
|
||||
|
||||
$tpl->assign(compact(
|
||||
'csrf_key', 'cancel_link', 'legend_part', 'tpl_materiel_name',
|
||||
'selected_eqmt', 'default_date', 'default_comment',
|
||||
'eqmts_by_cat'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/sorties/ajouter_sortie.tpl');
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Plugin\Materiels\Output;
|
||||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$eqmt = new Equipment;
|
||||
$output = new Output;
|
||||
|
||||
$outputs = $output->listAll();
|
||||
|
||||
foreach ($outputs as $key => $value) {
|
||||
$output_eqmt = $eqmt->get($value->equipment_id);
|
||||
$outputs[$key]->equipment = $output_eqmt->designation;
|
||||
}
|
||||
|
||||
$tpl->assign(compact('outputs'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/sorties/index.tpl');
|
@ -1,67 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
|
||||
use Garradin\Plugin\Materiels\Output;
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Utils;
|
||||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$output = new Output;
|
||||
$eqmt = new Equipment;
|
||||
|
||||
$eqmts_by_cat = $eqmt->ListAllAvailableByCategory();
|
||||
$selected_eqmt = "";
|
||||
|
||||
$kinds = $output->listKinds();
|
||||
$selected_kind = $kinds[0];
|
||||
|
||||
$date = new \DateTime;
|
||||
$date->setTimestamp(time());
|
||||
$default_date = $date;
|
||||
|
||||
$default_comment = "";
|
||||
|
||||
$csrf_key = 'add_output';
|
||||
|
||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$eqmt_id = f('equipment_id');
|
||||
$eqmt_number = (int) f('equipment_number');
|
||||
$output_date_format = date_create_from_format(
|
||||
"d/m/Y", f('output_date'))->format("Y-m-d");
|
||||
if ($output->PossibilityOwnedEqmtOutput($eqmt_id, $eqmt_number, $output_date_format))
|
||||
{
|
||||
$output->add([
|
||||
'kind' => f('kind'),
|
||||
'equipment_number' => $eqmt_number,
|
||||
'equipment_id' => $eqmt_id,
|
||||
'output_date' => $output_date_format,
|
||||
'additional_comment' => f('additional_comment'),
|
||||
]);
|
||||
Utils::redirect(PLUGIN_URL . 'sorties/index.php');
|
||||
} else
|
||||
{
|
||||
$output_date = f('output_date');
|
||||
$selected_eqmt = $eqmt_id;
|
||||
$selected_kind = f('kind');
|
||||
$default_date = $output_date;
|
||||
$default_comment = f('additional_comment');
|
||||
|
||||
$equiment = $eqmt->get($eqmt_id);
|
||||
$form->addError(
|
||||
"Il est impossible de sortir " . (string) $eqmt_number . " " . $equiment->designation . " à la date du " . (string) $output_date . '.');
|
||||
}
|
||||
}
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'sorties/index.php';
|
||||
$legend_part = "en stock disponible";
|
||||
$tpl_materiel_name = "stock_disponible";
|
||||
|
||||
$tpl->assign(compact(
|
||||
'csrf_key', 'cancel_link', 'legend_part', 'tpl_materiel_name',
|
||||
'kinds', 'selected_eqmt', 'selected_kind', 'default_date', 'default_comment',
|
||||
'eqmts_by_cat'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/sorties/ajouter_sortie.tpl');
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Garradin;
|
||||
use Garradin\Plugin\Materiels\Output;
|
||||
use Garradin\Plugin\Materiels\Equipment;
|
||||
use Garradin\Utils;
|
||||
|
||||
require_once __DIR__ . '/../_inc.php';
|
||||
|
||||
$output = new Output;
|
||||
|
||||
$o_to_delete = $output->get((int) qg('id'));
|
||||
|
||||
if (!$o_to_delete)
|
||||
{
|
||||
throw new UserException("Cette sortie n'existe pas.");
|
||||
}
|
||||
|
||||
$csrf_key = 'delete_output_' . $o_to_delete->id;
|
||||
|
||||
if (f('delete') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$output->delete($o_to_delete->id);
|
||||
Utils::redirect(PLUGIN_URL . 'sorties/index.php');
|
||||
}
|
||||
|
||||
$eqmt = new Equipment;
|
||||
$equipment = $eqmt->get($o_to_delete->equipment_id);
|
||||
|
||||
if ($output->PossibilityDeleteOutput($o_to_delete))
|
||||
{
|
||||
$cancel_link = PLUGIN_URL . 'sorties/index.php';
|
||||
|
||||
$output_string = (string) $o_to_delete->equipment_number . " " . $equipment->designation . " à la date du " . date_create_from_format(
|
||||
"Y-m-d", $o_to_delete->output_date)->format("d/m/y");
|
||||
|
||||
$tpl->assign(compact('output_string', 'csrf_key', 'cancel_link'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/sorties/supprimer_sortie.tpl');
|
||||
|
||||
} else {
|
||||
throw new UserException(
|
||||
"Cette sortie ne peut pas être supprimée car ça rendrait impossible l'historique des entrées et sorties de « " . $equipment->designation . " ». --- plus de 'retour de location / prêt' en entrée que de 'location / prêt' en sortie ! ---");
|
||||
}
|
Loading…
Reference in New Issue
Block a user