public function storeE() { $idmovimiento = DB::table('tmovimiento')->insertGetId(['tipo' => "Egreso", 'montototal' => Input::get('montototal'), 'fecha' => Input::get('fecha'), 'descripcion' => Input::get('descripcion')]); $newingreso = new Egreso(); $newingreso->nromovimiento = $idmovimiento; $newingreso->save(); return Redirect::to('movimientos'); }
public function storeE() { date_default_timezone_set("America/Lima"); $tiempo = getdate(); $timefull = date('Y-m-d') . ' ' . $tiempo['hours'] . ':' . $tiempo['minutes'] . ':' . $tiempo['seconds']; $idmovimiento = DB::table('tmovimiento')->insertGetId(['tipo' => "Egreso", 'montototal' => Input::get('montototal'), 'descripcion' => Input::get('descripcion'), 'fecha' => $timefull, 'idcom_orgdor' => Session::get('user_idcom_orgdor')]); $newingreso = new Egreso(); $newingreso->nromovimiento = $idmovimiento; $newingreso->save(); return Redirect::to('movimientos'); }
public static function agregarEgresopedidocompra($numero, $para_uso_en, $entregado_por, $cargo_entregado_por, $recivido_por, $cargo_recivido_por, $pedidocompra_id) { $e = new Egreso(); $e->numero = $numero; $e->nivel = Session::get('nivel'); $e->fecha = Egreso::cambiarfecha(); $e->para_uso_en = $para_uso_en; $e->entregado_por = $entregado_por; $e->cargo_entregado_por = $cargo_entregado_por; $e->recivido_por = $recivido_por; $e->cargo_recivido_por = $cargo_recivido_por; $e->pedidocompra_id = $pedidocompra_id; $e->save(); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Egreso(); $model->fecha = date('d/m/Y'); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Egreso'])) { $model->attributes = $_POST['Egreso']; $model->fecha = Tools::fixFecha($model->fecha); $propiedad = null; if ($model->centroCosto != null) { $ok = $model->validate(); if ($model->centroCosto->carga_a == '1') { $propiedad = Propiedad::model()->findByPk($model->propiedad_id); if ($propiedad == null) { $model->addError("propiedad_id", "Propiedad no puede ser nulo."); $ok = false; } } if ($ok) { if ($model->save()) { if ($model->centroCosto->carga_a == '1') { $egPro = new EgresoPropiedad(); $egPro->egreso_id = $model->id; $egPro->propiedad_id = $model->propiedad_id; $egPro->save(); } if ($model->centroCosto->carga_a == '2') { if (isset($_POST['chbDepartamentoId'])) { $cant_deptos = count($_POST['chbDepartamentoId']); if ($cant_deptos > 0) { foreach ($_POST['chbDepartamentoId'] as $i => $departamento) { $egDpto = new EgresoDepartamento(); $egDpto->departamento_id = $departamento; $egDpto->egreso_id = $model->id; if ($egDpto->validate()) { $egDpto->save(); } } } } } $this->redirect(array('admin')); } else { Yii::app()->user->setFlash('error', CHtml::errorSummary($model)); } } else { Yii::app()->user->setFlash('error', CHtml::errorSummary($model)); } } else { Yii::app()->user->setFlash('error', 'ERROR: Centro de costo no puede ser nulo.'); } $model->fecha = Tools::backFecha($model->fecha); } $conceptos = ConceptoPredefinido::model()->findAll(); $cptos = array(); foreach ($conceptos as $concepto) { $cptos[] = $concepto->nombre; } $deptos = new Departamento('search'); $deptos->unsetAttributes(); if (isset($_GET['Departamento'])) { $deptos->attributes = $_GET['Departamento']; } $this->render('create', array('model' => $model, 'conceptos' => $cptos, 'departamentos' => $deptos)); }