Esempio n. 1
0
 public function nuevoAction()
 {
     //Roles disponibles
     $rolesCollection = \RolQuery::create()->find();
     $rolesArray = array();
     foreach ($rolesCollection as $rol) {
         $rolesArray[$rol->getIdrol()] = $rol->getRolNombre();
     }
     $form = new \Empleados\Form\EmpleadoForm($rolesArray);
     $request = $this->getRequest();
     if ($request->isPost()) {
         //Si hicieron POST
         $post_data = $request->getPost();
         //filtro
         $filer = new \Empleados\Filter\EmpleadoFilter();
         $form->setInputFilter($filer->getInputFilter());
         //Le ponemos los datos a nuestro formulario
         $form->setData($request->getPost());
         //Validamos nuestro formulario de articulo
         if ($form->isValid()) {
             $empleado = new \Empleado();
             //Recorremos nuestro formulario y seteamos los valores a nuestro objeto Articulo
             foreach ($form->getData() as $key => $value) {
                 if ($key == 'empleado_password') {
                     $empleado->setByName($key, md5($value), \BasePeer::TYPE_FIELDNAME);
                 } else {
                     $empleado->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
                 }
             }
             //La imagen
             if (!empty($_FILES)) {
                 if (!empty($_FILES["name"])) {
                     $date = new \DateTime();
                     $upload_folder = '/img/empleados/';
                     $tipo_archivo = $_FILES['empleado_imagen']['type'];
                     $tipo_archivo = explode('/', $tipo_archivo);
                     $tipo_archivo = $tipo_archivo[1];
                     $nombre_archivo = 'empleado-' . $date->getTimestamp() . '.' . $tipo_archivo;
                     $tmp_archivo = $_FILES['empleado_imagen']['tmp_name'];
                     $archivador = $upload_folder . $nombre_archivo;
                     if (!move_uploaded_file($tmp_archivo, $_SERVER["DOCUMENT_ROOT"] . $archivador)) {
                         return $this->getResponse()->setContent(\Zend\Json\Json::encode(array('response' => false, 'msg' => 'Ocurrio un error al subir el archivo. No pudo guardarse.', 'status' => 'error')));
                     }
                     $empleado->setEmpleadoImagen($archivador);
                 }
             }
             $empleado->save();
             if (!$empleado->isPrimaryKeyNull()) {
                 //Ya se guardo y por lo tanto tiene un pk
                 //Agregamos un mensaje
                 $this->flashMessenger()->addMessage('Empleado guardado exitosamente!');
                 //Redireccionamos a nuestro list
                 $this->redirect()->toRoute('empleados');
             }
         }
     }
     return new ViewModel(array('form' => $form, 'modulos' => $modulos));
 }
Esempio n. 2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Empleado();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Empleado'])) {
         $model->attributes = $_POST['Empleado'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->Cedula));
         }
     }
     $this->render('create', array('model' => $model));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $nombre = Input::get('nombre');
     $cargoid = Input::get('cargoid');
     $departamentoid = Input::get('departamentoid');
     $rama_ejecutivaid = Input::get('rama_ejecutivaid');
     $empleado = new Empleado();
     $empleado->nombre = $nombre;
     $empleado->cargoid = $cargoid;
     $empleado->departamentoid = $departamentoid;
     $empleado->rama_ejecutivaid = $rama_ejecutivaid;
     $empleado->save();
     Session::flash('message', 'Registro guardado satisfactoriamente!');
     return Redirect::to('empleados');
 }
Esempio n. 4
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aEmpleado !== null) {
             if ($this->aEmpleado->isModified() || $this->aEmpleado->isNew()) {
                 $affectedRows += $this->aEmpleado->save($con);
             }
             $this->setEmpleado($this->aEmpleado);
         }
         if ($this->aExpediente !== null) {
             if ($this->aExpediente->isModified() || $this->aExpediente->isNew()) {
                 $affectedRows += $this->aExpediente->save($con);
             }
             $this->setExpediente($this->aExpediente);
         }
         if ($this->aGastofacturacion !== null) {
             if ($this->aGastofacturacion->isModified() || $this->aGastofacturacion->isNew()) {
                 $affectedRows += $this->aGastofacturacion->save($con);
             }
             $this->setGastofacturacion($this->aGastofacturacion);
         }
         if ($this->aProveedoritrade !== null) {
             if ($this->aProveedoritrade->isModified() || $this->aProveedoritrade->isNew()) {
                 $affectedRows += $this->aProveedoritrade->save($con);
             }
             $this->setProveedoritrade($this->aProveedoritrade);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }
Esempio n. 5
0
 function postSucursal(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     try {
         $sucursal = new Sucursal();
         $sucursal->idEmpresa = $data['idEmpresa'];
         $sucursal->idMunicipio = $data['idMunicipio'];
         $sucursal->nombre = $data['nombre'];
         $sucursal->direccion = $data['direccion'];
         $sucursal->telefono = $data['telefono'];
         $sucursal->latitud = $data['latitud'];
         $sucursal->longitud = $data['longitud'];
         $sucursal->promedio = $data['promedio'];
         //$sucursal->usuario	   =  $data['usuario'];
         //$sucursal->pass		   =  sha1($data['pass']);
         $sucursal->estado = "ACTIVO";
         $sucursal->save();
         $val = $sucursal->id;
         $admin = new Empleado();
         $admin->nombres = $data['nombres'];
         $admin->apellidos = $data['apellidos'];
         $admin->identificacion = $data['identificacion'];
         $admin->pass = sha1($data['pass']);
         $admin->telefono = $data['telefonoadmin'];
         $admin->estado = "ACTIVO";
         $admin->idperfil = '4';
         $admin->idSucursal = $sucursal->id;
         $admin->email = $data['email'];
         $admin->save();
         /*for($i=0; $i< count($data['servicios']);$i++){
          		$servicio = new ServiciosSucursal;
          		$servicio->idServicio =	 $data['servicios'][$i][0]['idServicio'];
          		$servicio->idSucursal =  $val;    					 
          		$servicio->save();
          	}*/
         $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "error", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
Esempio n. 6
0
 function post(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     try {
         $empresa = new Empresa();
         $empresa->nit = $data['nit'];
         $empresa->razonSocial = $data['razonSocial'];
         $empresa->email = $data['email'];
         $empresa->telefono = $data['telefono'];
         $empresa->contacto = $data['contacto'];
         $empresa->promedio = '0';
         $empresa->pass = sha1($data['pass']);
         $empresa->estado = "INACTIVO";
         $empresa->save();
         $administrador = new Empleado();
         $administrador->nombres = $data['nombres'];
         $administrador->apellidos = $data['apellidos'];
         $administrador->identificacion = $data['identificacion'];
         $administrador->pass = sha1($data['pass']);
         $administrador->estado = "INACTIVO";
         $administrador->telefono = $data['telefonoadmin'];
         $administrador->idperfil = '3';
         $administrador->email = $data['emailadmin'];
         $administrador->idEmpresa = $empresa->id;
         $administrador->save();
         for ($i = 0; $i < count($data['sectores']); $i++) {
             $sector = new SectorEmpresa();
             $sector->idSector = $data['sectores'][$i]['id'];
             $sector->idEmpresa = $empresa->id;
             $sector->save();
         }
         $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "error", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     date_default_timezone_set('America/Caracas');
     // Creamos un nuevo objeto
     $empleados = new Empleado();
     // Obtenemos la data enviada por el usuario
     $data = Input::all();
     // Revisamos si la data es válido
     if ($empleados->isValid($data)) {
         // Si la data es valida se la asignamos
         $empleados->fill($data);
         // Guardamos
         $empleados->save();
         // Y Devolvemos una redirección a la acción show para mostrar
         if ($empleados->tipo == 'proveedor') {
             return Redirect::route('empleados.show', array($empleados->id))->with('create', 'El proveedor <b>' . $empleados->nombre . '</b> ha sido creado correctamente.');
         } else {
             return Redirect::route('empleados.show', array($empleados->id))->with('create', 'El empleado <b>' . $empleados->nombre . '</b> ha sido creado correctamente.');
         }
     } else {
         // En caso de error regresa a la acción create con los datos y los errores encontrados
         return Redirect::route('empleados.create')->withInput()->withErrors($empleados->errors);
     }
 }
Esempio n. 8
0
 function postsuperadmin(Request $request, Response $response)
 {
     $response = $response->withHeader('Content-type', 'application/json');
     $data = json_decode($request->getBody(), true);
     try {
         $empleado = new Empleado();
         $empleado->nombres = $data['nombres'];
         $empleado->apellidos = $data['apellidos'];
         $empleado->identificacion = $data['identificacion'];
         $empleado->pass = sha1($data['pass']);
         $empleado->idperfil = $data['idperfil'];
         $empleado->email = $data['email'];
         $empleado->estado = "ACTIVO";
         $empleado->save();
         $respuesta = json_encode(array('msg' => "Guardado correctamente", "std" => 1));
         $response = $response->withStatus(200);
     } catch (Exception $err) {
         $respuesta = json_encode(array('msg' => "error", "std" => 0, "err" => $err->getMessage()));
         $response = $response->withStatus(404);
     }
     $response->getBody()->write($respuesta);
     return $response;
 }
 public function postInsertar()
 {
     //validar formulario
     $rules = array('nombres' => 'required|max:50', 'apellido_paterno' => 'required|max:50', 'apellido_materno' => 'required|max:50', 'fecha_ingreso' => 'required');
     $messages = array('required' => 'Campo Obligatorio.', 'max' => 'El campo :attribute no puede tener mas de 50 caracteres');
     $validator = Validator::make(Input::all(), $rules, $messages);
     if ($validator->fails()) {
         return Redirect::back()->withInput()->withErrors($validator);
     }
     //al pasar la validacion se procede a guardar campos
     $persona = new Persona();
     $persona->nombres = Input::get('nombres');
     $persona->apellido_paterno = Input::get('apellido_paterno');
     $persona->apellido_materno = Input::get('apellido_materno');
     $persona->save();
     $empleado = new Empleado();
     $empleado->persona_id = $persona->id;
     //insertar el valor del id de la persona anteriormente insertada
     $empleado->puesto_id = Input::get('puesto_id');
     $empleado->fecha_ingreso = Input::get('fecha_ingreso');
     $empleado->save();
     //redirigir al listado de personal operativo
     return Redirect::to('personal-operativo')->with('status', 'ok_create');
 }
Esempio n. 10
0
 public function nuevoAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $post_files = $request->getFiles();
         $entity = new \Empleado();
         foreach ($post_data as $key => $value) {
             if (\EmpleadoPeer::getTableMap()->hasColumn($key) && !empty($value)) {
                 $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
             }
         }
         //SETIAMOS LA FECHA EN EL FORMATO CORRECTO
         $empleado_iniciocontrato = date_create_from_format('d/m/Y', $post_data['empleado_iniciocontrato']);
         $entity->setEmpleadoIniciocontrato($empleado_iniciocontrato);
         //SETIAMOS LA CONTRASEÑA EN MD5
         $entity->setEmpleadoPassword(md5($post_data['empleado_password']));
         //SETIAMOS EL STATUS COMO ACTIVO
         $entity->setEmpleadoEstatus('activo');
         $entity->save();
         //LA FOTO DEL EMPLEADO
         if (!empty($post_files['empleado_foto']['name'])) {
             $upload_folder = '/img/admin/profiles/';
             $img_type = $post_files['empleado_foto']['type'];
             $img_type = explode('/', $img_type);
             $img_type = $img_type[1];
             $img_info = getimagesize($post_files['empleado_foto']['tmp_name']);
             $img_original = imagecreatefromjpeg($post_files['empleado_foto']['tmp_name']);
             $max_ancho = 250;
             $max_alto = 250;
             list($ancho, $alto) = getimagesize($post_files['empleado_foto']['tmp_name']);
             //Se calcula ancho y alto de la imagen final
             $x_ratio = $max_ancho / $ancho;
             $y_ratio = $max_alto / $alto;
             //Si el ancho y el alto de la imagen no superan los maximos,
             //ancho final y alto final son los que tiene actualmente
             if ($ancho <= $max_ancho && $alto <= $max_alto) {
                 //Si ancho
                 $ancho_final = $ancho;
                 $alto_final = $alto;
             } elseif ($x_ratio * $alto < $max_alto) {
                 $alto_final = ceil($x_ratio * $alto);
                 $ancho_final = $max_ancho;
             } else {
                 $ancho_final = ceil($y_ratio * $ancho);
                 $alto_final = $max_alto;
             }
             //Creamos una imagen en blanco de tamaño $ancho_final  por $alto_final .
             $tmp = imagecreatetruecolor($ancho_final, $alto_final);
             //Copiamos $img_original sobre la imagen que acabamos de crear en blanco ($tmp)
             imagecopyresampled($tmp, $img_original, 0, 0, 0, 0, $ancho_final, $alto_final, $ancho, $alto);
             //Se destruye variable $img_original para liberar memoria
             imagedestroy($img_original);
             //Definimos la calidad de la imagen final
             $calidad = 95;
             //Se crea la imagen final en el directorio indicado
             imagejpeg($tmp, $_SERVER['DOCUMENT_ROOT'] . "/img/admin/profiles/empleado_avatar_" . $entity->getIdempleado() . ".jpg", $calidad);
             //SETIAMOS LA FOTO
             $entity->setEmpleadoFoto("/img/admin/profiles/empleado_avatar_" . $entity->getIdempleado() . ".jpg");
             $entity->save();
         }
     }
     //INSTANCIAMOS NUESTRO FORMULARIO
     $mexico_states = \Shared\GeneralFunction\Geolocation::getMexicoStates();
     $form = new \Catalogo\Form\EmpleadoForm($mexico_states);
     //RETORNAMOS A NUESTRA VISTA
     $view_model = new ViewModel();
     $view_model->setTemplate('admin/catalogo/empleado/nuevo');
     $view_model->setVariable('form', $form);
     return $view_model;
 }
Esempio n. 11
0
 /**
  * Performs the work of inserting or updating the row in the database.
  *
  * If the object is new, it inserts it; otherwise an update is performed.
  * All related objects are also updated in this method.
  *
  * @param PropelPDO $con
  * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
  * @throws PropelException
  * @see        save()
  */
 protected function doSave(PropelPDO $con)
 {
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     if (!$this->alreadyInSave) {
         $this->alreadyInSave = true;
         // We call the save method on the following object(s) if they
         // were passed to this object by their corresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aEmpleadoRelatedByIdempleadocomercial !== null) {
             if ($this->aEmpleadoRelatedByIdempleadocomercial->isModified() || $this->aEmpleadoRelatedByIdempleadocomercial->isNew()) {
                 $affectedRows += $this->aEmpleadoRelatedByIdempleadocomercial->save($con);
             }
             $this->setEmpleadoRelatedByIdempleadocomercial($this->aEmpleadoRelatedByIdempleadocomercial);
         }
         if ($this->aEmpleadoRelatedByIdempleadooperaciones !== null) {
             if ($this->aEmpleadoRelatedByIdempleadooperaciones->isModified() || $this->aEmpleadoRelatedByIdempleadooperaciones->isNew()) {
                 $affectedRows += $this->aEmpleadoRelatedByIdempleadooperaciones->save($con);
             }
             $this->setEmpleadoRelatedByIdempleadooperaciones($this->aEmpleadoRelatedByIdempleadooperaciones);
         }
         if ($this->isNew() || $this->isModified()) {
             // persist changes
             if ($this->isNew()) {
                 $this->doInsert($con);
             } else {
                 $this->doUpdate($con);
             }
             $affectedRows += 1;
             $this->resetModified();
         }
         if ($this->clientearchivosScheduledForDeletion !== null) {
             if (!$this->clientearchivosScheduledForDeletion->isEmpty()) {
                 ClientearchivoQuery::create()->filterByPrimaryKeys($this->clientearchivosScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->clientearchivosScheduledForDeletion = null;
             }
         }
         if ($this->collClientearchivos !== null) {
             foreach ($this->collClientearchivos as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->expedientesScheduledForDeletion !== null) {
             if (!$this->expedientesScheduledForDeletion->isEmpty()) {
                 ExpedienteQuery::create()->filterByPrimaryKeys($this->expedientesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->expedientesScheduledForDeletion = null;
             }
         }
         if ($this->collExpedientes !== null) {
             foreach ($this->collExpedientes as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         if ($this->proveedorclientesScheduledForDeletion !== null) {
             if (!$this->proveedorclientesScheduledForDeletion->isEmpty()) {
                 ProveedorclienteQuery::create()->filterByPrimaryKeys($this->proveedorclientesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
                 $this->proveedorclientesScheduledForDeletion = null;
             }
         }
         if ($this->collProveedorclientes !== null) {
             foreach ($this->collProveedorclientes as $referrerFK) {
                 if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
                     $affectedRows += $referrerFK->save($con);
                 }
             }
         }
         $this->alreadyInSave = false;
     }
     return $affectedRows;
 }