begin to historic for an equipment
This commit is contained in:
parent
1e9c8d8553
commit
8f3caadde1
@ -34,7 +34,7 @@
|
|||||||
| *| mvt_date| date | |
|
| *| mvt_date| date | |
|
||||||
| | additional_comment| varchar(255) | |
|
| | additional_comment| varchar(255) | |
|
||||||
| Indexes |
|
| Indexes |
|
||||||
| 🔑 primary key | pk_plugin_materiels_entry | |
|
| 🔑 primary key | pk_plugin_materiels_movement | |
|
||||||
| Foreign Keys |
|
| Foreign Keys |
|
||||||
| | Fk_plugin_materiels_movement | ( equipment_id ) ref plugin_materiels_equipment (id) | |
|
| | Fk_plugin_materiels_movement | ( equipment_id ) ref plugin_materiels_equipment (id) | |
|
||||||
|
|
||||||
|
@ -117,12 +117,18 @@ class Equipment
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function AllListsAllByCategory()
|
public function AllListsAllByCategory()
|
||||||
|
// construct and return 3 lists with all equipments:
|
||||||
|
// equipments owned, equipments no owned and equipments just listed
|
||||||
|
// ordered by category
|
||||||
{
|
{
|
||||||
|
// get list of all equipments ordered by category
|
||||||
$eqmts_by_cat = $this->listAllByCategory();
|
$eqmts_by_cat = $this->listAllByCategory();
|
||||||
|
// construct the 3 lists
|
||||||
$eqmts_owned_by_cat = array();
|
$eqmts_owned_by_cat = array();
|
||||||
$eqmts_no_owned_by_cat = array();
|
$eqmts_no_owned_by_cat = array();
|
||||||
$eqmts_just_listed_by_cat = array();
|
$eqmts_just_listed_by_cat = array();
|
||||||
foreach ($eqmts_by_cat as $cat => $eqmts) {
|
foreach ($eqmts_by_cat as $cat => $eqmts) {
|
||||||
|
// for each category construct the 3 lists with all of his equipments
|
||||||
list($eqmts_owned, $eqmts_no_owned, $eqmts_just_listed) = $this->AllListsAll($eqmts);
|
list($eqmts_owned, $eqmts_no_owned, $eqmts_just_listed) = $this->AllListsAll($eqmts);
|
||||||
$eqmts_owned_by_cat[$cat] = $eqmts_owned;
|
$eqmts_owned_by_cat[$cat] = $eqmts_owned;
|
||||||
$eqmts_no_owned_by_cat[$cat] = $eqmts_no_owned;
|
$eqmts_no_owned_by_cat[$cat] = $eqmts_no_owned;
|
||||||
|
@ -168,4 +168,12 @@ class Movement
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function AllEqmtMovements($eqmt_id)
|
||||||
|
// return list of all movements for a specific equipments
|
||||||
|
// ordered by date and side
|
||||||
|
{
|
||||||
|
return DB::getInstance()->get(
|
||||||
|
"SELECT * FROM plugin_materiels_movement WHERE equipment_id = '{$eqmt_id}' ORDER BY mvt_date DESC, side DESC;");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,47 @@
|
|||||||
{include file="admin/_head.tpl" title="%s"|args:$plugin.nom current="plugin_%s"|args:$plugin.id}
|
<!-- nav bar-->
|
||||||
|
{include file="%s_nav.tpl"|args:$plugin_tpl current_nav="index"}
|
||||||
|
<!-- -->
|
||||||
|
<!-- -->
|
||||||
|
<h2 style="text-align: center;">Historique des entrées / sorties</h2>
|
||||||
|
|
||||||
{include file="%s_nav.tpl"|args:$plugin_tpl current="index"}
|
<br>
|
||||||
|
|
||||||
{foreach from=$all_dates item='date'}
|
<!-- table of movements -->
|
||||||
<p>{$date}</p>
|
{if $mvts}
|
||||||
|
<table class="list">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="5" style="text-align: center;">
|
||||||
|
<h3>{$eqmt_requested.designation} - {$eqmt_requested.category} -</h3>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th><b>Date</b></th>
|
||||||
|
<th><b>Sens</b></th>
|
||||||
|
<th><b>Type</b></th>
|
||||||
|
<th><b>Nombre</b></th>
|
||||||
|
<th><b>Remarques</b></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{foreach from=$mvts item="mvt"}
|
||||||
|
<tr>
|
||||||
|
<td>{$mvt.mvt_date|date_format:'%d/%m/%y'}</td>
|
||||||
|
{if $mvt.side}
|
||||||
|
<td>Sortie</td>
|
||||||
|
{else}
|
||||||
|
<td>Entrée</td>
|
||||||
|
{/if}
|
||||||
|
<td>{$mvt.kind}</td>
|
||||||
|
<td>{$mvt.equipment_number}</td>
|
||||||
|
<td>{$mvt.additional_comment}</td>
|
||||||
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{/if}
|
||||||
|
<!-- -->
|
||||||
|
{linkbutton label="Retour" shape="export" href=$return_link}
|
||||||
|
<!-- footer -->
|
||||||
{include file="admin/_foot.tpl"}
|
{include file="admin/_foot.tpl"}
|
||||||
|
<!-- -->
|
||||||
|
@ -1,25 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// historic of movements (entry and output) for a specific Equipment
|
||||||
|
|
||||||
namespace Garradin;
|
namespace Garradin;
|
||||||
use Garradin\Plugin\Materiels\Equipment;
|
use Garradin\Plugin\Materiels\Equipment;
|
||||||
use Garradin\Plugin\Materiels\Entry;
|
use Garradin\Plugin\Materiels\Category;
|
||||||
use Garradin\Plugin\Materiels\Output;
|
use Garradin\Plugin\Materiels\Movement;
|
||||||
|
|
||||||
require_once __DIR__ . '/_inc.php';
|
require_once __DIR__ . '/_inc.php';
|
||||||
|
|
||||||
$eqmt = new Equipment;
|
$eqmt = new Equipment;
|
||||||
$entry = new Entry;
|
$cat = new Category;
|
||||||
$output = new Output;
|
$mvt = new Movement;
|
||||||
|
|
||||||
$eq = $eqmt->get((int) qg('id'));
|
// get equipment requested, his category's name and all of his movements
|
||||||
|
$eqmt_requested = $eqmt->get((int) qg('id'));
|
||||||
|
$eqmt_cat = $cat->get($eqmt_requested->category_id);
|
||||||
|
$eqmt_requested->category = $eqmt_cat->name;
|
||||||
|
$mvts = $mvt->AllEqmtMovements($eqmt_requested->id);
|
||||||
|
|
||||||
$entry_dates = $entry->AllDatesByEquipment($eq->id);
|
$return_link = PLUGIN_URL . 'index.php';
|
||||||
$output_dates = $output->AllDatesByEquipment($eq->id);
|
|
||||||
$all_dates = array_unique(array_merge(
|
|
||||||
$entry_dates, $output_dates), SORT_REGULAR);
|
|
||||||
|
|
||||||
sort($all_dates);
|
// send all to template
|
||||||
|
$tpl->assign(compact('eqmt_requested', 'mvts', 'return_link'));
|
||||||
$tpl->assign(compact('all_dates'));
|
|
||||||
|
|
||||||
$tpl->display(PLUGIN_ROOT . '/templates/historique.tpl');
|
$tpl->display(PLUGIN_ROOT . '/templates/historique.tpl');
|
||||||
|
Loading…
Reference in New Issue
Block a user