/**
  * 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']));
 }
 /**
  * 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 = BorrowBook::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#3
0
  <td>
  </td>
    <td valign="top">
     <div class="cont_right">  
     <h1><?php 
echo Yii::t('library', 'Return Book Details');
?>
</h1>
     <div class="formCon">
    <div class="formConInner">
    <?php 
echo '<strong>' . Yii::t('library', 'Student Admission No ') . '</strong>';
$data = Students::model()->findAll(array('join' => 'JOIN borrow_book ON t.id 	 = borrow_book.student_id', 'condition' => 'borrow_book.status =:x', 'distinct' => true, 'params' => array(':x' => 'C')));
echo CHtml::dropDownList('BookID', '', CHtml::listData($data, 'id', 'admission_no'), array('prompt' => 'Select', 'options' => array($_REQUEST['id'] => array('selected' => true)), 'id' => 'book_id', 'submit' => array('/library/ReturnBook/manage')));
if (isset($_REQUEST['id'])) {
    $book = BorrowBook::model()->findAll('student_id=:t2', array(':t2' => $_REQUEST['id']));
    $student = Students::model()->findByAttributes(array('id' => $_REQUEST['id']));
    ?>
                        </div>
                        </div>
                        <div class="pdtab_Con" style="padding:0px;">
                        <table width="100%" cellpadding="0" cellspacing="0" border="0" >
<tr class="pdtab-h">
<td align="center"><?php 
    echo Yii::t('library', 'Student Name');
    ?>
</td>
<td align="center"><?php 
    echo Yii::t('library', 'ISBN');
    ?>
</td>
示例#4
0
    <td width="247" valign="top">

 <?php 
$this->renderPartial('/settings/library_left');
?>
 </td>
    <td valign="top">
    <div class="cont_right formWrapper">
<h1><?php 
echo Yii::t('library', 'View ReturnBook');
?>
</h1>


<?php 
$borrow = BorrowBook::model()->findByAttributes(array('id' => $model->borrow_book_id));
$book = Book::model()->findByAttributes(array('id' => $borrow->book_id));
$student = Students::model()->findByAttributes(array('id' => $borrow->student_id));
?>
<div class="pdtab_Con">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
 <tr class="pdtab-h">
 <td align="center"><?php 
echo Yii::t('library', 'Student Name');
?>
</td>
 <td align="center"><?php 
echo Yii::t('library', 'Book');
?>
</td>
 <td align="center"><?php 
 public function actionSendsms()
 {
     $sms_settings = SmsSettings::model()->findAll();
     if ($sms_settings[0]->is_enabled == '1' and $sms_settings[8]->is_enabled == '1') {
         // Checking if SMS is enabled.
         /*echo "Due Date ID: ".$_REQUEST['due_date_id']."<br/>";
         		echo "Target Date: ".$_REQUEST['target_date']."<br/>";*/
         $message_status = $_REQUEST['due_date_id'];
         // Customising the list according to the due date
         if ($_REQUEST['due_date_id'] == 0) {
             $borrowbook = BorrowBook::model()->findAll('status=:x', array(':x' => 'C'));
         } elseif ($_REQUEST['due_date_id'] == -1) {
             $borrowbook = BorrowBook::model()->findAll('due_date < CURRENT_DATE() AND status=:y', array(':y' => 'C'));
         } else {
             // Setting the ID for redirecting
             if ($_REQUEST['due_date_id'] == 5) {
                 $_REQUEST['due_date_id'] = 2;
             } elseif ($_REQUEST['due_date_id'] == 10) {
                 $_REQUEST['due_date_id'] = 3;
             }
             $borrowbook = BorrowBook::model()->findAll('due_date=:x AND status=:y', array(':x' => $_REQUEST['target_date'], ':y' => 'C'));
         }
         foreach ($borrowbook as $book) {
             // For each book
             $bookdetails = Book::model()->findByAttributes(array('id' => $book->book_id));
             $student = Students::model()->findByAttributes(array('id' => $book->student_id));
             //echo $student->first_name."<br/>";
             $to = '';
             $message = '';
             if ($student->phone1) {
                 // Checking if phone number is provided
                 $to = $student->phone1;
             } elseif ($student->phone2) {
                 $to = $student->phone2;
             }
             if ($to != '') {
                 // If phone number is provided, send SMS
                 $college = Configurations::model()->findByPk(1);
                 $from = $college->config_value;
                 // Customising messages
                 if ($message_status == 0 or $message_status == 5 or $message_status == 10) {
                     $message = 'Due date for returning the book "' . $bookdetails->title . '" : ' . $book->due_date;
                 } elseif ($message_status == -1) {
                     $message = 'Due date for returning the book "' . $bookdetails->title . '" was ' . $book->due_date;
                 } elseif ($message_status == 1) {
                     $message = 'Due date for returning the book "' . $bookdetails->title . '" is ' . $book->due_date . '. Please return or renew the book by tomorrow.';
                 }
                 //echo $message."<br/><br/>";
                 if ($message != '') {
                     // Send SMS if message is set
                     // SmsSettings::model()->sendSms($to,$from,$message);
                     Yii::app()->user->setFlash('notification', 'Library SMS is disabled!');
                 }
             }
             // End check phone number
         }
         // End for each book
     }
     // End check whether SMS is enabled
     $this->redirect(array('settings', 'id' => $_REQUEST['due_date_id']));
 }
示例#6
0
<div class="form">

<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'return-book-form', 'enableAjaxValidation' => false));
?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<?php 
echo $form->errorSummary($model);
if (Yii::app()->controller->action->id == 'create') {
    if (isset($_REQUEST['id']) and $_REQUEST['id'] != NULL) {
        $bookid = $_REQUEST['id'];
        $student_details = BorrowBook::model()->findByAttributes(array('student_id' => $bookid, 'status' => 'C'));
        $student = Students::model()->findByAttributes(array('id' => $bookid));
        $book = Book::model()->findByAttributes(array('id' => $student_details->book_id));
    }
}
?>
<div class="formCon">
<div class="formConInner">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td><?php 
echo $form->labelEx($model, Yii::t('library', 'student_id'));
?>
</td>
    <td>&nbsp;</td>
    <td><?php 
echo $form->textField($model, 'student_id', array('value' => $student->last_name . ' ' . $student->first_name));
示例#7
0
?>
    
    </td>
    <td valign="top">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td valign="top" width="75%">
        <div class="cont_right">
<h1><?php 
echo Yii::t('library', 'Library Dashboard');
?>
</h1>
<?php 
$due = BorrowBook::model()->findAll('due_date=:x', array(':x' => date('Y-m-d')));
$return = ReturnBook::model()->findAll('return_date=:x', array(':x' => date('Y-m-d')));
$borrow = BorrowBook::model()->findAll('issue_date=:x', array(':x' => date('Y-m-d')));
?>
<div class="overview">
	<div class="overviewbox ovbox1">
    	<h1><strong><?php 
echo Yii::t('library', 'Due Today');
?>
</strong></h1>
        <div class="ovrBtm"><?php 
echo count($due);
?>
</div>
    </div>
    <div class="overviewbox ovbox2">
    	<h1><strong><?php 
echo Yii::t('library', 'Returned Today');
示例#8
0
    if ($_REQUEST['id'] == 1) {
        $currdate = date('Y-m-d');
        $targetdate = date('Y-m-d', strtotime('+1 day', strtotime($currdate)));
        echo $targetdate;
    }
    if ($_REQUEST['id'] == 2) {
        $currdate = date('Y-m-d');
        $targetdate = date('Y-m-d', strtotime('+5 day', strtotime($currdate)));
        echo $targetdate;
    }
    if ($_REQUEST['id'] == 3) {
        $currdate = date('Y-m-d');
        $targetdate = date('Y-m-d', strtotime('+10 day', strtotime($currdate)));
        echo $targetdate;
    }
    $duedate = BorrowBook::model()->findAll('due_date=:x AND status=:y', array(':x' => $targetdate, ':y' => 'C'));
    ?>
         <table width="100%" cellpadding="0" cellspacing="0" border="0" style="padding:10px; width:100%;">
<tr>
<td><?php 
    echo Yii::t('library', 'Student Name');
    ?>
</td>
<td><?php 
    echo Yii::t('library', 'ISBN');
    ?>
</td>
<td><?php 
    echo Yii::t('library', 'Book Name');
    ?>
</td>
示例#9
0
                           <?php 
    } else {
        ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="247" valign="top">
   <?php 
        $this->renderPartial('/settings/library_left');
        ?>
 </td>
    <td valign="top">  
    <div class="cont_right">                
<?php 
        if (isset($book_id)) {
            echo '<h3>' . Yii::t('library', 'View borrowed book details') . '</h3> ';
            $book = BorrowBook::model()->findAllByAttributes(array('book_id' => $book_id, 'status' => 'C'));
            $bookdetails = Book::model()->findByAttributes(array('id' => $book_id));
            ?>
                <div class="pdtab_Con">
                       <table width="100%" cellpadding="0" cellspacing="0" border="0" >
						<tr class="pdtab-h">
						<td align="center"><?php 
            echo Yii::t('library', 'Student Name');
            ?>
</td>
						<td align="center"><?php 
            echo Yii::t('library', 'Book Name');
            ?>
</td>
                        <td align="center"><?php 
            echo Yii::t('library', 'ISBN');