Added banned FCPs to preordercampaign
This commit is contained in:
@@ -85,11 +85,30 @@ class AddressDB {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAllFcpNames($netzgebiet_id) {
|
||||
$fcps = [];
|
||||
if($netzgebiet_id) {
|
||||
$res = $this->db->query("SELECT rimo_fcp_name FROM `Hausnummer` WHERE netzgebiet_id=$netzgebiet_id GROUP BY rimo_fcp_name ORDER BY LENGTH(rimo_fcp_name), rimo_fcp_name");
|
||||
} else {
|
||||
$res = $this->db->query("SELECT rimo_fcp_name FROM `Hausnummer` WHERE GROUP BY rimo_fcp_name ORDER BY rimo_fcp_name");
|
||||
}
|
||||
if($this->db->num_rows($res)) {
|
||||
while($data = $this->db->fetch_object($res)) {
|
||||
if($data->rimo_fcp_name) {
|
||||
$fcps[] = $data->rimo_fcp_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fcps = array_unique($fcps);
|
||||
|
||||
return $fcps;
|
||||
}
|
||||
|
||||
/*
|
||||
* methods to create or update an Address from strings
|
||||
*/
|
||||
|
||||
public function createUpdateHausnummer($data) {
|
||||
$netzgebiet_id = 0;
|
||||
$netzgebiet = null;
|
||||
|
||||
@@ -12,7 +12,20 @@ class Preordercampaign extends mfBaseModel {
|
||||
private $corsorigins;
|
||||
private $total_homes;
|
||||
private $required_fields = [];
|
||||
private $banned_fcps;
|
||||
private $all_fcp_names;
|
||||
|
||||
public function getAllFcpNames() {
|
||||
if(!$this->id) return [];
|
||||
|
||||
$network = $this->getProperty("network");
|
||||
$netzgebiet_id = $network->adb_netzgebiet_id;
|
||||
if(!$netzgebiet_id) return [];
|
||||
|
||||
$addressdb = new AddressDB();
|
||||
$fcps = $addressdb->getAllFcpNames($netzgebiet_id);
|
||||
return $fcps;
|
||||
}
|
||||
|
||||
public function addTypes(Array $types) {
|
||||
$allowd_types = ["interest","provision","order","reorder"];
|
||||
@@ -151,6 +164,26 @@ class Preordercampaign extends mfBaseModel {
|
||||
return $this->salesclusters;
|
||||
}
|
||||
|
||||
if($name == "all_fcp_names") {
|
||||
$fcps = $this->getAllFcpNames();
|
||||
if($fcps) {
|
||||
$this->all_fcp_names = $fcps;
|
||||
} else {
|
||||
$this->all_fcp_names = [];
|
||||
}
|
||||
return $this->all_fcp_names;
|
||||
}
|
||||
|
||||
if($name == "banned_fcps") {
|
||||
$bfcp_json = $this->banned_rimo_fcp;
|
||||
$banned_fcp_array = json_decode($bfcp_json);
|
||||
if(!is_array($banned_fcp_array) || !$banned_fcp_array) {
|
||||
return [];
|
||||
}
|
||||
$this->banned_fcps = $banned_fcp_array;
|
||||
return $this->banned_fcps;
|
||||
}
|
||||
|
||||
if($name == "apiusers") {
|
||||
$items = PreordercampaignApiuserModel::search(["preordercampaign_id" => $this->id]);
|
||||
foreach($items as $poa) {
|
||||
|
||||
@@ -290,6 +290,18 @@ class PreordercampaignController extends mfBaseController {
|
||||
$data['exist_is_error'] = 0;
|
||||
}
|
||||
|
||||
//var_dump($r->banned_rimo_fcp);exit;
|
||||
if($r->banned_rimo_fcp && is_array($r->banned_rimo_fcp) && count($r->banned_rimo_fcp)) {
|
||||
$banned_fcp_json = json_encode($r->banned_rimo_fcp);
|
||||
if($banned_fcp_json) {
|
||||
$data["banned_rimo_fcp"] = $banned_fcp_json;
|
||||
} else {
|
||||
$data["banned_rimo_fcp"] = null;
|
||||
}
|
||||
} else {
|
||||
$data["banned_rimo_fcp"] = null;
|
||||
}
|
||||
|
||||
$data['edit_by'] = $this->me->id;
|
||||
|
||||
if($mode == "add") {
|
||||
|
||||
@@ -17,6 +17,7 @@ class PreordercampaignModel {
|
||||
public $exist_is_error;
|
||||
public $require_connectiontype;
|
||||
public $allow_unit_update;
|
||||
public $banned_rimo_fcp;
|
||||
public $note;
|
||||
|
||||
public $create_by;
|
||||
|
||||
Reference in New Issue
Block a user