318 lines
21 KiB
PHP
318 lines
21 KiB
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("Admin")?>">Admin</a></li>
|
|
<li class="breadcrumb-item active">RTR Reporting</li>
|
|
</ol>
|
|
</div>
|
|
<h4 class="page-title">Massenproduktwechsel</h4>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- end page title -->
|
|
|
|
<div class="row">
|
|
<div class="col-12 col-xl-10">
|
|
<h3>Produktwechsel erstellen</h3>
|
|
<div class="card">
|
|
<div class="card-body">
|
|
|
|
<div class="row">
|
|
<div class="col-6">
|
|
|
|
<div class="alert alert-purple">
|
|
Sucht alle aktiven Contracts mit <strong>bisherigem Produkt</strong> und erstellt jeweils einen <strong>Produktwechsel</strong>.
|
|
</div>
|
|
|
|
<form method="post" action="<?=self::getUrl("Admin", "massProductchange", ["do" => "create"])?>">
|
|
<div class="form-group">
|
|
<label for="old_product_ids">Bisherige Produkte</label>
|
|
<select name="old_product_ids[]" class="form-control select2" multiple="multiple">
|
|
<?php foreach(ProductModel::getAll() as $product): ?>
|
|
<option value="<?=$product->id?>" <?=(isset($old_product_ids) && is_array($old_product_ids) && in_array($product->id, $old_product_ids)) ? "selected='selected'" : ""?>><?=$product->name?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="new_product_id">Neues Produkt</label>
|
|
<select name="new_product_id" class="form-control select2">
|
|
<?php foreach(ProductModel::getActive() as $product): ?>
|
|
<option value="<?=$product->id?>" <?=(isset($new_product_id) && $new_product_id && $new_product_id == $product->id) ? "selected='selected'" : ""?>><?=$product->name?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<small>Individuelle Produktnamen werden mit neuem Produktname überschrieben.</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="price_type">Neuer Preis</label>
|
|
<select name="price_type" id="price_type" class="form-control">
|
|
<option value="keep" <?=(isset($price_type) && $price_type && $price_type == "keep") ? "selected='selected'" : ""?>>Bisherigen Preis beibehalten</option>
|
|
<option value="from_new_product" <?=(isset($price_type) && $price_type && $price_type == "from_new_product") ? "selected='selected'" : ""?>>Preis vom neuen Produkt übernehmen</option>
|
|
<option value="fixed" <?=(isset($price_type) && $price_type && $price_type == "fixed") ? "selected='selected'" : ""?>>Fixen Preis definieren</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div id="from_new_product_container" class="hidden mb-3">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="commit_setup_price" id="commit_setup_price" value="1" />
|
|
<label class="form-check-label" for="commit_setup_price">Setuppreis verrechnen</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="fix_price_container" class="hidden">
|
|
<div class="row mb-3">
|
|
<div class="col-1"></div>
|
|
<div class="col-11">
|
|
<div class="form-group">
|
|
<label for="fix_price_setup">Fixpreis Setup</label>
|
|
<input type="text" name="fix_price_setup" class="form-control" placeholder="Neuer Setup Preis" value="">
|
|
<small>Wenn beim Produktwechsel ein Einmalentgelt verrechnet werden soll</small>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="fix_price">Fixpreis</label>
|
|
<input type="text" name="fix_price" class="form-control" placeholder="Neuer Preis" value="">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="linked_contracts_action">Verknüpfte Contracts</label>
|
|
<select name="linked_contracts_action" id="linked_contracts_action" class="form-control">
|
|
<option value="keep" <?=(isset($linked_contracts_action) && $linked_contracts_action && $linked_contracts_action == "keep") ? "selected='selected'" : ""?>>übernehmen</option>
|
|
<option value="cancel" <?=(isset($linked_contracts_action) && $linked_contracts_action && $linked_contracts_action == "cancel") ? "selected='selected'" : ""?>>Kündigen</option>
|
|
</select>
|
|
<small>Betrifft nur Zusatzprodukte; Provisionsgutschriften werden automatisch richtig zugeordnet.</small>
|
|
</div>
|
|
|
|
<div id="linked_contracts_cancel_container" class="hidden mb-3">
|
|
<div class="row mb-4">
|
|
<div class="col-1"></div>
|
|
<div class="col-11">
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="radio" name="link_action_cancel_type" id="link_action_cancel_type_finish_date" value="finish_date" <?=(isset($link_action_cancel_type) && $link_action_cancel_type && $link_action_cancel_type == "finish_date") ? "checked='checked'" : ""?> />
|
|
<label class="form-check-label" for="link_action_cancel_type_finish_date">Kündigungsdatum = Fertigstellungsdatum des Produktwechsels</label>
|
|
</div>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="radio" name="link_action_cancel_type" id="link_action_cancel_type_link_billing_period" value="link_billing_period" <?=(isset($link_action_cancel_type) && $link_action_cancel_type && $link_action_cancel_type == "link_billing_period") ? "checked='checked'" : ""?> />
|
|
<label class="form-check-label" for="link_action_cancel_type_link_billing_period">Kündigungsdatum = Nach aktueller Verrechnungsperiode (z.B. Ende des Monats)</label>
|
|
</div>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="radio" name="link_action_cancel_type" id="link_action_cancel_type_link_contract_term" value="link_contract_term" <?=(isset($link_action_cancel_type) && $link_action_cancel_type && $link_action_cancel_type == "link_contract_term") ? "checked='checked'" : ""?> />
|
|
<label class="form-check-label" for="link_action_cancel_type_link_contract_term">Kündigungsdatum = Ende der Vertragslaufzeit des verlinkten Contracts</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="exclude_termination_contracts" id="exclude_termination_contracts" value="1" <?=(isset($exclude_termination_contracts) && $exclude_termination_contracts) ? "checked='checked'" : ""?> />
|
|
<label class="form-check-label" for="exclude_termination_contracts">Nur Contracts ohne verknüpften Anschluss</label>
|
|
</div>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" name="no_provision_credits" id="no_provision_credits" value="1" <?=(isset($no_provision_credits) && $no_provision_credits) ? "checked='checked'" : ""?> />
|
|
<label class="form-check-label" for="no_provision_credits">Keine Provisionsgutschriften erstellen</label>
|
|
</div>
|
|
|
|
<div class="form-group mt-3">
|
|
<label for="change_date">Produktwechsel durchführen am</label>
|
|
<input type="text" name="change_date" class="form-control datepicker" value="<?=(isset($change_date) && $change_date) ? $change_date : ""?>">
|
|
<small> = Fertigstellungsdatum vom neuen Contract</small>
|
|
</div>
|
|
|
|
<button type="submit" name="preview" value="1" class="btn btn-primary">Vorschau</button>
|
|
<?php if(isset($change_contracts)): ?>
|
|
<button type="submit" name="commit" value="1" class="btn btn-danger">Produktwechsel jetzt erstellen</button>
|
|
<?php endif; ?>
|
|
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if(isset($change_contracts)): ?>
|
|
<div class="row">
|
|
<div class="col">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<h3>Produktwechsel Vorschau</h3>
|
|
<p><?=count($change_contracts)?> Contracts zum Umstellen gefunden.</p>
|
|
<p>Hier werden alle Produktwechsel angezeigt, die erstellt werden.</p>
|
|
</div>
|
|
</div>
|
|
<?php foreach($change_contracts as $cc): ?>
|
|
<?php $oc = $cc["old_contract"]; ?>
|
|
<?php $nc = $cc["new_contract"]; ?>
|
|
<div class="card">
|
|
<table class="table table-sm m-3">
|
|
<tr>
|
|
<th></th>
|
|
<th>Alter Contract</th>
|
|
<th>Neuer Contract</th>
|
|
</tr>
|
|
<tr>
|
|
<th>Contract ID</th>
|
|
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $oc->id])?>" target="_blank"><?=$oc->id?></a></td>
|
|
<td>neu </td>
|
|
</tr>
|
|
<tr>
|
|
<th>Vertragsinhaber</th>
|
|
<td><a href="<?=self::getUrl("Address", "view", ["id" => $oc->owner_id])?>" target="_blank"><?=$oc->owner->getCompanyOrName()?></a></td>
|
|
<td><a href="<?=self::getUrl("Address", "view", ["id" => $nc->owner_id])?>" target="_blank"><?=$nc->owner->getCompanyOrName()?></a></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Rechnungsempfänger</th>
|
|
<td><a href="<?=self::getUrl("Address", "view", ["id" => $oc->billingaddress_id])?>" target="_blank"><?=$oc->billingaddress->getCompanyOrName()?></a></td>
|
|
<td><a href="<?=self::getUrl("Address", "view", ["id" => $nc->billingaddress_id])?>" target="_blank"><?=$nc->billingaddress->getCompanyOrName()?></a></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Matchcode</th>
|
|
<td><?=$oc->matchcode?></td>
|
|
<td><?=$nc->matchcode?></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Produktname</th>
|
|
<th><?=$oc->product->name?></th>
|
|
<th><?=$nc->product->name?></th>
|
|
</tr>
|
|
<tr>
|
|
<th>Contract Produktname</th>
|
|
<td><?=$oc->product_name?></td>
|
|
<td><?=$nc->product_name?></td>
|
|
</tr>
|
|
<tr>
|
|
<th>Preis</th>
|
|
<th>€ <?=number_format(($oc->amount != 1) ? $oc->price * $oc->amount : $oc->price, 4, ",", ".")?></th>
|
|
<th>€ <?=number_format(($nc->amount != 1) ? $nc->price * $nc->amount : $nc->price, 4, ",", ".")?></th>
|
|
</tr>
|
|
<tr>
|
|
<th>Setup Preis</th>
|
|
<td>€ <?=number_format($oc->price_setup, 4, ",", ".")?><?=($oc->amount != 1) ? " (Gesamt: € ".number_format($oc->price_setup * $oc->amount, 4, ",", ".").")" : ""?></td>
|
|
<td><?=number_format($nc->price_setup, 4, ",", ".")?><?=($nc->amount != 1) ? " (Gesamt: € ".number_format($nc->price_setup * $nc->amount, 4, ",", ".").")" : ""?></td>
|
|
</tr>
|
|
</table>
|
|
|
|
<hr />
|
|
|
|
<div class="card-body">
|
|
<h5>Verknüpfungen</h5>
|
|
<?php if($cc["linked_contracts"]): ?>
|
|
<table class="table table-sm table-striped">
|
|
<tr>
|
|
<th class="text-right">Aktion</th>
|
|
<th>Contract ID</th>
|
|
<th>Matchcode</th>
|
|
<th>Produkt</th>
|
|
<th>Preis</th>
|
|
<th>Setup Preis</th>
|
|
</tr>
|
|
<?php foreach($cc["linked_contracts"] as $lc): ?>
|
|
<?php //var_dump($lc); ?>
|
|
<?php if(is_object($lc["link_from"]) && $lc["action"] != "create_credit" && $lc["link_from"]->id): ?>
|
|
<tr>
|
|
<td class="text-right">
|
|
<?php if($lc["action"] == "keep"): ?>
|
|
Verknüpfung mit
|
|
<?php elseif($lc["action"] == "cancel"): ?>
|
|
<span class="text-danger">Verlinkten Contract kündigen</span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?=$lc["link_from"]->id ?? "neu"?></td>
|
|
<td><?=$lc["link_from"]->matchcode?></td>
|
|
<td><?=$lc["link_from"]->product->name?></td>
|
|
<td class="<?=($lc["link_from"]->price < 0) ? "text-danger" : ""?>">€ <?=number_format(($lc["link_from"]->amount != 1) ? $lc["link_from"]->price * $lc["link_from"]->amount : $lc["link_from"]->price, 4, ",", ".")?></td>
|
|
<td>€ <?=number_format($lc["link_from"]->price_setup, 4, ",", ".")?><?=($lc["link_from"]->amount != 1) ? " (Gesamt: € ".number_format($lc["link_from"]->price_setup * $lc["link_from"]->amount, 4, ",", ".").")" : ""?></td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
<?php if(is_object($lc["link_to"]) && $lc["link_to"]->product_id): ?>
|
|
<tr>
|
|
<td class="text-right">
|
|
<?php if($lc["action"] == "keep"): ?>
|
|
Verknüpfung mit
|
|
<?php elseif($lc["action"] == "create_credit"): ?>
|
|
neue Gutschrift an <strong><?=$lc["link_to"]->owner->getCompanyOrName()?></strong>
|
|
<?php elseif($lc["action"] == "cancel_credit"): ?>
|
|
<span class="text-danger">Gutschrift kündigen</span>
|
|
<?php endif; ?>
|
|
|
|
</td>
|
|
<td><?=$lc["link_to"]->id ?? "neu"?></td>
|
|
<td><?=$lc["link_to"]->matchcode?></td>
|
|
<td><?=$lc["link_to"]->product->name?></td>
|
|
<td class="<?=($lc["link_to"]->price < 0) ? "text-danger" : ""?>">€ <?=number_format(($lc["link_to"]->amount != 1) ? $lc["link_to"]->price * $lc["link_to"]->amount : $lc["link_to"]->price, 4, ",", ".")?></td>
|
|
<td>€ <?=number_format($lc["link_to"]->price_setup, 4, ",", ".")?><?=($lc["link_to"]->amount != 1) ? " (Gesamt: € ".number_format($lc["link_to"]->price_setup * $lc["link_to"]->amount, 4, ",", ".").")" : ""?></td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
<?php if(is_object($lc["credit"])): ?>
|
|
<tr>
|
|
<td class="text-right">Gutschrift</td>
|
|
<td><?=$lc["credit"]->id ?? "neu"?></td>
|
|
<td><?=$lc["credit"]->matchcode?></td>
|
|
<td><?=$lc["credit"]->owner->getCompanyOrName()?></td>
|
|
<td class="<?=($lc["credit"]->price < 0) ? "text-danger" : ""?>">€ <?=number_format(($lc["credit"]->amount != 1) ? $lc["credit"]->price * $lc["credit"]->amount : $lc["credit"]->price, 4, ",", ".")?></td>
|
|
<td>€ <?=number_format($lc["credit"]->price_setup, 4, ",", ".")?><?=($lc["credit"]->amount != 1) ? " (Gesamt: € ".number_format($lc["credit"]->price_setup * $lc["credit"]->amount, 4, ",", ".").")" : ""?></td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
<?php endforeach; ?>
|
|
</table>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
$(".select2").select2({
|
|
placeholder: "Bisheriges Produkt auswählen",
|
|
closeOnSelect: false,
|
|
});
|
|
$('.datepicker').datepicker({
|
|
language: 'de',
|
|
format: "dd.mm.yyyy",
|
|
showWeekDays: true,
|
|
todayBtn: 'linked',
|
|
autoclose: true
|
|
});
|
|
|
|
$("#price_type").change(function() {
|
|
if($(this).val() == "fixed") {
|
|
$("#fix_price_container").show();
|
|
} else {
|
|
$("#fix_price_container").hide();
|
|
}
|
|
|
|
if($(this).val() == "from_new_product") {
|
|
$("#from_new_product_container").show();
|
|
} else {
|
|
$("#from_new_product_container").hide();
|
|
}
|
|
});
|
|
|
|
$("#linked_contracts_action").change(function() {
|
|
if($(this).val() == "cancel") {
|
|
$("#linked_contracts_cancel_container").show();
|
|
} else {
|
|
$("#linked_contracts_cancel_container").hide();
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<?php include(realpath(dirname(__FILE__)."/../../../$mfLayoutPackage")."/footer.php"); ?>
|