Commit bd92dea7 authored by Daiyrbek Artelov's avatar Daiyrbek Artelov
Browse files

Resolves #30

parent 315004de
......@@ -118,14 +118,6 @@ if (isset($_POST['data-property'])) {
$iaView->setMessages($messages, iaView::ERROR);
} else {
$autoApprovalEnabled = $iaCore->get('realestate_auto_approval');
if (empty($_POST['plan_id'])) {
$item[iaEstate::COLUMN_STATUS] = $autoApprovalEnabled ? iaEstate::STATUS_AVAILABLE : iaCore::STATUS_APPROVAL;
} elseif ($_POST['plan_id'] != $listing['sponsored_plan_id']) {
$item[iaEstate::COLUMN_STATUS] = iaCore::STATUS_APPROVAL;
}
if (iaCore::ACTION_ADD == $pageAction) {
$listingId = $iaEstate->insert($item);
$result = (bool)$listingId;
......@@ -133,12 +125,8 @@ if (isset($_POST['data-property'])) {
$resultMessage = (iaEstate::STATUS_AVAILABLE == $item[iaEstate::COLUMN_STATUS])
? iaLanguage::get('listing_successfully_submitted') : null;
} else {
if ($autoApprovalEnabled) {
if (isset($_POST['status']) && $listing[iaEstate::COLUMN_STATUS] != iaCore::STATUS_APPROVAL) {
$item[iaEstate::COLUMN_STATUS] = iaSanitize::sql($_POST['status']);
}
} else {
$item[iaEstate::COLUMN_STATUS] = iaCore::STATUS_APPROVAL;
if (isset($_POST['status']) && $listing['status'] != iaCore::STATUS_APPROVAL) {
$item['status'] = iaSanitize::sql($_POST['status']);
}
$result = $iaEstate->update($item, $listingId);
......@@ -178,36 +166,34 @@ if (isset($_POST['data-property'])) {
$sections = $iaField->getTabs($iaEstate->getItemName(), $listing);
if (iaCore::ACTION_EDIT == $pageAction) {
if ($listing['status'] != iaCore::STATUS_APPROVAL && $iaCore->get('realestate_auto_approval')) {
// field emulation
// TODO: refactor
$sections['common'][] = [
'collapsed' => false,
'name' => 'status',
'title' => iaLanguage::get('other'),
'description' => '',
'fields' => [
[
'item' => $iaEstate->getItemName(),
'title' => iaLanguage::get('status'),
'class' => 'fieldzone',
'default' => $listing[iaEstate::COLUMN_STATUS],
'for_plan' => 0,
'name' => iaEstate::COLUMN_STATUS,
'relation' => iaField::RELATION_REGULAR,
'required' => true,
'type' => iaField::COMBO,
'values' => [
iaEstate::STATUS_AVAILABLE => iaLanguage::get(iaEstate::STATUS_AVAILABLE),
iaEstate::STATUS_HIDDEN => iaLanguage::get(iaEstate::STATUS_HIDDEN),
iaEstate::STATUS_SOLD => iaLanguage::get(iaEstate::STATUS_SOLD),
iaEstate::STATUS_RENTED => iaLanguage::get(iaEstate::STATUS_RENTED)
]
if (iaCore::ACTION_EDIT == $pageAction && iaCore::STATUS_APPROVAL != $listing['status']) {
// field emulation
// TODO: refactor
$sections['common'][] = [
'collapsed' => false,
'name' => 'status',
'title' => iaLanguage::get('other'),
'description' => '',
'fields' => [
[
'item' => $iaEstate->getItemName(),
'title' => iaLanguage::get('status'),
'class' => 'fieldzone',
'default' => $listing[iaEstate::COLUMN_STATUS],
'for_plan' => 0,
'name' => iaEstate::COLUMN_STATUS,
'relation' => iaField::RELATION_REGULAR,
'required' => true,
'type' => iaField::COMBO,
'values' => [
iaEstate::STATUS_AVAILABLE => iaLanguage::get(iaEstate::STATUS_AVAILABLE),
iaEstate::STATUS_HIDDEN => iaLanguage::get(iaEstate::STATUS_HIDDEN),
iaEstate::STATUS_SOLD => iaLanguage::get(iaEstate::STATUS_SOLD),
iaEstate::STATUS_RENTED => iaLanguage::get(iaEstate::STATUS_RENTED)
]
]
];
}
]
];
}
$listing['parents'] = $iaLocation->getParentsFlat($listing[iaEstate::COLUMN_LOCATION]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment