Merge branch 'fronkdev' into 'master'
Preorder patchposition can be edited now See merge request fronk/thetool!146
This commit is contained in:
@@ -337,6 +337,58 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-6">
|
||||
<h3>
|
||||
Patchposition
|
||||
<?php if($preorder->adb_wohneinheit_id): ?>
|
||||
<small id="preorder-detail-<?=$preorder->id?>-patchposition-edit"><a href="#" onclick="togglePortdata(<?=$preorder->id?>); return false;"><i class="fas fa-pencil"></i> Bearbeiten</a></small>
|
||||
<span id="preorder-detail-<?=$preorder->id?>-patchposition-controls" class="hidden">
|
||||
<button type="button" class="btn btn-sm btn-primary" onclick="savePortdata(<?=$preorder->id?>)"><i class="fas fa-check"></i></button>
|
||||
<button type="button" class="btn btn-sm btn-secondary" onclick="togglePortdata(<?=$preorder->id?>)"><i class="fas fa-times"></i></button>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</h3>
|
||||
<table class="table table-sm table-striped" id="preorder-detail-<?=$preorder->id?>-patchposition">
|
||||
<tr>
|
||||
<th>Equipment Name:</th>
|
||||
<td>
|
||||
<span id="preorder-detail-<?=$preorder->id?>-patchposition-string"><?=$preorder->adb_wohneinheit->getPatchEqString()?></span>
|
||||
<table class="row hidden" id="preorder-detail-<?=$preorder->id?>-patchposition-data-form">
|
||||
<tr>
|
||||
<th>Cluster:</td>
|
||||
<td><input type="text" class="form-control" name="patch_cluster"
|
||||
data-default="<?=($preorder->adb_wohneinheit->patch_cluster) ? $preorder->adb_wohneinheit->patch_cluster : $preorder->adb_hausnummer->netzgebiet->extref?>"
|
||||
/></td>
|
||||
</tr><tr>
|
||||
<th>Shelf:</td>
|
||||
<td><input type="text" class="form-control" name="patch_shelf"
|
||||
data-default="<?=$preorder->adb_wohneinheit->patch_shelf?>"
|
||||
/></td>
|
||||
</tr><tr>
|
||||
<th>Module:</td>
|
||||
<td><input type="text" class="form-control" name="patch_module"
|
||||
data-default="<?=$preorder->adb_wohneinheit->patch_module?>"
|
||||
/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Equipment Port:</th>
|
||||
<td>
|
||||
<span id="preorder-detail-<?=$preorder->id?>-patchposition-port"><?=$preorder->adb_wohneinheit->patch_port?></span>
|
||||
<table class="row hidden" id="preorder-detail-<?=$preorder->id?>-patchposition-port-form">
|
||||
<tr>
|
||||
<th>Port:</td>
|
||||
<td><input type="text" class="form-control" name="patch_port" data-default="<?=$preorder->adb_wohneinheit->patch_port?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -351,6 +403,67 @@
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
function togglePortdata(pid) {
|
||||
$("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_cluster']").val($("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_cluster']").data("default"));
|
||||
$("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_shelf']").val($("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_shelf']").data("default"));
|
||||
$("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_module']").val($("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_module']").data("default"));
|
||||
|
||||
$("#preorder-detail-" + pid + "-patchposition-port-form input[name='patch_port']").val($("#preorder-detail-" + pid + "-patchposition-port-form input[name='patch_port']").data("default"));
|
||||
|
||||
|
||||
$("#preorder-detail-" + pid + "-patchposition-data-form").toggle();
|
||||
$("#preorder-detail-" + pid + "-patchposition-string").toggle();
|
||||
|
||||
$("#preorder-detail-" + pid + "-patchposition-port-form").toggle();
|
||||
$("#preorder-detail-" + pid + "-patchposition-port").toggle();
|
||||
|
||||
$("#preorder-detail-" + pid + "-patchposition-edit").toggle();
|
||||
$("#preorder-detail-" + pid + "-patchposition-controls").toggle();
|
||||
|
||||
}
|
||||
|
||||
function savePortdata(pid) {
|
||||
if(!pid) return;
|
||||
|
||||
var cluster = $("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_cluster']").val();
|
||||
var shelf = $("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_shelf']").val();
|
||||
var module = $("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_module']").val();
|
||||
var port = $("#preorder-detail-" + pid + "-patchposition-port-form input[name='patch_port']").val();
|
||||
|
||||
$.post("<?=self::getUrl("Preorder", "Api")?>", {
|
||||
do: "savePatchposition",
|
||||
id: pid,
|
||||
cluster: cluster,
|
||||
shelf: shelf,
|
||||
module: module,
|
||||
port: port
|
||||
},
|
||||
(success) => {
|
||||
if(success.status == "OK") {
|
||||
var pid = success.result.id;
|
||||
var default_cluster = $("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_cluster']").data("default");
|
||||
var cluster = $("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_cluster']").val();
|
||||
var shelf = $("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_shelf']").val();
|
||||
var module = $("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_module']").val();
|
||||
var port = $("#preorder-detail-" + pid + "-patchposition-port-form input[name='patch_port']").val();
|
||||
|
||||
if(!cluster) cluster = default_cluster;
|
||||
|
||||
$("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_cluster']").data("default", cluster);
|
||||
$("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_shelf']").data("default", shelf);
|
||||
$("#preorder-detail-" + pid + "-patchposition-data-form input[name='patch_module']").data("default", module);
|
||||
$("#preorder-detail-" + pid + "-patchposition-port-form input[name='patch_port']").data("default", port);
|
||||
$("#preorder-detail-" + pid + "-patchposition-string").text(cluster + "-" + shelf + "-" + module);
|
||||
$("#preorder-detail-" + pid + "-patchposition-port").text(port);
|
||||
togglePortdata(pid);
|
||||
|
||||
}
|
||||
},
|
||||
"json"
|
||||
);
|
||||
}
|
||||
|
||||
function toggleStatusControl(pid, sid) {
|
||||
// set select to current status id
|
||||
$("#preorder-detail-status-" + pid + "-input select").val($("#preorder-detail-status-" + pid + "-text").data("status-id"));
|
||||
|
||||
@@ -159,6 +159,20 @@ class ADBWohneinheit extends mfBaseModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getPatchEqString() {
|
||||
$patch = "";
|
||||
if($this->patch_cluster) {
|
||||
$patch = $this->patch_cluster;
|
||||
} else {
|
||||
$patch = $this->getProperty("hausnummer")->netzgebiet->extref;
|
||||
}
|
||||
|
||||
if($this->patch_shelf) $patch .= "-".$this->patch_shelf;
|
||||
if($this->patch_module) $patch .= "-".$this->patch_module;
|
||||
|
||||
return $patch;
|
||||
}
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@ class ADBWohneinheitModel {
|
||||
public $zusatz;
|
||||
public $bezeichner;
|
||||
public $nutzung;
|
||||
public $patch_cluster;
|
||||
public $patch_shelf;
|
||||
public $patch_module;
|
||||
public $patch_port;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
|
||||
@@ -14,11 +14,52 @@ class Cif extends Modules\ApiControllerModule {
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* GET /preorder/:code/clientInstallationFinished
|
||||
*/
|
||||
public function providerSetCif($code) {
|
||||
return \mfResponse::InternalServerError();
|
||||
//return \mfResponse::Ok(["message" => "in providerSetCif($code)"]);
|
||||
$code = trim($code);
|
||||
if(!$code) {
|
||||
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
$preorder = \PreorderModel::getFirst(['ucode' => strtoupper($code), 'partner_id' => $this->me->address_id]);
|
||||
if(!$preorder) {
|
||||
// try oaid
|
||||
$preorder = \PreorderModel::getFirst(['oaid' => strtolower($code), 'partner_id' => $this->me->address_id], "`create` DESC");
|
||||
}
|
||||
if(!$preorder) {
|
||||
// try as extref
|
||||
$preorder = \PreorderModel::getFirst(['extref' => $code, 'partner_id' => $this->me->address_id]);
|
||||
}
|
||||
|
||||
if(!$preorder) {
|
||||
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
|
||||
if($preorder->partner_id != $this->me->address_id) {
|
||||
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
|
||||
// set status to 200
|
||||
if($preorder->status->code < 200) {
|
||||
$new_status = \PreorderstatusModel::getFirst(["code" => 200]);
|
||||
if(!$new_status) {
|
||||
return \mfResponse::InternalServerError();
|
||||
}
|
||||
$preorder->status_id = $new_status->id;
|
||||
$preorder->save();
|
||||
}
|
||||
|
||||
return \mfResponse::Ok(["message" => "Status successfully updated."]);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* GET /preorder/customerInstallationFeedback
|
||||
*/
|
||||
public function getCifData() {
|
||||
|
||||
if(!array_key_exists("ciftoken", $this->get) || !$this->get['ciftoken']) {
|
||||
@@ -35,10 +76,13 @@ class Cif extends Modules\ApiControllerModule {
|
||||
return \mfResponse::Ok($return);
|
||||
}
|
||||
|
||||
/*
|
||||
* POST /preorder/customerInstallationFeedback
|
||||
*/
|
||||
public function userSetCif() {
|
||||
return \mfResponse::InternalServerError();
|
||||
|
||||
if(!array_key_exists("ciftoken", $this->get) || !$this->get['ciftoken']) {
|
||||
if(!array_key_exists("ciftoken", $this->post) || !$this->post['ciftoken']) {
|
||||
return \mfResponse::BadRequest(["message" => "ciftoken missing"]);
|
||||
}
|
||||
|
||||
@@ -47,6 +91,18 @@ class Cif extends Modules\ApiControllerModule {
|
||||
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
||||
}
|
||||
|
||||
// set status to 200
|
||||
if($preorder->status->code < 200) {
|
||||
$new_status = \PreorderstatusModel::getFirst(["code" => 200]);
|
||||
if(!$new_status) {
|
||||
return \mfResponse::InternalServerError();
|
||||
}
|
||||
$preorder->status_id = $new_status->id;
|
||||
$preorder->save();
|
||||
}
|
||||
|
||||
return \mfResponse::Ok(["message" => "Status successfully updated."]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -693,8 +693,10 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
$preorder_data['extref'] = (trim($this->post['extref'])) ? trim($this->post['extref']) : null;
|
||||
$preorder_data['technology'] = (trim($this->post['technology'])) ? trim($this->post['technology']) : null;
|
||||
/*
|
||||
* patchposition now comes from RIMO
|
||||
$preorder_data['equipment_name'] = (trim($this->post['equipment_name'])) ? trim($this->post['equipment_name']) : null;
|
||||
$preorder_data['equipment_port'] = (trim($this->post['equipment_port'])) ? trim($this->post['equipment_port']) : null;
|
||||
$preorder_data['equipment_port'] = (trim($this->post['equipment_port'])) ? trim($this->post['equipment_port']) : null;*/
|
||||
|
||||
/*
|
||||
* setup price
|
||||
|
||||
@@ -433,8 +433,8 @@ class Preorder extends mfBaseModel {
|
||||
$a['connectionCount'] = ($this->connection_count) ? (int)$this->connection_count : 1;
|
||||
$a['isAdditionalOrder'] = ($this->is_additional_order) ? true : false;
|
||||
$a['technology'] = ($this->technology) ? $this->technology : null;
|
||||
$a['equipment_name'] = ($this->equipment_name) ? $this->equipment_name: null;
|
||||
$a['equipment_port'] = ($this->equipment_port) ? $this->equipment_port: null;
|
||||
$a['equipment_name'] = ($wohneinheit->getPatchEqString()) ? $wohneinheit->getPatchEqString(): null;
|
||||
$a['equipment_port'] = ($wohneinheit->patch_port) ? $wohneinheit->patch_port: null;
|
||||
$a['preorderType'] = $this->type;
|
||||
$a['acceptMarketing'] = ($this->accept_marketing) ? true : false;
|
||||
$a['acceptAgb'] = ($this->accept_agb) ? true : false;
|
||||
|
||||
@@ -802,6 +802,9 @@ class PreorderController extends mfBaseController {
|
||||
case "deleteWorkorder":
|
||||
$return = $this->deleteWorkorderApi();
|
||||
break;
|
||||
case "savePatchposition":
|
||||
$return = $this->savePatchpositionApi();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
@@ -987,39 +990,43 @@ class PreorderController extends mfBaseController {
|
||||
$update[] = $up;
|
||||
}
|
||||
|
||||
/* $update = [
|
||||
"preorder" => [
|
||||
"status" => [
|
||||
"id" => $status->id,
|
||||
"code" => $status->code,
|
||||
"text" => $status->name
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
if($preorder->adb_hausnummer_id) {
|
||||
$update["building"] = [
|
||||
"status" => [
|
||||
"id" => $preorder->adb_hausnummer->status->id,
|
||||
"code" => $preorder->adb_hausnummer->status->code,
|
||||
"text" => $preorder->adb_hausnummer->status->name
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
if($preorder->adb_wohneinheit_id) {
|
||||
$update["unit"] = [
|
||||
"status" => [
|
||||
"id" => $preorder->adb_wohneinheit->status->id,
|
||||
"code" => $preorder->adb_wohneinheit->status->code,
|
||||
"text" => $preorder->adb_wohneinheit->status->name
|
||||
]
|
||||
];
|
||||
}
|
||||
*/
|
||||
return ["message" => "Status saved successfully", "id" => $preorder_id, "updates" => $update];
|
||||
}
|
||||
|
||||
private function savePatchpositionApi() {
|
||||
$preorder_id = $this->request->id;
|
||||
|
||||
$cluster = $this->request->cluster;
|
||||
$shelf = $this->request->shelf;
|
||||
$module = $this->request->module;
|
||||
$port = $this->request->port;
|
||||
|
||||
if(!is_numeric($preorder_id) || $preorder_id < 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$preorder = new Preorder($preorder_id);
|
||||
if(!$preorder->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$preorder->adb_wohneinheit_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$we = $preorder->adb_wohneinheit;
|
||||
if($cluster && $cluster != $we->cluster) {
|
||||
$we->patch_cluster = $cluster;
|
||||
}
|
||||
$we->patch_shelf = $shelf;
|
||||
$we->patch_module = $module;
|
||||
$we->patch_port = $port;
|
||||
$we->save();
|
||||
|
||||
return ["message" => "Patchposition saved successfully", "id" => $preorder->id];
|
||||
|
||||
}
|
||||
|
||||
private function deleteWorkorderApi() {
|
||||
if(!$this->me->is("Admin")) {
|
||||
return false;
|
||||
@@ -1046,7 +1053,7 @@ class PreorderController extends mfBaseController {
|
||||
}
|
||||
|
||||
$workorder->delete();
|
||||
return ["Message" => "Workorder deleted successfully", "id" => $preorder->id];
|
||||
return ["message" => "Workorder deleted successfully", "id" => $preorder->id];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,8 +51,6 @@ class PreorderModel {
|
||||
public $phone;
|
||||
public $email;
|
||||
public $technology;
|
||||
public $equipment_name;
|
||||
public $equipment_port;
|
||||
public $is_additional_order;
|
||||
public $shipping_address;
|
||||
public $addon_services;
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class WohneinheitAddPatchdata extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Preorder");
|
||||
$table->removeColumn("equipment_name");
|
||||
$table->removeColumn("equipment_port");
|
||||
$table->save();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
$table = $this->table("Wohneinheit");
|
||||
$table->addColumn("patch_cluster", "string", ["null" => true, "default" => null, "limit" => 255, "after" => "nutzung"]);
|
||||
$table->addColumn("patch_shelf", "string", ["null" => true, "default" => null, "limit" => 255, "after" => "patch_cluster"]);
|
||||
$table->addColumn("patch_module", "string", ["null" => true, "default" => null, "limit" => 255, "after" => "patch_shelf"]);
|
||||
$table->addColumn("patch_port", "string", ["null" => true, "default" => null, "limit" => 255, "after" => "patch_module"]);
|
||||
$table->update();
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Preorder");
|
||||
$table->addColumn("equipment_name", "string", ["null" => true, "default" => null, "limit" => 1024, "after" => "technology"]);
|
||||
$table->addColumn("equipment_port", "string", ["null" => true, "default" => null, "limit" => 1024, "after" => "equipment_name"]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
$table = $this->table("Wohneinheit");
|
||||
$table->removeColumn("patch_port");
|
||||
$table->removeColumn("patch_module");
|
||||
$table->removeColumn("patch_shelf");
|
||||
$table->removeColumn("patch_cluster");
|
||||
$table->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ $mainlog = mfLoghandler::singleton();
|
||||
$log = new mfLog_File();
|
||||
$log->init(BASEDIR."/var/log/rimo-import.log");
|
||||
|
||||
$apiOwner = "rml";
|
||||
$apiOwner = "estmk";
|
||||
$apiEdition = "prod";
|
||||
$apiData = TT_RIMO_API_CREDS[$apiOwner][$apiEdition];
|
||||
|
||||
@@ -30,10 +30,10 @@ $apiToken = $apiData["key"];
|
||||
$epGetClusters = $apiUrl.RIMO_API_JSON_EP_GET_CLUSTERS;
|
||||
$epGetBuildings = $apiUrl.RIMO_API_JSON_EP_GET_BUILDINGS;
|
||||
|
||||
|
||||
/*
|
||||
if(!defined("RIMO_API_JSON_APIKEY_PROD")) {
|
||||
die("rimo api token not defined!");
|
||||
}
|
||||
}*/
|
||||
|
||||
$import_count = 0;
|
||||
|
||||
@@ -71,12 +71,14 @@ if($responseText === false) {
|
||||
}
|
||||
|
||||
$clustersResponse = json_decode($responseText);
|
||||
var_dump($clustersResponse);
|
||||
exit;
|
||||
//var_dump($clustersResponse);
|
||||
//exit;
|
||||
if(is_object($clustersResponse) && property_exists($clustersResponse, "item") && is_array($clustersResponse->item) && count($clustersResponse->item)) {
|
||||
|
||||
foreach($clustersResponse->item as $cluster) {
|
||||
$cluster_rimo_id = $cluster->id;
|
||||
echo "$cluster_rimo_id | name: ".$cluster->name."; label: ".$cluster->userLabel."\n";
|
||||
continue;
|
||||
$adb_netzgebiet = ADBNetzgebietModel::getFirst(['rimo_id' => $cluster_rimo_id]);
|
||||
if(!$adb_netzgebiet) {
|
||||
echo "Kein Netzgebiet für Salescluster $cluster_rimo_id (".$cluster->name.")\n";
|
||||
|
||||
Reference in New Issue
Block a user