Exemplo n.º 1
0
 public function defAction()
 {
     if (!system::issetUrl(2)) {
         system::redirect('/reference');
     }
     if ($class = ormClasses::get(system::url(2))) {
         if (!$class->isInheritor('handbook') || $class->getSName() == 'handbook') {
             system::redirect('/reference');
         }
         ui::setNaviBar(lang::right('values'));
         ui::setHeader($class->getName());
         ui::setBackButton('/reference');
         if (user::issetRight('val_upd')) {
             $count = 0;
             $fields = $class->loadFields();
             foreach ($fields as $field) {
                 if ($field['f_view'] == 1) {
                     $count++;
                 }
             }
         } else {
             $count = 4;
         }
         $sel = new ormSelect($class->getSName());
         if ($count > 5) {
             ui::newButton(lang::get('BTN_NEW_LIST'), '/reference/val_add/' . system::url(2));
             $table = new uiTable($sel);
             $table->showSearch(true);
             $table->addColumn('name', 'Имя объекта');
             $table->addColumn('id', '#', 200);
             $table->defaultRight('val_upd');
             $table->addRight('val_upd', 'edit', single);
             $table->addRight('val_del', 'drop', multi);
             return $table->getHTML();
         } else {
             ui::newButton(lang::get('BTN_SAVE'), "javascript:sendForm('save');");
             ui::newButton(lang::get('BTN_APPLY'), "javascript:sendForm('apply');");
             $form = new ormMultiForm('change');
             $form->setData($sel);
             $form->showColumnID();
             $form->setRight('val_proc_upd');
             $form->moreParam(system::url(2));
             if (!user::issetRight('val_upd') || !user::issetRight('val_add')) {
                 $form->withoutAdditions();
             }
             if (!user::issetRight('val_del')) {
                 $form->withoutRemoving();
             }
             return $form->getHTML();
         }
     } else {
         system::redirect('/reference');
     }
 }
Exemplo n.º 2
0
 public function defAction()
 {
     if (!system::issetUrl(2)) {
         system::redirect('/constructor');
     }
     $class = ormClasses::get(system::url(2));
     if (!$class->isInheritor('handbook') || $class->getSName() == 'handbook') {
         system::redirect('/constructor');
     }
     ui::setHeader(lang::get('CONSTR_LIST') . '"' . $class->getName() . '"');
     ui::setBackButton('/constructor');
     $count = 0;
     $fields = $class->loadFields();
     while (list($key, $field) = each($fields)) {
         if ($field['f_view'] == 1) {
             $count++;
         }
     }
     $sel = new ormSelect($class->getSName());
     if ($count > 3) {
         ui::newButton(lang::get('BTN_NEW_LIST'), '/constructor/list_add/' . system::url(2));
         //$objects = ormObjects::getObjectsByClass(system::url(2));
         $table = new uiTable($sel);
         $table->showSearch(true);
         $table->addColumn('name', 'Имя объекта');
         $table->defaultRight('list_upd');
         $table->addRight('list_upd', 'edit', single);
         $table->addRight('list_del', 'drop', multi);
         return $table->getHTML();
     } else {
         ui::newButton(lang::get('BTN_SAVE'), "javascript:sendForm('save');");
         ui::newButton(lang::get('BTN_APPLY'), "javascript:sendForm('apply');");
         $form = new ormMultiForm('change');
         $form->setData($sel);
         $form->setRight('list_proc_upd');
         $form->moreParam(system::url(2));
         /*
         	       // $form->addColumn('name', '', 150, '', 0);
         	       // $form->addColumn('nositeli', '', 120, '', 0);
                     $form->addColumn('e_mail', '', 200, 'правпы', 1);
                     $form->addColumn('spiska', '', 150, '', 1);
                     $form->addColumn('url', '', 150, '', 1);
         
                     function email($val, $obj){
         	return '<a href="mailto:'.$val.'">'.$val.'</a>';
                     }
         */
         //$form->withoutAdditions();
         //$form->withoutRemoving();
         return $form->getHTML();
     }
Exemplo n.º 3
0
 function view()
 {
     // Устанавливаем кнопки для формы
     ui::setCancelButton('/eshop/list');
     ui::newButton(lang::get('BTN_SAVE'), "javascript:sendForm('save');");
     ui::newButton(lang::get('BTN_APPLY'), "javascript:sendForm('apply');");
     if (file_exists(MODUL_DIR . '/eshop/template/order.tpl')) {
         include MODUL_DIR . '/eshop/template/order.tpl';
     }
     if (!($obj = ormObjects::get(system::url(2), 'eshop_order'))) {
         system::redirect('/eshop/list');
     }
     $order = new eShopOrder($obj);
     // Вывод информации о товарах
     function getGoodsName($val, $obj)
     {
         if ($obj = ormPages::get($val, 'goods')) {
             return '<a href="' . $obj->url . '" target="_blank">' . $obj->name . '</a>';
         }
     }
     function getPrice($val, $obj)
     {
         return '&nbsp;&nbsp;&nbsp;&nbsp;' . $obj->cost * $obj->count . ' руб.';
     }
     $sel = new ormSelect('eshop_goods');
     $sel->where('parents', '=', $obj->id);
     $table = new ormMultiForm('goods');
     $table->setData($sel);
     $table->insideForm();
     $table->addColumn('goods_id', 0, 400, 0, false, 'getGoodsName');
     $table->addColumn('cost', 0, 100, 0, false);
     $table->addColumn('count', 0, 100);
     $table->addColumn('id', 'Общая стоимость', 100, 0, false, 'getPrice');
     $table->withoutAdditions();
     page::assign('goods_list', $table->getHTML());
     page::assign('order.number', $order->getNumber());
     page::assign('order.cost', $order->getCost());
     page::assign('order.cost_all', $order->getTotalCost());
     page::assign('order.delivery_price', $order->getDeliveryPrice());
     page::assign('order.delivery', $order->_delivery);
     $obj->parseAllFields();
     page::assign('obj.id', $order->id);
     page::assign('obj.date', date('d.m.Y в H:i', strtotime($obj->date)));
     page::assign('user_link', '/mpanel/users/user_upd/' . $order->getUserId());
     ui::SelectBox('state', ormObjects::getObjectsByClass('eshop_status'), $obj->state, 200);
     ui::CheckBox('is_payment', 1, $obj->is_payment, 'Оплачено');
     // Создаем форму и выводим ее на страницу
     // $form = new ormEditForm($obj, $right);
     //return $form->getHTML();
     return page::parse($TEMPLATE['frame']);
 }
Exemplo n.º 4
0
    private function parseField($field, $TEMPLATE)
    {
        if (in_array($field['f_sname'], $this->read_only)) {
            $value = $this->obj->__get($field['f_sname']);
            page::assign('value', $value);
            if ($field['f_type'] == 90 || $field['f_type'] == 95 || $field['f_type'] == 105) {
                page::assign('val', $this->obj->__get('_' . $field['f_sname']));
            } else {
                page::assign('val', $value);
            }
            $value = page::parse($TEMPLATE['read_only']);
            page::assign('content', $value);
            return page::parse($TEMPLATE['field_standart']);
        }
        // Определяем значение поля
        if (isset($_SESSION['SAVING_POST']) && ($field['f_type'] < 70 || $field['f_type'] > 85) && isset($_SESSION['SAVING_POST'][$field['f_sname']])) {
            $value = $_SESSION['SAVING_POST'][$field['f_sname']];
        } else {
            if ($field['f_type'] == 105) {
                $value = $this->obj->__get('_' . $field['f_sname']);
            } else {
                $value = $this->obj->__get($field['f_sname']);
            }
        }
        page::assign('field.value', $value);
        // Для страниц, для кнопки "Показать \ скрыть доп. поля"
        if ($this->obj instanceof ormPage && in_array($field['f_sname'], $this->page_fields)) {
            $sh_page = isset($_SESSION['SH_FIELDS']) && $_SESSION['SH_FIELDS'] == 'show' ? '' : ' style="display:none;"';
            page::assign('sh_page', $sh_page);
        } else {
            page::assign('sh_page', '');
        }
        // Специальная обработка данных
        if ($field['f_type'] == 50) {
            page::assign('element', ui::CheckBox($field['f_sname'], 1, $value));
        } else {
            if ($field['f_type'] == 32) {
                if (empty($value) || $value == '0000-00-00 00:00:00') {
                    page::assign('field.date', '');
                    page::assign('field.time', '00:00');
                } else {
                    page::assign('field.date', date('d.m.Y', strtotime($value)));
                    page::assign('field.time', date('H:i', strtotime($value)));
                }
            } else {
                if ($field['f_type'] == 25) {
                    $time = empty($value) || $value == '0000-00-00' ? '' : date('d.m.Y', strtotime($value));
                    page::assign('field.date', $time);
                } else {
                    if ($field['f_type'] == 30) {
                        $time = empty($value) ? '' : date('H:i:s', strtotime($value));
                        page::assign('field.time', $time);
                    } else {
                        if ($field['f_type'] == 70 || $field['f_type'] == 75 || $field['f_type'] == 80 || $field['f_type'] == 85) {
                            if (system::$isAdmin) {
                                page::assign('element', ui::loadFile($field['f_sname'], $value));
                            } else {
                                page::fParse('element', $TEMPLATE['upload_file_field']);
                            }
                        } else {
                            if ($field['f_type'] == 73) {
                                page::assign('element', ui::listFile($field['f_sname'], $value));
                            } else {
                                if ($field['f_type'] == 90 || $field['f_type'] == 95) {
                                    // Выпадающий список или Список со множественным выбором
                                    // Получаем список объектов справочника
                                    page::assign('field.sname', $field['f_sname']);
                                    $data = ormObjects::getObjectsByClass($field['f_list_id']);
                                    $multi = $field['f_type'] == 95 ? 'selectbox_multi' : 'selectbox_template';
                                    $empty = !$field['f_required'] ? '&nbsp;' : '';
                                    if (system::$isAdmin) {
                                        page::assign('element', ui::SelectBox($field['f_sname'], $data, $value, 400, $empty, '', $multi));
                                        if ($field['f_quick_add']) {
                                            page::fParse('plus', $TEMPLATE['field_' . $field['f_type'] . '_plus']);
                                        } else {
                                            page::assign('plus', '');
                                        }
                                    } else {
                                        page::assign('element', ui::SelectBox($field['f_sname'], $data, $value, 200, $empty, '', $multi));
                                    }
                                } else {
                                    if ($field['f_type'] == 97) {
                                        // Подчиненный справочник
                                        // Получаем список объектов справочника
                                        $sel = new ormSelect($field['f_list_id']);
                                        $sel->where('parents', '=', $this->obj->id);
                                        // Выводим мультиформу для добавления и редактирования
                                        $form = new ormMultiForm('subject_list_' . $field['f_id']);
                                        $form->setData($sel);
                                        $form->insideForm();
                                        $re = $form->getHTML();
                                        //  echo $re;
                                        page::assign('element', $re);
                                    } else {
                                        if ($field['f_type'] == 100) {
                                            // Связь с объектом
                                            page::assign('element', ui::objectLinks($this->obj, $field['f_id']));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        page::assign('field.id', $field['f_id']);
        page::assign('field.name', $field['f_name']);
        page::assign('field.hint', $field['f_hint']);
        page::assign('field.sname', $field['f_sname']);
        page::fParse('field.dotted', !empty($field['f_hint']) ? 'dotted' : '');
        if (empty($field['f_max_size'])) {
            $field['f_max_size'] = $field['f_type'] == 60 ? 200 : 100;
        }
        page::assign('field.max_size', $field['f_max_size']);
        // Генерируем яву (создаем правила проверки для элементов формы)
        if ($field['f_required'] && ($field['f_type'] == 35 && $this->obj->id == '' || $field['f_type'] != 35)) {
            $msg = str_replace('%title%', $field['f_name'], lang::get('CONSTR_BASE_FIELD_E2'));
            if ($field['f_type'] == 60) {
                // HTML - редактор
                $this->addit_function .= page::parse('
  					function checkValue%field.sname%(){
  					 	var value = CKEDITOR.instances["%field.sname%"].getData();
    					return (value != "") ? true : [[ "cke_%field.sname%", "' . $msg . '" ]];
					}
  				');
                $this->java .= page::parse('rules.push("function,checkValue%field.sname%");');
            } else {
                if ($field['f_type'] == 100) {
                    // Выбор объекта
                    $this->addit_function .= page::parse('
  					function checkObjectLinks%field.sname%(){
  						var count = $("#objectsLinkList_%field.sname% > li").length;
    					return (count > 0) ? true : [[ %field.sname%, "' . $msg . '" ]];
					}
  				');
                    $this->java .= page::parse('rules.push("function,checkObjectLinks%field.sname%");');
                } else {
                    if ($field['f_type'] == 32) {
                        // Каледарь и время
                        $this->java .= page::parse('rules.push("required,%field.sname%_date,' . $msg . '");');
                    } else {
                        $this->java .= page::parse('rules.push("required,%field.sname%,' . $msg . '");');
                    }
                }
            }
            $zvezd = 'chek';
        } else {
            $zvezd = '';
        }
        page::assign('field.zvezd', $zvezd);
        if ($field['f_type'] == 15) {
            $this->java .= page::parse('rules.push("valid_email,%field.sname%,' . lang::get('CONSTR_BASE_FIELD_E3') . '");');
        }
        if ($field['f_type'] == 20) {
            $this->java .= page::parse('rules.push("reg_exp,%field.sname%,^(((f|ht){1}tp:/)*/[-a-zA-Z0-9@:%_\\+.~#?&//=]+)*$|^\\/{1}, ' . lang::get('CONSTR_BASE_FIELD_E4') . '");');
        }
        if ($field['f_type'] == 40) {
            $this->java .= page::parse('rules.push("digits_only,%field.sname%,' . lang::get('CONSTR_BASE_FIELD_E6') . '");');
        }
        if ($field['f_type'] == 45) {
            $this->java .= page::parse('rules.push("float_only,%field.sname%,' . lang::get('CONSTR_BASE_FIELD_E7') . '");');
        }
        if ($field['f_type'] == 47) {
            $this->java .= page::parse('rules.push("price_only,%field.sname%,' . lang::get('CONSTR_BASE_FIELD_E8') . '");');
        }
        if (isset($TEMPLATE['field_' . $field['f_type']])) {
            return page::parse($TEMPLATE['field_' . $field['f_type']]);
        } else {
            return str_replace('%title%', $field['f_sname'], lang::get('CONSTR_BASE_FIELD_E5'));
        }
    }