Merge branch 'add-preorder-filter' into 'master'
Added new Preorder Filter and Filter-Presets See merge request fronk/thetool!957
This commit is contained in:
@@ -8,10 +8,8 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<style>
|
||||
.preorder-campaign-import {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-content: flex-start;
|
||||
.select2-selection.select2-selection--multiple {
|
||||
min-height: calc(1.5em + .9rem + 2px);
|
||||
}
|
||||
|
||||
.preorder-campaign-header, .preorder-campaign-header-buttons {
|
||||
@@ -19,8 +17,23 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.preorder-campaign-import {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.preorder-campaign-header-buttons {
|
||||
max-width: 500px;
|
||||
max-width: 650px;
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 1720px) {
|
||||
.preorder-filters .col-sm-12 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 576px) {
|
||||
@@ -132,7 +145,7 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
<div class="card-body mb-3">
|
||||
<h4 class="header-title mb-3">Filter</h4>
|
||||
|
||||
<form method="get" action="<?=self::getUrl("Preorder")?>">
|
||||
<form method="get" action="<?=self::getUrl("Preorder")?>" class="preorder-filters">
|
||||
<div class="row">
|
||||
|
||||
|
||||
@@ -232,6 +245,16 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
<input type="text" class="form-control" name="filter[magic_search]" id="filter_magic_search" value="<?=$filter['magic_search'] ?? ""?>" />
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-2">
|
||||
<label class="form-label" for="filter_created_from">Zeitraum</label>
|
||||
<select name="filter[created_from]" id="filter_created_from" class="form-control">
|
||||
<option value=""></option>
|
||||
<option value="7" <?=(isset($filter) && array_key_exists("created_from", $filter) && $filter["created_from"] == 7) ? "selected='selected'" : ""?>>7 Tage</option>
|
||||
<option value="14" <?=(isset($filter) && array_key_exists("created_from", $filter) && $filter["created_from"] == 14) ? "selected='selected'" : ""?>>14 Tage</option>
|
||||
<option value="30" <?=(isset($filter) && array_key_exists("created_from", $filter) && $filter["created_from"] == 30) ? "selected='selected'" : ""?>>30 Tage</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row mt-2">
|
||||
@@ -283,7 +306,6 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
<div class="col-sm-12 col-md-2">
|
||||
<label class="form-label" for="filter_rimo_workorder">Rimo Workorder Status</label>
|
||||
<select name="filter[rimo_workorder_status][]" id="filter_rimo_workorder_status" multiple class="form-control">
|
||||
<option value=""></option>
|
||||
<option value="Clarify" <?=(isset($filter) && array_key_exists("rimo_workorder_status", $filter) && is_array($filter['rimo_workorder_status']) && in_array("Clarify", $filter['rimo_workorder_status'])) ? "selected='selected'" : ""?>>Clarify</option>
|
||||
<option value="Accepted" <?=(isset($filter) && array_key_exists("rimo_workorder_status", $filter) && is_array($filter['rimo_workorder_status'])&& in_array("Accepted", $filter['rimo_workorder_status'])) ? "selected='selected'" : ""?>>Accepted</option>
|
||||
<option value="Plan released" <?=(isset($filter) && array_key_exists("rimo_workorder_status", $filter) && is_array($filter['rimo_workorder_status'])&& in_array("Plan released", $filter['rimo_workorder_status'])) ? "selected='selected'" : ""?>>Plan released</option>
|
||||
@@ -304,6 +326,15 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 col-md-2">
|
||||
<label class="form-label" for="filter_preorder_status_flags">Statusflag</label>
|
||||
<select name="filter[preorder_status_flags][]" id="filter_preorder_status_flags" multiple class="form-control">
|
||||
<?php foreach(PreorderStatusflagModel::getAll() as $flag): ?>
|
||||
<option value="<?=$flag->id?>" <?=(isset($filter) && array_key_exists("preorder_status_flags", $filter) && is_array($filter['preorder_status_flags']) && in_array($flag->id, $filter['preorder_status_flags'])) ? "selected='selected'" : ""?>><?=$flag->name?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row mt-2">
|
||||
@@ -317,6 +348,22 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
<?php if(!$me->is("Preorderfront")): ?>
|
||||
<button type="submit" formaction="<?=self::getUrl("Preorder", "export")?>" id="export-button" class="btn btn-outline-success"><i class="fas fa-download"></i> CSV-Export</button>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- i need a dropdown with 2 options beautifull dropdown no select
|
||||
Gelöschte Bestellungen mit Workorder (button with href)
|
||||
Wohnung - Verkabelung erledigt (button with href)
|
||||
-->
|
||||
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-outline-primary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Filter-Presets
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<li><a class="dropdown-item" href="<?=self::getUrl("Preorder", "Index", ["filter" => ["status" => [21,22,23,24,25], "rimo_workorder" => 1, "borderpoint" => "all"]])?>">Gelöschte Bestellungen mit Workorder</a></li>
|
||||
<li><a class="dropdown-item" href="<?=self::getUrl("Preorder", "Index", ["filter" => ["preorder_status_flags" => [4], "connection_type" => ["apartment"], "borderpoint" => "all"]])?>">Wohnung - Verkabelung erledigt</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -474,9 +521,25 @@ $pagination_entity_name = "Vorbestellungen";
|
||||
$("#filter_partner_id").select2({closeOnSelect: false});
|
||||
$("#connection_type_id").select2({closeOnSelect: false});
|
||||
$("#filter_rimo_workorder_status").select2({closeOnSelect: false});
|
||||
$("#filter_preorder_status_flags").select2({closeOnSelect: false});
|
||||
|
||||
var attributes = ["bep_specified", "inhouse_cabling_supplied"];
|
||||
|
||||
$(document).ready(function() {
|
||||
// Toggle dropdown on button click
|
||||
$('.dropdown-toggle').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
$(this).siblings('.dropdown-menu').toggleClass('show');
|
||||
});
|
||||
|
||||
// Close dropdown when clicking outside
|
||||
$(document).on('click', function(e) {
|
||||
if (!$(e.target).closest('.dropdown').length) {
|
||||
$('.dropdown-menu').removeClass('show');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
attributes.forEach(function(attrib) {
|
||||
|
||||
@@ -416,6 +416,7 @@ class PreorderModel {
|
||||
LEFT JOIN `".FRONKDB_DBNAME."`.Preorderstatus tt_preorderstatus ON (tt_preorder.status_id = tt_preorderstatus.id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer as adb_hausnummer ON (tt_preorder.adb_hausnummer_id = adb_hausnummer.hausnummer_id)
|
||||
LEFT JOIN `".ADDRESSDB_DBNAME."`.Wohneinheit as adb_wohneinheit ON (tt_preorder.adb_wohneinheit_id = adb_wohneinheit.id)
|
||||
|
||||
LEFT OUTER JOIN (SELECT adb_wohneinheit_id, count(*) cnt, MAX(rimo_status) as rimo_status, MAX(rimo_name) as rimo_name, MAX(rimo_team_name) as rimo_team_name, MAX(rimo_team_id) as rimo_team_id FROM `".FRONKDB_DBNAME."`.RimoWorkorder GROUP BY adb_wohneinheit_id) workorder ON adb_wohneinheit.id = workorder.adb_wohneinheit_id
|
||||
WHERE $where
|
||||
ORDER BY lastname, firstname
|
||||
@@ -500,6 +501,31 @@ class PreorderModel {
|
||||
$where .= " AND tt_preorder.status_id > $status_id";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("preorder_status_flags", $filter)) {
|
||||
$preorder_status_flags = $filter['preorder_status_flags'];
|
||||
if (is_array($preorder_status_flags) && count($preorder_status_flags)) {
|
||||
$where .= " AND tt_preorder.id IN (
|
||||
SELECT psv.preorder_id
|
||||
FROM `".FRONKDB_DBNAME."`.PreorderStatusflagValue psv
|
||||
WHERE psv.flag_id IN (" . implode(',', $preorder_status_flags) . ")
|
||||
AND psv.value = 1
|
||||
GROUP BY psv.preorder_id
|
||||
HAVING COUNT(DISTINCT psv.flag_id) = " . count($preorder_status_flags) . "
|
||||
)";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("created_from", $filter)) {
|
||||
$created_from = $filter['created_from'];
|
||||
if(is_numeric($created_from)) {
|
||||
// use mysql function for the date (column is unix epoch)
|
||||
$created_from_epoch = time() - $created_from * 86400;
|
||||
// var_dump($created_from_epoch);
|
||||
// die();
|
||||
$where .= " AND FROM_UNIXTIME(tt_preorder.create) >= FROM_UNIXTIME($created_from_epoch)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("status_code", $filter)) {
|
||||
|
||||
Reference in New Issue
Block a user