Monday, February 24, 2014

DataProvider with condition NULL value

$DataProvider=new CActiveDataProvider('SaleInfo', array(
  'criteria'=>array(
   'condition'=>'user_id IS NULL',
  ),
   'pagination' => array('pageSize' => 50,),
    
 ));

Tuesday, February 18, 2014

Bootstrap TbTabs with with renderPartial


$this->widget('bootstrap.widgets.TbTabs', array(
                'type'=>'tabs',
                'tabs'=>array(
                        array('label'=>'Personal Information', 'content'=>$this->renderPartial('details', array('model'=>$model),true,true)),
                        array('label'=>'Business Information', 'content'=>$this->renderPartial('//businessprofile/details', array('model'=>$businessmodel,'id'=>$businessmodel->profile),true,true)),
                        array('label'=>'Growthplan Information', 'content'=>$this->renderPartial('//growthplan/details', array('model'=>$growthplanmodel,'id'=>$growthplanmodel->profileid),true,true)),
                  
                ),
            ));

CJuiTabs with renderPartial


$this->widget('zii.widgets.jui.CJuiTabs', array(
    'tabs'=>array(
        'Static tab'=>'Static content',
        'Personal Information'=>$this->renderPartial('details', array('model'=>$model),true,true),
 'Business Information'=>$this->renderPartial('//businessprofile/details', array('model'=>$businessmodel, 'id'=>$businessmodel->profile),true,true),
    ),
    'options'=>array(
        'collapsible'=>true,
        'selected'=>1,
    ),
    'htmlOptions'=>array(
        'style'=>'width:500px;'
    ),
));


Sunday, February 16, 2014

CGridView and show detail in CJuiDialog

$this->widget('zii.widgets.grid.CGridView', array(
     .....
     'columns' => array(
         ....
         array(
             'class' => 'CButtonColumn',
             'buttons' => array(
                 'view' => array(
                     'url' => 'url' => 'Yii::app()->createUrl("/path/to/controller/view")',
                     'options' => array(
                         'ajax' => array(
                             'type' => 'POST',
                             'url' => "js:$(this).attr('href')",
                             'update' => '#detail-section',
                         ),
                     ),
  
                 ),    // view button
             ),
         ),
     )
 ));
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
         'id' => 'dlg-detail',
         'options' => array(
             'title' => 'Dialog Box Title',
             'closeOnEscape' => true,
             'autoOpen' => false,
             'model' => false,
             'width' => 550,
             'height' => 450,
         ),
 ));
<div id="detail-section"></div>
 $this->endWidget();

Monday, January 6, 2014

CDetailView with static option value

public static function getUserTypes(){
  return array(
   '10'=> 'admin',
   '5'=> 'Doctor',
                        '4'=> 'Accountant',
                        '3'=> 'Pharmacist', 
                        '2'=> 'Nurse',
                        '1'=> 'Patient',
                        '0'=> 'No User',
  );
 }
 array('name'=>'role', 'value'=>$model->UserTypes[$model->role]),
OR
$services = array('1' => 'Airport Rates', '2' => 'Station Rates', '3' => 'Local Rates');
array(
 'name' => 'services_place',
 'value' => $model->services_place ? $services[$model->services_place]:"",
//      'value' => $model->services_place?$data->getStatus($model->services_place):"",
 
 ),
public function getStatus($services_place)
 {
  $data = array('1' => 'Airport Rates', '2' => 'Station Rates', '3' => 'Local Rates');
  return $data[$services_place];
 }

Wednesday, December 18, 2013

Yii beforeSave method

 function beforeSave() {
            
        if (parent::beforeSave()) {
            if($this->isNewRecord) {
            $this->password=md5($this->password);
             $this->createdate=date("Y-m-d, g:i a");
            }
        else {
            $this->modifydate=date("Y-m-d, g:i a");
          }
        
        }
        return true;
    }

Wednesday, December 4, 2013

yii ajaxLink

echo CHtml::ajaxLink(
  CHtml::image(Yii::app()->request->baseUrl.'/uploads/participants/thumbs/'.$model->picture,
      $model->name, array("style"=>"display:block; margin: 0 auto;height:90px;")),
  Yii::app()->createUrl( 'participants/participantdetails' ),
  array( 
    'type' => 'POST',
    'beforeSend' => "function( request )
                     { }",
    'success' => "function( data )
                  {
                   $('#idrr').html(data);
                  }",
    'data' => array( 'id' => $model->id)
  ),
  array(
    'href' => Yii::app()->createUrl( 'participants/participantdetails' ),
    'class' => 'dffclass'
  )
);