Preorder: Status can now be changed manually

This commit is contained in:
Frank Schubert
2023-11-07 13:00:29 +01:00
parent bd3489f6e4
commit 79fe0aa00e
18 changed files with 367 additions and 69 deletions
+23
View File
@@ -211,6 +211,8 @@ class Preorder extends mfBaseModel {
return $this->ucode;
}
private function generateNewUcode() {
$chars = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
$charsLength = strlen($chars);
@@ -221,6 +223,25 @@ class Preorder extends mfBaseModel {
return $ucode;
}
public function createCifCode() {
$cifcode = $this->generateNewCifcode();
while(PreorderModel::search(['cifcode' => $cifcode])) {
$cifcode = $this->generateNewCifcode();
}
$this->cifcode = $cifcode;
return $this->cifcode;
}
private function generateNewCifcode() {
$chars = '23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxzy';
$charsLength = strlen($chars);
$cifcode = '';
for ($i = 0; $i < 16; $i++) {
$cifcode .= $chars[rand(0, $charsLength - 1)];
}
return $cifcode;
}
public function getApiArray() {
if(!$this->id) {
return false;
@@ -233,6 +254,8 @@ class Preorder extends mfBaseModel {
$a = [];
$a['code'] = strtoupper($this->ucode);
$a['cifcode'] = $this->cifcode;
$a['cifurl'] = $this->cifurl;
$a['oaid'] = $this->oaid;
$a['extref'] = $this->extref;
$a['status'] = $this->getProperty("status")->getApiArray();