Пример #1
0
 public function proc_upd()
 {
     if (system::issetUrl(2)) {
         $obj = new ormField();
         $obj->setGroupId(system::url(2));
     } else {
         if (system::action() == "proc_upd") {
             $obj = new ormField($_POST['obj_id']);
         } else {
             if (system::action() == "proc_add") {
                 $obj = new ormField();
                 $obj->setGroupId($_POST['obj_id']);
             }
         }
     }
     if (!empty($_POST['fname'])) {
         $obj->setName($_POST['fname']);
     }
     if (!empty($_POST['max_size'])) {
         $obj->setMaxSize($_POST['max_size']);
     } else {
         $obj->setMaxSize(0);
     }
     $obj->setType(0);
     $obj->setInherit(1);
     $obj_id = $obj->save();
     if ($obj_id === false) {
         echo json_encode(array('error' => 1, 'data' => $obj->getErrorListText(' ')));
     } else {
         $tree = new ormFieldsTree();
         $forUpd = system::action() == "proc_add" ? 0 : 1;
         echo json_encode(array('error' => 0, 'data' => $tree->getFieldHTML($obj, $forUpd)));
     }
     system::stop();
 }
Пример #2
0
 public function proc_upd()
 {
     if (system::action() == "proc_upd") {
         $obj = new ormField($_POST['obj_id']);
     } else {
         if (system::action() == "proc_add") {
             $obj = new ormField();
             $obj->setGroupId($_POST['obj_id']);
         }
     }
     $obj->setName(system::POST('fname'));
     $obj->setSName(system::POST('fsname'));
     $obj->setHint(system::POST('hint'));
     $obj->setType(system::POST('type'));
     $obj->setView(system::POST('view'));
     $obj->setSearch(system::POST('search'));
     $obj->setInherit(system::POST('inherit'));
     $obj->setFilter(system::POST('filter'));
     $obj->setRequired(system::POST('required'));
     $obj->setSystem(system::POST('system'));
     $obj->setUniqum(system::POST('uniqum'));
     $obj->setMaxSize(system::POST('max_size'));
     $obj->setQuickAdd(system::POST('quick_add'));
     $obj->setRelType(system::POST('reltype'));
     $obj->setSpec(system::POST('spec'));
     // Работа с привязанным справочником
     if (system::POST('type') == 95 || system::POST('type') == 90 || system::POST('type') == 97) {
         $list_id = system::POST('list_id');
         // Если не был указан справочник, то автоматически создаем новый
         if (empty($list_id)) {
             $class_name = 'list_' . system::POST('fsname', isVarName);
             if ($class = ormClasses::get($class_name)) {
                 $list_id = $class->id();
             } else {
                 $class = new ormClass();
                 $class->setParentId(29);
                 $class->setName('Для поля "' . system::POST('fname', isString) . '"');
                 $class->setSName($class_name);
                 $class->setSystem(0);
                 $class->setIsList(1);
                 $list_id = $class->save();
                 if ($list_id === false) {
                     $list_id = 0;
                 }
             }
         }
         $obj->setListId($list_id);
     } else {
         $obj->setListId(0);
     }
     $obj_id = $obj->save();
     if ($obj_id === false) {
         echo json_encode(array('error' => 1, 'data' => $obj->getErrorListText(' ')));
     } else {
         $tree = new ormFieldsTree();
         $forUpd = system::action() == "proc_add" ? 0 : 1;
         echo json_encode(array('error' => 0, 'data' => $tree->getFieldHTML($obj, $forUpd)));
     }
     system::stop();
 }