コード例 #1
0
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model=new Idmaster;

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

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

$this->render('create',array(
'model'=>$model,
));
}
コード例 #2
0
ファイル: Controller.php プロジェクト: Rajagunasekaran/BACKUP
    public function updateOrderAutoId($newId)
    {
        list($year, $month, $id) = explode("/", $newId);
        $tmpType = substr($id, 0, 3);
        $forwhat = '';
        switch(strtolower($tmpType))
        {
            case strtolower(Helper::CONST_qotid_static_str):
                $forwhat = Helper::CONST_Quote;
                break;
            case strtolower(Helper::CONST_odrid_static_str):
                $forwhat = Helper::CONST_Order;
                break;
            case strtolower(Helper::CONST_invid_static_str):
                $forwhat = Helper::CONST_Invoice;
                break;
        }
        $lastId = substr($id, strlen($tmpType));
        
        $condition = 'forwhat="' . $forwhat . '"';
        $condition .= ' AND foryear = ' . $year;
        $condition .= ' AND formonth = ' . $month;

        $criteria = new CDbCriteria;
        $criteria->condition = $condition;
        $result = Idmaster::model()->findAll( $criteria );                
        if(count($result) > 0)
        {
            $idmastermodel = $result[0];
        }
        else
        {
            $idmastermodel = new Idmaster;
        }
        $idmastermodel->foryear = $year;
        $idmastermodel->formonth = $month;
        $idmastermodel->forwhat = $forwhat;
        $idmastermodel->lastid = $lastId;
        
        return $idmastermodel->save();
    }