PATH:
home
/
lab2454c
/
gemition.com
/
wp-content
/
themes
/
igpma
<?php /** * Template Name: Spot Price Test */ // For last 14 days..... $array_all = $array_all_sector_unit = $array_energy = $array_industrial = $array_waste = $array_afolu = $array_transport = []; $date = date('Y-m-d'); $prev_date = date('Y-m-d', strtotime($date . ' -14 day')); $urls = []; while (strtotime($date) >= strtotime($prev_date)) { array_push($urls, 'https://api.kyotounit.com/?action=get_co2_sector_emissions_by_date&value=' . $date); $date = date("Y-m-d", strtotime("-1 day", strtotime($date))); } $data = !empty($urls) ? curlMultiUrls($urls) : []; if (!empty($data)) { $flag = 1; foreach ($data as $key => $value) { $results = json_decode($value); if (!empty($results)) { foreach ($results as $r_key => $r_value) { if ($flag > 1) { $array_all_sector_unit[$r_value->sector][] = $r_value; } if ($r_value->sector == 'Energy') { array_push($array_energy, ['kyoto' => $r_value->kyoto_unit, 'date' => date('M j', strtotime($r_value->date))]); } if ($r_value->sector == 'Industrial processes') { array_push($array_industrial, ['kyoto' => $r_value->kyoto_unit, 'date' => date('M j', strtotime($r_value->date))]); } if ($r_value->sector == 'Waste') { array_push($array_waste, ['kyoto' => $r_value->kyoto_unit, 'date' => date('M j', strtotime($r_value->date))]); } if ($r_value->sector == 'Agriculture, Forestry & Land Use (AFOLU)') { array_push($array_afolu, ['kyoto' => $r_value->kyoto_unit, 'date' => date('M j', strtotime($r_value->date))]); } if ($r_value->sector == 'Transport') { array_push($array_transport, ['kyoto' => $r_value->kyoto_unit, 'date' => date('M j', strtotime($r_value->date))]); } } } $flag++; } } $array_energy = array_reverse($array_energy); $array_industrial = array_reverse($array_industrial); $array_waste = array_reverse($array_waste); $array_afolu = array_reverse($array_afolu); $array_transport = array_reverse($array_transport); // For every Monday until 01/09/2022 $base_line = '2022-09-01'; $current_date = date('Y-m-d'); $marquee_urls = []; if(date('j', strtotime($current_date)) === '1'){ $last_monday = date('Y-m-d', strtotime($current_date . ' -7 day')); }else{ $last_monday = date('Y-m-d',strtotime("last Monday")); } //$previous_monday = date('Y-m-d', strtotime($last_monday . ' -7 day')); while(strtotime($last_monday) >= strtotime($base_line)) { array_push($marquee_urls, 'https://api.kyotounit.com/?action=get_co2_sector_emissions_by_date&value=' . $last_monday); $last_monday = date("Y-m-d", strtotime("-7 day", strtotime($last_monday))); } array_push($marquee_urls, 'https://api.kyotounit.com/?action=get_co2_sector_emissions_by_date&value=2022-09-01'); $marquee_data = !empty($marquee_urls) ? curlMultiUrls($marquee_urls) : []; if (!empty($marquee_data)) { $flag = 1; foreach ($marquee_data as $key => $value) { $results = json_decode($value); if (!empty($results)) { foreach ($results as $r_key => $r_value) { $array_all[$r_value->sector][] = $r_value; } } } } $html = ''; get_header(); ?> <div class="body__container__wrapp body__container__wrapp__inner "> <div class="container-fluid"> <div class="marquee"> <div class="marquee__content"> <?php $json_latest = file_get_contents('https://api.kyotounit.com/?action=get_co2_sector_emissions_latest'); $data_latest = json_decode($json_latest, true); if (!empty($data_latest)) { $html .= '<ul class="list-inline">'; foreach ($data_latest as $key => $value) { if (empty($array_all[$value['sector']])) continue; $html .= "<li>"; $html .= "<span class='sector'>" . $value['sector'] . "</span>"; $flag = 0; $kyoto_unit_base_value = $sector_unit_base_value = 0; $kyoto_unit_change = $sector_unit_change = false; $sector_unit_difference = 0; foreach ($array_all[$value['sector']] as $prev_key => $prev_val) { $flag++; if($flag == 1){ $kyoto_unit_base_value = $prev_val->kyoto_unit; //$sector_unit_base_value = $prev_val->sector_unit; $sector_unit_base_value = $value['sector_unit']; continue; } $kyoto_unit_difference = $kyoto_unit_base_value - $prev_val->kyoto_unit; //$sector_unit_difference = $sector_unit_base_value - $prev_val->sector_unit; if(isset($array_all_sector_unit[$value['sector']][$prev_key]->sector_unit) && ($flag <= 3)){ $sector_unit_difference = $sector_unit_base_value - $array_all_sector_unit[$value['sector']][$prev_key]->sector_unit; } if ($kyoto_unit_difference != 0 && !$kyoto_unit_change) { $kyoto_unit_change = true; $sticker = $kyoto_unit_difference > 0 ? 'up' : 'downgreen'; $html .= "<span class='kyoto__unit'>" . $value['kyoto_unit'] . "<img src='//carbonbullion.com/wp-content/uploads/2022/09/" . $sticker . ".png'></span>"; } if ($sector_unit_difference != 0 && !$sector_unit_change && $flag <= 3 ) { $sector_unit_change = true; $sticker = $sector_unit_difference > 0 ? 'up' : 'downgreen'; $html .= "<span class='sector__unit'>" . $value['sector_unit'] . "<img src='//carbonbullion.com/wp-content/uploads/2022/09/" . $sticker . ".png'></span>"; } if ($kyoto_unit_change && $sector_unit_change) break; } if (!$kyoto_unit_change) $html .= "<span class='kyoto__unit'>" . $value['kyoto_unit'] . "<img src='//carbonbullion.com/wp-content/uploads/2022/09/flat-line.png'></span>"; if (!$sector_unit_change) $html .= "<span class='kyoto__unit'>" . $value['sector_unit'] . "<img src='//carbonbullion.com/wp-content/uploads/2022/09/flat-line.png'></span>"; $html .= "</li>"; } } $html .= "</ul>"; echo $html; ?> </div> </div> </div> <div class="spot__price__main"> <!-- <div class="carbon__bullion__price__graph"> <div class="container-xl"> <div class="graph__inner"> <img src="<?php //the_field('price_image'); ?>" alt="" /> </div> </div> </div> --> <div class="carbon__bullion__price__graph"> <div class="container-xl"> <div class="graph__inner"> <div class="row"> <div class="col-xl-9 col-lg-9 col-md-9 order-xl-2 order-lg-2 order-md-2 p-0"> <div class="m-4 chart__graph"> <ul class="nav nav-tabs" id="myTab"> <li class="nav-item"> <a href="#energy" class="nav-link active" data-bs-toggle="tab">Energy</a> </li> <li class="nav-item"> <a href="#industrial" class="nav-link" data-bs-toggle="tab">Industrial</a> </li> <li class="nav-item"> <a href="#waste" class="nav-link" data-bs-toggle="tab">Waste</a> </li> <li class="nav-item"> <a href="#afolu" class="nav-link" data-bs-toggle="tab">AFOLU</a> </li> <li class="nav-item"> <a href="#transport" class="nav-link" data-bs-toggle="tab">Transport</a> </li> </ul> <div class="tab-content"> <div class="tab-pane fade show active" id="energy"> <canvas id='canvas_energy'></canvas> </div> <div class="tab-pane fade" id="industrial"> <canvas id='canvas_industrial'></canvas> </div> <div class="tab-pane fade" id="waste"> <canvas id='canvas_waste'></canvas> </div> <div class="tab-pane fade" id="afolu"> <canvas id='canvas_afolu'></canvas> </div> <div class="tab-pane fade" id="transport"> <canvas id='canvas_transport'></canvas> </div> </div> </div> </div> <div class="col-xl-3 col-lg-3 col-md-3 p-0 order-xl-1 order-lg-1 order-md-1"> <?php if (have_rows('price_image')) : while (have_rows('price_image')) : the_row(); ?> <div class="industry__wrapp"> <div class="image__box"> <img src="<?php the_sub_field('first_image'); ?>" alt="" /> </div> <div class="image__box"> <img src="<?php the_sub_field('second_image'); ?>" alt="" /> </div> </div> <?php endwhile; endif; ?> </div> </div> </div> </div> <div class="world__curbon__price"> <div class="container-xl"> <?php if (get_field('carbon_price_heading')) : ?> <h3><?php the_field('carbon_price_heading'); ?></h3> <?php endif; ?> <?php if (have_rows('carbon_prices')) : ?> <ul> <?php while (have_rows('carbon_prices')) : the_row(); ?> <li><a href="link"><?php the_sub_field('price_name'); ?></a></li> <?php endwhile; ?> </ul> <?php endif; ?> </div> </div> <div class="product__wrapp"> <div class="product__list__main"> <div class="container-xl"> <div class="owl-carousel owl-theme products__wrapp"> <?php $j = 1; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'product', 'orderby' => 'date', 'order' => 'DESC', 'posts_per_page' => -1, 'taxonomy' => 'product_cat', 'paged' => $paged ); $products = new WP_Query($args); if ($products->have_posts()) : while ($products->have_posts()) : $products->the_post(); ?> <div class="item team__card"> <div class="product__item"> <div class="thumb__wrapper"> <a href="<?php the_permalink(); ?>"> <div class="image__box"> <?php if (has_post_thumbnail($products->post->ID)) echo get_the_post_thumbnail($products->post->ID, 'shop_catalog'); else echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" />'; ?> </div> </a> <a href="<?php the_permalink(); ?>" class="loop__product__link"> <h3 class="product__title"><?php the_title(); ?></h3> </a> <div class="product__descraption"> <?php the_excerpt(); ?> </div> </div> </div> </div> <?php endwhile; endif; wp_reset_query(); ?> </div> </div> </div> </div> <?php if (have_rows('spot_about_section')) : while (have_rows('spot_about_section')) : the_row(); ?> <div class="two__col__full__wrapp"> <div class="container-xl"> <div class="inner__content__wrap"> <div class="inner__content__holder"> <div class="container-xl"> <div class="row align-items-center"> <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6 order-xl-2 order-lg-2 order-md-2 order-sm-2"> <div class="image__box"> <img src="<?php the_sub_field('about_image'); ?>" alt="" /> </div> </div> <div class="col-xl-6 col-lg-6 col-md-6 col-sm-6"> <?php the_sub_field('about_spot_price'); ?> <?php the_sub_field('subscribe_form_shortcode'); ?> </div> </div> </div> </div> </div> </div> </div> <?php endwhile; endif; ?> </div> </div> </div> <script> var jsonfile_energy = { "jsonarray": <?php echo json_encode($array_energy); ?> } var data_energy = jsonfile_energy.jsonarray.map(function(e) { return e.kyoto; }); var labels_energy = jsonfile_energy.jsonarray.map(function(e) { return e.date; }); //var ctx = canvas.getContext('2d'); var ctx_energy = document.getElementById("canvas_energy").getContext("2d"); var config_energy = { type: 'line', data: { labels: labels_energy, datasets: [{ label: 'Graph Line', data: data_energy, backgroundColor: 'rgba(247, 146, 30, 1)' }] }, options: { scales: { yAxes: [{ position: 'right' }] } } }; var chart = new Chart(ctx_energy, config_energy); //// --------------- Industrial var jsonfile_industrial = { "jsonarray": <?php echo json_encode($array_industrial); ?> } var data_industrial = jsonfile_industrial.jsonarray.map(function(e) { return e.kyoto; }); var labels_industrial = jsonfile_industrial.jsonarray.map(function(e) { return e.date; }); //var ctx = canvas.getContext('2d'); var ctx_industrial = document.getElementById("canvas_industrial").getContext("2d"); var config_industrial = { type: 'line', data: { labels: labels_industrial, datasets: [{ label: 'Graph Line', data: data_industrial, backgroundColor: 'rgba(0, 172, 238, 1)' }] }, options: { scales: { yAxes: [{ position: 'right' }] } } }; var ctx_industrial = document.getElementById("canvas_industrial").getContext("2d"); var chart_industrial = new Chart(ctx_industrial, config_industrial); jQuery('a[href="#industrial"]').on('shown.bs.tab', function() { chart_industrial.update(); }); //// --------------- waste var jsonfile_waste = { "jsonarray": <?php echo json_encode($array_waste); ?> } var data_waste = jsonfile_waste.jsonarray.map(function(e) { return e.kyoto; }); var labels_waste = jsonfile_waste.jsonarray.map(function(e) { return e.date; }); //var ctx = canvas.getContext('2d'); var ctx_waste = document.getElementById("canvas_waste").getContext("2d"); var config_waste = { type: 'line', data: { labels: labels_waste, datasets: [{ label: 'Graph Line', data: data_waste, backgroundColor: 'rgba(102, 176, 50, 1)' }] }, options: { scales: { yAxes: [{ position: 'right' }] } } }; var ctx_waste = document.getElementById("canvas_waste").getContext("2d"); var chart_waste = new Chart(ctx_waste, config_waste); jQuery('a[href="#waste"]').on('shown.bs.tab', function() { chart_waste.update(); }); //// --------------- afolu var jsonfile_afolu = { "jsonarray": <?php echo json_encode($array_afolu); ?> } var data_afolu = jsonfile_afolu.jsonarray.map(function(e) { return e.kyoto; }); var labels_afolu = jsonfile_afolu.jsonarray.map(function(e) { return e.date; }); //var ctx = canvas.getContext('2d'); var ctx_afolu = document.getElementById("canvas_afolu").getContext("2d"); var config_afolu = { type: 'line', data: { labels: labels_afolu, datasets: [{ label: 'Graph Line', data: data_afolu, backgroundColor: 'rgba(61, 1, 164, 1)' }] }, options: { scales: { yAxes: [{ position: 'right' }] } } }; var ctx_afolu = document.getElementById("canvas_afolu").getContext("2d"); var chart_afolu = new Chart(ctx_afolu, config_afolu); jQuery('a[href="#afolu"]').on('shown.bs.tab', function() { chart_afolu.update(); }); //// --------------- transport var jsonfile_transport = { "jsonarray": <?php echo json_encode($array_transport); ?> } var data_transport = jsonfile_transport.jsonarray.map(function(e) { return e.kyoto; }); var labels_transport = jsonfile_transport.jsonarray.map(function(e) { return e.date; }); //var ctx = canvas.getContext('2d'); var ctx_transport = document.getElementById("canvas_transport").getContext("2d"); var config_transport = { type: 'line', data: { labels: labels_transport, datasets: [{ label: 'Graph Line', data: data_transport, backgroundColor: 'rgba(10, 113, 148, 1)' }] }, options: { scales: { yAxes: [{ position: 'right' }] } } }; var ctx_transport = document.getElementById("canvas_transport").getContext("2d"); var chart_transport = new Chart(ctx_transport, config_transport); jQuery('a[href="#transport"]').on('shown.bs.tab', function() { chart_transport.update(); }); </script> <?php get_footer(); ?>
[-] template-knowledge.php
[edit]
[+]
woocommerce
[-] template-option.php
[edit]
[-] template-othercomm.php
[edit]
[-] footer-widget.php
[edit]
[-] search.php
[edit]
[-] template-spot-price copy 1.php
[edit]
[-] index.php
[edit]
[-] page.php
[edit]
[-] searchform.php
[edit]
[+]
..
[-] template-faq.php
[edit]
[-] sidebar.php
[edit]
[-] template-sector.php
[edit]
[-] rtl.css
[edit]
[-] template-indexes.php
[edit]
[-] blank-page-with-container.php
[edit]
[-] template-globalgem.php
[edit]
[-] template-investment.php
[edit]
[-] single.php
[edit]
[-] footer.php
[edit]
[-] template-about.php
[edit]
[-] template-home.php
[edit]
[-] template-spot-price.php
[edit]
[-] .DS_Store
[edit]
[-] template-insight.php
[edit]
[-] template-partner.php
[edit]
[-] blank-page.php
[edit]
[-] left-sidebar.php
[edit]
[-] header.php
[edit]
[-] style.css
[edit]
[-] 404.php
[edit]
[-] readme.txt
[edit]
[-] template-spot-price copy 1.php.zip
[edit]
[-] single-attachment.php
[edit]
[-] woocommerce11.php
[edit]
[-] screenshot.png
[edit]
[-] template-stocks.php
[edit]
[-] custom-editor-style.css
[edit]
[-] functions.php
[edit]
[-] archive.php
[edit]
[-] fullwidth.php
[edit]
[+]
template-parts
[-] comments.php
[edit]
[-] template-sponsor.php
[edit]
[-] template-contact.php
[edit]
[+]
inc
[-] template-blog.php
[edit]