Merge branch 'fronkdev' into 'master'
Fixed preorder split ignoring original unit See merge request fronk/thetool!100
This commit is contained in:
@@ -18,6 +18,7 @@ define("INTERNAL_USER_USERNAME", $me->username);
|
|||||||
$ignore_preorders = [];
|
$ignore_preorders = [];
|
||||||
|
|
||||||
$campaign_prem_nord = 5;
|
$campaign_prem_nord = 5;
|
||||||
|
$campaign_prem_sued = 6;
|
||||||
$campaign_gross_st_florian = 7;
|
$campaign_gross_st_florian = 7;
|
||||||
$same_unit_count = 0;
|
$same_unit_count = 0;
|
||||||
|
|
||||||
@@ -26,7 +27,7 @@ $missing_doors = [];
|
|||||||
|
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$c = 0;
|
$c = 0;
|
||||||
foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaign_prem_nord, "connection_count" => 2]) as $preorder) {
|
foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaign_prem_nord, "connection_count" => 2, "adb_hausnummer_id" => 1898]) as $preorder) {
|
||||||
// check if we have enough units with extref
|
// check if we have enough units with extref
|
||||||
$wohneinheiten = ADBWohneinheitModel::search(["hausnummer_id" => $preorder->adb_hausnummer_id]);
|
$wohneinheiten = ADBWohneinheitModel::search(["hausnummer_id" => $preorder->adb_hausnummer_id]);
|
||||||
$unit_count = count($wohneinheiten);
|
$unit_count = count($wohneinheiten);
|
||||||
@@ -44,14 +45,14 @@ foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaig
|
|||||||
$available_units = [];
|
$available_units = [];
|
||||||
$additional_units = []; // to sort non-specific units last
|
$additional_units = []; // to sort non-specific units last
|
||||||
foreach($wohneinheiten as $unit) {
|
foreach($wohneinheiten as $unit) {
|
||||||
if(!PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id, "deleted" => 0])) {
|
if($preorder->adb_wohneinheit_id == $unit->id || !PreorderModel::getFirst(["adb_wohneinheit_id" => $unit->id, "deleted" => 0])) {
|
||||||
if($unit->tuer || preg_match('/^Top\s+\d+$/', $unit->zusatz)) {
|
if($unit->tuer || preg_match('/^Top\s+\d+$/', $unit->zusatz)) {
|
||||||
$available_units[] = $unit;
|
$available_units[] = $unit;
|
||||||
} else {
|
} else {
|
||||||
$additional_units[] = $unit;
|
$additional_units[] = $unit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo $preorder->id." balh\n";
|
//echo $preorder->id." balh\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +62,13 @@ foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaig
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
/*foreach($available_units as $au) {
|
||||||
|
echo "unit id: ".$au->id."\n";
|
||||||
|
echo "hausnummer ".$au->hausnummer_id." \n";
|
||||||
|
echo $au->extref."\n\n";
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
if($preorder->connection_count > count($available_units)) {
|
if($preorder->connection_count > count($available_units)) {
|
||||||
$md = [];
|
$md = [];
|
||||||
$md["unit_count"] = $unit_count;
|
$md["unit_count"] = $unit_count;
|
||||||
@@ -74,21 +82,31 @@ foreach(PreorderModel::search(["deleted" => 0, "preordercampaign_id" => $campaig
|
|||||||
// create new Preorders with available units
|
// create new Preorders with available units
|
||||||
// then set original Preorder deleted
|
// then set original Preorder deleted
|
||||||
echo "Creating ".$preorder->connection_count." new preorders\n";
|
echo "Creating ".$preorder->connection_count." new preorders\n";
|
||||||
for($i = 0; $i < $preorder->connection_count; $i++) {
|
|
||||||
if(!$available_units[$i]->oaid) {
|
for($c = 0; $c < $preorder->connection_count; $c++) {
|
||||||
$available_units[$i]->oaid = $available_units[$i]->getNewOAID();
|
if(!$available_units[$c]->oaid) {
|
||||||
$available_units[$i]->save();
|
$available_units[$c]->oaid = $available_units[$i]->getNewOAID();
|
||||||
|
$available_units[$c]->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
echo "unit id: ".$available_units[$c]->id."\n";
|
||||||
|
echo "hausnummer ".$available_units[$c]->hausnummer_id." \n";
|
||||||
|
echo $available_units[$c]->extref."\n\n";
|
||||||
|
*/
|
||||||
|
|
||||||
$new_preorder = clone($preorder);
|
$new_preorder = clone($preorder);
|
||||||
$new_preorder->ucode = $preorder->ucode.".".($i+1);
|
$new_preorder->ucode = $preorder->ucode.".".($c+1);
|
||||||
$new_preorder->connection_count = 1;
|
$new_preorder->connection_count = 1;
|
||||||
$new_preorder->adb_wohneinheit_id = $available_units[$i]->id;
|
$new_preorder->adb_wohneinheit_id = $available_units[$c]->id;
|
||||||
$new_preorder->oaid = $available_units[$i]->oaid;
|
$new_preorder->oaid = $available_units[$c]->oaid;
|
||||||
|
|
||||||
|
//var_dump($new_preorder);
|
||||||
|
|
||||||
$new_preorder->save();
|
$new_preorder->save();
|
||||||
}
|
}
|
||||||
|
//exit;
|
||||||
$preorder->deleted = 1;
|
$preorder->deleted = date("U");
|
||||||
$preorder->delete_reason = "connection_split";
|
$preorder->delete_reason = "connection_split";
|
||||||
$preorder->save();
|
$preorder->save();
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
Reference in New Issue
Block a user