{% extends 'money/base.html' %}
<!--
#-- ***************************************************************************
#--
#-- version 1.00  : 1 July 2014
#-- version 2.00  : 22-Aug-2014 Change Logic to get all values for request.user
#-- version 2.01  : 23-Aug-2014 Rename Pockets - old_money to initial_amount
#                                                pocket_amount  to rename as sum_pocket
#                                                Summ_old_money_Pockets to Summ_initial_amount_Pockets
#-- version 2.02  : 23-Aug-2014 Logic to make Pocket Total Amount Functional
#-- version 2.03  : 26-Aug-2014 Summary to show only for User who is logged in
#-- version 2.04  : 26-Aug-2014 Fix add_expenditure and add_bank transactions to have only pockets of user logged in
#-- version 2.05  : 27-Aug-2014 add decorators - login_required
#-- version 2.06  : 27-Aug-2014 Alert if trying to add expenditure without pockets
#--
#-- version 1.00    : 1 July 2014
#-- version 2.00    :   22-Aug-2014 :   Adding Bootstrap sb-admin-2 to the base-Template and doing changes here
#                                       http://startbootstrap.com/template-overviews/sb-admin-2/
#-- version 2.01    :   2-Sept-2014 :   Bootstrapping add_expenditure.html
#-- version 2.07    :   3-Sept-2014 :   Fixing Table bootstrapping
#-- version 2.09    :   4-Sept-2014 :   add_expenditure - Link for Now below datetimepicker
#-- version 2.10    :   4-Sept-2014 :   edit_expenditure - Same as in
#                                       add_expenditure - on expenditure delete - delete pocket total
#                                      views.py - edit_expenditure
#-- version 2.11    :   4-Sept-2014 :  changed Edit_Expenditure form as only delete expenditure form
#                                       changes in - views.py forms.py
#-- version 2.12    :   4-Sept-2014 :   fluid bootstrap in all forms
#-- Authors - Paarth Batra
#--
#-- ***************************************************************************

#-- ***************************************************************************
-->
{% block title %}
    {% if user.is_authenticated %}
        {{ user }}'s Dashboard
     {% else %}
        Money Dashboard
    {% endif %}
{% endblock %}

{% block body_block %}
    {% if user.is_authenticated %}
        <div class="span12">
            <div class="row">

                <div class="alert alert-info" role="alert">
                    <h2>
                        <center>Expenditure</center>
                    </h2>
                </div>
                <hr>
                {% if Summary_list %}
                    <div class="table-responsive table-scrollable">
                    <table border=10 class="table table-striped table-bordered table-hover ">
                        <div class="alert alert-info" role="alert">
                            <strong>Summary</strong></div>
                        <tr>
                            <th>Total Money Recorded</th>
                            <th>Total Money in All Pockets<br>(Sum of currency in pocket)</th>
                            <th>Initial Money in All Pockets</th>
                            <th>Total Money Withdrawn from Bank</th>
                            <th>Money not Recorded or Lost <br> - means more in Pocket or wrongly Recorded <br> if 0 -
                                all Ok
                            </th>
                            <th>Total Money Spent</th>
                            <th>Spent This Month</th>
                        </tr>

                        {% for exp in Summary_list %}
                            <!-- Following line changed to add an HTML hyperlink -->
                            <tr>
                                <td>{{ exp.Summ_Tot_Money_audited }} </td>
                                <td>{{ exp.Summ_Tot_Money_Pockets }}</td>
                                <td>{{ exp.Summ_initial_amount_Pockets }}</td>
                                <td>{{ exp.Summ_Tot_Withdrawn }}</td>
                                <td>{{ exp.Summ_Match }}</td>
                                <td>{{ exp.Summ_Total_Spent }}</td>
                                <td>{{ exp.Summ_Total_Spent_This_month }}</td>
                            </tr>

                        {% endfor %}
                    </table>
                {% else %}
                    <strong>There is No Summary Present present.</strong>
                {% endif %}
                <!--table responsive and scrollable -->
                </div>
            </div>
            <!--row-->
        </div>

        <div class="row-fluid">
            <div class="span12">
                <div class="row">

                    <div class="alert alert-info" role="alert">
                    <strong>Expenditure per Type of Expenditure</strong></div>
                    <hr>
                    <div id="containerHighChartJSONPie" style="min-width: 310px; height: 400px; margin: 10 auto"></div>


                </div>
            </div>
        </div>


        <hr>
        <div class="row-fluid">
            <div class="row">
                <div class="span6">
                    {% if Expenditure_list %}

                        <table border=10 class="table table-striped table-bordered table-hover ">
                            <div class="alert alert-info" role="alert">
                                <strong>Expenditure</strong></div>
                            <tr>
                                <th>Date</th>
                                <th>Description</th>
                                <th>Amount</th>
                                <th>Pocket</th>
                                <th>Type of Expenditure</th>
                            </tr>

                            {% for exp in Expenditure_list %}
                                <!-- Following line changed to add an HTML hyperlink -->
                                <tr>
                                    <td>{{ exp.exp_date }} </td>
                                    <td>{{ exp.description }}</td>
                                    <td>{{ exp.amount }}</td>
                                    <td>{{ exp.exp_pocket }}</td>
                                    <td>{{ exp.exp_type }}</td>
                                </tr>
                            {% endfor %}
                        </table>
                    {% else %}
                        <div class="alert alert-info" role="alert">
                            <strong>No Expenditure Yet</strong></div>

                    {% endif %}
                    <!-- for span6 for expenditure-->
                </div>
                <!--/span-->

                <div class="span6">
                    {% if PocketTransactions_list %}
                        <table border=10 class="table table-striped table-bordered table-hover ">
                            <div class="alert alert-info" role="alert">
                                <strong>Pocket Level Transactions</strong></div>
                            <tr>
                                <th>Date</th>
                                <th>From</th>
                                <th>To</th>
                                <th>Amount</th>
                                <th>Description</th>
                            </tr>
                            {% for exp in PocketTransactions_list %}
                                <!-- Following line changed to add an HTML hyperlink -->
                                <tr>
                                    <td>{{ exp.PT_date }} </td>
                                    <td>{{ exp.PT_Pocket_From }}</td>
                                    <td>{{ exp.PT_Pocket_To }}</td>
                                    <td>{{ exp.PT_Amount }}</td>
                                    <td>{{ exp.PT_Description }}</td>
                                </tr>
                            {% endfor %}
                        </table>
                    {% else %}
                        <div class="alert alert-info" role="alert">
                            <strong>There are no Pocket Transactions present.</strong></div>
                    {% endif %}
                    <!-- for span6 for expenditure-->
                </div>
                <!-- row -->
            </div>
        </div>
        <hr>
        <!-- for class row-->
        <div class="row-fluid">

                <div class="row">
                <div class="span6">
                    {% if Pockets_list %}
                        <div class="alert alert-info" role="alert">
                            <strong>Pockets</strong></div>
                        <table border=10 class="table table-striped table-bordered table-hover ">
                            <tr>
                                <th>Pocket Name</th>
                                <th>Description</th>
                                <th>Sum-Currency Notes in pocket</th>
                                <th>Pocket Total Amount</th>
                            </tr>
                            {% for exp in Pockets_list %}
                                <!-- Following line changed to add an HTML hyperlink -->
                                <tr>
                                    <td>{{ exp.pocket_name }} </td>
                                    <td>{{ exp.pocket_description }}</td>
                                    <td>{{ exp.sum_pocket }}</td>
                                    <td>{{ exp.pocket_total }}</td>
                                </tr>
                            {% endfor %}
                        </table>
                    {% else %}
                        <div class="alert alert-info" role="alert">
                            <strong>No Pockets</strong></div>
                    {% endif %}
                </div>


                <div class="span6">
                    {% if BankTransactions_list %}
                        <table border=10 class="table table-striped table-bordered table-hover ">
                            <div class="alert alert-info" role="alert">
                                <strong>Bank Transactions</strong></div>
                            <tr>
                                <th>Date</th>
                                <th>Description</th>
                                <th>Amount</th>
                                <th>Pocket</th>
                                <th>Transaction Type</th>
                            </tr>
                            {% for exp in BankTransactions_list %}
                                <!-- Following line changed to add an HTML hyperlink -->
                                <tr>
                                    <td>{{ exp.bank_exp_date }} </td>
                                    <td>{{ exp.bank_description }}</td>
                                    <td>{{ exp.bank_amount }}</td>
                                    <td>{{ exp.BT_pocket }}</td>
                                    <td>{{ exp.BT_Credit_Debit }}</td>
                                </tr>
                            {% endfor %}
                        </table>
                    {% else %}
                        <div class="alert alert-info" role="alert">
                            <strong>There are no Bank Transactions present.</strong></div>
                    {% endif %}
                    <!-- for span6 for expenditure-->
                </div>
                <!-- row -->
            </div>
        </div>
    {% endif %}
{% endblock %}

