public function actionCreate() { $model = new Facturas(); if (isset($_POST['Facturas'])) { $model->attributes = $_POST['Facturas']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->IdFactura)); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Facturas(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Facturas'])) { $model->attributes = $_POST['Facturas']; $model->proveedor_id = $_POST['proveedor_id']; $model->cierre_carga = false; $usuario = Usuarios::model()->findByPk(Yii::app()->user->getId()); $model->ente_organo_id = $usuario->ente_organo_id; $model->anho = Yii::app()->params['trimestresFechas'][Yii::app()->session['trimestreSeleccionado']]['anho']; //date("Y"); if ($model->save()) { $proveedores_eo = new ProveedoresEntesOrganos(); $proveedores_eo->proveedor_id = $model->proveedor_id; $proveedores_eo->ente_organo_id = $model->ente_organo_id; $proveedores_eo->save(); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function facturacion() { $factura = new Facturas(); $factura->nombreUsuario = Input::get('nombre'); $factura->Domicilio = Input::get('domicilio'); $factura->rfc = Input::get('RFC'); $factura->correo = Input::get('Correo'); $factura->save(); $FacturarR = new facturarr(); $FacturarR->id_restaurante = Auth::user()->id_restaurante; $FacturarR->estatus = 'pendiente'; $FacturarR->costo = Input::get('Costo'); $FacturarR->save(); return Redirect::to('restaurante/facturas')->with('message', 'factura guardada con éxito'); }
public function factura() { $usuario = User::where('username', '=', Input::get('username'))->first(); $factura = new Facturas(); $factura->id_usuario = $usuario->id; $factura->nombreF = Input::get('nombredelafactura'); $factura->nombreUsuario = Input::get('nombre_factura'); $factura->Domicilio = Input::get('domiciliofiscal'); $factura->rfc = Input::get('rfc'); $factura->correo = Input::get('correo_factura'); $factura->save(); return Response::json($factura->id); }
public function postPurchaseAndNewDir() { if (Cart::count() < 1) { Session::flash('danger', 'Error, no posee articulos en el carrito'); return Redirect::back(); } $input = Input::all(); $rules = array('email' => 'required|email', 'dir' => 'required'); $msg = array('required' => 'Campo requerido', 'email' => 'El campo debe ser un email'); $validator = Validator::make($input, $rules, $msg); if ($validator->fails()) { Redirect::back()->withError($validator)->withInput(); } $dir = new Dir(); $dir->user_id = Auth::user()->id; $dir->email = $input['email']; $dir->dir = $input['dir']; if ($dir->save()) { $fac = new Facturas(); $fac->user_id = Auth::user()->id; $fac->dir = $dir->id; if ($fac->save()) { foreach (Cart::content() as $c) { $misc = Misc::find($c->options['misc']); $misc->item_stock = $misc->item_stock - $c->qty; $misc->save(); $itemFac = new FacturaItem(); $itemFac->factura_id = $fac->id; $itemFac->item_id = $c->id; $itemFac->item_qty = $c->qty; $itemFac->item_talla = $c->options['talla']; $itemFac->item_color = $c->options['color']; $itemFac->item_precio = $c->price; $itemFac->save(); } Cart::destroy(); return Redirect::to('compra/procesar/' . $fac->id); } } }