preorderaddressreporting permission; preorder split script updated

This commit is contained in:
Frank Schubert
2023-05-31 15:57:28 +02:00
parent 81837986c4
commit 7216b3339d
10 changed files with 201 additions and 186 deletions

View File

@@ -2,7 +2,7 @@
<?php
//require 'vendor/autoload.php';
require("../config/config.php");
require("../../config/config.php");
define('FRONKDB_SQLDEBUG',false);
error_reporting(E_ALL & ~(E_NOTICE | E_STRICT | E_DEPRECATED));
@@ -38,16 +38,28 @@ foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaig
continue;
}
$available_units = [];
//if($preorder->id == 920) {var_dump($wohneinheiten);exit;}
$available_units = [];
$additional_units = []; // to sort non-specific units last
foreach($wohneinheiten as $unit) {
if(!PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id])) {
if(!PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id, "deleted" => 0])) {
if($unit->tuer || preg_match('/^Top\s+\d+$/', $unit->zusatz)) {
$available_units[] = $unit;
} else {
$additional_units[] = $unit;
}
} else {
echo $preorder->id." balh\n";
}
}
if(count($additional_units)) $available_units = array_merge($available_units, $additional_units);
/*if($preorder->id == 2441) {
var_dump($available_units);exit;
}*/
if($preorder->connection_count > count($available_units)) {
$md = [];
$md["unit_count"] = $unit_count;
@@ -72,7 +84,6 @@ foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaig
$new_preorder->connection_count = 1;
$new_preorder->adb_wohneinheit_id = $available_units[$i]->id;
$new_preorder->oaid = $available_units[$i]->oaid;
//var_dump($new_preorder);exit;
$new_preorder->save();
}