Ver Mensaje Individual
  #5 (permalink)  
Antiguo 28/02/2013, 13:34
ambichol
 
Fecha de Ingreso: febrero-2013
Ubicación: Lima
Mensajes: 301
Antigüedad: 11 años, 2 meses
Puntos: 5
Respuesta: mostrar año y mes actual en un combo

Código PHP:
Ver original
  1. <?php
  2.  error_reporting(E_ALL|E_STRICT);
  3.  ini_set('display_startup_errors',0);
  4.  ini_set('display_errors',0);
  5.  
  6. $mes  = $_REQUEST['mes'];
  7. $anho  = $_REQUEST['anho'];
  8.  
  9. if ($mes==''){
  10.  
  11. $ano = date("Y");
  12. $mes = date("m");
  13.  
  14. }
  15.  
  16. ?>
  17.     <script>
  18.     window.location = 'index.php';
  19.     </script>
  20. <?
  21.    }
  22.  
  23. ?> 
  24.  
  25. <?php
  26.  
  27.  include ("conexion.php");
  28.  $conexion= conectarmensajeria();
  29.  $direccion = $_SESSION['dir'];
  30.  $usuario = $_SESSION['user'];
  31.  
  32. $fecha = mssql_query("select distinct month(getdate()) as MES, year(getdate()) as ANHO from CT_DETIND",$conexion);
  33. $fecha2 = mssql_query("select distinct month(getdate())-1 as MES from CT_DETIND",$conexion);
  34. $combo1 = mssql_query("select distinct ANHO from CT_FECHAS where anho = year(getdate())",$conexion);//modificacion
  35. $combo2 = mssql_query("select distinct MES from CT_FECHAS",$conexion);
  36. $combo3 = mssql_query("select cod_are,upper(des_are),ORDEN_AREA from ct_detare order by ORDEN_AREA asc",$conexion);
  37.  
  38. $sql  = mssql_query("select distinct t01.cod_mae,t01.des_ind,t01.cod_ind,t01.cod_are,t01.fecha,
  39. t01.cod_res,obj,meta,
  40. (case when t01.fecha = '201306' then cast(valor as float) else 0 end) as [Valor_Mes],
  41. des_are,des_res,des_unim,COMENTADO
  42. from CT_DETIND t01 inner join CT_DETARE t02
  43. on t01.cod_are = t02.cod_are inner join CT_DETRES t03
  44. on t01.cod_res = t03.cod_res inner join CT_MAEIND t04
  45. on t01.cod_ind = t04.cod_ind inner join CT_COMENTARIOS t05
  46. on t01.cod_com = t05.cod_com
  47. where des_res like '%' AND t01.fecha = '201306'
  48. order by 10 asc",$conexion);
  49.  
  50. while ($row2 = mssql_fetch_row($fecha)){
  51.  
  52. if($row2[0]<10){
  53.  
  54. $fecha_anterior = "2013"."0".$row2[0]-1;
  55. $fecha_actual = "2013"."0".$row2[0];
  56. }else{
  57.  
  58. $fecha_anterior = "2013".$row2[0]-1;
  59. $fecha_actual = "2013".$row2[0];
  60. }
  61. }
  62.  
  63. $objetivo_anual = '201301';
  64. $area = '%';
  65. $mci = '%';
  66.  
  67. $mes_ant=$mes-1;
  68.  
  69. $stmt1=mssql_init("lista_t_f_anterior", $conexion);
  70. mssql_bind($stmt1,"@fecha_anterior",$fecha_anterior,SQLVARCHAR,FALSE);
  71. $query1 = mssql_execute($stmt1);
  72.  
  73. $stmt1=mssql_init("lista_t_f_actual", $conexion);
  74. mssql_bind($stmt1,"@fecha_actual",$fecha_actual,SQLVARCHAR,FALSE);      
  75. $query2 = mssql_execute($stmt1);
  76.  
  77. $stmt1=mssql_init("lista_t_f_actual", $conexion);
  78. mssql_bind($stmt1,"@fecha_actual",$fecha_actual,SQLVARCHAR,FALSE);      
  79. $query3 = mssql_execute($stmt1);
  80.  
  81. $stmt1=mssql_init("lista_t_f_anterior_area", $conexion);
  82. mssql_bind($stmt1,"@fecha_anterior",$fecha_anterior,SQLVARCHAR,FALSE);
  83. mssql_bind($stmt1,"@area",$area,SQLVARCHAR,FALSE);
  84. mssql_bind($stmt1,"@mci",$mci,SQLVARCHAR,FALSE);
  85. $query4 = mssql_execute($stmt1);
  86.  
  87. $stmt1=mssql_init("lista_t_f_actual_area", $conexion);
  88. mssql_bind($stmt1,"@fecha_actual",$fecha_actual,SQLVARCHAR,FALSE);    
  89. mssql_bind($stmt1,"@area",$area,SQLVARCHAR,FALSE);  
  90. mssql_bind($stmt1,"@mci",$mci,SQLVARCHAR,FALSE);
  91. $query5 = mssql_execute($stmt1);
  92.  
  93. $stmt1=mssql_init("lista_t_f_actual_area", $conexion);
  94. mssql_bind($stmt1,"@fecha_actual",$fecha_actual,SQLVARCHAR,FALSE);      
  95. mssql_bind($stmt1,"@area",$area,SQLVARCHAR,FALSE);
  96. mssql_bind($stmt1,"@mci",$mci,SQLVARCHAR,FALSE);
  97. $query6 = mssql_execute($stmt1);
  98.  
  99. echo $colores;
  100. ?>
  101.  
  102. <?php
  103.  
  104. if(isset($_REQUEST['button']))
  105. {
  106.  
  107. $anho = $_REQUEST['anho'];
  108. $fecha1 = $_REQUEST['mes'];
  109. $mci='::SELECCIONE::';
  110.  
  111. if($fecha1 <= 01){
  112. $fecha2 = 12;
  113. $anho2 = $anho-1;
  114. $fecha_anterior = $anho2.$fecha2;
  115. $fecha_actual = $anho.$fecha1;
  116. }else{
  117. $fecha_actual = $anho.$fecha1;
  118. $fecha_ant = $fecha1 - 1;
  119. if($fecha_ant<10){
  120. $fecha_anterior = $anho."0".$fecha_ant;
  121. }else{
  122. $fecha_anterior = $anho.$fecha_ant;
  123. }
  124. }
  125.  
  126. $objetivo_anual = $anho.'01';
  127.  
  128. $area = $_REQUEST['area'];
  129. $mci = $_REQUEST['mci'];
  130.  
  131. $stmt1=mssql_init("lista_t_f_anterior", $conexion);
  132. mssql_bind($stmt1,"@fecha_anterior",$fecha_anterior,SQLVARCHAR,FALSE);
  133. $query1 = mssql_execute($stmt1);
  134.  
  135. $stmt1=mssql_init("lista_t_f_actual", $conexion);
  136. mssql_bind($stmt1,"@fecha_actual",$fecha_actual,SQLVARCHAR,FALSE);      
  137. $query2 = mssql_execute($stmt1);
  138.  
  139. $stmt1=mssql_init("lista_t_f_actual", $conexion);
  140. mssql_bind($stmt1,"@fecha_actual",$fecha_actual,SQLVARCHAR,FALSE);      
  141. $query3 = mssql_execute($stmt1);
  142.  
  143. $stmt1=mssql_init("lista_t_f_anterior_area", $conexion);
  144. mssql_bind($stmt1,"@fecha_anterior",$fecha_anterior,SQLVARCHAR,FALSE);
  145. mssql_bind($stmt1,"@area",$area,SQLVARCHAR,FALSE);
  146. mssql_bind($stmt1,"@mci",$mci,SQLVARCHAR,FALSE);
  147. $query4 = mssql_execute($stmt1);
  148.  
  149. $stmt1=mssql_init("lista_t_f_actual_area", $conexion);
  150. mssql_bind($stmt1,"@fecha_actual",$fecha_actual,SQLVARCHAR,FALSE);    
  151. mssql_bind($stmt1,"@area",$area,SQLVARCHAR,FALSE);  
  152. mssql_bind($stmt1,"@mci",$mci,SQLVARCHAR,FALSE);
  153. $query5 = mssql_execute($stmt1);
  154.  
  155. $stmt1=mssql_init("lista_t_f_actual_area", $conexion);
  156. mssql_bind($stmt1,"@fecha_actual",$fecha_actual,SQLVARCHAR,FALSE);      
  157. mssql_bind($stmt1,"@area",$area,SQLVARCHAR,FALSE);
  158. mssql_bind($stmt1,"@mci",$mci,SQLVARCHAR,FALSE);
  159. $query6 = mssql_execute($stmt1);
  160.  
  161. }
  162.  
  163. ?>