Showing posts with label Datepicker. Show all posts
Showing posts with label Datepicker. Show all posts

Wednesday, 24 September 2014

Date Compare in YII model search function


View : Search form

label($model,'fromdate'); ?> widget('zii.widgets.jui.CJuiDatePicker',array( 'id'=>'HolidayHolidayrange_fromdate', 'name'=>'HolidayHolidayrange[fromdate]', 'value'=>$model->fromdate==''?'':date('d-m-Y',strtotime($model->fromdate)), 'options'=>array( 'dateFormat' => 'dd-mm-yy', 'showAnim'=>'slide', 'showButtonPanel'=>true, 'changeMonth'=>true, 'changeYear'=>true, 'yearRange'=>'1900:'.date('Y'), ), 'htmlOptions'=>array( 'style'=>'', 'placeHolder'=>'End Date' ), )); ?>
label($model,'todate'); ?> widget('zii.widgets.jui.CJuiDatePicker',array( 'id'=>'HolidayHolidayrange_todate', 'name'=>'HolidayHolidayrange[todate]', 'value'=>$model->todate==''?'':date('d-m-Y',strtotime($model->todate)), 'options'=>array( 'dateFormat' => 'dd-mm-yy', 'showAnim'=>'slide', 'showButtonPanel'=>true, 'changeMonth'=>true, 'changeYear'=>true, 'yearRange'=>'1900:'.date('Y'), ), 'htmlOptions'=>array( 'style'=>'', 'placeHolder'=>'End Date' ), )); ?>
Model's Search function
public function search()
 {
           ....................
        if(!empty($this->fromdate))  
        $criteria->addCondition('fromdate > "'.date("Y-m-d",strtotime($this->fromdate)).'" ');
   
        if(!empty($this->todate))
        $criteria->addCondition('todate < "'.date("Y-m-d",strtotime($this->todate)).'" ');
         .......................
       }

Tuesday, 18 June 2013

Datepicker disabled date from Database

Model:
class ModelLocalisationDatefixing extends Model { 
     public function getDatefixed() {   
             $query = $this->db->query("SELECT DATE_FORMAT(date, '%Y-%c-%e') AS date FROM " . DB_PREFIX . "date_fix WHERE status='1'");
             return $query->rows;   
      } 
    } 

View:
Delivery Date ( Max 7 days ) :

Controller:
public function datefixed()
    {  
        $date_string = array();
        $this->load->model('localisation/datefixing');
        $date_info = $this->model_localisation_datefixing->getDatefixed();
        $ddd=array_map('current',$date_info);
        $date_string['dateinfo']=$ddd;
        $this->response->setOutput(json_encode($date_string));
    }