WIP PreorderProduct

This commit is contained in:
Frank Schubert
2025-02-17 13:39:04 +01:00
parent 5125d16dae
commit 2c67a78ece
3 changed files with 498 additions and 0 deletions

View File

@@ -0,0 +1,180 @@
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/menu.php"); ?>
<div class="container">
<h1 class="mt-5">Preorder Product Management</h1>
<h2 class="mt-4">Create Preorder</h2>
<form id="createPreorderForm" class="mb-4">
<div class="form-group">
<label for="rimo_service_id">Rimo Service ID:</label>
<input type="number" class="form-control" id="rimo_service_id" name="rimo_service_id">
</div>
<button type="submit" class="btn btn-primary">Create Preorder</button>
</form>
<h2 class="mt-4">Create Preorder Product</h2>
<form id="createPreorderProductForm" class="mb-4">
<div class="form-group">
<label for="type">Type:</label>
<select class="form-control" id="type" name="type">
<option value="enduser_setup">Enduser Setup</option>
<option value="provider_setup">Provider Setup</option>
<option value="provider_usage">Provider Usage</option>
</select>
</div>
<div class="form-group">
<label for="name">Name:</label>
<input type="text" class="form-control" id="name" name="name">
</div>
<div class="form-group">
<label for="vatgroup_id">VAT Group ID:</label>
<input type="number" class="form-control" id="vatgroup_id" name="vatgroup_id">
</div>
<div class="form-group">
<label for="price_inet">Price Inet:</label>
<input type="number" step="0.0001" class="form-control" id="price_inet" name="price_inet">
</div>
<div class="form-group">
<label for="price_inet_tv">Price Inet TV:</label>
<input type="number" step="0.0001" class="form-control" id="price_inet_tv" name="price_inet_tv">
</div>
<div class="form-group">
<label for="price_catv">Price CATV:</label>
<input type="number" step="0.0001" class="form-control" id="price_catv" name="price_catv">
</div>
<div class="form-group">
<label for="price_passive">Price Passive:</label>
<input type="number" step="0.0001" class="form-control" id="price_passive" name="price_passive">
</div>
<div class="form-group">
<label for="create_by">Created By:</label>
<input type="number" class="form-control" id="create_by" name="create_by">
</div>
<div class="form-group">
<label for="edit_by">Edited By:</label>
<input type="number" class="form-control" id="edit_by" name="edit_by">
</div>
<button type="submit" class="btn btn-primary">Create Preorder Product</button>
</form>
<h2 class="mt-4">Create Preorder Product Price</h2>
<form id="createPreorderProductPriceForm" class="mb-4">
<div class="form-group">
<label for="preorderproduct_id">Preorder Product ID:</label>
<input type="number" class="form-control" id="preorderproduct_id" name="preorderproduct_id">
</div>
<div class="form-group">
<label for="netowner_id">Netowner ID:</label>
<input type="number" class="form-control" id="netowner_id" name="netowner_id">
</div>
<div class="form-group">
<label for="preordercampaign_id">Preorder Campaign ID:</label>
<input type="number" class="form-control" id="preordercampaign_id" name="preordercampaign_id">
</div>
<div class="form-group">
<label for="description">Description:</label>
<textarea class="form-control" id="description" name="description"></textarea>
</div>
<div class="form-group">
<label for="start_date">Start Date:</label>
<input type="date" class="form-control" id="start_date" name="start_date">
</div>
<div class="form-group">
<label for="end_date">End Date:</label>
<input type="date" class="form-control" id="end_date" name="end_date">
</div>
<div class="form-group">
<label for="price_inet">Price Inet:</label>
<input type="number" step="0.0001" class="form-control" id="price_inet" name="price_inet">
</div>
<div class="form-group">
<label for="price_inet_tv">Price Inet TV:</label>
<input type="number" step="0.0001" class="form-control" id="price_inet_tv" name="price_inet_tv">
</div>
<div class="form-group">
<label for="price_catv">Price CATV:</label>
<input type="number" step="0.0001" class="form-control" id="price_catv" name="price_catv">
</div>
<div class="form-group">
<label for="price_passive">Price Passive:</label>
<input type="number" step="0.0001" class="form-control" id="price_passive" name="price_passive">
</div>
<div class="form-group">
<label for="billing_delay">Billing Delay:</label>
<input type="number" class="form-control" id="billing_delay" name="billing_delay">
</div>
<div class="form-group">
<label for="billing_period">Billing Period:</label>
<input type="number" class="form-control" id="billing_period" name="billing_period">
</div>
<div class="form-group">
<label for="contract_term">Contract Term:</label>
<input type="number" class="form-control" id="contract_term" name="contract_term">
</div>
<div class="form-group">
<label for="note">Note:</label>
<textarea class="form-control" id="note" name="note"></textarea>
</div>
<div class="form-group">
<label for="create_by">Created By:</label>
<input type="number" class="form-control" id="create_by" name="create_by">
</div>
<div class="form-group">
<label for="edit_by">Edited By:</label>
<input type="number" class="form-control" id="edit_by" name="edit_by">
</div>
<button type="submit" class="btn btn-primary">Create Preorder Product Price</button>
</form>
<h2 class="mt-4">Create Preorder Product Marketshare Discount</h2>
<form id="createPreorderProductMarketshareDiscountForm" class="mb-4">
<div class="form-group">
<label for="preorderproductprice_id">Preorder Product Price ID:</label>
<input type="number" class="form-control" id="preorderproductprice_id" name="preorderproductprice_id">
</div>
<div class="form-group">
<label for="price_15">Price 15%:</label>
<input type="number" step="0.0001" class="form-control" id="price_15" name="price_15">
</div>
<div class="form-group">
<label for="price_20">Price 20%:</label>
<input type="number" step="0.0001" class="form-control" id="price_20" name="price_20">
</div>
<div class="form-group">
<label for="price_25">Price 25%:</label>
<input type="number" step="0.0001" class="form-control" id="price_25" name="price_25">
</div>
<div class="form-group">
<label for="price_30">Price 30%:</label>
<input type="number" step="0.0001" class="form-control" id="price_30" name="price_30">
</div>
<div class="form-group">
<label for="price_35">Price 35%:</label>
<input type="number" step="0.0001" class="form-control" id="price_35" name="price_35">
</div>
<div class="form-group">
<label for="price_40">Price 40%:</label>
<input type="number" step="0.0001" class="form-control" id="price_40" name="price_40">
</div>
<div class="form-group">
<label for="price_45">Price 45%:</label>
<input type="number" step="0.0001" class="form-control" id="price_45" name="price_45">
</div>
<div class="form-group">
<label for="price_50">Price 50%:</label>
<input type="number" step="0.0001" class="form-control" id="price_50" name="price_50">
</div>
<div class="form-group">
<label for="create_by">Created By:</label>
<input type="number" class="form-control" id="create_by" name="create_by">
</div>
<div class="form-group">
<label for="edit_by">Edited By:</label>
<input type="number" class="form-control" id="edit_by" name="edit_by">
</div>
<button type="submit" class="btn btn-primary">Create Preorder Product Marketshare Discount</button>
</form>
</div>
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>

View File

@@ -0,0 +1,296 @@
<?php
class PreorderProduct extends mfBaseModel {
private $preorder;
private $createor;
private $editor;
public function getProperty($name) {
if($this->$name == null) {
if($name == "preorder") {
$preorder = PreorderModel::getFirst(["id" => $this->preorder_id]);
if(!$preorder) {
$this->log->debug(__METHOD__ . ": Preorder " . $this->preorder_id . " not found");
return null;
}
$this->preorder = $preorder;
return $this->preorder;
}
if($name == "creator") {
$creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
if($creator) {
$this->creator = $creator;
return $this->creator;
}
$this->creator = new User($this->create_by);
if(!$this->creator->id) {
return null;
}
mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator);
return $this->creator;
}
if($name == "editor") {
$editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by);
if($editor) {
$this->editor = $editor;
return $this->editor;
}
$this->editor = new User($this->edit_by);
if(!$this->editor->id) {
return null;
}
mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor);
return $this->editor;
}
if($name == "product") {
$product = ProductModel::getFirst(["id" => $this->product_id]);
if(!$product) {
$this->log->debug(__METHOD__ . ": Product " . $this->product_id . " not found");
return null;
}
$this->product = $product;
return $this->product;
}
}
return parent::getProperty($name);
}
/********************************
* Begin static Model functions
*/
public static function create(Array $data) {
$model = new ConstructionConsent();
$table_fields = [
"type", "name", "vatgroup_id", "price", "price_setup",
"create_by","edit_by","create","edit"
];
foreach($data as $field => $value) {
if(in_array($field, $table_fields)) {
$model->$field = $value;
}
}
$me = new User();
$me->loadMe();
if($model->create_by === null) {
$model->create_by = $me->id;
}
if($model->edit_by === null) {
$model->edit_by = $me->id;
}
return $model;
}
public static function getAll() {
$items = [];
$db = FronkDB::singleton();
$res = $db->select("ConstructionConsent", "*", "1 = 1 ORDER BY adb_hausnummer_id");
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[] = new ConstructionConsent($data);
}
}
return $items;
}
public static function getFirst($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT * FROM ConstructionConsent
WHERE $where
ORDER BY adb_hausnummer_id LIMIT 1";
//var_dump($sql);exit;
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new ConstructionConsent($data);
if($item->id) {
return $item;
} else {
return null;
}
}
return null;
}
public static function count($filter) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT COUNT(*) as cnt FROM ConstructionConsent
LEFT JOIN ".ADDRESSDB_DBNAME.".view_hausnummer ON (ConstructionConsent.adb_hausnummer_id = view_hausnummer.hausnummer_id)
WHERE $where";
//mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
return $data->cnt;
}
return 0;
}
public static function search($filter, $limit = false, $order = false) {
//var_dump($filter);exit;
$items = [];
if(!$order) {
$order = "adb_hausnummer_id ASC";
}
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
$sql = "SELECT * FROM ConstructionConsent
LEFT JOIN ".ADDRESSDB_DBNAME.".view_hausnummer ON (ConstructionConsent.adb_hausnummer_id = view_hausnummer.hausnummer_id)
WHERE $where
ORDER BY $order";
if(is_array($limit) && count($limit)) {
if(is_numeric($limit['start']) && is_numeric($limit['count'])) {
$sql .= " LIMIT ".$limit['start'].", ".$limit['count'];
} elseif(is_numeric($limit['count'])) {
$sql .= " LIMIT ".$limit['count'];
}
}
mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {
$items[$data->id] = new ConstructionConsent($data);
}
}
return $items;
}
private static function getSqlFilter($filter) {
$where = "1=1 ";
if(array_key_exists("project_id", $filter)) {
$project_id = $filter['project_id'];
if(is_numeric($project_id)) {
$where .= " AND ConstructionConsent.constructionconsentproject_id=$project_id";
}
}
if(array_key_exists("constructionconsentproject_id", $filter)) {
$constructionconsentproject_id = $filter['constructionconsentproject_id'];
if(is_numeric($constructionconsentproject_id)) {
$where .= " AND ConstructionConsent.constructionconsentproject_id=$constructionconsentproject_id";
}
}
if(array_key_exists("adb_wohneinheit_id", $filter)) {
$adb_wohneinheit_id = $filter['adb_wohneinheit_id'];
if(is_numeric($adb_wohneinheit_id)) {
$where .= " AND ConstructionConsent.adb_wohneinheit_id=$adb_wohneinheit_id";
}
}
if(array_key_exists("termination_id", $filter)) {
$termination_id = $filter['termination_id'];
if(is_numeric($termination_id)) {
$where .= " AND ConstructionConsent.termination_id=$termination_id";
}
}
if(array_key_exists("object_type", $filter)) {
$object_type = FronkDB::singleton()->escape($filter["object_type"]);
if($object_type) {
$where .= " AND object_type='$object_type'";
}
}
if(array_key_exists("ez", $filter)) {
$ez = FronkDB::singleton()->escape($filter["ez"]);
if($ez) {
$where .= " AND ez='$ez'";
}
}
if(array_key_exists("status", $filter)) {
$status = FronkDB::singleton()->escape($filter["status"]);
if($status) {
$where .= " AND status='$status'";
}
}
if(array_key_exists("result", $filter)) {
$result = FronkDB::singleton()->escape($filter["result"]);
if($result) {
$where .= " AND result='$result'";
}
}
if(array_key_exists("owner_name", $filter)) {
$owner_name = FronkDB::singleton()->escape($filter["owner_name"]);
if($owner_name) {
$where .= " AND owner_name like '%$owner_name%'";
}
}
if(array_key_exists("owner_street", $filter)) {
$owner_street = FronkDB::singleton()->escape($filter["owner_street"]);
if($owner_street) {
$where .= " AND owner_street like '%$owner_street%'";
}
}
if(array_key_exists("owner_zip", $filter)) {
$owner_zip = FronkDB::singleton()->escape($filter["owner_zip"]);
if($owner_zip) {
$where .= " AND owner_zip like '%$owner_zip%'";
}
}
if(array_key_exists("owner_city", $filter)) {
$owner_city = FronkDB::singleton()->escape($filter["owner_city"]);
if($owner_city) {
$where .= " AND owner_city like '%$owner_city%'";
}
}
if(array_key_exists("owner_country", $filter)) {
$owner_country = FronkDB::singleton()->escape($filter["owner_country"]);
if($owner_country) {
$where .= " AND owner_country like '%$owner_country%'";
}
}
if(array_key_exists("network", $filter)) {
$network = FronkDB::singleton()->escape($filter["network"]);
if($network) {
$where .= " AND view_hausnummer.netzgebiet_id=$network";
}
}
if(array_key_exists("add-where", $filter)) {
$where .= " ".$filter['add-where'];
}
//var_dump($filter, $where);exit;
return $where;
}
}

View File

@@ -0,0 +1,22 @@
<?php
class PreorderProductController extends mfBaseController {
protected function init() {
$this->needlogin=true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me",$me);
if(!$me->is(["Admin", "netowner", "salespartner"]) && !$me->can("Preorder")) {
$this->redirect("Dashboard");
}
}
protected function indexAction() {
$this->layout()->setTemplate("PreorderProduct/Index");
//$product =
}
}