Created
July 19, 2016 14:53
-
-
Save demonio/08cdbda6b3038c2b08ba4f3e3e70a880 to your computer and use it in GitHub Desktop.
FULLCALENDAR en KumbiaPHP... LOL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
*/ | |
class AgendaConsole | |
{ | |
/** | |
*/ | |
public function enviar_correo($params) | |
{ | |
exec('wget https://iiswebusr:eldrazi@teleasistencia-vh.asispa1.es/agenda/enviar_correo/' . $params['id']); | |
#die( '<pre>' . print_r($s, 1) ); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
*/ | |
class AgendaController extends AppController | |
{ | |
public $meses = ['01'=>'Enero', '02'=>'Febrero', '03'=>'Marzo', '04'=>'Abril', '05'=>'Mayo', '06'=>'Junio', '07'=>'Julio', '08'=>'Agosto', '09'=>'Septiembre', '10'=>'Octubre', '11'=>'Noviembre', '12'=>'Diciembre']; | |
public $meses2 = ['01'=>'ENE', '02'=>'FEB', '03'=>'MAR', '04'=>'ABR', '05'=>'MAY', '06'=>'JUN', '07'=>'JUL', '08'=>'AGO', '09'=>'SEP', '10'=>'OCT', '11'=>'NOV', '12'=>'DIC']; | |
public $dias_semana = [1=>'Lunes', 2=>'Martes', 3=>'Miercoles', 4=>'Jueves', 5=>'Viernes', 6=>'Sábado', 7=>'Domingo']; | |
protected function before_filter() | |
{ | |
if ( Input::post('accion') ) $this->{Input::post('accion')}(); | |
} | |
public function index($anyo='', $mes='', $dia='', $id_tp_agenda='') | |
{ | |
$this->anyo = ($anyo) ? $anyo : date('Y'); | |
$this->mes = (strlen($mes) == 1) ? "0$mes" : $mes; | |
$this->dia = (strlen($dia) == 1) ? "0$dia" : $dia; | |
$this->fecha = "$this->anyo$this->mes$this->dia"; | |
$this->registros = (new TpAgenda)->registros($this->fecha); | |
if ($this->dia) | |
{ | |
if ($id_tp_agenda) $this->registro = (new TpAgenda)->registro($id_tp_agenda); | |
if ( ! $this->registro ) $this->registro = (new TpAgenda)->camposVacios(); | |
View::select('dia'); | |
} | |
else if ($this->mes) | |
{ | |
View::select('mes'); | |
} | |
else | |
{ | |
View::select('anyo'); | |
} | |
} | |
public function actualizar() | |
{ | |
(new TpAgenda)->actualizar($this->operador, $_POST, $this->parameters[3]); | |
} | |
public function enviar_correo($id) | |
{ | |
$registro = (new TpAgenda)->registro($id); | |
die( mail($registro->creado_por . '@asispa.org', $registro->nombre_tp_agenda, $registro->notas) ); | |
} | |
public function borrar($id_tp_agenda='') | |
{ | |
if ($id_tp_agenda > 0) | |
$id_tp_agenda = $id_tp_agenda; | |
else if ( ! empty($this->parameters[3]) ) | |
$id_tp_agenda = $this->parameters[3]; | |
(new TpAgenda)->borrar($this->operador, $id_tp_agenda); | |
View::select(''); | |
} | |
public function crear() | |
{ | |
(new TpAgenda)->crear($this->operador, $_POST); | |
} | |
public function listar_etiqueta($etiqueta) | |
{ | |
$this->registros = (new TpAgenda)->listarEtiqueta($etiqueta); | |
$this->etiqueta = $etiqueta; | |
} | |
public function gen_combo($table, $field_id, $field_name, $parent_name='', $parent_id=0) | |
{ | |
$this->options = (new TpAgenda)->genCombo($table, $field_id, $field_name, $parent_name, $parent_id); | |
} | |
public function mostrar($tipo_seleccionado='', $id_seleccionado='') | |
{ | |
$this->options = (new TpAgenda)->genCombo('tr_alarmas', 'id_tr_alarmas', 'nombre_tr_alarmas'); | |
$this->operadores = (new TpOperadores)->distinct('nombre_usuario'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table class="adjusted"> | |
<tr> | |
<td><a class="valign-wrapper" href="/agenda/index/<?=$anyo-1?>"><i class="material-icons small valign">arrow_back</i></a></td> | |
<td><h5><?=$anyo?></h5></td> | |
<td><a class="valign-wrapper" href="/agenda/index/<?=$anyo+1?>"><i class="material-icons small valign">arrow_forward</i></a></td> | |
</tr> | |
</table> | |
<table class="mt10 responsive-table"> | |
<?php for ($m=1; $m<=12; ++$m) : | |
if (strlen($m) == 1) $m = "0$m"; ?> | |
<tr> | |
<td><a href="/agenda/index/<?=$anyo?>/<?=$m?>"><?=$meses2[$m]?></a></td> | |
<?php for ($d=1; $d<=31; ++$d) : | |
if ( ! checkdate($m, $d, $anyo) ) continue; | |
if (strlen($d) == 1) $d = "0$d"; ?> | |
<td> | |
<a href="/agenda/index/<?="$anyo/$m/$d"?>"><?=$d?></a><br> | |
<sub><?=empty($registros['numero'][$m][$d]) ? '' : $registros['numero'][$m][$d]?></sub> | |
</td> | |
<?php endfor; ?> | |
</tr> | |
<?php endfor; ?> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form class="mr40" method="post"> | |
<div class="actions"> | |
<button class="btn-floating green darken-1 end mt10" name="accion" type="submit" value="crear"><i class="material-icons">save</i></button> | |
<button class="btn-floating orange darken-1 end mt10" name="accion" type="submit" value="actualizar"><i class="material-icons">save</i></button> | |
<button class="btn-floating red darken-1 end mt10" name="accion" ondrop="drop(event);" ondragover="allowDrop(event);" type="submit" value="borrar"><i class="material-icons" data-to="/agenda/borrar">delete</i></button> | |
</div> | |
<input name="fecha" type="hidden" value="<?="$anyo$mes$dia"?>" /> | |
<div class="card mt10 pb10 row"> | |
<table class="adjusted"> | |
<tr> | |
<td><a class="valign-wrapper" href="/agenda/index/<?=date( 'Y/m/d', strtotime( '-1 day', strtotime("$anyo$mes$dia") ) )?>"><i class="material-icons small valign">arrow_back</i></a></td> | |
<td> | |
<h5 class="teal-text darken-1"> | |
<?=$dia?> | |
<a href="/agenda/index/<?=$anyo?>/<?=$mes?>"><?=$meses[$mes]?></a> | |
de | |
<a href="/agenda/index/<?=$anyo?>"><?=$anyo?></a> | |
</h5> | |
</td> | |
<td><a class="valign-wrapper" href="/agenda/index/<?=date( 'Y/m/d', strtotime( '+1 day', strtotime("$anyo$mes$dia") ) )?>"><i class="material-icons small valign">arrow_forward</i></a></td> | |
</tr> | |
</table> | |
<div class="col s6 m3 l2 mt10"> | |
<label for="hora">Hora:</label> | |
<select id="hora" name="hora"> | |
<?php $hora = empty($registro->hora) ? date('H') : $registro->hora; | |
for ($h=0; $h<=23; ++$h) : | |
if ( strlen($h) == 1 ) $h = "0$h"; | |
$selected = ($h == $hora) ? ' selected': ''; ?> | |
<option<?=$selected?> value="<?=$h?>"><?=$h?></option> | |
<?php endfor; ?> | |
</select> | |
</div> | |
<div class="col s6 m3 l2 mt10"> | |
<label for="minuto">Minuto:</label> | |
<select id="minuto" name="minuto"> | |
<?php $minuto = empty($registro->minuto) ? date('i') : $registro->minuto; | |
for ($m=0; $m<=59; ++$m) : | |
if ( strlen($m) == 1 ) $m = "0$m"; | |
$selected = ($m == $minuto) ? ' selected': ''; ?> | |
<option<?=$selected?> value="<?=$m?>"><?=$m?></option> | |
<?php endfor; ?> | |
</select> | |
</div> | |
<div class="col s12 m6 l4 mt10"> | |
<label for="nombre_tp_agenda">Breve:</label> | |
<input id="nombre_tp_agenda" name="nombre_tp_agenda" type="text" value="<?=$registro->nombre_tp_agenda?>"> | |
</div> | |
<div class="col s12 m6 l4 mt10"> | |
<label for="etiquetas">Etiquetas:</label> | |
<input id="etiquetas" name="etiquetas" type="text" value="<?=$registro->etiquetas?>"> | |
</div> | |
<div class="col s12 m6 l8 mt10"> | |
<label>Extenso:</label> | |
<textarea class="materialize-textarea" name="notas"><?=$registro->notas?></textarea> | |
</div> | |
<div class="col s12 m5 l4 mt10"> | |
<input<?php if ($registro->avisar_al_correo) echo ' checked'; ?> id="avisar_al_correo" name="avisar_al_correo" type="checkbox"> | |
<label for="avisar_al_correo">Avisar al correo</label><br> | |
<br> | |
<input<?php if ($registro->avisar_al_telefono) echo ' checked'; ?> id="avisar_al_telefono" name="avisar_al_telefono" type="checkbox"> | |
<label for="avisar_al_telefono">Avisar al teléfono</label> | |
</div> | |
</div> | |
</form> | |
<?php foreach ($registros['todo'] as $reg) : | |
if ( strlen($reg->minuto) == 1 ) $reg->minuto = "0$reg->minuto"; ?> | |
<div class="card mr40 mt5 pa10" draggable="true" id="registro_<?=$reg->id_tp_agenda?>" ondragstart="drag(event)"> | |
<h5 class="a blue-text text-darken-1"> | |
<span class="bent"> </span> | |
<sup class="blue-grey-text text-lighten-1"><?=$reg->hora?>:<?=$reg->minuto?></sup> | |
<span><?=($reg->nombre_tp_agenda) ? $reg->nombre_tp_agenda : "Evento $reg->id_tp_agenda"?></span> | |
<a href="/agenda/index/<?="$anyo/$mes/$dia"?>/<?=$reg->id_tp_agenda?>"> | |
<sup><i class="material-icons">edit</i></sup> | |
</a> | |
</h5> | |
<blockquote class="blue-grey-text text-lighten-1 ml20">"<?=$reg->notas?>"</blockquote> | |
<p class="grey lighten-5 mt5 pa10"> | |
<?php if ($reg->etiquetas) : | |
if ( strstr($reg->etiquetas, ',') ) { | |
$etiquetas = explode(',', $reg->etiquetas); | |
foreach ($etiquetas as $etiqueta) : | |
$etiqueta = trim($etiqueta); ?> | |
<a href="/agenda/listar_etiqueta/<?=$etiqueta?>">[<?=$etiqueta?>]</a> | |
<?php endforeach; | |
} else { ?> | |
<a href="/agenda/listar_etiqueta/<?=$reg->etiquetas?>"><?=$reg->etiquetas?></a> | |
<?php } ?> | |
<?php endif; ?> | |
</p> | |
<div class="col s12 m6 l6 mt10"> | |
<input<?=($reg->avisar_al_correo) ? ' checked' : ''; ?> disabled type="checkbox"> | |
<label>Avisar al correo</label> | |
</div> | |
<div class="col s12 m6 l6 mt10"> | |
<input<?=($reg->avisar_al_telefono) ? ' checked' : ''; ?> disabled type="checkbox"> | |
<label>Avisar al teléfono</label> | |
</div> | |
<div class="end"></div> | |
</div> | |
<?php endforeach; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="card mr40 mt5 pa5"> | |
<h5 class="teal-text darken-1">Listando etiqueta: <?=$etiqueta?></h5> | |
</div> | |
<?php foreach ($registros as $reg) : | |
if ( strlen($reg->minuto) == 1 ) $reg->minuto = "0$reg->minuto"; ?> | |
<div class="card mr40 mt5 pa10" draggable="true" id="registro_<?=$reg->id_tp_agenda?>" ondragstart="drag(event)"> | |
<h5 class="a blue-text text-darken-1"> | |
<span class="bent"> </span> | |
<small class="blue-grey-text text-lighten-1 center-align"> | |
<a href="/agenda/index/<?=date( 'Y/m/d', strtotime($reg->fecha) )?>"><?=date( 'd', strtotime($reg->fecha) )?></a>-<a href="/agenda/index/<?=date( 'Y/m', strtotime($reg->fecha) )?>"><?=date( 'm', strtotime($reg->fecha) )?></a>/<a href="/agenda/index/<?=date( 'Y', strtotime($reg->fecha) )?>"><small><?=date( 'Y', strtotime($reg->fecha) )?></small></a><br> | |
<?=$reg->hora?>:<small><?=$reg->minuto?></small> | |
</small> | |
<span><?=($reg->nombre_tp_agenda) ? $reg->nombre_tp_agenda : "Evento $reg->id_tp_agenda"?></span> | |
<a href="/agenda/index/<?=date( 'Y/m/d', strtotime($reg->fecha) )?>/<?=$reg->id_tp_agenda?>"> | |
<sup><i class="material-icons">edit</i></sup> | |
</a> | |
</h5> | |
<blockquote class="blue-grey-text text-lighten-1 ml20">"<?=$reg->notas?>"</blockquote> | |
<p class="grey lighten-5 mt5 pa10"> | |
<?php if ($reg->etiquetas) : | |
if ( strstr($reg->etiquetas, ',') ) { | |
$etiquetas = explode(',', $reg->etiquetas); | |
foreach ($etiquetas as $etiqueta) : | |
$etiqueta = trim($etiqueta); ?> | |
<a href="/agenda/listar_etiqueta/<?=$etiqueta?>">[<?=$etiqueta?>]</a> | |
<?php endforeach; | |
} else { ?> | |
<a href="/agenda/listar_etiqueta/<?=$reg->etiquetas?>"><?=$reg->etiquetas?></a> | |
<?php } ?> | |
<?php endif; ?> | |
</p> | |
<div class="col s12 m6 l6 mt10"> | |
<input<?=($reg->avisar_al_correo) ? ' checked' : ''; ?> disabled type="checkbox"> | |
<label>Avisar al correo</label> | |
</div> | |
<div class="col s12 m6 l6 mt10"> | |
<input<?=($reg->avisar_al_telefono) ? ' checked' : ''; ?> disabled type="checkbox"> | |
<label>Avisar al teléfono</label> | |
</div> | |
<div class="end"></div> | |
</div> | |
<?php endforeach; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<table class="adjusted"> | |
<tr> | |
<td><a class="valign-wrapper" href="/agenda/index/<?=date( 'Y/m', strtotime( '-1 month', strtotime($fecha . '01') ) )?>"><i class="material-icons small valign">arrow_back</i></a></td> | |
<td><h5><?=$meses[$mes]?> de <a href="/agenda/index/<?=$anyo?>"><?=$anyo?></a></h5></td> | |
<td><a class="valign-wrapper" href="/agenda/index/<?=date( 'Y/m', strtotime( '+1 month', strtotime($fecha . '01') ) )?>"><i class="material-icons small valign">arrow_forward</i></a></td> | |
</tr> | |
</table> | |
<table class="mt10 responsive-table"> | |
<tr> | |
<?php for ($ds=1; $ds<=7; ++$ds) : ?> | |
<td><?=$dias_semana[$ds]?></td> | |
<?php endfor; ?> | |
</tr> | |
<?php | |
$ds = 1; | |
for ($d=1; $d<=31; ++$d) : | |
if ( strlen($d) == 1 ) $d = "0$d"; | |
if ( ! checkdate($mes, $d, $anyo) ) continue; | |
if ($ds == 1) echo "<tr>"; | |
if ( date( 'N', strtotime("$anyo-$mes-$d") ) == $ds) | |
{ | |
?> | |
<td> | |
<a href="/agenda/index/<?="$anyo/$mes/$d"?>"><?=$d?></a> | |
<sup><?=empty($registros['numero'][$mes][$d]) ? '' : $registros['numero'][$mes][$d]?></sup><br> | |
<?php if ( ! empty($registros['etiquetas'][$mes][$d]) ) : | |
foreach ($registros['etiquetas'][$mes][$d] as $k=>$v) : ?> | |
<br><a href="/agenda/listar_etiqueta/<?=urlencode($k)?>"><sup class="chip grey lighten-5"><?=$k?></sup></a> | |
<?php endforeach; | |
endif; ?> | |
</td> | |
<?php | |
} | |
else | |
{ | |
echo "<td> </td>"; | |
$d = 0; | |
} | |
if ($ds == 7) echo "</tr>"; | |
++$ds; | |
if ($ds == 8) $ds = 1; | |
endfor; ?> | |
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
*/ | |
class TpAgenda extends ActRecord | |
{ | |
prtected static $pk = 'id_tp_agenda'; | |
public function actualizar($operador, $post, $id_tp_agenda) | |
{ | |
$fecha = $post['fecha']; | |
$hora = $post['hora']; | |
$minuto = $post['minuto']; | |
$nombre_tp_agenda = $post['nombre_tp_agenda']; | |
$notas = $post['notas']; | |
$etiquetas = $post['etiquetas']; | |
$avisar_al_correo = empty($post['avisar_al_correo']) ? 0 : 1; | |
$avisar_al_telefono = empty($post['avisar_al_telefono']) ? 0 : 1; | |
$sql = "UPDATE Aquilesv2.dbo.tp_agenda SET nombre_tp_agenda='$nombre_tp_agenda', notas='$notas', fecha='$fecha', hora='$hora', minuto='$minuto', etiquetas='$etiquetas', avisar_al_correo='$avisar_al_correo', avisar_al_telefono='$avisar_al_telefono', creado=GETDATE(), creado_por='$operador->nombre_usuario' WHERE id_tp_agenda=" . (int)$id_tp_agenda; | |
#_::d($sql); | |
$this->sql($sql); | |
if ($avisar_al_correo) | |
{ | |
$ddmmyyyy = date( 'd/m/Y', strtotime($fecha) ); | |
$task = "schtasks /create /tn \"TELEMATRIX_$id\" /tr \"php C:/inetpub/wwwroot/core/console/kumbia.php agenda enviar_correo --id=$id\" /sc ONCE /st $hora:$minuto:00 /sd $ddmmyyyy"; | |
#_::d($task); | |
exec($task); | |
} | |
} | |
public function borrar($operador, $id_tp_agenda) | |
{ | |
$sql = "UPDATE Aquilesv2.dbo.tp_agenda SET eliminado=GETDATE(), eliminado_por='$operador->nombre_usuario' WHERE id_tp_agenda=" . (int)$id_tp_agenda; | |
$this->sql($sql); | |
} | |
public function crear($operador, $post) | |
{ | |
$fecha = $post['fecha']; | |
$hora = $post['hora']; | |
$minuto = $post['minuto']; | |
$nombre_tp_agenda = $post['nombre_tp_agenda']; | |
$notas = $post['notas']; | |
$etiquetas = $post['etiquetas']; | |
$avisar_al_correo = empty($post['avisar_al_correo']) ? 0 : 1; | |
$avisar_al_telefono = empty($post['avisar_al_telefono']) ? 0 : 1; | |
$sql = "INSERT INTO Aquilesv2.dbo.tp_agenda | |
(nombre_tp_agenda, notas, fecha, hora, minuto, etiquetas, avisar_al_correo, avisar_al_telefono, creado, creado_por) VALUES | |
('$nombre_tp_agenda', '$notas', '$fecha', '$hora', '$minuto', '$etiquetas', '$avisar_al_correo', '$avisar_al_telefono', GETDATE(), '$operador->nombre_usuario')"; | |
$this->sql($sql); | |
$id = $this->lastInsertId(); | |
if ($avisar_al_correo) | |
{ | |
$ddmmyyyy = date( 'd/m/Y', strtotime($fecha) ); | |
$task = "schtasks /create /tn \"TELEMATRIX_$id\" /tr \"php C:/inetpub/wwwroot/core/console/kumbia.php agenda enviar_correo --id=$id\" /sc ONCE /st $hora:$minuto:00 /sd $ddmmyyyy"; | |
#_::d($task); | |
exec($task); | |
} | |
} | |
public function listarEtiqueta($etiqueta) | |
{ | |
$sql = "SELECT * FROM tp_agenda WHERE eliminado IS NULL AND etiquetas LIKE '%$etiqueta%'"; | |
return $this->allBySql($sql); | |
} | |
public function registro($id) | |
{ | |
$sql = "SELECT * FROM tp_agenda WHERE eliminado IS NULL AND id_tp_agenda=?"; | |
return $this->firstBySql($sql, $id); | |
} | |
public function registros($fecha) | |
{ | |
if ( strlen($fecha) == 6 ) $fecha = substr_replace($fecha, '-', 4, 0); | |
else if ( strlen($fecha) == 8 ) | |
{ | |
$fecha = substr_replace($fecha, '-', 4, 0); | |
$fecha = substr_replace($fecha, '-', 7, 0); | |
} | |
$sql = "SELECT * FROM tp_agenda WHERE eliminado IS NULL AND fecha LIKE '$fecha%'"; | |
#_::d($sql); | |
$registros = $this->allBySql($sql); | |
foreach ($registros as $reg) | |
{ | |
$d = date( 'd', strtotime($reg->fecha) ); | |
$m = date( 'm', strtotime($reg->fecha) ); | |
$a[$m][$d] = empty($a[$m][$d]) ? 1 : ++$a[$m][$d]; | |
if ($reg->etiquetas) | |
{ | |
$etiquetas = explode(',', $reg->etiquetas); | |
foreach ($etiquetas as $eti) | |
{ | |
$eti = trim($eti); | |
$c[$m][$d][$eti] = ''; | |
} | |
} | |
} | |
$b['todo'] = $registros; | |
$b['numero'] = $a; | |
$b['etiquetas'] = $c; | |
#_::d($b); | |
return $b; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment