/** * Displays the login page */ public function actionLogin() { if (Yii::app()->user->isGuest) { $model = new UserLogin(); // collect user input data if (isset($_POST['UserLogin'])) { $model->attributes = $_POST['UserLogin']; // validate user input and redirect to previous page if valid if ($model->validate()) { $this->lastViset(); if (Yii::app()->user->returnUrl == '/index.php') { $this->redirect(Yii::app()->controller->module->returnUrl); } else { if (isAdmin()) { $this->redirect(PIUrl::createUrl('/admin')); } $this->redirect(Yii::app()->user->returnUrl); } } } // display the login form $this->render('/user/login', array('model' => $model)); } else { if (isAdmin()) { $this->redirect(PIUrl::createUrl('/admin')); } $this->redirect(Yii::app()->controller->module->returnUrl); } }
public function actionIndex() { if (!empty($_POST)) { $images = CUploadedFile::getInstancesByName('images'); if (isset($images) && count($images) > 0) { // go through each uploaded image foreach ($images as $image => $pic) { $model = new Images(); $imageType = explode('.', $pic->name); $imageType = $imageType[count($imageType) - 1]; $imageName = md5(uniqid()) . '.' . $imageType; if ($pic->saveAs(Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName)) { $model->image = $imageName; $model->name = $pic->name; $model->created = time(); $model->save(); Yii::app()->user->setFlash('success', translate('Thêm thành công.')); } // handle the errors here, if you want } } $this->redirect(PIUrl::createUrl('/admin/images/index/')); } $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; $count = Images::model()->count($criteria); $pages = new CPagination($count); // results per page $pages->pageSize = 18; $pages->applyLimit($criteria); $model = Images::model()->findAll($criteria); $this->render('index', compact('model', 'pages')); }
public function actionIndex() { $model = Teachers::model()->find(); $flag = 0; $flag1 = 0; if (!empty($_POST['Teachers'])) { $image1_old = $model->attributes['image1']; if (!empty(CUploadedFile::getInstance($model, 'image1')->name)) { $image1_old = $model->attributes['image1']; $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image1_old); if (file_exists($path) && !empty($image1_old)) { unlink($path); } $model->attributes = $_POST['Teachers']; $model->image1 = CUploadedFile::getInstance($model, 'image1'); $image = $model->image1; $imageType = explode('.', $model->image1->name); $imageType = $imageType[count($imageType) - 1]; $imageName = md5(uniqid()) . '.' . $imageType; $model->image1 = $imageName; $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName; $flag = 1; } else { $model->image1 = $image1_old; $model->attributes = $_POST['Teachers']; } $image2_old = $model->attributes['image2']; if (!empty(CUploadedFile::getInstance($model, 'image2')->name)) { $image2_old = $model->attributes['image2']; $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image2_old); if (file_exists($path) && !empty($image2_old)) { unlink($path); } $model->image2 = CUploadedFile::getInstance($model, 'image2'); $image1 = $model->image2; $imageType = explode('.', $model->image2->name); $imageType = $imageType[count($imageType) - 1]; $imageName = md5(uniqid()) . '.' . $imageType; $model->image2 = $imageName; $images_path1 = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName; $flag1 = 1; } else { $model->image2 = $image2_old; $model->attributes = $_POST['Teachers']; } if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhật thành công.')); if ($flag == 1) { $image->saveAs($images_path); } if ($flag1 == 1) { $image1->saveAs($images_path1); } $this->redirect(PIUrl::createUrl('/admin/teachers')); } } $this->render('index', array('model' => $model)); }
public function actionDelete($id, $is_product) { $model = $this->loadModel($id); $path = "/../upload/images/"; $name = $model->image; $this->unlink($path, $name); $model->delete(); Yii::app()->user->setFlash('success', translate('Xóa thành công.')); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser $this->redirect(PIUrl::createUrl('/admin/slides/index', array('is_product' => $is_product))); }
public function actionUpdate($id = null) { $model = Videos::model()->findByPk($id); if (isset($_POST['Videos'])) { $model->attributes = $_POST['Videos']; if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhập thành công.')); $this->redirect(PIUrl::createUrl('/admin/videos/index')); } } $this->render('update', array('model' => $model)); }
public function actionIndex() { $model = Links::model()->find(); if (!empty($_POST['Links'])) { $model->attributes = $_POST['Links']; if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhật thành công.')); $this->redirect(PIUrl::createUrl('/admin/links')); } } $this->render('index', array('model' => $model)); }
public function actionUpdate($id = null) { $model = Provinces::model()->findByPk($id); $flag = 0; if (!empty($_POST['Provinces'])) { $model->attributes = $_POST['Provinces']; if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhập thành công.')); $this->redirect(PIUrl::createUrl('/admin/provinces/')); } } $this->render('update', array('model' => $model)); }
public function actionUpdate($id = null) { $model = GroupSupport::model()->findByPk($id); if (isset($_POST['GroupSupport'])) { $model->attributes = $_POST['GroupSupport']; $model->created = time(); if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhập nhóm hổ trợ thành công.')); $this->redirect(PIUrl::createUrl('/admin/groupSupport/index')); } } $this->render('update', array('model' => $model)); }
public function actionCreate() { $model = new QuestionAnswers(); if (isset($_POST['QuestionAnswers'])) { $model->attributes = $_POST['QuestionAnswers']; $model->created = time(); if ($model->save()) { Yii::app()->user->setFlash('success', translate('Thêm thành công.')); $this->redirect(PIUrl::createUrl('/admin/questionAnswers/index')); } } $this->render('create', array('model' => $model)); }
public function actionUpdate($id = null) { $model = Wards::model()->findByPk($id); if (!empty($_POST['Wards'])) { $model->attributes = $_POST['Wards']; $model->province_id = $_POST['Wards']['province_id']; if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhập thành công.')); $this->redirect(PIUrl::createUrl('/admin/Wards/')); } } $dataProvinces = Provinces::model()->getData(); $this->render('update', array('model' => $model, 'dataProvinces' => $dataProvinces)); }
public function actionUpdate($id = null) { $model = ProductCategory::model()->findByPk($id); if (isset($_POST['ProductCategory'])) { $model->attributes = $_POST['ProductCategory']; $model->updated = time(); $model->type = $id; if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhập thành công.')); $this->redirect(PIUrl::createUrl('/admin/productCategory/index', array('id' => $id))); } } $this->render('update', array('model' => $model)); }
public function actionUpdate($id = null) { $model = Supports::model()->findByPk($id); if ($model === null) { throw new CHttpException('404', 'Không tìm thấy trang.'); } if (isset($_POST['Supports'])) { $model->attributes = $_POST['Supports']; if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhập thành công.')); $this->redirect(PIUrl::createUrl('/admin/support/index')); } } $this->render('update', array('model' => $model)); }
public function actionDelete($id) { $model = Slides::model()->findByPk($id); if ($model == null) { $this->redirect(PIUrl::createUrl('/admin/slides/index/')); } $name = $model->attributes['image']; $this->loadModel($id)->delete(); if (file_exists(Yii::app()->basePath . '/upload/images/' . $name) && $name->image != '') { unlink(Yii::app()->basePath . '/upload/images/' . $name); } Yii::app()->user->setFlash('success', translate('Xóa thành công.')); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser $this->redirect(PIUrl::createUrl('/admin/slides')); }
public function actionUpdate($id = null) { $model = CategoriesNews::model()->findByPk($id); if (isset($_POST['CategoriesNews'])) { $model->attributes = $_POST['CategoriesNews']; $model->created = time(); if (!empty($_POST['CategoriesNews']['parent_id'])) { $model->parent_id = $_POST['CategoriesNews']['parent_id']; } else { $model->parent_id = 0; } if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhập thành công.')); $this->redirect(PIUrl::createUrl('/admin/categoriesNews/index')); } } $arrCate = CategoriesNews::model()->getDataCategories1(); $this->render('update', array('model' => $model, 'arrCate' => $arrCate)); }
public function actionIndex($id = 0) { $model = Informations::model()->findByPK($id); if (empty($model)) { $model = new Informations(); } $flag = 0; if (!empty($_POST['Informations'])) { if (!empty(CUploadedFile::getInstance($model, 'image')->name)) { $image_old = $model->attributes['image']; $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image_old); if (file_exists($path) && !empty($image_old)) { unlink($path); } $model->attributes = $_POST['Informations']; $model->image = CUploadedFile::getInstance($model, 'image'); $image = $model->image; $imageType = explode('.', $model->image->name); $imageType = $imageType[count($imageType) - 1]; $imageName = md5(uniqid()) . '.' . $imageType; $model->image = $imageName; $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName; $flag = 1; } else { $arr = $_POST['Informations']; $model->attributes = $arr; } $model->created = time(); $model->alias = alias($_POST['Informations']['name']); if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhật thành công.')); if ($flag == 1) { $image->saveAs($images_path); } if ($id != 0) { $this->redirect(PIUrl::createUrl('/admin/informations/', array('id' => $id))); } else { $this->redirect(PIUrl::createUrl('/admin/informations/')); } } } $this->render('index', array('model' => $model)); }
<span class="divider"> <i class="icon-angle-right arrow-icon"></i> </span> </li> <li class="active"><?php echo translate('Quản lý đơn hàng'); ?> </li> </ul> </div> <div class="page-content"> <div class="page-header position-relative"> <h1>Chi tiết đơn hàng</h1> </div><!--/.page-header--> <a href="<?php echo PIUrl::createUrl('/admin/bill/'); ?> " class="btn btn-primary"> <i class="icon-ok bigger-110"></i> <?php echo translate('Quay lại'); ?> </a> <div class="row-fluid"> <div class="span12"> <form method="post"> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'billDetail-grid', 'dataProvider' => $model->search($id), 'filter' => $model, 'htmlOptions' => array(), 'itemsCssClass' => 'table table-striped table-bordered table-hover', 'emptyText' => 'Không có kết quả hiển thị', 'selectableRows' => 2, 'summaryText' => 'Hiển thị {start} - {end} của {count} kết quả ', 'columns' => array(array('header' => 'STT', 'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)'), 'product.name' => array('name' => 'product_id', 'type' => 'raw', 'value' => 'isset($data->product->name) ? $data->product->name : ""', 'filter' => false), 'number' => array('name' => 'number', 'type' => 'raw', 'filter' => false, 'value' => '$data->number'), 'price' => array('name' => 'price', 'type' => 'raw', 'filter' => false, 'value' => '$data->price')))); ?> </form> </div><!--/.span-->
?> > <a href="<?php echo PIUrl::createUrl('/admin/comments'); ?> "> <i class="icon-edit"></i> <span class="menu-text"> Thư liên hệ </span> </a> </li> <?php if (isset($_GET['qtmax'])) { ?> <li> <a href="<?php echo PIUrl::createUrl('/admin/categoriesNews', array('qtmax' => 1)); ?> "> <i class="icon-edit"></i> <span class="menu-text"> Danh mục bài viết </span> </a> </li> <?php } ?> </ul><!--/.nav-list--> <div class="sidebar-collapse" id="sidebar-collapse"> <i class="icon-double-angle-left"></i> </div> </div>
<?php $this->endWidget(); ?> </div><!--/.span--> </div><!--/.row-fluid--> </div><!--/.page-content--> </div><!--/.main-content--> <script> $(document).ready(function(){ $(".provinces").change(function(){ var id = $(this).val(); $.ajax({ url : "<?php echo PIUrl::createUrl('/admin/hotel/getWards'); ?> "+"?id="+id, dataType : "json", success : function(result){ var data = ""; for(i=0; i<result.length; i++){ data+="<option value='" + result[i].id +"'>" +result[i].title + "</option>"; } $(".wards").html(data); }, }); }); $("#submitForm").click(function(){ var cateNew = $(".typeHotel").val()
</div><!--/.span--> </div><!--/.row-fluid--> </div><!--/.page-content--> </div><!--/.main-content--> <style> .grid-view .filters input, .grid-view .filters select { width: 95%; } .btn-info{margin-right:3px;} input[type="checkbox"]{opacity:1;} .select-on-check-all{ margin-top:-7.3px !important; } </style> <script> $("document").ready(function(){ $(".deleteAll").live('click', function(){ var arrIdNew = $("#categriesnews-grid").yiiGridView('getSelection'); if(arrIdNew != ""){ var answer = confirm ("Bạn có muốn xóa các tin tức được chọn không?"); if(answer){ var arrIdNew = $("#categriesnews-grid").yiiGridView('getSelection'); var url = '<?php echo PIUrl::createUrl("/admin/support/deleteAll/id"); ?> '; url+= '/'+arrIdNew; window.location.href = url; } } }); }) </script>
echo $key; ?> "><?php echo $value; ?> </option> <?php } } ?> </select> </div> </div> </div> <?php $this->widget('ext.xupload.XUpload', array('url' => PIUrl::createUrl('/admin/images/upload'), 'model' => $model, 'attribute' => 'file', 'multiple' => true)); ?> </div> <style> #XUploadForm-form .row{margin-left:0} #XUploadForm-form .fileinput-button{margin-right:4px;} </style> </div> </div> <!--.span--> </div><!--/.row-fluid--> </div><!--/.page-content--> </div><!--/.main-content--> <script src="<?php echo Yii::app()->theme->baseUrl; ?>
public function actionDelImage($id, $typeId) { $model = Images::model()->findByPk($id); $name = $model->attributes['image']; if ($this->loadModel($id)->delete() && $name != '' && file_exists(Yii::app()->basePath . '/../upload/images/' . $name)) { unlink(Yii::app()->basePath . '/../upload/images/' . $name); } Yii::app()->user->setFlash('success', translate('Xóa thành công.')); if ($typeId == Images::$IMAGE_PATNER) { $this->redirect(PIUrl::createUrl('/admin/images/patner')); } elseif ($typeId == Images::$IMAGE_BANNER) { $this->redirect(PIUrl::createUrl('/admin/images/banner')); } else { $this->redirect(PIUrl::createUrl('/admin/images/index')); } // 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('index')); } }
public function actionUpdate($id = null) { $model = News::model()->findByPk($id); $flag = 0; $image_old = $model->attributes['image']; if (!empty($_POST['News'])) { if (!empty(CUploadedFile::getInstance($model, 'image')->name)) { $image_old = $model->attributes['image']; $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image_old); if (file_exists($path) && !empty($image_old)) { unlink($path); } $model->attributes = $_POST['News']; $model->image = CUploadedFile::getInstance($model, 'image'); $image = $model->image; $imageType = explode('.', $model->image->name); $imageType = $imageType[count($imageType) - 1]; $imageName = md5(uniqid()) . '.' . $imageType; $model->image = $imageName; $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName; $flag = 1; } else { $model->attributes = $_POST['News']; $model->image = $image_old; } $model->created = time(); $model->alias = alias($_POST['News']['name']); if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhật thành công.')); if ($flag == 1) { $image->saveAs($images_path); } $this->redirect(PIUrl::createUrl('/admin/news/' . $model->category_news_id)); } } $dataCategories = CategoriesNews::model()->getDataCategories(); $this->render('update', array('model' => $model, 'dataCategories' => $dataCategories)); }
</li> <li> <a href="<?php echo PIUrl::createUrl('user/profile/changepassword'); ?> "> <i class="icon-user"></i> <?php echo translate('Mật khẩu'); ?> </a> </li> <li> <a href="<?php echo PIUrl::createUrl('/user/logout'); ?> "> <i class="icon-off"></i> <?php echo translate('Đăng xuất'); ?> </a> </li> </ul> </li> </ul><!--/.ace-nav--> </div><!--/.container-fluid--> </div><!--/.navbar-inner--> </div>
?> </select> </div> <div class="span4"> <input type="file" class="id-input-file-1" id="id-input-file-1" name="Documents[filename][]"/> </div> </div> <div class="form-actions"> <button type="button" class="btn btn-purple btn-button-add-row"><i class="icon-plus bigger-110"></i> Thêm dòng</button> <button class="btn btn-primary" id="submitForm" type="submit"><i class="icon-ok bigger-110"></i><?php echo translate('Lưu thông tin'); ?> </button> <button type="button" onclick="location.href='<?php echo PIUrl::createUrl('/admin/documents'); ?> '" class="btn" ><i class="icon-undo bigger-110"></i><?php echo translate('hủy'); ?> </button> </div> </form> </div> </div><!--/.span--> </div><!--/.row-fluid--> </div><!--/.page-content--> </div><!--/.main-content--> <script> $(document).ready(function(){
</div><!--/.page-content--> </div><!--/.main-content--> <style> .grid-view .filters input, .grid-view .filters select { width: 92%; } .image img{ width:80px; height:60px; } .btn-info{margin-right:3px;} input[type="checkbox"]{opacity:1;} .select-on-check-all{ margin-top:-7.3px !important; } </style> <script> $("document").ready(function(){ $(".deleteAll").live('click', function(){ var arrIdNew = $("#hotel-grid").yiiGridView('getSelection'); if(arrIdNew != ""){ var answer = confirm ("Bạn có muốn xóa các tin tức được chọn không?"); if(answer){ var arrIdNew = $("#hotel-grid").yiiGridView('getSelection'); window.location.href = "<?php echo PIUrl::createUrl('/admin/hotel/deleteAll/'); ?> "+"?id="+arrIdNew; } } }); }) </script>
public function actionUpdate($id = null) { $model = Documents::model()->findByPk($id); $flag = 0; if (!empty($_POST['Documents'])) { $filename_old = $model->attributes['filename']; if (!empty(CUploadedFile::getInstance($model, 'filename')->name)) { $model->attributes = $_POST['Documents']; $model->filename = CUploadedFile::getInstance($model, 'filename'); $filename = $model->filename; $document = explode('.', $model->filename->name); $filenameType = $document[count($document) - 1]; $filenameName = md5(uniqid()) . '.' . $filenameType; $model->type = end($document); $model->size = $model->filename->size; $model->md5name = $filenameName; $model->filename = $document[count($document) - 2] . "." . $model->type; $filenames_path = Yii::getPathOfAlias('webroot') . '/upload/documents/' . $filenameName; $flag = 1; } else { $model->attributes = $_POST['Documents']; $model->filename = $filename_old; } $model->updated = time(); if ($model->save()) { Yii::app()->user->setFlash('success', translate('Cập nhật thành công.')); if ($flag == 1) { $filename->saveAs($filenames_path); } $this->redirect(PIUrl::createUrl('/admin/Documents/')); } } $dataCategories = categoriesDocuments::model()->getCategoriesDocument(); $this->render('update', array('model' => $model, 'dataCategory' => $dataCategories)); }
<li><a href="<?php echo PIUrl::createUrl('/home/news'); ?> " class="menu-news <?php echo yii::app()->getController()->action->id == 'news' ? 'active' : ''; ?> "><i class="icon-ib menu-news-hover"></i><span>Tin tức</span></a></li> <li><a href="<?php echo PIUrl::createUrl('/home/album'); ?> " class="menu-library <?php echo yii::app()->getController()->action->id == 'album' ? 'active' : ''; ?> "><i class="icon-ib menu-library-hover"></i><span>Thư viện hình ảnh</span></a></li> <li><a href="<?php echo PIUrl::createUrl('/home/contact'); ?> " class="menu-contact <?php echo yii::app()->getController()->action->id == 'contact' ? 'active' : ''; ?> "><i class="icon-ib menu-contact-hover"></i><span>Liên hệ</span></a></li> </ul> </div> <div class="clearfix"></div> <div class="wrap-copyright"> <div class="container"> <p class="copyright">Copyright © 2014 Trường mầm non Bảo Ngọc. <span>All rights reserved</span></p> <p class="designby">Designed by <a href="javascript:void(0)">Kovo.vn</a></p> </div> </div> </div>
echo $form->error($model, 'url'); ?> </div> </div> <div class="form-actions"> <button id="submitForm" class="btn btn-info" type="submit"> <i class="icon-ok bigger-110"></i> <?php echo translate('Cập nhập'); ?> </button> <button type="button" onclick="location.href='<?php echo PIUrl::createUrl('/admin/links'); ?> '" class="btn" > <i class="icon-undo bigger-110"></i> <?php echo translate('hủy'); ?> </button> </div> <?php $this->endWidget(); ?> </div><!--/.span--> </div><!--/.row-fluid--> </div><!--/.page-content--> </div><!--/.main-content-->
echo $form->error($model, 'name'); ?> </div> </div> <div class="form-actions"> <button id="submitForm" class="btn btn-primary" type="submit"> <i class="icon-ok bigger-110"></i> <?php echo translate('Thêm'); ?> </button> <button type="button" onclick="location.href='<?php echo PIUrl::createUrl('/admin'); ?> '" class="btn" > <i class="icon-undo bigger-110"></i> <?php echo translate('hủy'); ?> </button> </div> <?php $this->endWidget(); ?> </div><!--/.span--> </div><!--/.row-fluid--> </div><!--/.page-content--> </div><!--/.main-content-->
<?php $this->breadcrumbs = array(UserModule::t('Profile Fields') => array('admin'), UserModule::t($model->title)); ?> <ul class="breadcrumb" id="breadcrumb"> <li><span class="badge badge-success"><strong><?php echo UserModule::t('View Profile Field #') . $model->varname; ?> </strong></span></li> </ul> <a href="<?php echo PIUrl::createUrl('/user/profileField/update', array('id' => $model->id)); ?> " class="btn"><?php echo UserModule::t('Update Profile Field'); ?> </a> <?php echo CHtml::link(UserModule::t('Delete Profile Field'), "#", array("class" => "btn", "submit" => array('delete', 'id' => $model->id), 'confirm' => UserModule::t('Are you sure to delete this item?'))); $this->widget('bootstrap.widgets.TbDetailView', array('htmlOptions' => array('style' => 'margin-top:10px'), 'data' => $model, 'attributes' => array('id', 'varname', 'title', 'field_type', 'field_size', 'field_size_min', 'required', 'match', 'range', 'error_message', 'other_validator', 'widget', 'widgetparams', 'default', 'position', 'visible')));