public function actionCreateid() { $session = new Session(); $session->open(); if (\yii::$app->request->isAjax) { $id = \yii::$app->request->post('invid'); $session['invid'] = $id; $x; $count = 0; foreach ($session['invid'] as $data) { // $model = Saleorderline::find()->where(['saleid' => $data])->all(); $model2 = new \backend\models\Saleorderinvoiceline(); foreach ($model as $value) { $model2 = new \backend\models\Saleorderinvoiceline(); $count += 1; $model2->invid = $session['invrecid']; $model2->invline = $count; $model2->partno = $value->custorderno; $model2->description = $value->customername; $model2->quantity = $value->quantity; $model2->unitprice = $value->unitprice; $model2->totalamount = $value->totalamount; $model2->unit = $value->unit; $model2->saleid = $value->saleid; $model2->invoiceqty = $value->quantity; $model2->save(); } $model3 = new \backend\models\Invoicerefsale(); $model3->invid = $session['invrecid']; $model3->saleid = $data; $model3->save(); //cu $x = $data; } // foreach ($_POST['sales'] as $data) // { // $model2 = new \backend\models\Invoicerefsale(); // $model2->invid =$session['invid']; // $model2->saleid = $data; // // $model2->save(); // } // return $this->redirect(['saleorderinvoice/update','id'=>$session['invid']]); return $this->redirect(['saleorderinvoice/update', 'id' => $session['invrecid']]); // return $count; } else { // echo "ess"; } }
/** * Deletes an existing Saleorderinvoice model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { if ($this->findModel($id)->delete()) { $deldetail = \backend\models\Saleorderinvoiceline::deleteAll('invid = :invid', [':invid' => $id]); $deldetail2 = \backend\models\Invoicerefsale::deleteAll('invid = :invid', [':invid' => $id]); if ($deldetail) { return $this->redirect(['index']); } return $this->redirect(['index']); } }