Exemplo n.º 1
0
 public function save()
 {
     try {
         $model = new Type();
         $this->data->type->entry = 'typ_' . $this->data->type->entry;
         $model->setData($this->data->type);
         $model->save();
         $this->renderPrompt('information', 'OK', "editEntry('{$this->data->type->entry}');");
     } catch (\Exception $e) {
         $this->renderPrompt('error', $e->getMessage());
     }
 }
Exemplo n.º 2
0
 /**
  *
  */
 public function actionCreate()
 {
     $model = new Type();
     if (($data = Yii::app()->getRequest()->getPost('Type')) !== null) {
         $model->setAttributes($data);
         if ($model->save() && $model->storeTypeAttributes(Yii::app()->getRequest()->getPost('attributes', []))) {
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.store', 'Product type is created'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create']));
         }
     }
     $this->render('create', ['model' => $model, 'availableAttributes' => Attribute::model()->findAll()]);
 }
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionNew()
 {
     $model = new Type();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Type'])) {
         $model->attributes = $_POST['Type'];
         if ($model->save()) {
             $this->redirect(array('view', 'type' => $model->TYPE_ID));
         }
     }
     $this->render('new', array('model' => $model));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::all();
     $type = new Type();
     $type->name = $data['name'];
     $type->short_name = $data['short_name'];
     try {
         $type->save();
     } catch (ValidationException $errors) {
         return Redirect::route('admin.types.create')->withErrors($errors->getErrors())->withInput();
     }
     return Redirect::route('admin.types.create')->withErrors(array('mainSuccess' => 'Видът на учебното заведение е успешно добавен.'));
 }
 /**
  * Store a newly created resource in storage.
  * POST /clienttype
  *
  * @return Response
  */
 public function store()
 {
     Input::merge(array_map('trim', Input::all()));
     $input = Input::all();
     $validation = Validator::make($input, Type::$rules);
     if ($validation->passes()) {
         $client = new Type();
         $client->client_type = strtoupper(Input::get('client'));
         $client->desc = strtoupper(Input::get('description'));
         $client->save();
         return Redirect::route('client.index')->with('class', 'success')->with('message', 'Record successfully created.');
     } else {
         return Redirect::route('client.create')->withInput()->withErrors($validation)->with('class', 'error')->with('message', 'There were validation error.');
     }
 }
 public function up()
 {
     $db = Yii::app()->db;
     Yii::app()->setImport(['application.modules.store.models.*']);
     $cats = $db->createCommand("SELECT c1.* FROM site_store_category c1 LEFT JOIN site_store_category c2 ON c1.id=c2.parent_id WHERE c2.id IS NULL")->queryAll();
     foreach ($cats as $cat) {
         $Type = new Type();
         $Type->name = $cat['slug'];
         $Type->save();
         for ($i = 2; $i < 9; ++$i) {
             $TypeAttribute = new TypeAttribute();
             $TypeAttribute->type_id = $Type->id;
             $TypeAttribute->attribute_id = $i;
             $TypeAttribute->save();
         }
     }
 }
 /**
  * Создает новую модель Типа формы обучения.
  * Если создание прошло успешно - перенаправляет на просмотр.
  *
  * @return void
  */
 public function actionCreate()
 {
     $roles = ['1'];
     $role = \Yii::app()->user->role;
     if (array_intersect($role, $roles)) {
         $model = new Type();
         if (Yii::app()->getRequest()->getPost('Type') !== null) {
             $model->setAttributes(Yii::app()->getRequest()->getPost('Type'));
             if ($model->save()) {
                 Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('ListnerModule.listner', 'Запись добавлена!'));
                 $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
             }
         }
         $this->render('create', ['model' => $model]);
     } else {
         throw new CHttpException(403, 'Ошибка прав доступа.');
     }
 }
Exemplo n.º 8
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Type();
     $condition = array('condition' => 'status=:status', 'params' => array(':status' => 1), 'order' => 'name');
     $levels = Level::model()->findAll($condition);
     $option_levels = array();
     foreach ($levels as $level) {
         $option_levels[$level->level_id] = $level->name;
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Type'])) {
         $model->attributes = $_POST['Type'];
         if ($model->save()) {
             $this->redirect(array('index', 'id' => $model->type_id));
         }
     }
     $this->render('create', array('model' => $model, 'option_levels' => $option_levels));
 }
Exemplo n.º 9
0
 public function actionCreate()
 {
     $model = new Type();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (($data = Yii::app()->getRequest()->getPost('Type')) !== null) {
         $model->setAttributes($data);
         $model->categories = serialize(Yii::app()->getRequest()->getPost('categories'));
         if ($model->save()) {
             $model->setTypeAttributes(Yii::app()->getRequest()->getPost('attributes'));
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.type', 'Тип товара создан.'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create']));
         }
     }
     //$criteria = new CDbCriteria();
     //$criteria->addNotInCondition('id', CHtml::listData($model->attributeRelation, 'attribute_id', 'attribute_id'));
     $availableAttributes = Attribute::model()->findAll();
     $this->render('create', ['model' => $model, 'availableAttributes' => $availableAttributes]);
 }
Exemplo n.º 10
0
 public function getSave()
 {
     $id = Input::get('id');
     if ($id) {
         $Type = Type::find($id);
         $Type->name = Input::get('name');
         $Type->price = Input::get('price');
         $Type->description = Input::get('description');
         $Type->save();
         Session::flash('message', 'The records are updated successfully');
     } else {
         $Type = new Type();
         $Type->name = Input::get('name');
         $Type->price = Input::get('price');
         $Type->description = Input::get('description');
         $Type->save();
         Session::flash('message', 'The records are inserted successfully');
     }
     return Redirect::to('type');
 }
Exemplo n.º 11
0
 function parametrize($event = array())
 {
     $create = false;
     if (!empty($event['create']) && empty($event['errors'])) {
         $create = true;
         $entity = $event['create'];
     }
     if ($create) {
         switch ($entity) {
             case "types":
                 App::import('Model', 'Type');
                 $Type = new Type();
                 $types = array();
                 $types[] = array('type' => 'EMAIL', 'description' => 'Email access');
                 $types[] = array('type' => 'TWITTER', 'description' => 'Twitter access');
                 foreach ($types as $type) {
                     $Type->create();
                     $Type->save($type);
                 }
                 break;
         }
     }
 }
Exemplo n.º 12
0
 public function run($args)
 {
     $max_id = isset($args[0]) ? $args[0] : 0;
     $root = dirname(dirname(__DIR__));
     $parceBase = 'tiu_last';
     $log_spec = '/tmp/importTiuSpec.log';
     $log = '/tmp/importTiu.log';
     $k = file_get_contents($root . $log);
     $uploadDirectory = Yii::getPathOfAlias('webroot') . '/uploads/';
     $db = \Yii::app()->db;
     Yii::app()->setImport(['application.modules.store.models.*', 'application.models.*']);
     if ($max_id == 0) {
         $max_id = $db->createCommand()->select('MAX(id)')->from($parceBase . '.product')->queryScalar();
     }
     // импорт категорий
     if ($k == 0) {
         // перед созданием категорий все чистим
         echo "Clear tables and files... \n";
         $this->clear($uploadDirectory);
         echo "Set defaults... \n";
         $this->setDefault();
         $db->setActive(true);
         Yii::app()->language = 'ru';
         $categories = $db->createCommand("\n                SELECT name, id_item, id_parent FROM " . $parceBase . ".category_all\n            ")->queryAll();
         echo "Import categories... \n";
         foreach ($categories as $dump_category) {
             $category = new StoreCategory();
             $category->name_ru = $dump_category['name'];
             $category->tiu_id_item = $dump_category['id_item'];
             $category->status = 1;
             $name_translit = \yupe\helpers\YText::translit(str_replace(" ", "-", $dump_category['name']));
             $slug = $db->createCommand()->select('slug')->from('site_store_category')->where('slug =  "' . $name_translit . '"')->queryScalar();
             if ($slug === FALSE) {
                 $category->slug = $name_translit;
             } else {
                 //$category->slug = time() . '_' . $name_translit;
                 $category->slug = substr(md5($category->tiu_id_item), 0, 10) . '_' . $name_translit;
                 //echo $category->slug."\n";
             }
             $parent_id = $db->createCommand()->select('id')->from('site_store_category')->where('tiu_id_item =  "' . $dump_category['id_parent'] . '"')->queryScalar();
             $category->parent_id = $parent_id ? $parent_id : 1;
             if (!$category->save()) {
                 echo "\n";
                 echo "Error save StoreCategory for tiu_id_item = " . $category->tiu_id_item . "\n";
                 echo "\n";
             }
         }
         // создание типов
         echo "Create types... \n";
         $db->setActive(true);
         $cats = $db->createCommand("SELECT * FROM site_store_category")->queryAll();
         foreach ($cats as $cat) {
             $Type = new Type();
             $Type->name = $cat['slug'];
             if (!$Type->save()) {
                 echo "\n";
                 echo "Error save Type for {$cat['slug']} \n";
                 echo "\n";
                 continue;
             }
             // добавим постоянные характеристики
             foreach ($this->attr_id as $attr_id) {
                 $TypeAttribute = new TypeAttribute();
                 $TypeAttribute->type_id = $Type->id;
                 $TypeAttribute->attribute_id = $attr_id;
                 $TypeAttribute->save();
             }
         }
         $k = 1;
         file_put_contents($root . $log, $k);
     }
     // импорт продуктов
     echo "Import products... \n";
     echo "Max ID {$max_id} \n";
     for ($k; $k <= $max_id; $k++) {
         //			$db->setActive(false);
         $db->setActive(true);
         $dump_product = $db->createCommand()->select('*')->from($parceBase . '.product')->where('id =' . $k)->queryRow();
         if ($dump_product) {
             $name_translit = \yupe\helpers\YText::translit(str_replace(" ", "", $dump_product['name']));
             if (empty($name_translit)) {
                 file_put_contents($root . $log, $dump_product['id']);
                 continue;
                 // нет имени
             }
             $id_cat = $db->createCommand()->select('id_cat')->from($parceBase . '.productToCat')->where('id_product =' . $dump_product['id'])->queryScalar();
             if ($id_cat === FALSE) {
                 file_put_contents($root . $log, $dump_product['id']);
                 continue;
                 // нет категории
             }
             // скачаем файлы
             $image = $db->createCommand()->select('url')->from($parceBase . '.image')->where('id_item =' . $dump_product['id'])->queryRow();
             if ($image !== null && $image['url'] != '') {
                 $imageContent = $this->getData($image['url']);
                 if ($imageContent) {
                     $this->addToFiles('qqurl', $image['url']);
                     $file = new File();
                     $fileinfo = $file->uploadFile($uploadDirectory, array("jpg", "png", "jpeg"), 'Product');
                     // создание продукта
                     $sl = $db->createCommand()->select('slug')->from('site_store_product')->where('slug = "' . $name_translit . '"')->queryScalar();
                     if ($sl === FALSE) {
                         $slug = $name_translit;
                     } else {
                         //$slug = time() . '_' . $name_translit;
                         $slug = substr(md5($dump_product['id']), 0, 10) . '_' . $name_translit;
                     }
                     $category = $db->createCommand()->select('id, slug')->from('site_store_category')->where('tiu_id_item =  "' . $id_cat . '"')->queryRow();
                     if ($category) {
                         $category_id = $category['id'];
                         $type_id = $db->createCommand()->select('id')->from('site_store_type')->where("name = '{$category['slug']}'")->queryScalar();
                         if ($type_id === FALSE) {
                             print_r(" Error: can`t find StoreType for category_id = {$category_id} \n");
                             file_put_contents($root . $log, $dump_product['id']);
                             continue;
                         }
                         $sql = "INSERT INTO `site_store_product` (`name`, `description`, `price`, `user_id`, `slug`, `category_id`, `type_id`, `tiu_id`) VALUES ('" . $dump_product["name"] . "',:description,'" . $dump_product["price"] . "',1,'" . $slug . "'," . $category_id . "," . $type_id . "," . $dump_product['id'] . ")";
                     } else {
                         $sql = "INSERT INTO `site_store_product` (`name`, `description`, `price`, `user_id`, `slug`, `category_id`, `type_id`, `tiu_id`) VALUES ('" . $dump_product["name"] . "',:description,'" . $dump_product["price"] . "',1,'" . $slug . "',NULL,NULL," . $dump_product['id'] . ")";
                         $category_id = NULL;
                         $type_id = NULL;
                     }
                     $command = $db->createCommand($sql);
                     $command->bindParam(':description', $dump_product["description"], PDO::PARAM_STR);
                     $sql = $db->quoteValue($sql);
                     $command->execute();
                     $product_id = $db->getLastInsertID();
                     // id в c2go
                     // обработаем характеристики текущего продукта
                     $specs = $db->createCommand()->select('id_product, name, value')->from($parceBase . '.specification')->where('id_product =' . $dump_product['id'])->queryAll();
                     foreach ($specs as $spec) {
                         if (!empty($spec['name']) and !empty($spec['value'])) {
                             $name = \yupe\helpers\YText::translit($spec['name']);
                             if (in_array($name, $this->attr_name)) {
                                 // пропускаем постоянные
                                 continue;
                             }
                             $sql = "INSERT INTO `site_store_product_option` (`product_id`, `title`, `value`) \n                                        VALUES ('" . $product_id . "',:name,:value)";
                             $command = $db->createCommand($sql);
                             $command->bindParam(':name', $spec["name"], PDO::PARAM_STR);
                             $command->bindParam(':value', $spec["value"], PDO::PARAM_STR);
                             $sql = $db->quoteValue($sql);
                             $command->execute();
                         }
                         //$this->saveSpec($spec, $product_id, $category_id, $type_id);
                     }
                     file_put_contents($root . $log_spec, $dump_product['id']);
                     // связь продукта и файла
                     if (array_key_exists('id', $fileinfo)) {
                         $model = File::model()->findByPk($fileinfo['id']);
                         if ($model) {
                             $model->record_id = $product_id;
                             $model->update();
                         }
                     }
                     print_r($dump_product['id'] . ' ' . $slug . "\n");
                 }
             }
             file_put_contents($root . $log, $dump_product['id']);
         }
     }
     \Yii::app()->mail->send('*****@*****.**', '*****@*****.**', 'Импорт', 'Импорт категорий, товаров и характеристик завершен');
     //file_put_contents($root . $log, 0);
 }
Exemplo n.º 13
0
 public function postType($type_id)
 {
     $all = Input::all();
     $rules = array('name' => 'required|min:2|max:255', 'type' => 'required|min:3|max:255');
     $validator = Validator::make($all, $rules);
     if ($validator->fails()) {
         return Redirect::to('/admin/content/' . $type_id)->withErrors($validator)->withInput()->with('error', 'Ошибка');
     }
     if (is_numeric($type_id)) {
         $post = Type::find($type_id);
     } else {
         $post = new Type();
     }
     $post->type = $all['type'];
     $post->name = $all['name'];
     $post->template = $all['template'];
     $post->title = $all['title'];
     $post->text = $all['text'];
     $post->status = isset($all['status']) ? true : false;
     $post->save();
     return Redirect::to('/admin/content/' . $type_id)->with('success', 'Изменения сохранены');
 }
Exemplo n.º 14
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param      PropelPDO $con
  * @return     int The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws     PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aOffer !== null) {
             if ($this->aOffer->isModified() || $this->aOffer->isNew()) {
                 $affectedRows += $this->aOffer->save($con);
             }
             $this->setOffer($this->aOffer);
         }
         if ($this->aType !== null) {
             if ($this->aType->isModified() || $this->aType->isNew()) {
                 $affectedRows += $this->aType->save($con);
             }
             $this->setType($this->aType);
         }
         if ($this->aTypology !== null) {
             if ($this->aTypology->isModified() || $this->aTypology->isNew()) {
                 $affectedRows += $this->aTypology->save($con);
             }
             $this->setTypology($this->aTypology);
         }
         if ($this->isNew()) {
             $this->modifiedColumns[] = CustomerPeer::ID;
         }
         // If this object has been modified, then save it to the database.
         if ($this->isModified()) {
             if ($this->isNew()) {
                 $pk = CustomerPeer::doInsert($this, $con);
                 $affectedRows += 1;
                 // we are assuming that there is only 1 row per doInsert() which
                 // should always be true here (even though technically
                 // BasePeer::doInsert() can insert multiple rows).
                 $this->setId($pk);
                 //[IMV] update autoincrement primary key
                 $this->setNew(false);
             } else {
                 $affectedRows += CustomerPeer::doUpdate($this, $con);
             }
             $this->resetModified();
             // [HL] After being saved an object is no longer 'modified'
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Exemplo n.º 15
0
 public function postTypeAdd()
 {
     $validator = Validator::make(Input::all(), Type::$rules);
     if ($validator->fails()) {
         return Redirect::to('branch/type-add')->withErrors($validator)->withInput();
     }
     $type = new Type();
     $type->name = Input::get('name');
     $type->code = Input::get('code');
     $type->day = Input::get('day');
     $type->save();
     return Redirect::to('branch/type')->with('success', '客户类型添加成功!');
 }
Exemplo n.º 16
0
 function test_find()
 {
     //Arrange
     $descript = "Event Keepsakes";
     $descript2 = "Antiques";
     $test_Type = new Type($descript);
     $test_Type->save();
     $test_Type2 = new Type($descript2);
     $test_Type2->save();
     //Act
     $result = Type::find($test_Type->getId());
     //Assert
     $this->assertEquals($test_Type, $result);
 }
Exemplo n.º 17
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $about = "";
     $this->response['console'] = "SERVER[status]-> OK::200\n ";
     $this->response['console'] .= "\t" . Input::get('action') . "\n";
     switch (Input::get('action')) {
         case 'new_admin':
             $this->response['console'] .= "Creating new admin...\n";
             $mUser = new User();
             $mUser->username = Input::get('username');
             $mUser->password = Hash::make(Input::get('password'));
             $mUser->role = Input::get('role');
             $mUser->save();
             $this->response['message'] = ucfirst($mUser->username) . " was added to admins successfully";
             break;
         case 'new_medicine_type':
             $this->response['console'] .= "Creating new medicine type...\n";
             $mType = new Type();
             $mType->type = Input::get('type');
             $mType->save();
             $this->response['message'] = ucfirst($mType->type) . " was added to medicine types successfully";
             break;
         case 'new_medicine_breed':
             $this->response['console'] .= "Creating new medicine breed...\n";
             $mBreed = new Breed();
             $mBreed->breed = Input::get('breed');
             $mBreed->type_id = Input::get('type');
             $this->response['console'] = $mBreed->breed . " | " . $mBreed->type_id . "\n";
             $mBreed->save();
             $this->response['message'] = ucfirst($mBreed->breed) . " was added to medicine breeds successfully";
             break;
         case 'new_medicines_tip':
             $_about = Input::get('about');
             $this->response['console'] .= "Creating new medicine tip...\n";
             $this->response['console'] .= "about :" + $_about + " \n";
             if ($_about == "1") {
                 $about = "Health";
             } elseif ($_about == "2") {
                 $about = "Food";
             } else {
                 $about = "Dosage";
             }
             $mTip = new Tip();
             $mTip->type_id = Input::get('type');
             $mTip->breed_id = Input::get('breed');
             $mTip->about = $about;
             $mTip->content = Input::get('content');
             $this->response['console'] .= $mTip->type_id . " | " . $mTip->breed_id . " | " . $mTip->about . " | " . $mTip->content;
             $mTip->save();
             $this->response['message'] = "New tip was successfully recorded";
             break;
         case 'new_medicine':
             $this->response['console'] .= "Creating new medicine process has started\n";
             $mPet = new Pet();
             if (Input::hasFile('photo')) {
                 $uploadDir = public_path() . "/img/uploads/";
                 $this->response['console'] .= "\tNew image process has started\n";
                 $fileName = sha1(Input::get('name')) . "." . Input::get('ext');
                 $_FILES['photo']['name'] = $fileName;
                 $this->response['console'] .= "\ttmp_name: " . $_FILES['photo']['tmp_name'] . "\n";
                 $this->response['console'] .= "\tsaving to " . $uploadDir . "\n";
                 move_uploaded_file($_FILES["photo"]["tmp_name"], $uploadDir . $_FILES["photo"]["name"]);
                 $mPet->image = $fileName;
             }
             $mPet->name = Input::get('name');
             $mPet->breed_id = Input::get('breed');
             $mPet->appearance_id = Input::get('appearance');
             $mPet->type_id = Input::get('type');
             $mPet->age = Input::get('age');
             $mPet->price = Input::get('price');
             $mPet->description = Input::get('description');
             $mPet->care = Input::get('care');
             $mPet->save();
             $this->response['message'] = "{$mPet->name} was added to the list of medicines successfully";
     }
     return json_encode($this->response);
 }
Exemplo n.º 18
0
 function showEditTypeGeneralRes()
 {
     $displaySysAdmin = new DisplaySysAdmin();
     $survey = new Survey($_SESSION['SUID']);
     $tyd = getFromSessionParams('tyd');
     $content = "";
     if ($tyd != '') {
         //edit
         $type = $survey->getType($tyd);
         $_SESSION['TYD'] = $tyd;
         $content = $displaySysAdmin->displaySuccess(Language::messageTypeChanged(loadvar(SETTING_NAME)));
     } else {
         //add section!
         if (loadvar(SETTING_NAME) != "") {
             $type = new Type();
             $type->setSuid($_SESSION['SUID']);
             $_SESSION['TYD'] = $type->getTyd();
             $content = $displaySysAdmin->displaySuccess(Language::messageTypeAdded(loadvar(SETTING_NAME)));
         }
     }
     $checker = new Checker($_SESSION['SUID']);
     if ($tyd == '') {
         $checks = $checker->checkTypeName(loadvar(SETTING_NAME));
         if (sizeof($checks) > 0) {
             $content = implode("<br/>", $checks);
             return $this->showAddType($content);
         }
     }
     //ADD ALL SORTS OF CHECKS!!
     if ($tyd != '' || loadvar(SETTING_NAME) != "") {
         $type->setName(trim(loadvar(SETTING_NAME)));
         $type->setAnswerType(loadvar(SETTING_ANSWERTYPE));
         $type->setAnswerTypeCustom(loadvar(SETTING_ANSWERTYPE_CUSTOM));
         $type->setOptionsText(loadvarAllowHTML(SETTING_OPTIONS));
         $type->setArray(loadvar(SETTING_ARRAY));
         $type->setKeep(loadvar(SETTING_KEEP));
         $answertype = loadvar(SETTING_ANSWERTYPE);
         if (inArray($answertype, array(ANSWER_TYPE_NONE, ANSWER_TYPE_SECTION))) {
             $type->setHidden(HIDDEN_YES);
         } else {
             $type->setHidden(loadvar(SETTING_HIDDEN));
         }
         if ($type->getInputMask() == "") {
             switch ($answertype) {
                 case ANSWER_TYPE_INTEGER:
                     $type->setInputMask(INPUTMASK_INTEGER);
                     break;
                 case ANSWER_TYPE_DOUBLE:
                     $type->setInputMask(INPUTMASK_DOUBLE);
                     break;
                 case ANSWER_TYPE_RANGE:
                     $type->setInputMask(INPUTMASK_INTEGER);
                     break;
                 default:
                     $type->setInputMask(null);
                     break;
             }
         }
         $type->save();
         $checker = new Checker($_SESSION['SUID']);
         $checks = $checker->checkType($type);
         if (sizeof($checks) > 0) {
             $content .= $displaySysAdmin->displayError(implode("<br/>", $checks));
         }
     }
     /* compile */
     $compiler = new Compiler($_SESSION['SUID'], getSurveyVersion($survey));
     $mess = $compiler->generateTypes(array($type));
     $vars = $survey->getVariableDescriptivesOfType($tyd);
     $mess = $compiler->generateVariableDescriptives($vars);
     $mess = $compiler->generateGetFills($vars);
     $mess = $compiler->generateInlineFields($vars);
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     if ($tyd != '') {
         return $displaySysAdmin->showEditType($_SESSION['TYD'], $content);
     } else {
         return $displaySysAdmin->showSurvey($content);
     }
 }
 public function createAction()
 {
     if (!$this->request->isPost()) {
         return $this->forward("producttypes/index");
     }
     $producttypes = new Type();
     $producttypes->id = $this->request->getPost("id", "int");
     $producttypes->name = $this->request->getPost("name");
     $producttypes->name = strip_tags($producttypes->name);
     if (!$producttypes->save()) {
         foreach ($producttypes->getMessages() as $message) {
             $this->flash->error((string) $message);
         }
         return $this->forward("producttypes/new");
     } else {
         /* $this->flash->success("类型创建成功"); */
         $this->response->redirect("producttypes/search");
     }
 }
Exemplo n.º 20
0
         if (is_array($licenseconsortiumids) && in_array($display['consortiumID'], $licenseconsortiumids) || $_GET['shortName'] == $display['name']) {
             //			if ($_GET['shortName'] == $display['name']){
             echo "<option value='" . $display['consortiumID'] . "' selected>" . $display['name'] . "</option>";
         } else {
             echo "<option value='" . $display['consortiumID'] . "'>" . $display['name'] . "</option>";
         }
     }
     echo "</select>";
     break;
 case 'addType':
     if (isset($_GET['shortName']) && $_GET['shortName'] != '') {
         $type = new Type();
         $type->typeID = '';
         $type->shortName = $_GET['shortName'];
         try {
             $type->save();
         } catch (Exception $e) {
             echo $e->getMessage();
         }
     }
     echo "<select name='licenseTypeID' id='licenseTypeID'>";
     echo "<option value=''></option>";
     $license = new License();
     $display = array();
     foreach ($license->getTypeList() as $display) {
         if ($_GET['shortName'] == $display['name']) {
             echo "<option value='" . $display['typeID'] . "' selected>" . $display['name'] . "</option>";
         } else {
             echo "<option value='" . $display['typeID'] . "'>" . $display['name'] . "</option>";
         }
     }
Exemplo n.º 21
0
 private function setDatesetType($dataset_id, $dataset_types)
 {
     $temp = explode(",", $dataset_types);
     foreach ($temp as $key => $value) {
         $value = trim($value);
         if (strlen($value) > 0) {
             $type = Type::model()->find("name=?", array($value));
             if (!$type) {
                 // Type not found
                 $type = new Type();
                 $type->name = $value;
                 $type->description = "description";
                 $type->save(true);
             }
             $dataset_type = new DatasetType();
             $dataset_type->dataset_id = $dataset_id;
             $dataset_type->type_id = $type->id;
             $dataset_type->save(false);
         }
     }
 }