<li id="li-element-<?php echo $element ?>">
    <?php echo CHtml::activeLabel($model, 'dateStart', array('class' => 'noblock')); ?> /
    <?php echo CHtml::activeLabel($model, 'dateEnd', array('class' => 'noblock')); ?><br/>
    <?php
    $this->widget('application.extensions.FJuiDatePicker', array(
        'model' => $model,
        'attribute' => 'dateStart[' . $element . ']',
        'range' => 'eval_period_elem_' . $element . '',
        'language' => Yii::app()->controller->datePickerLang,
        'options' => array(
            'showAnim' => 'fold',
            'dateFormat' => 'yy-mm-dd',
            'minDate' => 'new Date()',
        ),
        'htmlOptions' => array(
            'class' => 'width90 span2 form-control inline select-booking-date',
            'readonly' => 'true',
        ),
    ));

    ?>
    <?php echo CHtml::dropDownList('dateTimeIn[' . $element . ']', '', HBooking::getTimesIn(), array('class' => 'span2 width150 form-control inline')) ?>
    /
    <?php
    $this->widget('application.extensions.FJuiDatePicker', array(
        'model' => $model,
        'attribute' => 'dateEnd[' . $element . ']',
        'range' => 'eval_period_elem_' . $element . '',
        'language' => Yii::app()->controller->datePickerLang,
        'options' => array(
            'showAnim' => 'fold',
            'dateFormat' => 'yy-mm-dd',
            'minDate' => 'new Date()',
        ),
        'htmlOptions' => array(
            'class' => 'width90 span2 form-control inline select-booking-date',
            'readonly' => 'true',
        ),
    ));

    ?>
    <?php echo CHtml::dropDownList('dateTimeOut[' . $element . ']', '', HBooking::getTimesOut(), array('class' => 'span2 width150 form-control inline')) ?>

    <br/>

    <?php echo CHtml::dropDownList('status[' . $element . ']', '', Bookingcalendar::getAllStatuses(), array('class' => 'span2 width200 form-control inline')) ?>
    <?php echo CHtml::button(tc('Save'), array('id' => 'bookings-save-' . $element . '', 'class' => 'bookings-save')) ?>
    <?php echo CHtml::button(tc('Delete'), array('id' => 'bookings-delete-' . $element . '', 'class' => 'bookings-delete')) ?>
    <br/><span id="status-save-<?php echo $element; ?>">&nbsp;</span>
    <div id="date_<?php echo $element ?>_error" class="errorMessage"
         style="display: none;"><?php echo tt('Fill fields', 'bookingcalendar'); ?></div>
</li>
<script>
    $(document).ready(function () {
        $("#bookings-delete-<?php echo $element; ?>").click(function () {
            $("#li-element-<?php echo $element; ?>").hide('slow');
            return false;
        });
        $("#bookings-save-<?php echo $element; ?>").click(function () {
            var id = "<?php echo $element; ?>";
            if ($('#Bookingcalendar_dateStart_' + id).val().length > 0 && $('#Bookingcalendar_dateEnd_' + id).val().length > 0) {
                var bookingStart = $('#Bookingcalendar_dateStart_' + id).val();
                var bookingEnd = $('#Bookingcalendar_dateEnd_' + id).val();
                var bookingStatus = $('#status_' + id).val();
                var bookingTimeIn = $('#dateTimeIn_' + id).val();
                var bookingTimeOut = $('#dateTimeOut_' + id).val();

                $('#date_' + id + '_error').hide();

                $.ajax({
                    success: function (msg) {
                        if (msg == "ok") {
                            $("#status-save-" + id).addClass('status-save-success').html(<?= CJavaScript::encode(tc("Success")) ?>);
                        } else if (msg == "access_error") {
                            $("#status-save-" + id).addClass('status-save-error').html(<?= CJavaScript::encode(tt("Access denied", "bookingcalendar")) ?>);
                        } else if (msg == "error_filling") {
                            $('#date_' + id + '_error').show();
                        } else if (msg == "error_save") {
                            $("#status-save-" + id).addClass('status-save-error').html(<?= CJavaScript::encode(tc("Error. Repeat attempt later")) ?>);
                        } else {
                            document.location.href = msg;
                        }
                        setTimeout('hideMessageDb($("#status-save-' + id + '"))', 4000);
                    },
                    type: 'get',
                    url: booking_save_url,
                    data: {
                        dateStart: bookingStart,
                        dateEnd: bookingEnd,
                        dateStatus: bookingStatus,
                        apId: apId,
                        dateTimeIn: bookingTimeIn,
                        dateTimeOut: bookingTimeOut
                    },
                    cache: false
                });
            } else {
                $('#date_' + id + '_error').show();
            }
            return false;
        });
    });
</script>