ok for output of borrowed equipment template, next validate form in php file
This commit is contained in:
parent
36784f51da
commit
00b6aee6fd
@ -153,13 +153,42 @@ class Equipment
|
||||
}
|
||||
|
||||
public function listAllReleasedRentByCategory()
|
||||
{
|
||||
$eqmts_by_cat = $this->listAllByCategory();
|
||||
$eqmts_released_by_cat = array();
|
||||
foreach ($eqmts_by_cat as $cat => $eqmts) {
|
||||
$eqmts_released = array();
|
||||
foreach ($eqmts as $eqmt) {
|
||||
$released = $this->CalculateOutOfStock($eqmt->id);
|
||||
if ($released) {
|
||||
$eqmt->released = $released;
|
||||
array_push($eqmts_released, $eqmt);
|
||||
}
|
||||
}
|
||||
if ($eqmts_released) {
|
||||
$eqmts_released_by_cat[$cat] = $eqmts_released;
|
||||
}
|
||||
}
|
||||
return $eqmts_released_by_cat;
|
||||
}
|
||||
|
||||
public function CalculateOutOfStockByDate($id, $date)
|
||||
{
|
||||
$entries = DB::getInstance()->firstColumn(
|
||||
"SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind = 'Retour de location / prêt' AND equipment_id = '{$id}' AND entry_date <= '{$date}';");
|
||||
$outputs = DB::getInstance()->firstColumn(
|
||||
"SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind = 'Location / Prêt' AND equipment_id = '{$id}' AND output_date <= '{$date}';");
|
||||
return $outputs - $entries;
|
||||
}
|
||||
|
||||
public function ListAllBorrowedByCategory()
|
||||
{
|
||||
$eqmts_by_cat = $this->listAllByCategory();
|
||||
$eqmts_borrowed_by_cat = array();
|
||||
foreach ($eqmts_by_cat as $cat => $eqmts) {
|
||||
$eqmts_borrowed = array();
|
||||
foreach ($eqmts as $eqmt) {
|
||||
$borrowed = $this->CalculateOutOfStock($eqmt->id);
|
||||
$borrowed = $this->CalculateNoOwned($eqmt->id);
|
||||
if ($borrowed) {
|
||||
$eqmt->borrowed = $borrowed;
|
||||
array_push($eqmts_borrowed, $eqmt);
|
||||
@ -171,13 +200,4 @@ class Equipment
|
||||
}
|
||||
return $eqmts_borrowed_by_cat;
|
||||
}
|
||||
|
||||
public function CalculateOutOfStockByDate($id, $date)
|
||||
{
|
||||
$entries = DB::getInstance()->firstColumn(
|
||||
"SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind = 'Retour de location / prêt' AND equipment_id = '{$id}' AND entry_date <= '{$date}';");
|
||||
$outputs = DB::getInstance()->firstColumn(
|
||||
"SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind = 'Location / Prêt' AND equipment_id = '{$id}' AND output_date <= '{$date}';");
|
||||
return $outputs - $entries;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
<tr>
|
||||
<th><b>Désignation</b></th>
|
||||
<th><b>Stock</b></th>
|
||||
<th><b>Sorti en location / prêt</b></th>
|
||||
<th><b>Sortie</b></th>
|
||||
<th><b>Disponible</b></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
@ -7,7 +7,7 @@
|
||||
<legend>Ajouter une sortie d'un matériel {$legend_part}</legend>
|
||||
{form_errors}
|
||||
<dl>
|
||||
{if $tpl_materiel_name != 'retour'}
|
||||
{if $tpl_materiel_name != 'emprunte'}
|
||||
<dt><label for="f_kind">Type</label> <b>(obligatoire)</b></dt>
|
||||
<dd>
|
||||
<select name="kind" id="f_kind">
|
||||
|
17
src/templates/sorties/emprunte.tpl
Normal file
17
src/templates/sorties/emprunte.tpl
Normal file
@ -0,0 +1,17 @@
|
||||
<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>
|
@ -5,7 +5,7 @@
|
||||
<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="pas_proprietaire.php"}
|
||||
{linkbutton shape="plus" label="Matériel emprunté" href="emprunte.php"}
|
||||
</fieldset>
|
||||
|
||||
{if $outputs}
|
||||
|
@ -1,7 +0,0 @@
|
||||
{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"}
|
||||
|
||||
pas propriétaire sortie
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
35
src/www/admin/sorties/emprunte.php
Normal file
35
src/www/admin/sorties/emprunte.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?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();
|
||||
|
||||
$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,21 +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;
|
||||
|
||||
$csrf_key = 'add_output';
|
||||
|
||||
$cancel_link = PLUGIN_URL . 'sorties/index.php';
|
||||
|
||||
|
||||
$tpl->assign(compact('csrf_key'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/sorties/pas_proprietaire.tpl');
|
Loading…
Reference in New Issue
Block a user