diff --git a/doc_db/doc_db.md b/doc_db/doc_db.md index ce6571c..83f8df3 100644 --- a/doc_db/doc_db.md +++ b/doc_db/doc_db.md @@ -34,7 +34,7 @@ | *| mvt_date| date | | | | additional_comment| varchar(255) | | | Indexes | -| đŸ”‘ primary key | pk_plugin_materiels_entry | | +| đŸ”‘ primary key | pk_plugin_materiels_movement | | | Foreign Keys | | | Fk_plugin_materiels_movement | ( equipment_id ) ref plugin_materiels_equipment (id) | | diff --git a/src/lib/Equipment.php b/src/lib/Equipment.php index 428b44f..6c39027 100644 --- a/src/lib/Equipment.php +++ b/src/lib/Equipment.php @@ -117,12 +117,18 @@ class Equipment } 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(); + // construct the 3 lists $eqmts_owned_by_cat = array(); $eqmts_no_owned_by_cat = array(); $eqmts_just_listed_by_cat = array(); 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); $eqmts_owned_by_cat[$cat] = $eqmts_owned; $eqmts_no_owned_by_cat[$cat] = $eqmts_no_owned; diff --git a/src/lib/Movement.php b/src/lib/Movement.php index 64755c2..9200bf7 100644 --- a/src/lib/Movement.php +++ b/src/lib/Movement.php @@ -168,4 +168,12 @@ class Movement } 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;"); + } } diff --git a/src/templates/historique.tpl b/src/templates/historique.tpl index 907327a..d9fa150 100644 --- a/src/templates/historique.tpl +++ b/src/templates/historique.tpl @@ -1,9 +1,47 @@ -{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_nav="index"} + + +

Historique des entrées / sorties

-{include file="%s_nav.tpl"|args:$plugin_tpl current="index"} - -{foreach from=$all_dates item='date'} -

{$date}

-{/foreach} +
+ +{if $mvts} + + + + + + + + + + + + + + + {foreach from=$mvts item="mvt"} + + + {if $mvt.side} + + {else} + + {/if} + + + + + {/foreach} + +
+

{$eqmt_requested.designation} - {$eqmt_requested.category} -

+
DateSensTypeNombreRemarques
{$mvt.mvt_date|date_format:'%d/%m/%y'}SortieEntrée{$mvt.kind}{$mvt.equipment_number}{$mvt.additional_comment}
+{/if} + +{linkbutton label="Retour" shape="export" href=$return_link} + {include file="admin/_foot.tpl"} + diff --git a/src/www/admin/historique.php b/src/www/admin/historique.php index 2f80c2c..52e962b 100644 --- a/src/www/admin/historique.php +++ b/src/www/admin/historique.php @@ -1,25 +1,27 @@ 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); -$output_dates = $output->AllDatesByEquipment($eq->id); -$all_dates = array_unique(array_merge( - $entry_dates, $output_dates), SORT_REGULAR); +$return_link = PLUGIN_URL . 'index.php'; -sort($all_dates); - -$tpl->assign(compact('all_dates')); +// send all to template +$tpl->assign(compact('eqmt_requested', 'mvts', 'return_link')); $tpl->display(PLUGIN_ROOT . '/templates/historique.tpl');