backend/controllers/DeliveryController.php
/**
     * Creates a new Delivery model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Delivery model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Delivery model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new Delivery();
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            $barcode = substr($model->nomor_barcode, 0,2);
            switch ($barcode) {
                case 'CC':
                    $jenisPengiriman = "Pos Ekspor";
                    break;
                case 'CP':
                    $jenisPengiriman = "Paketpos Cepat Internasional";
                    break;
                case 'RR':
                    $jenisPengiriman = "Registered Internasional";
                    break;
                case 'LX':
                    $jenisPengiriman = "ePacket";
                    break;
                default:
                    $jenisPengiriman = "EMS";
                    break;
            }
            $model->jasa_pengiriman = $jenisPengiriman;
            if($model->pengantar == ""){
                $model->pengantar = NULL;
            }
            $model->save();
            Yii::$app->session->setFlash('info', "Kiriman Tersimpan.");
            return $this->redirect(['view', 'id' => $model->id]);
        }
        return $this->render('create', [
            'model' => $model,
        ]);
    }
public function actionCreate ( ) { $ model = new Delivery ( ) ; if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> validate ( ) ) { $ barcode = substr ( $ model -> nomor_barcode , 0 , 2 ) ; switch ( $ barcode ) { case 'CC' : $ jenisPengiriman = " Pos Ekspor " ; break ; case 'CP' : $ jenisPengiriman = " Paketpos Cepat Internasional " ; break ; case 'RR' : $ jenisPengiriman = " Registered Internasional " ; break ; case 'LX' : $ jenisPengiriman = " ePacket " ; break ; default : $ jenisPengiriman = " EMS " ; break ; } $ model -> jasa_pengiriman = $ jenisPengiriman ; if ( $ model -> pengantar == " " ) { $ model -> pengantar = NULL ; } $ model -> save ( ) ; Yii :: $ app -> session -> setFlash ( 'info' , " Kiriman Tersimpan. " ) ; return $ this -> redirect ( [ 'view' , 'id' => $ model -> id ] ) ; } return $ this -> render ( 'create' , [ 'model' => $ model , ] ) ; }
Creates a new Delivery model.
Creates a new Delivery model .