2){$user = substr($nombres[1],0,3).substr($nombres[2],0,3);} else {$user = substr($nombres[0],0,3).substr($nombres[1],0,3);} return $cad.$user; } #LIMPIA CARACTERES DE ACENTOS function limpiar_caracteres($s) { $s = str_replace("á","a",$s); $s = str_replace("Á","A",$s); $s = str_replace("é","e",$s); $s = str_replace("É","E",$s); $s = str_replace("í","i",$s); $s = str_replace("Í","I",$s); $s = str_replace("ó","o",$s); $s = str_replace("Ó","O",$s); $s = str_replace("ú","u",$s); $s = str_replace("Ú","U",$s); $s = str_replace("ñ","n",$s); $s = str_replace("Ñ","N",$s); return $s; } #PAGINADOR function paginador($select1,$select2,$numpaginas,$pagina,$agrupar=''){ $row = mysql_fetch_assoc(mysql_query($select2, $_SESSION['conex'])); $total_records = $row['total']; if($numpaginas != 'Todos'){ $records_per_page = $numpaginas; $total_pages = ceil($total_records / $records_per_page); $page = intval($pagina); if($page < 1 || $page > $total_pages) $page = 1; $offset = ($page - 1) * $records_per_page; $limit = $agrupar." LIMIT ".$offset.",".$records_per_page; return $select1.$limit.'@'.$total_pages.'@'.$page; }else{ return $select1.'@1@1'; } } #FUNCION PARA VALIDAR EL FORMATO DEL ARCHIVO. function validar_tipo_formato($num,$archivo){ switch($num){ case 1: $arr = array('pdf'); break; case 2: $arr = array('jpg','png'); break; case 3: $arr = array('pdf','doc','docx'); break; case 4: $arr = array('pdf','doc','docx','xls','xlsx'); break; case 5: $arr = array('pdf','doc','docx','xls','xlsx','rar','zip'); break; } $formato = explode('.',$archivo); $ultimo = count($formato)-1; #recupero el valor del indice del ultimo arreglo. $tipo = $formato[$ultimo]; if(in_array(strtolower($tipo), $arr))return true; else return false; } #FUNCION PARA ARMAR SELECT DINAMICOS function combo($nombre,$id,$num,$extra='',$mult=''){ $txt=''; if(substr($nombre, -2) == '[]')$id_tmp = substr($nombre, 0, -2); else $id_tmp = $nombre; $txt.=''; return $txt; } #FUNCION QUE REGRESA EL PERIODO DE LA OBLIGACION function obtener_periodo($veces, $Periodo){ switch ($veces) { case 1: $Periodo == 1 ? $PeriodoLetra = "Enero" : $a = ''; $Periodo == 2 ? $PeriodoLetra = "Febrero" : $a = ''; $Periodo == 3 ? $PeriodoLetra = "Marzo" : $a = ''; $Periodo == 4 ? $PeriodoLetra = "Abril" : $a = ''; $Periodo == 5 ? $PeriodoLetra = "Mayo" : $a = ''; $Periodo == 6 ? $PeriodoLetra = "Junio" : $a = ''; $Periodo == 7 ? $PeriodoLetra = "Julio" : $a = ''; $Periodo == 8 ? $PeriodoLetra = "Agosto" : $a = ''; $Periodo == 9 ? $PeriodoLetra = "Septiembre" : $a = ''; $Periodo == 10 ? $PeriodoLetra = "Octubre" : $a = ''; $Periodo == 11 ? $PeriodoLetra = "Noviembre" : $a = ''; $Periodo == 12 ? $PeriodoLetra = "Diciembre" : $a = ''; break; case 2: $Periodo == 2 ? $PeriodoLetra = "Enero-Febrero" : $a = ''; $Periodo == 4 ? $PeriodoLetra = "Marzo-Abril" : $a = ''; $Periodo == 6 ? $PeriodoLetra = "Mayo-Junio" : $a = ''; $Periodo == 8 ? $PeriodoLetra = "Julio-Agosto" : $a = ''; $Periodo == 10 ? $PeriodoLetra = "Septiembre-Octubre" : $a = ''; $Periodo == 12 ? $PeriodoLetra = "Noviembre-Diciembre" : $a = ''; break; case 3: $Periodo == 3 ? $PeriodoLetra = "Enero-Marzo" : $a = ''; $Periodo == 6 ? $PeriodoLetra = "Abril-Junio" : $a = ''; $Periodo == 9 ? $PeriodoLetra = "Julio-Septiembre" : $a = ''; $Periodo == 12 ? $PeriodoLetra = "Octubre-Diciembre" : $a = ''; break; case 4: $Periodo == 4 ? $PeriodoLetra = "Enero-Abril" : $a = ''; $Periodo == 8 ? $PeriodoLetra = "Mayo-Agosto" : $a = ''; $Periodo == 12 ? $PeriodoLetra = "Septiembre-Diciembre" : $a = ''; break; case 6: $Periodo == 6 ? $PeriodoLetra = "Enero-Junio" : $a = ''; $Periodo == 12 ? $PeriodoLetra = "Julio-Diciembre" : $a = ''; break; case 12: $Periodo == 12 ? $PeriodoLetra = "Enero-Diciembre" : $a = ''; break; } return $PeriodoLetra; } #FUNCION QUE PERMITE CREAR SELECTS DINAMICOS CON VALORES DE LA BASE DE DATOS. function combo_tag($nombre,$tabla,$campo_asignar,$campo_ver,$opcion_blanco,$valor,$extra=''){ $txt = ''; $sql = mysql_query('select * from '.$tabla, $_SESSION['conex']); if(mysql_num_rows($sql) > 0){ $txt .= ''; }else $txt .= ''; return $txt; } function combo_tag_select($nombre,$consulta,$campo_asignar,$campo_ver,$opcion_blanco,$valor,$extra=''){ $txt = ''; $sql = mysql_query($consulta, $_SESSION['conex']); if(mysql_num_rows($sql) > 0){ $txt .= ''; }else $txt .= ''; mysql_free_result($sql); return $txt; } #FUNCION QUE PERMITE CREAR SELECTS DINAMICOS CON VALORES DE LA BASE DE DATOS. function combo_tag_multiple($nombre,$tabla,$campo_asignar,$campo_ver,$opcion_blanco,$valor,$extra=''){ $txt = ''; if(substr($nombre, -2) == '[]')$id_tmp = substr($nombre, 0, -2); else $id_tmp = $nombre; $sql = mysql_query('select * from '.$tabla, $_SESSION['conex']); if(mysql_num_rows($sql) > 0){ $txt .= ''; }else $txt .= ''; return $txt; } function amoneda($numero, $moneda){ /*$longitud = strlen($numero); $punto = substr($numero, -1,1); $punto2 = substr($numero, 0,1); $separador = "."; if($punto == "."){ $numero = substr($numero, 0,$longitud-1); $longitud = strlen($numero); } if($punto2 == "."){ $numero = "0".$numero; $longitud = strlen($numero); } $num_entero = strpos ($numero, $separador); $centavos = substr ($numero, ($num_entero)); $l_cent = strlen($centavos); if($l_cent == 2){$centavos = $centavos."0";} elseif($l_cent == 3){$centavos = $centavos;} elseif($l_cent > 3){$centavos = substr($centavos, 0,3);} $entero = substr($numero, -$longitud,$longitud-$l_cent); if(!$num_entero){ $num_entero = $longitud; $centavos = ".00"; $entero = substr($numero, -$longitud,$longitud); } $start = floor($num_entero/3); $res = $num_entero-($start*3); if($res == 0){$coma = $start-1; $init = 0;}else{$coma = $start; $init = 3-$res;} $d= $init; $i = 0; $c = $coma; while($i <= $num_entero){ if($d == 3 && $c > 0){$d = 0; $sep = ","; $c = $c-1;}else{$sep = "";} $final .= $sep.$entero[$i]; $i = $i+1; // todos los digitos $d = $d+1; // poner las comas } */ if($moneda == "pesos"){ return "$ ".$numero; } elseif($moneda == "dolares"){ return "USD ".$numero; } elseif($moneda == "euros"){ return $numero." EUR"; } } function cambiar_letra($cadena){ return str_replace("á","Á",str_replace("é","É",str_replace("í","Í",str_replace("ó","Ó",str_replace("ú","Ú",$cadena))))); } function date_fix($formato, $tiempo){ /* $formato es el formato de la funcion date () de php, puedo usar cualquier formato válido por ejemplo: Formato de fecha comun: "d/m/Y H:i:s" formato mysql: "Y-m-d H:i:s" $tiempo es el tiempo que quiero agregar o restar en mi propio formato.. +H:i:s -H:i:s */ list($horasigno,$minutos,$segundos) = explode(":",$tiempo); $horas = abs($horasigno); $cadena = 'now '; if (substr_count($horasigno,"-")==1) $cadena.= "-"; else $cadena.= "+"; if ($horas > 0 ) $cadena.= $horas. " hours "; if ($minutos > 0 ) $cadena.= $minutos. " minutes "; if ($segundos > 0 ) $cadena.= $segundos. " seconds "; return date($formato, strtotime($cadena)); } function validaRFC($rfc){ $okRfc = 1; $rfc = str_replace("-", "", $rfc); #par persona fisica $rfc = trim($rfc); if(strlen($rfc) == 13){ $contL = 0; $contN = 0; for($i=0; $i<4; $i++){ $Letra = substr($rfc, $i, 1); if(!is_numeric($Letra))$contL++; } if($contL == 4){ for($i=4; $i<10; $i++){ $Letra = substr($rfc, $i, 1); if(is_numeric($Letra))$contN++; } if($contN == 6)$okRfc = false; else $okRfc = true; }else $okRfc = true; } #para persona moral elseif(strlen($rfc) == 12){ $contL = 0; $contN = 0; for($i=0; $i<3; $i++){ $Letra = substr($rfc, $i, 1); if(!is_numeric($Letra))$contL++; } if($contL == 3){ for($i=3; $i<9; $i++){ $Letra = substr($rfc, $i, 1); if(is_numeric($Letra))$contN++; } if($contN == 6)$okRfc = false; else $okRfc = true; }else $okRfc = true; } return $okRfc; } function calcular_tiempo_trasnc($hora1,$hora2){ $cadena1 = date("H:i", strtotime($hora1)); $cadena2 = date("H:i", strtotime($hora2)); return date("H:i", strtotime("00:00") + strtotime($cadena2) - strtotime($cadena1)); } function calcular_tiempo_minutos($hora1,$hora2){ $diferencia = calcular_tiempo_trasnc($hora1,$hora2); $separar = explode(':',date("H:i", strtotime($diferencia))); $total_minutos_trasncurridos = ($separar[0] * 60) + $separar[1]; return $total_minutos_trasncurridos; } function sumahoras($hora1,$duracion){ $hora = date("H:i", strtotime($hora1)); $num = explode(":", $duracion); return date('h:i A', strtotime($hora.' + '.$num[0].' hours + '.$num[1].' minutes')); } #Variables que se utilizaran en varios archivos $ruta = "http://localhost/infonet/administrador"; $ruta1 = "http://localhost/infonet/index.php"; ?>