From 2fbaff8849d9eb08a3c926c3e64dfd91442f44f3 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 18 Apr 2012 14:54:46 +0000 Subject: [PATCH] Candidato -> arreglo en la fecha de nacimiento git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_IntranetNueva/trunk@42 77cfc57b-8ef4-1849-9df6-4a38aa5da120 --- www/js/custom/elements.js | 6 ------ www/protected/models/Candidato.php | 23 ++++++++++++++++++++++- www/protected/views/candidato/_form.php | 19 ++++++++++++++++++- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/www/js/custom/elements.js b/www/js/custom/elements.js index 8c47c13..55f3cf7 100644 --- a/www/js/custom/elements.js +++ b/www/js/custom/elements.js @@ -1,12 +1,6 @@ jQuery.noConflict(); jQuery(document).ready(function(){ - /** - * Date picker - **/ - jQuery( "#datepicker" ).datepicker(); - - /** * Growl Notification **/ diff --git a/www/protected/models/Candidato.php b/www/protected/models/Candidato.php index 18bfdc9..f853373 100644 --- a/www/protected/models/Candidato.php +++ b/www/protected/models/Candidato.php @@ -172,7 +172,7 @@ class Candidato extends CActiveRecord array('fecha_nacimiento, observaciones', 'safe'), - //array('fecha_nacimiento', 'date', 'allowEmpty'=>'true'), + array('fecha_nacimiento', 'date', 'format'=>'dd/MM/yyyy'), array('estado', 'unsafe'), @@ -297,4 +297,25 @@ class Candidato extends CActiveRecord return parent::beforeValidate(); } + + protected function beforeSave() + { + //PHP dates are displayed as dd/mm/yyyy + //MYSQL dates are stored as yyyy-mm-dd + $unafecha = DateTime::createFromFormat('d/m/Y', $this->fecha_nacimiento); + $this->fecha_nacimiento = $unafecha->format('Y-m-d'); + + parent::beforeSave(); + return true; + } + + protected function afterFind() { + //PHP dates are displayed as dd/mm/yyyy + //MYSQL dates are stored as yyyy-mm-dd + $unafecha = DateTime::createFromFormat('Y-m-d', $this->fecha_nacimiento); + $this->fecha_nacimiento = $unafecha->format('d/m/Y'); + + parent::afterFind(); + return true; + } } \ No newline at end of file diff --git a/www/protected/views/candidato/_form.php b/www/protected/views/candidato/_form.php index 37aed29..d07f654 100644 --- a/www/protected/views/candidato/_form.php +++ b/www/protected/views/candidato/_form.php @@ -94,7 +94,24 @@ Yii::app()->clientScript->registerScript('wysiwyg', $script, CClientScript::POS_
labelEx($model,'fecha_nacimiento'); ?>
- textField($model,'fecha_nacimiento',array('class'=>'sf','id'=>'datepicker')); ?> + widget('zii.widgets.jui.CJuiDatePicker', array( + 'model'=>$model, + 'attribute'=>'fecha_nacimiento', + 'name'=>'fecha_nacimiento', + 'language'=>'es', + 'options'=>array( + 'selectOtherMonths'=>true, + 'showButtonPanel'=>true, + 'showOtherMonths'=>true, + 'changeMonth' => true, + 'changeYear' => true, + ), + 'htmlOptions' => array( + 'class' => 'sf', + ) + )); + ?> error($model,'fecha_nacimiento', array('class'=>'errortext')); ?>