Ejemplo n.º 1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(ClienteRequest $request)
 {
     $contacto = new Contacto();
     $contacto->fill($request->all());
     $contacto->save();
     $persona = new Persona();
     $persona->fill($request->all());
     $persona->fecha_nacimiento = Carbon::createFromTimestamp(strtotime($request->fecha_nacimiento))->format('Y-m-d');
     $persona->contacto_id = $contacto->id;
     $persona->save();
     $cliente = new Cliente();
     $cliente->fill($request->all());
     $cliente->fecha_registro = Carbon::now();
     $cliente->numero_cliente = '000' . $persona->id;
     $cliente->persona_id = $persona->id;
     $cliente->save();
     $pregunta = new PreguntaSecreta();
     $pregunta->fill($request->all());
     $pregunta->save();
     $cuenta = new Cuenta();
     $cuenta->fill($request->all());
     $cuenta->cliente_id = $cliente->id;
     $cuenta->placa_auto = '';
     $cuenta->credito_disponible = 0;
     $cuenta->sucursal_gasolinera_id = $request->sucursal_gasolinera_id;
     $cuenta->pregunta_secreta_id = $pregunta->id;
     $cuenta->save();
     $usuario = new User();
     $usuario->name = $request->name;
     $usuario->password = bcrypt($request->password);
     $usuario->email = $request->correo;
     $usuario->cliente_id = $cliente->id;
     $usuario->save();
     return redirect()->route('cliente.index');
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Cuenta::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'fecha_ini' => $this->fecha_ini, 'fecha_fin' => $this->fecha_fin, 'created_at' => $this->created_at, 'baja' => $this->baja, 'id_contacto' => $this->id_contacto, 'id_plan' => $this->id_plan, 'precio' => $this->precio]);
     $query->andFilterWhere(['like', 'nombre_usuario', $this->nombre_usuario])->andFilterWhere(['like', 'clave', $this->clave]);
     return $dataProvider;
 }
 public function search($input)
 {
     $query = Cuenta::query();
     $columns = Schema::getColumnListing('cuentas');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
Ejemplo n.º 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Cuenta::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     /*$dataProvider->sort->attributes['id'] = [
       // The tables are the ones our relation are configured to
       // in my case they are prefixed with "tbl_"
       'asc' => ['id' => SORT_ASC],
       'desc' => ['id' => SORT_DESC],
       ];*/
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'tipocuenta' => $this->tipocuenta, 'saldo' => $this->saldo, 'idconcepto' => $this->idconcepto, 'fecha' => $this->fecha, 'gastoingreso' => $this->gastoingreso]);
     $query->andFilterWhere(['like', 'descripcion', $this->descripcion]);
     return $dataProvider;
 }
Ejemplo n.º 5
0
 /**
  * Elimina la contabilidad guardada
  */
 public function actionDelete()
 {
     $anyo = Yii::$app->request->post('anyocont');
     $consulta = 'DROP TABLE IF EXISTS cuenta' . $anyo . ';';
     Cuenta::getDb()->createCommand($consulta)->execute();
     return $this->redirect("index.php?r=cambioanyo");
 }
Ejemplo n.º 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCuentas()
 {
     return $this->hasMany(Cuenta::className(), ['idconcepto' => 'id']);
 }
Ejemplo n.º 7
0
 public function actionAjax()
 {
     if (isset($_POST['categoria'])) {
         $categoria = $_POST['categoria'];
         $tc = new TipoCategorias();
         echo json_encode($tc->getTipoCategoriasByCategoria($categoria));
     }
     if (isset($_POST['dameusu'])) {
         $damecat = $_POST['dameusu'];
         if ($damecat) {
             $tc = new Usuario();
             echo json_encode($tc->getUsuarios());
         }
     }
     if (isset($_POST['damecat'])) {
         $damecat = $_POST['damecat'];
         if ($damecat) {
             $tc = new CategoriasObjetos();
             echo json_encode($tc->getCategorias());
         }
     }
     if (isset($_POST['dameubi'])) {
         $damecat = $_POST['dameubi'];
         if ($damecat) {
             $tc = new Ubicaciones();
             echo json_encode($tc->getUbicaciones());
         }
     }
     if (isset($_POST['damesubc'])) {
         $damecat = $_POST['damesubc'];
         if ($damecat) {
             $tc = new TipoCategorias();
             echo json_encode($tc->getAllTipoCategorias());
         }
     }
     if (isset($_POST['damecg'])) {
         $damecat = $_POST['damecg'];
         if ($damecat) {
             $tc = new Cuenta();
             echo json_encode($tc->getConceptosGastos());
         }
     }
     if (isset($_POST['dameci'])) {
         $damecat = $_POST['dameci'];
         if ($damecat) {
             $tc = new Cuenta();
             echo json_encode($tc->getConceptoIngresos());
         }
     }
     if (isset($_POST['duplicar'])) {
         //Llama al procedimiento
         $dup = $_POST['duplicar'];
         if ($dup) {
             if (isset($_POST['id']) && isset($_POST['cantidad'])) {
                 $id = $_POST['id'];
                 $cantidad = $_POST['cantidad'];
                 $model = new Objeto();
                 try {
                     $numRowsAffected = $model::getDb()->createCommand("call duplicarObjeto(" . $id . "," . $cantidad . ");")->execute();
                     $objeto = Objeto::findOne($id);
                     echo "Se han añadido " . $cantidad . " registros más del objeto " . $objeto->tipo . " de " . $objeto->ubicacion;
                 } catch (yii\db\Exception $e) {
                     echo "No se ha podido duplicar según su solicitud";
                 }
             }
         }
     }
 }
Ejemplo n.º 8
0
 public function postCargarGasolina(Request $request, $id)
 {
     $cuenta = Cuenta::findOrFail($id);
     $valitador = \Validator::make($request->all(), ['consumo' => 'required|numeric|min:1|max:' . $cuenta->credito_disponible]);
     if ($valitador->fails()) {
         return redirect()->back()->withErrors($valitador);
     } else {
         $cuenta = Cuenta::findOrFail($id);
         $cuenta->credito_disponible = $cuenta->credito_disponible - $request->consumo;
         $cuenta->save();
         $consumo = new ConsumoCliente();
         $consumo->importe = $request->consumo;
         $consumo->cliente_id = $cuenta->cliente_id;
         $consumo->coche_id = $request->coche_id;
         $consumo->save();
         Flash::success('El cargo se ha efectuado exitosamente');
     }
     return redirect()->route('home');
 }
Ejemplo n.º 9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCuenta()
 {
     return $this->hasOne(Cuenta::className(), ['id' => 'cuenta_id']);
 }
Ejemplo n.º 10
0
 private function actualizarNumCuenta($numcuenta)
 {
     $comando = Cuenta::getDb()->createCommand('UPDATE cuenta SET id=id - 1 WHERE id>' . $numcuenta);
     $comando->execute();
     $command = Cuenta::getDb()->createCommand("SELECT max(id) FROM cuenta");
     $maximo = $command->queryScalar();
     $comando = Cuenta::getDb()->createCommand('ALTER TABLE cuenta AUTO_INCREMENT = :max');
     $comando->bindValue(':max', $maximo + 1);
     $comando->execute();
 }
Ejemplo n.º 11
0
 /**
  * Finds the Cuenta model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Cuenta the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Cuenta::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }