public function agregar() { //Comprobamos que vienen todos los datos. if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email']) && isset($_POST['first_name']) && isset($_POST['last_name']) && isset($_POST['company']) && (trim($_POST['password']) && trim($_POST['password2']))) { //Declaramos el objeto empleado. $empleado = new Empleado(); $empleado->usuario = $_POST['username']; $empleado->pass = $_POST['password']; $empleado->email = $_POST['email']; $empleado->nombre = $_POST['first_name']; $empleado->apellido = $_POST['last_name']; $empleado->empresa = $_POST['company']; $empleado->permisos = '1'; //Registramos el usuario. $nuevoEmple = $empleado->agregarEmpleado(); //Comprobamos que se ha agregado correctamente if ($nuevoEmple != false) { $this->session->set_flashdata('type', 'success'); $this->session->set_flashdata('msg', 'Usuario dado de alta con éxito'); redirect('/usuarios/'); } else { $this->session->set_flashdata('type', 'danger'); $this->session->set_flashdata('msg', 'Error al intentar dar de alta un nuevo usuario.'); redirect('/usuarios/'); } } else { $this->session->set_flashdata('type', 'danger'); $this->session->set_flashdata('msg', 'Por favor introduzca los datos del usuario neuvo correctamente.'); redirect('/usuarios/'); } }
public function index() { //Declaramos el objeto empleado. $empleado = new Empleado(); //Obtenemos el empleado en cuestion. $usuario = $empleado->empleado($this->ion_auth->user()->row()->id); $data['v'] = 'dashboard'; $data['title'] = 'Escritorio'; $data['controller'] = $this->router->fetch_class(); $data['method'] = $this->router->method; $data['userData'] = $usuario; $this->load->view('template', $data); }
public function index() { //Declaramos el objeto empleado. $empleado = new Empleado(); //Obtenemos el empleado en cuestion. $usuario = $empleado->empleado($this->ion_auth->user()->row()->id); //Damos valores a la configuracion del template. $data['v'] = '/clientes/clientes_view'; $data['title'] = 'Listado de Clientes'; $data['controller'] = $this->router->fetch_class(); $data['method'] = $this->router->method; $data['userData'] = $usuario; //Inflamos la vista. $this->load->view('template', $data); }
/** * Finds the Empleado model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Empleado the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Empleado::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Show the form for creating a new resource. * * @return Response */ public function create($id) { $empleados = Empleado::getListCmb($id); $proyecto = Proyecto::find($id); $this->layout->title = 'Nuevo Empleado'; $this->layout->titulo = 'Gestión de Proyectos'; $this->layout->nest('content', 'empleadosproyectos.create', array('proyecto' => $proyecto, 'empleados' => $empleados)); }
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; }
public function home() { $agente = Agente::find(1); $totalAgente = DB::table('agente')->count(); $iva = DB::table('impuesto')->where('estatus', '=', 'actual')->first(); date_default_timezone_set('America/Caracas'); $dia = date('d'); $mes = date('m'); $anio = date('Y'); $hoy = $anio . '-' . $mes . '-' . $dia; $mesActual = $anio . '-' . $mes; $reportesIva = DB::table('reportes')->orderBy('id', 'DESC')->where('fecha', '=', $hoy)->get(); $reportesTodos = DB::table('reportes')->orderBy('n_comp', 'desc')->get(); $proveedores = Proveedor::all(); $totalDia = 0; $totalMes = 0; $contador = 0; $reportesIslr = DB::table('reportesislr')->where('fecha', '=', $hoy)->orderBy('fecha', 'desc')->get(); $empleados = Empleado::all(); $reportesIslrTodos = DB::table('reportesislr')->orderBy('fecha', 'desc')->get(); // Suscripcion $diaLicencia = date('d', strtotime($agente->hasta)); $mesLicencia = date('m', strtotime($agente->hasta)); $anioLicencia = date('Y', strtotime($agente->hasta)); $licencia = date('Y-m-d', strtotime($agente->hasta)); $fechaHoy = date('Y-m-d'); $datetime1 = new DateTime($fechaHoy); $datetime2 = new DateTime($licencia); $interval = $datetime1->diff($datetime2); $resta = $interval->format('%R%a'); $diasRestante = str_replace("+", "", $resta); //dd($diasRestante); $hoyLicencia = date('d-m-Y'); if ($hoyLicencia == $diaLicencia . '-' . $mesLicencia . '-' . $anioLicencia) { $mensaje = '<div class="alert alert-warning"> <button type="button" class="close" data-dismiss="alert">×</button> <p>Hasta hoy ' . date("d/m/Y", strtotime($hoyLicencia)) . ' puedes usar la aplicación</p> </div>'; } elseif ($diasRestante <= 30) { $mensaje = '<div class="alert alert-warning"> <button type="button" class="close" data-dismiss="alert">×</button> <p>Te quedan ' . $diasRestante . ' días de suscripción, Por favor ponte en contacto con <b>joserph.a@gmail.com<b></p> </div>'; } else { $mensaje = ''; } if (is_null($iva)) { $iva = 'vencido'; } return View::make('home', array('agente' => $agente, 'totalAgente' => $totalAgente, 'iva' => $iva, 'reportesIva' => $reportesIva, 'proveedores' => $proveedores, 'reportesTodos' => $reportesTodos, 'reportesIslr' => $reportesIslr, 'empleados' => $empleados, 'reportesIslrTodos' => $reportesIslrTodos))->with('contador', $contador)->with('totalDia', $totalDia)->with('totalMes', $totalMes)->with('hoy', $hoy)->with('mes', $mes)->with('anio', $anio)->with('mensaje', $mensaje); //return var_dump($reportesTodos); }
public function __construct() { parent::__construct(); $this->load->model('evento_model'); $this->load->model('presupuesto_model'); $this->load->model('chat_model'); $this->load->model('cliente_model'); $this->load->model('tarea_model'); $this->load->model('respuesta_model'); $this->load->model('archivo_model'); $this->load->model('notas_model'); $this->load->model('noticias_model', 'Noticias'); }
public function Next_Set($et_id, $owner, $actual) { $Empleado = new Empleado(); $resultado = array(); $query = sprintf("select * from etapas where et_id=%s", $et_id); $aux = parent::consultar($query); $etapa = mysql_fetch_assoc($aux); if ($etapa["et_finaliza"] == false) { $query = sprintf("select * from etapas where et_id='%s'", $etapa["et_siguiente_etapa"]); $aux = parent::consultar($query); $etapa = mysql_fetch_assoc($aux); $resultado["finaliza"] = false; $resultado["etapa"] = $etapa["et_id"]; $resultado["empleado"] = $Empleado->busca_profundidad($owner, $etapa["et_profundidad_responsable"]); return $resultado; } else { $resultado["empleado"] = $actual; $resultado["etapa"] = $et_id; $resultado["finaliza"] = true; } return $resultado; }
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)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $this->performAjaxValidation($model, 'sancion-form'); if (isset($_POST['Sancion'])) { $model->attributes = $_POST['Sancion']; if ($model->save()) { ActividadSistema::registrarActividad($model, ActividadSistema::TIPO_UPDATE, Yii::app()->user->id); Notificacion::registrarAlertaA($model, Notificacion::ASIGNADO, Empleado::model()->find('id=:idUser', array(':idUser' => $model->empleado_id))->userid); $this->redirect(array('view', 'id' => $model->id)); } } $this->render('update', array('model' => $model)); }
public function authenticate() { $employe = Empleado::model()->with('empresa')->findByAttributes(array('username' => $this->username)); if ($employe === null || $employe->password !== $this->password) { $this->errorCode = self::ERROR_UNKNOWN_IDENTITY; } else { $this->_id = $employe->id; $this->setState('idEmpresa', $employe->idEmpresa); $fullData = '[' . $employe->numero . '] ' . $employe->nombre . ' ' . $employe->apellido; $this->setState('fullData', $fullData); $this->setState('nombreEmpresa', $employe->empresa->nombre); $this->errorCode = self::ERROR_NONE; } return !$this->errorCode; }
/** * Resets all references to other model objects or collections of model objects. * * This method is a user-space workaround for PHP's inability to garbage collect * objects with circular references (even in PHP 5.3). This is currently necessary * when using Propel in certain daemon or large-volume/high-memory operations. * * @param boolean $deep Whether to also clear the references on all referrer objects. */ public function clearAllReferences($deep = false) { if ($deep && !$this->alreadyInClearAllReferencesDeep) { $this->alreadyInClearAllReferencesDeep = true; if ($this->aEmpleado instanceof Persistent) { $this->aEmpleado->clearAllReferences($deep); } if ($this->aExpediente instanceof Persistent) { $this->aExpediente->clearAllReferences($deep); } $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aEmpleado = null; $this->aExpediente = null; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model = $this->loadModel($id); $this->performAjaxValidation($model, 'informe-form'); if (isset($_POST['Informe'])) { $model->attributes = $_POST['Informe']; $model->usuario_actualizacion_id = Yii::app()->user->id; $model->fecha_actualizacion = Util::FechaActual(); if ($model->save()) { ActividadSistema::registrarActividad($model, ActividadSistema::TIPO_UPDATE, Yii::app()->user->id); Notificacion::registrarAlertaA($model, Notificacion::ASIGNADO, Empleado::model()->find('id=:idUser', array(':idUser' => $model->entidad_tipo ? $model->entidad_tipo : $model->entidad_id))->userid); //$this->redirect(array('view', 'id' => $model->id)); $this->redirect(array('admin')); } } $this->render('update', array('model' => $model)); }
/** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { if (Yii::app()->request->isPostRequest) { // we only allow deletion via POST request $empleados = Empleado::model()->de_Cargo($id)->findAll(); if (count($empleados) == 0) { $this->reordenarPesoDeleted(); $this->loadModel($id)->delete(); Yii::app()->user->setFlash('success', "El Cargo ha sido eliminado con exito!."); } else { Yii::app()->user->setFlash('error', "No se puede eliminar este Cargo, contiene Empleados asignados."); } // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if (!isset($_GET['ajax'])) { $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } } else { throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.'); } }
function contabilidadsector(Request $request, Response $response) { $response = $response->withHeader('Content-type', 'application/json'); $id = $request->getAttribute("idSector"); $fechainicial = $request->getAttribute("fechainicial"); $fechafinal = $request->getAttribute("fechafinal"); $data = SectorEmpresa::select('sectorempresa.idEmpresa', 'empresa.razonSocial')->join('empresa', 'empresa.id', '=', 'sectorempresa.idEmpresa')->where('idSector', '=', $id)->get(); for ($i = 0; $i < count($data); $i++) { $sucu = Sucursal::select('sucursal.id', 'sucursal.nombre')->where('sucursal.idEmpresa', '=', $data[$i]->idEmpresa)->get(); $data[$i]['sucu'] = $sucu; for ($j = 0; $j < count($sucu); $j++) { $empl = Empleado::select('empleado.id as idempleado')->where('idSucursal', '=', $sucu[$j]->id)->get(); $sucu[$j]['idEmpleado'] = $empl; for ($k = 0; $k < count($empl); $k++) { $ingreso = Ingreso::select('ingresos.valor')->where('ingresos.idEmpleado', '=', $empl[$k]->idempleado)->whereBetween('ingresos.fecha', array($fechainicial, $fechafinal))->sum('ingresos.valor'); $empl[$k]['valor'] = $ingreso; } } } $response->getBody()->write($data); return $response; }
/** * Resets all references to other model objects or collections of model objects. * * This method is a user-space workaround for PHP's inability to garbage collect * objects with circular references (even in PHP 5.3). This is currently necessary * when using Propel in certain daemon or large-volume/high-memory operations. * * @param boolean $deep Whether to also clear the references on all referrer objects. */ public function clearAllReferences($deep = false) { if ($deep && !$this->alreadyInClearAllReferencesDeep) { $this->alreadyInClearAllReferencesDeep = true; if ($this->aEmpleado instanceof Persistent) { $this->aEmpleado->clearAllReferences($deep); } if ($this->aExpediente instanceof Persistent) { $this->aExpediente->clearAllReferences($deep); } if ($this->aGastofacturacion instanceof Persistent) { $this->aGastofacturacion->clearAllReferences($deep); } if ($this->aProveedoritrade instanceof Persistent) { $this->aProveedoritrade->clearAllReferences($deep); } $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aEmpleado = null; $this->aExpediente = null; $this->aGastofacturacion = null; $this->aProveedoritrade = null; }
<?php include_once "includes/camion.php"; include_once "includes/empleado.php"; include_once "includes/sucursal.php"; $empleado = new Empleado(); $sucursal = new Sucursal(); $camion = new Camion(); if (isset($_POST["origen"], $_POST["destino"], $_POST["empleado"], $_POST["cantidad_paquetes"], $_POST["placa"])) { if (!empty($_POST["origen"]) && !empty($_POST["destino"]) && !empty($_POST["empleado"]) && !empty($_POST["cantidad_paquetes"]) && !empty($_POST["placa"])) { $camion->setOrigen($_POST["origen"]); $camion->setDestino($_POST["destino"]); $camion->setEmpleado($_POST["empleado"]); $camion->setCantidad_paquetes($_POST["cantidad_paquetes"]); $camion->setPlaca($_POST["placa"]); $camion->agregar_camion(); $empleado->setNombre($_POST["empleado"]); $empleado->ocupar(); } } if (isset($_GET["eliminar"])) { $camion = $camion->setId_camion($_GET["eliminar"]); $camion->eliminar(); } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Camiones</title> <link rel="stylesheet" type="text/css" href="css/style.css"> </head>
<?php /** @var EmpleadoSubalternoController $this */ /** @var AweActiveForm $form */ $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('action' => Yii::app()->createUrl($this->route), 'method' => 'get')); ?> <?php echo $form->textFieldRow($model, 'id'); ?> <?php echo $form->dropDownListRow($model, 'empleado_id', array('' => ' -- Seleccione -- ') + CHtml::listData(Empleado::model()->findAll(), 'id', Empleado::representingColumn())); ?> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('type' => 'primary', 'label' => Yii::t('AweCrud.app', 'Search'))); ?> </div> <?php $this->endWidget();
public function scopes() { // var_dump(Empleado::model()->find('userid=:idUser', array(':idUser' => Yii::app()->user->id))->id); // die(); return array('activos' => array('condition' => 'estado = :estado', 'params' => array(':estado' => self::ESTADO_ACTIVO)), 'aCargo' => array('condition' => 'seccion = :idEncargado', 'params' => array(':idEncargado' => Yii::app()->user->id)), 'propias' => array('condition' => 'empleado_id = :id', 'params' => array(':id' => Empleado::model()->find('userid=:idUser', array(':idUser' => Yii::app()->user->id))->id)), 'propiasAcargo' => array('condition' => 'seccion = :idEncargado or empleado_id = :id', 'params' => array(':id' => Empleado::model()->find('userid=:idUser', array(':idUser' => Yii::app()->user->id))->id, ':idEncargado' => Yii::app()->user->id)), 'ordenByFechaSolicitud' => array('order' => 'fecha_solicitud DESC')); }
public function actionAjaxUpdateEtapa($id_data = null, $id_etapa = null) { if (Yii::app()->request->isAjaxRequest) { $modelSolicitud = SolicitudPermiso::model()->findByPk($id_data); $modelSolicitud->permismo_etapa_id = $id_etapa; // $updated = SolicitudPermiso::model()->updateByPk($id_data, array( // 'permismo_etapa_id' => $id_etapa // ) // ); // var_dump($modelSolicitud->empleado_id); // die(); if ($modelSolicitud->save()) { ActividadSistema::registrarActividad($modelSolicitud, ActividadSistema::TIPO_RESTORE, Yii::app()->user->id); Notificacion::registrarAlertaA($modelSolicitud, Notificacion::TIPO_RESTORE, Empleado::model()->find('id=:idUser', array(':idUser' => $modelSolicitud->empleado_id))->userid); } } }
<?php /** * Description of Empleado * * @author ALEX */ $nombre = $_POST['nombre']; $sueldo = $_POST['sueldo']; $empleado = new Empleado($nombre, $sueldo); $empleado->mostrarDatos(); $empleado->calcularImpuestos($sueldo); class Empleado { private $nombre; private $sueldo; //contructor public function __construct($nom, $suel) { $this->nombre = $nom; $this->sueldo = $suel; } //funcion motrar datos function mostrarDatos() { echo "Nombre: " . $this->nombre . "<br>"; echo "Sueldo: " . $this->sueldo . "<br>"; } function calcularImpuestos($suel) { $this->sueldo = $suel;
?> <?php echo Empleado::label(2); ?> </h4> <!-- widget action, you can also use btn, btn-group, nav-tabs or nav-pills (also support dropdown). enjoy! --> <div class="widget-action"> <button data-toggle="collapse" data-collapse="#widget-button" class="btn"> <i class="aweso-chevron-up color-cyan" data-toggle-icon="aweso-chevron-down aweso-chevron-up"></i> </button> </div> </div><!-- /widget header --> <!-- widget content --> <div class="widget-content bg-white"> <div style='overflow:auto'> <?php $dataProvider = ''; if (Util::getRolUser(Yii::app()->user->id) == 'OPERADOR') { $dataProvider = $model->activos()->searchSubAlterno(Empleado::model()->find('userid=:idUser', array(':idUser' => Yii::app()->user->id))->id, true); } else { $dataProvider = $model->noUser()->activos()->search(); } //$this->widget('bootstrap.widgets.TbGridView',array( $this->widget('ext.selgridview.BootSelGridView', array('id' => 'empleado-grid', 'type' => 'striped bordered hover advance ', 'template' => '{summary}{items}{pager}', 'dataProvider' => $dataProvider, 'pagerCssClass' => 'pagination text-center', 'selectableRows' => 2, 'filter' => $model, 'columns' => array(array('id' => 'check_id', 'class' => 'CCheckBoxColumn', 'value' => '$data->id'), array('name' => 'documento', 'value' => 'CHtml::link($data->documento, Yii::app()->createUrl("/personal/empleado/view", array("id"=>$data->id)))', 'type' => 'html'), array('name' => 'nombre_completo', 'value' => 'CHtml::link($data->nombre_completo, Yii::app()->createUrl("/personal/empleado/view", array("id"=>$data->id)))', 'type' => 'html'), array('name' => 'fecha_contratacion', 'value' => 'Util::FormatDate($data->fecha_contratacion, "Y/m/d")'), array('name' => 'usuario_creacion_id', 'value' => 'Yii::app()->user->um->loadUserById($data->usuario_creacion_id)->username'), array('name' => 'empleo_cargo_id', 'value' => 'isset($data->empleoCargo) ? $data->empleoCargo : null', 'filter' => CHtml::listData(EmpleoCargo::model()->findAll(), 'id', EmpleoCargo::representingColumn())), array('name' => 'horario_id', 'value' => 'isset($data->horario) ? $data->horario : null', 'filter' => CHtml::listData(Horario::model()->findAll(), 'id', Horario::representingColumn())), array('class' => 'CButtonColumn', 'template' => '{update} {delete}', 'deleteConfirmation' => CrugeTranslator::t('admin', 'Are you sure you want to delete this user'), 'buttons' => array('update' => array('label' => '<button class="btn btn-info"><i class="aweso-pencil"></i></button>', 'options' => array('title' => Yii::t('AweCrud.app', 'Update')), 'imageUrl' => false), 'delete' => array('label' => '<button class="btn btn-danger"><i class="aweso-trash"></i></button>', 'options' => array('title' => Yii::t('AweCrud.app', 'Delete')), 'imageUrl' => false)), 'htmlOptions' => array('width' => '80px'))))); ?> </div> </div> </div> </div> </div> <!--</fieldset>-->
<?php /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ class Empleado { private $nombre; private $sueldo; function __construct($nombre, $sueldo = null) { $this->nombre = $nombre; $this->sueldo = $sueldo; } public function imprimir() { echo "El nombre es: " . $this->nombre . "<br />" . " El sueldo es: " . $this->sueldo . "<br />"; } } $empleado1 = new Empleado("Quique", 5000); $empleado2 = new Empleado("Pepe"); $empleado1->imprimir(); $empleado2->imprimir();
function empleadosDisponibles(Request $request, Response $response) { $response = $response->withHeader('Content-type', 'application/json'); $idServicio = $request->getAttribute("idServicio"); $idSucursal = $request->getAttribute("idSucursal"); $fecha = $request->getAttribute("fecha"); $hora = $request->getAttribute("hora"); $cupos = $request->getAttribute("cupos"); $dataMitiempo = ServiciosSucursal::select("minutos")->where("idServicio", "=", $idServicio)->where("idSucursal", "=", $idSucursal)->first(); $minutos = 60; if ($data != null) { $minutos = $dataMitiempo->minutos; } $empleado = Empleado::select("*")->where("idSucursal", "=", $idSucursal)->where("idPerfil", "=", 2)->get(); //$horaFinal = "(sec_to_time(time_to_sec('$hora') + (time_to_sec('$hora') * $cupos)))"; $tiempo = 0; for ($i = 0; $i < $cupos; $i++) { $tiempo += $minutos; } $horaFinal = "ADDTIME('{$hora}', SEC_TO_TIME({$tiempo}*60))"; $data = array(); for ($i = 0; $i < count($empleado); $i++) { $query = "SELECT " . "tur.id " . "FROM " . "turno tur " . "WHERE " . "tur.idServicio = {$idServicio} AND " . "tur.idSucursal = {$idSucursal} AND " . "tur.idEmpleado = " . $empleado[$i]->id . " AND " . "tur.fechaReserva = '{$fecha}' AND " . "tur.reserva = 'A' AND " . "(tur.estadoTurno <> 'TERMINADO' AND tur.estadoTurno <> 'CANCELADO') AND (" . "(TIMESTAMP('{$fecha}','{$hora}') >= tur.horaReserva AND TIMESTAMP('{$fecha}','{$hora}') < tur.horaFinalReserva) OR " . "(TIMESTAMP('{$fecha}',{$horaFinal}) > tur.horaReserva AND TIMESTAMP('{$fecha}',{$horaFinal}) <= tur.horaFinalReserva))"; //. "(TIMESTAMP('$fecha','$hora') < tur.horaReserva AND TIMESTAMP('$fecha',$horaFinal) > tur.horaReserva))"; $disp = DB::select(DB::raw($query)); if (count($disp) == 0) { $data[] = $empleado[$i]; } } $response->getBody()->write(json_encode($data)); return $response; }
/** * Filter the query by a related Empleado object * * @param Empleado|PropelObjectCollection $empleado the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return RolQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByEmpleado($empleado, $comparison = null) { if ($empleado instanceof Empleado) { return $this->addUsingAlias(RolPeer::IDROL, $empleado->getIdrol(), $comparison); } elseif ($empleado instanceof PropelObjectCollection) { return $this->useEmpleadoQuery()->filterByPrimaryKeys($empleado->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByEmpleado() only accepts arguments of type Empleado or PropelCollection'); } }
public function getActivar($id) { $empleado = Empleado::find($id); $empleado->activo = "1"; $empleado->save(); return Redirect::to('personal-operativo')->with('status', 'ok_activar'); }
/** * Filter the query by a related Empleado object * * @param Empleado|PropelObjectCollection $empleado The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ExpedientearchivoQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByEmpleado($empleado, $comparison = null) { if ($empleado instanceof Empleado) { return $this->addUsingAlias(ExpedientearchivoPeer::IDEMPLEADO, $empleado->getIdempleado(), $comparison); } elseif ($empleado instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(ExpedientearchivoPeer::IDEMPLEADO, $empleado->toKeyValue('PrimaryKey', 'Idempleado'), $comparison); } else { throw new PropelException('filterByEmpleado() only accepts arguments of type Empleado or PropelCollection'); } }
<?php class Persona { public $dni; public $nombre; public final function setNombre($nombre) { $this->nombre = addslashes(strtoupper(trim($nombre))); } } class Empleado extends Persona { public $cargo; public function setCargo($cargo) { $this->cargo = addslashes(strtoupper(trim($cargo))); } } $regEmpleado = new Empleado(); $regEmpleado->setNombre('Juan Sanchez'); echo '<br>' . $regEmpleado->nombre;
public function editarAction() { $id = $this->params()->fromRoute('id'); $request = $this->getRequest(); if ($request->isPost()) { $post_data = $request->getPost(); //INSTANCIAMOS NUESTRA ENTIDAD $entity = \ClienteQuery::create()->findPk($id); //SETIAMOS NUESTROS DATOS CON EXCEPCIONES foreach ($post_data as $key => $value) { if (\ClientePeer::getTableMap()->hasColumn($key) && !empty($value) && $key != 'cliente_cumpleanios') { $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME); } } if (!empty($post_data['cliente_cumpleanios'])) { $cliente_cumpleanios = date_create_from_format('d/m/Y', $post_data['cliente_cumpleanios']); $entity->setClienteCumpleanios($cliente_cumpleanios); } $entity->save(); //Agregamos un mensaje $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!'); //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR return $this->redirect()->toRoute('admin/clientes/editar', array('id' => $entity->getIdcliente())); } $exist = \ClienteQuery::create()->filterByIdcliente($id)->exists(); if ($exist) { $entity = \ClienteQuery::create()->findPk($id); $empleados = \EmpleadoQuery::create()->filterByIdempleado(1, \Criteria::NOT_EQUAL)->find(); $empleados_array = array(); $empleado = new \Empleado(); foreach ($empleados as $empleado) { $id = $empleado->getIdempleado(); $empleados_array[$id] = $empleado->getEmpleadoNombre() . ' ' . $empleado->getEmpleadoApellidopaterno() . ' ' . $empleado->getEmpleadoApallidomaterno(); } $form = new \Admin\Clientes\Form\ClientesForm($empleados_array); $form->setData($entity->toArray(\BasePeer::TYPE_FIELDNAME)); //LOS ARCHIVOS $files = \ClientearchivoQuery::create()->filterByIdcliente($entity->getIdcliente())->find(); $files_array = array(); $file = new \Clientearchivo(); foreach ($files as $file) { $file_path = $file->getClientearchivoArchivo(); $file_name = explode('files/clientes/' . $entity->getIdcliente() . '/', $file->getClientearchivoArchivo()); $tmp['id'] = $file->getIdclientearchivo(); $tmp['name'] = $file_name[1]; $tmp['size'] = $file->getClientearchivoSize(); $tmp['type'] = mime_content_type($_SERVER['DOCUMENT_ROOT'] . '/' . $file->getClientearchivoArchivo()); $files_array[] = $tmp; } //RETORNAMOS A NUESTRA VISTA $view_model = new ViewModel(); $view_model->setTemplate('admin/clientes/clientes/editar'); $view_model->setVariables(array('entity' => json_encode($entity->toArray(\BasePeer::TYPE_FIELDNAME)), 'successMessages' => json_encode($this->flashMessenger()->getSuccessMessages()), 'form' => $form, 'files' => json_encode($files_array))); return $view_model; } else { return $this->redirect()->toRoute('admin/clientes', array('action' => 'index')); } }