Added customer_number and serice pin

This commit is contained in:
Frank Schubert
2021-08-26 20:33:00 +02:00
parent df127c08d9
commit d77642f9de
9 changed files with 96 additions and 6 deletions

View File

@@ -42,6 +42,12 @@
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="customer_number">Kundennummer</label>
<div class="col-lg-10">
<input type="text" class="form-control" name="customer_number" id="customer_number" value="<?=$address->customer_number?>" disabled="disabled" />
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="company">Firmenname</label>
<div class="col-lg-10">
@@ -114,6 +120,17 @@
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="spin">Service PIN</label>
<div class="col-lg-10">
<input type="spin" class="form-control" name="spin" id="spin" value="<?=$address->spin?>" disabled="disabled">
</div>
</div>
</div>
</div>
<div class="card">
<div class="card-body">
<div class="form-group row">

View File

@@ -51,6 +51,7 @@
<table class="table table-striped table-hover">
<tr>
<th>Typ</th>
<th>Kundennummer</th>
<th>Firma</th>
<th>Name</th>
<th>Adresse</th>
@@ -60,7 +61,22 @@
</tr>
<?php foreach($addresses as $address): ?>
<tr>
<td></td>
<?php if(is_array($address->types)):?>
<?php
$types = array_keys($address->types);
$l7d_types = [];
foreach($types as $type):
$l7d_types[] = __($type);
endforeach;
?>
<td title="<?=implode(", ", $l7d_types)?>">
<?=$l7d_types[0]?><?=(count($types)) ? ", ..." : ""?>
</td>
<?php endif; ?>
<td>
<?=$address->customer_number?>
<?=($address->spin) ? "<br /><span class='text-pink'>".$address->spin."</span>" : ""?>
</td>
<td><?=nl2br($address->company)?></td>
<td><?=$address->getFullName()?></td>
<td>

View File

@@ -52,7 +52,10 @@
<?php endif; ?>
<?php endif; ?>
</td>
<td><?=nl2br($order->owner->getCompanyOrName())?></td>
<td>
<?=nl2br($order->owner->getCompanyOrName())?>
<?=($order->owner->spin) ? "<br /><span class='text-pink'>".$order->owner->spin."</span>" : ""?>
</td>
<td>
<?=$order->owner->street?><br />
<?=$order->owner->zip?> <?=$order->owner->city?>

View File

@@ -1 +1 @@
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>" value="<?=$item->value->value_string?>">
<input type="text" class="form-control" name="wfitem_<?=$item->name?>_<?=$building->id?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>">

View File

@@ -1 +1 @@
<input type="text" class="form-control" name="wfitem_<?=$item->name?>" id="wfitem_<?=$item->name?>" value="<?=$item->value->value_string?>" placeholder="<?=$item->placeholder?>">
<input type="text" class="form-control" name="wfitem_<?=$item->name?>_<?=$building->id?>" id="wfitem_<?=$item->name?>_<?=$building->id?>" value="<?=$item->value->value_string?>" placeholder="<?=$item->placeholder?>">

View File

@@ -51,6 +51,20 @@ class Address extends mfBaseModel {
}
public function generateServicePin() {
if(!$this->customer_number) {
return false;
}
$num1 = rand(65, 90);
$num2 = rand(65, 90);
$c1 = chr($num1);
$c2 = chr($num2);
$spin = $c1.$c2.$this->customer_number;
return $spin;
}
public function getProperty($name) {
if($this->$name == null) {

View File

@@ -2,6 +2,8 @@
class AddressModel {
public $parent_id = null;
public $customer_number = null;
public $spin = null;
public $company = null;
public $firstname = null;
public $lastname = null;
@@ -76,6 +78,17 @@ class AddressModel {
}
public static function getLastCustomerNumber() {
$db = FronkDB::singleton();
$res = $db->select("Addres","customer_number", "customer_number > 0 ORDER BY customer_number DESC LIMIT 1");
if(!$db->num_rows($res)) {
return false;
}
$data = $db->num_rows($res);
return $data->customer_number;
}
public static function byNetwork($network_id, $addresstype) {
if(!is_numeric($network_id) || !$network_id) {
return false;

View File

@@ -21,7 +21,10 @@ class DashboardController extends mfBaseController {
var_dump($b->getNewObjectCode());exit;
*/
$address = AddressModel::getOne(5);
var_dump($address->types);exit;
/*$address = AddressModel::getOne(5);
var_dump($address->types);exit;*/
$a = new Address(1);
var_dump($a->generateServicePin());exit;
}
}

View File

@@ -359,6 +359,30 @@ class OrderController extends mfBaseController {
$this->log->warn("Unable to save OrderProduct:".print_r($product, true));
}
// if product is not external and customer is new, create customer_number and service pin
if(!$prod->external ) {
if(!$owner->customer_number) {
$last_num = AddressModel::getLastCustomerNumber();
if($last_num) {
$new_num = $last_num + 1;
} else {
$new_num = TT_FIRST_CUSTNUM;
}
$owner->customer_number = $new_num;
$owner->save();
}
if(!$owner->spin) {
$spin = $owner->generateServicePin();
if($spin) {
$owner->spin = $spin;
$owner->save();
}
}
}
}
}