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()
|
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_by_cat = $this->listAllByCategory();
|
||||||
$eqmts_borrowed_by_cat = array();
|
$eqmts_borrowed_by_cat = array();
|
||||||
foreach ($eqmts_by_cat as $cat => $eqmts) {
|
foreach ($eqmts_by_cat as $cat => $eqmts) {
|
||||||
$eqmts_borrowed = array();
|
$eqmts_borrowed = array();
|
||||||
foreach ($eqmts as $eqmt) {
|
foreach ($eqmts as $eqmt) {
|
||||||
$borrowed = $this->CalculateOutOfStock($eqmt->id);
|
$borrowed = $this->CalculateNoOwned($eqmt->id);
|
||||||
if ($borrowed) {
|
if ($borrowed) {
|
||||||
$eqmt->borrowed = $borrowed;
|
$eqmt->borrowed = $borrowed;
|
||||||
array_push($eqmts_borrowed, $eqmt);
|
array_push($eqmts_borrowed, $eqmt);
|
||||||
|
@ -171,13 +200,4 @@ class Equipment
|
||||||
}
|
}
|
||||||
return $eqmts_borrowed_by_cat;
|
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>
|
<tr>
|
||||||
<th><b>Désignation</b></th>
|
<th><b>Désignation</b></th>
|
||||||
<th><b>Stock</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><b>Disponible</b></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<legend>Ajouter une sortie d'un matériel {$legend_part}</legend>
|
<legend>Ajouter une sortie d'un matériel {$legend_part}</legend>
|
||||||
{form_errors}
|
{form_errors}
|
||||||
<dl>
|
<dl>
|
||||||
{if $tpl_materiel_name != 'retour'}
|
{if $tpl_materiel_name != 'emprunte'}
|
||||||
<dt><label for="f_kind">Type</label> <b>(obligatoire)</b></dt>
|
<dt><label for="f_kind">Type</label> <b>(obligatoire)</b></dt>
|
||||||
<dd>
|
<dd>
|
||||||
<select name="kind" id="f_kind">
|
<select name="kind" id="f_kind">
|
||||||
|
|
|
@ -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>
|
<fieldset>
|
||||||
<legend>Ajouter une sortie pour du </legend>
|
<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 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>
|
</fieldset>
|
||||||
|
|
||||||
{if $outputs}
|
{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"}
|
|
|
@ -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