Contractqueue changes
This commit is contained in:
@@ -194,8 +194,12 @@
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<div class="card mb-1">
|
||||
<div class="card mb-1" id="orderjournal-<?=$order->id?>" style="max-height: 280px; overflow: hidden; ">
|
||||
<div onclick="toggleJournal(<?=$order->id?>)" class="opener text-center align-bottom pointer" style="position: absolute ; bottom: 0; height: 60px; width: 100%; background: linear-gradient(0deg, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100%);">
|
||||
<i class="fas fa-chevron-down text-secondary" style="font-size: 18px; position:absolute; bottom:8px;"></i>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<h5 class="m-0">Bestelljournal</h5>
|
||||
|
||||
<table class="table table-sm table-striped mt-1 mb-0">
|
||||
@@ -248,6 +252,7 @@
|
||||
<th>Verz. Verrechnungsstart</th>
|
||||
<th>Erstellt</th>
|
||||
<th>Zuletzt bearbeitet</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<?php foreach($contracts as $contract): ?>
|
||||
@@ -354,6 +359,11 @@
|
||||
</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>
|
||||
<td>
|
||||
<a href="<?=self::getUrl("Contractqueue", "deletePosition", ["op_id" => $contract->orderproduct_id])?>" onclick="if(!confirm('Löscht die Position in Bestellung und Contractqueue. Wirklich löschen?')) return false;">
|
||||
<i class="far fa-xmark text-danger" title="Position in Bestellung und Contractqueue löschen"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
@@ -721,6 +731,11 @@
|
||||
});
|
||||
}
|
||||
|
||||
function toggleJournal(order_id) {
|
||||
$("#orderjournal-" + order_id).find("div.opener").remove();
|
||||
$("#orderjournal-" + order_id).css("max-height", "550px").css("overflow", "auto");
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -94,6 +94,7 @@ class ContractModel {
|
||||
$data["price_setup"] = $op->price_setup;
|
||||
$data["price_nne"] = $op->price_nne;
|
||||
$data["price_nbe"] = $op->price_nbe;
|
||||
$data["vatgroup_id"] = $op->product->vatgroup_id;
|
||||
$data["billing_delay"] = $op->billing_delay;
|
||||
$data["billing_period"] = $op->billing_period;
|
||||
$data["order_date"] = $order->order_date;
|
||||
@@ -152,6 +153,7 @@ class ContractModel {
|
||||
$data["price_setup"] = $cq->price_setup;
|
||||
$data["price_nne"] = $cq->price_nne;
|
||||
$data["price_nbe"] = $cq->price_nbe;
|
||||
$data["vatgroup_id"] = $cq->vatgroup_id;
|
||||
$data["billing_delay"] = $cq->billing_delay;
|
||||
$data["billing_period"] = $cq->billing_period;
|
||||
$data["contract_term"] = $cq->contract_term;
|
||||
|
||||
@@ -15,6 +15,8 @@ class ContractqueueController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function indexAction() {
|
||||
$this->importOrders();
|
||||
|
||||
if($this->request->resetFilter) {
|
||||
unset($_SESSION[MFAPPNAME.'-Contractqueue-filter']);
|
||||
}
|
||||
@@ -67,22 +69,65 @@ class ContractqueueController extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function getPreparedFilter($filter) {
|
||||
|
||||
return $filter;
|
||||
}
|
||||
|
||||
protected function importFinishedOrdersAction() {
|
||||
$o = 0;
|
||||
$max_orders = 1500;
|
||||
|
||||
$not_before = new DateTime("2024-07-10");
|
||||
protected function deletePosition() {
|
||||
$op_id = $this->request->op_id;
|
||||
|
||||
$cq = ContractqueueModel::getFirst(["orderproduct_id" => $op_id]);
|
||||
if(!$cq) {
|
||||
$this->layout()->setFlash("Bestellung in Contractqueue nicht gefunden", "error");
|
||||
$this->redirect("Contractqueue");
|
||||
}
|
||||
|
||||
$op = new OrderProduct($op_id);
|
||||
if(!$op->id) {
|
||||
$this->layout()->setFlash("Bestellung nicht gefunden", "error");
|
||||
$this->redirect("Contractqueue");
|
||||
}
|
||||
|
||||
$order = $op->order;
|
||||
if(!$order) {
|
||||
$this->layout()->setFlash("Bestellung nicht gefunden", "error");
|
||||
$this->redirect("Contractqueue");
|
||||
}
|
||||
|
||||
if(!is_array($order->products) || $order->products < 2 ) {
|
||||
$this->layout()->setFlash("Nur ein Produkt in Bestellung gefunden. Kann nicht gelöscht werden", "warning");
|
||||
$this->redirect("Contractqueue");
|
||||
}
|
||||
|
||||
$this->log->debug(__METHOD__.": Deleting OrderProduct $op_id from Order ".$order->id." (product_id: ".$op->product_id." product_name: ".$op->product->name." price: ".$op->price." price_setup: ".$op->price_setup." termination_id: ".$op->termination_id." voicenumber: ".$op->voicenumber.")");
|
||||
|
||||
if(!$op->delete()) {
|
||||
$this->layout()->setFlash("Fehler beim Löschen der Bestellposition", "error");
|
||||
$this->redirect("Contractqueue");
|
||||
}
|
||||
|
||||
if(!$cq->delete()) {
|
||||
$this->layout()->setFlash("Fehler beim Löschen der Contractqueue Position", "error");
|
||||
$this->redirect("Contractqueue");
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Position erfolgreich gelöscht", "success");
|
||||
$this->redirect("Contractqueue");
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function importOrders() {
|
||||
$o = 0;
|
||||
//$max_orders = 1500;
|
||||
|
||||
$not_before = new DateTime("2024-07-01");
|
||||
|
||||
foreach(OrderModel::search(["finish_date" => true, "finish_date<" => date("U"), "finish_date>" => $not_before->getTimestamp()]) as $order) {
|
||||
if(!is_array($order->products) || !count($order->products)) {
|
||||
//echo "keine Produkte in Order ".$order->id."\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(ContractqueueModel::getFirst(["order_id" => $order->id])) {
|
||||
continue;
|
||||
}
|
||||
@@ -90,7 +135,7 @@ class ContractqueueController extends mfBaseController {
|
||||
$skip_order = false;
|
||||
$contracts = [];
|
||||
$primary_matchcode = false;
|
||||
|
||||
|
||||
|
||||
foreach($order->products as $op) {
|
||||
$contract = ContractModel::getFirst(["orderproduct_id" => $op->id]);
|
||||
@@ -108,10 +153,10 @@ class ContractqueueController extends mfBaseController {
|
||||
$skip_order = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// if contract does not exist yet, create Contractqueue
|
||||
$contract = ContractqueueModel::createFromOrderproduct($op);
|
||||
|
||||
|
||||
// find reseller / receiver of credit
|
||||
// from product
|
||||
$product_attribs = $contract->product->attributes;
|
||||
@@ -130,7 +175,7 @@ class ContractqueueController extends mfBaseController {
|
||||
if(!$contract->crediting_partner_id && $contract->termination_id) {
|
||||
$contract->crediting_partner_id = $contract->termination->building->network->owner_id;
|
||||
}
|
||||
|
||||
|
||||
if($contract->matchcode) {
|
||||
$primary_matchcode = $contract->matchcode;
|
||||
}
|
||||
@@ -142,26 +187,26 @@ class ContractqueueController extends mfBaseController {
|
||||
$contracts = [];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if(!$primary_matchcode) {
|
||||
$primary_matchcode = $order->owner->street.", ".$order->owner->zip." ".$order->owner->city;
|
||||
}
|
||||
|
||||
|
||||
$links = [];
|
||||
// set matchcode and save
|
||||
foreach($contracts as $contract) {
|
||||
if(!$contract->matchcode) {
|
||||
$contract->matchcode = $primary_matchcode;
|
||||
|
||||
|
||||
}
|
||||
//var_dump($contract);exit;
|
||||
$contract->save();
|
||||
|
||||
|
||||
/*if(!count($links)) {
|
||||
$links[$contract->id] = $contract;
|
||||
} elseif(!array_key_exists($contract->id, $links)) {
|
||||
$first_link = reset($links);
|
||||
|
||||
|
||||
$new_link = ContractLinkModel::create([
|
||||
"contract_id" => $first_link->id,
|
||||
"origin_contract_id" => $contract->id,
|
||||
@@ -170,18 +215,13 @@ class ContractqueueController extends mfBaseController {
|
||||
$new_link->save();
|
||||
$links[$contract->id] = $contract;
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
$o++;
|
||||
|
||||
if($o >= $max_orders) {
|
||||
$this->layout()->setFlash("$o Bestellungen importiert, es gibt noch mehr Bestellungen zum importieren.", "info");
|
||||
$this->redirect("Contractqueue");
|
||||
}
|
||||
}
|
||||
$this->layout()->setFlash("Alle Bestellungen importiert", "success");
|
||||
$this->redirect("Contractqueue");
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
protected function commitAction() {
|
||||
@@ -238,6 +278,7 @@ class ContractqueueController extends mfBaseController {
|
||||
$journal->save();
|
||||
|
||||
$contract->addFilesFromOrder();
|
||||
$contract->addJournalFromOrder();
|
||||
|
||||
/*
|
||||
* Create Crediting Contract
|
||||
|
||||
@@ -23,6 +23,7 @@ class ContractqueueModel {
|
||||
public $price_setup = null;
|
||||
public $price_nne = null;
|
||||
public $price_nbe = null;
|
||||
public $vatgroup_id = null;
|
||||
public $billing_delay = null;
|
||||
public $billing_period = null;
|
||||
public $order_date;
|
||||
@@ -100,6 +101,7 @@ class ContractqueueModel {
|
||||
$data["price_setup"] = $op->price_setup;
|
||||
$data["price_nne"] = $op->price_nne;
|
||||
$data["price_nbe"] = $op->price_nbe;
|
||||
$data["vatgroup_id"] = $op->product->vatgroup_id;
|
||||
$data["billing_delay"] = $op->billing_delay;
|
||||
$data["billing_period"] = $op->billing_period;
|
||||
$data["order_date"] = $order->order_date;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class ContractqueueAddVatgroupId extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Contractqueue");
|
||||
$table->addColumn("vatgroup_id", "integer", ["null" => false, "after" => "price_nbe"]);
|
||||
$table->save();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user