ok for available equiment output tpl, next add validate form in php file
This commit is contained in:
parent
08e2af1f1d
commit
d58ae812b5
@ -65,6 +65,19 @@ class Equipment
|
|||||||
return $entries - $outputs;
|
return $entries - $outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function CalculateAvailable($id)
|
||||||
|
{
|
||||||
|
$entries = DB::getInstance()->firstColumn(
|
||||||
|
"SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind IN (
|
||||||
|
'Achat', 'Don', 'Récupération',
|
||||||
|
'Retour de location / prêt') AND equipment_id = ?;", $id);
|
||||||
|
$outputs = DB::getInstance()->firstColumn(
|
||||||
|
"SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind IN (
|
||||||
|
'Vente', 'Don', 'Besoin', 'Autre (perte, vol, ...)',
|
||||||
|
'Location / Prêt') AND equipment_id = ?;", $id);
|
||||||
|
return $entries - $outputs;
|
||||||
|
}
|
||||||
|
|
||||||
public function GetAllListByCategory()
|
public function GetAllListByCategory()
|
||||||
{
|
{
|
||||||
$eqmts_by_cat = $this->listAllByCategory();
|
$eqmts_by_cat = $this->listAllByCategory();
|
||||||
@ -105,4 +118,22 @@ class Equipment
|
|||||||
$eqmts_just_listed_by_cat
|
$eqmts_just_listed_by_cat
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function GetAvailableListByCategory()
|
||||||
|
{
|
||||||
|
$eqmts_by_cat = $this->listAllByCategory();
|
||||||
|
$eqmts_available_by_cat = array();
|
||||||
|
foreach ($eqmts_by_cat as $cat => $eqmts) {
|
||||||
|
$eqmts_available = array();
|
||||||
|
foreach ($eqmts as $eqmt) {
|
||||||
|
$available = $this->CalculateAvailable($eqmt->id);
|
||||||
|
if ($available) {
|
||||||
|
$eqmt->available = $available;
|
||||||
|
array_push($eqmts_available, $eqmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$eqmts_available_by_cat[$cat] = $eqmts_available;
|
||||||
|
}
|
||||||
|
return $eqmts_available_by_cat;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@ class Output
|
|||||||
'Besoin',
|
'Besoin',
|
||||||
'Autre (perte, vol, ...)',
|
'Autre (perte, vol, ...)',
|
||||||
'Location / Prêt',
|
'Location / Prêt',
|
||||||
'Retour de location / prêt',
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
35
src/templates/sorties/ajouter_sortie.tpl
Normal file
35
src/templates/sorties/ajouter_sortie.tpl
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{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"}
|
||||||
|
|
||||||
|
<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 != '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="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,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"}
|
|
||||||
|
|
||||||
en stock sortie
|
|
||||||
|
|
||||||
{include file="admin/_foot.tpl"}
|
|
@ -4,7 +4,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" href="en_stock.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="pas_proprietaire.php"}
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
19
src/templates/sorties/stock_disponible.tpl
Normal file
19
src/templates/sorties/stock_disponible.tpl
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<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} - (dispo {$eqmt.available})</option>
|
||||||
|
{/foreach}
|
||||||
|
</optgroup>
|
||||||
|
{/if}
|
||||||
|
{/foreach}
|
||||||
|
</select>
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</fieldset>
|
@ -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/en_stock.tpl');
|
|
35
src/www/admin/sorties/stock_disponible.php
Normal file
35
src/www/admin/sorties/stock_disponible.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;
|
||||||
|
$eqmts_by_cat = $eqmt->GetAvailableListByCategory();
|
||||||
|
|
||||||
|
$csrf_key = 'add_output';
|
||||||
|
|
||||||
|
$kinds = $output->listKinds();
|
||||||
|
$selected_kind = $kinds[0];
|
||||||
|
|
||||||
|
$date = new \DateTime;
|
||||||
|
$date->setTimestamp(time());
|
||||||
|
$default_date = $date;
|
||||||
|
|
||||||
|
$default_comment = "";
|
||||||
|
|
||||||
|
$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_kind', 'default_date', 'default_comment',
|
||||||
|
'eqmts_by_cat'));
|
||||||
|
|
||||||
|
$tpl->display(PLUGIN_ROOT . '/templates/sorties/ajouter_sortie.tpl');
|
Loading…
Reference in New Issue
Block a user