PageRenderTime 57ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/protected/views/reservation/_reservationForm.php

https://bitbucket.org/evipstudio_team/wroclawski-adres.pl
PHP | 212 lines | 199 code | 9 blank | 4 comment | 23 complexity | ad3951ab2e4c22b424c27af1e118060b MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1
  1. <div class="form resrv">
  2. <?php $form = $this->beginWidget('CActiveForm', array('action' => $action, 'id' => 'reservationForm', 'htmlOptions' => array('enctype' => 'multipart/form-data'))); ?>
  3. <?= $form->errorSummary($model); ?>
  4. <?if(Yii::app()->user->checkAccess('CmsUser')):?>
  5. <div class="row">
  6. <?= $form->labelEx($model, 'user_id'); ?>
  7. <?= $form->dropDownList($model, 'user_id', array('' => '') + CHtml::listData(User::model()->findAll(array('condition' => '`role`=\'client\' AND status=\'active\'', 'order' => 'surname')), 'id', 'fullName')) ?>
  8. </div>
  9. <?endif?>
  10. <div class="row">
  11. <?= $form->labelEx($model, 'type'); ?>
  12. <?= $form->dropDownList($model, 'type', array('' => '') + ZHtml::enumItem($model, 'type')) ?>
  13. </div>
  14. <div class="row">
  15. <?= CHtml::activeLabelEx($model, 'date_from'); ?>
  16. <?
  17. $this->widget('zii.widgets.jui.CJuiDatePicker', array(
  18. 'model' => $model,
  19. 'attribute' => 'date_from',
  20. 'language'=>Yii::app()->language,
  21. // 'options'=>array('dateFormat'=>'dd/mm/yy'),
  22. 'options'=>array('dateFormat'=>'yy-mm-dd', 'minDate'=>1),
  23. // 'htmlOptions' => array('size' => 10, 'maxlength' => 10, 'value'=>$model->formatDate('date_from')),
  24. 'htmlOptions' => array('size' => 10, 'maxlength' => 10, 'onChange'=>'loadRooms()'),
  25. ));
  26. ?>
  27. <?
  28. $this->widget('application.extensions.jui_timepicker.JTimePicker', array(
  29. 'model' => $model,
  30. 'attribute' => 'time_from',
  31. 'options' => array(
  32. 'rows'=>1,
  33. 'hourText'=>'Godzina',
  34. 'minuteText'=>'Minuta',
  35. 'showPeriod' => false,
  36. 'showPeriodLabels'=>false,
  37. 'hours'=> array('starts'=>intval(array_shift(explode(':', Yii::app()->params['AvailabilityFrom']))), 'ends'=>intval(array_shift(explode(':', Yii::app()->params['AvailabilityTo'])))),
  38. 'minutes'=> array('starts'=>0, 'ends'=>30, 'interval'=>30)
  39. ),
  40. 'htmlOptions' => array('size' => 8, 'maxlength' => 8, 'value'=>$model->formatTime('time_from'), 'onChange'=>'loadRooms()'),
  41. ))
  42. ?>
  43. (cały dzień: <?= $form->checkBox($model, 'from_all_day') ?>)
  44. </div>
  45. <div class="row">
  46. <?= CHtml::activeLabelEx($model, 'date_to'); ?>
  47. <?
  48. $model->formatDate('date_to');
  49. $this->widget('zii.widgets.jui.CJuiDatePicker', array(
  50. 'model' => $model,
  51. 'attribute' => 'date_to',
  52. 'language'=>Yii::app()->language,
  53. // 'options'=>array('dateFormat'=>'dd/mm/yy'),
  54. 'options'=>array('dateFormat'=>'yy-mm-dd', 'minDate'=>1),
  55. // 'htmlOptions' => array('size' => 10, 'maxlength' => 10, 'value'=>$model->formatDate('date_to')),
  56. 'htmlOptions' => array('size' => 10, 'maxlength' => 10, 'onChange'=>'loadRooms()'),
  57. ));
  58. ?>
  59. <?
  60. $this->widget('application.extensions.jui_timepicker.JTimePicker', array(
  61. 'model' => $model,
  62. 'attribute' => 'time_to',
  63. 'options' => array(
  64. 'rows'=>1,
  65. 'hourText'=>'Godzina',
  66. 'minuteText'=>'Minuta',
  67. 'showPeriod' => false,
  68. 'showPeriodLabels'=>false,
  69. 'hours'=> array('starts'=>intval(array_shift(explode(':', Yii::app()->params['AvailabilityFrom']))), 'ends'=>intval(array_shift(explode(':', Yii::app()->params['AvailabilityTo'])))),
  70. 'minutes'=> array('starts'=>0, 'ends'=>30, 'interval'=>30)
  71. ),
  72. 'htmlOptions' => array('size' => 8, 'maxlength' => 8, 'value'=>$model->formatTime('time_to'), 'onChange'=>'loadRooms()'),
  73. ))
  74. ?>
  75. (cały dzień: <?= $form->checkBox($model, 'to_all_day') ?>)
  76. </div>
  77. <div id="roomsPossibilites">
  78. </div>
  79. <div class="row">
  80. <?= $form->labelEx($model, 'comment'); ?>
  81. <?= $form->textArea($model, 'comment', array('rows' => 6, 'cols' => 30, 'style' => 'width: 98%')); ?>
  82. </div>
  83. *pola wymagane
  84. <?php $this->endWidget(); ?>
  85. </div>
  86. <script type="text/javascript">
  87. function loadRooms() {
  88. if($('#Reservation_type').val() && $('#Reservation_date_from').val() && $('#Reservation_date_to').val()) {
  89. $('#LoadingDialogBox').dialog('open');
  90. $.ajax({
  91. url: '<?= $this->createUrl('reservation/ShowRoomPossibilites') ?>/type/'+$('#Reservation_type').val()+'/id/'+<?=(($model->id)? $model->id:0)?>+'/date_from/'+$('#Reservation_date_from').val()+'/time_from/'+$('#Reservation_time_from').val()+'/from_all_day/'+$('#Reservation_from_all_day').is(':checked')+'/date_to/'+$('#Reservation_date_to').val()+'/time_to/'+$('#Reservation_time_to').val()+'/to_all_day/'+$('#Reservation_to_all_day').is(':checked'),
  92. type: 'get',
  93. success: function(data) {
  94. $('#roomsPossibilites').html(data);
  95. $('#LoadingDialogBox').dialog('close');
  96. }
  97. });
  98. }
  99. else {
  100. $('#roomsPossibilites').html('');
  101. }
  102. }
  103. $(function() {
  104. $( "#DialogBox" ).dialog( "option", "width", '550');
  105. $( "#DialogBox" ).dialog( "option", "height", 'auto');
  106. $( "#DialogBox" ).dialog( "option", "position", 'center');
  107. $('#Reservation_type').change(function() {loadRooms()});
  108. $('#Reservation_date_from').change(function() {loadRooms()});
  109. $('#Reservation_date_to').change(function() {loadRooms()});
  110. loadRooms();
  111. $( "#DialogBox" ).dialog( "option", "buttons", [
  112. <?if(!$model->isNewRecord):?>
  113. {
  114. text: "Usuń",
  115. click: function() {
  116. if(confirm("Czy jesteś pewien że chcesz usunąć rezerwację?")) {
  117. $.ajax({
  118. url: '<?=$this->createUrl('reservation/delete',array('id'=>$model->id))?>',
  119. type: 'get',
  120. success: function(data) {
  121. refreshCalendar();
  122. }
  123. });
  124. }
  125. $( this ).dialog( "close" );
  126. }
  127. },
  128. <?endif?>
  129. {
  130. text: "Anuluj",
  131. click: function() {
  132. refreshCalendar();
  133. $( this ).dialog( "close" );
  134. }
  135. },
  136. {
  137. text: "<?=$model->saveButtonText()?>",
  138. click: function() {
  139. $('#LoadingDialogBox').dialog('open');
  140. $.ajax({
  141. url: $('#reservationForm').attr('action'),
  142. type: 'post',
  143. data: $('#reservationForm').serializeArray(),
  144. success: function(data) {
  145. $( "#DialogBox" ).html(data);
  146. $('#LoadingDialogBox').dialog('close');
  147. }
  148. });
  149. }
  150. }
  151. ]);
  152. var tmp_from;
  153. $('#Reservation_from_all_day').change(function() {
  154. if($(this).is(':checked') && !$('#Reservation_time_from').is(':disabled')) {
  155. $('#Reservation_time_from').attr('disabled','disabled');
  156. tmp_from = $('#Reservation_time_from').val();
  157. $('#Reservation_time_from').val('cały dzień');
  158. }
  159. else
  160. if($('#Reservation_time_from').is(':disabled')){
  161. $('#Reservation_time_from').attr('disabled',false);
  162. $('#Reservation_time_from').val(tmp_from);
  163. }
  164. if($('#Reservation_date_from').val() == $('#Reservation_date_to').val()) {
  165. if($(this).is(':checked') && !$('#Reservation_to_all_day').is(':checked')) {
  166. $('#Reservation_to_all_day').attr('checked',true);
  167. $('#Reservation_to_all_day').change();
  168. }
  169. else
  170. if(!$(this).is(':checked') && $('#Reservation_to_all_day').is(':checked')) {
  171. $('#Reservation_to_all_day').attr('checked',false);
  172. $('#Reservation_to_all_day').change();
  173. }
  174. }
  175. });
  176. var tmp_to;
  177. $('#Reservation_to_all_day').change(function() {
  178. if($(this).is(':checked') && !$('#Reservation_to_from').is(':disabled')) {
  179. $('#Reservation_time_to').attr('disabled','disabled');
  180. tmp_to = $('#Reservation_time_to').val();
  181. $('#Reservation_time_to').val('cały dzień');
  182. }
  183. else
  184. if($('#Reservation_time_to').is(':disabled')){
  185. $('#Reservation_time_to').attr('disabled',false);
  186. $('#Reservation_time_to').val(tmp_to);
  187. }
  188. if($('#Reservation_date_from').val() == $('#Reservation_date_to').val()) {
  189. if($(this).is(':checked') && !$('#Reservation_from_all_day').is(':checked')) {
  190. $('#Reservation_from_all_day').attr('checked',true);
  191. $('#Reservation_from_all_day').change();
  192. }
  193. else
  194. if(!$(this).is(':checked') && $('#Reservation_from_all_day').is(':checked')) {
  195. $('#Reservation_from_all_day').attr('checked',false);
  196. $('#Reservation_from_all_day').change();
  197. }
  198. }
  199. });
  200. $('#Reservation_from_all_day').change();
  201. $('#Reservation_to_all_day').change();
  202. });
  203. </script>