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
<? | |
require_once './lib/PHPExcel/Classes/PHPExcel.php'; | |
$fileName = './templates/excel/plantilla.xlsx'; | |
$objPHPExcel = PHPExcel_IOFactory::createReader('Excel2007'); | |
$objPHPExcel = $objPHPExcel->load($fileName); | |
$active_sheet = $objPHPExcel->setActiveSheetIndex(0); | |
$highestRow = $worksheet->getHighestRow(); |
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
function distancia_gps ($punto1, $punto2) { | |
$metros = 6371000; //Circunferencia de la tierra | |
$coo1 = explode(',', $punto1); | |
$coo2 = explode(',', $punto2); | |
$distancia = $metros * acos(sin(deg2rad($coo1[0])) * sin(deg2rad($coo2[0])) + cos(deg2rad($coo1[0])) * cos(deg2rad($coo2[0])) * cos(deg2rad($coo1[1]) - deg2rad($coo2[1]))); | |
return ((is_numeric($distancia)) ? $distancia : 0); | |
} |
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
$hora_ini = "08:15"; | |
$hora_fin = "09:30"; | |
$fecha = date("Y-m-d"); | |
$ts_fin = strtotime($fecha." ".$hora_fin); | |
$ts_ini = strtotime($fecha." ".$hora_ini); | |
echo "TS_INI: ".$ts_ini."<br>"; | |
echo "TS_FIN: ".$ts_fin."<br>"; | |
echo "DIFF: ".($ts_fin-$ts_ini)/3600; |
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
CREATE TEMPORARY TABLE tabla_temporal AS | |
SELECT id | |
FROM tabla_original | |
GROUP BY campo_unico_1, campo_unico_2; | |
DELETE FROM tabla_original | |
WHERE id NOT IN(SELECT id FROM tabla_temporal); |
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
function url_get_contents ($Url) { | |
if (!function_exists('curl_init')){ | |
die('CURL is not installed!'); | |
} | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $Url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$output = curl_exec($ch); | |
curl_close($ch); | |
return $output; |
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
var start = $("#form_expedientes input[name='fecha']").datepicker('getDate'); | |
var end = $("#form_expedientes input[name='fecha_entrega']").datepicker('getDate'); | |
if(!start || !end) | |
return; | |
var days = 0; | |
if (start && end) { | |
days = Math.floor((end.getTime() - start.getTime()) / 86400000); // ms per day | |
} |
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
// Obtener registros de la tabla con fecha superior a hace tres meses | |
SELECT * FROM tabla WHERE fecha >= DATE_ADD(NOW(),INTERVAL -3 MONTH) | |
// De otro modo: | |
SELECT * FROM tabla WHERE fecha >= (NOW() + INTERVAL -3 MONTH) |
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 | |
// Obtener el array | |
$myarray = glob("*.*"); | |
// Ordenar por fecha ascendente | |
usort($myarray, create_function('$a,$b', 'return filemtime($a) - filemtime($b);')); |
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
$.validator.addMethod('require-one', function (value) { | |
return $('.require-one:checked').size() > 0; }, 'Please check at least one box.'); | |
var checkboxes = $('.require-one'); | |
var checkbox_names = $.map(checkboxes, function(e,i) { return $(e).attr("name")}).join(" "); | |
$("#itemForm").validate({ | |
groups: { checks: checkbox_names }, | |
errorPlacement: function(error, element) { | |
if (element.attr("type") == "checkbox") |
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
$(this).find("input[type='checkbox']").prop("checked",function( i, val ) { return !val; }); |
NewerOlder