Filter and pagination is still set after saving Order
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
<?php foreach($contracts as $contract): ?>
|
||||
<tr>
|
||||
<td><a href="<?=self::getUrl("Address", "Edit", ["id" => $contract->owner_id])?>" target="_blank"><?=$contract->owner->getCompanyOrName()?></a></td>
|
||||
<td><?=$contract->product->name?></td>
|
||||
<td><?=$contract->product->product->name?></td>
|
||||
<td>
|
||||
<?php if($contract->termination_id): ?>
|
||||
<?=$contract->termination->building->street?><br />
|
||||
|
||||
@@ -32,7 +32,11 @@
|
||||
<form method="post" action="<?=$this->getUrl("User","save")?>">
|
||||
|
||||
<?php if(is_array($group->items) && count($group->items)): ?>
|
||||
<?php foreach($group->items as $item): ?>
|
||||
<?php $i = 0; foreach($group->items as $item): ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<div class="p-2 <?=($i % 2 == 0) ? "bg-light" : ""?>">
|
||||
<div class="row">
|
||||
@@ -40,7 +44,7 @@
|
||||
<h4 class="header-title">Attribut <span class="text-monospace text-pink"><?=$item->name?></span></h4>
|
||||
</div>
|
||||
<div class="col-md-1 float-right">
|
||||
<small><a class="text-danger" href="<?=self::getUrl("ProducttechAttribute", "delete", ['id' => $item->id])?>" onclick="if(!confirm('Attribut wirklich löschen?')) return false;"><i class="fas fa-trash-alt"></i> löschen</a></small>
|
||||
<small><a class="text-danger" href="<?=self::getUrl("Contractconfig", "delete", ['id' => $item->id])?>" onclick="if(!confirm('Attribut wirklich löschen?')) return false;"><i class="fas fa-trash-alt"></i> löschen</a></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -93,8 +97,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php endforeach; ?>
|
||||
<?php $i++; endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
@@ -1,6 +1,17 @@
|
||||
<?php
|
||||
//var_dump($order);exit;
|
||||
$includes_external_product = false;
|
||||
|
||||
$urlfilter = [];
|
||||
if($s) {
|
||||
$urlfilter['s'] = $s;
|
||||
}
|
||||
if($noTermProducts) {
|
||||
$urlfilter['noTermProducts'] = 1;
|
||||
}
|
||||
if(is_array($filter) && count($filter)) {
|
||||
$urlfilter["filter"] = $filter;
|
||||
}
|
||||
$posturl = self::getUrl("Order", "save", $urlfilter);
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
@@ -34,7 +45,7 @@
|
||||
<div class="card-body">
|
||||
<h4 class="mb-2"><?=($order->id) ? "Bestellung bearbeiten" : "Neue Bestellung"?></h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=self::getUrl("Order", "save")?>" name="orderForm" id="orderForm" enctype="multipart/form-data">
|
||||
<form class="form-horizontal" method="post" action="<?=$posturl?>" name="orderForm" id="orderForm" enctype="multipart/form-data">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
@@ -141,10 +141,16 @@
|
||||
|
||||
<ul class="nav nav-tabs ml-1 border-0" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link <?=(!$showLonelies) ? "active" : ""?>" href="<?=self::getUrl("Order", "Index", ["filter" => $filter])?>">Bestellungen mit Anschluss</a>
|
||||
<a class="nav-link <?=(!$showLonelies) ? "active" : ""?>" href="<?=self::getUrl("Order", "Index", ["filter" => $filter])?>">Bestellungen mit Anschluss<?php if(is_array($lonelyOrders)): ?> <span class="counter"><?=$pagination['maxItems']?></span><?php endif; ?></a>
|
||||
</li>
|
||||
<li class="nav-item" role="presentation">
|
||||
<a class="nav-link <?=($showLonelies) ? "active" : ""?>" href="<?=self::getUrl("Order", "Index", ["noTermProducts" => 1, "filter" => $filter])?>">Bestellungen ohne Anschluss</a>
|
||||
<a class="nav-link <?=($showLonelies) ? "active" : ""?>" href="<?=self::getUrl("Order", "Index", ["noTermProducts" => 1, "filter" => $filter])?>">
|
||||
<?php if(is_array($lonelyOrders)): ?>
|
||||
Bestellungen ohne Anschluss <span class="counter"><?=count($lonelyOrders)?></span>
|
||||
<?php else: ?>
|
||||
Bestellungen ohne Anschluss
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<?php if($showLonelies): ?>
|
||||
@@ -234,7 +240,7 @@
|
||||
<?php endif; ?>
|
||||
<a href="<?=self::getUrl("Order", "downloadServicePin", ["id" => $order->id])?>"><i class="fas fa-file-alt" title="Service PIN als PDF herunterladen"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "sendServicePin", ["id" => $order->id])?>" onclick="if(!confirm('Soll der Service-PIN an den Vertragsinhaber gesendet werden?')) return false;"><i class="fas fa-paper-plane" title="Service PIN als PDF per Email an Vertragsinhaber"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "edit", ["id" => $order->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "edit", ["id" => $order->id, "filter" => $filter, "noTermProducts" => 1])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "delete", ["id" => $order->id])?>" onclick="if(!confirm('Bestellung wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -255,7 +261,7 @@
|
||||
<div class="row justify-content-center mt-2">
|
||||
<div class="col-xl-8 col-lg-12">
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<ul class="nav nav-tabs order-tab">
|
||||
<li class="nav-item"><a class="nav-link active" href="#order-detail-<?=$order->id?>-journal" data-toggle="tab" aria-expanded="false">Journal</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#order-detail-<?=$order->id?>-contact" data-toggle="tab" aria-expanded="false">Kontakt</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#order-detail-<?=$order->id?>-details" data-toggle="tab" aria-expanded="false">Details</a></li>
|
||||
@@ -535,7 +541,7 @@
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<i>Keine anschlusslosen Bestellungen zu den Suchkriterien gefunden</i>
|
||||
<i>Keine <strong>anschlusslosen</strong> Bestellungen zu den Suchkriterien gefunden</i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -544,11 +550,10 @@
|
||||
<?php else: ?>
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
|
||||
<?php if(count($orders)): ?>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th></th>
|
||||
@@ -647,7 +652,7 @@
|
||||
<?php endif; ?>
|
||||
<a href="<?=self::getUrl("Order", "downloadServicePin", ["id" => $order->id])?>"><i class="fas fa-file-alt" title="Service PIN als PDF herunterladen"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "sendServicePin", ["id" => $order->id])?>" onclick="if(!confirm('Soll der Service-PIN an den Vertragsinhaber gesendet werden?')) return false;"><i class="fas fa-paper-plane" title="Service PIN als PDF per Email an Vertragsinhaber"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "edit", ["id" => $order->id])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "edit", ["id" => $order->id, "filter" => $filter, "s" => $pagination['start']])?>"><i class="far fa-edit" title="Bearbeiten"></i></a>
|
||||
<a href="<?=self::getUrl("Order", "delete", ["id" => $order->id])?>" onclick="if(!confirm('Bestellung wirklich löschen?')) return false;" class="text-danger" title="Löschen"><i class="fas fa-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -677,7 +682,7 @@
|
||||
<div class="row justify-content-center mt-2">
|
||||
<div class="col-xl-8 col-lg-12">
|
||||
|
||||
<ul class="nav nav-tabs">
|
||||
<ul class="nav nav-tabs order-tab">
|
||||
<li class="nav-item"><a class="nav-link active" href="#order-detail-<?=$order->id?>-journal" data-toggle="tab" aria-expanded="false">Journal</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#order-detail-<?=$order->id?>-contact" data-toggle="tab" aria-expanded="false">Kontakt</a></li>
|
||||
<li class="nav-item"><a class="nav-link" href="#order-detail-<?=$order->id?>-details" data-toggle="tab" aria-expanded="false">Details</a></li>
|
||||
@@ -967,6 +972,9 @@
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
|
||||
<?php else: ?>
|
||||
<i>Keine Bestellungen <strong>mit Anschluss</strong> zu den Suchkriterien gefunden</i>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -996,7 +1004,13 @@
|
||||
toggleOrder(order);
|
||||
//$('body').scrollTop($('#order-' + order).offset() - 50);
|
||||
scrollToDiv('#order-' + order);
|
||||
|
||||
if(hash.match(/order=(\d+)-details/)) {
|
||||
$('.order-tab a[href="#order-detail-' + order + '-details"]').tab('show');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ class Contract extends mfBaseModel {
|
||||
private $owner;
|
||||
private $creator;
|
||||
private $product;
|
||||
private $orderproduct;
|
||||
private $termination;
|
||||
private $sla;
|
||||
private $editor;
|
||||
@@ -39,16 +40,27 @@ class Contract extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "product") {
|
||||
$this->product = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderproduct_id);
|
||||
$this->product = mfValuecache::singleton()->get("mfObjectmodel-Product-".$this->product_id);
|
||||
if($this->product === null) {
|
||||
$this->product = new OrderProduct($this->orderproduct_id);
|
||||
$this->product = new Product($this->product_id);
|
||||
if($this->product->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderproduct_id, $this->product);
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Product-".$this->product_id, $this->product);
|
||||
}
|
||||
}
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
if($name == "orderproduct") {
|
||||
$this->orderproduct = mfValuecache::singleton()->get("mfObjectmodel-OrderProduct-".$this->orderorderproduct_id);
|
||||
if($this->orderproduct === null) {
|
||||
$this->orderproduct = new OrderProduct($this->orderorderproduct_id);
|
||||
if($this->orderproduct->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-OrderProduct-".$this->orderorderproduct_id, $this->orderproduct);
|
||||
}
|
||||
}
|
||||
return $this->orderproduct;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$this->creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
if($this->creator === null) {
|
||||
|
||||
@@ -112,7 +112,7 @@ class OrderController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
if(!$showLonelies) {
|
||||
//if(!$showLonelies) {
|
||||
//var_dump($order_search);exit;
|
||||
$pagination['maxItems'] = OrderModel::count($order_search);
|
||||
foreach(OrderModel::search($order_search, $pagination) as $order) {
|
||||
@@ -120,9 +120,17 @@ class OrderController extends mfBaseController {
|
||||
$orders[$order->id] = $order;
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
$showLoneliesCount = false;
|
||||
foreach(["owner", "owner_address", "partner_number", "finish_date"] as $key) {
|
||||
if(array_key_exists($key, $filter) && $filter[$key]) {
|
||||
$showLoneliesCount = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($showLonelies) {
|
||||
|
||||
if($showLonelies || $showLoneliesCount) {
|
||||
$userIds = $this->me->getAddressOrParent()->getUserIds();
|
||||
//var_dump($userIds);exit;
|
||||
if(!array_key_exists("network_linked_status", $order_search)) {
|
||||
@@ -265,10 +273,13 @@ class OrderController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function addAction() {
|
||||
//var_dump($this->request->filter);exit;
|
||||
|
||||
|
||||
// TODO: filter by network permissions
|
||||
$this->layout()->setTemplate("Order/Form");
|
||||
if($this->me->is("Admin")) {
|
||||
$this->layout()->set("addresses", AddressModel::search(['parents_only' => 1]));
|
||||
//$this->layout()->set("addresses", AddressModel::search(['parents_only' => 1]));
|
||||
$this->layout()->set("products", ProductModel::getAll());
|
||||
$this->layout()->set("terminations", TerminationModel::getAll());
|
||||
} else {
|
||||
@@ -280,17 +291,18 @@ class OrderController extends mfBaseController {
|
||||
$users = [];
|
||||
foreach($this->me->my_networks as $network) {
|
||||
$network_ids[] = $network->id;
|
||||
$tmp_users = $network->getAddressUsersByAddresstype("salespartner");
|
||||
/*$tmp_users = $network->getAddressUsersByAddresstype("salespartner");
|
||||
foreach($tmp_users as $user) {
|
||||
if(!in_array($user->id, $users)) {
|
||||
$users[] = $user->id;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
/*
|
||||
// get addresses from salespartner address' user ids
|
||||
$addresses = AddressModel::search(["create_by" => $users]);
|
||||
$this->layout()->set("addresses", $addresses);
|
||||
|
||||
*/
|
||||
// get terminations in my networks
|
||||
$terms = TerminationModel::search(["network_id" => $network_ids]);
|
||||
$this->layout()->set("terminations", $terms);
|
||||
@@ -305,6 +317,15 @@ class OrderController extends mfBaseController {
|
||||
|
||||
}
|
||||
|
||||
if($this->request->filter) {
|
||||
$this->layout()->set("filter", $this->request->filter);
|
||||
}
|
||||
if($this->request->noTermProducts) {
|
||||
$this->layout()->set("noTermProducts", $this->request->noTermProducts);
|
||||
}
|
||||
if($this->request->s) {
|
||||
$this->layout()->set("s", $this->request->s);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -366,18 +387,12 @@ class OrderController extends mfBaseController {
|
||||
$this->layout()->setFlash("Bestellung nicht gefunden", "error");
|
||||
$this->redirect("Order");
|
||||
}
|
||||
|
||||
// refuse to save if there is a contract already
|
||||
|
||||
if($order->finish_date && is_array($order->contracts) && count($order->contracts)) {
|
||||
$this->layout()->setFlash("Bestellung kann nicht mehr bearbeitet werden, da sie bereits abgeschlossen und in Verrechnung ist.", "error");
|
||||
$this->redirect("Order", "edit", ['id' => $order->id]);
|
||||
}
|
||||
/*foreach($order->products as $p) {
|
||||
if($p->contract && $p->contract->id) {
|
||||
$this->layout()->setFlash("Bestellung kann nicht mehr bearbeitet werden, da sie bereits abgeschlossen und in Verrechnung ist.", "error");
|
||||
$this->redirect("Order", "edit", ['id' => $order->id]);
|
||||
}
|
||||
}*/
|
||||
} else {
|
||||
$id = false;
|
||||
$mode = "add";
|
||||
@@ -385,12 +400,6 @@ class OrderController extends mfBaseController {
|
||||
|
||||
// validate owner
|
||||
$owner = false;
|
||||
/*if(!$r->owner_id) {
|
||||
$this->layout()->setFlash("Bitte Vertragsinhaber auswählen oder eintragen.", "error");
|
||||
$this->layout()->set("order", $r);
|
||||
return $this->add();
|
||||
}*/
|
||||
|
||||
$owner_new = false;
|
||||
|
||||
if(is_numeric($r->owner_id) && $r->owner_id > 0) {
|
||||
@@ -415,11 +424,7 @@ class OrderController extends mfBaseController {
|
||||
return $this->add();
|
||||
}
|
||||
}
|
||||
}/* else {
|
||||
$this->layout()->setFlash("Ungültiger Vertragsinhaber.");
|
||||
$this->layout()->set("order", $r);
|
||||
return $this->add();
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
// validate billindaddress
|
||||
@@ -456,11 +461,7 @@ class OrderController extends mfBaseController {
|
||||
return $this->add();
|
||||
}
|
||||
}
|
||||
} /*else {
|
||||
$this->layout()->setFlash("Ungültiger Rechnungsempfänger.");
|
||||
$this->layout()->set("order", $r);
|
||||
return $this->add();
|
||||
}*/
|
||||
}
|
||||
|
||||
// validate sepa
|
||||
if(!$r->billing_type) {
|
||||
@@ -873,8 +874,23 @@ class OrderController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sq = "";
|
||||
$query = [];
|
||||
if($r->s) {
|
||||
$query['s'] = $r->s;
|
||||
}
|
||||
if($r->noTermProducts) {
|
||||
$query["noTermProducts"] = $r->noTermProducts;
|
||||
}
|
||||
if($r->filter) {
|
||||
$query["filter"] = $r->filter;
|
||||
}
|
||||
|
||||
$qs = http_build_query($query);
|
||||
|
||||
$this->layout()->setFlash("Bestellung erfolgreich gespeichert.", "success");
|
||||
$this->redirect("Order", "edit", ["id" => $new_id]);
|
||||
$this->redirect("Order", "Index", $qs, "order=$new_id-details");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -404,3 +404,16 @@ td.controls {
|
||||
.pointer {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
.counter {
|
||||
vertical-align: super;
|
||||
font-size: .75em;
|
||||
color: #fff;
|
||||
background-color: tomato;
|
||||
padding-left: 4px;
|
||||
padding-right: 4px;
|
||||
padding-top: 1px;
|
||||
padding-bottom: 1px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user