Esempio n. 1
0
 public function addInvoice()
 {
     if ($this->validate()) {
         $invoice = new Invoice();
         $invoice->invoice_no = $this->invoice_no;
         $invoice->due_date = $this->due_date;
         $invoice->bank_name = $this->bank_name;
         $invoice->account_no = $this->account_no;
         $invoice->customer = $this->customer;
         $invoice->address = $this->address;
         $invoice->telephone = $this->telephone;
         $invoice->fax = $this->fax;
         $invoice->pic = $this->pic;
         $invoice->mobile = $this->mobile;
         if ($invoice->save()) {
             $entpinvoice = new EntpInvoice();
             $entpinvoice->entrepreneur_user_id = Yii::$app->user->id;
             $entpinvoice->link('invoice', $invoice);
         }
         return $invoice;
     }
     return null;
 }
Esempio n. 2
0
 /**
  * Creates a new EntpInvoice model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Invoice();
     //$model = new NewInvoice();
     if ($model->load(Yii::$app->request->post())) {
         //            if ($invoice = $model->addInvoice()) {
         //                Yii::$app->session->setFlash('success','New Invoice Added');
         //                return $this->redirect(['index']);
         //                //return $this->goHome();
         //            }
         $model->loadDefaultValues();
         $model->save();
         if ($model->save()) {
             $invoice = new EntpInvoice();
             $invoice->entrepreneur_user_id = Yii::$app->user->id;
             $invoice->link('invoice', $model);
         }
         Yii::$app->session->setFlash('success', 'New Invoice Added');
         //return $this->redirect(['index']);
         //
         return $this->redirect(['view', 'entrepreneur_user_id' => Yii::$app->user->id, 'invoice_id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }