<?php $this->pageTitle = Yii::app()->name . ' - ' . tt('Booking apartment', 'booking'); $this->menu = array(array()); $this->adminTitle = tt('Booking apartment', 'booking'); ?> <?php if (issetModule('bookingcalendar')) { echo "<div class='flash-notice'>" . tt('booking_table_to_calendar', 'booking') . "</div>"; } ?> <?php $this->widget('CustomGridView', array('id' => 'admin-booking-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'afterAjaxUpdate' => 'function(){$("a[rel=\'tooltip\']").tooltip(); $("div.tooltip-arrow").remove(); $("div.tooltip-inner").remove();}', 'columns' => array(array('name' => 'id', 'htmlOptions' => array('class' => 'id_column')), array('name' => 'active', 'type' => 'raw', 'value' => 'Yii::app()->controller->returnBookingTableStatusHtml($data, "users-booking-grid", 1)', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Bookingtable::getAllStatuses()), array('name' => 'apartment_id', 'type' => 'raw', 'value' => '(isset($data->apartment) && $data->apartment->id) ? CHtml::link($data->apartment->id, $data->apartment->getUrl()) : tc("No")', 'filter' => false, 'sortable' => false), array('name' => 'username', 'value' => '$data->username', 'sortable' => false), array('name' => 'email', 'value' => '$data->email', 'sortable' => false), array('name' => 'phone', 'value' => '$data->phone', 'sortable' => false), array('name' => 'comment', 'value' => '$data->comment', 'sortable' => false), array('name' => 'date_start', 'value' => '(isset($data->timein) && $data->time_in) ? $data->date_start . " (". $data->timein->getStrByLang("title").")" : "" ', 'filter' => false, 'sortable' => false, 'htmlOptions' => array('style' => 'width:150px;')), array('name' => 'date_end', 'value' => '(isset($data->timeout) && $data->time_out) ? $data->date_end . " (". $data->timeout->getStrByLang("title").")" : "" ', 'filter' => false, 'sortable' => false, 'htmlOptions' => array('style' => 'width:150px;')), array('header' => tt('Creation date', 'booking'), 'value' => '$data->date_created', 'type' => 'raw', 'sortable' => false)))); Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl . '/js/jquery.jeditable.js', CClientScript::POS_END); Yii::app()->clientScript->registerScript('editable_select_booking_table_admin', "\n\t\tfunction ajaxSetBookingTableStatus(elem, id, id_elem, items){\n\t\t\t\$('#editable_select-'+id_elem).editable('" . Yii::app()->controller->createUrl("bookingtableactivate") . "', {\n\t\t\t\tdata : items,\n\t\t\t\ttype : 'select',\n\t\t\t\tcancel : '" . tc('Cancel') . "',\n\t\t\t\tsubmit : '" . tc('Ok') . "',\n\t\t\t\tstyle : 'inherit',\n\t\t\t\tsubmitdata : function() {\n\t\t\t\t\treturn {id : id_elem};\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t", CClientScript::POS_HEAD);
<?php $this->pageTitle .= ' - ' . tt('Booking applications', 'usercpanel'); $this->breadcrumbs = array(tc('Control panel') => Yii::app()->createUrl('/usercpanel'), tt('Booking applications', 'usercpanel')); if (issetModule('bookingcalendar')) { echo "<div class='flash-notice'>" . tt('booking_table_to_calendar', 'booking') . "</div>"; } ?> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'users-booking-grid', 'dataProvider' => $model->search(true), 'filter' => $model, 'columns' => array(array('name' => 'active', 'type' => 'raw', 'value' => 'Yii::app()->controller->returnBookingTableStatusHtml($data, "users-booking-grid", 1)', 'htmlOptions' => array('style' => 'width: 150px;'), 'sortable' => false, 'filter' => Bookingtable::getAllStatuses()), array('name' => 'apartment_id', 'type' => 'raw', 'value' => '(isset($data->apartment) && $data->apartment->id) ? CHtml::link($data->apartment->id, $data->apartment->getUrl()) : tc("No")', 'filter' => false, 'sortable' => false), array('name' => 'username', 'value' => '$data->username', 'filter' => true, 'sortable' => false), array('name' => 'email', 'value' => '$data->email', 'filter' => true, 'sortable' => false), array('name' => 'phone', 'value' => '$data->phone', 'filter' => true, 'sortable' => false), array('name' => 'comment', 'value' => 'truncateText($data->comment)', 'filter' => true, 'sortable' => false), array('name' => 'date_start', 'value' => '(isset($data->timein) && $data->time_in) ? $data->date_start . " (". $data->timein->getStrByLang("title").")" : "" ', 'filter' => true, 'sortable' => false, 'htmlOptions' => array('style' => 'width:150px;')), array('name' => 'date_end', 'value' => '(isset($data->timeout) && $data->time_out) ? $data->date_end . " (". $data->timeout->getStrByLang("title").")" : "" ', 'filter' => true, 'sortable' => false, 'htmlOptions' => array('style' => 'width:150px;')), array('header' => tt('Creation date', 'booking'), 'value' => '$data->date_created', 'type' => 'raw', 'filter' => false, 'sortable' => false)))); Yii::app()->clientScript->registerScriptFile(Yii::app()->request->baseUrl . '/js/jquery.jeditable.js', CClientScript::POS_END); Yii::app()->clientScript->registerScript('editable_select_booking_table', "\n\t\tfunction ajaxSetBookingTableStatus(elem, id, id_elem, items){\n\t\t\t\$('#editable_select-'+id_elem).editable('" . Yii::app()->controller->createUrl("bookingtableactivate") . "', {\n\t\t\t\tdata : items,\n\t\t\t\ttype : 'select',\n\t\t\t\tcancel : '" . tc('Cancel') . "',\n\t\t\t\tsubmit : '" . tc('Ok') . "',\n\t\t\t\tstyle : 'inherit',\n\t\t\t\tsubmitdata : function() {\n\t\t\t\t\treturn {id : id_elem};\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t", CClientScript::POS_HEAD);
public function actionBookingTableActivate() { $field = isset($_GET['field']) ? $_GET['field'] : 'active'; if (Yii::app()->request->getParam('id') && Yii::app()->request->getParam('value') != null) { $this->scenario = 'update_status'; $action = Yii::app()->request->getParam('value', null); $id = Yii::app()->request->getParam('id', null); $availableStatuses = Bookingtable::getAllStatuses(); if (!array_key_exists($action, $availableStatuses)) { $action = 0; } } if (!(!$id && $action === null)) { $model = $this->loadModelUserBookingTable($id); if ($this->scenario) { $model->scenario = $this->scenario; } if ($model) { $model->{$field} = $action; $model->save(false); if (issetModule('bookingcalendar')) { if ($field == 'active' && $action == Bookingtable::STATUS_CONFIRM) { $modelBookingCalendar = new Bookingcalendar(); $modelBookingCalendar->date_start = $model->date_start; $modelBookingCalendar->date_end = $model->date_end; $modelBookingCalendar->status = Bookingcalendar::STATUS_BUSY; $modelBookingCalendar->apartment_id = $model->apartment_id; $modelBookingCalendar->save(false); } } } } echo CHtml::link($availableStatuses[$action]); }