<?php
class Botones {
const GENERAL = "btn-default";
const PRIMARY = "btn-primary";
const SUCCESS = "btn-success";
const INFO = "btn-info";
const WARNING = "btn-warning";
const DANGER = "btn-danger";
const ENLACE = "btn-link";
const NARANJA = "bg-orange ";
const OLIVA = "bg-olive ";
const MARON = "bg-maroon ";
const PURPURA = "bg-purple ";
const NAVAL = "bg-navy ";
const VERDE = "verde-reciclaje ";
static
function personalizado($operacion, $botonFN = null, $botonTEXTO = null, $botonICONO = null, $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
' '.$botonCLASES.' ',
' '.$botonICONO.' '
);
return $btn;
}
static
function enlace($operacion, $botonFN = null, $botonTEXTO = '', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::ENLACE.' '.$botonCLASES.'',
'fa fa-link'
);
return $btn;
}
static
function recargar($operacion, $botonFN = null, $botonTEXTO = 'Recargar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::PRIMARY.' '.$botonCLASES.'',
'fa fa-refresh'
);
return $btn;
}
static
function tabla($operacion, $botonFN = null, $botonTEXTO = 'Listado', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(0).' '.$botonCLASES.'',
'fa fa-table'
);
return $btn;
}
static
function ver($operacion, $botonFN = null, $botonTEXTO = 'Ver', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(3).' '.$botonCLASES.'',
'fa fa-eye'
);
return $btn;
}
static
function nuevo($operacion, $botonFN = null, $botonTEXTO = 'Nuevo', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(1).' '.$botonCLASES.'',
'fa fa-plus'
);
return $btn;
}
static
function editar($operacion, $botonFN = null, $botonTEXTO = "Editar", $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(4).' '.$botonCLASES.'',
'fa fa-edit'
);
return $btn;
}
static
function eliminar($operacion, $botonFN = null, $botonTEXTO = 'Eliminar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(5).' '.$botonCLASES.'',
'fa fa-trash'
);
return $btn;
}
static
function desactivar($operacion, $botonFN = null, $botonTEXTO = 'Desactivar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(5).' '.$botonCLASES.'',
'fa fa-ban'
);
return $btn;
}
static
function reactivar($operacion, $botonFN = null, $botonTEXTO = 'Re-activar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::VERDE.' '.$botonCLASES.'',
'fa fa-recycle'
);
return $btn;
}
static
function aprobar($operacion, $botonFN = null, $botonTEXTO = 'Aprobar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::VERDE.' '.$botonCLASES.'',
'fa fa-check'
);
return $btn;
}
static
function negociacion($operacion, $botonFN = null, $botonTEXTO = 'Negociar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::PRIMARY.' '.$botonCLASES.'',
'fa fa-binoculars'
);
return $btn;
}
static
function estados($operacion, $botonFN = null, $botonTEXTO = 'Re-activar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::VERDE.' '.$botonCLASES.'',
'fa fa-retweet'
);
return $btn;
}
static
function guardar($operacion, $botonFN = null, $botonTEXTO = 'Guardar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(2).' '.$botonCLASES.'',
'fa fa-save', 'submit'
);
return $btn;
}
static
function guardarYnuevo($operacion, $botonFN = null, $botonTEXTO = 'Guardar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(2).' '.$botonCLASES.'',
'fa fa-save'
);
return $btn;
}
static
function aceptar($operacion, $botonFN = null, $botonTEXTO = 'Aceptar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(2).' '.$botonCLASES.'',
'fa fa-check', 'submit'
);
return $btn;
}
static
function cancelar($operacion, $botonFN = null, $botonTEXTO = 'Cancelar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::PURPURA.' '.$botonCLASES.'',
'fa fa-ban'
);
return $btn;
}
static
function cerrar($operacion, $botonFN = null, $botonTEXTO = 'Cerrar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::PURPURA.' '.$botonCLASES.'',
'fa fa-times'
);
return $btn;
}
static
function resetear($operacion, $botonFN = null, $botonTEXTO = 'Reset', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::NARANJA.' '.$botonCLASES.'',
'fa fa-undo', 'reset'
);
return $btn;
}
static
function descargar($operacion, $botonFN = null, $botonTEXTO = 'Descargar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(5).' '.$botonCLASES.'',
'fa fa-cloud-download', 'download'
);
return $btn;
}
static
function cargar($operacion, $botonFN = null, $botonTEXTO = 'Cargar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(2).' '.$botonCLASES.'',
'fa fa-cloud-upload'
);
return $btn;
}
static
function correo($operacion, $botonFN = null, $botonTEXTO = 'Notificar', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(7).' '.$botonCLASES.'',
'fa fa-envelope'
);
return $btn;
}
static
function marcarComo($operacion, $botonFN = null, $botonTEXTO = null, $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::INFO.' '.$botonCLASES.'',
'fa fa-check-circle-o'
);
return $btn;
}
static
function seleccionarTodos($operacion, $botonFN = null, $botonTEXTO = null, $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::INFO.' '.$botonCLASES.'',
'fa fa-check-square-o'
);
return $btn;
}
static
function PDF($operacion, $botonFN = null, $botonTEXTO = null, $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, 'PDF', 'PDF',
''.self::clase(7).' '.$botonCLASES.'',
'fa fa-file-pdf-o'
);
return $btn;
}
static
function XLS($operacion, $botonFN = null, $botonTEXTO = null, $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, 'XLS', 'XLS',
''.self::clase(7).' '.$botonCLASES.'',
'fa fa-file-excel-o'
);
return $btn;
}
static
function DOC($operacion, $botonFN = null, $botonTEXTO = null, $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, 'DOCx', 'DOCx',
''.self::clase(9).' '.$botonCLASES.'',
'fa fa-file-word-o'
);
return $btn;
}
static
function TXT($operacion, $botonFN = null, $botonTEXTO = null, $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, 'TXT', 'TXT',
''.self::clase(9).' '.$botonCLASES.'',
'fa fa-file-text-o'
);
return $btn;
}
static
function CSV($operacion, $botonFN = null, $botonTEXTO = null, $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, 'CSV', 'CSV',
''.self::clase(9).' '.$botonCLASES.'',
'fa fa-file-csv-o'
);
return $btn;
}
static
function vistaPrevia($operacion, $botonFN = null, $botonTEXTO = 'Vista Previa', $botonCLASES = null){
$btn = self::boton(
$operacion, $botonFN, $botonTEXTO, $botonTEXTO,
''.self::clase(2).' '.$botonCLASES.'',
'fa fa-eye','submit'
);
return $btn;
}
static function clase($id){
$clase = array(
'btn-default',
'btn-primary',
'btn-success',
'btn-info',
'btn-warning',
'btn-danger',
'btn-link',
'bg-purple',
'bg-navy ' ,
'bg-orange ' ,
'bg-olive ' ,
'bg-maroon ' ,
'bg-purple ' ,
'bg-navy ' ,
'bg-orange'
);
return $clase[$id];
}
static $sinTexto = false;
static function sinTexto($noMostrar){
self::$sinTexto = $noMostrar;
}
static function boton($operacionCODIGO, $botonFN, $botonTITLE, $botonTXT, $botonCLASES, $botonICONO, $botonTIPO = 'button' ){
if( !is_null($operacionCODIGO) or !empty($operacionCODIGO) ){
$Operacion = Operaciones::datosPorCodigo($operacionCODIGO);
if(!is_null($Operacion)){
if( Cliente::tienePermiso($operacionCODIGO) ){
if(is_null($botonFN)){
try{
$botonFN = 'cargarVista("'.
''.$Operacion->componenteCARPETA.'","'.$Operacion->controladorCLASE.'","'.$Operacion->operacionFUNCION.'", "",'.
'"'.$Operacion->operacionTITULO.'","TAB-'.$Operacion->operacionID.'" '.
');';
} catch(Exception $e){echo 'Excepción capturada: ', $e->getMessage(), "\n";}
}
}else{
return "NO TIENE PERMISO PARA ESTA OPERACION";
}
}else{
$botonTITLE .= " [No existe la operación] ";
}
}
$botonID = uniqid();
$codigoBOTON = '<button type="'.$botonTIPO.'" '.
'id="btn-'.$botonID.'" '.
'class="btn btn-sm '.$botonCLASES.' titulo-flotante" '.
'title="'.$botonTITLE.'" '.'>'.
'<i class="'.$botonICONO.'"></i> '.(self::$sinTexto ? '' : $botonTXT ).''.
'</button>';
if( $botonTIPO == 'button' ){
$codigoBOTON .= '<script>'.
'$( "#btn-'.$botonID.'" ).click(function() { '.$botonFN.' });'.
'</script>';
}
return $codigoBOTON;
}
}