예제 #1
0
 public function actionMark()
 {
     if (Yii::app()->request->isAjaxRequest && !Yii::app()->user->isGuest) {
         if (!isset($_GET['id'])) {
             throw new CHttpException(404, 'Страница не найденa');
         } else {
             $site_id = $_GET['id'];
             $site = Site::model()->findByPk($site_id);
             if ($site == null) {
                 throw new CHttpException(404, 'Страница не найденa');
             } else {
                 $mark = Mark::model()->find('site_id = :site_id AND user_id = :user_id', array('site_id' => $site->site_id, 'user_id' => Yii::app()->user->id));
                 if ($mark != null) {
                     $mark->delete();
                 }
                 $mark = new Mark();
                 $mark->user_id = Yii::app()->user->id;
                 $mark->site_id = $site_id;
                 $mark->value = $_POST['value'];
                 $mark->save();
                 print 'Ваш голос учтен';
                 Yii::app()->end();
             }
         }
     } else {
         throw new CHttpException(404, 'Страница не найдена');
     }
 }
예제 #2
0
</h1>

<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'models-form', 'enableAjaxValidation' => false));
?>

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

	<?php 
echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 256));
?>

	<?php 
echo $form->dropDownListRow($model, 'mark_id', CHtml::listData(Mark::model()->findAll(), 'id', 'name'), array('data-url' => Yii::app()->createUrl('modification/models'), 'name' => 'Models[mark_id]'));
?>

	<?php 
echo $form->checkBoxRow($model, 'pop');
?>

	<div class="form-actions">
		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Создать' : 'Сохранить'));
?>
	</div>

<?php 
$this->endWidget();
?>
예제 #3
0
<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'modification-form', 'enableAjaxValidation' => false));
?>

	<?php 
echo $form->errorSummary($model);
echo $form->dropDownListRow($model, 'markname', CHtml::listData(Mark::model()->findAll(), 'id', 'name'), array('data-url' => Yii::app()->createUrl('modification/models'), 'data-model_id' => $model->model_id, 'name' => 'Modification_markname'));
echo $form->dropDownListRow($model, 'modelname', array(), array('name' => 'Modification[model_id]'));
echo $form->textAreaRow($model, 'name', array('rows' => 6, 'cols' => 50, 'class' => 'span8'));
echo $form->textFieldRow($model, 'secode', array('class' => 'span5', 'maxlength' => 4));
echo $form->checkBoxRow($model, 'pop');
?>

	<div class="form-actions">
		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => $model->isNewRecord ? 'Создать' : 'Сохранить'));
?>
	</div>

<?php 
$this->endWidget();
?>

<script>
	$('#Modification_markname option[value="<?php 
echo Mark::model()->findByPk(Models::model()->findByPk($model->model_id)->mark_id)->id;
?>
"]').attr('selected', 'selected');
	$('body').addClass('modification_update_form');
</script>
예제 #4
0
<?php

$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get'));
?>

	<?php 
echo $form->textFieldRow($model, 'id', array('class' => 'span5', 'maxlength' => 10));
?>

	<?php 
echo $form->textFieldRow($model, 'name', array('class' => 'span5', 'maxlength' => 256));
?>

	<?php 
echo $form->dropDownListRow($model, 'mark_id', CHtml::listData(Mark::model()->findAll(), 'id', 'name'), array('name' => 'Models[mark_id]'));
?>

	<?php 
echo $form->checkBoxRow($model, 'pop');
?>

	<div class="form-actions">
		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => 'Искать'));
?>
	</div>

<?php 
$this->endWidget();
?>
예제 #5
0
 /**
  * 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 = Mark::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }