/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Cargos the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Cargos::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * 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) { $a = $this->loadModel($id); $b = Asignaciones::model()->findByAttributes(array('id' => $a->id_asignacion)); $c = Deducciones::model()->findByAttributes(array('id' => $a->id_deduccion)); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Nomina'], $_POST['Asignaciones'], $_POST['Deducciones'])) { // populate input data to $a and $b $a->attributes = $_POST['Nomina']; $b->attributes = $_POST['Asignaciones']; $c->attributes = $_POST['Deducciones']; // validate BOTH $a and $b $valid = $a->validate(); $valid = $b->validate() && $valid; $valid = $c->validate() && $valid; if ($valid) { $a->total_asig = $a->b_alimenticio($b->b_alimenticio, $a->id_empleado) + $a->asistencia($b->asistencia, $a->id_empleado) + $a->hdiurnas($b->horasextra_diurna, $a->id_empleado) + $a->hnocturnas($b->horasextras_nocturna, $a->id_empleado) + $a->sabado($b->sabado, $a->id_empleado) + $a->feriado($b->feriado, $a->id_empleado) + $a->prestamos + $a->vaciado + $a->otros; $a->total_deduc = $a->sso($c->sso, $a->id_empleado) + $a->spf($c->spf, $a->id_empleado) + $a->lph($c->lph, $a->id_empleado) + $a->inasistencia($c->inasistencia, $a->id_empleado) + $a->descuento; $empleado = Empleados::model()->findByAttributes(array('id' => $a->id_empleado)); $cargo = Cargos::model()->findByAttributes(array('id' => $empleado->id_cargo)); if ($cargo->tipo_sueldo == 1) { $a->neto = $cargo->sueldo + $a->total_asig - $a->total_deduc; } else { $a->neto = $cargo->sueldo / 2 + $a->total_asig - $a->total_deduc; } // use false parameter to disable validation $b->save(false); $c->save(false); $a->id_asignacion = $b->id; $a->id_deduccion = $c->id; $a->save(false); date_default_timezone_set('America/Caracas'); $auditoria = new Auditoria(); $auditoria->id_user = Yii::app()->user->getId(); $auditoria->accion = 3; $auditoria->modelo = $this->modelo; $auditoria->id_registro = $a->id; $auditoria->fecha = date("Y-m-d h:i:s"); $auditoria->save(false); $this->redirect(array('admin')); } } $this->render('update', array('a' => $a, 'b' => $b, 'c' => $c)); }
public function dependenciaAction($id = '') { $resul = Cargos::find(array('baja_logica=1 and organigrama_id=' . $id, 'order' => 'id ASC')); $this->view->disable(); $options = '<option value="">(Seleccionar)</option>'; foreach ($resul as $v) { $options .= '<option value="' . $v->id . '">' . $v->cargo . '</option>'; } echo $options; }
echo $form->error($b, 'talla_pantalon', array('class' => 'alert alert-danger', 'style' => 'padding:6px;')); ?> <div class="form-group input-group col-sm-12<?php echo $a->hasErrors('id_cargo') ? ' has-error' : ''; ?> "> <div class="input-group"> <span class="input-group-addon"> <i class="fa fa-graduation-cap fa-fw"></i> </span> <?php echo $form->dropDownList($a, 'id_cargo', Cargos::items(1), array('class' => 'form-control', 'title' => 'Indique el Cargo')); ?> <?php echo $a->hasErrors('id_cargo') ? "<span class='input-group-addon danger'><span class='glyphicon glyphicon-remove'></span></span>" : ''; ?> </div> <?php echo $form->error($a, 'id_cargo'); ?> </div>
/* @var $this CargosController */ /* @var $model Cargos */ $this->breadcrumbs = array('Cargos' => array('admin'), 'Gestionar'); $this->menu = array(array('label' => 'Nuevo Cargo', 'url' => array('create'))); ?> <?php $this->widget('zii.widgets.grid.CGridView', array('id' => 'cargos-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'itemsCssClass' => 'table table-striped table-hover table-bordered', 'columns' => array('cargo', array('header' => 'Sueldo', 'name' => 'sueldo', 'value' => function ($data) { return number_format($data->sueldo, 2, ',', '.'); }, 'htmlOptions' => array('style' => 'text-align: right;')), array('name' => 'tipo_sueldo', 'header' => 'Tipo de Sueldo', 'value' => function ($data) { if ($data->tipo_sueldo == '1') { return "Semanal"; } else { return "Mensual"; } }, 'filter' => CHtml::listData(Cargos::getOnoffs(), 'id', 'title')), array('class' => 'CButtonColumn', 'htmlOptions' => buttonWidth(), 'template' => template(), 'buttons' => viewVisible())))); ?> <div class="col-sm-6"> <div class="list-group"> <a href="#" class="list-group-item active"> Menú </a> <a href="index.php?r=cargos/create" class="list-group-item">Nuevo Cargo</a> </div> <?php function viewVisible() { if (Yii::app()->user->getState('role') == 2) { return array('view' => array('label' => '', 'imageUrl' => '', 'options' => array('class' => 'fa fa-search fa-fw')), 'update' => array('label' => '', 'imageUrl' => '', 'options' => array('class' => 'fa fa-pencil fa-fw'))); } else {
public function asistencia($asistencia, $id) { $empleado = Empleados::model()->findByAttributes(array('id' => $id)); $cargo = Cargos::model()->findByAttributes(array('id' => $empleado->id_cargo)); if ($asistencia == 0) { return $asistencia; } else { if ($cargo->tipo_sueldo == 1) { $semana_mes = 7; } else { $semana_mes = 30; } $sueldo_diario = $cargo->sueldo / $semana_mes; $asistencia = $sueldo_diario * 6; return $asistencia; } }