Hi, how to solve this?
I need to have an options where user can pull data based from the
-
the last day it was created
-
3 days ago
-
5 days ago
-
1 week ago
-
fortnight ago
-
month ago
-
quarter ago
8 ) 6 months ago
-
year ago
-
year+ ago
and it should be available at my advance search function.
here’s what i have at the moment ( I copied the function of the admin controller + view )
//controller
public function actionAdvancecvsearch()
{
$model = new Wsrecruitcvhead('search');
$model->unsetAttributes();
if(isset($_GET['Wsrecruitcvhead'])){
$model->attributes = $_GET['Wsrecruitcvhead'];
}
$this->render('advancecvsearch',array(
'model' => $model,
));
}
//model
const LAST_DAY = 0;
const LAST_3_DAYS = 1;
const LAST_5_DAYS = 2;
const LAST_WEEK = 3;
const LAST_FORNIGHT = 4;
const LAST_MONTH = 5;
const LAST_QUARTER = 6;
const LAST_6_MONTHS = 7;
const LAST_YEAR = 8;
const LAST_YEAR_BEYOND = 9;
/*
* if I have a DateCreated column in my table
* how will I use the data from the select option to solve it
*
*/
public function searchcv($returnRaw = false)
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('ResumeTitle',$this->ResumeTitle,true);
$criteria->compare('ResumeSummaryIntroduction',$this->ResumeSummaryIntroduction,true);
$criteria->compare('SummaryOfPositionSought',$this->SummaryOfPositionSought,true);
$criteria->compare('SummaryOfSkills',$this->SummaryOfSkills,true);
$criteria->compare('DateCreated',<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />?<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />?<img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />?,true);
if($returnRaw === true){
return $criteria;
}
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
/*
* display select option time intervals
*/
public function getTimeOptions()
{
return array(
self::LAST_DAY => 'A day ago',
self::LAST_3_DAYS => '3 days ago',
self::LAST_WEEK => 'A week ago',
self::LAST_FORNIGHT => '2 weeks ago',
self::LAST_MONTH => 'A month ago',
self::LAST_QUARTER => 'Last quarter',
self::LAST_6_MONTHS => '6 months ago',
self::LAST_YEAR => 'Last year',
self::LAST_YEAR_BEYOND => 'More than a year ago',
);
}
//view
<?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
<?php #echo " | " .CHtml::link('Save Search',array('savesearchresult','r'=>'wsrecruitcvhead/savesearchresult')); ?>
<div class="search-form" style="display:none">
<?php
$this->renderPartial('_mysearch',array(
'model'=>$model,
));
?>
</div>
<?php
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'wsrecruitcvhead-grid',
'dataProvider'=>$model->search(),
#'filter'=>$model,
'columns'=>array(
'ResumeTitle',
'ResumeSummaryIntroduction',
'SummaryOfPositionSought',
'SummaryOfSkills',
array(
'class' => 'CButtonColumn',
'viewButtonUrl' => 'Yii::app()->createUrl("wsrecruitcvhead/view",array("id"=>$data["ResumeID"]))',
'template'=>'{view}',
),
),
));
?>
//_mysearch view file
<div class="wide form">
<?php $form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'method'=>'get',
)); ?>
<div class="row">
<?php echo $form->label($model,'DateCreated'); ?>
<?php echo $form->dropDownList($model,'DateCreated', $model->getTimeOptions()); ?>
</div>
<div class="row">
<?php echo $form->label($model,'ResumeTitle'); ?>
<?php echo $form->textField($model,'ResumeTitle',array('size'=>60,'maxlength'=>255)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'ResumeSummaryIntroduction'); ?>
<?php echo $form->textArea($model,'ResumeSummaryIntroduction',array('rows'=>6, 'cols'=>50)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'SummaryOfPositionSought'); ?>
<?php echo $form->textArea($model,'SummaryOfPositionSought',array('rows'=>6, 'cols'=>50)); ?>
</div>
<div class="row">
<?php echo $form->label($model,'SummaryOfSkills'); ?>
<?php echo $form->textArea($model,'SummaryOfSkills',array('rows'=>6, 'cols'=>50)); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton('Search'); ?>
</div>
<?php $this->endWidget(); ?>