/**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     // $criteria = new CDbCriteria ();
     // $criteria->order = 'id desc';
     // $newest_book = Book::model()->find($criteria);
     //sach moi
     $criteria = new CDbCriteria();
     $criteria->order = 'id desc';
     $criteria->limit = 9;
     $list_book = Book::model()->findAll($criteria);
     //sach moi nhat
     $criteria = new CDbCriteria(array('order' => 'id DESC', 'limit' => '1'));
     // $dataProvider=new CActiveDataProvider('Book',array(
     // // 'pagination'=>array(
     // // 	'pageSize'=>Yii::app()->params['booksPerPage'],
     // // ),
     // 'criteria'=>$criteria,
     // ));
     $dataProvider = Book::model()->find($criteria);
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     // $this->render('index');
     $this->render('index', array('dataProvider' => $dataProvider, 'list_book' => $list_book));
 }
Exemplo n.º 2
0
 public function init()
 {
     parent::init();
     // Create new field in your users table for store dashboard preference
     // Set table name, user ID field name, user preference field name
     $this->setTableParams('dashboard_page', 'user_id', 'title');
     // set array of portlets
     $this->setPortlets(array(array('id' => 1, 'title' => 'Ultimos clientes', 'content' => Customer::model()->Top(4)), array('id' => 2, 'title' => 'Ultimas reservas', 'content' => Book::model()->Top(4)), array('id' => 3, 'title' => 'Puntos críticos', 'content' => Point::model()->Top(4)), array('id' => 4, 'title' => 'Ultimos boletines', 'content' => Mail::model()->Top(4)), array('id' => 5, 'title' => 'Informes', 'content' => Functions::lastReports()), array('id' => 6, 'title' => 'Ultimas facturas', 'content' => Invoice::model()->Top(4))));
     //set content BEFORE dashboard
     $this->setContentBefore();
     // uncomment the following to apply jQuery UI theme
     // from protected/components/assets/themes folder
     $this->applyTheme('ui-lightness');
     // uncomment the following to change columns count
     //$this->setColumns(4);
     // uncomment the following to enable autosave
     $this->setAutosave(true);
     // uncomment the following to disable dashboard header
     $this->setShowHeaders(false);
     // uncomment the following to enable context menu and add needed items
     /*
     $this->menu = array(
         array('label' => 'Index', 'url' => array('index')),
     );
     */
 }
Exemplo n.º 3
0
 public function actionIndex()
 {
     $num = 3;
     $array = Book::model()->findAll('id<:num', array(':num' => $num));
     //echo $array->title;
     $this->render('index', array('array' => $array));
 }
Exemplo n.º 4
0
 public function actionBookList()
 {
     if ($_POST["start"]) {
         $criteria = new CDbCriteria();
         $criteria->condition = "Start BETWEEN :start AND :finish AND UserID = :userid";
         $criteria->params = array(':start' => date("Y-m-d", strtotime($_POST["start"])), ':finish' => date("Y-m-d", strtotime($_POST["fin"])), ':userid' => Yii::app()->user->ID);
         $criteria->order = 'Start ASC';
         $model = Book::model()->findAll($criteria);
         set_time_limit(600);
         # mPDF
         $pdf = Yii::app()->ePdf->mpdf('', 'A4', '', '', '', '', '', '', '', '', 'P');
         $pdf->writeHTMLfooter = false;
         $pdf->writeHTMLheader = false;
         $pdf->DeflMargin = 15;
         $pdf->DefrMargin = 15;
         $pdf->tMargin = 15;
         $pdf->bMargin = 15;
         $pdf->w = 297;
         //manually set width
         $pdf->h = 209.8;
         //manually set height
         # render (full page)
         $pdf->WriteHTML($this->renderPartial('_booklist', array('model' => $model), true));
         # Outputs ready PDF
         $pdf->Output('ListaReservas_' . date("d/m/Y") . '.pdf', 'D');
     } else {
         $this->render('selector');
     }
 }
 public function runJoinSearch($i)
 {
     $book = Book::model()->find(array('alias' => 'b', 'condition' => 'b.title = :t', 'params' => [':t' => 'Hello' . $i], 'with' => ['author']));
     //        $book = $this->em->createQuery(
     //            'SELECT b, a FROM Book b JOIN b.author a WHERE b.title = ?1'
     //        )->setParameter(1, 'Hello' . $i)
     //         ->setMaxResults(1)
     //         ->getResult();
 }
Exemplo n.º 6
0
 public function actionIndex()
 {
     $b = new Book();
     $b->title = 'Master and Margarita';
     $b->author = 'M.Bylgakov';
     $b->year = '1905';
     //$b->save(false);
     $id = $_GET['id'];
     $model = Book::model()->search();
     $this->render('index', array('model' => $model));
 }
Exemplo n.º 7
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $model = array();
     $model['publishers'] = count(Publishing::model()->findAll());
     $model['authors'] = count(Author::model()->findAll());
     $model['books'] = count(Book::model()->findAll());
     $model['pictures'] = count(Picture::model()->findAll());
     // renders the view file 'protected/views/site/index.php'
     // using the default layout 'protected/views/layouts/main.php'
     $this->render('index', ['model' => $model]);
 }
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     $criteria->order = 'id desc';
     // $list_book = Book::model()->findAll($criteria);
     $list_book = new CActiveDataProvider('Book', array('pagination' => array('pageSize' => '9'), 'criteria' => $criteria));
     //sach moi nhat
     $criteria = new CDbCriteria(array('order' => 'id DESC', 'limit' => '1'));
     $dataProvider = Book::model()->find($criteria);
     $this->render('index', array('dataProvider' => $dataProvider, 'list_book' => $list_book));
 }
Exemplo n.º 9
0
 public static function getBooksAll()
 {
     $criteria = new CDbCriteria([]);
     $pages = new CPagination(Book::model()->count($criteria));
     $pages->pageSize = 4;
     $pages->applyLimit($criteria);
     $model = Book::model()->findAll($criteria);
     $books = array();
     foreach ($model as $item) {
         $books[] = self::getBookAll($item->id);
     }
     return $books;
 }
Exemplo n.º 10
0
 private function RunReport()
 {
     $criteria = new CDbCriteria();
     $criteria = array('select' => 'count(grade_id) as num_grade, grade_id', 'with' => array('grade'), 'group' => 'grade_id');
     $books = Book::model()->findAll($criteria);
     // initialize report
     $report = array('data' => array(array('label' => 'Comic Books by Grade', 'data' => array(), 'bars' => array('show' => true, 'align' => 'center'))), 'options' => array('legend' => array('show' => false)), 'htmlOptions' => array('style' => 'width:200px;height:200px;'));
     foreach ($books as $book) {
         $report['data'][0]['data'][] = array($book->grade_id, $book->num_grade);
         $report['options']['xaxis']['ticks'][] = array($book->grade_id, $book->grade->name);
     }
     return $report;
 }
Exemplo n.º 11
0
 public function actionLend($book_id, $user_id)
 {
     $model = Book::model()->findByPk($book_id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested book does not exist.');
     }
     $request = Request::model()->find('book_id=:book_id AND requester_id=:user_id', array(':book_id' => $book_id, ':user_id' => $user_id));
     if ($request === null) {
         throw new CHttpException(404, 'The request does not exist.');
     }
     $request->delete();
     $model->borrower_id = $user_id;
     $model->save();
     $this->redirect(array('book/index'));
 }
Exemplo n.º 12
0
 private function _normalizeContent($arrContent)
 {
     if (isset($arrContent['book_name'])) {
         $book = Book::model()->find('LCASE(book_name) LIKE LCASE(:name)', array('name' => '%' . $arrContent['book_name'] . '%'));
         if ($book == null) {
             $book = Book::model()->find('LCASE(book_name) LIKE LCASE(:name)', array('name' => $arrContent['name']));
         }
         if (isset($book) && !empty($book)) {
             $arrContent['book_link_id'] = $book->link_id;
         }
     }
     if (isset($arrContent['book_name'])) {
         unset($arrContent['book_name']);
     }
     return $arrContent;
 }
Exemplo n.º 13
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new BorrowBook();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if ($_POST['BorrowBook']) {
         $model->attributes = $_POST['BorrowBook'];
         $model->validate();
         if (isset($_POST['BorrowBook']) and $_POST['BorrowBook']['student_admission_no'] != NULL and $_POST['BorrowBook']['subject'] != NULL and $_POST['BorrowBook']['book_name'] != NULL and $_POST['BorrowBook']['issue_date'] != NULL and $_POST['BorrowBook']['due_date'] != NULL) {
             $model->attributes = $_POST['BorrowBook'];
             if ($model->validate()) {
                 $student = Students::model()->findByAttributes(array('admission_no' => $_POST['BorrowBook']['student_admission_no'], 'is_deleted' => 0, 'is_active' => 1));
                 if ($student == NULL) {
                     Yii::app()->user->setFlash('errorMessage', UserModule::t("Enter valid student admission number! <br/> The entered admission_no is deleted or inactive"));
                     $this->redirect(array('create', 'id' => $_POST['BorrowBook']['student_admission_no']));
                 }
                 $status = Book::model()->findByAttributes(array('id' => $_POST['BorrowBook']['book_name']));
                 if ($status != NULL) {
                     if ($status->copy == 0) {
                         $this->redirect(array('/library/BorrowBook/listbook/'));
                     } else {
                         if ($model->issue_date) {
                             //$currdate=$model->issue_date;
                             //$model->due_date =date('Y-m-d',strtotime("+1 months", strtotime($currdate)));
                             $model->issue_date = date('Y-m-d', strtotime($model->issue_date));
                         }
                         $model->due_date = date('Y-m-d', strtotime($model->due_date));
                         $model->status = 'C';
                         $model->book_id = $status->id;
                         $model->subject = $status->subject;
                         $model->student_id = $student->id;
                         $model->book_name = $status->title;
                         if ($model->save()) {
                             //echo $status->copy; exit;
                             $status->saveAttributes(array('status' => 'S', 'copy_taken' => $status->copy_taken + 1, 'copy' => $status->copy - 1));
                             $this->redirect(array('view', 'id' => $model->id));
                         }
                     }
                 } else {
                     $this->redirect(array('/library/BorrowBook/error/'));
                 }
             }
         }
     }
     $this->render('create', array('model' => $model));
 }
Exemplo n.º 14
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id)
 {
     $model = new ReturnBook();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['ReturnBook'])) {
         $model->attributes = $_POST['ReturnBook'];
         if ($model->return_date) {
             $model->return_date = date('Y-m-d', strtotime($model->return_date));
         }
         if ($model->issue_date) {
             $model->issue_date = date('Y-m-d', strtotime($model->issue_date));
         }
         if ($_POST['ReturnBook']['borrow_book_id']) {
             $borrow = BorrowBook::model()->findByAttributes(array('id' => $_POST['ReturnBook']['borrow_book_id']));
         }
         $status = Book::model()->findByAttributes(array('title' => $borrow->book_name));
         //echo $model->borrow_book_id; exit;
         $model->book_id = $status->id;
         if ($model->save()) {
             //$borrow=BorrowBook::model()->findByAttributes(array('id'=>$model->borrow_book_id,'student_id'=>$id));
             $user = User::model()->findByAttributes(array('id' => Yii::app()->user->id));
             //updating borrowbook table
             // echo count($borrow);
             $borrow->status = 'R';
             // $borrow->validate();
             //var_dump($borrow->getErrors());
             //  exit;
             $borrow->save();
             $status->status = 'R';
             $status->copy = $status->copy + 1;
             if ($status->copy_taken != '0') {
                 $status->copy_taken = $status->copy_taken - 1;
             }
             $status->save();
             //if($model->return_date >= $borrow->due_date)
             //					{
             //					User::sendMail($user->email,'Due date expired','<html><body>Dear '.$profile->first_name.' '.$profile->last_name.' ,
             //		Your due date has expired. And you have to pay the fine.</body></html>', 'Dear '.$profile->first_name.' '.$profile->last_name.' ,
             //		Your due date has expired. And you have to pay the fine');
             //					}
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('create', array('model' => $model, 'bookid' => $_POST['BookID']));
 }
Exemplo n.º 15
0
	/**
	 * Creates a new model.
	 * If creation is successful, the browser will be redirected to the 'view' page.
	 */
	public function actionCreate()
	{
		$model=new Giohang;

		// Uncomment the following line if AJAX validation is needed
		// $this->performAjaxValidation($model);

		if(isset($_POST['Giohang']))
		{
			$idbook = intval($_POST['Giohang']["id_book"]);
			$namebook = intval($_POST['Giohang']["name_book"]);
			$cost = intval($_POST['Giohang']["cost"]);
			$status = intval($_POST['Giohang']["status"]);
			$number = intval($_POST['Giohang']["number"]);
			$iduser = Yii::app()->user->id;

			// update so luong sach
			$book=Book::model()->findByPk($idbook);
			// Book::model()->loadModel($idbook);
			if ($book->slcon > $number) {
				$book->slcon = $book->slcon - $number;
				$book->save();



			$model->id_book = $idbook;
			$model->name_book = $namebook;
			$model->cost = $cost;
			$model->status = $status;
			$model->number = $number;
			$model->id_user = $iduser;

			$model->attributes=$_POST['Giohang'];
			if($model->save())
				// $this->redirect(array('view','id'=>$model->id));
				$this->redirect(array('//site/index'));
		}
		}

		// $this->render('create',array(
		// 	'model'=>$model,
		// ));
	}
Exemplo n.º 16
0
 public function actionIndex()
 {
     if (Yii::app()->user->isGuest) {
         if (Yii::app()->request->isPostRequest && isset($_POST["login"])) {
             $user = new User("login");
             $user->setAttributes($_POST["login"]);
             $user->remember = true;
             if ($user->login()) {
                 $this->redirect("/");
             } else {
                 Yii::app()->user->setFlash("error", $user->getError("pass"));
             }
         }
         if (p()['registerType'] == "INVITE") {
             $this->layout = "empty";
             $this->render("index_guest");
             return;
         }
     }
     $this->layout = "column1";
     $hot_key = sprintf("hot.%d.%d.%d", Yii::app()->user->ini["hot.s_lang"], Yii::app()->user->ini["hot.t_lang"], Yii::app()->user->ini["hot.img"]);
     if (!($hot = Yii::app()->cache->get($hot_key))) {
         $C = new CDbCriteria(array("condition" => "t.ac_read = 'a'", "order" => "t.last_tr DESC NULLS LAST"));
         $C->limit = Yii::app()->user->ini["hot.img"] ? 12 : 36;
         if (Yii::app()->user->ini["hot.s_lang"]) {
             $C->addCondition("t.s_lang = " . Yii::app()->user->ini["hot.s_lang"]);
         }
         if (Yii::app()->user->ini["hot.t_lang"]) {
             $C->addCondition("t.t_lang = " . Yii::app()->user->ini["hot.t_lang"]);
         }
         $hot = Book::model()->findAll($C);
         Yii::app()->cache->set($hot_key, $hot, 60);
     }
     if (!($announces = Yii::app()->cache->get("announces"))) {
         $announces = Announce::model()->with("book.cat", "book.owner", "seen")->findAll(array("condition" => "t.topics BETWEEN 80 AND 89 AND book.ac_read = 'a'", "order" => "t.cdate desc", "limit" => 5));
         Yii::app()->cache->set("announces", $announces, 90);
     }
     if (!($blog = Yii::app()->cache->get("blog"))) {
         $blog = BlogPost::model()->common()->findAll(["limit" => 10]);
         Yii::app()->cache->set("blog", $blog, 105);
     }
     $this->render('index', array("hot" => $hot, "searchTop" => $this->getSearchTop(), "announces" => $announces, "blog" => $blog));
 }
Exemplo n.º 17
0
 public function actionView($id)
 {
     $teacher = $this->loadModel($id);
     $this->_seoTitle = '名师 - ' . $teacher->name;
     $userId = $this->_cookiesGet('userId');
     $userType = $this->_cookiesGet('userType');
     $reviewModel = new Review();
     if ($userType === 'student' and isset($_POST['Review'])) {
         $reviewModel->attributes = $_POST['Review'];
         $reviewModel->teacher_id = $id;
         $reviewModel->student_id = $userId;
         $reviewModel->ctime = time();
         if ($reviewModel->validate() and $reviewModel->save()) {
             Yii::app()->user->setFlash('success', '保存成功');
         }
     }
     $criteria = new CDbCriteria();
     $books = Book::model()->findAllByAttributes(array('teacher_id' => $id));
     $lessons = array();
     $reviews = array();
     $list = yii::app()->request->getParam('list');
     if ($list === null or $list === 'lesson') {
         $model = Lesson::model();
         $count = $model->count($criteria->addCondition("teacher_id = {$id}"));
         $pager = new CPagination($count);
         $pager->pageSize = 4;
         $pager->applyLimit($criteria);
         $lessons = $model->findAll($criteria);
     } else {
         $model = Review::model();
         $count = $model->count($criteria->addCondition("teacher_id = {$id}"));
         $pager = new CPagination($count);
         $pager->pageSize = 4;
         $pager->applyLimit($criteria);
         $reviews = Yii::app()->db->createCommand()->select('s.*, r.contents, r.ctime')->from('seed_review r')->leftjoin('seed_student s', 's.id=r.student_id')->where('r.teacher_id=:teacher_id', array(':teacher_id' => $id))->order('ctime desc')->limit(4, $pager->currentPage * $pager->pageSize)->queryAll();
     }
     //判断学员已关注老师
     if ($userType === 'student') {
         $is_focus = StudentTeacher::model()->findByAttributes(array('student_id' => $userId, 'teacher_id' => $id));
     }
     $this->render('view', array('is_focus' => $is_focus, 'teacher' => $teacher, 'lessons' => $lessons, 'reviews' => $reviews, 'books' => $books, 'userType' => $userType, 'reviewModel' => $reviewModel, 'count' => $count, 'pager' => $pager, 'list' => $_GET['list']));
 }
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $gio1 = Giohang::model()->findByPk($id);
     $a = $gio1->number;
     $book = Book::model()->findByPk($gio1->id_book);
     if (isset($_POST['Giohang'])) {
         $model->attributes = $_POST['Giohang'];
         if ($model->save()) {
             print_r($book->slcon);
             $book->slcon = $book->slcon + $a - $model->number;
             print_r($book->slcon);
             $book->save();
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     // print_r($model->id_book);
     // print_r($a);
     $book->save();
     $this->render('update', array('model' => $model));
 }
Exemplo n.º 19
0
 public function actionIndex($cat_id = 0)
 {
     $cat_id = (int) $cat_id;
     if ($cat_id) {
         $cat = Category::model()->findByPk((int) $cat_id);
         $branch = $cat->mp;
     } else {
         $cat = $branch = null;
     }
     $tree = Category::model()->tree($branch)->with("booksCount")->findAll();
     if ($cat) {
         $n = count($cat->mp);
         $books_dp = new CActiveDataProvider(Book::model()->with("cat"), array("criteria" => array("condition" => "cat.mp[1:{$n}] = '{$cat->mpPacked}'", "order" => "t.s_title"), "pagination" => array("pageSize" => 50)));
     } else {
         $books_dp = null;
     }
     if ($_GET["ajax"]) {
         $this->renderPartial("catalog_ajax", array("tree" => $tree));
     } else {
         $this->render("catalog", array("cat" => $cat, "tree" => $tree, "books_dp" => $books_dp));
     }
 }
Exemplo n.º 20
0
 public function actionAdmin($id = null)
 {
     /**
      * @var $model           Book
      */
     $model = new Book();
     if ($id) {
         $model = Book::model()->findByPk($id);
     }
     $alerts = array();
     if ($_POST) {
         $tmp = $_POST;
         $book = $tmp['Book'];
         $saveType = $tmp['save'];
         $model->attributes = $book;
         $isNew = false;
         if (!$model->id) {
             $isNew = true;
         }
         if ($model->save()) {
             $alerts['success']['Book'] = 'บันทึกข้อมูลหนังสือเรียบร้อยแล้ว';
         } else {
             $alerts['danger']['Book'] = $model->errors;
         }
         if (!isset($alerts['danger'])) {
             if ($saveType === 'SaveAndNew') {
                 $this->redirect($this->createUrl('admin'));
             } else {
                 if ($isNew) {
                     $this->redirect($this->createUrl('admin', array('id' => $model->id)));
                 }
             }
         }
     }
     $this->render('admin', array('model' => $model, 'alerts' => $alerts));
 }
Exemplo n.º 21
0
 /**
  * @test
  */
 public function saveMultiple()
 {
     $book = Book::model()->findByPk(1);
     Yii::app()->language = 'pt';
     $book->title = 'O Diabo Veste Prada';
     $book->title_en = 'The Devil Wears Prada';
     $book->title_sv = 'Djävulen bär Prada';
     $saveResult = $book->save();
     $this->assertTrue($saveResult);
     $this->assertEquals($book->title_pt, 'O Diabo Veste Prada');
     $this->assertEquals($book->title_sv, 'Djävulen bär Prada');
     $this->assertEquals($book->title_en, 'The Devil Wears Prada');
     $book = Book::model()->findByPk(1);
     Yii::app()->language = 'en';
     $this->assertEquals($book->title_pt, 'O Diabo Veste Prada');
     $this->assertEquals($book->title_sv, 'Djävulen bär Prada');
     $this->assertEquals($book->title_en, 'The Devil Wears Prada');
     $this->assertEquals($book->title, 'The Devil Wears Prada');
 }
Exemplo n.º 22
0
 public function actionTranslations($id, $book_id)
 {
     $user = $this->loadUser($id);
     $book = Book::model()->with("membership")->findByPk((int) $book_id);
     if (!$book) {
         throw new CHttpException(404, "Перевода не существует. Вероятно, он удалён.");
     }
     if (!$book->can("read")) {
         throw new CHttpException(403, "Вы не можете просматривать версии перевода в этом проекте. " . $book->getWhoCanDoIt("read", false));
     }
     if (!$book->can("trread")) {
         throw new CHttpException(403, "Вы не можете просматривать версии перевода в этом проекте. " . $book->getWhoCanDoIt("trread", false));
     }
     $translations = new CActiveDataProvider(Translation::model()->userbook($user->id, $book->id)->with("orig.chap"), array("criteria" => array("order" => "t.cdate desc"), "pagination" => array("pageSize" => 20)));
     $this->side_view = array("profile_side" => array("user" => $user, "userinfo" => $user->userinfo));
     $this->render("translations", array("user" => $user, "book" => $book, "translations" => $translations));
 }
Exemplo n.º 23
0
<?php

$this->breadcrumbs = array('Books' => array('/library'), 'AllBooks');
$form = $this->beginWidget('CActiveForm', array('id' => 'book-form', 'enableAjaxValidation' => false));
?>
<h3><?php 
echo Yii::t('library', 'Book Details');
?>
</h3>
                      
<?php 
if (isset($book_id)) {
    $book = Book::model()->findAllByAttributes(array('id' => $book_id));
    if ($book != NULL) {
        ?>
                        <table width="100%" cellpadding="0" cellspacing="0" border="0" style="padding:10px; width:100%;">
<tr>
<td>Y<?php 
        echo Yii::t('library', 'Book Title');
        ?>
</td>
<td><?php 
        echo Yii::t('library', 'ISBN');
        ?>
</td>
<td><?php 
        echo Yii::t('library', 'Author');
        ?>
</td>
<td><?php 
        echo Yii::t('library', 'Copies Available');
Exemplo n.º 24
0
 /**
  * Note: This test assumes default Yii::t() fallback behavior
  * @test
  */
 public function furtherFallbackBehaviorTests()
 {
     $books = Book::model()->findAll();
     $book = $books[0];
     $this->assertEquals(2, count($books));
     $fooText = "Lean on me";
     Yii::app()->language = Yii::app()->sourceLanguage;
     $this->assertEquals($fooText, Yii::t('app', $fooText));
     Yii::app()->language = 'ch';
     $this->assertEquals($fooText, Yii::t('app', $fooText));
     $chapter = new Chapter();
     $chapter->_book_id = $book->id;
     $chapter->_title = $fooText;
     Yii::app()->language = 'en_us';
     $this->assertEquals($fooText, $chapter->title);
     Yii::app()->language = 'de';
     $this->assertEquals($fooText, $chapter->title);
     $saveResult = $chapter->save();
     $this->assertTrue($saveResult);
     $chapters = Chapter::model()->findAll();
     $chapter = $chapters[0];
     $this->assertEquals(1, count($chapters));
     $this->assertEquals($fooText, $chapter->title);
     $this->assertEquals($fooText, $chapter->title_de);
     $this->assertEquals($fooText, $chapter->title_ch);
     Yii::app()->language = 'ch';
     $this->assertEquals($book->title_en_us, $book->title_ch);
     $this->assertEquals($book->title_pt, 'O Diabo Veste Prada');
     $this->assertEquals($book->title_sv, 'Djävulen bär Prada');
     $this->assertEquals($book->title_en_us, 'The Devil Wears Prada');
     $this->assertEquals($book->title_en, 'The Devil Wears Prada');
 }
Exemplo n.º 25
0
$setup_stu = false;
$setup_emp = false;
$setup_cou = false;
$setup_fee = false;
$setup_tim = false;
$setup_lib = false;
$setup_hos = false;
$setup_tra = false;
$setups = 0;
$exp_stu = Students::model()->findAll();
$exp_emp = Employees::model()->findAll();
$exp_cou = Courses::model()->findAll();
$exp_fee = FinanceFeeCategories::model()->findAll();
$exp_tim = TimetableEntries::model()->findAll();
Yii::app()->getModule('library');
$exp_lib = Book::model()->findAll();
Yii::app()->getModule('hostel');
$exp_hos = Hosteldetails::model()->findAll();
Yii::app()->getModule('transport');
$exp_tra = RouteDetails::model()->findAll();
if (count($exp_stu)) {
    $setup_stu = true;
    $setups++;
}
if (count($exp_emp)) {
    $setup_emp = true;
    $setups++;
}
if (count($exp_cou)) {
    $setup_cou = true;
    $setups++;
Exemplo n.º 26
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $criteria = new CDbCriteria();
     // 创建CDbCriteria对象
     $criteria->condition = 'deal = 0';
     // 设置查询条件
     // echo $criteria->condition;
     $count = Book::model()->count($criteria);
     $this->render('index', array('count' => $count));
 }
Exemplo n.º 27
0
    ?>
</td>
<td align="center"><?php 
    echo Yii::t('library', 'Due Date');
    ?>
</td>
<td align="center"><?php 
    echo Yii::t('library', 'Is returned');
    ?>
</td>
</tr>

<?php 
    if ($book != NULL) {
        foreach ($book as $book_1) {
            $bookdetails = Book::model()->findByAttributes(array('id' => $book_1->book_id));
            $author = Author::model()->findByAttributes(array('auth_id' => $bookdetails->author));
            $publication = Publication::model()->findByAttributes(array('publication_id' => $bookdetails->publisher));
            ?>
<tr>

<td align="center"><?php 
            echo $student->last_name . ' ' . $student->first_name;
            ?>
</td>
<td align="center"><?php 
            echo $bookdetails->isbn;
            ?>
</td>
<td align="center"><?php 
            echo $bookdetails->title;
Exemplo n.º 28
0
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
 /**
  * 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 $id the ID of the model to be loaded
  * @return Book the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Book::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Exemplo n.º 30
0
    echo $row->id;
    ?>
">
        <?php 
    echo $row->id;
    ?>
</td>

      <td><?php 
    echo $row->name;
    ?>
</td>
	  <td>
		<?php 
    //$teachers = Teacher::model()->findByAttributes(array('id' => 'row->id'));
    $book = Book::model()->findByPk($row->id);
    $teachers = $book->teachers;
    echo $teachers->name;
    ?>
	  </td>
	  <td><?php 
    echo $row->year;
    ?>
</td>
      <td ><a href="<?php 
    echo $this->createUrl('update', array('id' => $row->id));
    ?>
"><img src="<?php 
    echo $this->_baseUrl;
    ?>
/static/admin/images/update.png" align="absmiddle" /></a>&nbsp;&nbsp;<a href="<?php