I have to select the date from the database and return it to the form as a table, and put the data in the table. I do it like this: I choose a date:

<div class="row"> <?php echo $form->labelEx($model,'L_BEGIN'); ?> <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array( //'id' => 'L_BEGIN', 'id' => CHtml::getIdByName(get_class($model) . '[L_BEGIN]'), 'name' => 'L_BEGIN', 'value'=>$model, 'model' => $model, 'attribute' => 'L_BEGIN', 'language' => 'ru', 'options' => array( 'showAnim' => 'slide', 'dateFormat'=>'dd.mm.yy', 'minDate'=>'01.10.2014', 'maxDate'=>date("dmY"), 'showAnim' =>'slide', 'showOtherMonths'=>true, 'selectOtherMonths'=>true, 'showButtonPanel'=>true, 'changeMonth'=>true, 'changeYear'=>true,), 'htmlOptions' => array( 'style' => 'height:20px;', //'value' => date('dmY'), 'readonly'=>'readonly', 'onchange'=>'typeOfDate()', // 'readonly'=>'readonly', // "name"=>'start' ),));?> <?php echo $form->error($model,'L_BEGIN'); ?> </div> 

script:

 <script> function typeOfDate(){ var flag=0; var ok = $('#PLATLGOTA1_L_BEGIN').val(); $.ajax({ url: "index.php?r=PLATLGOTA1/getday", type: 'POST', data: 'date='+ok, dataType:'json', timeout:1000, success: function(data){ console.log(flag); if(flag!=0) { $("#PLATLGOTA1_summa_uplat").val(data); console.log($("#summa_uplat").val(data)); } } }) flag=1; }; </script> 

And in the controller I do this:

  public function actionGetday() { $ldate = ""; $l_begin= $_POST['date']; //получили дату $time = strtotime($l_begin); $final = date("dmY", strtotime("+1 month", $time)); //добовляем один месяц $KBK=""; $summa_uplat=""; $cn=Yii::app()->db; $dataReader=$cn->createCommand('select id,date,okpo,predpr,type_nalog,SUM(nachislen) as summ FROM lickart_t_r1a where > type_nalog like "%710%" AND type_nalog not like "71010000" AND type_nalog not >like "71050000" AND okpo="2170123590" and str_to_date(date,"%Y-%m-%d") >str_to_date("'.$final.'","%d.%m.%Y") GROUP BY type_nalog')->query()->readall(); foreach ($dataReader as $dataRa) { $KBK=$dataRa['type_nalog']; $summa_uplat=$dataRa['summ']; } $arr = array($summa_uplat); $response =json_encode($arr); echo $response; } 

Who can helps how to make that the data was displayed in the table? Thanks in advance.

    0