public function loadModel($id)
 {
     $model = Rooms::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 /**
  * 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);
     $this->zwDevices = $this->getDevices();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Devices'])) {
         $model->attributes = $_POST['Devices'];
         //get room by room id
         $room = Rooms::model()->findAllByPk($model->attributes['tbl_rooms_idtbl_room']);
         if (count($room)) {
             foreach ($room as $rm) {
                 file_get_contents(Yii::app()->params['serverurl'] . "/server.php?command=setnode&node=" . urlencode($model->attributes['tbl_device_nodeid']) . "&name=" . urlencode($model->attributes['tbl_device_name']) . "&zone=" . $rm->tbl_room_name);
             }
         }
         if ($model->save()) {
             //update server details
             $this->redirect(array('admin'));
         }
     }
     $this->render('update', array('model' => $model));
 }
Ejemplo n.º 3
0
<div class="form">

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

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

    <?php 
echo $form->errorSummary($model);
?>

    <?php 
echo $form->labelEx($model, 'Room');
$models = Rooms::model()->findAll(array('order' => 'tbl_room_name'));
$list = CHtml::listData($models, 'idtbl_room', 'tbl_room_name');
echo CHtml::dropDownList('room_id', null, array("" => "Select Room") + $list, array('ajax' => array('type' => 'POST', 'url' => CController::createUrl('sceneDevices/getdevices'), 'update' => '#' . CHtml::activeId($model, 'tbl_devices_idtbl_device'))));
?>

    <div class="row">	
    <?php 
if (isset($_GET["sceneId"])) {
    $model->tbl_scene_idtbl_scene = $_GET["sceneId"];
}
echo $form->hiddenField($model, 'tbl_scene_idtbl_scene');
?>
    </div>

    <div class="row">
       <?php 
Ejemplo n.º 4
0
<?php

/* @var $this ClassTypeController */
/* @var $model ClassType */
/* @var $form CActiveForm */
$roomData = Rooms::model()->findAll();
$roomArray = CHtml::listData($roomData, 'room_Id', 'room_Number');
?>
<script type="text/javascript">
function myfunction(){
	var start = new Date();
	var end = new Date();
	start = document.getElementById("start_time").value;
	 end = document.getElementById("end_time").value;
	diff(start, end);
}
function diff(start, end) {
    start = start.split(":");
    end = end.split(":");
    var startDate = new Date(0, 0, 0, start[0], start[1], 0);
    var endDate = new Date(0, 0, 0, end[0], end[1], 0);
    var diff = endDate.getTime() - startDate.getTime();
    var hours = Math.floor(diff / 1000 / 60 / 60);
    diff -= hours * 1000 * 60 * 60;
    var minutes = Math.floor(diff / 1000 / 60);

    //alert(hours +"==="+minutes);
    
    var data= (hours < 9 ? "0" : "") + hours + ":" + (minutes < 9 ? "0" : "") + minutes;
    if(data != "NaN:NaN"){
    document.getElementById("total").value = data;