Merge branch 'fronkdev' into 'master'

Preorder network operators & Contract

See merge request fronk/thetool!338
This commit is contained in:
Frank Schubert
2024-04-18 12:06:44 +00:00
24 changed files with 2779 additions and 1306 deletions

View File

@@ -156,10 +156,10 @@
<td><?=($contract->product_external) ? "Ja" : "Nein"?></td>
</tr><tr>
<th>Setup Preis:</th>
<td>€ <?=$contract->price_setup?></td>
<td class="<?=($contract->price_setup < 0) ? "text-danger" : ""?>">€ <?=$contract->price_setup?></td>
</tr><tr>
<th>Preis Periodisch:</th>
<td>€ <?=$contract->price?></td>
<td class="<?=($contract->price < 0) ? "text-danger" : ""?>">€ <?=$contract->price?></td>
</tr><tr>
<th>Verrechnungsperiode:</th>
<td>
@@ -261,9 +261,15 @@
<em>Vertrag manuell angelegt</em>
<?php elseif($j->value == "import"): ?>
<em>Vertrag importiert: <?=nl2br(htmlentities($j->text))?>
<?php elseif($j->value == "order"): ?>
<em>Vertrag aus Bestellung #<a href="<?=self::getUrl("Order", "edit", ["id" => $contract->orderproduct->order_id])?>"><?=$contract->orderproduct->order_id?></a> erstellt
<?php endif; ?>
</td>
<?php elseif($j->type == "credit_created"): ?>
<td><i class="far fa-money-bill-simple-wave text-secondary pl-1"></i></td>
<td style="width: 100%"><em>Gutschrift-Vertrag <a href="<?=self::getUrl("Contract", "View", ["contract_id" => $j->value])?>"><?=$j->value?></a> erstellt</em>
</td>
<?php elseif($j->type == "link"): ?>
<?php $link = new Contract($j->value); ?>
<td><i class="fas fa-link text-secondary pl-1"></i></td>
@@ -321,45 +327,56 @@
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
<table class="table table-striped table-sm table-bordered table-hover">
<tr>
<th>Typ</th>
<th>Kunde</th>
<th>Contract ID</th>
<th>Typ</th>
<th>Produkt</th>
<th>Bestelldatum</th>
<th>Fertigstellung</th>
<th>Kündigung</th>
<th></th>
</tr>
<?php foreach($contract->links as $link): ?>
<?php
if($link->contract_id == $contract->id) {
$direction = "von";
$linkcontract = $link->origin;
} else {
$linkcontract = $link->contract;
if($link->type == "upgrade" || $link->type == "downgrade") {
$direction = "auf";
}
if($link->type == "relocation") {
$direction = "nach";
}
}
?>
<tr>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->id?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=__($link->type, "contract")?> <?=($link->type != "link") ? $direction : ""?></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->product_name?> [<?=$linkcontract->matchcode?>]</a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->order_date) ? date('d.m.Y', $linkcontract->order_date) : ""?></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->finish_date) ? date('d.m.Y', $linkcontract->finish_date) : ""?></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : ""?></td>
<td>
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
</td>
</tr>
<?php foreach([$contract->linkFrom, $contract->linkTo] as $links): ?>
<?php foreach($links as $link): ?>
<?php
if($link->contract_id == $contract->id) {
$direction = "von";
$linkcontract = $link->origin;
if($link->type == "credit") {
$direction = "";
//continue;
}
} else {
$linkcontract = $link->contract;
if($link->type == "upgrade" || $link->type == "downgrade") {
$direction = "auf";
}
if($link->type == "relocation") {
$direction = "nach";
}
if($link->type == "credit") {
$direction = "zu";
//continue;
}
}
?>
<tr>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=__($link->type, "contract")?> <?=($link->type != "link") ? $direction : ""?></td>
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->id?></a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>"><?=$linkcontract->product_name?> [<?=$linkcontract->matchcode?>]</a></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->order_date) ? date('d.m.Y', $linkcontract->order_date) : ""?></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->finish_date) ? date('d.m.Y', $linkcontract->finish_date) : ""?></td>
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><?=($linkcontract->cancel_date) ? date('d.m.Y', $linkcontract->cancel_date) : ""?></td>
<td>
<a href="<?=self::getUrl("Contract", "deleteLink", ["link_id" => $link->id])?>" onclick="if(!confirm('Verknüpfung wirklich entfernen?')) return false;" class="text-danger" title="Verknüpfung entfernen"><i class="fas fa-xmark-large"></i></a>
</td>
</tr>
<?php endforeach; ?>
<?php endforeach; ?>
</table>
<?php endif; ?>

View File

@@ -78,360 +78,371 @@
<div class="card">
<div class="card-body mb-3">
<form method="post" action="<?=self::getUrl("Contractqueue", "commit")?>">
<div class="row">
<div class="col-12">
<div class="float-left">
<h4 class="header-title">Fertiggestellte Bestellungen</h4>
<button type="submit" class="btn btn-primary"><i class="fas fa-fw fa-check"></i> Markierte Elemente als Contract übernehmen</button>
</div>
<div class="float-right">
<a class="btn btn-primary mb-2" href="<?=self::getUrl("Contractqueue", "importFinishedOrders")?>"><i class="fas fa-fw fa-file-import"></i> Fertiggestellte Bestellungen importieren</a>
<a class="btn btn-outline-primary mb-2" href="<?=self::getUrl("Contractqueue", "importFinishedOrders")?>"><i class="fas fa-fw fa-file-import"></i> Fertiggestellte Bestellungen importieren</a>
</div>
</div>
</div>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<?php $i = 0; foreach($orders as $order_id => $contracts): ?>
<?php $order = $contracts[0]->orderproduct->order; ?>
<div class="row">
<div class="col-12">
<div class="card border-top-success">
<div class="card-header">
<span class="float-right order-date-pill active mr-2 mt-1">Fertigstellung: <span class="text-monospace font-weight-bold"><?=date("d.m.Y", $order->finish_date)?></span></span>
<span class="float-right order-date-pill active mr-2 mt-1">Zuletzt bearbeitet: <span class="text-monospace font-weight-bold"><?=date("d.m.Y H:i", $order->edit)?> (<?=$order->editor?>)</span></span>
<span class="float-right order-date-pill active mr-2 mt-1">Erstellt: <span class="text-monospace font-weight-bold"><?=date("d.m.Y H:i", $order->create)?> (<?=$order->creator?>)</span></span>
<h4><a href="<?=self::getUrl("Order", "", ["id" => $order_id])?>" target="_blank">Bestellung <?=$order_id?></a></h4>
</div>
<div class="card-body bg-light">
<div class="row">
<div class="col-6">
<div class="card" id="owner-<?=$order_id?>">
<div class="card-body">
<div>
<span class="float-right"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('owner', <?=$order_id?>, false)"></i></span>
<h5 class="m-0">Inhaber</h5>
</div>
<hr class="mt-1" />
<div class="text">
<span class="text-monospace"><?=$order->owner->customer_number?></span><br />
<strong><?=$order->owner->getCompanyOrName()?></strong><br />
<?=$order->owner->street?><br />
<?=$order->owner->zip?> <?=$order->owner->city?><br />
<?php $i = 0; foreach($orders as $order_id => $contracts): ?>
<?php $order = $contracts[0]->orderproduct->order; ?>
<div class="row">
<div class="col-12">
<div class="card border-top-success">
<div class="card-header">
<span class="float-right order-date-pill active mr-2 mt-1">Fertigstellung: <span class="text-monospace font-weight-bold"><?=date("d.m.Y", $order->finish_date)?></span></span>
<span class="float-right order-date-pill active mr-2 mt-1">Zuletzt bearbeitet: <span class="text-monospace font-weight-bold"><?=date("d.m.Y H:i", $order->edit)?> (<?=$order->editor?>)</span></span>
<span class="float-right order-date-pill active mr-2 mt-1">Erstellt: <span class="text-monospace font-weight-bold"><?=date("d.m.Y H:i", $order->create)?> (<?=$order->creator?>)</span></span>
<h4><a href="<?=self::getUrl("Order", "", ["id" => $order_id])?>" target="_blank">Bestellung <?=$order_id?></a></h4>
</div>
<div class="card-body bg-light">
<div class="row">
<div class="col-6">
<div class="card" id="owner-<?=$order_id?>">
<div class="card-body">
<div>
<span class="float-right"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('owner', <?=$order_id?>, false)"></i></span>
<h5 class="m-0">Inhaber</h5>
</div>
<hr class="mt-1" />
<div class="text">
<span class="text-monospace"><?=$order->owner->customer_number?></span><br />
<strong><?=$order->owner->getCompanyOrName()?></strong><br />
<?=$order->owner->street?><br />
<?=$order->owner->zip?> <?=$order->owner->city?><br />
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<select
name="owner_id-<?=$order_id?>"
class="form-control basicAutoComplete"
autocomplete="off"
id="owner_id-<?=$order_id?>"
data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1"
placeholder="Tippen zum Suchen... (Bestandskunden)"
data-noresults-text="Keine Suchergebnisse"
data-val="<?=$order->owner_id?>"
data-ov="<?=$order->owner_id?>"
>
<option></option>
</select>
<div class="input-group-append">
<button type="button" class="btn btn-primary" onclick="saveAddress('owner', <?=$order_id?>)"><i class="fas fa-check"></i></button>
<button type="button" class="btn btn-secondary" onclick="toggleEdit('owner', <?=$order_id?>, false)"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<select
name="owner_id-<?=$order_id?>"
</div>
<div class="card" id="billingaddress-<?=$order_id?>">
<div class="card-body">
<div>
<span class="float-right"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('billingaddress', <?=$order_id?>, false)"></i></span>
<h5 class="m-0">Rechnungsempfänger</h5>
</div>
<hr class="mt-1" />
<div class="text">
<?php if($order->billingaddress_id): ?>
<?=($order->billingaddress->customer_number) ? $order->billingaddress->customer_number."<br />" : ""?>
<?=$order->billingaddress->getCompanyOrName()?><br />
<?=$order->billingaddress->street?><br />
<?=$order->billingaddress->zip?> <?=$order->billingaddress->city?><br />
<?php endif; ?>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<select
name="billingaddress_id-<?=$order_id?>"
class="form-control basicAutoComplete"
autocomplete="off"
id="owner_id-<?=$order_id?>"
id="billingaddress_id-<?=$order_id?>"
data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1"
placeholder="Tippen zum Suchen... (Bestandskunden)"
data-noresults-text="Keine Suchergebnisse"
data-val="<?=$order->owner_id?>"
data-ov="<?=$order->owner_id?>"
>
<option></option>
</select>
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveAddress('owner', <?=$order_id?>)"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('owner', <?=$order_id?>, false)"><i class="fas fa-times"></i></button>
data-val="<?=$order->billingaddress_id?>"
data-ov="<?=$order->billingaddress_id?>"
>
<option></option>
</select>
<div class="input-group-append">
<button type="button" class="btn btn-primary" onclick="saveAddress('billingaddress', <?=$order_id?>)"><i class="fas fa-check"></i></button>
<button type="button" class="btn btn-secondary" onclick="toggleEdit('billingaddress', <?=$order_id?>, false)"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card" id="billingaddress-<?=$order_id?>">
<div class="card-body">
<div>
<span class="float-right"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('billingaddress', <?=$order_id?>, false)"></i></span>
<h5 class="m-0">Rechnungsempfänger</h5>
</div>
<hr class="mt-1" />
<div class="text">
<?php if($order->billingaddress_id): ?>
<?=($order->billingaddress->customer_number) ? $order->billingaddress->customer_number."<br />" : ""?>
<?=$order->billingaddress->getCompanyOrName()?><br />
<?=$order->billingaddress->street?><br />
<?=$order->billingaddress->zip?> <?=$order->billingaddress->city?><br />
<?php endif; ?>
</div>
<div class="col-6">
<div class="card mb-1">
<div class="card-body">
<h5 class="m-0">Bestelljournal</h5>
<table class="table table-sm table-striped mt-1 mb-0">
<tr>
<th>Erstellt</th>
<th>Text</th>
</tr>
<?php foreach($order->journals as $journal): ?>
<tr>
<td class="text-monospace"><?=date("d.m.Y H:i", $journal->create)?> (<?=$journal->creator?>)</td>
<td><?=nl2br($journal->text)?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<select
name="billingaddress_id-<?=$order_id?>"
class="form-control basicAutoComplete"
autocomplete="off"
id="billingaddress_id-<?=$order_id?>"
data-url="<?=self::getUrl('Address','api')?>?do=findAddress&autocomplete=1"
placeholder="Tippen zum Suchen... (Bestandskunden)"
data-noresults-text="Keine Suchergebnisse"
data-val="<?=$order->billingaddress_id?>"
data-ov="<?=$order->billingaddress_id?>"
>
<option></option>
</select>
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveAddress('billingaddress', <?=$order_id?>)"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('billingaddress', <?=$order_id?>, false)"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</div>
</div>
<?php if(trim($order->note)): ?>
<div class="row">
<div class="col">
<div class="card">
<div class="card-body">
<h5 class="m-0">Interne Notiz</h5>
<hr class="mt-1">
<?=nl2br(htmlentities($order->note))?>
</div>
</div>
</div>
</div>
</div>
<div class="col-6">
<div class="card mb-1">
<div class="card-body">
<h5 class="m-0">Bestelljournal</h5>
<?php endif; ?>
<div class="row">
<table class="table table-sm table-striped mt-1 mb-0">
<tr>
<th>Erstellt</th>
<th>Text</th>
</tr>
<?php foreach($order->journals as $journal): ?>
<tr>
<td class="text-monospace"><?=date("d.m.Y H:i", $journal->create)?> (<?=$journal->creator?>)</td>
<td><?=nl2br($journal->text)?></td>
</tr>
<?php endforeach; ?>
</table>
<div class="col-12">
<div class="card">
<div class="card-body">
<h5>Produkte</h5>
<table class="table table-striped table-hover" id="order-products-<?=$order_id?>">
<tr>
<th style="width:56px;"><input type="checkbox" class="form-control pointer checkbox-toggle" onclick="toggleOrderApproval(this, <?=$order_id?>, 'order')" /></th>
<th>Produkt</th>
<th>Matchcode</th>
<th>Preis</th>
<th>Preis Setup</th>
<th>Rechnungsperiode</th>
<th>Verz. Verrechnungsstart</th>
<th>Erstellt</th>
<th>Zuletzt bearbeitet</th>
</tr>
<?php foreach($contracts as $contract): ?>
<tr id="contract-<?=$contract->id?>">
<td><input type="checkbox" class="form-control pointer" value="<?=$contract->id?>" id="approve-order-<?=$order_id?>-contract-<?=$contract->id?>" onclick="toggleApproval(<?=$order_id?>, 'order')" <?=($contract->approved) ? "checked='checked'" : ""?> /></td>
<td class="text-wrap product">
<div class="text">
<!--i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'product')"></i--> <span class="value"><?=$contract->product_name?></span>
<?php if($contract->termination_id && $contract->termination): ?>
<br /><small class="text-pink"><?=$contract->termination->code?> - <?= str_replace("\n", " - ", $contract->termination->getAddress())?></small>
<?php endif ?>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<select class="edit-control form-control" data-val="<?=$contract->product_id?>" data-ov="<?=$contract->product_id?>"></select>
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'product')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'product')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="matchcode">
<div class="text">
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'matchcode')"></i> <span class="value"><?=htmlentities($contract->matchcode)?></span>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<input type="text" class="form-control edit-control" value="<?=$contract->matchcode?>" data-val="<?=htmlentities($contract->matchcode)?>" data-ov="<?=htmlentities($contract->matchcode)?>" />
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'matchcode')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'matchcode')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="price">
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price')"></i> € <span class="value"><?=$contract->price?></span></div>
<div class="edit hidden">
<div class="input-group mb-3">
<input type="text" class="form-control edit-control" value="<?=$contract->price?>" data-val="<?=$contract->price?>" data-ov="<?=$contract->price?>" />
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'price')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="price_setup">
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price_setup')"></i> € <span class="value"><?=$contract->price_setup?></span></div>
<div class="edit hidden">
<div class="input-group mb-3">
<input type="text" class="form-control edit-control" value="<?=$contract->price_setup?>" data-val="<?=$contract->price_setup?>" data-ov="<?=$contract->price_setup?>" />
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'price_setup')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price_setup')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="billing_period">
<div class="text">
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_period')"></i>
<span class="value">
<?php if($contract->billing_period == 1): ?>
monatlich
<?php elseif($contract->billing_period == 12): ?>
Jährlich
<?php elseif($contract->billing_period == 24): ?>
2-jährlich
<?php elseif($contract->billing_period == 36): ?>
3-jährlich
<?php else: ?>
<?=(12 / $contract->billing_period)?>x Jährlich
<?php endif; ?>
</span>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<select class="edit-control form-control" data-val="<?=$contract->product_id?>" data-ov="<?=$contract->product_id?>">
<option value="1" <?=($contract->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
<option value="12" <?=($contract->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
<option value="24" <?=($contract->billing_period == 24) ? "selected='selected'" : ""?>>2-Jährlich</option>
<option value="36" <?=($contract->billing_period == 36) ? "selected='selected'" : ""?>>3-Jährlich</option>
</select>
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'billing_period')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_period')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="billing_delay">
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_delay')"></i> <span class="value"><?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></span></div>
<div class="edit hidden">
<div class="input-group mb-3">
<input type="text" class="form-control edit-control" value="<?=$contract->billing_delay?>" data-val="<?=$contract->billing_delay?>" data-ov="<?=$contract->billing_delay?>" />
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'billing_delay')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_delay')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->orderproduct->create)?><br /><?=$contract->orderproduct->creator->name?></td>
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->orderproduct->edit)?><br /><?=$contract->orderproduct->editor->name?></td>
</tr>
<?php endforeach; ?>
</table>
<h5>Gutschriften / Provisionen</h5>
<table class="table table-striped table-hover" id="credit-products-<?=$order_id?>">
<tr>
<th style="width:56px;"><input type="checkbox" class="form-control pointer checkbox-toggle" onclick="toggleOrderApproval(this, <?=$order_id?>, 'credit')" /></th>
<th>Bezieher</th>
<th>Produkt</th>
<th>Matchcode</th>
<th>Provision</th>
<th>Rechnungsperiode</th>
<th>Verz. Verrechnungsstart</th>
</tr>
<?php foreach($contracts as $contract): ?>
<?php $credit = $contract->getCredit(); if(!$credit) continue; ?>
<tr id="credit-<?=$contract->id?>">
<td><input type="checkbox" class="form-control pointer" value="<?=$contract->id?>" id="approve-credit-<?=$order_id?>-contract-<?=$contract->id?>" onclick="toggleApproval(<?=$order_id?>, 'credit')" <?=($contract->approved_credit) ? "checked='checked'" : ""?> /></td>
<td class="crediting_partner_name text value"><?=($credit["partner"]) ? $credit["partner"]->getCompanyOrName() : ""?></td>
<td class="text-wrap product text">
<span class="value"><?=$contract->product_name?></span>
<?php if($contract->termination_id && $contract->termination): ?>
<br /><small class="text-pink"><?=$contract->termination->code?> - <?= str_replace("\n", " - ", $contract->termination->getAddress())?></small>
<?php endif; ?>
</td>
<td class="crediting_matchcode">
<div class="text">
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"></i> <span class="value"><?=$contract->crediting_matchcode?></span>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<input type="text" class="form-control edit-control" value="<?=$contract->matchcode?>" data-val="<?=$contract->crediting_matchcode?>" data-ov="<?=$contract->crediting_matchcode?>" />
<div class="input-group-append">
<button class="btn btn-primary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="crediting_partner_rate text value">
<?=($credit["rate_source"] == "rate") ? "€ ".$credit["rate"] : "€ ".$contract->price_nne?> <?=($credit["rate_source"] == "rate") ? "(Prozentrate)" : "(NNE)"?>
</td>
<td class="billing_period text value">
<?php if($contract->billing_period == 1): ?>
monatlich
<?php elseif($contract->billing_period == 24): ?>
3-jährlich
<?php elseif($contract->billing_period == 36): ?>
3-jährlich
<?php else: ?>
<?=(12 / $contract->billing_period)?>x Jährlich
<?php endif; ?>
</td>
<td class="billing_delay text value"><?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<?php if(trim($order->note)): ?>
<div class="row">
<div class="col">
<div class="card">
<div class="card-body">
<h5 class="m-0">Interne Notiz</h5>
<hr class="mt-1">
<?=nl2br(htmlentities($order->note))?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h5>Produkte</h5>
<table class="table table-striped table-hover" id="order-products-<?=$order_id?>">
<tr>
<th style="width:56px;"><input type="checkbox" class="form-control pointer checkbox-toggle" onclick="toggleOrderApproval(this, <?=$order_id?>, 'order')" /></th>
<th>Produkt</th>
<th>Matchcode</th>
<th>Preis</th>
<th>Preis Setup</th>
<th>Rechnungsperiode</th>
<th>Verz. Verrechnungsstart</th>
<th>Erstellt</th>
<th>Zuletzt bearbeitet</th>
</tr>
<?php foreach($contracts as $contract): ?>
<tr id="contract-<?=$contract->id?>">
<td><input type="checkbox" class="form-control pointer" id="approve-order-<?=$order_id?>-contract-<?=$contract->id?>" onclick="toggleApproval(<?=$order_id?>, 'order')" <?=($contract->approved) ? "checked='checked'" : ""?> /></td>
<td class="text-wrap product">
<div class="text">
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'product')"></i> <span class="value"><?=$contract->product_name?></span>
<?php if($contract->termination_id && $contract->termination): ?>
<br /><small class="text-pink"><?=$contract->termination->code?> - <?= str_replace("\n", " - ", $contract->termination->getAddress())?></small>
<?php endif ?>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<select class="edit-control form-control" data-val="<?=$contract->product_id?>" data-ov="<?=$contract->product_id?>"></select>
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'product')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'product')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="matchcode">
<div class="text">
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'matchcode')"></i> <span class="value"><?=htmlentities($contract->matchcode)?></span>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<input type="text" class="form-control edit-control" value="<?=$contract->matchcode?>" data-val="<?=htmlentities($contract->matchcode)?>" data-ov="<?=htmlentities($contract->matchcode)?>" />
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'matchcode')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'matchcode')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="price">
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price')"></i> € <span class="value"><?=$contract->price?></span></div>
<div class="edit hidden">
<div class="input-group mb-3">
<input type="text" class="form-control edit-control" value="<?=$contract->price?>" data-val="<?=$contract->price?>" data-ov="<?=$contract->price?>" />
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'price')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="price_setup">
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price_setup')"></i> € <span class="value"><?=$contract->price_setup?></span></div>
<div class="edit hidden">
<div class="input-group mb-3">
<input type="text" class="form-control edit-control" value="<?=$contract->price_setup?>" data-val="<?=$contract->price_setup?>" data-ov="<?=$contract->price_setup?>" />
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'price_setup')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'price_setup')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="billing_period">
<div class="text">
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_period')"></i>
<span class="value">
<?php if($contract->billing_period == 1): ?>
monatlich
<?php elseif($contract->billing_period == 12): ?>
Jährlich
<?php elseif($contract->billing_period == 24): ?>
2-jährlich
<?php elseif($contract->billing_period == 36): ?>
3-jährlich
<?php else: ?>
<?=(12 / $contract->billing_period)?>x Jährlich
<?php endif; ?>
</span>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<select class="edit-control form-control" data-val="<?=$contract->product_id?>" data-ov="<?=$contract->product_id?>">
<option value="1" <?=($contract->billing_period == 1) ? "selected='selected'" : ""?>>Monatlich</option>
<option value="12" <?=($contract->billing_period == 12) ? "selected='selected'" : ""?>>Jährlich</option>
<option value="24" <?=($contract->billing_period == 24) ? "selected='selected'" : ""?>>2-Jährlich</option>
<option value="36" <?=($contract->billing_period == 36) ? "selected='selected'" : ""?>>3-Jährlich</option>
</select>
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'billing_period')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_period')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="billing_delay">
<div class="text"><i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_delay')"></i> <span class="value"><?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></span></div>
<div class="edit hidden">
<div class="input-group mb-3">
<input type="text" class="form-control edit-control" value="<?=$contract->billing_delay?>" data-val="<?=$contract->billing_delay?>" data-ov="<?=$contract->billing_delay?>" />
<div class="input-group-append">
<button class="btn btn-primary" onclick="saveEdit('contract', <?=$contract->id?>, 'billing_delay')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('contract', <?=$contract->id?>, 'billing_delay')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->orderproduct->create)?><br /><?=$contract->orderproduct->creator->name?></td>
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->orderproduct->edit)?><br /><?=$contract->orderproduct->editor->name?></td>
</tr>
<?php endforeach; ?>
</table>
<h5>Gutschriften / Provisionen</h5>
<table class="table table-striped table-hover" id="credit-products-<?=$order_id?>">
<tr>
<th style="width:56px;"><input type="checkbox" class="form-control pointer checkbox-toggle" onclick="toggleOrderApproval(this, <?=$order_id?>, 'credit')" /></th>
<th>Bezieher</th>
<th>Produkt</th>
<th>Matchcode</th>
<th>Provision</th>
<th>Rechnungsperiode</th>
<th>Verz. Verrechnungsstart</th>
</tr>
<?php foreach($contracts as $contract): ?>
<?php $credit = $contract->getCredit(); if(!$credit) continue; ?>
<tr id="credit-<?=$contract->id?>">
<td><input type="checkbox" class="form-control pointer" id="approve-credit-<?=$order_id?>-contract-<?=$contract->id?>" onclick="toggleApproval(<?=$order_id?>, 'credit')" <?=($contract->approved) ? "checked='checked'" : ""?> /></td>
<td class="crediting_partner_name text value"><?=($credit["partner"]) ? $credit["partner"]->getCompanyOrName() : ""?></td>
<td class="text-wrap product text">
<span class="value"><?=$contract->product_name?></span>
<?php if($contract->termination_id && $contract->termination): ?>
<br /><small class="text-pink"><?=$contract->termination->code?> - <?= str_replace("\n", " - ", $contract->termination->getAddress())?></small>
<?php endif; ?>
</td>
<td class="crediting_matchcode">
<div class="text">
<i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"></i> <span class="value"><?=$contract->crediting_matchcode?></span>
</div>
<div class="edit hidden">
<div class="input-group mb-3">
<input type="text" class="form-control edit-control" value="<?=$contract->matchcode?>" data-val="<?=$contract->crediting_matchcode?>" data-ov="<?=$contract->crediting_matchcode?>" />
<div class="input-group-append">
<button class="btn btn-primary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"><i class="fas fa-check"></i></button>
<button class="btn btn-secondary" onclick="toggleEdit('credit', <?=$contract->id?>, 'matchcode')"><i class="fas fa-times"></i></button>
</div>
</div>
</div>
</td>
<td class="crediting_partner_rate text value">
<?=($credit["rate_source"] == "rate") ? "€ ".$credit["rate"] : "€ ".$contract->price_nne?> <?=($credit["rate_source"] == "rate") ? "(Prozentrate)" : "(NNE)"?>
</td>
<td class="billing_period text value">
<?php if($contract->billing_period == 1): ?>
monatlich
<?php elseif($contract->billing_period == 24): ?>
3-jährlich
<?php elseif($contract->billing_period == 36): ?>
3-jährlich
<?php else: ?>
<?=(12 / $contract->billing_period)?>x Jährlich
<?php endif; ?>
</td>
<td class="billing_delay text value"><?=($contract->billing_delay) ? $contract->billing_delay." Monate" : ""?></td>
</tr>
<?php endforeach; ?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php $i++; endforeach; ?>
<?php $i++; endforeach; ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination-summary.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../")."/tpl/pagination.php"); ?>
<button type="submit" class="btn btn-primary"><i class="fas fa-fw fa-check"></i> Markierte Elemente als Contract übernehmen</button>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
<?php
@@ -444,6 +455,39 @@
var products = <?=json_encode($prods)?>;
$("input[id^='approve-order-'], input[id^='approve-credit-']").change(function() {
var id = this.id;
console.log(this);
var order_match = id.match(/approve-(order|credit)-(\d+)-contract-(\d+)/);
var type = order_match[1];
//var order_id = order_match[2];
var cq_id = order_match[3];
var value = $(this).is(":checked") ? 1 : 0;
$.ajax({
url: "<?=self::getUrl("Contractqueue", "api")?>",
type: "POST",
data: {
do: "setApproval",
type: type,
//order_id: order_id,
cq_id: cq_id,
value: value
},
dataType: "json",
context: {
element_id: this.id,
checked: $(this).is(":checked")
},
success: function (success) {
console.log(this.element_id);
}
});
});
function toggleOrderApproval(cbox, order_id, type) {
if(!parseInt(order_id) || !order_id) return;
@@ -455,6 +499,7 @@
} else {
$("#" + type + "-products-" + order_id + " input[id^='approve-" + type + "-" + order_id + "-contract-']").prop('checked', false);
}
$("input[id^='approve-" + type + "-" + order_id + "-contract-']").change();
}
function toggleApproval(order_id, type) {
@@ -473,6 +518,8 @@
if(checked_count < box_count) {
$("#" + type + "-products-" + order_id + " .checkbox-toggle").prop("checked", false);
}
$("input[id^='approve-" + type + "-" + order_id + "-contract-']").change();
}
function toggleEdit(type, id, control_name) {

View File

@@ -0,0 +1,67 @@
<?php
ob_end_flush();
header("Content-type: text/csv");
header('Content-disposition: attachment; filename="Kampagne-'.$campaign->name.'-billing-'.date('Y-m-d_H-i-s').'.csv"');
?>
Kampagne;Netzgebiet ID;Netzgebiet;Extref;Bestellcode;OAID;Bestelldatum;Bestelltyp;Status Code; Status Name;Anschlusstyp;GWR Adresscode;Meridian;RW;HW;Anschluss Strasse;Anschluss Hausnummer;Anschluss PLZ;Anschluss Ort;Anschluss Wohneinheit;GPS Breite;GPS Länge;Anzahl Anschlüsse;Kunde Firma;Kunde UID;Kunde Vorname;Kunde Nachname;Kunde Strasse;Kunde PLZ;Kunde Ort;Kunde Telefon;Kunde Email;Partner;Preis Setup;Erstellt;Letzte Bearbeitung
<?php
$line = 0;
while($data = mysqli_fetch_object($res)):
//$campaign = Layout::getMfValuecacheObject("Preordercampaign", $data->preordercampaign_id);
$status = Layout::getMfValuecacheObject("Preorderstatus", $data->status_id);
$hausnummer = Layout::getMfValuecacheObject("ADBHausnummer", $data->adb_hausnummer_id);
$wohneinheit = Layout::getMfValuecacheObject("ADBWohneinheit", $data->adb_wohneinheit_id);
$netzgebiet = Layout::getMfValuecacheObject("ADBNetzgebiet", $hausnummer->netzgebiet_id);
$strasse = Layout::getMfValuecacheObject("ADBStrasse", $hausnummer->strasse_id);
$gemeinde = Layout::getMfValuecacheObject("ADBGemeinde",$strasse->gemeinde_id);
$ortschaft = Layout::getMfValuecacheObject("ADBOrtschaft", $hausnummer->ortschaft_id);
$plz = Layout::getMfValuecacheObject("ADBPlz", $hausnummer->plz_id);
$partner = Layout::getMfValuecacheObject("Address", $data->partner_id);
$unit_data = "";
if($wohneinheit->block) $unit_data .= "Block ".$wohneinheit->block;
if($wohneinheit->stiege) $unit_data .= "Stiege ".$wohneinheit->stiege;
if($wohneinheit->stock) $unit_data .= "Stock ".$wohneinheit->stock;
if($wohneinheit->tuer) $unit_data .= "Tür ".$wohneinheit->tuer;
if($wohneinheit->unit_string) {
$unit_data = $wohneinheit->unit_string;
}
$bep = false;
$inhouse = false;
if($data->attributes) {
$attribs = json_decode($data->attributes, true);
if($attribs['bep_specified']) $bep = true;
if($attribs['inhouse_cabling_supplied']) $inhouse = true;
}
$addon_property = 0;
$addon_inhouse = 0;
if($data->addon_services) {
$services = json_decode($data->addon_services);
if(is_array($services) && count($services)) {
foreach($services as $service) {
if($service->service == "installation_onproperty" && $service->ordered) {
$addon_property = 1;
}
if($service->service == "installation_inhouse" && $service->ordered) {
$addon_inhouse = 1;
}
}
}
}
if($data->uid == "string") $data->uid = "";
?>
"<?=$campaign->name?>";"<?=$netzgebiet->extref?>";"<?=$netzgebiet->name?>";"<?=$data->extref?>";"<?=$data->ucode?>";"<?=$wohneinheit->oaid?>";"<?=($data->order_date) ? date("d.m.Y",$data->order_date) : ""?>";"<?=__($data->type,"preorder")?>";"<?=$status->code?>";"<?=$status->name?>";"<?=__($data->connection_type,"preorder")?>";"<?=$hausnummer->adrcd?>";"<?=$hausnummer->meridian?>";"<?=$hausnummer->rw?>";"<?=$hausnummer->hw?>";"<?=$strasse->name?>";"<?=$hausnummer->hausnummer?>";"<?=$plz->plz?>";"<?=$ortschaft->name?>";"<?=$unit_data?>";"<?=$hausnummer->gps_lat?>";"<?=$hausnummer->gps_long?>";<?=$data->connection_count?>;"<?=$data->company?>";"<?=$data->uid?>";"<?=$data->firstname?>";"<?=$data->lastname?>";"<?=$data->street?>";"<?=$data->zip?>";"<?=$data->city?>";"<?=$data->phone?>";"<?=$data->email?>";"<?=$partner->getCompanyOrName()?>";<?=$data->price_setup?>;"<?=date("Y-m-d H:i:s",$data->create)?>";"<?=date("Y-m-d H:i:s",$data->edit)?>"
<?php
$line++;
if($line % 1000 === 0) {
flush();
}
endwhile;

View File

@@ -1,325 +1,499 @@
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<?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("Preordercampaign")?>">Vorbestellkampagnen</a></li>
<li class="breadcrumb-item active"><?=($Action=="add") ? "neu" : "bearbeiten"?></li>
</ol>
</div>
<h4 class="page-title">Vorbestellkampagne</h4>
<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("Preordercampaign") ?>">Vorbestellkampagnen</a>
</li>
<li class="breadcrumb-item active"><?= ($Action == "add") ? "neu" : "bearbeiten" ?></li>
</ol>
</div>
<h4 class="page-title">Vorbestellkampagne</h4>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-lg-12">
<div class="card bg-light">
<div class="card-body">
<h4 class="header-title mb-2"><?=($Action=="add") ? "Neue " : ""?>Vorbestellkampagne <?=($Action=="edit") ? "bearbeiten " : ""?></h4>
<form class="form-horizontal" method="post" action="<?=self::getUrl("Preordercampaign", "save")?>">
<input type="hidden" name="id" value="<?=$campaign->id?>" />
<div class="col-lg-12">
<div class="card">
<div class="card bg-light">
<div class="card-body">
<h4 class="header-title mb-2"><?= ($Action == "add") ? "Neue " : "" ?>
Vorbestellkampagne <?= ($Action == "edit") ? "bearbeiten " : "" ?></h4>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="network_id">Netzgebiet *</label>
<div class="col-lg-10">
<select class="select2 form-control " name="network_id" id="network_id">
<option></option>
<?php foreach($networks as $network): ?>
<option value="<?=$network->id?>" <?=($campaign->network_id == $network->id) ? "selected='selected'" : ""?>><?=($network->name)?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("Preordercampaign", "save") ?>">
<input type="hidden" name="id" value="<?= $campaign->id ?>"/>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="name">Name *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="name" id="name" value="<?=$campaign->name?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="description">Info</label>
<div class="col-lg-10">
<textarea class="form-control" style="height:120px;" name="description"><?=$campaign->description?></textarea>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="area">Gebiet *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="area" id="area" value="<?=$campaign->area?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="homes_total">Homes gesamt *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="homes_total" id="homes_total" value="<?=$campaign->homes_total?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="from">Von</label>
<div class="col-lg-10">
<input type="text" class="form-control datepicker" name="from" id="from" value="<?=($campaign->from) ? date('d.m.Y', $campaign->from) : ""?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="to">Bis</label>
<div class="col-lg-10">
<input type="text" class="form-control datepicker" name="to" id="to" value="<?=($campaign->to) ? date('d.m.Y', $campaign->to) : ""?>" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="product_type">Verfügbare Produkte *</label>
<div class="col-lg-10">
<select class="form-control" name="product_type" id="product_type" data-placeholder="Bitte auswählen ...">
<option value="all" <?=($campaign->product_type == "all") ? "selected='selected'" : ""?>>Alle Produkte im Netzgebiet</option>
<option value="no_setup" <?=($campaign->product_type == "no_setup") ? "selected='selected'" : ""?>>Alle Produkte im Netzgebiet, ohne Herstellungsprodukt</option>
<option value="setup_only" <?=($campaign->product_type == "setup_only") ? "selected='selected'" : ""?>>Nur Anschlussbestellung, keine Produkte</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="types">Erlaubte Vorbestellungstypen *</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple" name="types[]" id="types" multiple="multiple" data-placeholder="Bitte auswählen ...">
<option value="interest" <?=(is_array($campaign->types) && array_key_exists("interest", $campaign->types)) ? "selected='selected'" : ""?>><?=__("interest", "preorder")?></option>
<option value="provision" <?=(is_array($campaign->types) && array_key_exists("provision", $campaign->types)) ? "selected='selected'" : ""?>><?=__("provision", "preorder")?></option>
<option value="order" <?=(is_array($campaign->types) && array_key_exists("order", $campaign->types)) ? "selected='selected'" : "netowner"?>><?=__("order", "preorder")?></option>
<option value="reorder" <?=(is_array($campaign->types) && array_key_exists("reorder", $campaign->types)) ? "selected='selected'" : "netowner"?>><?=__("reorder", "preorder")?></option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="fulfillment">Auftragsabwicklung bei Projektstart *</label>
<div class="col-lg-10">
<select class="form-control" name="fulfillment" id="fulfillment" data-placeholder="Bitte auswählen ...">
<option value="thetool" <?=($campaign->fulfillment == "thetool") ? "selected='selected'" : ""?>>thetool</option>
<option value="rimo" <?=($campaign->fulfillment == "rimo") ? "selected='selected'" : ""?>>RIMO</option>
<option value="thirdparty" <?=($campaign->fulfillment == "thirdparty") ? "selected='selected'" : ""?>>Drittsystem</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="oaid_origin">OAID Herkunft *</label>
<div class="col-lg-10">
<select class="form-control" name="oaid_origin" id="oaid_origin" data-placeholder="Bitte auswählen ...">
<option value="thetool" <?=($campaign->oaid_origin == "thetool") ? "selected='selected'" : ""?>>thetool</option>
<option value="ofaa" <?=($campaign->oaid_origin == "ofaa") ? "selected='selected'" : ""?>>OFAA</option>
</select>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="network_id">Netzgebiet *</label>
<div class="col-lg-10">
<select class="select2 form-control " name="network_id" id="network_id">
<option></option>
<?php foreach ($networks as $network): ?>
<option value="<?= $network->id ?>" <?= ($campaign->network_id == $network->id) ? "selected='selected'" : "" ?>><?= ($network->name) ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="name">Name *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="name" id="name"
value="<?= $campaign->name ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="description">Info</label>
<div class="col-lg-10">
<textarea class="form-control" style="height:120px;"
name="description"><?= $campaign->description ?></textarea>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="area">Gebiet *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="area" id="area"
value="<?= $campaign->area ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="homes_total">Homes gesamt *</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="homes_total" id="homes_total"
value="<?= $campaign->homes_total ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="from">Von</label>
<div class="col-lg-10">
<input type="text" class="form-control datepicker" name="from" id="from"
value="<?= ($campaign->from) ? date('d.m.Y', $campaign->from) : "" ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="to">Bis</label>
<div class="col-lg-10">
<input type="text" class="form-control datepicker" name="to" id="to"
value="<?= ($campaign->to) ? date('d.m.Y', $campaign->to) : "" ?>"/>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="product_type">Verfügbare Produkte
*</label>
<div class="col-lg-10">
<select class="form-control" name="product_type" id="product_type"
data-placeholder="Bitte auswählen ...">
<option value="all" <?= ($campaign->product_type == "all") ? "selected='selected'" : "" ?>>
Alle Produkte im Netzgebiet
</option>
<option value="no_setup" <?= ($campaign->product_type == "no_setup") ? "selected='selected'" : "" ?>>
Alle Produkte im Netzgebiet, ohne Herstellungsprodukt
</option>
<option value="setup_only" <?= ($campaign->product_type == "setup_only") ? "selected='selected'" : "" ?>>
Nur Anschlussbestellung, keine Produkte
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="types">Erlaubte Vorbestellungstypen
*</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple" name="types[]" id="types"
multiple="multiple" data-placeholder="Bitte auswählen ...">
<option value="interest" <?= (is_array($campaign->types) && array_key_exists("interest", $campaign->types)) ? "selected='selected'" : "" ?>><?= __("interest", "preorder") ?></option>
<option value="provision" <?= (is_array($campaign->types) && array_key_exists("provision", $campaign->types)) ? "selected='selected'" : "" ?>><?= __("provision", "preorder") ?></option>
<option value="order" <?= (is_array($campaign->types) && array_key_exists("order", $campaign->types)) ? "selected='selected'" : "netowner" ?>><?= __("order", "preorder") ?></option>
<option value="reorder" <?= (is_array($campaign->types) && array_key_exists("reorder", $campaign->types)) ? "selected='selected'" : "netowner" ?>><?= __("reorder", "preorder") ?></option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="fulfillment">Auftragsabwicklung bei
Projektstart *</label>
<div class="col-lg-10">
<select class="form-control" name="fulfillment" id="fulfillment"
data-placeholder="Bitte auswählen ...">
<option value="thetool" <?= ($campaign->fulfillment == "thetool") ? "selected='selected'" : "" ?>>
thetool
</option>
<option value="rimo" <?= ($campaign->fulfillment == "rimo") ? "selected='selected'" : "" ?>>
RIMO
</option>
<option value="thirdparty" <?= ($campaign->fulfillment == "thirdparty") ? "selected='selected'" : "" ?>>
Drittsystem
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="oaid_origin">OAID Herkunft *</label>
<div class="col-lg-10">
<select class="form-control" name="oaid_origin" id="oaid_origin"
data-placeholder="Bitte auswählen ...">
<option value="thetool" <?= ($campaign->oaid_origin == "thetool") ? "selected='selected'" : "" ?>>
thetool
</option>
<option value="ofaa" <?= ($campaign->oaid_origin == "ofaa") ? "selected='selected'" : "" ?>>
OFAA
</option>
</select>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="adb_netzgebiet_ids">Beschränkt auf
Salescluster (GWR)</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple"
name="adb_netzgebiet_ids[]" id="adb_netzgebiet_ids" multiple="multiple"
data-placeholder="Salescluster ...">
<?php foreach (ADBNetzgebietModel::getAll() as $salescluster): ?>
<option value="<?= $salescluster->id ?>" <?= (is_array($campaign->salesclusters) && array_key_exists($salescluster->id, $campaign->salesclusters)) ? "selected='selected'" : "" ?>><?= $salescluster->name ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="banned_rimo_fcp">Für Bestellung
gesperrte FCPs</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple bg-danger"
name="banned_rimo_fcp[]" id="banned_rimo_fcp" multiple="multiple"
data-placeholder="FCPs ...">
<?php foreach ($campaign->all_fcp_names as $fcp_name): ?>
<option value="<?= $fcp_name ?>" <?= (is_array($campaign->banned_fcps) && in_array($fcp_name, $campaign->banned_fcps)) ? "selected='selected'" : "" ?>><?= $fcp_name ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="adb_netzgebiet_ids">Erforderliche
Zusatzfelder:</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple" name="required_fields[]"
id="required_fields" multiple="multiple" data-placeholder="Felder ...">
<option value="contact_type" <?= (is_array($campaign->required_fields) && in_array("contact_type", $campaign->required_fields)) ? "selected='selected'" : "" ?>>
Kontakttyp (Besitzer/Bewohner)
</option>
</select>
<small>Diese Felder müssen beim Bestellen angegeben werden</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="district_is_city">Ortsteil ist
Ort:</label>
<div class="col-lg-10">
<select class="form-control" name="district_is_city" id="district_is_city">
<option value="0" <?= (!$campaign->district_is_city) ? "selected='selected'" : "" ?>>
Nein
</option>
<option value="1" <?= ($campaign->district_is_city) ? "selected='selected'" : "" ?>>
Ja
</option>
</select>
<small>Statt Ort muss Ortsteil/Bezirk angegeben werden</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="hausnummer_add_zusatz">Adresszusatz an
Hausnummer anhängen:</label>
<div class="col-lg-10">
<select class="form-control" name="hausnummer_add_zusatz"
id="hausnummer_add_zusatz">
<option value="0" <?= (!$campaign->hausnummer_add_zusatz) ? "selected='selected'" : "" ?>>
Nein
</option>
<option value="1" <?= ($campaign->hausnummer_add_zusatz) ? "selected='selected'" : "" ?>>
Ja
</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="exist_is_error">Erlaubte Vorbestellungen
pro Wohneinheit (API):</label>
<div class="col-lg-10">
<select class="form-control" name="exist_is_error" id="exist_is_error">
<option value="0" <?= (!$campaign->exist_is_error) ? "selected='selected'" : "" ?>>
Mehr als eine
</option>
<option value="1" <?= ($campaign->exist_is_error) ? "selected='selected'" : "" ?>>
Maximal eine
</option>
</select>
<small>Weiterer Bestellversuch liefert Fehler zurück</small>
</div>
</div>
<hr/>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="cifurl">CIF Url</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="cifurl" id="cifurl"
value="<?= $campaign->cifurl ?>"/>
<small>
Customer Installation Feedback (für QR-Code bei Status 145).<br/>
Templatevariable <code>{{CIFTOKEN}}</code> wird mit echtem Cif Token ersetzt<br/>
Beispiel: <code>https://pro.ichwillglasfaser.at/ClientSubmit/finishedInstallationWork?c={{CIFTOKEN}}</code>
</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="cifcableurl">Kabelnachbestell-Url</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="cifcableurl" id="cifcableurl"
value="<?= $campaign->cifcableurl ?>"/>
<small>Für Begleitschreiben - Status 145</small>
</div>
</div>
</div>
</div>
<div class="card bg-light">
<div class="card-body">
<h4>Netzbetreiber</h4>
<div class="card">
<div class="card-body">
<h4>Aktivnetzbetreiber</h4>
<?php foreach ($campaign->active_operators as $aop): ?>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="active_operators_<?= $aop->id ?>"></label>
<div class="col-lg-4">
<select class="form-control"
name="active_operators[<?= $aop->id ?>]"
id="active_operators_<?= $aop->id ?>"
data-placeholder="Netzbetreiber wählen ...">
<option></option>
<?php foreach (AddressModel::search(['addresstype' => ["netowner"]]) as $operator): ?>
<option value="<?= $operator->id ?>" <?= ($operator->id == $aop->operator_id) ? "selected='selected'" : "" ?>><?= $operator->getCompanyOrName() ?></option>
<?php endforeach; ?>
</select>
</div>
<label class="col-lg-1 col-form-label text-right" for="active_isps">ISPs:</label>
<div class="col-lg-4">
<select class="select2 form-control select2-multiple active_isps"
name="active_isps[<?= $aop->operator_id ?>][]"
id="active_isps_<?= $aop->id ?>" multiple="multiple"
data-placeholder="ISPs wählen ...">
<option></option>
<?php foreach (AddressModel::search(['addresstype' => ["salespartner"]]) as $isp): ?>
<option value="<?= $isp->id ?>" <?= (array_key_exists($isp->id, $aop->isps)) ? "selected='selected'" : "" ?>><?= $isp->getCompanyOrName() ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<?php endforeach; ?>
<hr/>
<div class="form-group row">
<label class="col-lg-2 col-form-label text-right"
for="active_operators">Neu</label>
<div class="col-lg-4">
<select class="form-control" name="active_operators[new]"
id="active_operators"
data-placeholder="Netzbetreiber wählen ...">
<option></option>
<?php foreach (AddressModel::search(['addresstype' => ["netowner"]]) as $operator): ?>
<option value="<?= $operator->id ?>"><?= $operator->getCompanyOrName() ?></option>
<?php endforeach; ?>
</select>
</div>
<label class="col-lg-1 col-form-label text-right"
for="active_isps">ISPs:</label>
<div class="col-lg-4">
<select class="select2 form-control select2-multiple active_isps"
name="active_isps[new]" id="active_isps" multiple="multiple"
data-placeholder="ISPs wählen ...">
<option></option>
<?php foreach (AddressModel::search(['addresstype' => ["salespartner"]]) as $isp): ?>
<option value="<?= $isp->id ?>"><?= $isp->getCompanyOrName() ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="apiusers">Passive Netzbetreiber</label>
<div class="col-lg-10">
<select class="form-control" name="passive_operators[]"
id="passive_operators" multiple="multiple"
data-placeholder="Netzbetreiber wählen ...">
<?php foreach (AddressModel::search(['addresstype' => ["netowner", "salespartner"]]) as $operator): ?>
<option value="<?= $operator->id ?>" <?= (is_array($campaign->passive_operators) && array_key_exists($operator->id, $campaign->passive_operators)) ? "selected='selected'" : "" ?>><?= $operator->getCompanyOrName() ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<h4>API-User</h4>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="apiusers">Erlaubte
User</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple"
name="apiusers[]" id="apiusers" multiple="multiple"
data-placeholder="Benutzer auswählen ...">
<?php foreach (UserModel::search(['apikey' => true]) as $user): ?>
<option value="<?= $user->id ?>" <?= (is_array($campaign->apiusers) && array_key_exists($user->id, $campaign->apiusers)) ? "selected='selected'" : "" ?>><?= $user->username ?>
(<?= $user->name ?>)
</option>
<?php endforeach; ?>
</select>
<small>Benutzer mit API-Key</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="corsorigins">CORS Origin
Hostnamen</label>
<div class="col-lg-10">
<textarea class="form-control"
name="corsorigins"><?= ($campaign->corsorigins) ? implode("\n", $campaign->corsorigins) : "" ?></textarea>
<small>Hostname der Website, mit oder ohne Protokoll
(<em>https://</em>); *. als Wildcard erlaubt
(<em>*.domain.com</em>); ein Eintrag pro Zeile</small>
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
<div class="col-lg-10">
<textarea class="form-control" style="height:120px;" name="note"
id="note"><?= $campaign->note ?></textarea>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2"></label>
<div class="col-lg-10">
<button type="submit" name="return" value="" class="btn btn-primary">Speichern</button>
<button type="submit" name="return" value="index" class="btn btn-primary ml-1">Speichern und zur Übersicht</button>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="adb_netzgebiet_ids">Beschränkt auf Salescluster (GWR)</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple" name="adb_netzgebiet_ids[]" id="adb_netzgebiet_ids" multiple="multiple" data-placeholder="Salescluster ...">
<?php foreach(ADBNetzgebietModel::getAll() as $salescluster): ?>
<option value="<?=$salescluster->id?>" <?=(is_array($campaign->salesclusters) && array_key_exists($salescluster->id, $campaign->salesclusters)) ? "selected='selected'" : ""?>><?=$salescluster->name?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="banned_rimo_fcp">Für Bestellung gesperrte FCPs</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple bg-danger" name="banned_rimo_fcp[]" id="banned_rimo_fcp" multiple="multiple" data-placeholder="FCPs ...">
<?php foreach($campaign->all_fcp_names as $fcp_name): ?>
<option value="<?=$fcp_name?>" <?=(is_array($campaign->banned_fcps) && in_array($fcp_name, $campaign->banned_fcps)) ? "selected='selected'" : ""?>><?=$fcp_name?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="adb_netzgebiet_ids">Erforderliche Zusatzfelder:</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple" name="required_fields[]" id="required_fields" multiple="multiple" data-placeholder="Felder ...">
<option value="contact_type" <?=(is_array($campaign->required_fields) && in_array("contact_type", $campaign->required_fields)) ? "selected='selected'" : ""?>>Kontakttyp (Besitzer/Bewohner)</option>
</select>
<small>Diese Felder müssen beim Bestellen angegeben werden</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="district_is_city">Ortsteil ist Ort:</label>
<div class="col-lg-10">
<select class="form-control" name="district_is_city" id="district_is_city">
<option value="0" <?=(!$campaign->district_is_city) ? "selected='selected'" : ""?>>Nein</option>
<option value="1" <?=($campaign->district_is_city) ? "selected='selected'" : ""?>>Ja</option>
</select>
<small>Statt Ort muss Ortsteil/Bezirk angegeben werden</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="hausnummer_add_zusatz">Adresszusatz an Hausnummer anhängen:</label>
<div class="col-lg-10">
<select class="form-control" name="hausnummer_add_zusatz" id="hausnummer_add_zusatz">
<option value="0" <?=(!$campaign->hausnummer_add_zusatz) ? "selected='selected'" : ""?>>Nein</option>
<option value="1" <?=($campaign->hausnummer_add_zusatz) ? "selected='selected'" : ""?>>Ja</option>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="exist_is_error">Erlaubte Vorbestellungen pro Wohneinheit (API):</label>
<div class="col-lg-10">
<select class="form-control" name="exist_is_error" id="exist_is_error">
<option value="0" <?=(!$campaign->exist_is_error) ? "selected='selected'" : ""?>>Mehr als eine</option>
<option value="1" <?=($campaign->exist_is_error) ? "selected='selected'" : ""?>>Maximal eine</option>
</select>
<small>Weiterer Bestellversuch liefert Fehler zurück</small>
</div>
</div>
<hr />
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="cifurl">CIF Url</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="cifurl" id="cifurl" value="<?=$campaign->cifurl?>" />
<small>
Customer Installation Feedback (für QR-Code bei Status 145).<br />
Templatevariable <code>{{CIFTOKEN}}</code> wird mit echtem Cif Token ersetzt<br />
Beispiel: <code>https://pro.ichwillglasfaser.at/ClientSubmit/finishedInstallationWork?c={{CIFTOKEN}}</code>
</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="cifcableurl">Kabelnachbestell-Url</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="cifcableurl" id="cifcableurl" value="<?=$campaign->cifcableurl?>" />
<small>Für Begleitschreiben - Status 145</small>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card bg-light">
<div class="card-body">
<h4>API-User</h4>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="apiusers">Erlaubte User</label>
<div class="col-lg-10">
<select class="select2 form-control select2-multiple" name="apiusers[]" id="apiusers" multiple="multiple" data-placeholder="Benutzer auswählen ...">
<?php foreach(UserModel::search(['apikey' => true]) as $user): ?>
<option value="<?=$user->id?>" <?=(is_array($campaign->apiusers) && array_key_exists($user->id, $campaign->apiusers)) ? "selected='selected'" : ""?>><?=$user->username?> (<?=$user->name?>)</option>
<?php endforeach; ?>
</select>
<small>Benutzer mit API-Key</small>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="corsorigins">CORS Origin Hostnamen</label>
<div class="col-lg-10">
<textarea class="form-control" name="corsorigins"><?=($campaign->corsorigins) ? implode("\n", $campaign->corsorigins) : ""?></textarea>
<small>Hostname der Website, mit oder ohne Protokoll (<em>https://</em>); *. als Wildcard erlaubt (<em>*.domain.com</em>); ein Eintrag pro Zeile</small>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card bg-light">
<div class="card-body">
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="note">Interne Notiz</label>
<div class="col-lg-10">
<textarea class="form-control" style="height:120px;" name="note" id="note"><?=$campaign->note?></textarea>
</div>
</div>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2"></label>
<div class="col-lg-10">
<button type="submit" class="btn btn-primary">Speichern</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$('.datepicker').datepicker({
language: 'de',
format: "dd.mm.yyyy",
showWeekDays: true,
todayBtn: 'linked',
autoclose: true
});
$("#types").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
$("#adb_netzgebiet_ids").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
$("#apiusers").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
$("#required_fields").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
$("#banned_rimo_fcp").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false,
background: "bg-danger"
});
</script>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
<script type="text/javascript">
$('.datepicker').datepicker({
language: 'de',
format: "dd.mm.yyyy",
showWeekDays: true,
todayBtn: 'linked',
autoclose: true
});
$("#types").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
$("#adb_netzgebiet_ids").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
/*
$("#active_operators").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
*/
$("#passive_operators").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
$(".active_isps").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
$("#apiusers").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
$("#required_fields").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false
});
$("#banned_rimo_fcp").select2({
allowClear: true,
placeholder: "",
closeOnSelect: false,
background: "bg-danger"
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -0,0 +1,46 @@
<?php
namespace application\Api\v1\Modules\Operationaldata;
use application\Api\v1\Modules;
require_once(APPDIR."/Api/v1/Modules/ApiControllerModule.php");
/*
* API Endpoints for Operationaldata from SNOPP
*/
class Snopp extends Modules\ApiControllerModule
{
public function init()
{
}
public function setPreorderConnected($id) {
if(!$id || !is_numeric($id)) {
return \mfResponse::BadRequest(["message" => "id missing"]);
}
$wohneinheit = new \ADBWohneinheit($id);
if(!$wohneinheit->id) {
return \mfResponse::NotFound(["message" => "Home not found"]);
}
$preorder = \PreorderModel::getFirstActive(["adb_wohneinheit_id" => $id]);
if(!$preorder) {
return \mfResponse::NotFound(["message" => "Home not found"]);
}
$new_status = \PreorderstatusModel::getFirst(["code" => 300]);
if(!$new_status) {
return \mfResponse::InternalServerError();
}
if($preorder->status->code < $new_status->code) {
$preorder->status_id = $new_status->id;
$preorder->save();
}
return \mfResponse::Ok(["message" => "OK"]);
}
}

View File

@@ -1,6 +1,5 @@
<?php
//namespace thetool\Api\Modules\Preorder;
namespace application\Api\v1\Modules\Preorder;
use application\Api\v1\Modules;

View File

@@ -1,5 +1,8 @@
<?php
require_once(APPDIR."/Api/v1/Modules/Operationaldata/Snopp.php");
use application\Api\v1\Modules;
class OperationaldataApicontroller extends mfBaseApicontroller
@@ -28,21 +31,23 @@ class OperationaldataApicontroller extends mfBaseApicontroller
/*
* TODO: Load Api Modules automatically in mfBaseApiController
*/
/*$modules = [];
foreach (["Cif", "Activation"] as $moduleName) {
$classname = "application\\Api\\v1\\Modules\\Preorder\\" . $moduleName;
$modules = [];
foreach (["Snopp"] as $moduleName) {
$classname = "application\\Api\\v1\\Modules\\Operationaldata\\" . $moduleName;
$modules[$moduleName] = new $classname([
"get" => $this->get,
"post" => $this->post,
"db" => $this->db(),
"me" => $this->me
]);
}*/
}
$this->addRoute("/operationaldata/networks", "getNetworks", "GET");
$this->addRoute("/operationaldata/preordercampaigns", "getPreorderCampaigns", "GET");
$this->addRoute("/operationaldata/buildings", "getBuildingsByCampaign", "GET");
$this->addRoute("/operationaldata/home/:id/connected", [$modules["Snopp"], "setPreorderConnected"], "POST");
/*$this->addRoute("/preorder/open", "getOpenPreorders", "GET");
$this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "getCifData"], "GET");
$this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "userSetCif"], "POST");
@@ -184,12 +189,112 @@ class OperationaldataApicontroller extends mfBaseApicontroller
return mfResponse::NotFound(["message" => "Network not found"]);
}
if($campaign->from > date('U') || $campaign->to < date('U')) {
return mfResponse::Ok(["buildings" => []]);
}
$adb_netzgebiet_id = $campaign->adb_netzgebiet->id;
if(!$adb_netzgebiet_id) {
return mfResponse::NotFound(["message" => "Network not found"]);
}
// nur Bestellungen von Aktivnetzbetreiber und seine ISPs
if(!count($campaign->active_operators)) {
return mfResponse::Ok(["buildings" => []]);
}
$isp_ids = [];
foreach($campaign->active_operators as $aop) {
foreach($aop->isps as $op_isp) {
if(!in_array($op_isp->id, $isp_ids)) {
$isp_ids[] = $op_isp->isp_id;
}
}
}
//var_dump($isp_ids);exit;
$b = [];
$woStateNameToId = [];
$woStateNameToId["Clarify"] = 5;
$woStateNameToId["Review"] = 7;
$woStateNameToId["Accepted"] = 8;
$woStateNameToId["Plan Released"] = 10;
$woStateNameToId["Assigned"] = 20;
$woStateNameToId["Executed"] = 30;
$woStateNameToId["Documented"] = 40;
$woStateNameToId["Cancelled"] = 99;
foreach(PreorderModel::searchActive(["preordercampaign_id" => $campaign_id, "partner_id" => $isp_ids]) as $preorder) {
$hausnummer_id = $preorder->adb_hausnummer_id;
$wohneinheit_id = $preorder->adb_wohneinheit_id;
if(!$hausnummer_id || !$wohneinheit_id) continue;
$hausnummer = $preorder->adb_hausnummer;
$wohneinheit = $preorder->adb_wohneinheit;
if(!array_key_exists($hausnummer_id, $b)) {
$b[$hausnummer_id] = [
'id' => $preorder->adb_hausnummer_id,
'status' => [
'code' => $preorder->status->code,
'text' => $preorder->status->name
],
'oaid' => $hausnummer->oaid,
'salescluster_id' => $preorder->preordercampaign_id,
'network_id' => $preorder->campaign->network_id,
'zip' => $hausnummer->plz->plz,
'city' => $hausnummer->strasse->gemeinde->name,
"municipality" => "",
'district' => $hausnummer->ortschaft->name,
'street' => $hausnummer->strasse->name,
'housenumber' => $hausnummer->hausnummer,
'gps_lat' => ($hausnummer->gps_lat) ? (float)$hausnummer->gps_lat : null,
'gps_long' => ($hausnummer->gps_long) ? (float)$hausnummer->gps_long : null,
"homes" => []
];
if($this->district_is_city) {
$b[$hausnummer_id]['city'] = $hausnummer->ortschaft->name;
$b[$hausnummer_id]['municipality'] = $hausnummer->strasse->gemeinde->name;
} else {
unset($b[$hausnummer_id]['municipality']);
}
}
if(!array_key_exists($wohneinheit_id, $b[$hausnummer_id]["homes"])) {
$b[$hausnummer_id]["homes"][] = [
'id' => $wohneinheit_id,
'oaid' => $wohneinheit->oaid,
'num' => (int)$wohneinheit->num,
'block' => $wohneinheit->block,
'stiege' => $wohneinheit->stiege,
'stock' => $wohneinheit->stock,
'tuer' => $wohneinheit->tuer,
'zusatz' => $wohneinheit->zusatz,
'patch_cluster' => $wohneinheit->patch_cluster,
'patch_shelf' => $wohneinheit->patch_shelf,
'patch_module' => $wohneinheit->patch_module,
'patch_port' => $wohneinheit->patch_port,
'workorder_id' => ($wohneinheit->rimo_workorder) ? $wohneinheit->rimo_workorder->id : null,
'workorder_name' => ($wohneinheit->rimo_workorder) ? $wohneinheit->rimo_workorder->rimo_name : null,
'workorder_state_id' => ($wohneinheit->rimo_workorder) ? $woStateNameToId[$wohneinheit->rimo_workorder->rimo_status] : null,
'workorder_state_label' => ($wohneinheit->rimo_workorder) ? $wohneinheit->rimo_workorder->rimo_status : null,
];
}
}
$buildings = array_values($b);
return mfResponse::Ok(["buildings" => $buildings]);
/*
$db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
$sql = AddressDB::$wohneinheit_query;
@@ -249,17 +354,19 @@ class OperationaldataApicontroller extends mfBaseApicontroller
}
/*foreach($b as $tmp_b) {
/*
foreach($b as $tmp_b) {
$homes = array_values($tmp_b["homes"]);
return mfResponse::Ok(["Homes" => $homes]);
unset($tmp_b["homes"]);
$tmp_b["homes"] = array_values($homes);
$buildings[] = $tmp_b;
}*/
}
$buildings = array_values($b);
return mfResponse::Ok(["buildings" => $buildings]);
*/
}
}

View File

@@ -50,6 +50,9 @@ class Contract extends mfBaseModel {
case "link":
$this->linkTo[] = $link;
break;
case "credit":
$this->linkFrom[] = $link;
break;
case "upgrade":
$this->upgradeTo[] = $link;
break;
@@ -73,6 +76,9 @@ class Contract extends mfBaseModel {
case "link":
$this->linkFrom[] = $link;
break;
case "credit":
$this->linkTo[] = $link;
break;
case "upgrade":
$this->upgradeFrom[] = $link;
break;
@@ -126,7 +132,40 @@ class Contract extends mfBaseModel {
return false;
}
public function addFilesFromOrder() {
if(!$this->orderproduct_id) {
return true;
}
$op = $this->getProperty("orderproduct");
$order = $op->order;
if(!$order || !$order->id) return true;
foreach($order->files as $file) {
$cfile = ContractFileModel::create([
"contract_id" => $this->id,
"file_id" => $file->file_id,
"name" => $file->name,
"description" => $file->description,
"create_by" => $file->create_by,
"edit_by" => $file->edit_by
]);
$cfile->save();
$journal = ContractjournalModel::create([
"contract_id" => $this->id,
"type" => "file",
"value" => $cfile->id,
"text" => (array_key_exists($cfile->name, TT_ORDER_FILE_TYPES)) ? TT_ORDER_FILE_TYPES[$cfile->name] : $cfile->name
]);
$journal->save();
}
}
public function getProperty($name) {
if($this->$name == null) {
@@ -227,7 +266,7 @@ class Contract extends mfBaseModel {
}
if($name == "links") {
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => $link]);
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => "link"]);
//var_dump($this->links);exit;
return $this->links;
}

View File

@@ -56,7 +56,7 @@ class ContractModel {
return $model;
}
public static function createFromOrderproduct($op) {
public static function createFromOrderproduct(OrderProduct $op) {
$log = mfLoghandler::singleton();
if(!$op->id) {
@@ -107,6 +107,82 @@ class ContractModel {
return $contract;
}
public static function createFromContractQueue(Contractqueue $cq, $contracttype = "contract") {
$log = mfLoghandler::singleton();
$me = new User();
$me->loadMe();
if(!$cq->id) {
$log->warning(__METHOD__."(): Invalid Contractqueue object");
return false;
}
$order_id = $cq->order_id;
$product_id = $cq->product_id;
$order = new Order($order_id);
$product = new Product($product_id);
if(!$order->id || !$product->id) {
$log->warning(__METHOD__."(): Invalid Order or Product");
return false;
}
if(!$order->finish_date || $order->finish_date > date("U")) {
$log->warning(__METHOD__."(): Order not finished yet");
return false;
}
$data = [];
$data["orderproduct_id"] = $cq->orderproduct_id;
$data["matchcode"] = $cq->matchcode;
$data["owner_id"] = $cq->owner_id;
$data["billingaddress_id"] = ($cq->billingaddress_id) ? $cq->billingaddress_id : $cq->owner_id;
$data["termination_id"] = ($cq->termination_id) ? $cq->termination_id : null;
$data["product_id"] = $cq->product_id;
$data["product_name"] = $cq->product_name;
$data["product_info"] = $cq->product_info;
$data["amount"] = $cq->amount;
$data["sla_id"] = $cq->sla_id;
$data["product_external"] = $cq->product_external;
$data["product_external_id"] = $cq->product_external_id;
$data["price"] = $cq->price;
$data["price_setup"] = $cq->price_setup;
$data["price_nne"] = $cq->price_nne;
$data["price_nbe"] = $cq->price_nbe;
$data["billing_delay"] = $cq->billing_delay;
$data["billing_period"] = $cq->billing_period;
$data["contract_term"] = $cq->contract_term;
$data["order_date"] = $order->order_date;
$data["finish_date"] = $order->finish_date;
$data["finish_date_by"] = $me->id;
$data["note"] = $order->note;
if($contracttype == "credit") {
$crediting_price = $cq->price_nne;
if($cq->crediting_partner_rate) {
$crediting_price = round($cq->price / 100 * $cq->crediting_partner_rate, 4);
}
$crediting_price *= -1;
$data["matchcode"] = $cq->crediting_matchcode;
$data["owner_id"] = $cq->crediting_partner_id;
$data["billingaddress_id"] = $cq->crediting_partner_id;
$data["termination_id"] = null;
$data["price"] = $crediting_price;
$data["price_setup"] = 0;
$data["price_nne"] = 0;
$data["price_nbe"] = 0;
}
$contract = ContractModel::create($data);
//var_dump($contract);exit;
return $contract;
}
public function savePrecontract($contract) {

View File

@@ -167,6 +167,114 @@ class ContractqueueController extends mfBaseController {
}
$this->layout()->setFlash("Alle Bestellungen importiert", "success");
$this->redirect("Contractqueue");
}
protected function commitAction() {
$r = $this->request;
//var_dump($r->get());exit;
$new_contracts = [];
$c = 0;
$o = 0;
foreach(ContractqueueModel::search(["approved" => true, "contract_id" => null]) as $cq) {
//var_dump($cq);exit;
$contract = new Contract($cq->orderproduct_id);
if($contract->id) continue; // contract should not yet exist
/*
* Create Contract
*/
$contract = ContractModel::createFromContractqueue($cq);
if(!$contract->save()) {
$this->layout()->setFlash("Eine Position in Bestellung ".$cq->order_id." konnte nicht übernommen werden: Fehler beim Speichern");
continue;
}
$c++;
$cq->contract_id = $contract->id;
$cq->save();
// create Contractjournal
$journal = ContractjournalModel::create([
'contract_id' => $contract->id,
'type' => "created_from",
'value' => "order"
]);
$journal->save();
$contract->addFilesFromOrder();
/*
* Create Crediting Contract
* if required
*/
if($cq->approved_credit) {
$credit = ContractModel::createFromContractQueue($cq, "credit");
if(!$credit->save()) {
$this->layout()->setFlash("Zu einer Position in Bestellung ".$cq->order_id." konnte keine Gutschrift erstellt werden: Fehler beim Speichern");
continue;
}
$journal = ContractjournalModel::create([
'contract_id' => $credit->id,
'type' => "created_from",
'value' => "order"
]);
$journal->save();
$journal = ContractjournalModel::create([
'contract_id' => $contract->id,
'type' => "credit_created",
'value' => $credit->id
]);
$journal->save();
$link = ContractLinkModel::create([
'contract_id' => $contract->id,
'origin_contract_id' => $credit->id,
'type' => 'credit'
]);
$link->save();
// XXX: retour link erstellen?
}
/*
* Create ContractLinks
*/
foreach($new_contracts as $origin) {
if(ContractLinkModel::getFirst(["contract_id" => $contract->id, "origin_contract_id" => $origin->id])) {
continue;
}
$link = ContractLinkModel::create([
'contract_id' => $contract->id,
'origin_contract_id' => $origin->id,
'type' => 'link'
]);
$link->save();
if($link->id) {
$journal = ContractjournalModel::create([
'contract_id' => $contract->id,
'type' => "link",
'value' => $origin->id
]);
$journal->save();
$ojournal = ContractjournalModel::create([
'contract_id' => $origin->id,
'type' => "link",
'value' => $contract->id
]);
$ojournal->save();
}
}
$new_contracts[] = $contract;
}
$this->layout()->setFlash("$c Contracts erstellt", "success");
$this->redirect("Contract");
}
protected function apiAction() {
@@ -180,6 +288,9 @@ class ContractqueueController extends mfBaseController {
case "saveContract":
$return = $this->saveContractApi();
break;
case "setApproval":
$return = $this->setApprovalApi();
break;
default:
$return = false;
}
@@ -304,4 +415,31 @@ class ContractqueueController extends mfBaseController {
return ["contract" => $return, "credit" => $credit];
}
private function setApprovalApi() {
$r = $this->request;
//var_dump($r->get());exit;
$id = $r->cq_id;
if(!is_numeric($id) || $id < 1) {
return false;
}
$cq = new Contractqueue($id);
if(!$cq->id) {
return false;
}
if($r->type == "order") {
$cq->approved = $r->value;
}
if($r->type == "credit") {
$cq->approved_credit = $r->value;
}
$cq->save();
return ["message" => "contract saved"];
}
}

View File

@@ -236,7 +236,7 @@ class ContractqueueModel {
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'];
}
}
@@ -266,7 +266,16 @@ class ContractqueueModel {
$where .= " AND Contractqueue.id like '%$id%'";
}
}
if(array_key_exists("approved", $filter)) {
$approved = $filter['approved'];
if($approved) {
$where .= " AND Contractqueue.approved = 1";
} else {
$where .= " AND Contractqueue.approved = 0";
}
}
if(array_key_exists("contract_id", $filter)) {
$contract_id = $filter['contract_id'];
if(is_numeric($contract_id)) {

View File

@@ -453,7 +453,9 @@ class PreorderModel {
if(array_key_exists("partner_id", $filter)) {
$partner_id = $filter['partner_id'];
if(is_numeric($partner_id)) {
if(is_array($partner_id)) {
$where .= " AND partner_id IN (".join(",", $partner_id).")";
} elseif(is_numeric($partner_id)) {
$where .= " AND partner_id=$partner_id";
}
}

View File

@@ -15,6 +15,8 @@ class Preordercampaign extends mfBaseModel {
private $required_fields = [];
private $banned_fcps;
private $all_fcp_names;
private $active_operators;
private $passive_operators;
public function getAllFcpNames() {
if(!$this->id) return [];
@@ -184,7 +186,32 @@ class Preordercampaign extends mfBaseModel {
$this->banned_fcps = $banned_fcp_array;
return $this->banned_fcps;
}
if($name == "passive_operators") {
$pops = PreordercampaignOperatorModel::search(["preordercampaign_id" => $this->id, "type" => "passive"]);
if(!$pops) {
return [];
}
$this->passive_operators = [];
foreach($pops as $pop) {
$this->passive_operators[$pop->operator_id] = $pop;
}
return $this->passive_operators;
}
if($name == "active_operators") {
$aops = PreordercampaignOperatorModel::search(["preordercampaign_id" => $this->id, "type" => "active"]);
if(!$aops) {
return [];
}
$this->active_operators = [];
foreach($aops as $aop) {
$this->active_operators[$aop->operator_id] = $aop;
}
return $this->active_operators;
}
if($name == "apiusers") {
$items = PreordercampaignApiuserModel::search(["preordercampaign_id" => $this->id]);
foreach($items as $poa) {

View File

@@ -375,13 +375,145 @@ class PreordercampaignController extends mfBaseController {
}
}
}
//var_dump($r->get());exit;
// sync active operators and ISPs
if(is_array($r->active_operators) && count($r->active_operators)) {
// delete removed operators
foreach(PreordercampaignOperatorModel::search(["preordercampaign_id" => $campaign->id, "type" => "active"]) as $op) {
if(!in_array($op->operator_id, $r->active_operators)) {
$this->log->debug("deleting campaignoperator ".$op->id);
$op->delete(); // automatically deletes isps too
}
}
//var_dump($r->active_operators);exit;
// add missing operators
foreach($r->active_operators as $op_key => $op_id) {
if(!$op_id) continue;
$op = PreordercampaignOperatorModel::getFirst(["preordercampaign_id" => $campaign->id, "type" => "active", "operator_id" => $op_id]);
if(!$op) {
$op = PreordercampaignOperatorModel::create([
"preordercampaign_id" => $campaign->id,
"operator_id" => $op_id,
"type" => "active"
]);
$op->save();
}
//var_dump($r->active_isps, $op_id);exit;
// sync operators ISPs
if(is_array($r->active_isps) && array_key_exists($op_id, $r->active_isps) && count($r->active_isps[$op_id])) {
// delete removed ISPs
foreach(PreordercampaignOperatorIspModel::search(["campaignoperator_id" => $op_key]) as $isp) {
if(!array_key_exists($op_id, $r->active_isps) || !in_array($isp->isp_id, $r->active_isps[$op_id])) {
$this->log->debug("Deleting isp ".$isp->id." from operator $op_id");
$isp->delete();
}
}
// create new ISPs if not existing
//var_dump($op_key, $r->active_isps[$op_id]);exit;
foreach ($r->active_isps[$op_id] as $isp_id) {
if ($op_key == "new" || !PreordercampaignOperatorIspModel::getFirst(["campaignoperator_id" => $op_key, "isp_id" => $isp_id])) {
$new_isp = PreordercampaignOperatorIspModel::create([
"campaignoperator_id" => $op_key,
"isp_id" => $isp_id
]);
//var_dump($new_isp);exit;
if (!$new_isp->save()) {
$this->log->debug("Error saving isp " . print_r($new_isp, true));
}
$this->log->debug("created operatorIsp $op_id $isp_id");
}
}
} else {
// got empty ISP list, so delete all ISPs
if($op_id && $op_key != "new") {
foreach(PreordercampaignOperatorIspModel::search(["campaignoperator_id" => $op_key]) as $isp) {
$this->log->debug("Deleting all ISPs for $op_id");
$isp->delete();
}
}
}
}
} else {
// got empty operator list, delete all
foreach(PreordercampaignOperatorModel::search(["preordercampaign_id" => $campaign->id, "type" => "active"]) as $op) {
$op->delete(); // automatically deletes isps too
}
}
if(is_array($r->passive_operators)) {
if(!count($r->passive_operators)) {
foreach(PreordercampaignOperatorModel::search(["preordercampaign_id" => $campaign->id, "type" => "passive"]) as $op) {
$op->delete();
}
} else {
foreach(PreordercampaignOperatorModel::search(["preordercampaign_id" => $campaign->id, "type" => "passive"]) as $op) {
if(!in_array($op->id, $r->passive_operators)) {
$op->delete();
}
}
foreach($r->passive_operators as $op_id) {
if(!$op_id) continue;
if(!PreordercampaignOperatorModel::getFirst(["preordercampaign_id" => $campaign->id, "type" => "passive", "operator_id" => $op_id])) {
$new_op = PreordercampaignOperatorModel::create([
"preordercampaign_id" => $campaign->id,
"operator_id" => $op_id,
"type" => "passive"
]);
$new_op->save();
}
}
}
} else {
foreach(PreordercampaignOperatorModel::search(["preordercampaign_id" => $campaign->id, "type" => "passive"]) as $op) {
$op->delete();
}
}
$this->layout()->setFlash("Vorbestellkampagne erfolgreich gespeichert.", "success");
//$this->redirect("Preordercampaign", "Edit", ['id' => $new_id]);
$this->redirect("Preordercampaign");
if($r->return == "index") {
$this->redirect("Preordercampaign");
}
$this->redirect("Preordercampaign", "Edit", ['id' => $new_id]);
}
protected function billingAction() {
if(!$this->me->is("Admin")) {
$this->redirect("Preordercampaign");
}
$id = $this->request->id;
if(!is_numeric($id) || !$id) {
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
$this->redirect("Preordercampaign");
}
$campaign = new Preordercampaign($id);
if(!$campaign->id) {
$this->layout()->setFlash("Vorbestellkampagne nicht gefunden", "error");
$this->redirect("Preordercampaign");
}
// Get mysqli resource from Model, so layout can output data as it's retrieved
// Works around lousy performance and horrendous memory usage
$res = PreorderModel::searchActive(["preordercampaign_id" => $id], [], true);
$this->layout()->setTemplate("Preorder/billing-export.csv");
$this->layout()->set("res", $res);
$this->layout()->set("campaign", $campaign);
}
protected function downloadAddonServices() {
$id = $this->request->preordercampaign_id;
if(!is_numeric($id) || !$id) {

View File

@@ -0,0 +1,52 @@
<?php
class PreordercampaignOperator extends mfBaseModel
{
private $operator;
private $preordercampaign;
private $isps;
protected function beforeDelete() {
// delete all ISPs
foreach(PreordercampaignOperatorIspModel::search(["campaignoperator_id" => $this->id]) as $isp) {
$isp->delete();
}
return true;
}
public function getProperty($name) {
if($this->$name == null) {
if($name == "isps") {
$isps = PreordercampaignOperatorIspModel::search(["campaignoperator_id" => $this->id]);
if(!$isps) {
return [];
}
foreach($isps as $isp) {
$this->isps[$isp->isp_id] = $isp;
}
return $this->isps;
}
if($name == "operator") {
$operator = mfValuecache::singleton()->getMfObject("Address", $this->operator_id);
if(!$operator) {
return null;
}
$this->operator = $operator;
return $this->operator;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = mfValuecache::singleton()->getMfObject($classname, $this->$idfield);
if(!$this->$name) {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,169 @@
<?php
class PreordercampaignOperatorModel {
public $preordercampaign_id;
public $operator_id;
public $type;
public $create_by;
public $edit_by;
public $create;
public $edit;
public static function create(Array $data) {
$model = new PreordercampaignOperator();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("PreordercampaignOperator", "*", "1=1 ORDER BY id");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new PreordercampaignOperator($data);
}
}
return $items;
}
public static function getFirst($filter = null) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
mfLoghandler::singleton()->debug($where);
$res = $db->select("PreordercampaignOperator", "*", "$where ORDER BY id");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new PreordercampaignOperator($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function getFirstOaid($oaid) {
$db = FronkDB::singleton();
if(!$oaid) return null;
$where = self::getSqlFilter(["oaid" => $oaid]);
//mfLoghandler::singleton()->debug($where);
$res = $db->select("PreordercampaignOperator", "*", "$where ORDER BY id");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new PreordercampaignOperator($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function count($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(*) as cnt FROM PreordercampaignOperator
WHERE $where
";
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
return $data->cnt;
}
return 0;
}
public static function search($filter, $limit = false) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT * FROM PreordercampaignOperator
WHERE $where
ORDER BY 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'];
}
}
$res = $db->query($sql);
//mfLoghandler::singleton()->debug($sql);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new PreordercampaignOperator($data);
}
}
return $items;
}
private static function getSqlFilter($filter) {
$db = FronkDB::singleton();
$where = "1=1 ";
if(!is_array($filter)) {
return $where;
}
if(array_key_exists("preordercampaign_id", $filter)) {
$preordercampaign_id = $filter['preordercampaign_id'];
if(is_numeric($preordercampaign_id)) {
$where .= " AND preordercampaign_id = $preordercampaign_id";
}
}
if(array_key_exists("operator_id", $filter)) {
$operator_id = $filter['operator_id'];
if(is_numeric($operator_id)) {
$where .= " AND operator_id = $operator_id";
}
}
if(array_key_exists("type", $filter)) {
$type = $db->escape($filter['type']);
if($type) {
$where .= " AND type LIKE '$type'";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,30 @@
<?php
class PreordercampaignOperatorIsp extends mfBaseModel
{
private $isp;
public function getProperty($name) {
if($this->$name == null) {
if($name == "isp") {
$isp = mfValuecache::singleton()->getMfObject("Address", $this->isp_id);
if(!$isp) {
return null;
}
$this->isp = $isp;
return $this->isp;
}
$classname = ucfirst($name);
$idfield = $name."_id";
$this->$name = mfValuecache::singleton()->getMfObject($classname, $this->$idfield);
if(!$this->$name) {
return null;
}
}
return $this->$name;
}
}

View File

@@ -0,0 +1,160 @@
<?php
class PreordercampaignOperatorIspModel {
public $campaignoperator_id;
public $isp_id;
public $type;
public $create_by;
public $edit_by;
public $create;
public $edit;
public static function create(Array $data) {
$model = new PreordercampaignOperatorIsp();
foreach($data as $field => $value) {
if(property_exists(get_called_class(), $field)) {
$model->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("PreordercampaignOperatorIsp", "*", "1=1 ORDER BY id");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new PreordercampaignOperatorIsp($data);
}
}
return $items;
}
public static function getFirst($filter = null) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
mfLoghandler::singleton()->debug($where);
$res = $db->select("PreordercampaignOperatorIsp", "*", "$where ORDER BY id");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new PreordercampaignOperatorIsp($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function getFirstOaid($oaid) {
$db = FronkDB::singleton();
if(!$oaid) return null;
$where = self::getSqlFilter(["oaid" => $oaid]);
//mfLoghandler::singleton()->debug($where);
$res = $db->select("PreordercampaignOperatorIsp", "*", "$where ORDER BY id");
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new PreordercampaignOperatorIsp($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function count($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(*) as cnt FROM PreordercampaignOperatorIsp
WHERE $where
";
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
return $data->cnt;
}
return 0;
}
public static function search($filter, $limit = false) {
$items = [];
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT * FROM PreordercampaignOperatorIsp
WHERE $where
ORDER BY 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'];
}
}
$res = $db->query($sql);
//mfLoghandler::singleton()->debug($sql);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new PreordercampaignOperatorIsp($data);
}
}
return $items;
}
private static function getSqlFilter($filter) {
$db = FronkDB::singleton();
$where = "1=1 ";
if(!is_array($filter)) {
return $where;
}
if(array_key_exists("isp_id", $filter)) {
$isp_id = $filter['isp_id'];
if(is_numeric($isp_id)) {
$where .= " AND isp_id = $isp_id";
}
}
if(array_key_exists("campaignoperator_id", $filter)) {
$campaignoperator_id = $filter['campaignoperator_id'];
if(is_numeric($campaignoperator_id)) {
$where .= " AND campaignoperator_id = $campaignoperator_id";
}
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -105,7 +105,7 @@ class PreorderstatusModel {
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'];
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class CreatePreordercampaignOperators extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
$table = $this->table("PreordercampaignOperator");
$table->addColumn("preordercampaign_id", "integer", ["null" => false]);
$table->addColumn("operator_id", "integer", ["null" => false]);
$table->addColumn("type", "enum", ["null" => false, "values" => "active,passive", "default" => "active"]);
$table->addColumn("create_by", "integer", ["null" => false]);
$table->addColumn("edit_by", "integer", ["null" => false]);
$table->addColumn("create", "integer", ["null" => false]);
$table->addColumn("edit", "integer", ["null" => false]);
$table->create();
$table = $this->table("PreordercampaignOperatorIsp");
$table->addColumn("campaignoperator_id", "integer", ["null" => false]);
$table->addColumn("isp_id", "integer", ["null" => false]);
$table->addColumn("create_by", "integer", ["null" => false]);
$table->addColumn("edit_by", "integer", ["null" => false]);
$table->addColumn("create", "integer", ["null" => false]);
$table->addColumn("edit", "integer", ["null" => false]);
$table->create();
}
if($this->getEnvironment() == "addressdb") {
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
$this->table("PreordercampaignOperatorIsp")->drop()->save();
$this->table("PreordercampaignOperator")->drop()->save();
}
if($this->getEnvironment() == "addressdb") {
}
}
}

View File

@@ -55,6 +55,7 @@ $l['contract.upgrade'] = "Upgrade";
$l['contract.downgrade'] = "Downgrade";
$l['contract.relocation'] = "Umzug";
$l['contract.productchange'] = "Produktwechsel";
$l['contract.credit'] = "Gutschrift";
$l['cc.oesterreich'] = "AT";

View File

@@ -212,6 +212,12 @@ class mfBaseModel {
if($this->fieldprefix && !strstr($field,"_")) {
$where=$this->fieldprefix."_id=$id";
}
if(method_exists($this, "beforeDelete")) {
// delete can be canceled
if(!$this->beforeDelete()) {
return false;
}
}
if($this->db->delete($this->table,$where)) {
if(method_exists($this, "afterDelete")) {
$this->afterDelete();

View File

@@ -262,7 +262,7 @@ class AddressHelper
}
if (!$strasse) {
$this->logFindAddressError("[EE] Konnte Strasse '$strasse_name' in Gemeinde '$gemeinde_id' nicht anlegen ($addr_dbg_str)");
$this->logFindAddressError("[EE] Konnte Strasse '$strasse_name' in Gemeinde '$gemeinde_id' nicht finden bzw. anlegen ($addr_dbg_str)");
return false;
}