Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="tab-pane" id="graph">
- {% set JanAmount = 0 %} {% set FebAmount = 0 %} {% set MarAmount = 0 %} {% set AprAmount = 0 %} {% set MaiAmount = 0 %} {% set JunAmount = 0 %} {% set JulAmount = 0 %}
- {% set AugAmount = 0 %} {% set SepAmount = 0 %} {% set OktAmount = 0 %} {% set NovAmount = 0 %} {% set DecAmount = 0 %}
- {% set nJanAmount = 0 %} {% set nFebAmount = 0 %} {% set nMarAmount = 0 %} {% set nAprAmount = 0 %} {% set nMaiAmount = 0 %} {% set nJunAmount = 0 %} {% set nJulAmount = 0 %}
- {% set nAugAmount = 0 %} {% set nSepAmount = 0 %} {% set nOktAmount = 0 %} {% set nNovAmount = 0 %} {% set nDecAmount = 0 %}
- {% set datum = current_user.cwmon %}
- {% set yeahrNow = datum|date('Y') %}
- {% set monthNow = datum|date('Y') %}
- {% for statement in statements %}
- {% set month = env.getFormattedDatetime(statements.date)|date('n') %}
- {% set yeahr = env.getFormattedDatetime(statements.date)|date('Y') %}
- {% if yeahr == yeahrNow and month == 1 %}
- {% if statement.amount > 0 %}
- {% set JanAmount = JanAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nJanAmount = nJanAmount - statement.amount %}
- {% endif %}
- {% elseif yeahr == yeahrNow and month == 2 %}
- {% if statement.amount > 0 %}
- {% set FebAmount = FebAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nFebAmount = nFebAmount - statement.amount %}
- {% endif %}
- </br>
- <a>{{ month }}</a> <a>{{ yeahr }}</a>
- {% elseif yeahr == yeahrNow and month == 3 %}
- {% if statement.amount > 0 %}
- {% set MarAmount = MarAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nMarAmount = nMarAmount - statement.amount %}
- {% endif %}
- {% elseif yeahr == yeahrNow and month == 4 %}
- {% if statement.amount > 0 %}
- {% set AprAmount = AprAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nAprAmount = nAprAmount - statement.amount %}
- {% endif %}
- {% elseif yeahr == yeahrNow and month == 5 %}
- {% if statement.amount > 0 %}
- {% set MaiAmount = MaiAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nMaiAmount = nMaiAmount - statement.amount %}
- {% endif %}
- {% elseif yeahr == yeahrNow and month == 6 %}
- {% if statement.amount > 0 %}
- {% set JunAmount = JunAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nJunAmount = nJunAmount - statement.amount %}
- {% endif %}
- {% elseif yeahr == yeahrNow and month == 7 %}
- {% if statement.amount > 0 %}
- {% set JulAmount = JulAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nJulAmount = nJulAmount - statement.amount %}
- {% endif %}
- {% elseif yeahr == yeahrNow and month == 8 %}
- {% if statement.amount > 0 %}
- {% set AugAmount = AugAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nAugAmount = nAugAmount - statement.amount %}
- {% endif %}
- {% elseif yeahr == yeahrNow and month == 9 %}
- {% if statement.amount > 0 %}
- {% set SepAmount = SepAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nSepAmount = nSepAmount - statement.amount %}
- {% endif %}
- {% elseif yeahr == yeahrNow and month == 10 %}
- {% if statement.amount > 0 %}
- {% set OktAmount = OktAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nOktAmount = nOktAmount - statement.amount %}
- {% endif %}
- {% elseif yeahr == yeahrNow and month == 11 %}
- {% if statement.amount > 0 %}
- {% set NovAmount = NovAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nNovAmount = nNovAmount - statement.amount %}
- {% endif %}
- {% elseif yeahr == yeahrNow and month == 12 %}
- {% if statement.amount > 0 %}
- {% set DecAmount = DecAmount + statement.amount %}
- {% elseif statement.amount < 0 %}
- {% set nDecAmount = nDecAmount - statement.amount %}
- {% endif %}
- {% endif %}
- {% endfor %}
- <canvas id="financeChart"></canvas>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js" integrity="sha512-d9xgZrVZpmmQlfonhQUvTR7lMPtO7NkZMkA0ABN3PHCbKA5nqylQ/yWlFAyY6hYgdF1Qh6nYiuADWwKB4C2WSw==" crossorigin="anonymous"></script>
- <script>
- var pJan = '{{ JanAmount }}';
- var pFeb = '{{ FebAmount }}';
- var pMar = '{{ MarAmount }}';
- var pApr = '{{ AprAmount }}';
- var pMai = '{{ MaiAmount }}';
- var pJun = '{{ JunAmount }}';
- var pJul = '{{ JulAmount }}';
- var pAug = '{{ AugAmount }}';
- var pSep = '{{ SepAmount }}';
- var pOct = '{{ OktAmount }}';
- var pNov = '{{ NovAmount }}';
- var pDez = '{{ DecAmount }}';
- var nJan = '{{ nJanAmount }}';
- var nFeb = '{{ nFebAmount }}';
- var nMar = '{{ nMarAmount }}';
- var nApr = '{{ nAprAmount }}';
- var nMai = '{{ nMaiAmount }}';
- var nJun = '{{ nJunAmount }}';
- var nJul = '{{ nJulAmount }}';
- var nAug = '{{ nAugAmount }}';
- var nSep = '{{ nSepAmount }}';
- var nOct = '{{ nOktAmount }}';
- var nNov = '{{ nNovAmount }}';
- var nDez = '{{ nDecAmount }}';
- //alert(pNov);
- //alert(nNov);
- var financeChartObject = document.getElementById('financeChart');
- var chart = new Chart(financeChartObject, {
- type: 'bar',
- data: {
- labels: ["Januar","Februar", "März", "April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],
- datasets: [{
- label: "Einkommen",
- backgroundColor: 'rgba(65,105,255,0.4)',
- borderColor: 'rgba(65,105,255,1)',
- data: [pJan, pFeb, pMar, pApr, pMai, pJun, pJul, pAug, pSep, pOct, pNov, pDez]
- },{
- label: "Ausgaben",
- fill: true,
- backgroundColor: 'rgba(255,0,0,0.4)',
- borderColor: 'rgba(255,0,0,1)',
- data: [nJan, nFeb, nMar, nApr, nMai, nJun, nJul, nAug, nSep, nOct, nNov, nDez]
- }]
- }
- });
- </script>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement