public function actionTac_vu_khach() { $dangtin = new LoginForm(); $khachhang = new Khachhang(); $form = new CForm('application.views.admin.tac_vu_khach.form_tac_vu_khach', $khachhang); $khachhang->setScenario('dang_tin_khach'); if ($form->submitted('dangtinkhach') && $form->validate()) { $id = $khachhang->idkhach; $arry = explode("_", $id); $username = $arry[0]; if (isset($arry[1])) { $id = $arry[1]; if ($user = Khachhang::model()->TTkhach($id, $username)) { $dangtin->username = $user['ten_dang_nhap']; $dangtin->password = $user['password']; $dangtin->_identity = new UserIdentity($dangtin->username, $dangtin->password); $dangtin->_identity->authenticate(); $dangtin->login(); $this->redirect(Yii::app()->request->baseUrl . '/dang-tin'); } else { $this->__message = "Nhập sai id khách hàng!"; } } else { $this->__message = "Nhập sai cú pháp!"; } } $this->render('tac_vu_khach', array('form' => $form, 'message' => $this->__message)); }
/** * Displays the authorization assignments for an user. */ public function actionUser() { // Create the user model and attach the required behavior $userClass = $this->module->userClass; $model = CActiveRecord::model($userClass)->findByPk($_GET['id']); $model->attachBehavior('rights', new RightsUserBehavior()); $assignedItems = $this->_authorizer->getAuthItems(null, $model->getId(), null, true); $assignments = array_keys($assignedItems); // Make sure we have items to be selected $selectOptions = Rights::getAuthItemSelectOptions(null, $assignments); if ($selectOptions !== array()) { // Create a from to add a child for the authorization item $form = new CForm(array('elements' => array('itemname' => array('label' => false, 'type' => 'dropdownlist', 'items' => $selectOptions)), 'buttons' => array('submit' => array('type' => 'submit', 'label' => Rights::t('core', 'Assign')))), new AssignmentForm()); // Form is submitted and data is valid, redirect the user if ($form->submitted() === true && $form->validate() === true) { // Update and redirect $this->_authorizer->authManager->assign($form->model->itemname, $model->getId()); $item = $this->_authorizer->authManager->getAuthItem($form->model->itemname); $item = $this->_authorizer->attachAuthItemBehavior($item); Yii::app()->user->setFlash($this->module->flashSuccessKey, Rights::t('core', 'Permission :name assigned.', array(':name' => $item->getNameText()))); $this->redirect(array('assignment/user', 'id' => $model->getId())); } } else { $form = null; } // Create a data provider for listing the assignments $dataProvider = new AuthItemDataProvider('assignments', array('userId' => $model->getId())); // Render the view $this->render('user', array('model' => $model, 'dataProvider' => $dataProvider, 'form' => $form)); }
public function actionRegisterconstruct() { $model = new RegisterTestForm(); $form = new CForm("application.views.formconstruct.registerbuilder", $model); if ($form->submitted('register') && $form->validate()) { print "Зарегистрирован удачно"; } $this->render("registerconstruct", array('form' => $form)); }
/** * Displays the order page */ public function actionOrder() { $model = new OrderForm(); $form = new CForm('application.views.site.orderForm', $model); if ($form->submitted('order') && $form->validate()) { $this->redirect(array('site/index')); } else { $this->render('order', array('form' => $form)); } }
/** * * @param CActiveRecord $model * @param int $id * @param array $config */ public function registerAssignScript($model, $id, array $config = array()) { Yii::app()->controller->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'assignDriver', "options" => array('title' => 'Assign Driver', 'autoOpen' => false, 'modal' => true, 'buttons' => array('Close' => 'js:function(){$(this).dialog("close")}', 'Assign' => 'js:function(){' . CHtml::ajax(array('url' => $config['ajaxUrl'], 'type' => 'post', 'dataType' => 'json', 'data' => 'js:$("#assignDriver form").serialize()', 'success' => 'function(r){if(r.success){ $("#assignDriver").dialog("close"); $.fn.yiiGridView.update("tracking-grid"); }; if(!r.success){alert("Gagal assign driver")}}')) . ';}'))), true); $driverForm = new CForm(array('elements' => array('driver' => array('type' => 'dropdownlist', 'items' => OrderTracking::getDriverList()), 'id' => array('type' => 'hidden'))), $model); echo $driverForm->render(); Yii::app()->controller->endWidget(); Yii::app()->clientScript->registerScript($id, "jQuery('body').undelegate('.assignDriver_button','click').delegate('.assignDriver_button','click',function(){\ndriverDialog=jQuery('#assignDriver');\ndriverDialog.dialog('open');\njQuery('#assignDriver input#OrderTracking_id').val(\$(this).attr('rel').replace('grid.',''));\n\treturn false;\n});\t"); }
public function actionResult() { $model = new SearchForm(); $form = new CForm('application.views.search.form', $model); if ($form->submitted('search') && $form->validate()) { $result = $model->searchResult(); //$this->redirect(array('search/index')); $this->render('index', array('form' => $form, 'result' => $result)); } else { $this->render('index', array('form' => $form)); } }
/** * Action: Index * * @access public * @return void */ public function actionIndex() { // Only go ahead with the logout if the end-user is logged in, if the end-user is a guest then we can skip // the entire logout procedure, and skip to the redirect back home! if (!Yii::app()->user->isGuest) { // Has the "authUser" persistent state been set, which contains the user's true authenticated ID, and is // it different to the user's current ID? if (is_int(Yii::app()->user->getState('authUser')) && Yii::app()->user->getState('authUser') != Yii::app()->user->getState('id') && is_object($authUser = User::model()->findByPk(Yii::app()->user->getState('authUser')))) { $model = new \application\model\form\Logout(); $form = new CForm('application.forms.logout', $model); if ($form->submitted() && $form->validate()) { // Has the user opted to switch back to their original account? if ($model->switch) { // Create a new user identity instance, but since we aren't going to use any credentials to // authenticate the user, we can just pass in empty strings. $identity = new UserIdentity('', ''); // Attempt to load the identitiy of the user defined by the ID in the "authUser" persistent // state. if ($identity->load(Yii::app()->user->getState('authUser')) && Yii::app()->user->login($identity)) { // The original user account was successfully logged in, redirect to the homepage. $this->redirect(Yii::app()->homeUrl); } else { throw new CException(Yii::t('application', 'An error occured whilst attempting to load your original user account. You have been logged out for security reasons.')); } } else { // Log out the current user. Pass bool(false) as an argument to prevent the entire session // from being destroyed, and instead only delete the persistent states that were created // specifically for the user logged in. An example of why this is the behaviour we want is // storing the language selection in a session - if the website visitor selects French as // the language to view the website in (regardless of whether this functionality is actually // implemented), we don't want that session variable destroyed causing the entire website to // switch back to the default language of English just because the user wanted to log out. // Personally I believe that this should be the default behaviour, but it's not. Yii::app()->user->logout(false); $this->redirect(Yii::app()->homeUrl); } } // Render the logout page, so that the end-user may be presented with a choice instead of // automatically logged out (as if the default). $this->render('index', array('form' => $form, 'displayName' => $authUser->displayName)); // End the application here to prevent any redirection. Yii::app()->end(); } else { // Log out the current user. Please refer to the lengthy explaination earlier in this method for why // we pass bool(false). Yii::app()->user->logout(false); } } // We don't want the user to stay on the logout page. Redirect them back to the homepage. $this->redirect(Yii::app()->homeUrl); }
public function actionIndex() { $model = new ConfigForm(); $form = new CForm('application.views.config.form', $model); $model->load(); if ($form->submitted('submit')) { $model->attributes = $_POST['ConfigForm']; if ($model->save()) { Yii::app()->user->setFlash('config', Yii::t('app', 'Your new options have been saved.')); } $this->render('index', array('form' => $form, 'model' => $model, 'result' => $result)); } else { $this->render('index', array('form' => $form)); } }
/** * @param $id * @throws CHttpException */ public function actionUpdate($id) { $model = $this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); $formElements = ['title' => 'Update ' . $model->sectionName . ' description', 'elements' => ['<label>Section Name</label><span>' . $model->sectionName . '</span>', 'description' => ['type' => 'textarea']], 'buttons' => ['save' => ['type' => 'submit', 'label' => 'Save']]]; $form = new CForm($formElements, $model); if ($form->submitted('save') && $form->validate()) { if ($model->save()) { Yii::app()->user->setFlash('success', 'Surveillance section description updated successfully'); $this->redirect(['index']); } Yii::app()->user->setFlash('error', 'Surveillance section description not updated successfully,' . ' please contact your administrator'); } $this->render('update', ['model' => $model, 'form' => $form]); }
function bodyToString($destroy = true) { $setup_left = (new CDiv([(new CDiv())->addClass(ZBX_STYLE_SIGNIN_LOGO), $this->getList()]))->addClass(ZBX_STYLE_SETUP_LEFT); $setup_right = (new CDiv($this->getStage()))->addClass(ZBX_STYLE_SETUP_RIGHT); if (CWebUser::$data && CWebUser::getType() == USER_TYPE_SUPER_ADMIN) { $cancel_button = (new CSubmit('cancel', _('Cancel')))->addClass(ZBX_STYLE_BTN_ALT)->addClass(ZBX_STYLE_FLOAT_LEFT); if ($this->DISABLE_CANCEL_BUTTON) { $cancel_button->setEnabled(false); } } else { $cancel_button = null; } if (array_key_exists($this->getStep() + 1, $this->stage)) { $next_button = new CSubmit('next[' . $this->getStep() . ']', _('Next step')); } else { $next_button = new CSubmit($this->SHOW_RETRY_BUTTON ? 'retry' : 'finish', _('Finish')); } $back_button = (new CSubmit('back[' . $this->getStep() . ']', _('Back')))->addClass(ZBX_STYLE_BTN_ALT)->addClass(ZBX_STYLE_FLOAT_LEFT); if ($this->getStep() == 0 || $this->DISABLE_BACK_BUTTON) { $back_button->setEnabled(false); } $setup_footer = (new CDiv([new CDiv([$next_button, $back_button]), $cancel_button]))->addClass(ZBX_STYLE_SETUP_FOOTER); $setup_container = (new CDiv([$setup_left, $setup_right, $setup_footer]))->addClass(ZBX_STYLE_SETUP_CONTAINER); return parent::bodyToString($destroy) . $setup_container->ToString(); }
public function __construct($path, $model) { $this->model = $model; list($module, $form) = explode(".", $path, 2); $form_path = "application.modules.{$module}.forms.{$form}"; parent::__construct($form_path, $model); }
function sendOnAfterResultStatusChange($WEB_FORM_ID, $RESULT_ID, $NEW_STATUS_ID = false, $CHECK_RIGHTS = 'Y') { $NEW_STATUS_ID = intval($NEW_STATUS_ID); $dbRes = CForm::GetByID($WEB_FORM_ID); if (!($arForm = $dbRes->Fetch())) { return; } CTimeZone::Disable(); $dbRes = CFormResult::GetByID($RESULT_ID); CTimeZone::Enable(); if (!($arResult = $dbRes->Fetch()) || !$arResult['USER_ID']) { return; } $dbRes = CUser::GetByID($arResult['USER_ID']); if (!($arUser = $dbRes->Fetch())) { return; } if (!$NEW_STATUS_ID) { $NEW_STATUS_ID = CFormStatus::GetDefault($WEB_FORM_ID); } $dbRes = CFormStatus::GetByID($NEW_STATUS_ID); if (!($arStatus = $dbRes->Fetch()) || strlen($arStatus['MAIL_EVENT_TYPE']) <= 0) { return; } $arTemplates = CFormStatus::GetMailTemplateArray($NEW_STATUS_ID); if (!is_array($arTemplates) || count($arTemplates) <= 0) { return; } $arEventFields = array("EMAIL_TO" => $arUser['EMAIL'], "RS_FORM_ID" => $arForm["ID"], "RS_FORM_NAME" => $arForm["NAME"], "RS_FORM_VARNAME" => $arForm["SID"], "RS_FORM_SID" => $arForm["SID"], "RS_RESULT_ID" => $arResult["ID"], "RS_DATE_CREATE" => $arResult["DATE_CREATE"], "RS_USER_ID" => $arResult['USER_ID'], "RS_USER_EMAIL" => $arUser['EMAIL'], "RS_USER_NAME" => $arUser["NAME"] . " " . $arUser["LAST_NAME"], "RS_STATUS_ID" => $arStatus["ID"], "RS_STATUS_NAME" => $arStatus["TITLE"]); $dbRes = CEventMessage::GetList($by = "id", $order = "asc", array('ID' => implode('|', $arTemplates), "ACTIVE" => "Y", "EVENT_NAME" => $arStatus["MAIL_EVENT_TYPE"])); while ($arTemplate = $dbRes->Fetch()) { CEvent::Send($arTemplate["EVENT_NAME"], $arTemplate["SITE_ID"], $arEventFields, "Y", $arTemplate["ID"]); } }
/** * Renders the open tag of the form. The default implementation will render the open form tag. * @return string The rendering result. */ public function renderBegin() { if (!$this->getParent() instanceof self and !isset($this->activeForm['class'])) { $this->activeForm['class'] = 'TbActiveForm'; } return parent::renderBegin(); }
function __form_CreateForm($SID, $__current_dir) { // check collisions $dbTmpForm = CForm::GetBySID($SID); if ($arTmpForm = $dbTmpForm->Fetch()) { return false; } //$dirName = ToLower($SID); $formConfigFile = $__current_dir . '/form.php'; $fieldsConfigFile = $__current_dir . '/fields.php'; // check config existence if (!file_exists($formConfigFile) || !file_exists($fieldsConfigFile)) { return false; } // load form config $arForm = array(); require $formConfigFile; // setup form if ($FORM_ID = CForm::Set($arForm, false, 'N')) { // load fields config $arFormFields = array(); require $fieldsConfigFile; // setup form fields foreach ($arFormFields as $key => $arField) { CFormField::Set($arField, false, 'N'); } $arStatus = array('FORM_ID' => $FORM_ID, 'TITLE' => 'DEFAULT', 'CSORT' => 100, 'ACTIVE' => 'Y', 'DEFAULT_VALUE' => 'Y', 'arPERMISSION_MOVE' => array(0)); CFormStatus::Set($arStatus, false, 'N'); } return $FORM_ID; }
/** * Constructor */ public function __construct($content) { parent::__construct(); $this->content = $content; $save = isset($content['id']) ? 'save' : 'create'; $this->AddElement(new CFormElementHidden('id', array('value' => $content['id'])))->AddElement(new CFormElementText('title', array('value' => $content['title'])))->AddElement(new CFormElementText('key', array('value' => $content['key'])))->AddElement(new CFormElementTextarea('data', array('label' => 'Content:', 'value' => $content['data'])))->AddElement(new CFormElementText('type', array('value' => $content['type'])))->AddElement(new CFormElementText('filter', array('value' => $content['filter'])))->AddElement(new CFormElementSubmit($save, array('callback' => array($this, 'DoSave'), 'callback-args' => array($content))))->AddElement(new CFormElementSubmit('delete', array('callback' => array($this, 'DoDelete'), 'callback-args' => array($content)))); $this->SetValidation('title', array('not_empty'))->SetValidation('key', array('not_empty')); }
/** Create all form elements and validation rules in the constructor. * */ public function __construct() { parent::__construct(); $items = array('tomato', 'potato', 'apple', 'pear', 'banana'); $shoppingcart = array('potato', 'pear'); $this->AddElement(new CFormElementCheckboxMultiple('items', array('values' => $items, 'checked' => $shoppingcart))); $this->AddElement(new CFormElementSubmit('submit', array('callback' => array($this, 'DoSubmit')))); }
static function get_option($array_title, $selectedvalue = "") { $option = '<option value="">Aucun</option>'; foreach($array_title as $key=>$valeur) { $selected = CForm::get_selected($selectedvalue, $valeur); $option = $option . "<option value='" . $key . "'" . $selected . ">" . utf8_encode($valeur) . "</option>\n"; } return $option; }
static function get_option($selectedvalue, $tablename="pays", $colvaluename="id", $colvuename="nom", $where=1) { $option = ""; $result = CTable::select($colvaluename . " , " . $colvuename, $tablename, $where, $colvuename); while($array = mysql_fetch_array($result)) { $selected = CForm::get_selected($selectedvalue, $array[$colvaluename]); $option = $option . "<option value='" . $array[$colvaluename] . "'" . $selected . ">" . ucfirst(utf8_encode(substr($array[$colvuename], 0, 25))) . "</option>\n"; } return $option; }
public function renderBody() { $output = parent::renderBody(); if (!$this->getParent() instanceof self && $this->side == 'admin') { $this->attributes['class'] = 'admin_form'; return $this->getParent()->msg(t('Поля отмеченные * обязательны.'), 'info') . $output; } return $output; }
static function get_option($selectedvalue, $idtype) { $option = ""; $type_possible = CTableQuestion::get_enum('type'); foreach($type_possible as $valeur) { $selected = CForm::get_selected($selectedvalue, $valeur); $option = $option . "<option value='" . $valeur . "'" . $selected . ">" . $valeur . "</option>\n"; } return $option; }
static function get_option($selectedvalue, $tablename, $colvaluename="id", $colvuename="nom", $where=1) { $option = ""; $sql = "SELECT " . $colvaluename . ", " . $colvuename . " FROM " . $tablename . " WHERE " . $where . " ORDER BY " . $colvuename; $result = CBdd::select($sql); while($array = mysql_fetch_array($result)) { $selected = CForm::get_selected($selectedvalue, $array[$colvaluename]); $option = $option . "<option value='" . $array[$colvaluename] . "'" . $selected . ">" . ucfirst(utf8_encode(substr($array[$colvuename], 0, 16))) . "</option>\n"; } return $option; }
/** * Constructor * */ public function create($successCallback, $values = null) { parent::__construct(); $message = $values ? $values['message'] : ""; $email = $values ? $values['email'] : ""; $name = $values ? $values['name'] : ""; $id = $values ? $values['id'] : ""; $this->AddElement(new CFormElementText('message', ['value' => $message]))->AddElement(new CFormElementText('name', ['value' => $name]))->AddElement(new CFormElementText('email', ['value' => $email]))->AddElement(new CFormElementHidden('id', ['value' => $id]))->AddElement(new CFormElementSubmit('submit', array('callback' => $successCallback)))->AddElement(new CFormElementSubmit('submit-fail', array('callback' => array($this, 'DoSubmitFail')))); return $this; }
/** Create all form elements and validation rules in the constructor. * */ public function __construct() { parent::__construct(); $items = array('tomato', 'potato', 'apple', 'pear', 'banana'); $shoppingcart = array('potato', 'pear'); foreach ($items as $item) { $this->AddElement(new CFormElementCheckbox($item, array('value' => $item, 'label' => $item, 'checked' => in_array($item, $shoppingcart)))); } $this->AddElement(new CFormElementSubmit('submit', array('callback' => array($this, 'DoSubmit')))); }
/** * Constructor * */ public function create($successCallback, $user = null) { parent::__construct(); $acronym = $user ? $user->acronym : ""; $email = $user ? $user->email : ""; $name = $user ? $user->name : ""; $id = $user ? $user->id : ""; $password = $user ? $user->password : ""; $this->AddElement(new CFormElementText('acronym', ['value' => $acronym]))->AddElement(new CFormElementText('name', ['value' => $name]))->AddElement(new CFormElementText('email', ['value' => $email]))->AddElement(new CFormElementHidden('id', ['value' => $id]))->AddElement(new CFormElementPassword('password', ['value' => $password]))->AddElement(new CFormElementSubmit('submit', array('callback' => $successCallback)))->AddElement(new CFormElementSubmit('submit-fail', array('callback' => array($this, 'DoSubmitFail')))); return $this; }
public function run() { if (!Yii::app()->user->isGuest) { $this->redirect('index.php'); } $form = new CForm('application.views.user.registerForm'); $form['user']->model = new User('register'); $form['profile']->model = new UserProfile(); if ($form->submitted('register') && $form->validate()) { $user = $form['user']->model; $profile = $form['profile']->model; if ($user->save(false)) { $profile->id = $user->id; $profile->save(false); $this->redirect(array('site/index')); } } else { $this->render('register', array('form' => $form)); } }
static function get_option($selectedvalue, $idconfiguration) { $option = ""; $sql = "SELECT choix FROM configuration WHERE id = " . $idconfiguration; $result = CBdd::select_one($sql, "choix"); $choix_possible = explode('|', $result); foreach($choix_possible as $valeur) { $selected = CForm::get_selected($selectedvalue, $valeur); $option = $option . "<option value='" . $valeur . "'" . $selected . ">" . $valeur . "</option>\n"; } return $option; }
/** * Đăng tin rao vặt */ public function actionDang_tin($currentPage = 1) { if (Yii::app()->user->name == 'Guest' || !isset(Yii::app()->user->userId)) { $this->redirect(Yii::app()->homeUrl . 'dang-nhap'); } $form = new CForm('application.views.user.rao_vat._form'); $form['tinkhachhang']->model = new Tinkhachhang(); $form['tinraovat']->model = $tinraovat = new Tinraovat(); $noticeMessage = ''; if ($form->submitted('dangtin') && $form->validate()) { $tinkhachhang = $form['tinkhachhang']->model; $tinraovat = $form['tinraovat']->model; //Nếu không đủ tiền để đăng tin sẽ không đăng if ($tinkhachhang->trutien(Tinraovat::CODE_RV)) { $tinkhachhang->ma_loai_tin = Tinraovat::CODE_RV; if ($tinkhachhang->save(false)) { $image = CUploadedFile::getInstance($tinraovat, 'anh'); if ($image) { $newName = md5(microtime(true) . 'xechieuve') . $image->name; $tinraovat->anh = $newName; $image->saveAs(Tinraovat::IMAGE_DIR_RV . $newName); } $tinraovat->ma_tin = $tinkhachhang->ma_tin; $tinraovat->save(false); $this->__message = "Tin bạn đăng đã được hiển thị tại trang rao vặt"; } } else { $this->__message = "Tài khoản của bạn không đủ để đăng tin"; } } $tinraovat = new Tinraovat(); $paginatorRV = new Paginate($currentPage, new Tinkhachhang(), self::LIMITED_REDCORD_RV, ' ma_loai_tin = ' . Tinraovat::CODE_RV); $listTinRV = $tinraovat->listTinRV($paginatorRV); //render view $data = array('form' => $form, 'listTinRV' => $listTinRV, 'paginatorRV' => $paginatorRV, 'urlPaginatorRV' => 'rao_vat/pagedtrv?page=', 'ajaxElementId' => '#tableRV', 'message' => $this->__message); if (Yii::app()->request->isAjaxRequest) { $this->renderPartial('dang_tin', $data); } else { $this->render('dang_tin', $data); } }
static function get_option($selectedvalue, $tablename, $colvaluename="id", $colvuename="nom", $where=1, $order = null) { $option = ""; if(!$order) { $order = $colvuename; } $result = CTable::select($colvaluename . " , " . $colvuename, $tablename, $where, $order); while($array = mysql_fetch_array($result)) { $selected = CForm::get_selected($selectedvalue, $array[$colvaluename]); $option = $option . "<option value='" . $array[$colvaluename] . "'" . $selected . ">" . $array[$colvuename] . "</option>\n"; } return $option; }
/** Create all form elements and validation rules in the constructor. * */ public function __construct() { parent::__construct(); /* $this->AddElement(new CFormElementText('name', array('label'=>'Name of contact person:', 'required'=>true))) ->AddElement(new CFormElementText('email', array('required'=>true))) ->AddElement(new CFormElementText('phone', array('required'=>true))); */ $this->AddElement(new CFormElementCheckbox('accept_mail', array('label' => 'It´s great if you send me product information by mail.', 'checked' => false)))->AddElement(new CFormElementCheckbox('accept_phone', array('label' => 'You may call me to try and sell stuff.', 'checked' => true)))->AddElement(new CFormElementCheckbox('accept_agreement', array('label' => 'You must accept the <a href=http://opensource.org/licenses/GPL-3.0>license agreement</a>.', 'required' => true)))->AddElement(new CFormElementSubmit('submit', array('callback' => array($this, 'DoSubmit'))))->AddElement(new CFormElementSubmit('submit-fail', array('callback' => array($this, 'DoSubmitFail')))); /*$this->SetValidation('name', array('not_empty')) ->SetValidation('email', array('not_empty')) ->SetValidation('phone', array('not_empty', 'numeric')); */ $this->SetValidation('accept_agreement', array('must_accept')); }
function CreateForm($arForm, $arFormFields, $langFile) { if (!CModule::IncludeModule("form")) { return false; } // set defaults $arFieldDefaults = array("ACTIVE" => "Y", "C_SORT" => 0, "ADDITIONAL" => "N", "TITLE_TYPE" => "text", "IN_RESULTS_TABLE" => "Y", "IN_EXCEL_TABLE" => "Y"); foreach ($arFormFields as $key => $arField) { if ($arFormFields['ADDITIONAL'] == 'Y' && !is_set($arFormFields['C_SORT'])) { $arFormFields['C_SORT'] = 5000; } $arFieldDefaults["C_SORT"] += 100; $arFormFields[$key] = array_merge($arFieldDefaults, $arField); $arFormFields[$key]["TITLE"] = GetMessage($arField["SID"] . "_QUESTION"); } $rsLanguage = CLanguage::GetList($by, $order, array()); while ($arLanguage = $rsLanguage->Fetch()) { WizardServices::IncludeServiceLang($langFile, $arLanguage["LID"]); $arForm["arMENU"][$arLanguage["LID"]] = GetMessage(substr($arForm["SID"], 0, -3) . "_MENU_NAME"); } $dbForm = CForm::GetBySID($arForm["SID"]); if ($dbForm->Fetch()) { return; } WizardServices::IncludeServiceLang("status.php"); if ($formID = CForm::Set($arForm, false, "N")) { // setup form fields foreach ($arFormFields as $key => $arField) { $arField["FORM_ID"] = $formID; $fieldID = CFormField::Set($arField, false, "N"); } if ($arTemplates = CForm::SetMailTemplate($formID)) { CForm::Set(array('SID' => $arForm['SID'], 'arMAIL_TEMPLATE' => $arTemplates), $formID, 'N'); } $arStatuses = array(array("FORM_ID" => $formID, "TITLE" => GetMessage("STATUS_NEW"), "C_SORT" => 100, "ACTIVE" => "Y", "DEFAULT_VALUE" => "Y", "CSS" => "statusgray", "arPERMISSION_VIEW" => array(0), "arPERMISSION_MOVE" => array(0), "arPERMISSION_EDIT" => array(0), "arPERMISSION_DELETE" => array(0)), array("FORM_ID" => $formID, "TITLE" => GetMessage("STATUS_RECEIVED"), "C_SORT" => 200, "ACTIVE" => "Y", "DEFAULT_VALUE" => "N", "CSS" => "statusblue", "arPERMISSION_VIEW" => array(0)), array("FORM_ID" => $formID, "TITLE" => GetMessage("STATUS_DONE"), "C_SORT" => 300, "ACTIVE" => "Y", "DEFAULT_VALUE" => "N", "CSS" => "statusgreen", "arPERMISSION_VIEW" => array(0)), array("FORM_ID" => $formID, "TITLE" => GetMessage("STATUS_REFUSE"), "C_SORT" => 400, "ACTIVE" => "Y", "DEFAULT_VALUE" => "N", "CSS" => "statusred", "arPERMISSION_VIEW" => array(0))); foreach ($arStatuses as $key => $arStatus) { if ($STATUS_ID = CFormStatus::Set($arStatus, false, "N")) { if ($arStatus['DEFAULT_VALUE'] == 'N' && ($arTemplates = CFormStatus::SetMailTemplate($formID, $STATUS_ID))) { foreach ($arTemplates as $TEMPLATE_ID) { if (null == $em) { $em = new CEventMessage(); } $em->Update($TEMPLATE_ID, array('MESSAGE' => GetMessage('STATUS_MESSAGE'))); } CFormStatus::Set(array('FORM_ID' => $formID, 'arMAIL_TEMPLATE' => $arTemplates), $STATUS_ID, 'N'); } } } } return $formID; }