コード例 #1
0
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id, 'PeKasKeluar');
     if (isset($_POST) && !empty($_POST)) {
         foreach ($_POST as $k => $v) {
             $_POST['PeKasKeluar'][$k] = $v;
         }
         $_POST['PeKasKeluar']['entry_time'] = Yii::app()->dateFormatter->format('yyyy-MM-dd', time());
         $_POST['PeKasKeluar']['users_id'] = Yii::app()->user->getId();
         $_POST['PeKasKeluar']['doc_ref'] = '';
         $model->attributes = $_POST['PeKasKeluar'];
         if ($model->save()) {
             $status = true;
         } else {
             $msg = " " . CHtml::errorSummary($model);
             $status = false;
         }
         if (Yii::app()->request->isAjaxRequest) {
             echo CJSON::encode(array('success' => $status, 'msg' => $msg, 'id' => $model->kas_keluar_id));
             Yii::app()->end();
         } else {
             $this->redirect(array('view', 'id' => $model->kas_keluar_id));
         }
     }
     $this->render('update', array('model' => $model));
 }
コード例 #2
0
ファイル: BansController.php プロジェクト: DmitriyS/CS-Bans
 public function actionUnban($id)
 {
     $ban_model = $this->loadModel($id);
     if (!Webadmins::checkAccess('bans_unban', $ban_model->admin_nick)) {
         throw new CHttpException(403, "У Вас недостаточно прав");
     }
     $history_model = new History();
     $history_model->unsetAttributes();
     $history_model->player_ip = $ban_model->player_ip;
     $history_model->player_id = $ban_model->player_id;
     $history_model->player_nick = $ban_model->player_nick;
     $history_model->admin_ip = $ban_model->admin_ip;
     $history_model->admin_id = $ban_model->admin_id;
     $history_model->admin_nick = $ban_model->admin_nick;
     $history_model->ban_type = $ban_model->ban_type;
     $history_model->ban_reason = $ban_model->ban_reason;
     $history_model->ban_created = $ban_model->ban_created;
     $history_model->ban_length = $ban_model->ban_length;
     $history_model->server_ip = $ban_model->server_ip;
     $history_model->server_name = $ban_model->server_name;
     $history_model->unban_created = time();
     $history_model->unban_reason = 'Разбанен с сайта';
     $history_model->unban_admin_nick = Yii::app()->user->name;
     if ($history_model->save()) {
         if ($ban_model->delete()) {
             Yii::app()->end('Игрок разбанен');
         }
     }
     Yii::app()->end(CHtml::errorSummary($ban_model));
 }
コード例 #3
0
ファイル: OrderController.php プロジェクト: alextravin/yupe
 /**
  *
  */
 public function actionCreate()
 {
     $model = new Order(Order::SCENARIO_USER);
     if (Yii::app()->getRequest()->getIsPostRequest() && Yii::app()->getRequest()->getPost('Order')) {
         $order = Yii::app()->getRequest()->getPost('Order');
         $products = Yii::app()->getRequest()->getPost('OrderProduct');
         $coupons = isset($order['couponCodes']) ? $order['couponCodes'] : [];
         if ($model->store($order, $products, Yii::app()->getUser()->getId(), (int) Yii::app()->getModule('order')->defaultStatus)) {
             if (!empty($coupons)) {
                 $model->applyCoupons($coupons);
             }
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('OrderModule.order', 'The order created'));
             if (Yii::app()->hasModule('cart')) {
                 Yii::app()->getModule('cart')->clearCart();
             }
             //отправить уведомления
             Yii::app()->orderNotifyService->sendOrderCreatedAdminNotify($model);
             Yii::app()->orderNotifyService->sendOrderCreatedUserNotify($model);
             if (Yii::app()->getModule('order')->showOrder) {
                 $this->redirect(['/order/order/view', 'url' => $model->url]);
             }
             $this->redirect(['/store/product/index']);
         } else {
             Yii::app()->getUser()->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, CHtml::errorSummary($model));
         }
     }
     $this->redirect(Yii::app()->getUser()->getReturnUrl($_SERVER['HTTP_REFERER']));
 }
 public function actionIndex()
 {
     // Residents::model()->deleteAll();
     foreach (range(0, 5) as $key => $value) {
         $fakerObj = Faker\Factory::create();
         $model = new Residents('createNewRecord');
         $model->salutation = $fakerObj->title;
         $model->firstname = $fakerObj->firstName;
         $model->lastname = $fakerObj->lastName;
         $model->middle_name = $fakerObj->firstName;
         $model->blood_type = "O";
         $model->house_number = $fakerObj->buildingNumber;
         $model->street_name = $fakerObj->streetName;
         $model->barangay_name = $fakerObj->streetName;
         $model->mobile_phone_number = "0906" . rand(1111111, 9999999);
         $model->town = "Solano";
         $model->province = "Nueva Vizcaya";
         $model->country = "Philippines";
         $model->birthdayYear = date("Y");
         $model->birthdayMonth = date("m");
         $model->birthdayDate = date("d");
         $model->residentSinceYear = date("Y");
         $model->residentSinceMonth = date("m");
         $model->residentSinceDate = date("d");
         $model->employment_type = "Full-time";
         if ($model->save()) {
             echo "New record created \r\n";
         } else {
             echo CHtml::errorSummary($model);
             die;
         }
     }
 }
コード例 #5
0
ファイル: ApiController.php プロジェクト: Eisenheim94/blog
 public function actionCreate()
 {
     //$data = (array)json_decode( file_get_contents('php://input') );
     //echo (var_dump($data));
     $model = new Post();
     $model->setAttributes($this->getJsonInput());
     //$model->setAttributes($data);
     if (!$model->validate()) {
         $this->sendResponse(400, CHtml::errorSummary($model));
     } else {
         if (!$model->save(false)) {
             throw new CException('Cannot create a record');
         }
     }
     $model->refresh();
     echo CJSON::encode($model);
     /*
     		if(isset($_GET['id']))
                 $id=$_GET['id'];
     		$posts = Post::model()->findAllByAttributes(array("author"=>1));
     		foreach($posts as $p) {
     			$author = User::model()->findByPk($p['author']);
     			$p['author'] = $author['name'];
     		}
     		echo CJSON::encode($posts);*/
 }
コード例 #6
0
 public function run($id, $attribute, $que)
 {
     if (Yii::app()->request->isPostRequest) {
         // we only allow deletion via POST request
         $model = $this->controller->loadModel($id);
         $range = Yii::app()->cache->get($que);
         if (empty($range)) {
             throw new CHttpException(400, 'Invalid queuetoggle identificator!!! Check JtoggleColumn settings queueid.');
         }
         $range = explode(',', $range);
         if (!isset($_POST['val'])) {
             $curr = array_search($model->{$attribute}, $range);
             $next = isset($range[$curr + 1]) ? $range[$curr + 1] : $range[0];
             $model->{$attribute} = $next;
         } else {
             $val = $_POST['val'];
             if (!in_array($_POST['val'], $range)) {
                 throw new CHttpException(400, 'Invalid post data');
             }
             $model->{$attribute} = $val;
             if (!$model->validate()) {
                 throw new CHttpException(400, CHtml::errorSummary($model));
             }
         }
         $model->save(false);
         // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
         if (!isset($_GET['ajax'])) {
             $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }
コード例 #7
0
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id, 'PeDonatur');
     if (isset($_POST) && !empty($_POST)) {
         foreach ($_POST as $k => $v) {
             $_POST['PeDonatur'][$k] = $v;
         }
         $msg = "Data gagal disimpan";
         $model->attributes = $_POST['PeDonatur'];
         if ($model->save()) {
             $status = true;
             $msg = "Data berhasil di simpan dengan id " . $model->id;
         } else {
             $msg .= " " . CHtml::errorSummary($model);
             $status = false;
         }
         if (Yii::app()->request->isAjaxRequest) {
             echo CJSON::encode(array('success' => $status, 'msg' => $msg));
             Yii::app()->end();
         } else {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model));
 }
コード例 #8
0
ファイル: UiController.php プロジェクト: dev-lav/htdocs
 public function actionLogin()
 {
     $this->layout = CrugeUtil::config()->loginLayout;
     $model = Yii::app()->user->um->getNewCrugeLogon('login');
     // por ahora solo un metodo de autenticacion por vez es usado, aunque sea un array en config/main
     //
     $model->authMode = CrugeFactory::get()->getConfiguredAuthMethodName();
     Yii::app()->user->setFlash('loginflash', null);
     Yii::log(__CLASS__ . "\nactionLogin\n", "info");
     if (isset($_POST[CrugeUtil::config()->postNameMappings['CrugeLogon']])) {
         $model->attributes = $_POST[CrugeUtil::config()->postNameMappings['CrugeLogon']];
         if ($model->validate()) {
             if ($model->login(false) == true) {
                 Yii::log(__CLASS__ . "\nCrugeLogon->login() returns true\n", "info");
                 // a modo de conocimiento, Yii::app()->user->returnUrl es
                 // establecida automaticamente por CAccessControlFilter cuando
                 // preFilter llama a accessDenied quien a su vez llama a
                 // CWebUser::loginRequired que es donde finalmente se llama a setReturnUrl
                 $this->redirect(Yii::app()->user->returnUrl);
             } else {
                 Yii::app()->user->setFlash('loginflash', Yii::app()->user->getLastError());
             }
         } else {
             Yii::log(__CLASS__ . "\nCrugeUser->validate es false\n" . CHtml::errorSummary($model), "error");
         }
     }
     $this->render('login', array('model' => $model));
 }
 protected function setUp()
 {
     $firstProduct = new Product();
     $firstProduct->name = "wooden chair 2x";
     $firstProduct->description = "a wooden chair made of wood";
     $firstProduct->quantity = 50;
     $firstProduct->price = 3000;
     $firstProduct->sku = uniqid();
     if (!$firstProduct->save()) {
         throw new Exception(CHtml::errorSummary($firstProduct));
     } else {
         $this->productModels[] = $firstProduct;
     }
     $secondProduct = new Product();
     $secondProduct->name = "wooden chair 3x";
     $secondProduct->description = "a wooden chair made of wood but with color";
     $secondProduct->quantity = 60;
     $secondProduct->price = 4000;
     $secondProduct->sku = uniqid();
     if (!$secondProduct->save()) {
         throw new Exception(CHtml::errorSummary($secondProduct));
     } else {
         $this->productModels[] = $secondProduct;
     }
     /*create  product model*/
     parent::setUp();
 }
コード例 #10
0
ファイル: UsuarioController.php プロジェクト: Telemedellin/tm
 public function actionIngresar()
 {
     if (Yii::app()->user->hasFlash('backto')) {
         $backto = Yii::app()->user->getFlash('backto');
         Yii::app()->user->setFlash('backto', null);
         Yii::app()->user->setFlash('backto', $backto);
     } else {
         $backto = 'usuario/perfil';
     }
     if (!Yii::app()->user->isGuest) {
         $this->redirect(bu($backto));
     }
     $model = Yii::app()->user->um->getNewCrugeLogon('login');
     $model->authMode = CrugeFactory::get()->getConfiguredAuthMethodName();
     Yii::app()->user->setFlash('loginflash', null);
     Yii::log(__CLASS__ . "\nactionLogin\n", "info");
     if (isset($_POST[CrugeUtil::config()->postNameMappings['CrugeLogon']])) {
         $model->attributes = $_POST[CrugeUtil::config()->postNameMappings['CrugeLogon']];
         if ($model->validate()) {
             if ($model->login(false) == true) {
                 Yii::log(__CLASS__ . "\nCrugeLogon->login() returns true\n", "info");
                 // a modo de conocimiento, Yii::app()->user->returnUrl es
                 // establecida automaticamente por CAccessControlFilter cuando
                 // preFilter llama a accessDenied quien a su vez llama a
                 // CWebUser::loginRequired que es donde finalmente se llama a setReturnUrl
                 $this->redirect(bu($backto));
             } else {
                 Yii::app()->user->setFlash('loginflash', Yii::app()->user->getLastError());
             }
         } else {
             Yii::log(__CLASS__ . "\nCrugeUser->validate es false\n" . CHtml::errorSummary($model), "error");
         }
     }
     $this->render('ingresar', array('model' => $model));
 }
コード例 #11
0
 /**
  * Append an array of items
  * Used on install, import
  *
  * @param $items
  * @param $class
  * @return int
  */
 public function appendFromArray($items, $class, &$error = '')
 {
     $imported = 0;
     $error = '';
     if (!empty($items)) {
         foreach ($items as $item) {
             $model = new $class();
             $model->setAttributes($item, false);
             if ($model->hasAttribute('labels') && is_string($model->labels)) {
                 //maybe on import: labels assigned as string
                 $model->labels = array(Yii::app()->language => $model->labels);
             }
             if ($model->hasAttribute('titles') && is_string($model->titles)) {
                 //maybe on import: titles assigned as string
                 $model->titles = array(Yii::app()->language => $model->titles);
             }
             $saved = $model->save();
             if ($saved) {
                 $imported++;
             } else {
                 $error = $class . ' [RecNo ' . ($imported + 1) . '] ' . CHtml::errorSummary($model);
                 return $imported;
             }
         }
     }
     return $imported;
 }
コード例 #12
0
 public function actionCreateAjaxMenuitem()
 {
     // if insert
     if (isset($_POST['Menuitem'])) {
         $model = new Menuitem();
         $model->attributes = $_POST['Menuitem'];
         // if insert without ajax / javascript is disabled
         if (!Yii::app()->request->isAjaxRequest) {
             if ($model->save()) {
                 $message = "<strong>Well done!</strong> You successfully Add New Menu";
                 Yii::app()->user->setFlash('info', $message);
             } else {
                 $message = CHtml::errorSummary($model);
                 Yii::app()->user->setFlash('error', $message);
             }
             $this->redirect(array('admin', 'id' => $model->term_id));
         }
         // if insert with ajax / javascript is enable
         if ($model->save()) {
             exit(json_encode(array('result' => 'success', 'term_id' => $model->term_id, 'name' => $model->meta_key, 'msg' => 'Your menu has been successfully saved')));
         } else {
             exit(json_encode(array('result' => 'failed', 'msg' => CHtml::errorSummary($model))));
         }
     } else {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
 }
コード例 #13
0
 public function actionAjaxPersona()
 {
     $model = new Persona();
     if (Yii::app()->request->isAjaxRequest) {
         $post = trim(file_get_contents('php://input'));
         //por ejemplo traeria: "cedula=123&nombre=aasas&apellido=aaa"
         // como lo sabemos ? simple: Yii::log("POST=".$post,"info");
         // ahora los pasamos a un array con forma key=>value
         // para que model->attributes los acepte:
         $attributes = array();
         foreach (explode("&", $post) as $item) {
             $att = explode("=", $item);
             $attributes[$att[0]] = $att[1];
         }
         // listo hemos convertido el string post a un array indexado:
         // var_export($attributes,true) mostraria:
         //  array ( 'cedula' => '123', 'nombre' => 'aasas', 'apellido' => 'aaa', )
         $model->attributes = $attributes;
         if ($model->validate()) {
             // ok todo bien, haces algo aqui con el modelo...
             // como es un ejemplo no haremos nada mas que informar.
             return;
         } else {
             // si defined('YII_DEBUG') or define('YII_DEBUG',true);
             // es TRUE por defecto, ver /index.php
             // entonces la excepcion mostrara un codigo horrible,
             // pero si la ponemos en FALSE, entonces solo mostrara
             // el errorSummary, lo cual es deseable.
             throw new Exception(CHtml::errorSummary($model));
         }
     }
 }
コード例 #14
0
 public function saveModel()
 {
     if (!$this->save()) {
         yii::app()->user->setFlash('error', CHtml::errorSummary($this));
         return false;
     }
     return true;
 }
コード例 #15
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $leadsAndStatusDataProvider = new LeadsStatusDataProvider();
     // $leadsAndStatusDataProvider = new LeadsStatusUrlDataProvider();
     $chartDataObj = new ChartDataProvider($leadsAndStatusDataProvider->data);
     $chartDataProvider = $chartDataObj->getData();
     /* client data */
     $clientVb = Yii::app()->askteriskDb->createCommand("select * from client_panel")->queryAll();
     $clientj6 = Yii::app()->askteriskDb->createCommand("select * from clientj6_sec_today")->queryAll();
     $clientj6 = $clientj6[0];
     $_5CXFER = Yii::app()->askteriskDb->createCommand("select * from `5cxfer_today`")->queryRow();
     $criteria = new CDbCriteria();
     $criteria->order = "date_created DESC";
     $currentBalance = BalanceLog::model()->find($criteria);
     $updatedInitBalance = 300;
     foreach ($clientVb as $key => $value) {
         if ($currentBalance) {
             $updatedInitBalance = $currentBalance->current_balance;
         } else {
             $currentBalance->current_balance = 300;
             $currentBalance->save();
         }
         $tempContainer = $clientVb[$key];
         $tempContainer['raw_seconds'] = doubleval($value['seconds']) + doubleval($clientj6['seconds']);
         $tempContainer['id'] = uniqid();
         $tempContainer['total'] = doubleval($tempContainer['raw_seconds']) / 60 * doubleval($value['ppminc']);
         $tempContainer['balance'] = doubleval($updatedInitBalance);
         $tempContainer['balance'] -= doubleval($tempContainer['total']);
         $tempContainer['total'] = '£ ' . sprintf("%.2f", $tempContainer['total']);
         $tempContainer['balance'] = '£ ' . sprintf("%.2f", $tempContainer['balance']);
         $tempContainer['raw_seconds'] = doubleval($value['seconds']) + doubleval($clientj6['seconds']);
         $tempContainer['hours'] = intval($tempContainer['raw_seconds'] / (60 * 60));
         $tempContainer['minutes'] = intval($tempContainer['raw_seconds'] / 60);
         $tempContainer['seconds'] = intval($tempContainer['raw_seconds'] % 60);
         // $tempContainer['cxfer']  = $_5CXFER['generated'];
         $tempContainer['cxfer'] = BarryOptLog::getCountToday();
         $clientVb[$key] = $tempContainer;
     }
     /*compute the total*/
     /*file uploaded*/
     $fileUploadedObj = new ClientUploadedData();
     $fileUploadedArr = $fileUploadedObj->getListUploaded();
     /*export range form*/
     $exportModel = new ExportRangeForm();
     $exportModel->unsetAttributes();
     if (isset($_POST['ExportRangeForm'])) {
         $exportModel->attributes = $_POST['ExportRangeForm'];
         if ($exportModel->validate()) {
             $this->redirect(array("/export/range", "dateFrom" => $exportModel->date_from, "dateTo" => $exportModel->date_to));
         } else {
             Yii::app()->user->setFlash("error", CHtml::errorSummary($exportModel));
             $this->redirect(array('/site/index'));
         }
     }
     $this->render('index', compact('clientVb', 'fileUploadedArr', 'exportModel', 'leadsAndStatusDataProvider', 'chartDataProvider'));
 }
コード例 #16
0
 public function save()
 {
     /*saves the data in the db*/
     $newMainAccount = new MainAccount();
     $newMainAccount->attributes = $this->attributes;
     if (!$newMainAccount->save()) {
         throw new Exception("Sorry cant save new Main account . Reason : " . CHtml::errorSummary($newMainAccount));
     }
     return $newMainAccount;
 }
コード例 #17
0
ファイル: YiicmsHelper.php プロジェクト: vangogogo/justsns
 public static function error($message, $type = 'error', $notification = 'true', $forwardUrl = '', $callbackType = 'closeCurrent')
 {
     if ($message instanceof CModel) {
         if ($message->hasErrors()) {
             $message = preg_replace("/\n/", '', CHtml::errorSummary($message));
         } else {
             $message = '';
         }
     }
     YiicmsHelper::responseAjax($message, $type, $notification, $forwardUrl, $callbackType);
 }
コード例 #18
0
 public function getJSClassParams()
 {
     if (!isset($this->_JSClassParams)) {
         $title = X2Model::getModelTitle(get_class($this->model), true);
         $targetClass = $this->targetClass;
         $behavior = $this->model->asa('X2ModelConversionBehavior');
         $conversionFailed = $behavior->conversionFailed && $behavior->errorModel !== null && get_class($behavior->errorModel) === $this->targetClass;
         $this->_JSClassParams = array_merge(parent::getJSClassParams(), array('buttonSelector' => $this->buttonSelector, 'translations' => array('conversionError' => Yii::t('app', '{model} conversion failed.', array('{model}' => $title)), 'conversionWarning' => Yii::t('app', '{model} Conversion Warning', array('{model}' => $title)), 'convertAnyway' => Yii::t('app', 'Convert Anyway'), 'Cancel' => Yii::t('app', 'Cancel')), 'targetClass' => $this->targetClass, 'modelId' => $this->model->id, 'conversionFailed' => $conversionFailed, 'conversionIncompatibilityWarnings' => $this->model->getConversionIncompatibilityWarnings($this->targetClass), 'errorSummary' => $conversionFailed ? "<div class='form'>" . CHtml::errorSummary($this->model->asa('X2ModelConversionBehavior')->errorModel, Yii::t('app', '{model} conversion failed.', array('{model}' => $title))) . "</div>" : ''));
     }
     return $this->_JSClassParams;
 }
コード例 #19
0
 public function run()
 {
     Yii::import('site.common.modules.hotel.models.*');
     $hotelForm = new HotelForm();
     if (isset($_REQUEST['HotelForm'])) {
         $hotelForm->attributes = $_REQUEST['HotelForm'];
         $rooms = array();
         if (isset($_REQUEST['HotelRoomForm'])) {
             foreach ($_REQUEST['HotelRoomForm'] as $i => $info) {
                 $room = new HotelRoomForm();
                 $room->attributes = $info;
                 if ($room->validate()) {
                     $rooms[] = $room;
                 }
             }
         }
         $hotelForm->rooms = $rooms;
         if ($hotelForm->validate()) {
             $hotelSearchParams = new HotelSearchParams();
             $hotelSearchParams->checkIn = date('Y-m-d', strtotime($hotelForm->fromDate));
             $hotelSearchParams->city = City::getCityByPk($hotelForm->cityId);
             $hotelSearchParams->duration = $hotelForm->duration;
             foreach ($hotelForm->rooms as $room) {
                 if ($room->childCount == 1) {
                     $hotelSearchParams->addRoom($room->adultCount, $room->cots, $room->childAge);
                 } else {
                     $hotelSearchParams->addRoom($room->adultCount, $room->cots, false);
                 }
             }
             $HotelClient = new HotelBookClient();
             $pCacheId = md5(serialize($hotelSearchParams));
             Yii::app()->pCache->set('hotelSearchParams' . $pCacheId, $hotelSearchParams, appParams('hotel_search_cache_time'));
             $resultSearch = $HotelClient->fullHotelSearch($hotelSearchParams);
             Yii::app()->hotelsRating->injectRating($resultSearch->hotels, $hotelSearchParams->city);
             $cacheId = substr(md5(uniqid('', true)), 0, 10);
             Yii::app()->cache->set('hotelResult' . $cacheId, $resultSearch, appParams('hotel_search_cache_time'));
             Yii::app()->cache->set('hotelSearchParams' . $cacheId, $hotelSearchParams, appParams('hotel_search_cache_time'));
             Yii::app()->cache->set('hotelForm' . $cacheId, $hotelForm, appParams('hotel_search_cache_time'));
             if ($resultSearch['hotels']) {
                 $hotelStack = new HotelStack($resultSearch);
                 $results = $hotelStack->groupBy('hotelId')->groupBy('roomSizeId')->groupBy('rubPrice')->sortBy('rubPrice', 2)->getJsonObject();
                 echo json_encode(array('pCacheId' => $pCacheId, 'cacheId' => $cacheId, 'hotels' => $results));
             } else {
                 echo json_encode(array('cacheId' => $cacheId, 'hotels' => array()));
             }
         } else {
             //invalid form
             throw new CHttpException(500, CHtml::errorSummary($hotelForm));
         }
         Yii::app()->end();
     } else {
         throw new CHttpException(404);
     }
 }
コード例 #20
0
 public function store()
 {
     $ret = false;
     if ($this->getIsNewRecord()) {
         $ret = $this->insert();
     } else {
         $ret = $this->update();
     }
     Yii::log(__CLASS__ . "::store() #" . $this->getPrimaryKey() . "\nresult=" . $ret . "\nerrorinfo:" . CHtml::errorSummary($this) . "\n" . "json: " . CJSON::encode($this) . "\n", "info");
     return $ret;
 }
コード例 #21
0
ファイル: WidgetController.php プロジェクト: hung5s/yap
 public function actionEnable($id)
 {
     $widget = CmsWidget::model()->findByPk($id);
     if ($widget) {
         $widget->status = $widget->status ? false : true;
         if (!$widget->update('status')) {
             echo CHtml::errorSummary($widget);
         }
     } else {
         throw new XException('Widget is not found or not installed.', 1);
     }
 }
コード例 #22
0
 public function actionCreateCollege()
 {
     $model = new College();
     if (isset($_POST['name'])) {
         $model->attributes = $_POST;
         if ($model->save()) {
             echo "ok";
         } else {
             echo CHtml::errorSummary($model);
         }
     }
 }
コード例 #23
0
ファイル: TwitterApp.php プロジェクト: keyeMyria/CRM
 public function renderInputs()
 {
     $this->attributes = array('oauthAccessToken' => null, 'oauthAccessTokenSecret' => null, 'consumerKey' => null, 'consumerSecret' => null);
     echo CHtml::activeLabel($this, 'consumerKey');
     $this->renderInput('consumerKey');
     echo CHtml::activeLabel($this, 'consumerSecret');
     $this->renderInput('consumerSecret');
     echo CHtml::activeLabel($this, 'oauthAccessToken');
     $this->renderInput('oauthAccessToken');
     echo CHtml::activeLabel($this, 'oauthAccessTokenSecret');
     $this->renderInput('oauthAccessTokenSecret');
     echo CHtml::errorSummary($this);
 }
コード例 #24
0
ファイル: SiteController.php プロジェクト: Bodya91/yii-rest
 public function actionLogin()
 {
     $model = new LoginForm();
     $model->attributes = $_POST;
     if ($model->validate()) {
         if (!$model->login()) {
             throw new CException('Cannot login user');
         }
         $this->sendResponse(200, JSON::encode(Yii::app()->user));
     } else {
         $this->sendResponse(400, CHtml::errorSummary($model, false));
     }
 }
コード例 #25
0
 public function actionResume($id, $start = 1)
 {
     $model = $this->loadModel($id);
     if (!$model->resume()) {
         Yii::app()->user->setFlash('server', Yii::t('mc', 'Server resume failed: ') . CHtml::errorSummary($model));
     } else {
         if ($start) {
             McBridge::get()->serverCmd($id, 'start');
         }
         Yii::app()->user->setFlash('server', Yii::t('mc', 'Server resumed'));
     }
     $this->redirect(array('view', 'id' => $model->id));
 }
コード例 #26
0
 public function actionIndex()
 {
     if (Yii::app()->request->isPostRequest) {
         $mainFormHelper = new MainFormHelper();
         $mainLeadObj = $mainFormHelper->setFormValToObj($_POST);
         $mainLeadObj->user_id = Yii::app()->user->id;
         if ($mainLeadObj->save()) {
             Yii::app()->user->setFlash("success", "Success! Lead saved");
         } else {
             Yii::app()->user->setFlash("error", CHtml::errorSummary($mainLeadObj));
         }
     }
     $this->redirect(array('/site/index'));
 }
コード例 #27
0
ファイル: MandrillAccount.php プロジェクト: dsyman2/X2CRM
 public function renderInputs()
 {
     $this->password = null;
     echo CHtml::activeLabel($this, 'senderName');
     $this->renderInput('senderName');
     echo CHtml::activeLabel($this, 'email');
     $this->renderInput('email');
     echo CHtml::activeLabel($this, 'user');
     $this->renderInput('user');
     echo CHtml::activeLabel($this, 'password');
     $this->renderInput('password');
     echo '<br/>';
     echo CHtml::errorSummary($this);
 }
コード例 #28
0
ファイル: BansController.php プロジェクト: BroneKot/CS-Bans
 public function actionUnban($id)
 {
     $model = $this->loadModel($id);
     // Проверка прав
     if (!Webadmins::checkAccess('bans_unban', $model->admin_nick)) {
         throw new CHttpException(403, "У Вас недостаточно прав");
     }
     $model->ban_length = '-1';
     $model->expired = 1;
     if ($model->save(FALSE)) {
         Yii::app()->end('Игрок разбанен');
     }
     Yii::app()->end(CHtml::errorSummary($model));
 }
コード例 #29
0
ファイル: EventController.php プロジェクト: Bodya91/yii-rest
 public function actionUpdate($id)
 {
     if (null === ($model = Event::model()->findByPk($id))) {
         throw new CHttpException(404);
     }
     $model->setAttributes($this->getJsonInput());
     if (!$model->validate()) {
         $this->sendResponse(400, CHtml::errorSummary($model));
     } else {
         if (!$model->save(false)) {
             throw new CException('Cannot update a record');
         }
     }
     $model->refresh();
     $this->sendResponse(200, CJSON::encode($model));
 }
コード例 #30
0
 public function actionFiniquitar($id)
 {
     $modelo = Contrato::model()->findByPk($id);
     //fix bug que había por propiedad dependiente
     $modelo->propiedad_id = $modelo->departamento->propiedad_id;
     //end fix
     $modelo->vigente = 0;
     $modelo->fecha_finiquito = date('Y-m-d');
     if ($modelo->save()) {
         Yii::app()->user->setFlash('success', 'Contrato finiquitado correctamente.');
         $this->redirect(CController::createUrl('//contrato/admin'));
     } else {
         Yii::app()->user->setFlash('error', 'ERROR: No se pudo finiquitar el contrato: ' . CHtml::errorSummary($modelo));
         $this->redirect(CController::createUrl('//contrato/admin'));
     }
 }