} elseif (isset($_POST['action'])) {
         if ('edit' === $_POST['action'] && isset($_POST['city']) && is_array($_POST['city']) && !empty($_POST['city'])) {
             $arrActRegions['edit'] = true;
             // инициируем "Наименование страницы" отображаемое в форме
             $arrNamePage = array(array('name' => MENU_ADMIN_MAIN, 'link' => CONF_ADMIN_FILE), array('name' => MENU_DICTIONARY_REGIONS, 'link' => CONF_ADMIN_FILE . '?m=dictionary&s=regions'), array('name' => $region[$pid]['name'], 'link' => CONF_ADMIN_FILE . '?m=dictionary&s=regions&action=citys&pid=' . $pid), array('name' => FORM_ACTION_EDIT, 'link' => false));
             $smarty->assign('arrCitys', $citys->retCategorysByIds(array_keys($_POST['city'])));
             if (isset($_POST['save_citys'])) {
                 // проверяем на пустоту, поля обязательные для заполнения
                 foreach ($_POST['city'] as $value) {
                     if (!validate::arrDataNotEmpty($value['arrBindFields'])) {
                         $arrErrors[] = ERROR_EMPTY_NAME;
                         break;
                     }
                 }
                 isset($_POST['capital_city']) ? $_POST['city']['capital_city'] = $_POST['capital_city'] : null;
                 empty($arrErrors) ? $citys->actionCitys($_POST['action'], $_POST['city'], $region[$pid]['id']) : null;
             }
         } elseif ('setcapital' === $_POST['action'] && isset($_POST['capital_city']) && !empty($_POST['capital_city'])) {
             $citys->actionCitys($_POST['action'], array($_POST['capital_city']), $region[$pid]['id']);
         } elseif ('resetcapital' === $_POST['action']) {
             $citys->actionCitys($_POST['action'], array($region[$pid]['id']), $region[$pid]['id']);
         } elseif ('del' === $_POST['action'] && isset($_POST['city']) && is_array($_POST['city']) && !empty($_POST['city'])) {
             $citys->actionCitys($_POST['action'], array_keys($_POST['city']), $region[$pid]['id']);
         } else {
             messages::messageChangeSaved(MESSAGE_WARNING_UNKNOWN_ACTION, false, CONF_ADMIN_FILE . '?m=dictionary&s=regions&action=citys&pid=' . $pid);
         }
     }
     // END групповые действия с Городами - Редактирование/Сортировка/Удаление
 } else {
     messages::messageChangeSaved(ERROR_SECTION_NOT_EXISTS, false, CONF_ADMIN_FILE . '?m=dictionary&s=regions');
 }
예제 #2
0
} else {
    if (!empty($_POST['do'])) {
        // переключение Региона в статус "Регион-Город"
        if ('setRegionMajor' == $_POST['do'] && !empty($_POST['rid'])) {
            $force = isset($_POST['force']) ? true : false;
            /**
             * инициализация списка регионов
             */
            $regions = new regions();
            $arrDataRegions = $regions->retCategorys();
            if (!empty($arrDataRegions[$_POST['rid']])) {
                $arrFields = array($_POST['rid']);
                $citys = new citys();
                if ($force) {
                    $listCitys = $citys->retCategorysByParentIds($_POST['rid']);
                    if (is_array($listCitys) && $citys->actionCitys('del', array_keys($listCitys), $_POST['rid'], true)) {
                        if ($regions->actionRegions('setRegionMajor', $arrFields, true)) {
                            echo ajax::sdgJSONencode(array('success' => true));
                        } else {
                            echo ajax::sdgJSONencode(array('error' => 'errRegionSetMajor'));
                        }
                    } else {
                        echo ajax::sdgJSONencode(array('error' => 'errRegionDeleteChildRecords'));
                    }
                } else {
                    if ($citys->retCategorysByParentIds($_POST['rid'])) {
                        echo ajax::sdgJSONencode(array('error' => 'errRegionHasChildRecords'));
                    } else {
                        if ($regions->actionRegions('setRegionMajor', $arrFields, true)) {
                            echo ajax::sdgJSONencode(array('success' => true));
                        } else {