$command=Yii::app()->db->createCommand(); $command->select('SUM(amount) AS sum'); $command->from('sale_info'); $command->where('user_id='.$_GET['users'].' AND ratingtyle="Initial"'); $command->andWhere('created_date>:start', array(':start' => $_GET['startdate'])); $command->andWhere('created_date<:end', array(':end' => $_GET['enddate'])); echo 'Initial Fee: '.$command->queryScalar();
Tuesday, December 30, 2014
Use BETWEEN AND Clause in Yii QueryBuilder
Sunday, December 28, 2014
CDbCriteria addBetweenCondition or filter by date range
// $criteria->addBetweenCondition($column, $valueStart, $valueEnd, 'AND'); $criteria = new CDbCriteria; $criteria->addBetweenCondition('actual_completion_date', $_GET['startdate'], $_GET['enddate'], 'AND'); $criteria->group = 'client_id'; $dataProvider = new CActiveDataProvider('SaleInfo', array( 'criteria' => $criteria, 'pagination' => array( 'pageSize' => 20, ), ) );
Monday, December 22, 2014
Invisible/hide rows in CGridView rowCssClassExpression
$this->widget('zii.widgets.grid.CGridView', array( 'id'=>'ordersort-grid', 'dataProvider'=>$dataProvider, 'rowCssClassExpression'=>'$data->dateleftint($data->order_id, $data->quantity, $data->order_date) >0?"row-open":"row-closed"', 'htmlOptions'=>array( 'class'=>'table table-striped table-hover table-bordered', ), 'columns'=>array( 'order_id', 'name', 'quantity', array( 'header' => 'Day Left', 'value'=>'$data->dateleft($data->order_id, $data->item_id, $data->quantity, $data->order_date)', 'type' => 'raw', 'cssClassExpression' => '"foo" . (2+3) ."bar"', ), array( 'name'=>'employee_id', 'header' => 'Employer', 'value'=>'($data->employee_id=="")? "Not Selected" : $data->Employerr->company_name', 'type' => 'raw', ), 'total', 'paid', 'due', 'active', 'paid_opt', 'process_by', 'process_date', array( 'class'=>'CButtonColumn', 'template'=>'{process}', 'buttons'=>array ( 'process' => array ( 'label'=>'Post job/adv', 'url'=>'Yii::app()->createUrl("order/jobpost", array("id"=>$data->id))', 'visible'=>'$data->dateleftint($data->order_id, $data->quantity, $data->order_date) > 0 ? true : false;' ), ), ), ), ));
Saturday, October 25, 2014
Saturday, October 18, 2014
Tuesday, September 30, 2014
Multiple database in yii
'db'=>array( 'connectionString' => 'mysql:host=localhost;dbname=test', 'emulatePrepare' => true, 'username' => 'test', 'class'=>'CDbConnection', 'password' => 'test@2014test', 'charset' => 'utf8', ), 'db2'=>array( 'connectionString' => 'mysql:host=localhost;dbname=*****net', 'emulatePrepare' => true, 'username' => '*****net', 'password' => '*******', 'class'=>'CDbConnection', 'charset' => 'utf8', ),
Call function at CGridView in yii
array( 'header'=>'client', 'type'=>'raw', 'value'=>'$data->getClientinformation($data->client_id)', 'filter'=>$model->getClientinfilter(), ),
public function getClientinformation($client_id){ $user = Yii::app()->db2->createCommand() ->select('name') ->from('client') ->where('id=:id', array(':id'=>$client_id)) ->queryAll(); return $user[0]['name']; } public function getClientinfilter(){ // return 'jibon'; $command = Yii::app()->db2->createCommand(); $userArray = $command->select('id, name')->from('client')->order('name')->queryAll(); return CHtml::dropdownlist('GalleryBooking[client_id]','',CHtml::listData($userArray,'id','name'), array('empty' => '')); }
Saturday, July 5, 2014
How to disable submit button using check
echo CHtml::submitButton('Finish', Yii::app()->session['userid']==0 ? array('disabled'=>'disabled') : array('name' => 'cartfinal', 'class'=>'btn btn-primary'));
Friday, May 2, 2014
Yii AJAX form validation on submit
$form=$this->beginWidget('CActiveForm', array( 'id'=>'directoryinfo-form', 'enableAjaxValidation'=>true, 'clientOptions'=>array('validateOnSubmit'=>true), 'htmlOptions'=>array('enctype'=>'multipart/form-data'), ));
Thursday, March 6, 2014
yii highcharts
$tadates=Target::model()->findAll( array( 'select'=>'date, achived', 'condition'=>'user_id="'.$model->user_id.'"' )); $xAxis=array(); $yAxis=array(); foreach($tadates as $tadate): $xAxis[]=date("M, Y",strtotime($tadate->date)); $targetvalue[] = 100*1; $yAxis[]=$tadate->achived*1; endforeach; $this->Widget('ext.highcharts.HighchartsWidget', array( 'options'=> array( 'credits' => array('enabled' => false), 'exporting' => array( 'enabled' => true, ), 'title' => array( 'text' => 'Target', ), 'xAxis' => array( 'title' => array( 'text' => 'Year', ), 'categories' => $xAxis, ), 'yAxis' => array( 'title' => array( 'text' => 'Target', ), ), 'series' => array( array( 'name' => 'Target chart', 'data' => $yAxis, 'shadow' => false, 'type' => 'column', ), array( 'name' => 'Target Value', 'data' => $targetvalue, 'color'=> '#8bbc21', 'shadow' => false, 'type' => 'column', ) ) ) ) );
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]; }
Subscribe to:
Posts (Atom)