ok for all calculation, next add output
This commit is contained in:
parent
71775c0f67
commit
54858e2d18
BIN
materiels.tar.gz
BIN
materiels.tar.gz
Binary file not shown.
@ -47,21 +47,62 @@ class Equipment
|
||||
return $entries - $outputs;
|
||||
}
|
||||
|
||||
public function listAllOwnedByCategory()
|
||||
public function CalculateOutOfStock($id)
|
||||
{
|
||||
$entries = DB::getInstance()->firstColumn(
|
||||
"SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind = 'Retour de location / prêt' AND equipment_id = ?;", $id);
|
||||
$outputs = DB::getInstance()->firstColumn(
|
||||
"SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind = 'Location / Prêt' AND equipment_id = ?;", $id);
|
||||
return $outputs - $entries;
|
||||
}
|
||||
|
||||
public function CalculateNoOwned($id)
|
||||
{
|
||||
$entries = DB::getInstance()->firstColumn(
|
||||
"SELECT sum(equipment_number) FROM plugin_materiels_entry WHERE kind = 'Location / Prêt' AND equipment_id = ?;", $id);
|
||||
$outputs = DB::getInstance()->firstColumn(
|
||||
"SELECT sum(equipment_number) FROM plugin_materiels_output WHERE kind = 'Retour de location / prêt' AND equipment_id = ?;", $id);
|
||||
return $entries - $outputs;
|
||||
}
|
||||
|
||||
public function GetAllListByCategory()
|
||||
{
|
||||
$eqmts_by_cat = $this->listAllByCategory();
|
||||
$eqmts_owned_by_cat = array();
|
||||
$eqmts_no_owned_by_cat = array();
|
||||
$eqmts_just_listed_by_cat = array();
|
||||
foreach ($eqmts_by_cat as $cat => $eqmts) {
|
||||
$eqmts_owned = array();
|
||||
$eqmts_no_owned = array();
|
||||
$eqmts_just_listed = array();
|
||||
foreach ($eqmts as $eqmt) {
|
||||
$stock = $this->CalculateStock($eqmt->id);
|
||||
if ($stock) {
|
||||
$eqmt->stock = $this->CalculateStock($eqmt->id);
|
||||
array_push($eqmts_owned, $eqmt);
|
||||
}
|
||||
$stock = $this->CalculateStock($eqmt->id);
|
||||
if ($stock) {
|
||||
$eqmt->stock = $stock;
|
||||
$out_of_stock = $this->CalculateOutOfStock($eqmt->id);
|
||||
if ($out_of_stock) {
|
||||
$eqmt->out_of_stock = $out_of_stock;
|
||||
} else {
|
||||
$eqmt->out_of_stock = 0;
|
||||
}
|
||||
array_push($eqmts_owned, $eqmt);
|
||||
}
|
||||
$no_owned = $this->CalculateNoOwned($eqmt->id);
|
||||
if ($no_owned) {
|
||||
$eqmt->no_owned = $no_owned;
|
||||
array_push($eqmts_no_owned, $eqmt);
|
||||
}
|
||||
if ($stock + $no_owned == 0) {
|
||||
array_push($eqmts_just_listed, $eqmt);
|
||||
}
|
||||
}
|
||||
$eqmts_owned_by_cat[$cat] = $eqmts_owned;
|
||||
$eqmts_no_owned_by_cat[$cat] = $eqmts_no_owned;
|
||||
$eqmts_just_listed_by_cat[$cat] = $eqmts_just_listed;
|
||||
}
|
||||
return $eqmts_owned_by_cat;
|
||||
return array(
|
||||
$eqmts_owned_by_cat, $eqmts_no_owned_by_cat,
|
||||
$eqmts_just_listed_by_cat
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,4 +17,20 @@ class Output
|
||||
'Retour de location / prêt',
|
||||
);
|
||||
}
|
||||
|
||||
public function add($data = [])
|
||||
{
|
||||
DB::getInstance()->insert('plugin_materiels_output', $data);
|
||||
}
|
||||
|
||||
public function edit($id, $data = [])
|
||||
{
|
||||
$db = DB::getInstance();
|
||||
$db->update('plugin_materiels_output', $data, $db->where('id', $id));
|
||||
}
|
||||
|
||||
public function listAll()
|
||||
{
|
||||
return DB::getInstance()->get('SELECT * FROM plugin_materiels_output ORDER BY output_date DESC;');
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
<li class="{if $current == 'index'}current{/if}"><a href="{plugin_url}">Inventaire</a></li>
|
||||
<li class="{if $current == 'categories'}current{/if}"><a href="{plugin_url file="categories/index.php"}">Catégories</a></li>
|
||||
<li class="{if $current == 'entrees'}current{/if}"><a href="{plugin_url file="entrees/index.php"}">Entrées</a></li>
|
||||
<li class="{if $current == 'sorties_definitives'}current{/if}"><a href="{plugin_url file="sorties.php"}">Sorties</a></li>
|
||||
<li class="{if $current == 'sorties'}current{/if}"><a href="{plugin_url file="sorties/index.php"}">Sorties</a></li>
|
||||
<li class="{if $current == 'recherche'}current{/if}"><a href="{plugin_url file="recherche.php"}">Recherche</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -5,11 +5,13 @@
|
||||
<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}">{$eqmt.designation}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{if $eqmts}
|
||||
<optgroup label="-- {$cat} --">
|
||||
{foreach from=$eqmts item="eqmt"}
|
||||
<option value="{$eqmt.id}">{$eqmt.designation}</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</select>
|
||||
</dd>
|
||||
|
@ -8,25 +8,27 @@
|
||||
{linkbutton shape="plus" label="Matériel déjà répertorié" href="deja_repertorie.php"}
|
||||
</fieldset>
|
||||
|
||||
<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>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$entries item="entry"}
|
||||
<tr>
|
||||
<td>{$entry.entry_date}</td>
|
||||
<td>{$entry.kind}</td>
|
||||
<td>{$entry.equipment_number}</td>
|
||||
<td>{$entry.equipment.designation}</td>
|
||||
<td>{$entry.additional_comment}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{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>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$entries item="entry"}
|
||||
<tr>
|
||||
<td>{$entry.entry_date}</td>
|
||||
<td>{$entry.kind}</td>
|
||||
<td>{$entry.equipment_number}</td>
|
||||
<td>{$entry.equipment.designation}</td>
|
||||
<td>{$entry.additional_comment}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
||||
|
@ -21,8 +21,8 @@
|
||||
<tr>
|
||||
<td>{$eqmt.designation}</td>
|
||||
<td>{$eqmt.stock}</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>{$eqmt.out_of_stock}</td>
|
||||
<td>{$eqmt.stock - $eqmt.out_of_stock}</td>
|
||||
<td class="actions">
|
||||
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
||||
</td>
|
||||
@ -33,8 +33,56 @@
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
<h2>Matériel dont l'association n'est pas propriétaire</h2>
|
||||
<h2>Matériel dont l'association n'est pas propriétaire (loué ou prêté)</h2>
|
||||
{foreach from=$eqmts_no_owned_by_cat key='cat' item="eqmts"}
|
||||
{if $eqmts}
|
||||
<h3>{$cat}</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><b>Désignation</b></th>
|
||||
<th><b>Nombre</b></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$eqmts item="eqmt"}
|
||||
<tr>
|
||||
<td>{$eqmt.designation}</td>
|
||||
<td>{$eqmt.no_owned}</td>
|
||||
<td class="actions">
|
||||
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
<h2>Matériel déjà répertorié qui n'est plus en possession de l'association</h2>
|
||||
<h2>Matériel dont l'association n'est plus en possession</h2>
|
||||
{foreach from=$eqmts_just_listed_by_cat key='cat' item="eqmts"}
|
||||
{if $eqmts}
|
||||
<h3>{$cat}</h3>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><b>Désignation</b></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$eqmts item="eqmt"}
|
||||
<tr>
|
||||
<td>{$eqmt.designation}</td>
|
||||
<td class="actions">
|
||||
{linkbutton shape="edit" label="Modifier" href="modifier_materiel.php?id=%d"|args:$eqmt.id}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
{/foreach}
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
||||
|
@ -2,4 +2,6 @@
|
||||
|
||||
{include file="%s_nav.tpl"|args:$plugin_tpl current="sorties"}
|
||||
|
||||
en stock sortie
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
34
src/templates/sorties/index.tpl
Normal file
34
src/templates/sorties/index.tpl
Normal file
@ -0,0 +1,34 @@
|
||||
{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"}
|
||||
|
||||
<fieldset>
|
||||
<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 emprunté" href="pas_proprietaire.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>
|
||||
</thead>
|
||||
<tbody>
|
||||
{foreach from=$outputs item="output"}
|
||||
<tr>
|
||||
<td>{$output.output_date}</td>
|
||||
<td>{$output.kind}</td>
|
||||
<td>{$output.equipment_number}</td>
|
||||
<td>{$output.equipment.designation}</td>
|
||||
<td>{$output.additional_comment}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{/if}
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
7
src/templates/sorties/pas_proprietaire.tpl
Normal file
7
src/templates/sorties/pas_proprietaire.tpl
Normal file
@ -0,0 +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="sorties"}
|
||||
|
||||
pas propriétaire sortie
|
||||
|
||||
{include file="admin/_foot.tpl"}
|
@ -13,8 +13,13 @@ require_once __DIR__ . '/_inc.php';
|
||||
|
||||
$eqmt = new Equipment;
|
||||
|
||||
$eqmts_owned_by_cat = $eqmt->listAllOwnedByCategory();
|
||||
list(
|
||||
$eqmts_owned_by_cat, $eqmts_no_owned_by_cat,
|
||||
$eqmts_just_listed_by_cat) = $eqmt->GetAllListByCategory();
|
||||
|
||||
$tpl->assign(compact('eqmts_owned_by_cat'));
|
||||
$tpl->assign(compact(
|
||||
'eqmts_owned_by_cat', 'eqmts_no_owned_by_cat',
|
||||
'eqmts_just_listed_by_cat'
|
||||
));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/index.tpl');
|
||||
|
21
src/www/admin/sorties/en_stock.php
Normal file
21
src/www/admin/sorties/en_stock.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?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');
|
21
src/www/admin/sorties/index.php
Normal file
21
src/www/admin/sorties/index.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?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) {
|
||||
$outputs[$key]->equipment = $eqmt->get($value->equipment_id);
|
||||
}
|
||||
|
||||
$tpl->assign(compact('outputs'));
|
||||
|
||||
$tpl->display(PLUGIN_ROOT . '/templates/sorties/index.tpl');
|
21
src/www/admin/sorties/pas_proprietaire.php
Normal file
21
src/www/admin/sorties/pas_proprietaire.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?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