Merge branch 'fronkdev' into 'master'
PreorderBilling WIP & Api changed See merge request fronk/thetool!1127
This commit is contained in:
@@ -99,6 +99,20 @@ class Preorder extends mfBaseModel {
|
||||
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() {
|
||||
$contact_fields = [
|
||||
"company",
|
||||
@@ -141,7 +155,8 @@ class Preorder extends mfBaseModel {
|
||||
"preorder_id" => $this->id,
|
||||
"key" => $field,
|
||||
"old_value" => $this->_old_data->$field,
|
||||
"new_value" => $this->data->$field
|
||||
"new_value" => $this->data->$field,
|
||||
"changed" => date("U")
|
||||
]);
|
||||
$history->save();
|
||||
}
|
||||
|
||||
@@ -1064,6 +1064,9 @@ class PreorderController extends mfBaseController {
|
||||
case "saveOrderdate":
|
||||
$return = $this->saveOrderdateApi();
|
||||
break;
|
||||
case "saveActivationdate":
|
||||
$return = $this->saveActivationdateApi();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
@@ -1097,6 +1100,34 @@ class PreorderController extends mfBaseController {
|
||||
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() {
|
||||
$preorder_id = $this->request->preorder_id;
|
||||
$workorder_id = $this->request->workorder_id;
|
||||
|
||||
@@ -658,6 +658,20 @@ class PreorderModel
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists("<=status_code", $filter)) {
|
||||
$status_code = $filter['<=status_code'];
|
||||
if (is_numeric($status_code)) {
|
||||
$where .= " AND tt_preorderstatus.code <= $status_code";
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists(">=status_code", $filter)) {
|
||||
$status_code = $filter['>=status_code'];
|
||||
if (is_numeric($status_code)) {
|
||||
$where .= " AND tt_preorderstatus.code >= $status_code";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (array_key_exists("preordercampaign_id", $filter)) {
|
||||
$preordercampaign_id = $filter['preordercampaign_id'];
|
||||
|
||||
Reference in New Issue
Block a user