financialCalculations.php
9.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<h2 class="content-header">
<?= $t->_(isset(explode('/', $this->router->getRewriteUri())[2])? explode('/', $this->router->getRewriteUri())[2] : 'main') ?>
</h2>
<section style="overflow: visible" class="content">
<div class="main_block">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-calendar"></i>
</div>
<input type="text" class="form-control custom_width" id="reservation">
<a href="#" class="green_but orders_data_request" data-toggle="modal" data-target="#myModal" ><?= $t->_('reconciliation') ?></a>
</div>
<!-- /.input group -->
</div>
<div class="fin_content">
<div class="line l_one">
<div class="fin_cell c_one"><span style="display:none;"><?= $t->_('order_number') ?></span></div>
<div class="fin_cell c_two"><span><?= $t->_('invoice') ?></span></div>
<div class="fin_cell c_two"><span><?= $t->_('actually_paid') ?></span></div>
<div class="fin_cell c_two"><span>Статус</span></div>
<div class="fin_cell c_two"><span>Дата</span></div>
</div>
<div class="order_lines">
<?php if(isset($payment) && !empty($payment)): ?>
<?php foreach($payment as $item): ?>
<div class="order_line">
<div class="fin_cell c_one">
<span style="display:none;">
<a href="#"><?= $t->_('orders') ?> №12345</a>
</span>
</div>
<div class="fin_cell c_two money">
<?php if($item['amount'] > 0): ?>
<span class="count" data-count="<?= $item['amount'] ?>"><?= $item['amount'] ?></span> грн.
<?php endif; ?>
</div>
<div class="fin_cell c_two money">
<?php if($item['amount'] < 0): ?>
<span class="pay" data-pay="<?= -$item['amount'] ?>"><?= -$item['amount'] ?></span> грн.
<?php endif; ?>
</div>
<div style="color: #333" class="fin_cell c_two money">
<?= $t->_($item['type']) ?>
</div>
<div style="color: #333" class="date fin_cell c_two money" data-date="<?= date('d.m.Y', strtotime($item['date'])) ?>">
<?= date('d.m.Y', strtotime($item['date'])) ?>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
<div class="lines_final">
<div class="line final_one">
<div style="box-sizing:border-box;height: 39px;width: 171px;max-width: 171px" class="fin_cell c_one"><span><?= $t->_('sum') ?></span></div>
<div class="fin_cell c_two money"><span id="sum"><?= $sum_order ?></span> грн.</div>
<div class="fin_cell c_two money"><span id="paid"><?= $sum_paid ?></span> грн.</div>
</div>
<div class="line final_two">
<div class="fin_cell c_one"><span>Сальдо</span></div>
<div class="fin_cell balance"><span id="result"><?= $sum_paid - $sum_order ?></span> грн.</div>
</div>
</div>
</div>
</div>
</section>
<script src="/plugins/daterangepicker/moment.js"></script>
<script src="/plugins/daterangepicker/daterangepicker.js"></script>
<script>
moment.locale('ru', {
months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
monthsShort :'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_'),
weekdays : 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
longDateFormat : {
LT : 'HH:mm',
LTS : 'HH:mm:ss',
L : 'DD.MM.YYYY',
LL : 'D MMMM YYYY г.',
LLL : 'D MMMM YYYY г., HH:mm',
LLLL : 'dddd, D MMMM YYYY г., HH:mm'
},
calendar : {
sameDay: '[Сегодня в] LT',
nextDay: '[Завтра в] LT',
lastDay: '[Вчера в] LT',
nextWeek: function (now) {
if (now.week() !== this.week()) {
switch (this.day()) {
case 0:
return '[В следующее] dddd [в] LT';
case 1:
case 2:
case 4:
return '[В следующий] dddd [в] LT';
case 3:
case 5:
case 6:
return '[В следующую] dddd [в] LT';
}
} else {
if (this.day() === 2) {
return '[Во] dddd [в] LT';
} else {
return '[В] dddd [в] LT';
}
}
},
relativeTime : {
future : 'через %s',
past : '%s назад',
s : 'несколько секунд',
h : 'час',
d : 'день',
M : 'месяц',
y : 'год'
},
ordinalParse: /\d{1,2}-(й|го|я)/,
ordinal: function (number, period) {
switch (period) {
case 'M':
case 'd':
case 'DDD':
return number + '-й';
case 'D':
return number + '-го';
case 'w':
case 'W':
return number + '-я';
default:
return number;
}
},
meridiemParse: /ночи|утра|дня|вечера/i,
isPM : function (input) {
return /^(дня|вечера)$/.test(input);
},
// in case the meridiem units are not separated around 12, then implement
// this function (look at locale/id.js for an example)
// meridiemHour : function (hour, meridiem) {
// return /* 0-23 hour, given meridiem token and hour 1-12 */
// },
},
meridiem : function (hour, minute, isLower) {
if (hour < 4) {
return 'ночи';
} else if (hour < 12) {
return 'утра';
} else if (hour < 17) {
return 'дня';
} else {
return 'вечера';
}
},
week : {
dow : 1, // Monday is the first day of the week.
doy : 7 // The week that contains Jan 1st is the first week of the year.
}
});
moment.locale('ru');
//Date range picker
var full_saldo = <?= $sum_paid - $sum_order ?>;
var result = [];
$(".order_lines").find(".order_line").each(function(){
result[result.length] = this;
});
var min_date = $(result[0]).find(".date").data('date');
var conf = {startDate:moment(min_date, "DD.MM.YYYY"), format: 'DD.MM.YYYY',locale:
{
applyLabel: "<?= $t->_('apply')?>",
cancelLabel: "<?= $t->_('cancel')?>",
fromLabel: "<?= $t->_('from_month') ?>",
toLabel: "По",
weekLabel: 'Н'
}};
$('#reservation').daterangepicker(conf);
$('#DateReservation').daterangepicker(conf);
$("body").on("click",".applyBtn",function(){
$(".line.final_two.added").remove();
var start = $("input[name=daterangepicker_start]").val();
var end = $("input[name=daterangepicker_end]").val();
var count = result.length;
var sum = 0;
var paid = 0;
for(var i=0; i<count; i++){
var date_val = $(result[i]).find(".date").data('date');
if(moment(date_val, 'DD.MM.YYYY' ) >= moment(start, 'DD.MM.YYYY' ) && moment(date_val, 'DD.MM.YYYY' ) <= moment(end, 'DD.MM.YYYY' ) ) {
$(result[i]).css("display","block");
sum += $(result[i]).find(".count").data("count") ? +$(result[i]).find(".count").data("count") : 0;
paid += $(result[i]).find(".pay").data("pay") ? +$(result[i]).find(".pay").data("pay") : 0;
} else {
$(result[i]).css("display","none");
}
}
$("#paid").html(paid.toFixed(1));
$("#sum").html(sum.toFixed(1));
$("#result").html((sum-paid).toFixed(1));
$(".line.final_two .fin_cell.c_one span").html('Сальдо <?= $t->_('saldo_period') ?>');
$(".fin_content .lines_final").append('<div class="line final_two added"><div class="fin_cell c_one"><span>Сальдо</span></div><div class="fin_cell balance"><span id="result">'+full_saldo+'</span> грн.</div></div>');
});
$('#DateReservation');
$('.orders_data_request').click(function(){
var date_value = $('#reservation').val();
$("#DateReservation").val(date_value);
})
</script>