PreorderBilling WIP & Api changed
This commit is contained in:
@@ -512,6 +512,14 @@ $pagination_entity_name = "Vorbestellungen";
|
|||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
$(".datepicker").datepicker({
|
||||||
|
//orientation: "bottom",
|
||||||
|
language: 'de',
|
||||||
|
format: "dd.mm.yyyy",
|
||||||
|
showWeekDays: true,
|
||||||
|
todayBtn: 'linked',
|
||||||
|
autoclose: true
|
||||||
|
});
|
||||||
$("#filter_type").select2({closeOnSelect: false});
|
$("#filter_type").select2({closeOnSelect: false});
|
||||||
$("#filter_status").select2({closeOnSelect: false});
|
$("#filter_status").select2({closeOnSelect: false});
|
||||||
$("#filter_partner_id").select2({closeOnSelect: false});
|
$("#filter_partner_id").select2({closeOnSelect: false});
|
||||||
@@ -1195,6 +1203,62 @@ $pagination_entity_name = "Vorbestellungen";
|
|||||||
'json');
|
'json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleActivationdateControl(pid) {
|
||||||
|
// set select to current status id
|
||||||
|
//$("#preorder-detail-activationdate-" + pid + "-input select").val($("#preorder-detail-activationdate-" + pid + "-text").data("activationdate"));
|
||||||
|
|
||||||
|
// toggle controls
|
||||||
|
$("#preorder-detail-activationdate-" + pid + "-text").toggle();
|
||||||
|
$("#preorder-detail-activationdate-" + pid + "-input").toggle();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function savePreorderActivationdateControl(pid) {
|
||||||
|
if(!Number.isInteger(pid) || pid < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var value = $("#preorder-detail-activationdate-" + pid + "-input input").val();
|
||||||
|
|
||||||
|
//console.log("add opacity-5 to ")
|
||||||
|
$("#preorder-" + pid + "-body").addClass("opacity-5");
|
||||||
|
$("#preorder-" + pid + "-body .loader-big").show();
|
||||||
|
|
||||||
|
// reset loading overlay if request times out
|
||||||
|
setTimeout(() => {
|
||||||
|
$("#preorder-" + pid + "-body").removeClass("opacity-5");
|
||||||
|
$("#preorder-" + pid + "-body .loader-big").hide();
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
$.post("<?=self::getUrl("Preorder","Api")?>",
|
||||||
|
{
|
||||||
|
'do': "saveActivationdate",
|
||||||
|
id: pid,
|
||||||
|
activation_date: value
|
||||||
|
},
|
||||||
|
function(success) {
|
||||||
|
if(success.status == "OK") {
|
||||||
|
console.log(success);
|
||||||
|
var new_activationdate = success.result.activation_date;
|
||||||
|
var pid = success.result.preorder_id;
|
||||||
|
//console.log(updates);
|
||||||
|
$("#preorder-detail-activationdate-" + pid + "-textpart").text(new_activationdate);
|
||||||
|
$("#preorder-detail-activationdate-" + pid + "-input").val(new_activationdate);
|
||||||
|
|
||||||
|
$("#preorder-detail-activationdate-" + pid + "-text").addClass("text-success");
|
||||||
|
setTimeout(() => { $("#preorder-detail-activationdate-" + pid + "-text").removeClass("text-success") }, 1500);
|
||||||
|
|
||||||
|
toggleActivationdateControl(pid);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#preorder-" + pid + "-body").removeClass("opacity-5");
|
||||||
|
$("#preorder-" + pid + "-body .loader-big").hide();
|
||||||
|
},
|
||||||
|
'json');
|
||||||
|
}
|
||||||
|
|
||||||
function createWorkorder(pid) {
|
function createWorkorder(pid) {
|
||||||
if(!Number.isInteger(pid) || pid < 1) {
|
if(!Number.isInteger(pid) || pid < 1) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -84,6 +84,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Aktivierungsdatum (Status 500):</th>
|
||||||
|
<td>
|
||||||
|
<?php if($preorder->getStatuschangeTo(500)): ?>
|
||||||
|
<span id="preorder-detail-activationdate-<?=$preorder->id?>-text" data-activationdate="<?=($preorder->getStatuschangeTo(500)) ? (new DateTime("@".$preorder->getStatuschangeTo(500)))->format("d.m.Y") : ""?>"><span id="preorder-detail-activationdate-<?=$preorder->id?>-textpart"><?=($preorder->getStatuschangeTo(500)) ? (new DateTime("@".$preorder->getStatuschangeTo(500)))->format("d.m.Y") : ""?></span> <a href="#" onclick="return toggleActivationdateControl(<?=$preorder->id?>)"><i class="fas fa-fw fa-edit"></i></a></span>
|
||||||
|
<div class="input-group" id="preorder-detail-activationdate-<?=$preorder->id?>-input" style="display:none">
|
||||||
|
<input type="text" class="form-control datepicker" value="<?=($preorder->getStatuschangeTo(500)) ? (new DateTime("@".$preorder->getStatuschangeTo(500)))->format("d.m.Y") : ""?>" />
|
||||||
|
<div class="input-group-append">
|
||||||
|
<button type="button" class="btn btn-primary" title="Speichern" onclick="savePreorderActivationdateControl(<?=$preorder->id?>)"><i class="fas fa-check"></i></button>
|
||||||
|
<button type="button" class="btn btn-secondary" title="Abbrechen" onclick="toggleActivationdateControl(<?=$preorder->id?>)"><i class="fas fa-times"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<th>Erstellt:</th>
|
<th>Erstellt:</th>
|
||||||
<td class="text-monospace"><?=date("d.m.Y H:i",$preorder->create)?> (<?=$preorder->creator->name?>)</td>
|
<td class="text-monospace"><?=date("d.m.Y H:i",$preorder->create)?> (<?=$preorder->creator->name?>)</td>
|
||||||
|
|||||||
@@ -929,28 +929,24 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$prices_return = [
|
$prices_return = [
|
||||||
"price_inet" => (float)$prices["operator_usage"]->price_inet,
|
"oaid" => $oaid,
|
||||||
"price_inet_tv" => (float)$prices["operator_usage"]->price_inet_tv,
|
"enduser_setup_price_net" => (float)$prices["enduser_setup"]->price_setup,
|
||||||
"price_catv" => (float)$prices["operator_usage"]->price_catv,
|
"enduser_setup_price_gross" => (float)$prices["enduser_setup"]->price_setup * 1.2,
|
||||||
|
|
||||||
"operator_setup_price" => (float)$prices["operator_setup"]->price_setup,
|
|
||||||
"operator_setup_info" => $prices["operator_setup"]->description,
|
|
||||||
"operator_setup_valid_until" => $prices["operator_setup"]->end_date,
|
|
||||||
|
|
||||||
"enduser_setup_price" => (float)$prices["enduser_setup"]->price_setup,
|
|
||||||
"enduser_setup_info" => $prices["enduser_setup"]->description,
|
"enduser_setup_info" => $prices["enduser_setup"]->description,
|
||||||
"enduser_setup_valid_until" => $prices["enduser_setup"]->end_date,
|
"enduser_setup_valid_until" => $prices["enduser_setup"]->end_date,
|
||||||
|
|
||||||
"vatrate" => 20,
|
"vatrate" => 20,
|
||||||
];
|
];
|
||||||
|
|
||||||
if(PreorderBilling::getFirst(["adb_wohneinheit_id" => $unit->id, "product_id" => $enduser_setup_product_id])) {
|
//$paid = $unit->enduser_setup_paid;
|
||||||
$prices_return["enduser_setup_price"] = 0;
|
if(PreorderBilling::getFirst(["adb_wohneinheit_id" => $unit->id, "product_id" => $enduser_setup_product_id, "invoice_id" => false])) {
|
||||||
|
$prices_return["enduser_setup_price_net"] = 0;
|
||||||
|
$prices_return["enduser_setup_price_gross"] = 0;
|
||||||
$prices_return["enduser_setup_info"] = "paid";
|
$prices_return["enduser_setup_info"] = "paid";
|
||||||
$prices_return["enduser_setup_valid_until"] = null;
|
$prices_return["enduser_setup_valid_until"] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mfResponse::Ok(['oaid' => $oaid, 'prices' => $prices_return]);
|
return mfResponse::Ok($prices_return);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function exportAddresses() {
|
protected function exportAddresses() {
|
||||||
|
|||||||
@@ -21,6 +21,11 @@ class Activation extends Modules\ApiControllerModule {
|
|||||||
if($this->me->is("Preorderreadonly")) return \mfResponse::Forbidden();
|
if($this->me->is("Preorderreadonly")) return \mfResponse::Forbidden();
|
||||||
|
|
||||||
$code = trim($code);
|
$code = trim($code);
|
||||||
|
$activation_date = false;
|
||||||
|
if(array_key_exists("activation_date", $this->get)) {
|
||||||
|
$activation_date = trim($this->get['activation_date']);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$code) {
|
if(!$code) {
|
||||||
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||||
}
|
}
|
||||||
@@ -43,14 +48,41 @@ class Activation extends Modules\ApiControllerModule {
|
|||||||
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($activation_date) {
|
||||||
|
try {
|
||||||
|
$adate = new \DateTime($activation_date);
|
||||||
|
$adate->setTimezone(new \DateTimeZone("Europe/Vienna"));
|
||||||
|
$adate->setTime(2, 0, 0); // set time to 2:00:00
|
||||||
|
// activation date cannot be in the future
|
||||||
|
if($adate > new \DateTime()) {
|
||||||
|
return \mfResponse::BadRequest(["message" => "Activation date can only be in the past"]);
|
||||||
|
}
|
||||||
|
} catch(\Exception $e) {
|
||||||
|
return \mfResponse::BadRequest(["message" => "Invalid activation_date format"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set status to 500
|
// set status to 500
|
||||||
if($preorder->status->code < 500) {
|
if($preorder->status->code < 500) {
|
||||||
|
if($preorder->status->code < 242) {
|
||||||
|
return \mfResponse::BadRequest(["message" => "Service cannot be activated, because Construction work is not yet finished"]);
|
||||||
|
}
|
||||||
|
|
||||||
$new_status = \PreorderstatusModel::getFirst(["code" => 500]);
|
$new_status = \PreorderstatusModel::getFirst(["code" => 500]);
|
||||||
if(!$new_status) {
|
if(!$new_status) {
|
||||||
return \mfResponse::InternalServerError();
|
return \mfResponse::InternalServerError();
|
||||||
}
|
}
|
||||||
$preorder->status_id = $new_status->id;
|
$preorder->status_id = $new_status->id;
|
||||||
$preorder->save();
|
$preorder->save();
|
||||||
|
|
||||||
|
if($adate) {
|
||||||
|
$history = \PreorderHistoryModel::getLastStatusChangeTo($preorder->id, 500);
|
||||||
|
if($history) {
|
||||||
|
$history->changed = $adate->getTimestamp();
|
||||||
|
$history->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return \mfResponse::Ok(["message" => "Status successfully updated."]);
|
return \mfResponse::Ok(["message" => "Status successfully updated."]);
|
||||||
|
|||||||
@@ -856,11 +856,31 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(trim($this->post['orderDate'])) {
|
if(trim($this->post['orderDate'])) {
|
||||||
$order_date = trim($this->post['orderDate']);
|
try {
|
||||||
|
$order_date = new DateTime(trim($this->post['orderDate']));
|
||||||
|
$order_date->setTime(4, 0, 0);
|
||||||
|
$order_date->setTimezone(new DateTimeZone('Europe/Vienna'));
|
||||||
|
|
||||||
|
// cannot be older than 14 days
|
||||||
|
$now = new DateTime();
|
||||||
|
$now->setTime(4, 0, 0);
|
||||||
|
$now->setTimezone(new DateTimeZone('Europe/Vienna'));
|
||||||
|
$diff = $now->diff($order_date);
|
||||||
|
if($diff->days > 14) {
|
||||||
|
return mfResponse::BadRequest(["message" => "orderDate cannot be older than 14 days"]);
|
||||||
|
}
|
||||||
|
$preorder_data['order_date'] = $order_date->getTimestamp();
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$this->log->debug(__METHOD__.": Error parsing orderDate: " . $e->getMessage());
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*$order_date = trim($this->post['orderDate']);
|
||||||
$m = [];
|
$m = [];
|
||||||
if(preg_match('/^(\d\d\d\d)-(\d\d)-(\d\d)$/', $order_date, $m)) {
|
if(preg_match('/^(\d\d\d\d)-(\d\d)-(\d\d)$/', $order_date, $m)) {
|
||||||
$preorder_data['order_date'] = mktime(4, 0, 0, $m[2], $m[3], $m[1]);
|
$preorder_data['order_date'] = mktime(4, 0, 0, $m[2], $m[3], $m[1]);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
if($is_additional_order) {
|
if($is_additional_order) {
|
||||||
|
|||||||
@@ -99,6 +99,20 @@ class Preorder extends mfBaseModel {
|
|||||||
mfValuecache::singleton()->delete("preorder-save-nesting-level-" . $this->id);
|
mfValuecache::singleton()->delete("preorder-save-nesting-level-" . $this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getStatuschangeTo($status_code) {
|
||||||
|
$status = PreorderstatusModel::getFirst(["code" => $status_code]);
|
||||||
|
if(!$status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$history = PreorderHistoryModel::getLastStatusChangeTo($this->id, $status_code);
|
||||||
|
if(!$history) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $history->changed;
|
||||||
|
}
|
||||||
|
|
||||||
public function updateRimoWorkorderContact() {
|
public function updateRimoWorkorderContact() {
|
||||||
$contact_fields = [
|
$contact_fields = [
|
||||||
"company",
|
"company",
|
||||||
@@ -141,7 +155,8 @@ class Preorder extends mfBaseModel {
|
|||||||
"preorder_id" => $this->id,
|
"preorder_id" => $this->id,
|
||||||
"key" => $field,
|
"key" => $field,
|
||||||
"old_value" => $this->_old_data->$field,
|
"old_value" => $this->_old_data->$field,
|
||||||
"new_value" => $this->data->$field
|
"new_value" => $this->data->$field,
|
||||||
|
"changed" => date("U")
|
||||||
]);
|
]);
|
||||||
$history->save();
|
$history->save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1064,6 +1064,9 @@ class PreorderController extends mfBaseController {
|
|||||||
case "saveOrderdate":
|
case "saveOrderdate":
|
||||||
$return = $this->saveOrderdateApi();
|
$return = $this->saveOrderdateApi();
|
||||||
break;
|
break;
|
||||||
|
case "saveActivationdate":
|
||||||
|
$return = $this->saveActivationdateApi();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$return = false;
|
$return = false;
|
||||||
}
|
}
|
||||||
@@ -1097,6 +1100,34 @@ class PreorderController extends mfBaseController {
|
|||||||
return ["message" => "Orderdate saved successfully", "preorder_id" => $preorder_id, "order_date" => $order_date];
|
return ["message" => "Orderdate saved successfully", "preorder_id" => $preorder_id, "order_date" => $order_date];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function saveActivationdateApi() {
|
||||||
|
$preorder_id = $this->request->id;
|
||||||
|
$activation_date = $this->request->activation_date;
|
||||||
|
|
||||||
|
$preorder = new Preorder($preorder_id);
|
||||||
|
if(!$preorder->id) {
|
||||||
|
$this->log->debug(__METHOD__.": preorder ($preorder_id) not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$activationdate = DateTime::createFromFormat("d.m.Y", $activation_date, new DateTimeZone("Europe/Vienna"));
|
||||||
|
$activationdate->getTimestamp();
|
||||||
|
} catch(Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$history = PreorderHistoryModel::getLastStatusChangeTo($preorder->id, 500);
|
||||||
|
if(!$history) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$history->changed = $activationdate->getTimestamp();
|
||||||
|
$history->save();
|
||||||
|
|
||||||
|
return ["message" => "Activationdate saved successfully", "preorder_id" => $preorder_id, "activation_date" => $activation_date];
|
||||||
|
}
|
||||||
|
|
||||||
private function addWorkorderRemarkApi() {
|
private function addWorkorderRemarkApi() {
|
||||||
$preorder_id = $this->request->preorder_id;
|
$preorder_id = $this->request->preorder_id;
|
||||||
$workorder_id = $this->request->workorder_id;
|
$workorder_id = $this->request->workorder_id;
|
||||||
|
|||||||
@@ -199,12 +199,12 @@ class PreorderBilling extends mfBaseModel {
|
|||||||
|
|
||||||
if(array_key_exists("invoice_id", $filter)) {
|
if(array_key_exists("invoice_id", $filter)) {
|
||||||
$invoice_id = $filter['invoice_id'];
|
$invoice_id = $filter['invoice_id'];
|
||||||
if(is_numeric($invoice_id)) {
|
if($invoice_id === null || $invoice_id === false) {
|
||||||
$where .= " AND PreorderBilling.invoice_id=$invoice_id";
|
|
||||||
} elseif($invoice_id === null || $invoice_id === false) {
|
|
||||||
$where .= " AND (PreorderBilling.invoice_id IS NULL OR PreorderBilling.invoice_id=0)";
|
$where .= " AND (PreorderBilling.invoice_id IS NULL OR PreorderBilling.invoice_id=0)";
|
||||||
} elseif($invoice_id === true) {
|
} elseif($invoice_id === true) {
|
||||||
$where .= " AND (PreorderBilling.invoice_id IS NOT NULL AND PreorderBilling.invoice_id > 0)";
|
$where .= " AND (PreorderBilling.invoice_id IS NOT NULL AND PreorderBilling.invoice_id > 0)";
|
||||||
|
} elseif(is_numeric($invoice_id)) {
|
||||||
|
$where .= " AND PreorderBilling.invoice_id=$invoice_id";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class PreorderBillingController extends mfBaseController {
|
|||||||
|
|
||||||
if($preorder->status->code >= 899) {
|
if($preorder->status->code >= 899) {
|
||||||
// TODO is canceled, need to determine if setup still needs to be billed
|
// TODO is canceled, need to determine if setup still needs to be billed
|
||||||
$this->log->debug(__METHOD__." already cancelled");
|
$this->log->debug(__METHOD__.": already cancelled");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,14 +263,14 @@ class PreorderBillingController extends mfBaseController {
|
|||||||
$product->setNetoperatorId($netoperator->id);
|
$product->setNetoperatorId($netoperator->id);
|
||||||
$price = $product->getCampaignPrice($preorder->preordercampaign_id, $order_date->format("Y-m-d"));
|
$price = $product->getCampaignPrice($preorder->preordercampaign_id, $order_date->format("Y-m-d"));
|
||||||
if(!$price) {
|
if(!$price) {
|
||||||
die("operator_setup price not found for campaign ".$preorder->preordercampaign_id." and date ".$order_date->format("Y-m-d"));
|
die("operator_setup price not found for netoperator ".$netoperator->id.", campaign ".$preorder->preordercampaign_id." and date ".$order_date->format("Y-m-d"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for existing billing record
|
// check for existing billing record
|
||||||
//var_dump($product);
|
//var_dump($product);
|
||||||
if(PreorderBilling::getFirst(["preorder_id" => $preorder->id, "product_id" => $product->id])) {
|
if(PreorderBilling::getFirst(["preorder_id" => $preorder->id, "product_id" => $product->id])) {
|
||||||
//echo "billing record exists\n<br />";
|
//echo "billing record exists\n<br />";
|
||||||
$this->log->debug(__METHOD__."billing record exists");
|
$this->log->debug(__METHOD__.": billing record exists");
|
||||||
return true; // already billed
|
return true; // already billed
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,7 +432,7 @@ class PreorderBillingController extends mfBaseController {
|
|||||||
|
|
||||||
//var_dump($product, $price);exit;
|
//var_dump($product, $price);exit;
|
||||||
|
|
||||||
$status_change = PreorderHistoryModel::getFirstStatusChangeToOrHigher($preorder->id, 500);
|
$status_change = PreorderHistoryModel::getLastStatusChangeTo($preorder->id, 500);
|
||||||
if(!$status_change) {
|
if(!$status_change) {
|
||||||
$this->log->debug(__METHOD__.": No status change to 500 found for preorder ".$preorder->id." so using creation date");
|
$this->log->debug(__METHOD__.": No status change to 500 found for preorder ".$preorder->id." so using creation date");
|
||||||
$status_change = $preorder;
|
$status_change = $preorder;
|
||||||
|
|||||||
@@ -9,6 +9,35 @@ class PreorderHistory extends mfBaseModel {
|
|||||||
private $old;
|
private $old;
|
||||||
private $new;
|
private $new;
|
||||||
|
|
||||||
|
public function afterSave() {
|
||||||
|
$this->createHistoryEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function createHistoryEntry() {
|
||||||
|
if(!$this->id) return true;
|
||||||
|
|
||||||
|
$changed = $this->getChangedFields();
|
||||||
|
|
||||||
|
if($this->key == "status_id" && in_array("changed", $changed) && $this->_old_data->changed) {
|
||||||
|
try {
|
||||||
|
$status = new Preorderstatus($this->new_value);
|
||||||
|
if(!$status->id) return true;
|
||||||
|
|
||||||
|
$this->log->debug(__METHOD__ . ": 'changed' changed from '" . $this->_old_data->changed . "' to '" . $this->data->changed . "'");
|
||||||
|
$history = PreorderHistoryModel::create([
|
||||||
|
"preorder_id" => $this->preorder_id,
|
||||||
|
"key" => "status_changed-".$status->code,
|
||||||
|
"old_value" => $this->_old_data->changed,
|
||||||
|
"new_value" => $this->data->changed,
|
||||||
|
"changed" => date("U")
|
||||||
|
]);
|
||||||
|
$history->save();
|
||||||
|
} catch(Exception $e) {
|
||||||
|
$this->log->debug($e->getTraceAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getValue($type = "new", $raw = false) {
|
public function getValue($type = "new", $raw = false) {
|
||||||
if($type != "old" && $type != "new") return null;
|
if($type != "old" && $type != "new") return null;
|
||||||
|
|
||||||
@@ -51,6 +80,16 @@ class PreorderHistory extends mfBaseModel {
|
|||||||
return "Status Flag ".$psf->code." - ".$psf->name;
|
return "Status Flag ".$psf->code." - ".$psf->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(preg_match('/status_changed-(\d+)/', $key, $m)) {
|
||||||
|
if(array_key_exists(1, $m)) {
|
||||||
|
$code = $m[1];
|
||||||
|
$ps = PreorderstatusModel::getFirst(["code" => $code]);
|
||||||
|
if($code == 500) {
|
||||||
|
return "Aktivierungsdatum (Status 500)";
|
||||||
|
}
|
||||||
|
return "Status ".$ps->code." Timestamp";
|
||||||
|
}
|
||||||
|
}
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +112,10 @@ class PreorderHistory extends mfBaseModel {
|
|||||||
return date("d.m.Y", $value);
|
return date("d.m.Y", $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(preg_match('/^status_changed-/', $this->key)) {
|
||||||
|
return date("d.m.Y", $value);
|
||||||
|
}
|
||||||
|
|
||||||
if(!is_object($value)) {
|
if(!is_object($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class PreorderHistoryModel {
|
|||||||
public $key;
|
public $key;
|
||||||
public $old_value;
|
public $old_value;
|
||||||
public $new_value;
|
public $new_value;
|
||||||
|
public $changed;
|
||||||
public $create_by;
|
public $create_by;
|
||||||
public $edit_by;
|
public $edit_by;
|
||||||
public $create;
|
public $create;
|
||||||
@@ -47,9 +48,9 @@ class PreorderHistoryModel {
|
|||||||
$status_id = $status->id;
|
$status_id = $status->id;
|
||||||
$sql = "SELECT * FROM PreorderHistory WHERE preorder_id = $preorder_id AND `key` = 'status_id' AND new_value = $status_id";
|
$sql = "SELECT * FROM PreorderHistory WHERE preorder_id = $preorder_id AND `key` = 'status_id' AND new_value = $status_id";
|
||||||
if($type == "first") {
|
if($type == "first") {
|
||||||
$sql .= " ORDER BY id ASC LIMIT 1";
|
$sql .= " ORDER BY `create` ASC LIMIT 1";
|
||||||
} else {
|
} else {
|
||||||
$sql .= " ORDER BY id DESC LIMIT 1";
|
$sql .= " ORDER BY `create` DESC LIMIT 1";
|
||||||
}
|
}
|
||||||
//mfLoghandler::singleton()->debug($sql);
|
//mfLoghandler::singleton()->debug($sql);
|
||||||
$res = FronkDB::singleton()->query($sql);
|
$res = FronkDB::singleton()->query($sql);
|
||||||
|
|||||||
@@ -52,28 +52,13 @@ class PreordercampaignOperatorIspModel {
|
|||||||
$db = FronkDB::singleton();
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
$where = self::getSqlFilter($filter);
|
$where = self::getSqlFilter($filter);
|
||||||
|
$sql = "SELECT PreordercampaignOperatorIsp.* FROM PreordercampaignOperatorIsp
|
||||||
|
LEFT JOIN PreordercampaignOperator ON (PreordercampaignOperatorIsp.campaignoperator_id = PreordercampaignOperator.id)
|
||||||
|
WHERE $where
|
||||||
|
ORDER BY id
|
||||||
|
LIMIT 1";
|
||||||
mfLoghandler::singleton()->debug($where);
|
mfLoghandler::singleton()->debug($where);
|
||||||
$res = $db->select("PreordercampaignOperatorIsp", "*", "$where ORDER BY id");
|
$res = $db->query($sql);
|
||||||
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)) {
|
if($db->num_rows($res)) {
|
||||||
$data = $db->fetch_object($res);
|
$data = $db->fetch_object($res);
|
||||||
$item = new PreordercampaignOperatorIsp($data);
|
$item = new PreordercampaignOperatorIsp($data);
|
||||||
@@ -90,7 +75,8 @@ class PreordercampaignOperatorIspModel {
|
|||||||
$db = FronkDB::singleton();
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
$where = self::getSqlFilter($filter);
|
$where = self::getSqlFilter($filter);
|
||||||
$sql = "SELECT COUNT(*) as cnt FROM PreordercampaignOperatorIsp
|
$sql = "SELECT COUNT(PreordercampaignOperatorIsp.*) as cnt FROM PreordercampaignOperatorIsp
|
||||||
|
LEFT JOIN PreordercampaignOperator ON (PreordercampaignOperatorIsp.campaignoperator_id = PreordercampaignOperator.id)
|
||||||
WHERE $where
|
WHERE $where
|
||||||
";
|
";
|
||||||
|
|
||||||
@@ -107,7 +93,8 @@ class PreordercampaignOperatorIspModel {
|
|||||||
$db = FronkDB::singleton();
|
$db = FronkDB::singleton();
|
||||||
|
|
||||||
$where = self::getSqlFilter($filter);
|
$where = self::getSqlFilter($filter);
|
||||||
$sql = "SELECT * FROM PreordercampaignOperatorIsp
|
$sql = "SELECT PreordercampaignOperatorIsp.* FROM PreordercampaignOperatorIsp
|
||||||
|
LEFT JOIN PreordercampaignOperator ON (PreordercampaignOperatorIsp.campaignoperator_id = PreordercampaignOperator.id)
|
||||||
WHERE $where
|
WHERE $where
|
||||||
ORDER BY id";
|
ORDER BY id";
|
||||||
|
|
||||||
@@ -153,6 +140,14 @@ class PreordercampaignOperatorIspModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(array_key_exists("preordercampaign_id", $filter)) {
|
||||||
|
$preordercampaign_id = $filter['preordercampaign_id'];
|
||||||
|
if(is_numeric($preordercampaign_id)) {
|
||||||
|
$where .= " AND preordercampaign_id = $preordercampaign_id";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//var_dump($filter, $where);exit;
|
//var_dump($filter, $where);exit;
|
||||||
return $where;
|
return $where;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -234,6 +234,69 @@ paths:
|
|||||||
Parameter missing or malformed
|
Parameter missing or malformed
|
||||||
'401':
|
'401':
|
||||||
description: Unauthorized
|
description: Unauthorized
|
||||||
|
/addressdb/{oaid}/pricing:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- addressdb
|
||||||
|
summary: Liefert Endkundenpreise
|
||||||
|
description: Liefert Endkundenpreise für die angegebene Adresse
|
||||||
|
operationId: getAddressPricing
|
||||||
|
parameters:
|
||||||
|
- name: oaid
|
||||||
|
description: "**OAID** der Wohneinheit; Wie in `searchAddress` oder `findAddress` zurückgegeben. Preise sind `0`, wenn Herstellungsentgelt bereits bezahlt wurde."
|
||||||
|
in: path
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: Successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
description: Status string
|
||||||
|
example: OK
|
||||||
|
result:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
oaid:
|
||||||
|
type: string
|
||||||
|
description: OAID der Wohneinheit
|
||||||
|
example: "AT-9999-abcdef01"
|
||||||
|
enduser_setup_price_net:
|
||||||
|
type: number
|
||||||
|
description: Herstellungsentgelt für Endkunde Netto
|
||||||
|
example: 1250
|
||||||
|
enduser_setup_price_gross:
|
||||||
|
type: number
|
||||||
|
description: Herstellungsentgelt für Endkunde Brutto
|
||||||
|
example: 1500
|
||||||
|
enduser_setup_info:
|
||||||
|
type: string
|
||||||
|
description: Zusätzliche Information zum Preis
|
||||||
|
example: Rabattaktion in Gemeinde
|
||||||
|
nullable: true
|
||||||
|
enduser_setup_valid_until:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
description: Gültigkeitsdatum des Herstellungsentgelts, sofern in Aktionszeitraum, sonst `null`
|
||||||
|
example: "2025-05-31"
|
||||||
|
nullable: true
|
||||||
|
vatrate:
|
||||||
|
type: number
|
||||||
|
description: "Mehrwertsteuersatz in %"
|
||||||
|
example: 20
|
||||||
|
'400':
|
||||||
|
description: |
|
||||||
|
Bad Request
|
||||||
|
|
||||||
|
Parameter missing or malformed
|
||||||
|
'401':
|
||||||
|
description: Unauthorized
|
||||||
/addressdb/findStreet:
|
/addressdb/findStreet:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -831,8 +894,8 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- preorder
|
- preorder
|
||||||
summary: Bestellung auf Status 500 - Fertiggestellt setzen
|
summary: Bestellung auf Status 500 - Fertiggestellt setzen
|
||||||
description: Setzt Status der Bestellung auf 500 - Fertiggestellt. Wird gesetzt, wenn beim Kunden alle Installationsarbeiten abgeschlossen sind und der Service aktiv ist.
|
description: Setzt Status der Bestellung auf 500 - Fertiggestellt. Wird gesetzt, wenn beim Kunden alle Installationsarbeiten abgeschlossen sind und der Service aktiv ist. Optional mit Aktivierungsdateum
|
||||||
operationId: setInhouseIntallationFinished
|
operationId: setInhouseIntallationFinishedWithActivationDate
|
||||||
parameters:
|
parameters:
|
||||||
- name: id
|
- name: id
|
||||||
in: path
|
in: path
|
||||||
@@ -840,6 +903,13 @@ paths:
|
|||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
|
- name: activation_date
|
||||||
|
in: query
|
||||||
|
description: (Optional) Tatsächliches Aktivierungsdatum bei nachträglicher Aktivmeldung. Muss in der Vergangenheit liegen. ISO 8601 Format
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Successful operation
|
description: Successful operation
|
||||||
@@ -1262,7 +1332,7 @@ components:
|
|||||||
orderDate:
|
orderDate:
|
||||||
type: string
|
type: string
|
||||||
format: date
|
format: date
|
||||||
description: Bestell- oder Vertragsdatum ISO 8601 Format
|
description: Bestell- oder Vertragsdatum ISO 8601 Format. Darf nicht älter als 14 Tage sein
|
||||||
example: "2023-02-01"
|
example: "2023-02-01"
|
||||||
preorderType:
|
preorderType:
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
Reference in New Issue
Block a user