Skip to content

Commit

Permalink
Исправления для gorod.mos
Browse files Browse the repository at this point in the history
  • Loading branch information
vlasovilya committed Jul 22, 2014
1 parent d8d8e31 commit 24ae6fb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions protected/models/DorogiMosForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ public function rules()
array('details', 'length', 'max'=>690),
array('notifyViaEmail, notifyViaSms', 'numerical', 'integerOnly'=>true),
array('todayCount', 'numerical', 'integerOnly'=>true, 'max'=>$this->maxTodayCount, 'tooBig'=>'Вы пытаетесь отправлять слишком много заявлений. Максимальное число заявлений в день = {max} шт.'),
array('todayCount', 'checkDuplicates'),
array('email', 'email'),
);
}

public function checkDuplicates($attribute,$params)
{
$prevRequest=HoleRequests::model()->find(Array('condition'=>'type="dorogimos" AND user_id='.Yii::app()->user->id, 'order'=>'date_sent DESC'));
if ($prevRequest && $prevRequest->date_sent>=time()-3) $this->addError($attribute, 'Вы пытаетесь отправлять заявления слишком часто.');
}


public function getClient()
{
Expand Down Expand Up @@ -134,6 +141,7 @@ public function getTodaySended(){
public function beforeValidate(){
parent::beforeValidate();
$this->todayCount=$this->todaySended;
if (Yii::app()->user->email) $this->email=Yii::app()->user->email;
return true;
}

Expand Down
7 changes: 6 additions & 1 deletion protected/views/holes/_form_dorogimos.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
text: "Отправить",
click: function(){
$("#dorogimos-request-form").submit();
return false;
}
},' : '').'
{
Expand Down Expand Up @@ -55,16 +56,19 @@
<?php echo $form->textField($model,'name',array('size'=>60)); ?>
<?php echo $form->error($model,'name'); ?>
</div>
<!--
<div class="row">
<?php echo $form->labelEx($model,'fatherName'); ?>
<?php echo $form->textField($model,'fatherName',array('size'=>60)); ?>
<?php echo $form->error($model,'fatherName'); ?>
</div>
-->
<div class="row">
<?php echo $form->labelEx($model,'email'); ?>
<?php echo $form->textField($model,'email',array('size'=>60)); ?>
<?php echo $form->textField($model,'email',array('size'=>60, 'disabled'=>$model->email ? true : null)); ?>
<?php echo $form->error($model,'email'); ?>
</div>
<!--
<div class="row">
<?php echo $form->labelEx($model,'phoneNumber'); ?>
<?php echo $form->textField($model,'phoneNumber',array('size'=>60)); ?>
Expand All @@ -90,6 +94,7 @@
<?php echo $form->error($model,'notifyViaSms'); ?>
</div>
</div>
-->

<div class="row">
<?php echo $form->labelEx($model,'holeAddress'); ?>
Expand Down

0 comments on commit 24ae6fb

Please sign in to comment.