public function beforeSave() { $format = new CustomFormat(); //$this->tglrevisimodul = $format->formatDateMediumForDB($this->tglrevisimodul); foreach ($this->metadata->tableSchema->columns as $columnName => $column) { if ($column->dbType == 'date' && !empty($this->columnName)) { $this->{$columnName} = $format->formatDateForDb($this->{$columnName}); } elseif ($column->dbType == 'timestamp without time zone' && !empty($this->{$columnName})) { $this->{$columnName} = $format->formatDateTimeforDb($this->{$columnName}); // print_r($this->$columnName);exit(); } } return parent::beforeSave(); }
<?php $this->widget('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker', array('model' => $model, 'attribute' => 'tglpinjampeg', 'language' => '', 'mode' => 'date', 'options' => array('dateFormat' => Params::DATE_FORMAT, 'changeYear' => true, 'changeMonth' => true, 'yearRange' => '-70y:+4y', 'maxDate' => 'd', 'showAnim' => 'fold', 'timeText' => 'Waktu', 'hourText' => 'Jam', 'minuteText' => 'Menit', 'secondText' => 'Detik', 'showSecond' => true, 'timeFormat' => 'hh:mm:ss', 'showOn' => 'button', 'buttonImage' => Yii::app()->baseUrl . "/css/icons/32/calendar.png", 'buttonImageOnly' => true), 'htmlOptions' => array('readonly' => true, 'onkeypress' => "return \$(this).focusNextInputField(event)"))); ?> </div> </div> <div class="mws-form-row"> <?php echo $form->labelEx($model, 'nopinjam'); ?> <div class="mws-form-item "> <?php $command = Yii::app()->db->CreateCommand()->select('MAX(nopinjam) AS maxnumber')->from('pinjamanpeg_t')->queryAll(); $maxnumber = $command[0]['maxnumber']; $urutan = $maxnumber + 1; $nomor = CustomFormat::pad_zero($urutan, 5, TRUE); ?> <?php echo $form->textField($model, 'nopinjam', array('maxlength' => 50, 'onkeypress' => 'return $(this).focusNextInputField(event);', 'class' => 'digit-medium', 'value' => $nomor)); ?> </div> </div> <div class="mws-form-row"> <?php echo $form->labelEx($model, 'untukkeperluan'); ?> <div class="mws-form-item "> <?php echo $form->textArea($model, 'untukkeperluan', array('rows' => 6, 'cols' => 50, 'onkeypress' => 'return $(this).focusNextInputField(event);'));
<?php $this->widget('MyDateTimePicker', array('model' => $modPengeluarankas, 'attribute' => 'tglpengeluaran', 'language' => '', 'mode' => 'date', 'options' => array('changeYear' => false, 'changeMonth' => false, 'yearRange' => '-70y:+4y', 'maxDate' => 'd', 'showAnim' => 'fold', 'timeText' => 'Waktu', 'hourText' => 'Jam', 'minuteText' => 'Menit', 'secondText' => 'Detik', 'showSecond' => false, 'timeFormat' => 'hh:mm:ss'), 'htmlOptions' => array('value' => date('Y-m-d'), 'readonly' => true, 'onkeypress' => "return \$(this).focusNextInputField(event)"))); ?> </div> </div> <div class="mws-form-row"> <?php echo CHtml::label('No Pengeluaran', 'KPengeluarankasT_nopengeluaran'); ?> <div class="mws-form-item"> <?php $command = Yii::app()->db->createCommand()->select('MAX(nopengeluaran) AS maxnumber')->from('pengeluarankas_t')->queryAll(); $maxnumber = $command[0]['maxnumber']; $urutan = substr($maxnumber, -1) + 1; $nomor = date('Ymd') . CustomFormat::pad_zero($urutan, 3, TRUE); ?> <?php echo CHtml::activeTextField($modPengeluarankas, 'nopengeluaran', array('class' => 'digit-short', 'value' => $nomor)); ?> </div> </div> <div class="mws-form-row"> <?php echo CHtml::label('Keperluan', 'KPengeluarankasT_untukkeperluan'); ?> <div class="mws-form-item"> <?php echo CHtml::activeTextField($modPengeluarankas, 'untukkeperluan', array('class' => 'digit-medium', 'maxlength' => 50, 'value' => 'Gaji karyawan')); ?>
/** * Manages all models. */ public function actionAdmin() { $model = new KPenggajianT('search'); $model->unsetAttributes(); // clear any default values $model->tglAwal = date('Y-m-d 00:00:00'); $model->tglAkhir = date('Y-m-d H:i:s'); if (isset($_GET['KPenggajianT'])) { $format = new CustomFormat(); $model->tglAwal = $format->formatDateTimeMediumForDB($_REQUEST['KPenggajianT']['tglAwal']); $model->tglAkhir = $format->formatDateTimeMediumForDB($_REQUEST['KPenggajianT']['tglAkhir']); $model->attributes = $_GET['KPenggajianT']; } $this->render('admin', array('model' => $model)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); /* penyesuaian format date dari db ke data yang ditampilkan ke user*/ $format = new CustomFormat(); empty($model->tglditerima) ? $model->tglditerima = null : ($model->tglditerima = $format->formatDbtoDate($model->tglditerima)); empty($model->tglkeluar) ? $model->tglkeluar = null : ($model->tglkeluar = $format->formatDbtoDate($model->tglkeluar)); empty($model->tgllahir_karyawan) ? $model->tgllahir_karyawan = null : ($model->tgllahir_karyawan = $format->formatDbtoDate($model->tgllahir_karyawan)); // $tempcreatetime = $model->create_time; /*---------------------------------------------------------------------------------------------------------*/ $temLogo = $model->photo_karyawan; if (isset($_POST['KKaryawanM'])) { $random = rand(00, 9999999); $model->attributes = $_POST['KKaryawanM']; $model->photo_karyawan = CUploadedFile::getInstance($model, 'photo_karyawan'); $gambar = $model->photo_karyawan; empty($model->tglditerima) ? $model->tglditerima = null : ($model->tglditerima = $format->formatDateForDb($model->tglditerima)); empty($model->tglkeluar) ? $model->tglkeluar = null : ($model->tglkeluar = $format->formatDateForDb($model->tglkeluar)); empty($model->tgllahir_karyawan) ? $model->tgllahir_karyawan = null : ($model->tgllahir_karyawan = $format->formatDateForDb($model->tgllahir_karyawan)); // print_r($model->create_time);exit; if (!empty($model->photo_karyawan)) { $model->photo_karyawan = $random . $model->photo_karyawan; Yii::import("ext.EPhpThumb.EPhpThumb"); $thumb = new EPhpThumb(); $thumb->init(); //this is needed $fullImgName = $model->photo_karyawan; $fullImgSource = Params::pathKaryawanDirectory() . $fullImgName; $fullThumbSource = Params::pathKaryawanDirectory() . 'kecil_' . $fullImgName; if ($model->save()) { if (!empty($model->no_fingerprint)) { $this->insertData($model); } if (!empty($temLogo)) { unlink(Params::pathKaryawanDirectory() . $temLogo); unlink(Params::pathKaryawanDirectory() . 'kecil_' . $temLogo); } $gambar->saveAs($fullImgSource); $thumb->create($fullImgSource)->resize(200, 200)->save($fullThumbSource); $this->redirect(array('view', 'id' => $model->karyawan_id)); } else { Yii::app()->user->setFlash('error', 'Data <strong>Gagal!</strong> disimpan.'); } } else { // $model->create_time = $format->formatDbToDateTime($model->create_time); $model->photo_karyawan = $temLogo; // exit(); if ($model->validate()) { if ($model->save()) { if (!empty($model->no_fingerprint)) { $this->insertData($model); } $this->redirect(array('admin', 'id' => $model->karyawan_id)); } } } } $this->render('update', array('model' => $model)); }