/**
  * Deletes an existing PurchaseOrder model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     if ($model = $this->findModel($id)) {
         foreach (PurchaseOrderDetail::findAll(['purchase_order_id' => $model->id]) as $item) {
             $item->delete();
         }
         $model->delete();
         return $this->goBack(Url::previous());
     } else {
         throw new NotFoundHttpException();
     }
 }