<commit_before>{% extends "layout.html" %}
{% block title %}Logistics Summary{% endblock %}
{% block javascripts %}
<!--[if IE]><script language="javascript" type="text/javascript" src="/static/nigeria/js/excanvas.pack.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="/static/nigeria/js/jquery.flot.js"></script>
<script language="javascript">
$(document).ready(function() {


stock_loc_data = {{stock_per_loc_plot_data|safe}};
stock_loc_options = {{stock_per_loc_plot_options|safe}};
$.plot($("#sl_pl"), stock_loc_data , stock_loc_options );

// add tooltip.  unfortunately this isn't working now
$("#sl_pl").bind("plotclick", function (event, pos, item) {
            if (item) {
                $("#tooltip").remove();
                var y = item.datapoint[1].toFixed(0);
                showTooltip(item.pageX, item.pageY,
                            item.series.label + " = " + y);
            }
                });
       

data_for_dates = {{stock_over_time_data|safe}};
axis_for_dates =  {{stock_over_time_options|safe}};

$.plot($('#sl_ot'), data_for_dates, axis_for_dates);

data_for_child_dates = {{stock_over_time_child_data|safe}};
axis_for_child_dates =  {{stock_over_time_child_options|safe}};

$.plot($('#sl_ot_children'), data_for_child_dates, axis_for_child_dates);

});

     function showTooltip(x, y, contents) {
        $('<div id="tooltip">' + contents + '</div>').css( {
            position: 'absolute',
            display: 'none',
            top: y + 5,
            left: x + 5,
            border: '1px solid #fdd',
            padding: '2px',
            'background-color': '#fee',
            opacity: 0.80
        }).appendTo("body").fadeIn(200);
    }


</script>
{% endblock %}
{% block stylesheets %}
<style>
td {border-top: none}
tr.variant-amount { background-color: #FFD6DD; }
tr.variant-waybill { background-color: #FFD869; }
tr.variant-incorrect { background-color: #FFD6DD; }
</style>
{% endblock %}

{% block content %}
<div class="split">
  <div class = "location_summary">
    <h3>Logistics information for {{location.name}}</h3>
    <b>Current Stock: </b>{% if location.stock %}{{location.stock}}{% else %}None{% endif %}
  </div> 
	
  <table width="100%">
    <tr>
      <td colspan="2">
        <div class="module">
          <h2>Stock Levels Over Time</h2>
          <div id="sl_ot" style="height:350px;width:900;"></div>
        </div>
      </td>
    </tr>
    <tr>
      <td>
        <div class="module">
          <h2>Stock Levels Over Time For {{location.name}} Shipment Destinations</h2>
	  <div id="sl_ot_children" style="height:350px;width:450px;">
	  </div>
        </div>
      </td>
      <td>
	<div class="module">
          <h2>Current Stock Levels at {{location.name}} Shipment Destinations</h2>
	  <div id="sl_pl" style="height:350px;width:450px;">
	  </div>
        </div>
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <a name="st">
		<div class="module">
          <h2>Shipment Transactions</h2>
			<table class="shipment_discrepancy" width="100%">
			<thead><tr><th>Waybill No.</th><th>Date</th><th>From</th><th>To</th><th>Amount</th></tr></thead>
			<tbody>
			{% for transaction in transactions_pager.object_list %}
				<tr {% ifequal transaction.flag "I" %}class="variant-waybill"{% else %}{% ifequal transaction.flag "R" %}class="variant-amount"{% endifequal %}{% endifequal %}>
                   <td>{{transaction.shipment_id}}</td>
                   <td>{{transaction.date|date:"M j, Y h:iA"}}</td>
                   <td><a href="/reports/logistics/summary/{{transaction.origin.id}}/">{{transaction.origin.name}}</a></td>
				   <td><a href="/reports/logistics/summary/{{transaction.destination.id}}/">{{transaction.destination.name}}</a></td>
				   <td>{{transaction.amount}}</td>
                </tr>
			{% endfor %}<commit_msg>separated the display of legend from the graph<commit_after>{% extends "layout.html" %}
{% block title %}Logistics Summary{% endblock %}
{% block javascripts %}
<!--[if IE]><script language="javascript" type="text/javascript" src="/static/nigeria/js/excanvas.pack.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="/static/nigeria/js/jquery.flot.js"></script>
<script language="javascript">
$(document).ready(function() {


stock_loc_data = {{stock_per_loc_plot_data|safe}};
stock_loc_options = {{stock_per_loc_plot_options|safe}};

stock_options = { bar: stock_loc_options, xaxis: {ticks: {{bar_ticks|safe}}, tickFormatter: "string"}, legend: {show: true, container : $('#stock_level_legend')} }

$.plot($("#sl_pl"), stock_loc_data , stock_options );

// add tooltip.  unfortunately this isn't working now
$("#sl_pl").bind("plotclick", function (event, pos, item) {
            if (item) {
                $("#tooltip").remove();
                var y = item.datapoint[1].toFixed(0);
                showTooltip(item.pageX, item.pageY,
                            item.series.label + " = " + y);
            }
                });
       

data_for_dates = {{stock_over_time_data|safe}};
axis_for_dates =  {{stock_over_time_options|safe}};

$.plot($('#sl_ot'), data_for_dates, axis_for_dates);

data_for_child_dates = {{stock_over_time_child_data|safe}};
axis_for_child_dates =  {{stock_over_time_child_options|safe}};

options = '{"bars":{"show":false},"points":{"show":true},"grid":{"clickable":false},"xaxis":{"mode":"time","timeformat":"%m/%d/%y"},"yaxis":{"min":0},"legend":{"show":false},"lines":{"show":true}}'

//Hack added here to remind flot to include options from the views eg addition of xaxis, points, and lines options of the plot. This should be removed.

//The hints option added in the axis_for_child_dates_legend options below isnt working yet. Still working on this.
axis_for_child_dates_legend = {bar: axis_for_child_dates, xaxis: {mode:"time", timeformat:"%m/%d/%y"}, points: {show: true},lines : {show: true}, legend: { show: true, container:  $('#stock_level_over_time_legend')}, selection: {mode: "xy"}, hints:{ hintFormatter:  function hintFormatter( ) {
                /*var datetime = new Date( datapoint.x );

                var hour = datetime.getHours();
                var minute = datetime.getMinutes();
                var second = datetime.getSeconds();
                var time = ( ( hour < 10 ) ? "0" : "" ) + hour + ":" +
                           ( ( minute < 10 ) ? "0" : "" ) + minute + ":" +
                           ( ( second < 10 ) ? "0" : "" ) + second;
*/
                return "Hello";/*"<table><tr><td><strong>Time:</strong></td><td>" +
                       datetime.toDateString() + "<br/>@" + time + "</td></tr>" +
                       "<tr><td><strong>Value:</strong></td><td>" +
                       datapoint.y.toFixed(2) + "</td></tr></table>";*/
              } } }

//Generate the plot here
$.plot($('#sl_ot_children'), data_for_child_dates, axis_for_child_dates_legend);


$('#sl_ot_children').bind( 'plotmousemove', function( e, pos ) {
          if( !pos.selected ) { return; }
          plot.highlight( pos.selected );
});

} );
     function showTooltip(x, y, contents) {
        $('<div id="tooltip">' + contents + '</div>').css( {
            position: 'absolute',
            display: 'none',
            top: y + 5,
            left: x + 5,
            border: '1px solid #fdd',
            padding: '2px',
            'background-color': '#fee',
            opacity: 0.80
        }).appendTo("body").fadeIn(200);
    }


</script>
{% endblock %}
{% block stylesheets %}
<style>
td {border-top: none}
tr.variant-amount { background-color: #FFD6DD; }
tr.variant-waybill { background-color: #FFD869; }
tr.variant-incorrect { background-color: #FFD6DD; }
</style>
{% endblock %}

{% block content %}
<div class="split">
  <div class = "location_summary">
    <h3>Logistics information for {{location.name}}</h3>
    <b>Current Stock: </b>{% if location.stock %}{{location.stock}}{% else %}None{% endif %}
  </div> 
	
  <table width="100%">
    <tr>
      <td colspan="2">
        <div class="module">
          <h2>Stock Levels Over Time</h2>
          <div id="sl_ot" style="height:350px;width:900;"></div>
        </div>
      </td>
    </tr>
    <tr>
      <td>
        <div class="module">
          <h2>Stock Levels Over Time For {{location.name}} Shipment Destinations</h2>
	  <div id="sl_ot_children" style="height:350px;width:650px;">
	  </div>
        </div>
      </td>
      <td>
  	    <div class="module">
	        <h2>Legend</h2>
	        <div id="stock_level_over_time_legend" style="height:350px;width:150px;"></div>
	    </div>
    </td>
    <td>
           
    </td> 
    </tr>
    <tr>
    <td>
        <div class="module">
          <h2>Current Stock Levels at {{location.name}} Shipment Destinations</h2>
          <div id="sl_pl" style="height:350px;width:650px;">
          </div>
        </div>
    </td>
    <td>
 	<h2>Legend</h2>
	<div id="stock_level_legend" style="height:350px;width:200px;"></div>
    </td> 
    </tr>
    <tr>
      <td colspan="2">
        <a name="st">
		<div class="module">
          <h2>Shipment Transactions</h2>
			<table class="shipment_discrepancy" width="100%">
			<thead><tr><th>Waybill No.</th><th>Date</th><th>From</th><th>To</th><th>Amount</th></tr></thead>
			<tbody>
			{% for transaction in transactions_pager.object_list %}
				<tr {% ifequal transaction.flag "I" %}class="variant-waybill"{% else %}{% ifequal transaction.flag "R" %}class="variant-amount"{% endifequal %}{% endifequal %}>
                   <td>{{transaction.shipment_id}}</td>
                   <td>{{transaction.date|date:"M j, Y h:iA"}}</td>
                   <td><a href="/reports/logistics/summary/{{transaction.origin.id}}/">{{transaction.origin.name}}</a></td>
				   <td><a href="/reports/logistics/summary/{{transaction.destination.id}}/">{{transaction.destination.name}}</a></td>
				   <td>{{transaction.amount}}</td>
                </tr>
			{% endfor %}
{'fraction_non_alphanumeric': 0.19287863590772317, 'fraction_numerical': 0.013340020060180542, 'mean_word_length': 2.896443923407581, 'pattern_counts': {'":': 17, '<': 215, '<?xml version=': 0, '>': 212, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5318219', 'n_tokens_mistral': 3525, 'n_tokens_neox': 3242, 'n_words': 616}