public function actionGuardarOrden() { $model = new OrdenPedido(); //$model->personal_entrega_id = $_POST['OrdenPedido']['personal_entrega_id']; //$model->personal_recibe_id = $_POST['OrdenPedido']['personal_recibe_id']; $model->personal_entrega_id = 1; $model->personal_recibe_id = $_POST['personalRecibe']; $model->observacion = $_POST['observacion']; $model->fecha = date("Y-m-d H:i:s"); if ($model->save()) { $eltotal = 0; for ($i = 0; $i <= $_POST['variable']; $i++) { //$x = $i+1; // if (isset($_POST['tipo_' . $i])) { $detalleP = new OrdenPedidoDetalle(); $detalleP->orden_pedido_id = $model->id; $detalleP->tipo_orden_pedido_id = $_POST['tipo_' . $i]; $detalleP->producto_id = $_POST['productos_' . $i]; $detalleP->area = $_POST['area_' . $i]; $detalleP->cantidad = $_POST['cantidad_' . $i]; $detalleP->save(); } } $this->redirect(array('view', 'id' => $model->id)); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new OrdenPedidoDetalle(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['OrdenPedidoDetalle'])) { $model->attributes = $_POST['OrdenPedidoDetalle']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }