Merge pull request #1887 from amitsharma322/gli-3196
Fixed: Allow selected property type after disabling it when editing a hotel in the back office
This commit is contained in:
@@ -57,6 +57,17 @@ class AdminHotelPropertyTypesController extends ModuleAdminController
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
$this->bulk_actions = array(
|
||||
'enableSelection' => array(
|
||||
'text' => $this->l('Enable selected'),
|
||||
'icon' => 'icon-power-off text-success',
|
||||
),
|
||||
'disableSelection' => array(
|
||||
'text' => $this->l('Disable selected'),
|
||||
'icon' => 'icon-power-off text-danger',
|
||||
),
|
||||
'divider' => array(
|
||||
'text' => 'divider',
|
||||
),
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'confirm' => $this->l('Delete selected items?'),
|
||||
@@ -157,6 +168,13 @@ class AdminHotelPropertyTypesController extends ModuleAdminController
|
||||
|
||||
$this->display = $idPropertyType ? 'edit' : 'add';
|
||||
|
||||
if (!$this->errors && !Tools::getValue('active') && $idPropertyType) {
|
||||
$objPropertyType = new HotelPropertyType((int) $idPropertyType);
|
||||
if (Validate::isLoadedObject($objPropertyType) && $objPropertyType->active && $objPropertyType->isUsed()) {
|
||||
$this->errors[] = $this->l('You cannot disable this property type because it is currently assigned to one or more properties.');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->errors) {
|
||||
parent::postProcess();
|
||||
}
|
||||
@@ -165,6 +183,34 @@ class AdminHotelPropertyTypesController extends ModuleAdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function processStatus()
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
if (Validate::isLoadedObject($object) && $object->active && $object->isUsed()) {
|
||||
$this->errors[] = $this->l('You cannot disable this property type because it is currently assigned to one or more properties.');
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return parent::processStatus();
|
||||
}
|
||||
|
||||
protected function processBulkDisableSelection()
|
||||
{
|
||||
if (is_array($this->boxes) && !empty($this->boxes)) {
|
||||
foreach ($this->boxes as $idPropertyType) {
|
||||
$object = new HotelPropertyType((int) $idPropertyType);
|
||||
if (Validate::isLoadedObject($object) && $object->isUsed()) {
|
||||
$this->errors[] = $this->l('You cannot disable this property type because it is currently assigned to one or more properties.');
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return parent::processBulkDisableSelection();
|
||||
}
|
||||
|
||||
public function processDelete()
|
||||
{
|
||||
$object = $this->loadObject();
|
||||
|
||||
Reference in New Issue
Block a user