Here Is my Code:
Controller:
class ProductController extends Controller
{
…
/**
* Manages all Skus.
*/
public function actionAdmin()
{
$uid = Yii::app()->user->getId();
if($uid != 1){
$value = ComSpry::getUnserilizedata($uid);
if(empty($value) || !isset($value)){
throw new CHttpException(403,'You are not authorized to perform this action.');
}
if(!in_array(1, $value)){
throw new CHttpException(403,'You are not authorized to perform this action.');
}
}
$image-new Skuimages;
$model=new Sku('search');
$model->unsetAttributes(); // clear any default values
if(isset($_GET['Sku']))
$model->attributes=$_GET['Sku'];
$imageUrl=$image->imageThumbUrl;
$this->render('admin',array(
'model'=>$model,
'skuimages'=>$imageUrl
));
}
}
}
MOdel:
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
if(!empty($this->met_not_less)){
$criteria->condition="totmetalwei > :met_not_less";
$criteria->params[':met_not_less']=$this->met_not_less;
}
if(!empty($this->met_not_more)){
$criteria->condition="totmetalwei < :met_not_more ";
$criteria->params[':met_not_more']=$this->met_not_more;
}
$criteria->compare('idsku',$this->idsku);
$criteria->compare('skucode',$this->skucode,true);
$criteria->compare('tdnum',$this->tdnum,true);
$criteria->compare('cdate',$this->cdate,true);
$criteria->compare('mdate',$this->mdate,true);
$criteria->compare('updby',$this->updby);
$criteria->compare('leadtime',$this->leadtime);
$criteria->compare('refpo',$this->refpo);
$criteria->compare('parentsku',$this->parentsku);
$criteria->compare('parentrel',$this->parentrel,true);
$criteria->compare('taxcode',$this->taxcode,true);
$criteria->compare('dimunit',$this->dimunit,true);
$criteria->compare('dimdia',$this->dimdia,true);
$criteria->compare('dimhei',$this->dimhei,true);
$criteria->compare('dimwid',$this->dimwid,true);
$criteria->compare('dimlen',$this->dimlen,true);
$criteria->compare('totmetalwei',$this->totmetalwei,true);
$criteria->compare('metweiunit',$this->metweiunit,true);
$criteria->compare('totstowei',$this->totstowei,true);
$criteria->compare('stoweiunit',$this->stoweiunit,true);
$criteria->compare('numstones',$this->numstones);
$criteria->compare('grosswt',$this->grosswt);
if(!empty($this->type)) $criteria->with[] = 'skucontent';
if(!empty($this->gemstone)) $criteria->with[] = 'stones';
if(!empty($this->gem_shape)) $criteria->with[] = 'shapes';
if(!empty($this->gem_size)) $criteria->with[] = 'sizes';
if(!empty($this->type) || !empty($this->gemstone) || !empty($this->gem_shape) || !empty($this->gem_size)) $criteria->together = true;
if(!empty($this->type)) $criteria->compare( 'skucontent.type', $this->type, true );
if(!empty($this->gemstone)) $criteria->compare('stones.namevar',$this->gemstone, true);
if(!empty($this->gem_shape)) $criteria->compare('shapes.name',$this->gem_shape, true);
if(!empty($this->gem_size)) $criteria->compare('sizes.size',$this->gem_size, true);
if(!empty($this->sku_size)) $criteria->compare( 'skucontent.size', $this->sku_size, true );
return new CActiveDataProvider(get_class($this), array(
'criteria'=>$criteria,
));
}
Views:
In the view, I am getting ajax error when I search shape with size and stone name.
Many Thanks…
3830