Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

Jappendo With Upload + Cjuidialog

$
0
0
can anyone help me??
i have a form like this :

: Capture.PNG

my problem are :
1. in Cjuidialog where we choose in 2nd, the firs textfield changed
2. upload file cant uploaded

form appendo :
<table class="appendo-gii" id="<?php echo $id ?>">
	<thead>
		<tr>
			<td>Nama</td>
			<td>Tanggal</td>
			<td>File</td>
		</tr>
	</thead>
	<tbody>
    <?php if ($model->nama_dokter == null): ?>
		<tr>
			<td>
				<?php echo CHtml::hiddenField('kd_dokter[]','',array('id'=>'kd_dokter')); ?> 
				<?php echo CHtml::textField('nama_dokter[]','',array('id'=>'nama_dokter')); ?> 
				<?php echo CHtml::Button('x', array('name' => 'del_people', 'id' => 'del_people', 'onclick' => '$("#nama_dokter").val("");$("#kd_dokter").val("")')) ?>
				<?php echo CHtml::Button('Get Dokter', array('onclick' => '$("#dialogdokter").dialog("open"); return false;',)); ?>
			</td>
            <td>
				<?php echo CHtml::dropDownList('bulan[]',"string",
					array("1"=>"Januari",
						  "2"=>"Februari",
						  "3"=>"Maret",
						  "4"=>"April",
						  "5"=>"Mei",
						  "6"=>"Juni",
						  "7"=>"Juli",
						  "8"=>"Agustus",
						  "9"=>"September",
						  "10"=>"Oktober",
						  "11"=>"November",
						  "12"=>"Desember",),
					array('style'=>'width:100px'));
				?>
			</td>
			<td>
				<?php echo CHtml::fileField('nama_file[]',''); ?>
			</td>
		</tr>
    <?php else: ?>
        <?php for($i = 0; $i < sizeof($model->nama_dokter); ++$i): ?>
    		<tr>
    			<td>
					<?php echo CHtml::hiddenField('kd_dokter[]',$model->enum_name[$i],array('id'=>'kd_dokter')); ?> 
					<?php echo CHtml::textField('nama_dokter[]',$model->enum_name[$i],array('style'=>'width:120px')); ?>
				</td>
                <td>
					<?php
					$this->widget('zii.widgets.jui.CJuiDatePicker', array(
						'name'=>'tgl_upload[]',
						'value'=>$model->enum_name[$i],
						 'options'=>array(
							'showAnim'=>'fold',
							'dateFormat'=>'yy-mm-dd',
						),
						'htmlOptions'=>array(
							'style'=>'height:20px;'
						),
					));
					?>
				</td>
                <td>
					<?php echo CHtml::fileField('nama_file[]',$model->enum_name[$i]); ?>
                </td>
            </tr>
        <?php endfor; ?>
		<tr>
			<td>
				<?php echo CHtml::hiddenField('kd_dokter[]','',array('id'=>'kd_dokter')); ?> 
				<?php echo CHtml::textField('nama_dokter[]','',array('id'=>'nama_dokter')); ?> 
				<?php echo CHtml::Button('x', array('name' => 'del_people', 'id' => 'del_people', 'onclick' => '$("#nama_dokter").val("");$("#kd_dokter").val("")')) ?>
				<?php echo CHtml::Button('Get Dokter',  
						array('onclick' => '$("#dialogdokter").dialog("open"); return false;',  
					));  
				?>
			</td>
            <td>
				<?php
				$this->widget('zii.widgets.jui.CJuiDatePicker', array(
					'name'=>'tgl_upload',
					'value'=>isset(Yii::app()->request->cookies['tgl_upload']) ? Yii::app()->request->cookies['tgl_upload'] : '',
					 'options'=>array(
						'showAnim'=>'fold',
						'dateFormat'=>'yy-mm-dd',
					),
					'htmlOptions'=>array(
						'style'=>'height:20px;'
					),
				));
				?>
			</td>
			<td>
				<?php echo CHtml::fileField('nama_file[]',''); ?>
			</td>
		</tr>
    <?php endif; ?>
	</tbody>
</table>
<?php
$this->beginWidget('zii.widgets.jui.CJuiDialog', array( // the dialog
	'id'=>'dialogdokter',
	'options'=>array(
		'title'=>'Daftar Dokter',
		'autoOpen'=>false,
		'modal'=>true,
		'width'=>550,
		'height'=>470,
	),
)); 
echo $this->render('loadDokter', array('model'=>$model));
?>
<div class="divForForm"></div>
<?php $this->endWidget();?>


controller :
public function actionCreate()
	{
		$model=new FilePendapatan;
		
		if(isset($_POST['nama_dokter']))
		{
			//$model->attributes=$_POST['nama_dokter'];
			//$nama_file = CUploadedFile::getInstances($model,'nama_file');
			$total = count($_POST['nama_dokter']);
		    for ($i = 0; $i <= $total; $i++)
		    {
		    	if(isset($_POST['nama_dokter'][$i]))
		    	{
		     		$file_add = new FilePendapatan();
		        	$file_add->kd_dokter = $_POST['kd_dokter'][$i];
					$file_add->nama_dokter = $_POST['nama_dokter'][$i];
		        	$file_add->tgl_upload = $_POST['tgl_upload'][$i];
		        	//$file_add->nama_file = $_POST['nama_file'][$i];
		         	$file_add->save();
		    	}
		    }
		    if ($model->save()) {
				//$model->nama_file->saveAs(Yii::app()->basePath .'/../file/' . $model->nama_file);
				$this->redirect(array('view','id'=>$model->id));
			}
		}
		$this->render('create',array(
			'model'=>$model,
		));
	}


sorry for my bad english, thanks before. .

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>