Contractqueue: commit to Contract finished
This commit is contained in:
@@ -377,7 +377,7 @@
|
||||
*/
|
||||
<?php if($contract->product_id && is_object(($contract->product))): ?>
|
||||
$('#product_id').autoComplete('set', { value: <?=$contract->product_id?>, text: '<?=($contract->product_id) ? str_replace("'", "\\'", str_replace(["\n", "\r"], " ", $contract->product->name))." [".$contract->product_id."]" : ""?>'});
|
||||
<?php if(array_key_exists("termination_required", $contract->product) && $contract->product->attributes["termination_required"] != 1): ?>
|
||||
<?php if(array_key_exists("termination_required", $contract->product->attributes) && $contract->product->attributes["termination_required"] != 1): ?>
|
||||
$("#termination_row").hide();
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
|
||||
@@ -63,7 +63,14 @@
|
||||
<option value="1" <?=($filter['show_canceled'] == 1 ) ? "selected='selected'" : ""?>>Anzeigen</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-2">
|
||||
<label class="form-label" for="filter_show_credit">Gutschriften</label>
|
||||
<select class="form-control" name="filter[show_credit]" id="filter_show_credit">
|
||||
<option value="0" <?=($filter['show_credit'] == 0) ? "selected='selected'" : ""?>>Ausblenden</option>
|
||||
<option value="1" <?=($filter['show_credit'] == 1 ) ? "selected='selected'" : ""?>>Anzeigen</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col">
|
||||
@@ -110,8 +117,8 @@
|
||||
<tr>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->id?></a></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $contract->owner_id])?>" target="_blank"><i class="far fa-eyes" title="Kunde in neuem Tab anzeigen"></i></a> <?=$contract->owner->getCompanyOrName()?> (<?=$contract->owner->customer_number?>)</td>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->product_name?></a></td>
|
||||
<td><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
|
||||
<td class="<?=($contract->isCancelled()) ? "canceled" : "" ?> <?=(!$contract->isFinished()) ? "not-finished" : "" ?>"><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->product_name?></a></td>
|
||||
<td class="<?=($contract->isCancelled()) ? "canceled" : "" ?> <?=(!$contract->isFinished()) ? "not-finished" : "" ?>"><a href="<?=self::getUrl("Contract", "view", ["contract_id" => $contract->id])?>"><?=$contract->matchcode?></a></td>
|
||||
<!--<td>
|
||||
<?php if($contract->termination_id): ?>
|
||||
<?=$contract->termination->building->street?><br />
|
||||
@@ -121,9 +128,9 @@
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>-->
|
||||
<td><?=$contract->price?></td>
|
||||
<td><?=$contract->price_setup?></td>
|
||||
<td>
|
||||
<td class="<?=($contract->isCancelled()) ? "canceled" : "" ?> <?=(!$contract->isFinished()) ? "not-finished" : "" ?> <?=($contract->price < 0) ? "text-danger" : ""?>"><?=$contract->price?></td>
|
||||
<td class="<?=($contract->isCancelled()) ? "canceled" : "" ?> <?=(!$contract->isFinished()) ? "not-finished" : "" ?> <?=($contract->price_setup < 0) ? "text-danger" : ""?>"><?=$contract->price_setup?></td>
|
||||
<td class="<?=($contract->isCancelled()) ? "canceled" : "" ?> <?=(!$contract->isFinished()) ? "not-finished" : "" ?>">
|
||||
<?php if($contract->billing_period == 1): ?>
|
||||
monatlich
|
||||
<?php elseif($contract->billing_period == 24): ?>
|
||||
@@ -134,7 +141,7 @@
|
||||
<?=(12 / $contract->billing_period)?>x Jährlich
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="text-monospace"><?=($contract->finish_date) ? date('d.m.Y', $contract->finish_date) : ""?></td>
|
||||
<td class="text-monospace <?=(!$contract->isFinished()) ? "not-finished" : "" ?>"><?=($contract->finish_date) ? date('d.m.Y', $contract->finish_date) : ""?></td>
|
||||
<td class="text-monospace"><?=($contract->cancel_date) ? date('d.m.Y', $contract->cancel_date) : ""?></td>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->create)?><br /><?=$contract->creator->name?></td>
|
||||
<td class="text-monospace"><?=date('d.m.Y H:i', $contract->edit)?><br /><?=$contract->editor->name?></td>
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
<?php if((is_array($contract->linkFrom) && count($contract->linkFrom)) || (is_array($contract->linkTo) && count($contract->linkTo))): ?>
|
||||
<h4>Verknüpfte Verträge</h4>
|
||||
|
||||
<table class="table table-striped table-sm table-bordered table-hover">
|
||||
<table class="table table-striped table-sm table-bordered table-hover" id="link-table">
|
||||
<tr>
|
||||
<th title="Verlinkten Contract mit neuem Contract verknüpfen">Übernehmen</th>
|
||||
<th title="Verlinkten Contract mit altem Contract zusammen kündigen">Kündigen</th>
|
||||
@@ -177,7 +177,7 @@
|
||||
<th>Fertigstellung</th>
|
||||
<th>Kündigung</th>
|
||||
</tr>
|
||||
<?php foreach($contract->links as $link): ?>
|
||||
<?php foreach($contract->linksWithCredit as $link): ?>
|
||||
<?php
|
||||
|
||||
if($link->contract_id == $contract->id) {
|
||||
@@ -188,9 +188,14 @@
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><input type="radio" class="form-check" id="link-<?=$link->id?>-action-keep" name="links[<?=$link->id?>]" value="keep" <?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?> /></td>
|
||||
<td><input type="radio" class="form-check" id="link-<?=$link->id?>-action-cancel" name="links[<?=$link->id?>]" value="cancel" /></td>
|
||||
<tr data-link-type="<?=$link->type?>">
|
||||
<td>
|
||||
<input type="radio" class="form-check link-keep" id="link-<?=$link->id?>-action-keep" name="links[<?=$link->id?>]" value="keep" <?=($linkcontract->cancel_date && $linkcontract->cancel_date < date('U')) ? "" : "checked='checked'"?> />
|
||||
<?php if($link->type == "credit"): ?>
|
||||
(Gutschrift wird neu erstellt)
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><input type="radio" class="form-check link-cancel" id="link-<?=$link->id?>-action-cancel" name="links[<?=$link->id?>]" value="cancel" /></td>
|
||||
<td><a href="<?=self::getUrl("Address", "View", ["id" => $linkcontract->owner_id])?>" target="_blank"><?=$linkcontract->owner->getCompanyOrName()?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>" target="_blank"><?=$linkcontract->id?></a></td>
|
||||
<td class="contract <?=($linkcontract->isCancelled()) ? "canceled" : ""?>"><a href="<?=self::getUrl("Contract", "View", ["contract_id" => $linkcontract->id])?>" target="_blank"><?=$linkcontract->product_name?></a></td>
|
||||
@@ -307,6 +312,29 @@
|
||||
//$('#termination_id-' + id + '-line').hide();
|
||||
}
|
||||
|
||||
// set credit-link to cancel if new product does not need credit
|
||||
const attrib = p.attributes;
|
||||
|
||||
let crediting_partner = false;
|
||||
let crediting_rate = 0;
|
||||
|
||||
if(crediting_partner in p.attributes) {
|
||||
crediting_partner = parseInt(p.attributes.crediting_partner);
|
||||
}
|
||||
if(crediting_rate in p.attributes) {
|
||||
crediting_rate = parseFloat(p.attributes.crediting_rate);
|
||||
}
|
||||
|
||||
let price_nne = parseFloat(p.price_nne);
|
||||
//console.log(p.price_nne, crediting_partner, crediting_rate);
|
||||
|
||||
if(price_nne || (crediting_partner && crediting_rate)) {
|
||||
$("#link-table tr[data-link-type='credit'] input.link-keep").prop("checked", "checked");
|
||||
}
|
||||
if(!price_nne && (!crediting_partner || !crediting_rate)) {
|
||||
$("#link-table tr[data-link-type='credit'] input.link-cancel").prop("checked", "checked");
|
||||
}
|
||||
|
||||
},
|
||||
'json');
|
||||
|
||||
|
||||
@@ -29,12 +29,17 @@
|
||||
|
||||
<div class="card border-top-success">
|
||||
<div class="card-body">
|
||||
<?php if(!$contract->finish_date || $contract->finish_date > date('U')): ?>
|
||||
<?php if(!$contract->isFinished()): ?>
|
||||
<h2 class="text-center mb-3 text-secondary">In Herstellung</h2>
|
||||
<?php endif; ?>
|
||||
<?php if($contract->isCancelled()): ?>
|
||||
<h2 class="text-center mb-3 text-danger">GEKÜNDIGT</h2>
|
||||
<?php endif; ?>
|
||||
<?php if(str_contains(strtolower($contract->sla->name), "residential")): ?>
|
||||
<h2 class="text-center mb-3 text-danger">Privatprodukt</h2>
|
||||
<?php else: ?>
|
||||
<h2 class="text-center mb-3 text-primary">Businessprodukt</h2>
|
||||
<?php endif; ?>
|
||||
<h3 class="text-center mb-3 <?=($contract->isCancelled()) ? "canceled" : ""?>"><?=$contract->product_name?> [<?=$contract->id?>]</h3>
|
||||
|
||||
<table class="table table-sm table-striped view-table">
|
||||
@@ -232,7 +237,13 @@
|
||||
<td style="white-space: nowrap" class="text-monospace"><?=date("d.m.Y H:i", $j->create)?> (<?=$j->creator?>)</td>
|
||||
|
||||
<?php if($j->type == "text" || $j->type == "phone"):?>
|
||||
<td><i class="fas <?=($j->type == "text") ? "fa-align-left bg-success" : "fa-phone bg-success"?> text-white p-1"></i></td>
|
||||
<td>
|
||||
<?php if($j->type == "text"): ?>
|
||||
<i class="fas fa-align-left bg-warning text-white p-1" title="Kommentar"></i>
|
||||
<?php else: ?>
|
||||
<i class="fas fa-phone bg-warning text-white p-1" title="Anruf"></i>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php if(strlen($j->text) > 120): ?>
|
||||
<td style="width: 100%" class="pointer" onclick="toggleTruncatedJournalText(<?=$j->id?>)">
|
||||
<span id="truncated-<?=$j->id?>"><i class="fas fa-caret-right"></i> <?=self::strtrim(str_replace(["\n", "\r", "\t"]," ", $j->text), 120)?></span>
|
||||
@@ -246,7 +257,7 @@
|
||||
</td>
|
||||
|
||||
<?php elseif($j->type == "file"): ?>
|
||||
<td><i class="fas fa-download bg-primary text-white p-1"></i></td>
|
||||
<td><i class="fas fa-download bg-primary text-white p-1" title="Dateiupload"></i></td>
|
||||
<td style="width: 100%">
|
||||
<?php if($j->text): ?>
|
||||
<?=self::strtrim(str_replace(["\n", "\r", "\t"]," ", $j->text), 128)?><br />
|
||||
@@ -262,7 +273,7 @@
|
||||
<?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
|
||||
<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"): ?>
|
||||
@@ -344,7 +355,7 @@
|
||||
$direction = "von";
|
||||
$linkcontract = $link->origin;
|
||||
if($link->type == "credit") {
|
||||
$direction = "";
|
||||
$direction = "zu";
|
||||
//continue;
|
||||
}
|
||||
} else {
|
||||
@@ -356,7 +367,7 @@
|
||||
$direction = "nach";
|
||||
}
|
||||
if($link->type == "credit") {
|
||||
$direction = "zu";
|
||||
$direction = "";
|
||||
//continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -526,7 +526,7 @@ class Address extends mfBaseModel {
|
||||
|
||||
if($name == "permissions") {
|
||||
$this->permissions = NetworkAddressModel::search(['address_id' => $this->id]);
|
||||
return $permissions;
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
if($name == "parent") {
|
||||
@@ -540,16 +540,36 @@ class Address extends mfBaseModel {
|
||||
}
|
||||
|
||||
if($name == "contracts") {
|
||||
$owning = ContractModel::search(['owner_id' => $this->id]);
|
||||
$billing = ContractModel::search(['billingaddress_id' => $this->id]);
|
||||
$this->contracts = array_merge($owning, $billing);
|
||||
$contracts = [];
|
||||
foreach(ContractModel::search(['owner_id' => $this->id]) as $contract) {
|
||||
if(!array_key_exists($contract->id, $contracts)) {
|
||||
$contracts[$contract->id] = $contract;
|
||||
}
|
||||
}
|
||||
foreach(ContractModel::search(['billingaddress_id' => $this->id]) as $contract) {
|
||||
if(!array_key_exists($contract->id, $contracts)) {
|
||||
$contracts[$contract->id] = $contract;
|
||||
}
|
||||
}
|
||||
|
||||
$this->contracts = $contracts;
|
||||
return $this->contracts;
|
||||
}
|
||||
|
||||
if($name == "active_contracts") {
|
||||
$owning = ContractModel::searchActive(['owner_id' => $this->id]);
|
||||
$billing = ContractModel::searchActive(['billingaddress_id' => $this->id]);
|
||||
$this->contracts = array_merge($owning, $billing);
|
||||
$contracts = [];
|
||||
foreach(ContractModel::searchActive(['owner_id' => $this->id]) as $contract) {
|
||||
if(!array_key_exists($contract->id, $contracts)) {
|
||||
$contracts[$contract->id] = $contract;
|
||||
}
|
||||
}
|
||||
foreach(ContractModel::searchActive(['billingaddress_id' => $this->id]) as $contract) {
|
||||
if(!array_key_exists($contract->id, $contracts)) {
|
||||
$contracts[$contract->id] = $contract;
|
||||
}
|
||||
}
|
||||
|
||||
$this->contracts = $contracts;
|
||||
return $this->contracts;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class Contract extends mfBaseModel {
|
||||
private $isCancelled;
|
||||
private $journals;
|
||||
private $links;
|
||||
private $linksWithCredit;
|
||||
private $linkFrom;
|
||||
private $linkTo;
|
||||
private $upgradeFrom;
|
||||
@@ -116,6 +117,24 @@ class Contract extends mfBaseModel {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function isFinished() {
|
||||
if(!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$now = date('U');
|
||||
|
||||
if($this->finish_date && $this->finish_date <= $now) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if($this->cancel_date && $this->cancel_date <= $now) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function generateMatchcode() {
|
||||
$owner_address = $this->getProperty("owner")->street.", ".$this->getProperty("owner")->zip." ".$this->getProperty("owner")->city;
|
||||
@@ -270,7 +289,13 @@ class Contract extends mfBaseModel {
|
||||
//var_dump($this->links);exit;
|
||||
return $this->links;
|
||||
}
|
||||
|
||||
|
||||
if($name == "linksWithCredit") {
|
||||
$this->linksWithCredit = ContractLinkModel::includesContractId($this->id, ["type" => ["link", "credit"]]);
|
||||
//var_dump($this->links);exit;
|
||||
return $this->linksWithCredit;
|
||||
}
|
||||
|
||||
if(in_array($name, ['linkFrom','linkTo','upgradeFrom','upgradeTo','downgradeFrom','downgradeTo','productchangeFrom','productchangeTo','relocationFrom','relocationTo'])) {
|
||||
if($this->$name === null) {
|
||||
$this->getLinks();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -214,7 +214,7 @@ class ContractModel {
|
||||
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
||||
WHERE $where
|
||||
GROUP BY Contract.id
|
||||
ORDER BY Contract.owner_id,Contract.product_id,Contract.`create`
|
||||
ORDER BY Contract.`create`,Contract.id
|
||||
LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
@@ -269,12 +269,12 @@ class ContractModel {
|
||||
WHERE $where
|
||||
AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())
|
||||
GROUP BY Contract.id
|
||||
ORDER BY Contract.owner_id,Contract.`create`";
|
||||
ORDER BY Contract.`create`,Contract.id";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
@@ -328,12 +328,12 @@ class ContractModel {
|
||||
LEFT JOIN Product ON (Contract.product_id = Product.id)
|
||||
WHERE $where
|
||||
GROUP BY Contract.id
|
||||
ORDER BY Contract.owner_id,Contract.`create`";
|
||||
ORDER BY Contract.`create`,Contract.id";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
|
||||
} elseif(is_numeric($count)) {
|
||||
} elseif(is_numeric($limit['count'])) {
|
||||
$sql .= " LIMIT ".$limit['count'];
|
||||
}
|
||||
}
|
||||
@@ -441,6 +441,32 @@ class ContractModel {
|
||||
$where .= " AND Contract.imported_data like '$imported_data'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("price<", $filter)) {
|
||||
$price = $filter['price<'];
|
||||
if(is_numeric($price)) {
|
||||
$where .= " AND Contract.price < $price";
|
||||
}
|
||||
}
|
||||
if(array_key_exists("price<=", $filter)) {
|
||||
$price = $filter['price<='];
|
||||
if(is_numeric($price)) {
|
||||
$where .= " AND Contract.price <= $price";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("price>", $filter)) {
|
||||
$price = $filter['price>'];
|
||||
if(is_numeric($price)) {
|
||||
$where .= " AND Contract.price > $price";
|
||||
}
|
||||
}
|
||||
if(array_key_exists("price>=", $filter)) {
|
||||
$price = $filter['price>='];
|
||||
if(is_numeric($price)) {
|
||||
$where .= " AND Contract.price >= $price";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("add-where", $filter)) {
|
||||
$where .= " ".$filter['add-where'];
|
||||
|
||||
@@ -160,8 +160,19 @@ class ContractLinkModel {
|
||||
$where .= " AND ContractLink.origin_contract_id = '$origin_contract_id'";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(array_key_exists("type", $filter)) {
|
||||
$type = $filter["type"];
|
||||
if(is_array($type) && count($type)) {
|
||||
$where .= " AND ContractLink.type IN ('".join("','", $type)."')";
|
||||
} else {
|
||||
$type = $db->escape($filter['type']);
|
||||
if($type) {
|
||||
$where .= " AND ContractLink.type = '$type'";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
|
||||
@@ -83,19 +83,27 @@ class ContractqueueController extends mfBaseController {
|
||||
if(ContractqueueModel::getFirst(["order_id" => $order->id])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$skip_order = false;
|
||||
$contracts = [];
|
||||
$primary_matchcode = false;
|
||||
|
||||
|
||||
|
||||
foreach($order->products as $op) {
|
||||
$contract = ContractModel::getFirst(["orderproduct_id" => $op->id]);
|
||||
if(!$contract) {
|
||||
$contract = ContractqueueModel::getFirst(["orderproduct_id" => $op->id]);
|
||||
}
|
||||
if($contract && $contract->matchcode) {
|
||||
$primary_matchcode = $contract->matchcode;
|
||||
continue;
|
||||
if($contract) {
|
||||
if($contract->matchcode) {
|
||||
$primary_matchcode = $contract->matchcode;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if($op->product->external) {
|
||||
$skip_order = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
// if contract does not exist yet, create Contractqueue
|
||||
@@ -126,7 +134,11 @@ class ContractqueueController extends mfBaseController {
|
||||
$contract->crediting_matchcode = $order->owner->getCompanyOrName().", ".$order->owner->street.", ".$order->owner->zip." ".$order->owner->city;
|
||||
$contracts[] = $contract;
|
||||
}
|
||||
|
||||
|
||||
if($skip_order) {
|
||||
$contracts = [];
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!$primary_matchcode) {
|
||||
$primary_matchcode = $order->owner->street.", ".$order->owner->zip." ".$order->owner->city;
|
||||
@@ -176,22 +188,41 @@ class ContractqueueController extends mfBaseController {
|
||||
$new_contracts = [];
|
||||
$c = 0;
|
||||
$o = 0;
|
||||
$last_order_id = 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
|
||||
$contract = ContractModel::getFirst(["orderproduct_id" => $cq->orderproduct_id]);
|
||||
if($contract) {
|
||||
$this->log->debug("Contract von orderproduct ".$cq->orderproduct_id." existiert schon: ".$contract->id);
|
||||
continue;
|
||||
} // contract should not yet exist
|
||||
|
||||
$order_id = $cq->orderproduct->order_id;
|
||||
|
||||
if($c >= 2000) {
|
||||
if($order_id != $last_order_id) {
|
||||
$this->layout()->setFlash("$c Contracts (exkl. Gutschriften) erstellt", "info");
|
||||
$this->redirect("Contractqueue");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$last_order_id = $order_id;
|
||||
|
||||
/*
|
||||
* 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");
|
||||
$this->log->debug("Eine Position in Bestellung ".$cq->order_id." konnte nicht übernommen werden: Fehler beim Speichern");
|
||||
$this->layout()->setFlash("Eine Position in Bestellung ".$cq->order_id." konnte nicht übernommen werden: Fehler beim Speichern", "warning");
|
||||
continue;
|
||||
}
|
||||
|
||||
$c++;
|
||||
|
||||
|
||||
$cq->contract_id = $contract->id;
|
||||
$cq->save();
|
||||
|
||||
@@ -213,7 +244,8 @@ class ContractqueueController extends mfBaseController {
|
||||
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");
|
||||
$this->log->log("Zu einer Position in Bestellung ".$cq->order_id." konnte keine Gutschrift erstellt werden: Fehler beim Speichern");
|
||||
$this->layout()->setFlash("Zu einer Position in Bestellung ".$cq->order_id." konnte keine Gutschrift erstellt werden: Fehler beim Speichern", "warning");
|
||||
continue;
|
||||
}
|
||||
$journal = ContractjournalModel::create([
|
||||
@@ -229,8 +261,8 @@ class ContractqueueController extends mfBaseController {
|
||||
]);
|
||||
$journal->save();
|
||||
$link = ContractLinkModel::create([
|
||||
'contract_id' => $contract->id,
|
||||
'origin_contract_id' => $credit->id,
|
||||
'contract_id' => $credit->id,
|
||||
'origin_contract_id' => $contract->id,
|
||||
'type' => 'credit'
|
||||
]);
|
||||
$link->save();
|
||||
@@ -240,39 +272,43 @@ class ContractqueueController extends mfBaseController {
|
||||
/*
|
||||
* 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([
|
||||
if(array_key_exists($order_id, $new_contracts)) {
|
||||
foreach ($new_contracts[$order_id] as $origin) {
|
||||
if (ContractLinkModel::getFirst(["contract_id" => $contract->id, "origin_contract_id" => $origin->id])) {
|
||||
continue;
|
||||
}
|
||||
$link = ContractLinkModel::create([
|
||||
'contract_id' => $contract->id,
|
||||
'type' => "link",
|
||||
'value' => $origin->id
|
||||
'origin_contract_id' => $origin->id,
|
||||
'type' => 'link'
|
||||
]);
|
||||
$journal->save();
|
||||
$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();
|
||||
$ojournal = ContractjournalModel::create([
|
||||
'contract_id' => $origin->id,
|
||||
'type' => "link",
|
||||
'value' => $contract->id
|
||||
]);
|
||||
$ojournal->save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$new_contracts[$order_id] = [];
|
||||
}
|
||||
|
||||
$new_contracts[] = $contract;
|
||||
$new_contracts[$order_id][] = $contract;
|
||||
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("$c Contracts erstellt", "success");
|
||||
$this->redirect("Contract");
|
||||
$this->redirect("Contractqueue");
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class ContractqueueModel {
|
||||
LEFT JOIN Product ON (Contractqueue.product_id = Product.id)
|
||||
WHERE $where
|
||||
GROUP BY Contractqueue.id
|
||||
ORDER BY Contractqueue.owner_id,Contractqueue.product_id,Contractqueue.`create`
|
||||
ORDER BY Contractqueue.order_id,Contractqueue.orderproduct_id,Contractqueue.owner_id,Contractqueue.product_id,Contractqueue.`create`
|
||||
LIMIT 1";
|
||||
//var_dump($sql);exit;
|
||||
$res = $db->query($sql);
|
||||
@@ -196,7 +196,7 @@ class ContractqueueModel {
|
||||
WHERE $where
|
||||
AND (cancel_date IS NULL OR cancel_date > UNIX_TIMESTAMP())
|
||||
GROUP BY Contractqueue.id
|
||||
ORDER BY Contractqueue.owner_id,Contractqueue.`create`";
|
||||
ORDER BY Contractqueue.order_id,Contractqueue.orderproduct_id,Contractqueue.owner_id,Contractqueue.`create`";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
@@ -231,7 +231,7 @@ class ContractqueueModel {
|
||||
LEFT JOIN Product ON (Contractqueue.product_id = Product.id)
|
||||
WHERE $where
|
||||
GROUP BY Contractqueue.id
|
||||
ORDER BY Contractqueue.owner_id,Contractqueue.`create`";
|
||||
ORDER BY Contractqueue.order_id,Contractqueue.orderproduct_id,Contractqueue.owner_id,Contractqueue.`create`";
|
||||
|
||||
if(is_array($limit) && count($limit)) {
|
||||
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
|
||||
|
||||
@@ -145,6 +145,10 @@ h1, h2, h3, h4, h5, h6 {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.not-finished {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
/* tinymce */
|
||||
.tox-editor-header,
|
||||
.tox-menubar,
|
||||
|
||||
Reference in New Issue
Block a user