Merge branch 'fronkdev' of code.fronk.at:fronk/thetool into fronkdev

This commit is contained in:
Frank Schubert
2024-07-31 11:29:20 +02:00
18 changed files with 603 additions and 41 deletions

View File

@@ -118,6 +118,18 @@
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="sla_id">SLA</label>
<div class="col-lg-10">
<select class="form-control" name="sla_id" id="sla_id">
<?php foreach(SlaModel::getAll("name DESC") as $sla): ?>
<option value="<?=$sla->id?>" <?=($contract && $contract->sla_id == $sla->id) ? "selected='selected'" : ""?>><?=$sla->name?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="vatgroup_id">Umsatzsteuergruppe</label>
<div class="col-lg-10">
@@ -177,7 +189,7 @@
<hr />
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="order_date">Bestelldatum</label>
<label class="col-lg-2 col-form-label" for="order_date">Bestelldatum *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="order_date" id="order_date" value="<?=($contract->order_date) ? date("d.m.Y",$contract->order_date) : ""?>">
</div>
@@ -312,6 +324,14 @@
todayBtn: 'linked',
autoclose: true
});
$('#order_date').datepicker({
language: 'de',
format: "dd.mm.yyyy",
showWeekDays: true,
todayBtn: 'linked',
autoclose: true
});
$(".select2").select2({
allowClear: true,
@@ -422,6 +442,7 @@
p = success.result.product;
$("#vatgroup_id").val(p.vatgroup_id);
$("#price").val(p.price);
$("#sla_id").val(p.sla_id);
$("#price_setup").val(p.price_setup);
$("#price_nne").val(p.price_nne);
$("#price_nbe").val(p.price_nbe);

View File

@@ -55,6 +55,11 @@
<label class="form-label" for="filter_product_name">Produkt</label>
<input type="text" class="form-control" name="filter[product_name]" id="filter_product_name" value="<?=$filter['product_name']?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_matchcode">Matchcode</label>
<input type="text" class="form-control" name="filter[matchcode]" id="filter_matchcode" value="<?=$filter['matchcode']?>" />
</div>
<div class="col-2">
<label class="form-label" for="filter_show_canceled">Gekündigte Produkte</label>

View File

@@ -1,6 +1,11 @@
<?php
$f = false;
$hide_credit = false;
$hide_credit = true;
if($me->is("Admin")) {
$hide_credit = false;
}
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>

View File

@@ -199,8 +199,8 @@
<td>
<input type="radio" class="form-check link-keep pointer"
id="link-<?=$link->id?>-action-keep"
name="links[<?=$link->id?>][action]"
value="keep" <?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?>
name="links[<?=$link->id?>][action]" value="keep"
<?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?>
onchange="linkActionChange(<?=$link->id?>)" />
<?php if($link->type == "credit"): ?>
(Gutschrift wird neu erstellt)

View File

@@ -0,0 +1,37 @@
<?php
/**
* @var Order $order
*/
$this->setReturnValue([
'subject' => "[ESTMK] Produktwechsel ".$order->owner->getCompanyOrName(),
'from_email' => "workspace.admin@xinon.at",
'from_email_name' => "thetool"
]);
$url_prefix = "http".($_SERVER["HTTPS"] ? "s" : "")."://".$_SERVER["HTTP_HOST"];
?>
project: storungen-and-support
type: Produktwechsel
status: Neu
priority: Residential
Kundenname: <?=str_replace(["\n", "\r"], "", $order->owner->getCompanyOrName())?>
Telefon: <?=$order->owner->phone?>
e-Mail: <?=$order->owner->email?>
Kundennummer: <?=$order->owner->customer_number?>
Kunde: <?=str_replace(["\n", "\r"], "", $order->owner->getCompanyOrName())?>
### Neue Produkte:
<?php foreach($order->products as $product): ?>
<?=$product->product->name?>
<?php endforeach; ?>
<?=$url_prefix?><?=self::getUrl("Order", "", ["id" => $order->id])?>
⚠️ Upgradebestellung muss nach der technischen Umstellung in thetool ABGESCHLOSSEN werden.

View File

@@ -544,7 +544,14 @@
<h4>Produkte</h4>
<div class="row col-12 mt-2 mb-2">
<label><input type="checkbox" class="input-check" name="upgrade" value="1" <?=($order->upgrade) ? "checked='checked'" : ""?> /> Bestellung ist Upgrade</label>
<?php if($me->address_id == 209): ?>
<label><input type="checkbox" class="input-check" name="upgrade" value="1" <?=($order->upgrade) ? "checked='checked'" : ""?> /> Bestellung ist Upgrade</label>
<?php else: ?>
<p class="alert alert-warning">
Upgrades können ab sofort nur noch über die Upgradefunktion auf der Bestellübersicht eingegeben werden.
<a href="<?=self::getUrl("Order", "addUpgrade")?>">Klicken Sie hier</a>, um zur Upgradefunktion zu gelangen.
</p>
<?php endif; ?>
</div>
<div></div>
@@ -605,6 +612,7 @@
<select class="form-control" name="products[<?=$i?>][billing_period]" id="billing_period-<?=$i?>" placeholder="Rechnungsperiode">
<option value="1" <?=($product->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
<option value="12" <?=($product->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
<option value="0" <?=($product->billing_period == 0) ? "selected='selected'" : ""?>>Einmalig</option>
</select>
</div>
<div class="col-2">
@@ -772,6 +780,7 @@
<select class="form-control" name="products[<?=$i?>][billing_period]" id="billing_period-<?=$i?>" placeholder="Rechnungsperiode">
<option value="1">Monatlich</option>
<option value="12">Jährlich</option>
<option value="0">Einmalig</option>
</select>
</div>
<div class="col-2">
@@ -1244,7 +1253,15 @@
$('#price_setup-' + id).val(p.price_setup);
$('#price_nne-' + id).val(p.price_nne);
$('#price_nbe-' + id).val(p.price_nbe);
var period = Number.parseInt(p.billing_period);
var price = Number.parseFloat(p.price);
if(!period && !price) {
$('#price-' + id).prop("disabled", true);
} else {
$('#price-' + id).prop("disabled", false);
}
console.log(p.attributes);
console.log("form_id: " + id);
if(typeof p.attributes === 'object' && "termination_required" in p.attributes && p.attributes.termination_required == 1) {
@@ -1266,6 +1283,7 @@
} else {
$('#voicenumber-' + id + '-line').hide();
}
},
'json');
@@ -1671,6 +1689,7 @@
<select class="form-control" name="products[' + i +'][billing_period]" id="billing_period-' + i +'" placeholder="Rechnungsperiode"> \
<option value="1">Monatlich</option> \
<option value="12">Jährlich</option> \
<option value="0">Einmalig</option> \
</select> \
</div> \
<div class="col-2"> \

View File

@@ -143,7 +143,9 @@
<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>
<?php if($me->address_id != 209): ?>
<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>
<?php endif; ?>
</div>
</div>
</div>
@@ -177,9 +179,15 @@
<?php else: ?>
Nur Sonderprodukte/Projekte
<?php endif; ?>
</a>
</li>
<?php if($me->address_id != 209): ?>
<li class="nav-item">
<a class="nav-link" href="<?=self::getUrl("Order", "Upgrades", ["filter" => $filter])?>">
Upgrades
</a>
</li>
<?php endif; ?>
</ul>
<?php if($showSpecial) $lonelyOrders = $special_orders ?>

View File

@@ -1,6 +1,10 @@
<?php
$f = "o";
$hide_credit = true;
if($me->is("Admin")) {
$hide_credit = false;
}
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>

View File

@@ -0,0 +1,307 @@
<?php
$pagination_baseurl = $this->getUrl("Order","Upgrades");
$pagination_baseurl_params = ["filter" => $filter];
$pagination_entity_name = "Upgrades";
//var_dump($mynetworks);
$sorted_networks = [];
if(is_array($mynetworks) && count($mynetworks)) {
foreach($mynetworks as $net) {
$sorted_networks[$net->name] = $net->id;
}
}
ksort($sorted_networks);
//var_dump($mynetworks);
//var_dump($sorted_networks);exit;
?>
<?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 active">Bestellungen</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">
<div class="card-body mb-3">
<h4 class="header-title mb-3">Filter</h4>
<form method="get" action="<?=self::getUrl("Order", "Upgrades")?>">
<div class="row">
<div class="col-2">
<label class="form-label" for="filter_building_street">Straße (Anschluss)</label>
<input type="text" class="form-control" name="filter[building_street]" id="filter_building_street" value="<?=$filter['building_street']?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_owner">Kunde</label>
<input type="text" class="form-control" name="filter[owner]" id="filter_owner" value="<?=$filter['owner']?>" />
</div>
<div class="col-2">
<label class="form-label" for="filter_owner">Straße (Kunde)</label>
<input type="text" class="form-control" name="filter[owner_address]" id="filter_owner_address" value="<?=$filter['owner_address']?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_partner_number">Partnernummer</label>
<input type="text" class="form-control" name="filter[partner_number]" id="filter_partner_number" value="<?=$filter['partner_number']?>" />
</div>
<div class="col-1">
<label class="form-label" for="filter_customer_type">Kundentyp</label>
<select name="filter[customer_type]" id="filter_customer_type" class="form-control">
<option></option>
<option value="residential" <?=($filter['customer_type'] == "residential") ? 'selected="selected"' : ""?>>Residential</option>
<option value="business" <?=($filter['customer_type'] == "business") ? 'selected="selected"' : ""?>>Business</option>
</select>
</div>
</div>
<div class="row mt-2">
<div class="col">
<button type="submit" class="btn btn-primary">Filter anwenden</button>
<a class="btn btn-secondary" href="<?=self::getUrl("Order", "Upgrades")?>">Filter zurücksetzen</a>
</div>
</div>
</form>
</div>
</div>
<div class="row">
<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>
</div>
</div>
</div>
<ul class="nav nav-tabs ml-1" role="tablist">
<li class="nav-item">
<a class="nav-link" href="<?=self::getUrl("Order", "Index", ["filter" => $filter])?>">Bestellungen mit Anschluss</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?=self::getUrl("Order", "Index", ["noTermProducts" => 1, "filter" => $filter])?>">
Bestellungen ohne Anschluss
</a>
</li>
<li class="nav-item">
<a class="nav-link " href="<?=self::getUrl("Order", "Index", ["voiceProductsOnly" => 1, "filter" => $filter])?>">
Nur Voice/PBX
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="<?=self::getUrl("Order", "Index", ["specialProductsOnly" => 1, "filter" => $filter])?>">
Nur Sonderprodukte/Projekte
</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="<?=self::getUrl("Order", "Upgrades", ["filter" => $filter])?>">
Upgrades
</a>
</li>
</ul>
<div class="card border-top-info">
<div class="card-body mb-3">
<?php if(is_array($upgrades) && count($upgrades)): ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<table class="table table-striped table-hover">
<tr>
<th></th>
<th class="align-middle">Contact ID</th>
<th class="align-middle">Bisheriger Vertragsinhaber</th>
<th class="align-middle">Bestehendes Produkt<br />Matchcode</th>
<th class="align-middle">Verknüpfte Produkte</th>
<th class="align-middle">Rechnungsperiode</th>
<th class="align-middle">Preis<br />Preis Setup</th>
<th class="border border-dark text-center align-middle pl-0 pr-0">Fertigstellungssdatum<br />(Falls vorhanden)</th>
<th class="align-middle">Neuer Vertragsinhaber</th>
<th class="align-middle">Neues Produkt<br />Matchcode</th>
<th class="align-middle">Preis<br />Preis Setup</th>
<th></th>
</tr>
<?php foreach($upgrades as $upgrade): ?>
<tr id="upgrade-<?=$upgrade->id?>">
<td class="bg-lightblue border border-end text-center pointer" onclick="toggleUpgrade(<?=$upgrade->id?>); return false;">
<i class="fas fa-fw fa-angle-down"></i>
</td>
<td><?=$upgrade->origin->id?></td>
<td><?=$upgrade->origin->owner->getCompanyOrName()?> <?=($upgrade->origin->owner->customer_number) ? " [".$upgrade->origin->owner->customer_number."]" : ""?></td>
<td>
<?=$upgrade->origin->product_name?><br />
<span class="font-italic"><?=$upgrade->origin->matchcode?></span>
</td>
<td><?=$upgrade->origin->countActiveLinks()?></td>
<td><?=__($upgrade->origin->billing_period, "billing_period")?></td>
<td>
€ <?=number_format($upgrade->origin->price, 4, ",", ".")?><br />
€ <?=number_format($upgrade->origin->price_setup, 4, ",", ".")?>
</td>
<td class="border border-dark text-center align-middle pl-0 pr-0" style="font-size: 1.3rem;">
<?php if($upgrade->contract->finish_date): ?>
<?=date("d.m.Y", $upgrade->contract->finish_date)?>
<?php elseif($upgrade->origin->cancel_date): ?>
<?=date("d.m.Y", $upgrade->origin->cancel_date)?>
<?php endif; ?>
<i class="fas fa-fw fa-right"></i>
</td>
<td><?=$upgrade->contract->owner->getCompanyOrName()?></td>
<td>
<?=$upgrade->contract->product_name?><br />
<span class="font-italic"><?=$upgrade->contract->matchcode?></span>
</td>
<td>
€ <?=number_format($upgrade->contract->price, 4, ",", ".")?><br />
€ <?=number_format($upgrade->contract->price_setup, 4, ",", ".")?>
</td>
<!--td>
<a href="<?=self::getUrl("Order", "editProductchange", ["contract_id" => $upgrade->origin->id])?>"><i class="far fa-edit" title="Produktwechsel bearbeiten"></i></a>
</td-->
</tr>
<tr id="upgrade-detail-<?=$upgrade->id?>" style="display:none; background-color:#fff">
<td colspan="8">
<div class="card">
<div class="card-body">
<div class="row justify-content-center">
<div class="col-12">
<h4>Verknüpfte bestehende Produkte</h4>
<table class="table table-sm table-striped">
<tr>
<th>Contact ID</th>
<th>Vertragsinhaber</th>
<th>Produkt<br />Matchcode</th>
<th class="align-middle">Rechnungsperiode</th>
<th>Preis<br />Preis Setup</th>
<th>Übernahmeaktion</th>
</tr>
<?php foreach($upgrade->origin->linksWithCredit as $link): ?>
<?php
if($link->contract_id == $upgrade->origin_contract_id) {
$linkcontract = $link->origin;
} else {
$linkcontract = $link->contract;
}
if($linkcontract->price < 0) continue;
if($linkcontract->isCancelled()) continue;
?>
<tr>
<td><?=$linkcontract->id?></td>
<td><?=$linkcontract->owner->getCompanyOrName()?></td>
<td>
<?=$linkcontract->product_name?><br />
<span class="font-italic"><?=$linkcontract->matchcode?></span>
</td>
<td><?=__($linkcontract->billing_period, "billing_period")?></td>
<td>
€ <?=number_format($linkcontract->price, 4, ",", ".")?><br />
€ <?=number_format($linkcontract->price_setup, 4, ",", ".")?>
</td>
<td>
<?php if($linkcontract->cancel_date): ?>
<strong>Kündigung am <span class="text-danger"><?=date("d.m.Y", $linkcontract->cancel_date)?></span></strong>
<?php elseif($link->change_action == "cancel"): ?>
<strong>Kündigung bei Fertigstellung</strong>
<?php else: ?>
Wird übernommen
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
</td>
</tr>
<tr></tr>
<?php endforeach; ?>
</table>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<?php else: ?>
<i>Keine Upgrades zu den Suchkriterien gefunden</i>
<?php endif; ?>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
$('.datepicker').each(function() {
$(this).datepicker({
language: 'de',
format: "dd.mm.yyyy",
showWeekDays: true,
todayBtn: 'linked',
autoclose: true
});
});
//sortSelect(document.getElementById("filter_network_id"));
var upgrade_id;
var hash = window.location.hash.substr(1);
var match = hash.match(/upgrade=(\d+)/);
if(match && match[1]) {
upgrade_id = match[1]
toggleUpgrade(upgrade_id);
$('html, body').animate( {scrollTop: $('#upgrade-' + upgrade_id).offset().top - 230}, 200);
}
});
function toggleUpgrade(id) {
$('#upgrade-detail-' + id).toggle();
if($('#upgrade-detail-' + id).is(":hidden")) {
$('#upgrade-' + id).removeClass("bg-lightblue");
$('#upgrade-' + id).removeClass("text-info");
history.replaceState(null, null, ' ');
} else {
$('#upgrade-' + id).addClass("text-info");
$('#upgrade-' + id).addClass("bg-lightblue");
location.hash = "upgrade=" + id;
return false;
}
}
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -180,7 +180,7 @@
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="price">Verkaufspreis Netto (Periodisch) *</label>
<div class="col-lg-10">
<input type="text" name="price" id="price" class="form-control" value="<?=$this::dotToComma($product->price)?>" />
<input type="text" name="price" id="price" class="form-control" value="<?=$this::dotToComma($product->price)?>" <?=(!$product->billing_period && !(float)$product->price) ? "disabled='disabled'" : ""?> />
</div>
</div>
<div class="form-group row">
@@ -334,7 +334,18 @@
$('#producttech_form').hide();
}
});
$("#billing_period").change(() => {
var price = Number.parseFloat($("#price").val().replace(",","."));
var period = Number.parseInt($("#billing_period").val());
if(!period && !price) {
$("#price").prop("disabled", true);
} else {
$("#price").prop("disabled", false);
}
});
// disable mousewheel on input number field when in focus
$('form').on('focus', 'input[type=number]', function (e) {
$(this).on('wheel.disableScroll', function (e) {

View File

@@ -153,8 +153,7 @@
<td><?=$product->producttech->name?><?=(is_array($product->attributes) && array_key_exists(TT_ATTRIB_RTRTECHCODE_NAME, $product->attributes)) ? " (".$product->attributes[TT_ATTRIB_RTRTECHCODE_NAME]->value.")" : "" ?></td>
<td><?=__($product->producttech->customer_type)?></td>
<td><?=$product->price?></td>
<td><?=__($product->billing_period, "billing_period")?>
</td>
<td><?=__($product->billing_period, "billing_period")?></td>
<td><?=$product->sla->name?></td>
<td><?=$product->ivt_id?></td>
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">

View File

@@ -241,6 +241,17 @@ class Contract extends mfBaseModel {
return false;
}
public function countActiveLinks($with_credit = false) {
$links = $this->getProperty("links");
if(is_array($links) && count($links)) {
return count($links);
}
return 0;
}
public function generateMatchcode() {
$owner_address = $this->getProperty("owner")->street . ", " . $this->getProperty("owner")->zip . " " . $this->getProperty("owner")->city;

View File

@@ -429,6 +429,21 @@ class ContractController extends mfBaseController
$contract_data['termination_id'] = null;
}
//var_dump($r->links);
// lookup credit contract and if it's missing in $r->links
if(!$this->me->is("Admin")) {
$credit_link = ContractLinkModel::includesContractId($contract->id, ["type" => "credit"]);
if($credit_link) {
if(is_array($r->links) && !array_key_exists($credit_link->id, $r->links)) {
$r->links[$credit_link->id] = [];
}
$r->links[$credit_link->id]["action"] = "keep";
}
}
//var_dump($r->links);exit;
$new_contract->update($contract_data);
$new_contract_id = $new_contract->save();
@@ -455,6 +470,8 @@ class ContractController extends mfBaseController
]);
$journal->save();
if (is_array($r->links) && count($r->links)) {
foreach ($r->links as $link_id => $link_data) {
$action = $link_data["action"];
@@ -597,7 +614,7 @@ class ContractController extends mfBaseController
$this->layout()->setFlash("Produktwechsel erfolgreich erstellt", "success");
if($f == "o") {
$this->redirect("Order");
$this->redirect("Order","Upgrades");
} else {
$this->redirect("Contract", "view", ["contract_id" => $new_contract_id]);
}
@@ -749,6 +766,7 @@ class ContractController extends mfBaseController
$contract_data["product_info"] = $r->product_info;
$contract_data['amount'] = ($r->amount) ? (float)$r->amount : 1;
$contract_data['vatgroup_id'] = $r->vatgroup_id;
$contract_data['sla_id'] = (float)$r->sla_id;
$contract_data['price'] = (float)$r->price;
$contract_data['price_setup'] = (float)$r->price_setup;
$contract_data['price_nne'] = (float)$r->price_nne;
@@ -790,10 +808,6 @@ class ContractController extends mfBaseController
//var_dump($contract_data);exit;
if ($mode == "add") {

View File

@@ -100,7 +100,7 @@ class ContractLinkModel {
$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 Address ON (Contract.owner_id = Address.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)
@@ -123,7 +123,7 @@ class ContractLinkModel {
$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 Address ON (Contract.owner_id = Address.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)
@@ -230,6 +230,84 @@ class ContractLinkModel {
}
}
if(array_key_exists("owner_id", $filter)) {
$owner_id = $filter['owner_id'];
if(is_numeric($owner_id)) {
$where .= " AND Contract.owner_id=$owner_id";
}
}
if(array_key_exists("billingaddress_id", $filter)) {
$billingaddress_id = $filter['billingaddress_id'];
if(is_numeric($billingaddress_id)) {
$where .= " AND Contract.billingaddress_id=$billingaddress_id";
}
}
if(array_key_exists("product_id", $filter)) {
$product_id = $filter['product_id'];
if(is_numeric($product_id)) {
$where .= " AND Contract.product_id=$product_id";
}
}
if(array_key_exists("orderproduct_id", $filter)) {
$orderproduct_id = $filter['orderproduct_id'];
if(is_numeric($orderproduct_id)) {
$where .= " AND Contract.orderproduct_id=$orderproduct_id";
}
}
if(array_key_exists("product_name", $filter)) {
$product_name = $db->escape($filter['product_name']);
if($product_name) {
$where .= " AND (Contract.`product_name` like '%$product_name%' OR Product.name like '%$product_name%')";
}
}
if(array_key_exists("matchcode", $filter)) {
$matchcode = $db->escape($filter['matchcode']);
if($matchcode) {
$where .= " AND Contract.`matchcode` like '%$matchcode%'";
}
}
if(array_key_exists("rtr_code", $filter)) {
$rtr_code = $filter['rtr_code'];
if(is_numeric($rtr_code)) {
$where .= " AND Contract.rtr_code=$rtr_code";
}
}
if(array_key_exists("customer_number", $filter)) {
$customer_number = $filter['customer_number'];
if(is_numeric($customer_number)) {
$where .= " AND Address.customer_number=$customer_number";
}
}
if(array_key_exists("owner", $filter)) {
$owner = FronkDB::singleton()->escape($filter["owner"]);
if($owner) {
$where .= " AND (Address.customer_number like '$owner' OR Address.company like '%$owner%' OR (CONCAT(Address.firstname, ' ', Address.lastname) like '%$owner%' OR CONCAT(Address.lastname, ' ', Address.firstname) like '%$owner%' ))";
}
}
if(array_key_exists("imported_from", $filter)) {
$imported_from = FronkDB::singleton()->escape($filter["imported_from"]);
if($imported_from) {
$where .= " AND Contract.imported_from like '$imported_from'";
}
}
if(array_key_exists("imported_data", $filter)) {
$imported_data = FronkDB::singleton()->escape($filter["imported_data"]);
if($imported_data) {
$where .= " AND Contract.imported_data like '$imported_data'";
}
}
if(array_key_exists("price<", $filter)) {
$price = $filter['price<'];
if(is_numeric($price)) {
@@ -256,6 +334,13 @@ class ContractLinkModel {
}
}
if(array_key_exists("billing_period", $filter)) {
$billing_period = $filter['billing_period'];
if(is_numeric($billing_period)) {
$where .= " AND Contract.billing_period=$billing_period";
}
}
if(array_key_exists("finish_date", $filter)) {
$finish_date = $filter['finish_date'];
if(is_numeric($finish_date)) {
@@ -270,13 +355,6 @@ class ContractLinkModel {
}
}
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)) {
@@ -284,10 +362,17 @@ class ContractLinkModel {
}
}
if(array_key_exists("finish_date_null_or_gte", $filter)) {
$cancel_date = $filter['finish_date_null_or_gte'];
if(is_numeric($cancel_date)) {
$where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date >= $cancel_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)";
$cancel_date = $filter['finish_date_null_or_lte'];
if(is_numeric($cancel_date)) {
$where .= " AND (Contract.finish_date IS NULL OR Contract.finish_date <= $cancel_date)";
}
}

View File

@@ -264,7 +264,31 @@ class Order extends mfBaseModel {
return true;
}
}
public function sendUpgradeEmail() {
$tk_tpl = new Layout();
$tk_tpl->setTemplate("Emailtemplates/order/productchange-ticket-order");
$tpl_vars = [
"order" => $this,
];
foreach($tpl_vars as $name => $val) {
$tk_tpl->set($name, $val);
}
$tk_body = $tk_tpl->render();
$tk_values = $tk_tpl->getReturnedValue();
$tk_email = new Emailnotification();
$tk_email->setSubject($tk_values["subject"]);
$tk_email->setBody($tk_body);
$tk_email->setFrom($tk_values["from_email"], $tk_values["from_email_name"]);
$tk_email->setTo("workspace@xinon.at");
$tk_email->setHeader("X-" . MFAPPNAME . "-Cid", $this->id);
$tk_email->send();
}
public function sendFileuploadEmail(OrderFile $file) {
$filetype = $file->name;

View File

@@ -479,13 +479,14 @@ class OrderController extends mfBaseController {
$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
];
unset($filter["finish_date"]);
$upgrade_search = $filter;
$upgrade_search["type"] = "upgrade";
$upgrade_search["contract_creator_address_id"] = $this->me->address_id;
$upgrade_search["finish_date_null_or_gte"] = date("U");
$upgrade_search["price>="] = 0;
$pagination["maxItems"] = ContractLinkModel::countWithContracts($upgrade_search);
@@ -493,6 +494,7 @@ class OrderController extends mfBaseController {
$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"),
@@ -1084,7 +1086,12 @@ class OrderController extends mfBaseController {
} else {
$this->log->debug(__CLASS__."::save(): NOT creating new SPIN for ".$owner->getCompanyOrName()." (".$owner->id."): SPIN exists or owner of Order was changed or external products");
}
if($mode == "add" && $order->upgrade) {
// send upgrade ticket
$order->sendUpgradeEmail();
}
}
//var_dump($_FILES['OrderFileUpload']);exit;

View File

@@ -244,7 +244,7 @@ class OrderModel {
if(array_key_exists("owner", $filter)) {
$owner = FronkDB::singleton()->escape($filter['owner']);
if($owner) {
$where .= " AND (Address.company like '%$owner%' OR Address.firstname like '%$owner%' OR Address.lastname like '%$owner%' OR Address.customer_number like '%$owner%')";
$where .= " AND (Address.customer_number like '$owner' OR Address.company like '%$owner%' OR Address.firstname like '%$owner%' OR Address.lastname like '%$owner%' OR Address.customer_number like '%$owner%')";
}
}

View File

@@ -48,12 +48,17 @@ class SlaModel {
return $item;
}
public static function getAll() {
public static function getAll($order = false) {
$items = [];
$_order = "name";
if($order) {
$_order = $order;
}
$db = FronkDB::singleton();
$res = $db->select("Sla", "*", "1 = 1 ORDER BY name");
$res = $db->select("Sla", "*", "1 = 1 ORDER BY $_order");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new Sla($data);