change date format to have correct order in sql request, next add validate form in php file for available equipment output
This commit is contained in:
parent
d58ae812b5
commit
b8a7d664c2
BIN
materiels.tar.gz
BIN
materiels.tar.gz
Binary file not shown.
|
@ -65,19 +65,6 @@ class Equipment
|
|||
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()
|
||||
{
|
||||
$eqmts_by_cat = $this->listAllByCategory();
|
||||
|
@ -119,6 +106,19 @@ class Equipment
|
|||
);
|
||||
}
|
||||
|
||||
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 GetAvailableListByCategory()
|
||||
{
|
||||
$eqmts_by_cat = $this->listAllByCategory();
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<tbody>
|
||||
{foreach from=$entries item="entry"}
|
||||
<tr>
|
||||
<td>{$entry.entry_date}</td>
|
||||
<td>{$entry.entry_date|date_format:'%d/%m/%y'}</td>
|
||||
<td>{$entry.kind}</td>
|
||||
<td>{$entry.equipment_number}</td>
|
||||
<td>{$entry.equipment}</td>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<tbody>
|
||||
{foreach from=$outputs item="output"}
|
||||
<tr>
|
||||
<td>{$output.output_date}</td>
|
||||
<td>{$entry.output_date|date_format:'%d/%m/%y'}</td>
|
||||
<td>{$output.kind}</td>
|
||||
<td>{$output.equipment_number}</td>
|
||||
<td>{$output.equipment}</td>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{if $eqmts}
|
||||
<optgroup label="-- {$cat} --">
|
||||
{foreach from=$eqmts item="eqmt"}
|
||||
<option value="{$eqmt.id}">{$eqmt.designation} - (dispo {$eqmt.available})</option>
|
||||
<option value="{$eqmt.id}">{$eqmt.designation} - (dispo: {$eqmt.available})</option>
|
||||
{/foreach}
|
||||
</optgroup>
|
||||
{/if}
|
||||
|
|
|
@ -44,11 +44,13 @@ if (f('save'))
|
|||
'category_id' => (int) f('category_id'),
|
||||
'designation' => ucfirst(strtolower(f('designation'))),
|
||||
]);
|
||||
$entry_date_format = date_create_from_format(
|
||||
"d/m/Y", f('entry_date'))->format("Y-m-d");
|
||||
$entry->add([
|
||||
'kind' => f('kind'),
|
||||
'equipment_number' => (int) f('equipment_number'),
|
||||
'equipment_id' => $eqmt_id,
|
||||
'entry_date' => f('entry_date'),
|
||||
'entry_date' => $entry_date_format,
|
||||
'additional_comment' => f('additional_comment'),
|
||||
]);
|
||||
Utils::redirect(PLUGIN_URL . 'entrees/index.php');
|
||||
|
|
|
@ -14,11 +14,14 @@ $csrf_key = 'add_entry';
|
|||
|
||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$entry = new Entry;
|
||||
$entry_date_format = date_create_from_format(
|
||||
"d/m/Y", f('entry_date'))->format("Y-m-d");
|
||||
$entry->add([
|
||||
'kind' => f('kind'),
|
||||
'equipment_number' => (int) f('equipment_number'),
|
||||
'equipment_id' => f('equipment_id'),
|
||||
'entry_date' => f('entry_date'),
|
||||
'entry_date' => $entry_date_format,
|
||||
'additional_comment' => f('additional_comment'),
|
||||
]);
|
||||
Utils::redirect(PLUGIN_URL . 'entrees/index.php');
|
||||
|
|
|
@ -15,11 +15,13 @@ if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
|||
if ($form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$entry = new Entry;
|
||||
$entry_date_format = date_create_from_format(
|
||||
"d/m/Y", f('entry_date'))->format("Y-m-d");
|
||||
$entry->add([
|
||||
'kind' => 'Retour de location / prêt',
|
||||
'equipment_number' => (int) f('equipment_number'),
|
||||
'equipment_id' => f('equipment_id'),
|
||||
'entry_date' => f('entry_date'),
|
||||
'entry_date' => $entry_date_format,
|
||||
'additional_comment' => f('additional_comment'),
|
||||
]);
|
||||
Utils::redirect(PLUGIN_URL . 'entrees/index.php');
|
||||
|
|
|
@ -14,6 +14,20 @@ $eqmts_by_cat = $eqmt->GetAvailableListByCategory();
|
|||
|
||||
$csrf_key = 'add_output';
|
||||
|
||||
if (f('save') && $form->check($csrf_key) && !$form->hasErrors())
|
||||
{
|
||||
$output_date_format = date_create_from_format(
|
||||
"d/m/Y", f('entry_date'))->format("Y-m-d");
|
||||
$output->add([
|
||||
'kind' => f('kind'),
|
||||
'equipment_number' => (int) f('equipment_number'),
|
||||
'equipment_id' => f('equipment_id'),
|
||||
'output_date' => $output_date_format,
|
||||
'additional_comment' => f('additional_comment'),
|
||||
]);
|
||||
Utils::redirect(PLUGIN_URL . 'entrees/index.php');
|
||||
}
|
||||
|
||||
$kinds = $output->listKinds();
|
||||
$selected_kind = $kinds[0];
|
||||
|
||||
|
|
Loading…
Reference in New Issue