/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model=new Statushistory;

// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);

if(isset($_POST['Statushistory']))
{
$model->attributes=$_POST['Statushistory'];
if($model->save())
$this->redirect(array('view','id'=>$model->id));
}

$this->render('create',array(
'model'=>$model,
));
}
예제 #2
0
    public function updatestatushistory($ofwhich, $ofwhichid, $status, $statusdt)
    {//1 -order 2- ordertask etc.,
//            $statusmodel = Statusmaster::model()->getStatusByNameOrId($status, $ofwhich, true);
//            if(empty($statusmodel))
//            {
//                return;
//            }
//            $status = $statusmodel->name;
        $rtn = false;
        try
        {
            $higherflds = array();
            $stsfldtoupdate = $this->getStatusHistoryFieldFromId($ofwhich, $status, $higherflds);
            if(empty($stsfldtoupdate))
            {
                return;
            }
            $cndn = 'ofwhich_id=:ofwhich';
            $params = array(':ofwhich' => $ofwhichid);
            $criteria=new CDbCriteria(array(
                                    'condition' => $cndn,
                                    'params'=> $params,
                            ));
            $result = Statushistory::model()->findAll($criteria);            
            $attributes = array(
                    "$stsfldtoupdate" => $statusdt
                    );
            foreach($higherflds as $higerfld)
            {
                $attributes["$higerfld"] = null;
            }
            if(!empty($result) && !empty($result[0]))
            {
                $record = Statushistory::model()->findByPk($result[0]->id);
            }
            else
            {
                $record = new Statushistory;
                $attributes["ofwhich_id"] = $ofwhichid;
            }
            if(!empty($record))
            {
                $record->attributes = $attributes;
                $rtn = $record->save();
            }
        }
        catch(Exception $e)
        {
           $rtn = false; 
        }
        return $rtn;
    }