sustentabilidad.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <?php
  2. require_once 'shared/conexionBD.php';
  3. mysqli_query($conexion, "SET NAMES utf8");
  4. $hoy = date("d/m/y");
  5. $mes = date("m");
  6. $totalElec = 0;
  7. $arrMeses = array("01" => "Enero",
  8. "02" => "Febrero",
  9. "03" => "Marzo",
  10. "04" => "Abril",
  11. "05" => "Mayo",
  12. "06" => "Junio",
  13. "07" => "Julio",
  14. "08" => "Agosto",
  15. "09" => "Septiembre",
  16. "10" => "Octubre",
  17. "11" => "Noviembre",
  18. "12" => "Diciembre");
  19. // Obtenemos los datos de la gráfica de Electricidad hasta el mes anterior al actual
  20. /*$qryGraficas = "SELECT DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m') AS FECHA, SUM(VADI) AHORRO
  21. FROM ITT_ASW_SUDE
  22. WHERE TIPO='E'
  23. AND DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m') < DATE_FORMAT(SYSDATE(), '%Y-%m')
  24. GROUP BY TIPO, DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m')
  25. ORDER BY DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m') DESC
  26. LIMIT 12";
  27. $qryGraf = mysqli_query($conexion, $qryGraficas);
  28. $datosElec = array();
  29. while ($column = mysqli_fetch_assoc($qryGraf)) {
  30. $datosElec[] = $column;
  31. $totalElec = $totalElec + $column['AHORRO'];
  32. }*/
  33. $qryTest = "SELECT * FROM ITT_ASW_SUDE WHERE TIPO = 'E' ORDER BY IDSU DESC";
  34. $gstTest = mysqli_query($conexion, $qryTest);
  35. $arrTest = array();
  36. while ($test = mysqli_fetch_assoc($gstTest)) {
  37. $vadi = array_key_exists($test['IDSU'], $arrTest) ? floatval($arrTest[$test['IDSU']]['AHORRO']) : 0;
  38. $arrTest[$test['IDSU']] = [
  39. "FECHA" => $test['IDSU'],
  40. "AHORRO" => $vadi + floatval($test['VADI']),
  41. ];
  42. }
  43. $arrElec = array();
  44. $cont = 0;
  45. foreach($arrTest as $key=>$val){
  46. $arrDate = explode("-", $key);
  47. $currentMonth = date("m");
  48. $currentYear = date("Y");
  49. if($currentYear == $arrDate[0] && $currentMonth == $arrDate[1]) continue;
  50. if($currentYear == $arrDate[0] && intval($currentMonth) < intval($arrDate[1])) continue;
  51. if($cont < 12){
  52. $arrElec[] = $val;
  53. $totalElec = $totalElec + floatval($val['AHORRO']);
  54. }
  55. $cont++;
  56. }
  57. $datosElec = array_reverse($arrElec);
  58. $actualMonth = date("Y-m");
  59. $currentDay = date("d");
  60. $currentDay = intval($currentDay);
  61. $actualKW = 0;
  62. $qryActMonth = "SELECT * FROM ITT_ASW_SUDE WHERE TIPO = 'E' AND IDSU = '$actualMonth' ORDER BY DIAN ASC";
  63. $gstActMonth = mysqli_query($conexion, $qryActMonth);
  64. while ($actMonth = mysqli_fetch_assoc($gstActMonth)) {
  65. $dia = intval($actMonth['DIAN']);
  66. if($dia <= $currentDay){
  67. $actualKW += floatval($actMonth['VADI']);
  68. }
  69. }
  70. $totalElec = $totalElec + $actualKW;
  71. $datosElec[] = ["FECHA" => $actualMonth, "AHORRO" => $actualKW ];
  72. // Obtenemos los datos de la gráfica de Electricidad del mes actual hasta el día actual
  73. /*$qryDiaElec = "SELECT DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m') AS FECHA, SUM(VADI) AHORRO
  74. FROM ITT_ASW_SUDE
  75. WHERE TIPO='E' AND DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m') = DATE_FORMAT(SYSDATE(), '%Y-%m')
  76. AND DIAN <= DATE_FORMAT(SYSDATE(), '%d')
  77. GROUP BY TIPO, DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m')";
  78. $qryGrafElD = mysqli_query($conexion, $qryDiaElec);
  79. $datosElecD = array();
  80. while ($column = mysqli_fetch_assoc($qryGrafElD)) {
  81. $datosElec[] = $column;
  82. $totalElec = $totalElec + $column['AHORRO'];
  83. $ahorroKW=$column['AHORRO'];
  84. }*/
  85. $datosElecJson = json_encode($datosElec);
  86. // <--------------Operación para tala de árboles y emisiones de CO2------------------------->
  87. $milesEle = $totalElec/1000;
  88. $co2 = $milesEle*458;
  89. $arboles = $milesEle*19;
  90. $emisiones = $ahorroKW*0.458;
  91. // Obtenemos los datos de la gráfica de Agua hasta el mes anterior al actual
  92. $qryGraficaA = "SELECT DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m') AS FECHA, SUM(VADI) AHORRO
  93. FROM ITT_ASW_SUDE
  94. WHERE TIPO='A'
  95. AND DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m') < DATE_FORMAT(SYSDATE(), '%Y-%m')
  96. GROUP BY TIPO, DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m')
  97. ORDER BY DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m') DESC
  98. LIMIT 12";
  99. $qryGrafA = mysqli_query($conexion, $qryGraficaA);
  100. $datosAgua = array();
  101. $totalAgua = 0;
  102. while ($column = mysqli_fetch_assoc($qryGrafA)) {
  103. $datosAgua[] = $column;
  104. $totalAgua = $totalAgua + $column['AHORRO'];
  105. }
  106. $datosAgua = array_reverse($datosAgua);
  107. // Obtenemos los datos de la gráfica de Agua del mes actual hasta el día actual
  108. $qryDiaAguaD = "SELECT DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m') AS FECHA, SUM(VADI) AHORRO
  109. FROM ITT_ASW_SUDE
  110. WHERE TIPO='A' AND DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m') = DATE_FORMAT(SYSDATE(), '%Y-%m')
  111. AND DIAN <= DATE_FORMAT(SYSDATE(), '%d')
  112. GROUP BY TIPO, DATE_FORMAT(STR_TO_DATE(IDSU,'%Y-%m'),'%Y-%m')";
  113. $qryGrafAgD = mysqli_query($conexion, $qryDiaAguaD);
  114. $datosAguaD = array();
  115. while ($column = mysqli_fetch_assoc($qryGrafAgD)) {
  116. $datosAgua[] = $column;
  117. $totalAgua = $totalAgua + $column['AHORRO'];
  118. }
  119. $datosAguaJson = json_encode($datosAgua);
  120. // <--------------Operación para la equivalencia de PET------------------------->
  121. $botellas = $totalAgua/3.43;
  122. $botellas = number_format($botellas, 2, '.', ',');
  123. //Obtenemos todas las imágenes
  124. $qryImagenesSus = "SELECT IDIM, URLI, TIPO FROM `ITT_ASW_SUIM` ";
  125. $qryImgSus = mysqli_query($conexion, $qryImagenesSus);
  126. $arrImgSus = array();
  127. while ($columnImgs = mysqli_fetch_assoc($qryImgSus)) {
  128. $arrImgSus[] = $columnImgs;
  129. }
  130. ?>
  131. <!DOCTYPE html>
  132. <!--[if IE 8 ]> <html xml:lang="es" lang="es" class="no-js ie8"> <![endif]-->
  133. <!--[if IE 9 ]> <html xml:lang="es" lang="es" class="no-js ie9"> <![endif]-->
  134. <html xml:lang="es" lang="es">
  135. <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  136. <head>
  137. <!-- Global site tag (gtag.js) - Google Analytics -->
  138. <!--Producción-->
  139. <script async src="https://www.googletagmanager.com/gtag/js?id=UA-125019062-2"></script>
  140. <!--Producción-->
  141. <script>
  142. window.dataLayer = window.dataLayer || [];
  143. function gtag(){dataLayer.push(arguments);}
  144. gtag('js', new Date());
  145. gtag('config', 'UA-125019062-2');
  146. </script>
  147. <!-- End Global site tag (gtag.js) - Google Analytics -->
  148. <!-- [if IE]> -->
  149. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
  150. <meta http-equiv="cleartype" content="on"/>
  151. <!-- <![endif] -->
  152. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  153. <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  154. <title>Sustentabilidad – S&amp;P</title>
  155. <meta name="description" content="Todo lo que debes saber de la producción, distribución y logística de S&amp;P, sistemas de ventilación residenciales, comerciales e industriales."/>
  156. <meta name="keywords" content="Magento, Varien, E-commerce"/>
  157. <meta name="robots" content="INDEX,FOLLOW"/>
  158. <link rel="icon" href="https://statics.solerpalau.com/skin/frontend/solerpalau/default/favicon.ico" type="image/x-icon"/>
  159. <link rel="shortcut icon" href="https://statics.solerpalau.com/skin/frontend/solerpalau/default/favicon.ico" type="image/x-icon"/>
  160. <link rel="apple-touch-icon" sizes="57x57"
  161. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/apple-icon-57x57.png">
  162. <link rel="apple-touch-icon" sizes="60x60"
  163. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/apple-icon-60x60.png">
  164. <link rel="apple-touch-icon" sizes="72x72"
  165. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/apple-icon-72x72.png">
  166. <link rel="apple-touch-icon" sizes="76x76"
  167. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/apple-icon-76x76.png">
  168. <link rel="apple-touch-icon" sizes="114x114"
  169. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/apple-icon-114x114.png">
  170. <link rel="apple-touch-icon" sizes="120x120"
  171. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/apple-icon-120x120.png">
  172. <link rel="apple-touch-icon" sizes="144x144"
  173. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/apple-icon-144x144.png">
  174. <link rel="apple-touch-icon" sizes="152x152"
  175. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/apple-icon-152x152.png">
  176. <link rel="apple-touch-icon" sizes="180x180"
  177. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/apple-icon-180x180.png">
  178. <link rel="icon" type="image/png" sizes="192x192"
  179. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/android-icon-192x192.png">
  180. <link rel="icon" type="image/png" sizes="32x32"
  181. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/favicon-32x32.png">
  182. <link rel="icon" type="image/png" sizes="96x96"
  183. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/favicon-96x96.png">
  184. <link rel="icon" type="image/png" sizes="16x16"
  185. href="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/favicon-16x16.png">
  186. <meta name="msapplication-TileColor" content="#ffffff">
  187. <meta name="msapplication-TileImage"
  188. content="../../../statics.solerpalau.com/skin/frontend/solerpalau/default/images/favicons/ms-icon-144x144.png">
  189. <meta name="theme-color" content="#ffffff">
  190. <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
  191. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>
  192. <script type="text/javascript">
  193. var $j = jQuery.noConflict();
  194. </script>
  195. <script type="text/javascript" src="js/events.js"></script>
  196. <link rel="stylesheet" href="css/style-sustentability.css">
  197. <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500,700&display=swap" rel="stylesheet">
  198. <link rel="stylesheet" type="text/css" href="css/style-css01.css" media="all" />
  199. <link rel=“preload” href=%e2%80%9c/skin/frontend/solerpalau/default/fonts/icomoone8bc.html?y8wbvh%e2%80%9d as=“font”>
  200. </head>
  201. <body class=" cms-page-view cms-produccion-distribucion-logistica level-2 customer-logged-out">
  202. <?php include 'header.php' ?>
  203. <script type="text/javascript">
  204. //<![CDATA[
  205. if (typeof HIB.menu == 'object' && typeof HIB.menu.init == 'function') {
  206. HIB.menu.init();
  207. }
  208. //]]>
  209. </script>
  210. <section class="custom-container main-padding">
  211. <div class="title">
  212. <h1 class="big-green">Soler y palau</h1>
  213. <h2 class="medium-green">por un mundo sustentable</h2>
  214. </div>
  215. <p class="text-sustentability">En S&P estamos comprometidos con un mundo más sustentable;
  216. por lo anterior, a través de nuestras diversas acciones internas como el
  217. ahorro de agua, energía eléctrica y reciclaje buscamos reducir el
  218. impacto ambiental y mejorar la calidad de vida.
  219. </p>
  220. <div class="light-content flex-box">
  221. <div class="graph">
  222. <h3 class="small-green">LUZ AHORRADA EN LOS ÚLTIMOS <?php echo count($datosElec); ?> MESES</h3>
  223. <div class="light-content-inside">
  224. <h3 class="small-green vertical">AHORRO</h3>
  225. <div id="columnchart_values" class="light-graph"></div>
  226. </div>
  227. <h3 class="small-green">MESES</h3>
  228. <p>Actualizado al <?php echo($hoy);?></p>
  229. </div>
  230. <div class="light-slide">
  231. <!--Slider starts-->
  232. <div class="slider-content display-container"><center>
  233. <?php
  234. if(!empty($arrImgSus)){
  235. foreach($arrImgSus as $imagenes){
  236. if($imagenes['TIPO']=='E'){
  237. $id = $imagenes['IDIM'];
  238. $url = $imagenes['URLI'];
  239. ?>
  240. <div class="item-slider-one">
  241. <h3 class="small-green img-title">Esto equivale a:</h3>
  242. <img class="img-little-slider" src="<?php echo($url); ?>" alt="IMG001">
  243. <p class="img-footer"><?php echo(number_format($co2, 2, '.', ','));?> kg de CO2 que equivale a participar en el corte de casi <?php echo(number_format($arboles, 2, '.', ','));?> arboles.</p>
  244. </div>
  245. <?php
  246. }
  247. }
  248. }
  249. ?>
  250. </center></div>
  251. <!--Slider ends-->
  252. </div>
  253. </div>
  254. <div class="light-content flex-box">
  255. <div class="graph">
  256. <h3 class="small-green">AGUA AHORRADA EN LOS ÚLTIMOS <?php echo count($datosAgua); ?> MESES</h3>
  257. <div class="light-content-inside">
  258. <h3 class="small-green vertical">AHORRO</h3>
  259. <div id="columnchart_agua" class="light-graph"></div>
  260. </div>
  261. <h3 class="small-green">MESES</h3>
  262. <p>Actualizado al <?php echo($hoy);?></p>
  263. </div>
  264. <div class="light-slide">
  265. <!--Slider starts-->
  266. <div class="slider-content display-container"><center>
  267. <?php
  268. if(!empty($arrImgSus)){
  269. foreach($arrImgSus as $imagenes){
  270. if($imagenes['TIPO']=='A'){
  271. $id = $imagenes['IDIM'];
  272. $url = $imagenes['URLI'];
  273. ?>
  274. <div class="item-slider-two">
  275. <h3 class="small-green img-title">Esto equivale a:</h3>
  276. <img class="img-little-slider" src="<?php echo($url); ?>" alt="IMG001">
  277. <p class="img-footer"><?php echo($botellas); ?> botellas de PET de 1.5L.</p>
  278. </div>
  279. <?php
  280. }
  281. }
  282. }
  283. ?>
  284. </center></div>
  285. <!--Slider ends-->
  286. </div>
  287. </div>
  288. </section>
  289. <div class="separator"></div>
  290. <hr class="padding-floor">
  291. <section class="floor">
  292. <div class="custom-container flex-box">
  293. <div class="floor-slider-container">
  294. <div class="floor-content floor-display-container" >
  295. <?php
  296. if(!empty($arrImgSus)){
  297. $countSlider = 0;
  298. foreach($arrImgSus as $imagenes){
  299. if($imagenes['TIPO']=='S'){
  300. $id = $imagenes['IDIM'];
  301. $url = $imagenes['URLI'];
  302. $countSlider++;
  303. ?>
  304. <img class="item-slider-three" width="100%" src="<?php echo($url); ?>" alt="Sustentabilidad S&P">
  305. <?php
  306. }
  307. }
  308. }
  309. ?>
  310. <div class="center floor-container floor-section floor-large floor-bottommiddle" style="width:100%">
  311. <div class="left left-hover img-footer" onclick="plusDivsSliderThree(-1)">&#10094;</div>
  312. <div class="right right-hover img-footer" onclick="plusDivsSliderThree(+1)">&#10095;</div>
  313. </div>
  314. </div>
  315. <div class="badge-container"><center>
  316. <?php
  317. for ($i = 1; $i <= $countSlider; $i++) {
  318. ?>
  319. <span class="badge demo border hover-white" onclick="currentDivSliderThree(<?php echo($i); ?>)"></span>
  320. <?php
  321. }
  322. ?>
  323. </center></div>
  324. </div>
  325. <div class="floor-text-container">
  326. <h2 class="floor-title">A través de</h2>
  327. <h3 class="floor-subtitle">nuestras acciones de cuidado al medio ambiente</h3>
  328. <p class="floor-text">Durante el mes de <?php echo($arrMeses[$mes]); ?> se han reducido <?php echo(number_format($emisiones, 2, '.', ',')); ?> emisiones de C02.</p>
  329. <?php
  330. if(!empty($arrImgSus)){
  331. foreach($arrImgSus as $imagenes){
  332. if($imagenes['IDIM']==1000){
  333. $url = $imagenes['URLI'];
  334. ?>
  335. <p class="floor-text"><?php echo($url); ?></p>
  336. <?php
  337. }
  338. }
  339. }
  340. ?>
  341. </p>
  342. </div>
  343. </div>
  344. </section>
  345. <?php include 'footer.php' ?>
  346. </body>
  347. <script>
  348. var slideIndex = 1;
  349. var ind = 1;
  350. showDivsSliderOne(slideIndex);
  351. var slideIndexTwo = 1;
  352. var indTwo = 1;
  353. showDivsSliderTwo(slideIndexTwo);
  354. var slideIndexThree = 1;
  355. showDivsSliderThree(slideIndexThree);
  356. function plusDivsSliderOne(n){
  357. ind = n;
  358. showDivsSliderOne(slideIndex += n);
  359. }
  360. function plusDivsSliderTwo(n){
  361. indTwo = n;
  362. showDivsSliderTwo(slideIndexTwo += n);
  363. }
  364. function plusDivsSliderThree(n) {
  365. showDivsSliderThree(slideIndexThree += n);
  366. }
  367. function currentDivSliderThree(n) {
  368. showDivsSliderThree(slideIndexThree = n);
  369. }
  370. function showDivsSliderOne(n){
  371. var i;
  372. var x = document.getElementsByClassName("item-slider-one");
  373. if (n > x.length) {slideIndex = 1}
  374. if (n < 1) {slideIndex = x.length};
  375. for (i = 0; i < x.length; i++){
  376. x[i].style.display = "none";
  377. }
  378. x[slideIndex-1].style.display = "block";
  379. if(ind > 0){
  380. x[slideIndex-1].classList.add("slideRight");
  381. x[slideIndex-1].classList.remove("slideLeft");
  382. }
  383. if(ind < 0){
  384. x[slideIndex-1].classList.add("slideLeft");
  385. x[slideIndex-1].classList.remove("slideRight");
  386. }
  387. }
  388. function showDivsSliderTwo(n){
  389. var i;
  390. var x = document.getElementsByClassName("item-slider-two");
  391. if (n > x.length) {slideIndexTwo = 1}
  392. if (n < 1) {slideIndexTwo = x.length};
  393. for (i = 0; i < x.length; i++){
  394. x[i].style.display = "none";
  395. }
  396. x[slideIndexTwo-1].style.display = "block";
  397. if(indTwo > 0){
  398. x[slideIndexTwo-1].classList.add("slideRight");
  399. x[slideIndexTwo-1].classList.remove("slideLeft");
  400. }
  401. if(indTwo < 0){
  402. x[slideIndexTwo-1].classList.add("slideLeft");
  403. x[slideIndexTwo-1].classList.remove("slideRight");
  404. }
  405. }
  406. function showDivsSliderThree(n) {
  407. var i;
  408. var x = document.getElementsByClassName("item-slider-three");
  409. var dots = document.getElementsByClassName("demo");
  410. if (n > x.length) {slideIndexThree = 1}
  411. if (n < 1) {slideIndexThree = x.length}
  412. for (i = 0; i < x.length; i++) {
  413. x[i].style.display = "none";
  414. }
  415. for (i = 0; i < dots.length; i++) {
  416. dots[i].className = dots[i].className.replace(" badge-background", "");
  417. dots[i].classList.add("badge-hover");
  418. }
  419. x[slideIndexThree-1].style.display = "block";
  420. dots[slideIndexThree-1].className += " badge-background";
  421. dots[slideIndexThree-1].classList.remove("badge-hover");
  422. }
  423. </script>
  424. </html>
  425. <script type="text/javascript">
  426. var arrayMeses = new Array();
  427. arrayMeses['01'] = 'Enero';
  428. arrayMeses['02'] = 'Febrero';
  429. arrayMeses['03'] = 'Marzo';
  430. arrayMeses['04'] = 'Abril';
  431. arrayMeses['05'] = 'Mayo';
  432. arrayMeses['06'] = 'Junio';
  433. arrayMeses['07'] = 'Julio';
  434. arrayMeses['08'] = 'Agosto';
  435. arrayMeses['09'] = 'Septiembre';
  436. arrayMeses['10'] = 'Octubre';
  437. arrayMeses['11'] = 'Noviembre';
  438. arrayMeses['12'] = 'Diciembre';
  439. var array = JSON.parse('<?php echo($datosElecJson); ?>');
  440. google.charts.load("current", {packages:['corechart']});
  441. google.charts.setOnLoadCallback(drawChart);
  442. function drawChart() {
  443. var data = new google.visualization.DataTable();
  444. data.addColumn('string','Fecha');
  445. data.addColumn('number','kW/hr');
  446. data.addColumn({role: "style"});
  447. data.addColumn({role: "annotation"});
  448. for (var i = 0; i < array.length; i++) {
  449. mes = array[i].FECHA;
  450. nombreMes=mes.split('-');
  451. nombreMes = arrayMeses[nombreMes[1]];
  452. ahorro = parseFloat(array[i].AHORRO);
  453. annotation = "⚡";
  454. data.addRow([nombreMes, ahorro,'stroke-color: #e5b92c; stroke-width: 2; fill-color: #ffd233',annotation]);
  455. }
  456. // ffd233
  457. var view = new google.visualization.DataView(data);
  458. view.setColumns([0, 1,
  459. {
  460. calc: "stringify",
  461. sourceColumn: 3,
  462. type: "string",
  463. role: "annotation"
  464. },
  465. 2]);
  466. var options = {
  467. title: "Se han ahorrado en total <?php echo(number_format($totalElec, 2, '.', ',')); ?> kW/hr",
  468. subtitle: 'Based on a scale of 1 to 10',
  469. colors: ['#ffd233'],
  470. width: '100%',
  471. height: '100%',
  472. bar: {groupWidth: "50%"},
  473. legend: {
  474. color: '#ffd233',
  475. textStyle: {
  476. fontName: 'Montserrat,sans-serif',
  477. }
  478. },
  479. annotations: {
  480. alwaysOutside: true
  481. },
  482. vAxis: {
  483. minValue: 0
  484. },
  485. hAxis: {
  486. slantedTextAngle: 90
  487. }
  488. };
  489. var chart = new google.visualization.ColumnChart(document.getElementById("columnchart_values"));
  490. chart.draw(view, options);
  491. function resizeHandler () {
  492. chart.draw(view, options);
  493. }
  494. if (window.addEventListener) {
  495. window.addEventListener('resize', resizeHandler, false);
  496. }
  497. else if (window.attachEvent) {
  498. window.attachEvent('onresize', resizeHandler);
  499. }
  500. }
  501. // SEGUNDA GRÁFICA
  502. var arrayAgua = JSON.parse('<?php echo($datosAguaJson); ?>');
  503. google.charts.load("current", {packages:['corechart']});
  504. google.charts.setOnLoadCallback(drawChartA);
  505. function drawChartA() {
  506. var dataA = new google.visualization.DataTable();
  507. dataA.addColumn('string','Fecha');
  508. dataA.addColumn('number','Litros');
  509. dataA.addColumn({role: "style"});
  510. dataA.addColumn({role: "annotation"});
  511. for (var i = 0; i < arrayAgua.length; i++) {
  512. mesA = arrayAgua[i].FECHA;
  513. nombreMesA=mesA.split('-');
  514. nombreMesA = arrayMeses[nombreMesA[1]];
  515. ahorroA = parseFloat(arrayAgua[i].AHORRO);
  516. annotation = "💧";
  517. dataA.addRow([nombreMesA, ahorroA,'stroke-color: #61adc1; stroke-width: 2; fill-color: #6cd1fd',annotation]);
  518. }
  519. var viewA = new google.visualization.DataView(dataA);
  520. viewA.setColumns([0, 1,
  521. { calc: "stringify",
  522. sourceColumn: 3,
  523. type: "string",
  524. role: "annotation" },
  525. 2]);
  526. var optionsA = {
  527. title: "Se han ahorrado en total <?php echo(number_format($totalAgua, 2, '.', ',')); ?> litros",
  528. // subtitle: "Acualizado al",
  529. colors: ['#6cd1fd'],
  530. width: '100%',
  531. bar: {groupWidth: "50%"},
  532. legend: {
  533. textStyle: {
  534. fontName: 'Montserrat,sans-serif',
  535. }
  536. },
  537. annotations: {
  538. alwaysOutside: true
  539. },
  540. vAxis: {
  541. minValue: 0
  542. },
  543. hAxis: {
  544. slantedTextAngle: 90
  545. }
  546. };
  547. var chartA = new google.visualization.ColumnChart(document.getElementById("columnchart_agua"));
  548. chartA.draw(viewA, optionsA);
  549. function resizeHandler () {
  550. chartA.draw(viewA, optionsA);
  551. }
  552. if (window.addEventListener) {
  553. window.addEventListener('resize', resizeHandler, false);
  554. }
  555. else if (window.attachEvent) {
  556. window.attachEvent('onresize', resizeHandler);
  557. }
  558. }
  559. </script>