remove {} in all db requests strings, replace them with '?, '
This commit is contained in:
parent
4518f43532
commit
a6916e7e4b
@ -22,7 +22,7 @@ class Category
|
|||||||
public function delete($id)
|
public function delete($id)
|
||||||
// delete a specific category
|
// delete a specific category
|
||||||
{
|
{
|
||||||
DB::getInstance()->delete('plugin_materiels_category', 'id = ' . $id);
|
DB::getInstance()->delete('plugin_materiels_category', 'id = ?', $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get($id)
|
public function get($id)
|
||||||
|
@ -31,7 +31,7 @@ class Equipment
|
|||||||
public function delete($id)
|
public function delete($id)
|
||||||
// delete a specific equipment
|
// delete a specific equipment
|
||||||
{
|
{
|
||||||
DB::getInstance()->delete('plugin_materiels_equipment', 'id = ' . $id);
|
DB::getInstance()->delete('plugin_materiels_equipment', 'id = ?', $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listAllByCategory()
|
public function listAllByCategory()
|
||||||
@ -184,11 +184,11 @@ class Equipment
|
|||||||
$entries = DB::getInstance()->firstColumn(
|
$entries = DB::getInstance()->firstColumn(
|
||||||
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '0' AND kind IN (
|
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '0' AND kind IN (
|
||||||
'Achat', 'Don', 'Récupération',
|
'Achat', 'Don', 'Récupération',
|
||||||
'Retour de location / prêt') AND equipment_id = '{$id}' AND mvt_date <= '{$date}';");
|
'Retour de location / prêt') AND equipment_id = ? AND mvt_date <= ?;", $id, $date);
|
||||||
$outputs = DB::getInstance()->firstColumn(
|
$outputs = DB::getInstance()->firstColumn(
|
||||||
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '1' AND kind IN (
|
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '1' AND kind IN (
|
||||||
'Vente', 'Don', 'Besoin', 'Autre (perte, vol, ...)',
|
'Vente', 'Don', 'Besoin', 'Autre (perte, vol, ...)',
|
||||||
'Location / Prêt') AND equipment_id = '{$id}' AND mvt_date <= '{$date}';");
|
'Location / Prêt') AND equipment_id = ? AND mvt_date <= ?;", $id, $date);
|
||||||
return $entries - $outputs;
|
return $entries - $outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,9 +222,9 @@ class Equipment
|
|||||||
// return number of a specific equipment is out at a specific date
|
// return number of a specific equipment is out at a specific date
|
||||||
{
|
{
|
||||||
$entries = DB::getInstance()->firstColumn(
|
$entries = DB::getInstance()->firstColumn(
|
||||||
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '0' AND kind = 'Retour de location / prêt' AND equipment_id = '{$id}' AND mvt_date <= '{$date}';");
|
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '0' AND kind = 'Retour de location / prêt' AND equipment_id = ? AND mvt_date <= ?;", $id, $date);
|
||||||
$outputs = DB::getInstance()->firstColumn(
|
$outputs = DB::getInstance()->firstColumn(
|
||||||
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '1' AND kind = 'Location / Prêt' AND equipment_id = '{$id}' AND mvt_date <= '{$date}';");
|
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '1' AND kind = 'Location / Prêt' AND equipment_id = ? AND mvt_date <= ?;", $id, $date);
|
||||||
return $outputs - $entries;
|
return $outputs - $entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,9 +258,9 @@ class Equipment
|
|||||||
// return the number of equipments no owned at a specific date
|
// return the number of equipments no owned at a specific date
|
||||||
{
|
{
|
||||||
$entries = DB::getInstance()->firstColumn(
|
$entries = DB::getInstance()->firstColumn(
|
||||||
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '0' AND kind = 'Location / Prêt' AND equipment_id = '{$id}' AND mvt_date <= '{$date}';");
|
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '0' AND kind = 'Location / Prêt' AND equipment_id = ? AND mvt_date <= ?;", $id, $date);
|
||||||
$outputs = DB::getInstance()->firstColumn(
|
$outputs = DB::getInstance()->firstColumn(
|
||||||
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '1' AND kind = 'Retour de location / prêt' AND equipment_id = '{$id}' AND mvt_date <= '{$date}';");
|
"SELECT sum(equipment_number) FROM plugin_materiels_movement WHERE side = '1' AND kind = 'Retour de location / prêt' AND equipment_id = ? AND mvt_date <= ?;", $id, $date);
|
||||||
return $entries - $outputs;
|
return $entries - $outputs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ class Movement
|
|||||||
public function delete($id)
|
public function delete($id)
|
||||||
// delete specific movement
|
// delete specific movement
|
||||||
{
|
{
|
||||||
DB::getInstance()->delete('plugin_materiels_movement', 'id = ' . $id);
|
DB::getInstance()->delete('plugin_materiels_movement', 'id = ?', $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function listEntryKinds()
|
public function listEntryKinds()
|
||||||
@ -51,7 +51,7 @@ class Movement
|
|||||||
public function listAllOneSide($side)
|
public function listAllOneSide($side)
|
||||||
// return all entries if side is 0 or all outputs if side is 1 ordered by date
|
// return all entries if side is 0 or all outputs if side is 1 ordered by date
|
||||||
{
|
{
|
||||||
$mvts = DB::getInstance()->get("SELECT * FROM plugin_materiels_movement WHERE side = '{$side}' ORDER BY mvt_date DESC;");
|
$mvts = DB::getInstance()->get("SELECT * FROM plugin_materiels_movement WHERE side = ? ORDER BY mvt_date DESC;", $side);
|
||||||
// for each movements get the equipment's designation
|
// for each movements get the equipment's designation
|
||||||
$eqmt = new Equipment;
|
$eqmt = new Equipment;
|
||||||
foreach ($mvts as $key => $value) {
|
foreach ($mvts as $key => $value) {
|
||||||
@ -68,7 +68,7 @@ class Movement
|
|||||||
{
|
{
|
||||||
// get all entry dates after the specific date and make a list with its
|
// get all entry dates after the specific date and make a list with its
|
||||||
$after_entry_dates = DB::getInstance()->get(
|
$after_entry_dates = DB::getInstance()->get(
|
||||||
"SELECT mvt_date FROM plugin_materiels_movement WHERE side = '0' AND kind = 'Retour de location / prêt' AND equipment_id = '{$id}' AND mvt_date > '{$date}';");
|
"SELECT mvt_date FROM plugin_materiels_movement WHERE side = '0' AND kind = 'Retour de location / prêt' AND equipment_id = ? AND mvt_date > ?;", $id, $date);
|
||||||
$entry_dates = array($date);
|
$entry_dates = array($date);
|
||||||
foreach ($after_entry_dates as $row)
|
foreach ($after_entry_dates as $row)
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ class Movement
|
|||||||
$after_output_dates = DB::getInstance()->get(
|
$after_output_dates = DB::getInstance()->get(
|
||||||
"SELECT mvt_date FROM plugin_materiels_movement WHERE side = '1' AND kind IN (
|
"SELECT mvt_date FROM plugin_materiels_movement WHERE side = '1' AND kind IN (
|
||||||
'Vente', 'Don', 'Besoin', 'Autre (perte, vol, ...)',
|
'Vente', 'Don', 'Besoin', 'Autre (perte, vol, ...)',
|
||||||
'Location / Prêt') AND equipment_id = '{$id}' AND mvt_date > '{$date}';");
|
'Location / Prêt') AND equipment_id = ? AND mvt_date > ?;", $id, $date);
|
||||||
$output_dates = array($date);
|
$output_dates = array($date);
|
||||||
foreach ($after_output_dates as $row)
|
foreach ($after_output_dates as $row)
|
||||||
{
|
{
|
||||||
@ -124,7 +124,7 @@ class Movement
|
|||||||
{
|
{
|
||||||
// get all output dates after the specific date and make a list with its
|
// get all output dates after the specific date and make a list with its
|
||||||
$after_output_dates = DB::getInstance()->get(
|
$after_output_dates = DB::getInstance()->get(
|
||||||
"SELECT mvt_date FROM plugin_materiels_movement WHERE side = '1' AND kind = 'Retour de location / prêt' AND equipment_id = '{$id}' AND mvt_date > '{$date}';");
|
"SELECT mvt_date FROM plugin_materiels_movement WHERE side = '1' AND kind = 'Retour de location / prêt' AND equipment_id = ? AND mvt_date > ?;", $id, $date);
|
||||||
$output_dates = array($date);
|
$output_dates = array($date);
|
||||||
foreach ($after_output_dates as $row)
|
foreach ($after_output_dates as $row)
|
||||||
{
|
{
|
||||||
@ -170,11 +170,11 @@ class Movement
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function AllEqmtMovements($eqmt_id)
|
public function AllEqmtMovements($eqmt_id)
|
||||||
// return list of all movements for a specific equipments
|
// return list of all movements for a specific equipment
|
||||||
// ordered by date and side
|
// ordered by date and side
|
||||||
// if same date order by rent output and after put entry for return
|
// if same date order by rent output and after put entry for return
|
||||||
{
|
{
|
||||||
return DB::getInstance()->get(
|
return DB::getInstance()->get(
|
||||||
"SELECT * FROM plugin_materiels_movement WHERE equipment_id = '{$eqmt_id}' ORDER BY mvt_date DESC, CASE WHEN (side = '1' AND kind = 'Location / Prêt') THEN 1 WHEN (side = '0' AND kind != 'Retour de location / prêt') THEN 2 ELSE 0 END, side DESC;");
|
"SELECT * FROM plugin_materiels_movement WHERE equipment_id = ? ORDER BY mvt_date DESC, CASE WHEN (side = '1' AND kind = 'Location / Prêt') THEN 1 WHEN (side = '0' AND kind != 'Retour de location / prêt') THEN 2 ELSE 0 END, side DESC;", $eqmt_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,6 @@
|
|||||||
{foreach from=$eqmts_just_listed item="eqmt"}
|
{foreach from=$eqmts_just_listed item="eqmt"}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{$eqmt.designation}</td>
|
<td>{$eqmt.designation}</td>
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user