Added fields to POST /preorder
This commit is contained in:
@@ -9,203 +9,4 @@ class AddressDB {
|
||||
$this->log = mfLoghandler::singleton();
|
||||
}
|
||||
|
||||
public function import($input) {
|
||||
if(!$input) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(is_string($input)) {
|
||||
if(!file_exists($input)) {
|
||||
return false;
|
||||
}
|
||||
$file = fopen($input, "r");
|
||||
if(!$file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$input = $file;
|
||||
}
|
||||
|
||||
if(!is_resource($input)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$gem_kz = "";
|
||||
$gem_name = "";
|
||||
$ort_kz = "";
|
||||
$plz_name = "";
|
||||
$ort_name = "";
|
||||
$strasse_building = "";
|
||||
$strasse = "";
|
||||
$hausnummer_name = "";
|
||||
|
||||
$i = 0;
|
||||
while($csv = fgetcsv($input, 0, ";")) {
|
||||
$i++;
|
||||
if($i == 1) continue;
|
||||
|
||||
//var_dump($csv);
|
||||
|
||||
|
||||
if(trim($csv[0])) {
|
||||
$gem_kz = trim($csv[0]);
|
||||
$gem_name = trim($csv[1]);
|
||||
$ort_kz = trim($csv[2]);
|
||||
$plz_name = trim($csv[3]);
|
||||
$ort_name = trim($csv[4]);
|
||||
$strasse_building = trim($csv[5]);
|
||||
$strasse_name = trim($csv[6]);
|
||||
|
||||
//echo "strasse: $strasse\n";
|
||||
//echo "strasse_building: $strasse_building\n";
|
||||
|
||||
$hausnummer_name = preg_replace('/^'.$strasse_name.'\s+/', "", $strasse_building);
|
||||
//echo "$strasse_name $hausnummer_name\n";
|
||||
}
|
||||
|
||||
$strasse_we = trim($csv[7]);
|
||||
$nutzung = trim($csv[8]);
|
||||
$we_num = trim($csv[11]);
|
||||
|
||||
if(!$strasse_we) {
|
||||
echo "Adresse Wohneinheit fehlt.\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
//echo "strasse_we: $strasse_we\n";
|
||||
if($strasse_building == $strasse_we) {
|
||||
$addresszusatz = "";
|
||||
} else {
|
||||
$addresszusatz = preg_replace('/^'.$strasse_building.'\s+/', "", $strasse_we);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$hausnummer_zusatz = ADBWohneinheit::parseHausnummerZusatz($addresszusatz);
|
||||
//var_dump($hausnummer_zusatz);
|
||||
|
||||
echo "$gem_name $plz_name $ort_name $strasse_name $hausnummer_name ";
|
||||
foreach($hausnummer_zusatz as $key => $value) {
|
||||
if($value) {
|
||||
if($key == "zusatz") {
|
||||
echo $value;
|
||||
continue;
|
||||
}
|
||||
echo ucfirst($key)." ".$value;
|
||||
}
|
||||
}
|
||||
echo " ($nutzung)\n";
|
||||
|
||||
$gemeinde = ADBGemeindeModel::getFirst(['kennziffer' => $gem_kz]);
|
||||
if(!$gemeinde) {
|
||||
$gemeinde = new ADBGemeinde();
|
||||
$gemeinde->kennziffer = $gem_kz;
|
||||
$gemeinde->code = $gem_kz;
|
||||
$gemeinde->name = $gem_name;
|
||||
$gemeinde_id = $gemeinde->save();
|
||||
if(!$gemeinde_id) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$ort = ADBOrtschaftModel::getFirst(['kennziffer' => $ort_kz]);
|
||||
if(!$ort) {
|
||||
$ort = new ADBOrtschaft();
|
||||
$ort->gemeinde_id = $gemeinde->id;
|
||||
$ort->kennziffer = $ort_kz;
|
||||
$ort->name = $ort_name;
|
||||
$ort->plz = $plz_name;
|
||||
$ort_id = $ort->save();
|
||||
if(!$ort_id) {
|
||||
die("Error creating Ortschaft $ort_kz $ort_name!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$plz = ADBPlzModel::getFirst(['plz' => $plz_name]);
|
||||
if(!$plz) {
|
||||
$plz = new ADBPlz();
|
||||
$plz->plz = $plz_name;
|
||||
$plz->plzstring = $plz_name;
|
||||
$plz_id = $plz->save();
|
||||
if(!$plz) {
|
||||
die("Error creating Plz $plz_name!\n");
|
||||
}
|
||||
}
|
||||
//var_dump($plz);exit;
|
||||
|
||||
|
||||
$strasse = ADBStrasseModel::getFirst(['gemeinde_id' => $gemeinde->id, 'ortschaft_id' => $ort->id, 'name' => $strasse_name]);
|
||||
if(!$strasse) {
|
||||
$strasse = new ADBStrasse();
|
||||
$strasse->ortschaft_id = $ort->id;
|
||||
$strasse->gemeinde_id = $gemeinde->id;
|
||||
$strasse->name = $strasse_name;
|
||||
$strasse_id = $strasse->save();
|
||||
if(!$strasse_id) {
|
||||
die("error creating Strasse $strasse_name (gemeinde ".$gemeinde->id.", ort ".$ort->id.")");
|
||||
}
|
||||
}
|
||||
//var_dump($strasse);exit;
|
||||
|
||||
|
||||
$hausnummer = ADBHausnummerModel::getFirst(['strasse_id' => $strasse->id, 'hausnummer' => $hausnummer_name]);
|
||||
if(!$hausnummer) {
|
||||
$hausnummer = new ADBHausnummer();
|
||||
$hausnummer->plz_id = $plz->id;
|
||||
$hausnummer->strasse_id = $strasse->id;
|
||||
$hausnummer->hausnummer = $hausnummer_name;
|
||||
$hausnummer_id = $hausnummer->save();
|
||||
if(!$hausnummer_id) {
|
||||
die("error creating Hausnummer $strasse_name $hausnummer_name");
|
||||
}
|
||||
}
|
||||
//var_dump($hausnummer);exit;
|
||||
|
||||
|
||||
$we_search = [
|
||||
'hausnummer_id' => $hausnummer->id,
|
||||
'num' => $we_num,
|
||||
'block' => $hausnummer_zusatz['block'],
|
||||
'stiege' => $hausnummer_zusatz['stiege'],
|
||||
'stock' => $hausnummer_zusatz['stock'],
|
||||
'tuer' => $hausnummer_zusatz['tuer'],
|
||||
'zusatz' => $hausnummer_zusatz['zusatz'],
|
||||
'nutzung' => $nutzung
|
||||
];
|
||||
|
||||
/*if($hausnummer_name == "12a") {
|
||||
var_dump($we_search);exit;
|
||||
}*/
|
||||
|
||||
$wohneinheit = ADBWohneinheitModel::getFirst($we_search);
|
||||
if(!$wohneinheit) {
|
||||
$wohneinheit = new ADBWohneinheit();
|
||||
$wohneinheit->hausnummer_id = $hausnummer->id;
|
||||
$wohneinheit->num = $we_num;
|
||||
$wohneinheit->block = ($hausnummer_zusatz['block']) ? $hausnummer_zusatz['block'] : null;
|
||||
$wohneinheit->stiege = ($hausnummer_zusatz['stiege']) ? $hausnummer_zusatz['stiege'] : null;
|
||||
$wohneinheit->stock = ($hausnummer_zusatz['stock']) ? $hausnummer_zusatz['stock'] : null;
|
||||
$wohneinheit->tuer = ($hausnummer_zusatz['tuer']) ? $hausnummer_zusatz['tuer'] : null;
|
||||
$wohneinheit->zusatz = ($hausnummer_zusatz['zusatz']) ? $hausnummer_zusatz['zusatz'] : null;
|
||||
$wohneinheit->nutzung = $nutzung;
|
||||
$wohneinheit_id = $wohneinheit->save();
|
||||
if(!$wohneinheit_id) {
|
||||
die("error creating Wohneinheit $strasse_name $hausnummer_name ".implode(", ", $hausnummer_zusatz));
|
||||
}
|
||||
} else {
|
||||
echo "XXXX wohneinheit gibts schon: $strasse_name $hausnummer_name ".implode(", ", $hausnummer_zusatz)."\n\n";
|
||||
}
|
||||
|
||||
|
||||
/*if($i > 10) {
|
||||
exit;
|
||||
}*/
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -14,6 +14,10 @@ class AddressDBController extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
protected function importAction($input) {
|
||||
|
||||
}
|
||||
|
||||
protected function apiAction() {
|
||||
if(!$this->me->is(["Admin","netowner"])) {
|
||||
$this->redirect("Dashboard");
|
||||
|
||||
209
application/AddressDB/Importer/csv.php
Normal file
209
application/AddressDB/Importer/csv.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
class AddressDB_Importer_Csv {
|
||||
private $db;
|
||||
private $log;
|
||||
|
||||
public function __construct() {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$this->log = mfLoghandler::singleton();
|
||||
}
|
||||
|
||||
public function import($input) {
|
||||
if(!$input) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(is_string($input)) {
|
||||
if(!file_exists($input)) {
|
||||
return false;
|
||||
}
|
||||
$file = fopen($input, "r");
|
||||
if(!$file) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$input = $file;
|
||||
}
|
||||
|
||||
if(!is_resource($input)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$gem_kz = "";
|
||||
$gem_name = "";
|
||||
$ort_kz = "";
|
||||
$plz_name = "";
|
||||
$ort_name = "";
|
||||
$strasse_building = "";
|
||||
$strasse = "";
|
||||
$hausnummer_name = "";
|
||||
|
||||
$i = 0;
|
||||
while($csv = fgetcsv($input, 0, ";")) {
|
||||
$i++;
|
||||
if($i == 1) continue;
|
||||
|
||||
//var_dump($csv);
|
||||
|
||||
|
||||
if(trim($csv[0])) {
|
||||
$gem_kz = trim($csv[0]);
|
||||
$gem_name = trim($csv[1]);
|
||||
$ort_kz = trim($csv[2]);
|
||||
$plz_name = trim($csv[3]);
|
||||
$ort_name = trim($csv[4]);
|
||||
$strasse_building = trim($csv[5]);
|
||||
$strasse_name = trim($csv[6]);
|
||||
|
||||
//echo "strasse: $strasse\n";
|
||||
//echo "strasse_building: $strasse_building\n";
|
||||
|
||||
$hausnummer_name = preg_replace('/^'.$strasse_name.'\s+/', "", $strasse_building);
|
||||
//echo "$strasse_name $hausnummer_name\n";
|
||||
}
|
||||
|
||||
$strasse_we = trim($csv[7]);
|
||||
$nutzung = trim($csv[8]);
|
||||
$we_num = trim($csv[11]);
|
||||
|
||||
if(!$strasse_we) {
|
||||
echo "Adresse Wohneinheit fehlt.\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
//echo "strasse_we: $strasse_we\n";
|
||||
if($strasse_building == $strasse_we) {
|
||||
$addresszusatz = "";
|
||||
} else {
|
||||
$addresszusatz = preg_replace('/^'.$strasse_building.'\s+/', "", $strasse_we);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$hausnummer_zusatz = ADBWohneinheit::parseHausnummerZusatz($addresszusatz);
|
||||
//var_dump($hausnummer_zusatz);
|
||||
|
||||
echo "$gem_name $plz_name $ort_name $strasse_name $hausnummer_name ";
|
||||
foreach($hausnummer_zusatz as $key => $value) {
|
||||
if($value) {
|
||||
if($key == "zusatz") {
|
||||
echo $value;
|
||||
continue;
|
||||
}
|
||||
echo ucfirst($key)." ".$value;
|
||||
}
|
||||
}
|
||||
echo " ($nutzung)\n";
|
||||
|
||||
$gemeinde = ADBGemeindeModel::getFirst(['kennziffer' => $gem_kz]);
|
||||
if(!$gemeinde) {
|
||||
$gemeinde = new ADBGemeinde();
|
||||
$gemeinde->kennziffer = $gem_kz;
|
||||
$gemeinde->code = $gem_kz;
|
||||
$gemeinde->name = $gem_name;
|
||||
$gemeinde_id = $gemeinde->save();
|
||||
if(!$gemeinde_id) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$ort = ADBOrtschaftModel::getFirst(['kennziffer' => $ort_kz]);
|
||||
if(!$ort) {
|
||||
$ort = new ADBOrtschaft();
|
||||
$ort->gemeinde_id = $gemeinde->id;
|
||||
$ort->kennziffer = $ort_kz;
|
||||
$ort->name = $ort_name;
|
||||
$ort->plz = $plz_name;
|
||||
$ort_id = $ort->save();
|
||||
if(!$ort_id) {
|
||||
die("Error creating Ortschaft $ort_kz $ort_name!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$plz = ADBPlzModel::getFirst(['plz' => $plz_name]);
|
||||
if(!$plz) {
|
||||
$plz = new ADBPlz();
|
||||
$plz->plz = $plz_name;
|
||||
$plz->plzstring = $plz_name;
|
||||
$plz_id = $plz->save();
|
||||
if(!$plz) {
|
||||
die("Error creating Plz $plz_name!\n");
|
||||
}
|
||||
}
|
||||
//var_dump($plz);exit;
|
||||
|
||||
|
||||
$strasse = ADBStrasseModel::getFirst(['gemeinde_id' => $gemeinde->id, 'ortschaft_id' => $ort->id, 'name' => $strasse_name]);
|
||||
if(!$strasse) {
|
||||
$strasse = new ADBStrasse();
|
||||
$strasse->ortschaft_id = $ort->id;
|
||||
$strasse->gemeinde_id = $gemeinde->id;
|
||||
$strasse->name = $strasse_name;
|
||||
$strasse_id = $strasse->save();
|
||||
if(!$strasse_id) {
|
||||
die("error creating Strasse $strasse_name (gemeinde ".$gemeinde->id.", ort ".$ort->id.")");
|
||||
}
|
||||
}
|
||||
//var_dump($strasse);exit;
|
||||
|
||||
|
||||
$hausnummer = ADBHausnummerModel::getFirst(['strasse_id' => $strasse->id, 'hausnummer' => $hausnummer_name]);
|
||||
if(!$hausnummer) {
|
||||
$hausnummer = new ADBHausnummer();
|
||||
$hausnummer->plz_id = $plz->id;
|
||||
$hausnummer->strasse_id = $strasse->id;
|
||||
$hausnummer->hausnummer = $hausnummer_name;
|
||||
$hausnummer_id = $hausnummer->save();
|
||||
if(!$hausnummer_id) {
|
||||
die("error creating Hausnummer $strasse_name $hausnummer_name");
|
||||
}
|
||||
}
|
||||
//var_dump($hausnummer);exit;
|
||||
|
||||
|
||||
$we_search = [
|
||||
'hausnummer_id' => $hausnummer->id,
|
||||
'num' => $we_num,
|
||||
'block' => $hausnummer_zusatz['block'],
|
||||
'stiege' => $hausnummer_zusatz['stiege'],
|
||||
'stock' => $hausnummer_zusatz['stock'],
|
||||
'tuer' => $hausnummer_zusatz['tuer'],
|
||||
'zusatz' => $hausnummer_zusatz['zusatz'],
|
||||
'nutzung' => $nutzung
|
||||
];
|
||||
|
||||
/*if($hausnummer_name == "12a") {
|
||||
var_dump($we_search);exit;
|
||||
}*/
|
||||
|
||||
$wohneinheit = ADBWohneinheitModel::getFirst($we_search);
|
||||
if(!$wohneinheit) {
|
||||
$wohneinheit = new ADBWohneinheit();
|
||||
$wohneinheit->hausnummer_id = $hausnummer->id;
|
||||
$wohneinheit->num = $we_num;
|
||||
$wohneinheit->block = ($hausnummer_zusatz['block']) ? $hausnummer_zusatz['block'] : null;
|
||||
$wohneinheit->stiege = ($hausnummer_zusatz['stiege']) ? $hausnummer_zusatz['stiege'] : null;
|
||||
$wohneinheit->stock = ($hausnummer_zusatz['stock']) ? $hausnummer_zusatz['stock'] : null;
|
||||
$wohneinheit->tuer = ($hausnummer_zusatz['tuer']) ? $hausnummer_zusatz['tuer'] : null;
|
||||
$wohneinheit->zusatz = ($hausnummer_zusatz['zusatz']) ? $hausnummer_zusatz['zusatz'] : null;
|
||||
$wohneinheit->nutzung = $nutzung;
|
||||
$wohneinheit_id = $wohneinheit->save();
|
||||
if(!$wohneinheit_id) {
|
||||
die("error creating Wohneinheit $strasse_name $hausnummer_name ".implode(", ", $hausnummer_zusatz));
|
||||
}
|
||||
} else {
|
||||
echo "XXXX wohneinheit gibts schon: $strasse_name $hausnummer_name ".implode(", ", $hausnummer_zusatz)."\n\n";
|
||||
}
|
||||
|
||||
|
||||
/*if($i > 10) {
|
||||
exit;
|
||||
}*/
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
21
application/AddressDB/Importer/rimo.php
Normal file
21
application/AddressDB/Importer/rimo.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
class AddressDB_Importer_Rimo {
|
||||
private $db;
|
||||
private $log;
|
||||
|
||||
private $campaign;
|
||||
|
||||
public function __construct(Preordercampain $campaign) {
|
||||
$this->db = FronkDB::singleton(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
$this->log = mfLoghandler::singleton();
|
||||
}
|
||||
|
||||
public function isValid() {
|
||||
|
||||
}
|
||||
|
||||
public function import() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -32,11 +32,23 @@ class AddressdbApicontroller extends mfBaseApicontroller {
|
||||
|
||||
protected function findCity() {
|
||||
$search = $this->db()->escape(trim($this->post['search']));
|
||||
$city = $this->db()->escape(trim($this->post['city']));
|
||||
$zip = $this->db()->escape(trim($this->post['zip']));
|
||||
|
||||
if($city) {
|
||||
$search = $city;
|
||||
}
|
||||
|
||||
if(!$search) {
|
||||
return mfResponse::BadRequest(['message' => "Searchstring cannot be empty!"]);
|
||||
}
|
||||
|
||||
$results = ADBGemeindeModel::search(['name%' => $search]);
|
||||
$city_search = ['name%' => $search];
|
||||
if($zip) {
|
||||
$city_search['zip'] = $zip;
|
||||
}
|
||||
|
||||
$results = ADBGemeindeModel::search($city_search);
|
||||
|
||||
|
||||
$cities = [];
|
||||
|
||||
@@ -36,11 +36,33 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
return mfResponse::Forbidden();
|
||||
}
|
||||
|
||||
$type = $this->post['type'];
|
||||
$type = $this->post['preorderType'];
|
||||
if($type != "interest" && $type != "provision" && $type != "order") {
|
||||
return mfResponse::BadRequest(["message" => "Unknown type"]);
|
||||
return mfResponse::BadRequest(["message" => "Invalid preorderType"]);
|
||||
}
|
||||
|
||||
$connection_type = false;
|
||||
switch($this->post['connectionType']) {
|
||||
case "single-dwelling":
|
||||
$connection_type = "single-dwelling";
|
||||
break;
|
||||
case "multi-dwelling":
|
||||
$connection_type = "multi-dwelling";
|
||||
break;
|
||||
case "apartment-building":
|
||||
$connection_type = "apartment-building";
|
||||
break;
|
||||
case "apartment":
|
||||
$connection_type = "apartment";
|
||||
break;
|
||||
case "business":
|
||||
$connection_type = "business";
|
||||
break;
|
||||
default:
|
||||
return mfResponse::BadRequest(["message" => "Invalid connectionType"]);
|
||||
}
|
||||
|
||||
|
||||
if(!array_key_exists("address", $this->post)) {
|
||||
return mfResponse::BadRequest(['message' => "address missing"]);
|
||||
}
|
||||
@@ -49,7 +71,9 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
return mfResponse::BadRequest(['message' => "customer data missing"]);
|
||||
}
|
||||
|
||||
// check address
|
||||
/*
|
||||
* check address
|
||||
*/
|
||||
if(!property_exists($this->post['address'],"street") || !$this->post['address']->street ||
|
||||
!property_exists($this->post['address'],"housenumber") || !$this->post['address']->housenumber ||
|
||||
!property_exists($this->post['address'],"zip") || !$this->post['address']->zip ||
|
||||
@@ -72,7 +96,9 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
}
|
||||
|
||||
// check customer
|
||||
/*
|
||||
* check customer
|
||||
*/
|
||||
$customer = $this->post['customer'];
|
||||
|
||||
if(!property_exists($customer,"firstname") || !$customer->firstname ||
|
||||
@@ -84,9 +110,9 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
return mfResponse::BadRequest(['message' => "Mandatory customer fields missing"]);
|
||||
}
|
||||
|
||||
|
||||
// search address in AddressDB
|
||||
|
||||
/*
|
||||
* search address in AddressDB
|
||||
*/
|
||||
foreach($address_search as $field => $value) {
|
||||
$where .= " AND `$field` = '$value'";
|
||||
}
|
||||
@@ -100,10 +126,10 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
|
||||
$address = $this->db()->fetch_object($res);
|
||||
|
||||
|
||||
|
||||
|
||||
// search wohneinheit
|
||||
|
||||
/*
|
||||
* search wohneinheit
|
||||
*/
|
||||
$unit = false;
|
||||
if(count($unit_search)) {
|
||||
foreach($unit_search as $field => $value) {
|
||||
@@ -128,11 +154,15 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
$unit = $this->db()->fetch_object($res);
|
||||
}
|
||||
}
|
||||
//var_dump($unit);exit;
|
||||
|
||||
/*
|
||||
* build fields
|
||||
*/
|
||||
$preorder_data = [];
|
||||
$preorder_data['preordercampaign_id'] = $this->campaign->id;
|
||||
$preorder_data['type'] = $type;
|
||||
$preorder_data['connection_type'] = $connection_type;
|
||||
$preorder_data['connection_count'] = (intval($this->post['connectionCount'])) ? intval($this->post['connectionCount']) : 1;
|
||||
$preorder_data['submit_type'] = "api";
|
||||
if($this->request_json) {
|
||||
$preorder_data['submit_request'] = $this->request_json;
|
||||
@@ -143,23 +173,52 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
$preorder_data['adb_wohneinheit_id'] = $unit->wohneinheit_id;
|
||||
}
|
||||
|
||||
if($this->post['acceptAgb'] === true) {
|
||||
$preorder_data['accept_agb'] = 1;
|
||||
}
|
||||
if($this->post['acceptDsgvo'] === true) {
|
||||
$preorder_data['accept_dsgvo'] = 1;
|
||||
}
|
||||
if($this->post['acceptMarketing'] === true) {
|
||||
$preorder_data['accept_marketing'] = 1;
|
||||
}
|
||||
if($this->post['acceptWithdrawal'] === true) {
|
||||
$preorder_data['accept_withdrawal'] = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* setup price
|
||||
*/
|
||||
$product = false;
|
||||
if($type == "provision") {
|
||||
$product = $this->campaign->setup_products['provision'][0];
|
||||
if($product) {
|
||||
$preorder_data['setup_product_id'] = $product->id;
|
||||
$preorder_data['price_setup'] = $product->price_setup;
|
||||
}
|
||||
}
|
||||
if($type == "order") {
|
||||
$product = $this->campaign->setup_products['activation'][0];
|
||||
if($product) {
|
||||
$preorder_data['setup_product_id'] = $product->id;
|
||||
$preorder_data['price_setup'] = $product->price_setup;
|
||||
}
|
||||
if($product) {
|
||||
$preorder_data['setup_product_id'] = $product->id;
|
||||
$preorder_data['price_setup'] = $product->price_setup;
|
||||
if($connection_type == "multi-dwelling") {
|
||||
if($preorder_data['connection_count'] == 2) {
|
||||
$preorder_data['price_setup'] = round($product->price_setup * 2 - (($product->price_setup * 2) / 100) * TT_PREORDER_DISCOUNT_2);
|
||||
}
|
||||
if($connection_type == "multi-dwelling" && $preorder_data['connection_count'] == 3) {
|
||||
$preorder_data['price_setup'] = round($product->price_setup * 3 - (($product->price_setup * 3) / 100) * TT_PREORDER_DISCOUNT_3);
|
||||
}
|
||||
}
|
||||
if($connection_type == "apartment" && $type == "order") {
|
||||
$preorder_data['price_setup'] = round($product->price_setup - (($product->price_setup) / 100) * TT_PREORDER_DISCOUNT_APART);
|
||||
}
|
||||
if($connection_type == "business") {
|
||||
$preorder_data['price_setup'] = round($product->price_setup - (($product->price_setup) / 100) * TT_PREORDER_DISCOUNT_BUSINESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* get customer data
|
||||
*/
|
||||
foreach(['company','uid','firstname','lastname','street','zip','city','phone','email'] as $key) {
|
||||
if(property_exists($customer, $key)) {
|
||||
$preorder_data[$key] = $customer->$key;
|
||||
@@ -167,9 +226,12 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* create preorder record
|
||||
*/
|
||||
$preorder = PreorderModel::create($preorder_data);
|
||||
$preorder->createUcode();
|
||||
//var_dump($preorder);exit;
|
||||
$preorder_id = $preorder->save();
|
||||
|
||||
if(!$preorder_id || !$preorder->ucode) {
|
||||
@@ -177,11 +239,6 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
}
|
||||
|
||||
return mfResponse::Ok(["code" => $preorder->ucode]);
|
||||
|
||||
var_dump($preorder);exit;
|
||||
|
||||
|
||||
var_dump($this->post);exit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,8 @@ class PreorderModel {
|
||||
public $adb_wohneinheit_id;
|
||||
public $building_id;
|
||||
public $termination_id;
|
||||
public $connection_type;
|
||||
public $connection_count;
|
||||
public $product_id;
|
||||
public $setup_product_id;
|
||||
public $type;
|
||||
@@ -18,6 +20,10 @@ class PreorderModel {
|
||||
public $billing_delay;
|
||||
public $billing_period;
|
||||
public $partner_id;
|
||||
public $accept_agb;
|
||||
public $accept_dsgvo;
|
||||
public $accept_marketing;
|
||||
public $accept_withdrawal;
|
||||
public $company;
|
||||
public $uid;
|
||||
public $firstname;
|
||||
|
||||
@@ -225,7 +225,7 @@ paths:
|
||||
| single-dwelling | Einfamilienhaus
|
||||
| multi-dwelling | Mehrfamilienhaus (bis 3 Wohneinheiten)
|
||||
| apartment-building | Mehrparteienhaus (ab 4 Wohneinheiten)
|
||||
| apartment-renter | Mieter in Mehrparteienhaus
|
||||
| apartment | Wohneinheit in Mehrparteienhaus
|
||||
| business | Gewerbebetrieb |
|
||||
operationId: submitPreorder
|
||||
requestBody:
|
||||
@@ -424,7 +424,15 @@ components:
|
||||
properties:
|
||||
connectionType:
|
||||
type: string
|
||||
enum: [einfamilienhaus, mehrfamilienhaus, mehrparteienhaus, mieter, business]
|
||||
enum: [single-dwelling, multi-dwelling, apartment-building, apartment, business]
|
||||
description: |
|
||||
|connectionType | description |
|
||||
|---------------|-------------|
|
||||
| single-dwelling | Einfamilienhaus
|
||||
| multi-dwelling | Mehrfamilienhaus (bis 3 Wohneinheiten)
|
||||
| apartment-building | Mehrparteienhaus (ab 4 Wohneinheiten)
|
||||
| apartment | Wohneinheit in Mehrparteienhaus
|
||||
| business | Gewerbebetrieb |
|
||||
connectionCount:
|
||||
type: int
|
||||
default: 1
|
||||
@@ -441,7 +449,6 @@ components:
|
||||
| interest | Interessensbekundung|
|
||||
| provision | Vorsorgeanschluss|
|
||||
| order | Vollanschluss|
|
||||
|
||||
acceptMarketing:
|
||||
type: boolean
|
||||
description: Zustimmung Datenspeicherung/-weitergabe
|
||||
|
||||
Reference in New Issue
Block a user