Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Alberto Cricelli committed Mar 1, 2020
2 parents 5585cdf + 81e3707 commit 0784196
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
/*.sublime-project
/*.sublime-workspace
/.idea
/.vscode
/*.code-*

# Makefile
/build
26 changes: 25 additions & 1 deletion app/Model/Registro.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Dependencias
*/
App::uses('AppModel', 'Model');
App::uses('CakeSession', 'Model/Datasource');

/**
* Registro
Expand Down Expand Up @@ -116,7 +117,7 @@ class Registro extends AppModel {
'notBlank' => array(
'rule' => 'notBlank',
'required' => true,
'allowEmpty' => false,
'allowEmpty' => true,
'last' => true,
'message' => 'Este campo no puede estar vacío'
),
Expand Down Expand Up @@ -154,12 +155,35 @@ public function beforeValidate($options = array()) {
if (!isset($this->data[$this->alias]['id'])) {
if (empty($this->data[$this->alias]['obs'])) {
$this->data = $this->validate = array();
} else {
$this->data[$this->alias]['entrada'] = date('H:i:s');
}
} else {
$registros = (array)CakeSession::read('RegistrosCreados');
if (!in_array($this->data[$this->alias]['id'], $registros)) {
$this->data[$this->alias]['salida'] = date('H:i:s');
}
}

return true;
}

/**
* afterSave
*
* @param bool $created Indica si el registro se ha creado
* @param array $options Opciones
*
* @return void
*/
public function afterSave($created, $options = array()) {
if ($created) {
$registros = (array)CakeSession::read('RegistrosCreados');
$registros[] = $this->data[$this->alias]['id'];
CakeSession::write('RegistrosCreados', $registros);
}
}

/**
* Devuelve la fecha del primer registro de asistencia
*
Expand Down
4 changes: 2 additions & 2 deletions app/Model/Usuario.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ public function getCargos($id = null) {
foreach ($rows as $rid => $row) {
if (empty($row['Registro']['id'])) {
$row['Registro']['asignatura_id'] = $row['Cargo']['asignatura_id'];
$row['Registro']['entrada'] = $row['Horario']['entrada'];
$row['Registro']['entrada'] = date('H:i:s');
$row['Registro']['fecha'] = date('Y-m-d H:i:s');
$row['Registro']['salida'] = $row['Horario']['salida'];
$row['Registro']['salida'] = null;
$row['Registro']['tipo'] = 1;
$row['Registro']['usuario_id'] = $id;
}
Expand Down
3 changes: 2 additions & 1 deletion app/View/Elements/Report/table.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
if (!empty($chunk)):
foreach ($chunk as $rid => $row):
$asistencia = ($row['Registro']['tipo'] === '1');
$salida = (!empty($row['Registro']['salida']) ? date('H:i', strtotime($row['Registro']['salida'])) : '-');
?>
<tr>
<?php if (empty($data['asignatura'])): ?>
Expand All @@ -55,7 +56,7 @@
</td>

<td class="row6">
<?php echo ($asistencia ? date('H:i', strtotime($row['Registro']['salida'])) : '-') ?>
<?php echo ($asistencia ? $salida : '-') ?>
</td>

<td class="row7">
Expand Down
3 changes: 2 additions & 1 deletion app/View/Registros/admin_generar_reporte.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ $this->Html->addCrumb('Generar reporte');
$start = $this->Paginator->counter(array('format' => '%start%'));
foreach ($rows as $rid => $row):
$asistencia = ($row['Registro']['tipo'] == '1');
$salida = (!empty($row['Registro']['salida']) ? date('H:i', strtotime($row['Registro']['salida'])) : '-');
$rows[$rid] = array(
$start++,
str_replace(':', ':<br />', h($row['Registro']['asignatura'])),
$row['Usuario']['legajo'],
h($row['Registro']['usuario']),
date('d/m/Y' . ($asistencia ? ' H:i:s' : ''), strtotime($row['Registro']['fecha'])),
($asistencia ? date('H:i', strtotime($row['Registro']['entrada'])) : '-'),
($asistencia ? date('H:i', strtotime($row['Registro']['salida'])) : '-'),
($asistencia ? $salida : '-'),
nl2br(h($row['Registro']['obs']))
);
endforeach;
Expand Down
14 changes: 6 additions & 8 deletions app/View/Usuarios/dashboard.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,16 @@ $this->Html->script('dashboard', array('inline' => false));
<td><?php echo h($this->request->data['Cargo'][$rid]['asignatura']) ?></td>
<td>
<?php
echo $this->Form->input(sprintf('Registro.%d.entrada', $rid), array(
'error' => false, 'interval' => 5, 'label' => false,
'required' => false, 'separator' => ' : ', 'timeFormat' => 24
))
echo $this->Form->hidden(sprintf('Registro.%d.entrada', $rid));
echo date('H:i', strtotime($this->request->data['Registro'][$rid]['entrada']));
?>
</td>
<td>
<?php
echo $this->Form->input(sprintf('Registro.%d.salida', $rid), array(
'error' => false, 'interval' => 5, 'label' => false,
'required' => false, 'separator' => ' : ', 'timeFormat' => 24
))
echo $this->Form->hidden(sprintf('Registro.%d.salida', $rid));
if (!empty($this->request->data['Registro'][$rid]['salida'])):
echo date('H:i', strtotime($this->request->data['Registro'][$rid]['salida']));
endif;
?>
</td>
</tr>
Expand Down

0 comments on commit 0784196

Please sign in to comment.