?> <?php $this->widget('ext.elrte.elRTE', array('selector' => 'AdminArticlesModel_fulltext', 'doctype' => '<!DOCTYPE html PUBLIC \\"-//W3C//DTD XHTML 1.0 Transitional//EN\\" \\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\\">', 'cssClass' => 'el-rte', 'absoluteURLs' => 'false', 'allowSource' => 'true', 'lang' => 'en', 'styleWithCSS' => 'true', 'height' => '500', 'width' => '100%', 'fmAllow' => 'true', 'toolbar' => 'maxi')); echo $form->textArea($model, 'fulltext'); ?> <?php echo $form->error($model, 'fulltext'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'genre'); ?> <?php $data = CHtml::listData(AdminGenreModel::model()->findAll(), 'code', 'name'); echo $form->dropDownList($model, 'genre', $data); ?> <?php echo $form->error($model, 'genre'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'tags'); ?> <?php echo $form->textField($model, 'tags'); ?> <?php
public function actionIndex() { $pageSize = Yii::app()->request->getParam('pageSize', Yii::app()->params['pageSize']); Yii::app()->user->setState('pageSize', $pageSize); $model = new AdminVideoModel('search'); $copyrightType = Yii::app()->request->getParam('ccp_type', null); if (isset($_GET['AdminVideoModel'])) { if (isset($_GET['AdminVideoModel']['created_time']) && $_GET['AdminVideoModel']['created_time'] != "") { // Re-setAttribute create datetime $createdTime = $_GET['AdminVideoModel']['created_time']; if (strrpos($createdTime, "-")) { $createdTime = explode("-", $createdTime); $fromDate = explode("/", trim($createdTime[0])); $fromDate = $fromDate[2] . "-" . str_pad($fromDate[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($fromDate[1], 2, '0', STR_PAD_LEFT); $fromDate .= " 00:00:00"; $toDate = explode("/", trim($createdTime[1])); $toDate = $toDate[2] . "-" . str_pad($toDate[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($toDate[1], 2, '0', STR_PAD_LEFT); $toDate .= " 23:59:59"; } else { $fromDate = date("Y-m-d", strtotime($_GET['AdminVideoModel']['created_time'])) . " 00:00:00"; $toDate = date("Y-m-d", strtotime($_GET['AdminVideoModel']['created_time'])) . " 23:59:59"; } } } $is_composer = ""; if (isset($_GET['is_composer']) && $_GET['is_composer'] > 0) { $is_composer = $_GET['is_composer']; } $is_lyric = ""; if (isset($_GET['is_lyric']) && $_GET['is_lyric'] > 0) { $is_lyric = $_GET['is_lyric']; } $categoryList = AdminGenreModel::model()->gettreelist(2); $cpList = AdminCpModel::model()->findAll(); $numPage = 1; $count = 0; if (isset($_GET['AdminVideoModel'])) { $limit = 10; $offset = 0; $where = ""; if ($_GET['AdminVideoModel']['genre_id'] != '') { $genreId = (int) $_GET['AdminVideoModel']['genre_id']; $where .= " and (g.id = '{$genreId}' OR g.parent_id= '{$genreId}')"; } if ($_GET['AdminVideoModel']['name'] != '') { $where .= " and t.name LIKE '%" . $_GET['AdminVideoModel']['name'] . "%' "; } if ($_GET['AdminVideoModel']['artist_name'] != '') { $where .= " and a.name LIKE '%" . $_GET['AdminVideoModel']['artist_name'] . "%' "; } if ($_GET['is_composer'] == 1 || $_GET['is_composer'] == 2) { if ($_GET['is_composer'] == 1) { $where .= " and t.composer_id > 0 "; } else { $where .= " and t.composer_id = 0 "; } } if ($_GET['is_lyric'] == 1 || $_GET['is_lyric'] == 2) { if ($_GET['is_lyric'] == 1) { $where .= " and ve.description <> '' "; } else { $where .= " and (ve.description = '' OR ve.description is null)"; } } if ($_GET['AdminVideoModel']['max_bitrate'] != '') { $bitRate = $_GET['AdminVideoModel']['max_bitrate']; if ($bitRate == "720") { $where .= " and t.profile_ids LIKE '%9%'"; } } if ($_GET['AdminVideoModel']['created_time'] != '') { $where .= " and t.created_time BETWEEN '{$fromDate}' AND '{$toDate}' "; } $sql = "SELECT count(DISTINCT `t`.`id`)\n\t\t\t\t\tFROM video t \n\t\t\t\t\tINNER JOIN video_status st ON t.id = st.video_id\n\t\t\t\t\tLEFT JOIN video_artist va ON t.id =va.video_id\n\t\t\t\t\tLEFT JOIN artist a ON a.id=va.artist_id\n\t\t\t\t\tLEFT JOIN genre g ON g.id = t.genre_id\n\t\t\t\t\tLEFT JOIN video_extra ve ON t.id = ve.video_id\n\t\t\t\t\tWHERE true {$where}\n\t\t\t\t\t"; $count = Yii::app()->db->createCommand($sql)->queryScalar(); $perPage = 5000; if ($count <= $perPage) { $numPage = 1; } elseif ($count % $perPage == 0) { $numPage = $count / $perPage; } else { $numPage = $count / $perPage + 1; $numPage = (int) $numPage; } if (isset($_GET['export'])) { $page = Yii::app()->request->getParam('page', 1); $limit = $perPage; $offset = ($page - 1) * $limit; $sql = "SELECT t.id, t.name as video_name, a.name as composer_name, \n\t\t\t\tt.composer_id, t.genre_id, g.name, t.artist_name,ve.description as lyric,\n\t\t\t\tsc.copryright_id as copyright_id,c.appendix_no,c.contract_no \n\t\t\t\tFROM video t\n\t\t\t\tINNER JOIN video_status st ON t.id = st.video_id\n\t\t\t\tLEFT JOIN video_artist va ON va.video_id = t.id\n\t\t\t\tLEFT JOIN artist a ON a.id=t.composer_id\n\t\t\t\tLEFT JOIN genre g ON g.id=t.genre_id\n\t\t\t\tLEFT JOIN video_extra ve ON t.id = ve.video_id\n\t\t\t\tLEFT JOIN video_copyright sc ON sc.video_id=t.id\n\t\t\t\tLEFT JOIN copyright c ON c.id=sc.copryright_id \t\t\t\t\n\t\t\t\tWHERE true {$where}\n\t\t\t\tGROUP BY t.id\n\t\t\t\tORDER BY t.id ASC\n\t\t\t\tLIMIT {$limit}\n\t\t\t\tOFFSET {$offset}\n\t\t\t\t"; $data = Yii::app()->db->createCommand($sql)->queryAll(); $label = array('id' => 'ID', 'video_name' => 'Video', 'artist_name' => 'Ca sỹ', 'composer_name' => 'Nhạc sỹ', 'composer_id' => 'composer_id', 'name' => 'Thể loại', 'lyric' => 'Lyric', 'contract_no' => 'Số hợp đồng', 'cc' => 'Tên CP, Ca sĩ, đại diện HĐ', 'appendix_no' => 'Số phụ lục', 'copyright_id' => 'ID Hợp đồng'); $title = Yii::t('admin', 'Export_' . $page); $excelObj = new ExcelExport($data, $label, $title); $excelObj->export(); exit; } } $this->render('index', array('model' => $model, 'categoryList' => $categoryList, 'cpList' => $cpList, 'pageSize' => $pageSize, 'is_composer' => $is_composer, 'copyrightType' => $copyrightType, 'numPage' => $numPage, 'count' => $count, 'is_lyric' => $is_lyric)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = AdminGenreModel::model()->findByPk(new MongoId($id)); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
?> <?php echo $form->error($model, 'description'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'parent'); ?> <?php $c = array('conditions' => array('status' => array('==' => 1))); if ($model->_id) { $c['conditions']['_id'] = array('<>' => $model->_id); } $genres = AdminGenreModel::model()->findAll($c); $data = array(); foreach ($genres as $genre) { $data["{$genre->_id}"] = $genre->name; } echo CHtml::dropDownList('AdminGenreModel[parent]', (string) $model->parent, $data, array('prompt' => '--None--', 'class' => 'form-control')); ?> <?php echo $form->error($model, 'parent'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'position'); ?>
public function actionIndex() { $pageSize = Yii::app()->request->getParam('pageSize', Yii::app()->params['pageSize']); Yii::app()->user->setState('pageSize', $pageSize); $model = new AdminSongModel('search'); $copyrightType = Yii::app()->request->getParam('ccp_type', null); if (isset($_GET['AdminSongModel'])) { if (isset($_GET['AdminSongModel']['created_time']) && $_GET['AdminSongModel']['created_time'] != "") { // Re-setAttribute create datetime $createdTime = $_GET['AdminSongModel']['created_time']; if (strrpos($createdTime, "-")) { $createdTime = explode("-", $createdTime); $fromDate = explode("/", trim($createdTime[0])); $fromDate = $fromDate[2] . "-" . str_pad($fromDate[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($fromDate[1], 2, '0', STR_PAD_LEFT); $fromDate .= " 00:00:00"; $toDate = explode("/", trim($createdTime[1])); $toDate = $toDate[2] . "-" . str_pad($toDate[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($toDate[1], 2, '0', STR_PAD_LEFT); $toDate .= " 23:59:59"; } else { $fromDate = date("Y-m-d", strtotime($_GET['AdminSongModel']['created_time'])) . " 00:00:00"; $toDate = date("Y-m-d", strtotime($_GET['AdminSongModel']['created_time'])) . " 23:59:59"; } } } $is_composer = ""; if (isset($_GET['is_composer']) && $_GET['is_composer'] > 0) { $is_composer = $_GET['is_composer']; } $categoryList = AdminGenreModel::model()->gettreelist(2); $cpList = AdminCpModel::model()->findAll(); if (isset($_GET['AdminSongModel'])) { $limit = 10; $offset = 0; $where = ""; if ($_GET['AdminSongModel']['cp_id'] != '') { $where .= " and t.cp_id = " . $_GET['AdminSongModel']['cp_id'] . " "; } if ($_GET['AdminSongModel']['genre_id'] != '') { $where .= " and sg.genre_id = " . $_GET['AdminSongModel']['genre_id'] . " "; } if ($_GET['AdminSongModel']['name'] != '') { $where .= " and t.name LIKE '%" . $_GET['AdminSongModel']['name'] . "%' "; } if ($_GET['AdminSongModel']['artist_name'] != '') { $where .= " and t.artist_name LIKE '%" . $_GET['AdminSongModel']['artist_name'] . "%' "; } if ($_GET['is_composer'] == 1 || $_GET['is_composer'] == 2) { if ($_GET['is_composer'] == 1) { $where .= " and t.composer_id > 0 "; } else { $where .= " and t.composer_id = 0 "; } } if ($_GET['AdminSongModel']['max_bitrate'] != '') { $where .= " and t.max_bitrate = " . $_GET['AdminSongModel']['max_bitrate']; } if ($_GET['ccp_type'] != '') { $where .= " and sc.type = " . $_GET['ccp_type']; } if ($_GET['AdminSongModel']['created_time'] != '') { $where .= " and t.created_time BETWEEN '{$fromDate}' AND '{$toDate}' "; } $sql = "SELECT count(DISTINCT `t`.`id`)\n\t\t\t\t\tFROM song t \n\t\t\t\t\tINNER JOIN song_status st ON t.id = st.song_id\n\t\t\t\t\tLEFT JOIN artist a ON a.id=t.composer_id\n\t\t\t\t\tLEFT JOIN song_genre sg ON sg.song_id=t.id\n\t\t\t\t\tLEFT JOIN song_copyright sc ON sc.song_id=t.id\n\t\t\t\t\tLEFT JOIN copyright c ON c.id=sc.copryright_id\n\t\t\t\t\tWHERE t.status=1 {$where}\n\t\t\t\t\t"; $count = Yii::app()->db->createCommand($sql)->queryScalar(); $perPage = 10000; if ($count <= $perPage) { $numPage = 1; } elseif ($count % $perPage == 0) { $numPage = $count / $perPage; } else { $numPage = $count / $perPage + 1; $numPage = (int) $numPage; } if (isset($_GET['export'])) { $page = Yii::app()->request->getParam('page', 1); $limit = $perPage; $offset = ($page - 1) * $limit; $sql = "SELECT t.id, t.name, t.artist_name, a.name as composer_name, t.composer_id, sg.genre_name, sc.copryright_id as copyright_id,c.appendix_no,c.contract_no, cp.name as cc, '' as ccc \n\t\t\t\tFROM song t\n\t\t\t\tINNER JOIN song_status st ON t.id = st.song_id\n\t\t\t\tLEFT JOIN cp ON t.cp_id = cp.id\n\t\t\t\tLEFT JOIN artist a ON a.id=t.composer_id\n\t\t\t\tLEFT JOIN song_genre sg ON sg.song_id=t.id\n\t\t\t\tLEFT JOIN song_copyright sc ON sc.song_id=t.id\n\t\t\t\tLEFT JOIN copyright c ON c.id=sc.copryright_id\n\t\t\t\tWHERE t.status=1 {$where}\n\t\t\t\tGROUP BY t.id\n\t\t\t\tORDER BY t.id ASC\n\t\t\t\tLIMIT {$limit}\n\t\t\t\tOFFSET {$offset}\n\t\t\t\t"; $data = Yii::app()->db->createCommand($sql)->queryAll(); $label = array('id' => 'ID', 'name' => 'Bài Hát', 'artist_name' => 'Ca sỹ', 'composer_name' => 'Nhạc sỹ', 'composer_id' => 'composer_id', 'contract_no' => 'Số hợp đồng', 'cc' => 'Tên CP, Ca sĩ, đại diện HĐ', 'appendix_no' => 'Số phụ lục', 'ccc' => 'STTPL', 'copyright_id' => 'ID Hợp đồng'); $title = Yii::t('admin', 'Export_' . $page); $excelObj = new ExcelExport($data, $label, $title); $excelObj->export(); exit; } } $this->render('index', array('model' => $model, 'categoryList' => $categoryList, 'cpList' => $cpList, 'pageSize' => $pageSize, 'is_composer' => $is_composer, 'copyrightType' => $copyrightType, 'numPage' => $numPage, 'count' => $count)); }