Merge branch 'fronkdev' into 'master'
WIP Productchange See merge request fronk/thetool!516
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="alert alert-purple">
|
||||
<p>
|
||||
Wählen Sie das neue Produkt aus oder ändern Sie den Preis.<br />
|
||||
Wenn ein <strong>Fertigstellungsdatum</strong> eingetragen wird, wird das alte Produkt am Vortag
|
||||
gekündigt.<br />
|
||||
<strong>Ohne Fertigstellungsdatum</strong> wird das neue Produkt händisch nach der technischen Produktanpassung fertiggestellt.
|
||||
</p>
|
||||
<p>
|
||||
<strong>Verknüpfte Produkte</strong> können beibehalten oder gekündigt werden.<br />
|
||||
Um beim verknüpften Produkt ein Kündigungsdatum einzutragen, muss beim Hauptprodukt ein Fertigstellungsdatum eingetragen sein.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card border-top-purple">
|
||||
<div class="card-body">
|
||||
<h4 class="text-center mb-3">Neuer Contract</h4>
|
||||
@@ -140,7 +157,7 @@
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="billing_delay">Fertigstellungsdatum</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" name="finish_date" id="finish_date" value="" />
|
||||
<input type="text" class="form-control" name="finish_date" id="finish_date" value="" onchange="finishDateChange()" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -356,4 +373,12 @@
|
||||
}
|
||||
//link-<?=$link->id?>-action-cancel
|
||||
}
|
||||
|
||||
function finishDateChange() {
|
||||
$("#link-table input.link-cancel:checked").each(function() {
|
||||
var match = this.id.match(/^link-(\d+)-action/);
|
||||
link_id = match[1];
|
||||
linkActionChange(link_id);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -143,7 +143,7 @@
|
||||
<div class="col-12">
|
||||
<div class="float-right">
|
||||
<a class="btn btn-lg btn-primary mb-2" href="<?=self::getUrl("Order", "add")?>"><i class="fas fa-fw fa-square-plus "></i> Neue Bestellung anlegen</a>
|
||||
<!--a class="btn btn-lg btn-purple mb-2 ml-2" href="<?=self::getUrl("Order", "addUpgrade")?>"><i class="fas fa-fw fa-square-up "></i> Upgrade eingeben</a-->
|
||||
<a class="btn btn-lg btn-purple mb-2 ml-2" href="<?=self::getUrl("Order", "addUpgrade")?>"><i class="fas fa-fw fa-square-up "></i> Upgrade eingeben</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
<?php
|
||||
$urlfilter = [];
|
||||
if($s) {
|
||||
$urlfilter['s'] = $s;
|
||||
}
|
||||
if($noTermProducts) {
|
||||
$urlfilter['noTermProducts'] = 1;
|
||||
}
|
||||
if(isset($filter) && is_array($filter) && count($filter)) {
|
||||
$urlfilter["filter"] = $filter;
|
||||
}
|
||||
$posturl = self::getUrl("Order", "save", $urlfilter);
|
||||
?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Order")?>">Bestellungen</a></li>
|
||||
<li class="breadcrumb-item active">Produktwechsel</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Bestellungen</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
<div class="card no-shadow">
|
||||
<div class="card-body bg-light">
|
||||
<h4 class="mb-2">Produktwechsel</h4>
|
||||
|
||||
<form class="form-horizontal" method="post" action="<?=$posturl?>" name="orderForm" id="orderForm" enctype="multipart/form-data">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6" id="owner-block">
|
||||
|
||||
|
||||
<div class="form-group row">
|
||||
|
||||
<div class="col-lg-12 mb-2">
|
||||
<h4>Vertragsinhaber auswählen</h4>
|
||||
|
||||
<select class="form-control basicAutoComplete" autocomplete="off" name="owner_id" id="owner_id" data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1" placeholder="Tippen zum Suchen... (Bestandskunden)" data-noresults-text="Keine Suchergebnisse">
|
||||
<option></option>
|
||||
</select>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card" id="product-list">
|
||||
<div class="card-body">
|
||||
<table>
|
||||
<thead>
|
||||
<th>Contract ID</th>
|
||||
<th>Produkt</th>
|
||||
<th>Matchcode</th>
|
||||
<th>Preis p.P.</th>
|
||||
<th>Herstellungskosten</th>
|
||||
<th>Fertigstellung</th>
|
||||
<th>Kündigung</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -380,7 +380,7 @@ class ContractController extends mfBaseController
|
||||
if (!$product->id) {
|
||||
$this->layout()->setFlash("Produkt nicht gefunden", "error");
|
||||
if($f == "o") {
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id, "f" => $f]);
|
||||
$this->redirect("Order", "productchange", ["contract_id" => $id]);
|
||||
} else {
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||
}
|
||||
@@ -397,7 +397,7 @@ class ContractController extends mfBaseController
|
||||
} catch (Exception $e) {
|
||||
$this->layout()->setFlash("Ungültiges Kündigungsdateum", "error");
|
||||
if($f == "o") {
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id, "f" => $f]);
|
||||
$this->redirect("Order", "productchange", ["contract_id" => $id]);
|
||||
} else {
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||
}
|
||||
@@ -420,7 +420,7 @@ class ContractController extends mfBaseController
|
||||
if (!$contract_data['termination_id'] || !$termination->id) {
|
||||
$this->layout()->setFlash("Produkt erfordert Anschluss.", "error");
|
||||
if($f == "o") {
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id, "f" => $f]);
|
||||
$this->redirect("Order", "productchange", ["contract_id" => $id]);
|
||||
} else {
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||
}
|
||||
@@ -435,7 +435,11 @@ class ContractController extends mfBaseController
|
||||
|
||||
if (!$new_contract_id) {
|
||||
$this->layout()->setFlash("Neuer Contract konnte nicht gespeichert werden", "error");
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||
if($f == "o") {
|
||||
$this->redirect("Order", "productchange", ["contract_id" => $id]);
|
||||
} else {
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||
}
|
||||
}
|
||||
|
||||
if($contract_cancel_date) {
|
||||
@@ -459,9 +463,9 @@ class ContractController extends mfBaseController
|
||||
try {
|
||||
$cancel_date = DateTime::createFromFormat("d.m.Y", $link_data["cancel_date"], new DateTimeZone("Europe/Vienna"));
|
||||
} catch (Exception $e) {
|
||||
$this->layout()->setFlash("Ungültiges Kündigungsdateum", "error");
|
||||
$this->layout()->setFlash("Ungültiges Kündigungsdatum", "error");
|
||||
if($f == "o") {
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id, "f" => $f]);
|
||||
$this->redirect("Order", "productchange", ["contract_id" => $id]);
|
||||
} else {
|
||||
$this->redirect("Contract", "productchange", ["contract_id" => $id]);
|
||||
}
|
||||
@@ -589,7 +593,7 @@ class ContractController extends mfBaseController
|
||||
$this->layout()->setFlash("Konnte Verknüpfung nicht speichern", "warn");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Neuer Contract erfolgreich erstellt", "success");
|
||||
$this->layout()->setFlash("Produktwechsel erfolgreich erstellt", "success");
|
||||
if($f == "o") {
|
||||
$this->redirect("Order");
|
||||
} else {
|
||||
|
||||
@@ -93,6 +93,63 @@ class ContractLinkModel {
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function countWithContracts($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) as cnt FROM ContractLink
|
||||
LEFT JOIN Contract ON (ContractLink.contract_id = Contract.id)
|
||||
LEFT JOIN Address AS Owner ON (Contract.owner_id = Owner.id)
|
||||
LEFT JOIN Worker ON (ContractLink.create_by = Worker.id)
|
||||
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
||||
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
||||
WHERE $where
|
||||
";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
return $data->cnt;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static function searchWithContracts($filter, $limit = false) {
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT ContractLink.* FROM ContractLink
|
||||
LEFT JOIN Contract ON (ContractLink.contract_id = Contract.id)
|
||||
LEFT JOIN Address AS Owner ON (Contract.owner_id = Owner.id)
|
||||
LEFT JOIN Worker ON (ContractLink.create_by = Worker.id)
|
||||
LEFT JOIN OrderProduct ON (Contract.orderproduct_id = OrderProduct.id)
|
||||
LEFT JOIN `Order` ON (OrderProduct.order_id = `Order`.id)
|
||||
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
||||
WHERE $where
|
||||
ORDER BY Contract.`create`,Contract.id";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
while($data = $db->fetch_object($res)) {
|
||||
$items[$data->id] = new ContractLink($data);
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function count($filter) {
|
||||
$db = FronkDB::singleton();
|
||||
@@ -109,7 +166,7 @@ class ContractLinkModel {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public static function search($filter, $limit = false) {
|
||||
//var_dump($filter);exit;
|
||||
$items = [];
|
||||
@@ -123,7 +180,7 @@ class ContractLinkModel {
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
@@ -171,9 +228,96 @@ class ContractLinkModel {
|
||||
$where .= " AND ContractLink.type = '$type'";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(array_key_exists("price<", $filter)) {
|
||||
$price = $filter['price<'];
|
||||
if(is_numeric($price)) {
|
||||
$where .= " AND Contract.price < $price";
|
||||
}
|
||||
}
|
||||
if(array_key_exists("price<=", $filter)) {
|
||||
$price = $filter['price<='];
|
||||
if(is_numeric($price)) {
|
||||
$where .= " AND Contract.price <= $price";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("price>", $filter)) {
|
||||
$price = $filter['price>'];
|
||||
if(is_numeric($price)) {
|
||||
$where .= " AND Contract.price > $price";
|
||||
}
|
||||
}
|
||||
if(array_key_exists("price>=", $filter)) {
|
||||
$price = $filter['price>='];
|
||||
if(is_numeric($price)) {
|
||||
$where .= " AND Contract.price >= $price";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date", $filter)) {
|
||||
$finish_date = $filter['finish_date'];
|
||||
if(is_numeric($finish_date)) {
|
||||
$where .= " AND Contract.finish_date = $finish_date";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date>", $filter)) {
|
||||
$finish_date = $filter['finish_date>'];
|
||||
if(is_numeric($finish_date)) {
|
||||
$where .= " AND Contract.finish_date >= $finish_date";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date_null_or_gte", $filter)) {
|
||||
$finish_date = $filter['finish_date_null_or_gte'];
|
||||
if(is_numeric($finish_date)) {
|
||||
$where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date >= $finish_date)";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date<", $filter)) {
|
||||
$finish_date = $filter['finish_date<'];
|
||||
if(is_numeric($finish_date)) {
|
||||
$where .= " AND Contract.finish_date <= $finish_date";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("finish_date_null_or_lte", $filter)) {
|
||||
$finish_date = $filter['finish_date_null_or_lte'];
|
||||
if(is_numeric($finish_date)) {
|
||||
$where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date <= $finish_date)";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("cancel_date>", $filter)) {
|
||||
$cancel_date = $filter['cancel_date>'];
|
||||
if(is_numeric($cancel_date)) {
|
||||
$where .= " AND Contract.cancel_date >= $cancel_date";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("cancel_date_null_or_gte", $filter)) {
|
||||
$cancel_date = $filter['cancel_date_null_or_gte'];
|
||||
if(is_numeric($cancel_date)) {
|
||||
$where .= " AND (Contract.cancel_date IS NULL OR Contract.cancel_date >= $cancel_date)";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("cancel_date<", $filter)) {
|
||||
$cancel_date = $filter['cancel_date<'];
|
||||
if(is_numeric($cancel_date)) {
|
||||
$where .= " AND Contract.cancel_date <= $cancel_date";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("cancel_date_null_or_lte", $filter)) {
|
||||
$cancel_date = $filter['cancel_date_null_or_lte'];
|
||||
if(is_numeric($cancel_date)) {
|
||||
$where .= " AND (Contract.cancel_date IS NULL OR Contract.cancel_date <= $cancel_date)";
|
||||
}
|
||||
}
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
|
||||
@@ -427,10 +427,6 @@ class OrderController extends mfBaseController {
|
||||
return $this->addAction();
|
||||
}
|
||||
|
||||
protected function upgradesAction() {
|
||||
|
||||
}
|
||||
|
||||
protected function setwaitingAction() {
|
||||
$order_id = $this->request->id;
|
||||
$order = new Order($order_id);
|
||||
@@ -462,6 +458,41 @@ class OrderController extends mfBaseController {
|
||||
$this->redirect("Order","Index", $qs);
|
||||
}
|
||||
|
||||
protected function upgradesAction() {
|
||||
$this->layout()->setTemplate("Order/Upgrades");
|
||||
|
||||
$rfilter = $this->request->filter;
|
||||
if(!$rfilter) {
|
||||
$rfilter = [];
|
||||
}
|
||||
|
||||
$this->layout->set("filter", $rfilter);
|
||||
$filter = $this->getPreparedFilter($this->request->filter);
|
||||
|
||||
// pagination defaults
|
||||
$pagination = [];
|
||||
$pagination['start'] = 0;
|
||||
$pagination['count'] = 20;
|
||||
$pagination['maxItems'] = 0;
|
||||
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
|
||||
$upgrade_search = [
|
||||
"type" => "upgrade",
|
||||
"contract_creator_address_id" => $this->me->address_id,
|
||||
"finish_date_null_or_gte" => date("U"),
|
||||
"price>=" => 0
|
||||
];
|
||||
|
||||
|
||||
$pagination["maxItems"] = ContractLinkModel::countWithContracts($upgrade_search);
|
||||
|
||||
$upgrades = ContractLinkModel::searchWithContracts($upgrade_search, $pagination);
|
||||
$this->layout()->set("upgrades", $upgrades);
|
||||
$this->layout()->set("pagination", $pagination);
|
||||
}
|
||||
protected function addUpgrade() {
|
||||
//$this->layout()->setTemplate("Order/Productchange");
|
||||
Helper::renderVue($this, "OrderProductchange", "Neuer Produktwechsel", ["CONTRACT_API_URL" => $this->getUrl("Contract", "api"),
|
||||
|
||||
Reference in New Issue
Block a user