05.06.2018, 13:16. Показов 2057. Ответов 1
Вот как-то так это все работает.
При нажатии кнопок
| JavaScript |
1
2
| <button class="btn btn-default" type="button" ng-click="printReport('report_calculation_1', reports, period)"><i class="fa fa-print"></i> Печать</button>
<button class="btn btn-default" type="button" ng-click="excelReport('report_calculation_1', reports, period)"><i class="fa fa-table"></i> Сохранить в exel</button> |
|
идет печать файла или сохранение в excel
но этого не происходит так, как нужно
нажимаю печать выводится ВСЁ без учета формы сортировки.... в ошибках консоли выпадает что-то типа:
vreport_calculationundefinedundefined
Нажимаю сохранить в excel в консоли выводится типа:
| JavaScript |
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
| {module: "excel_report", action: "report_calculation_1", table: "{"from":"2018-05-01","to":"2018-06-06","storage_id…":"82","xdate":"2018-06-06","zdate":"2018-05-01"}", object: Array(830)}
action
:
"report_calculation_1"
module
:
"excel_report"
object
:
Array(830)
[0 … 99]
[100 … 199]
[200 … 299]
[300 … 399]
[400 … 499]
[500 … 599]
[600 … 699]
[700 … 799]
[800 … 829]
length
:
830
__proto__
:
Array(0)
table
:
"{"from":"2018-05-01","to":"2018-06-06","storage_idstorage":"82","xdate":"2018-06-06","zdate":"2018-05-01"}"
__proto__
:
Object |
|
| PHP |
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
| <?php
namespace lib\library\class_map;
use lib\core\PdoAdapter;
use lib\library\class_map\report;
class excel_report {
public $table;
function __construct($table = null) {
$this->_db = PdoAdapter::get_instance_db();
$this->report = new report();
$this->table = $table;
}
function report_tasks_deadline_excel_report($data) {
$data = json_decode($data['object']);
$filter = json_decode($this->table);
// $obj = array("object" => null, 'json' => false);
// $object = $this->report->get_tasks_deadline_report($obj);
;
if (count($data) > 0) {
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=tasks_" . date('y-m-d') . ".xls");
include_once BASE_DIR . '/templates/printer/report_tasks_deadline.php';
}
}
function report_calculation_1_excel_report($data) {
$data = json_decode($data['object']);
$filter = json_decode($this->table);
// $obj = array("object" => null, 'json' => false);
// $object = $this->report->get_tasks_deadline_report($obj);
;
if (count($data) > 0) {
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=goods_" . date('y-m-d') . ".xls");
include_once BASE_DIR . '/templates/printer/report_calculation.php';
}
}
function report_calculation_excel_report($data)
$data = json_decode($data['object']);
$filter = json_decode($this->table);
$obj = array("object" => null, 'json' => false);
$object = $this->report->report_calculationCtrl($obj);
;
if (count($data) > 0) {
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=report.xls");
include_once BASE_DIR . '/templates/printer/report_calculation_1.php';
}
}
function report_project_tasks_deadline_excel_report($data) {
$data = json_decode($data['object']);
$filter = json_decode($this->table);
// $obj = array("object" => null, 'json' => false);
// $object = $this->report->get_project_tasks_deadline_report($obj);
if (count($data) > 0) {
header("Content-type: application/vnd-ms-excel");
header("Content-Disposition: attachment; filename=project_". date('y-m-d') .".xls");
include_once BASE_DIR . '/templates/printer/report_project_tasks_deadline.php';
}
}
} |
|
В report_calculation_1.php вывожу
| PHP |
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
| <h3>Отчет - Остатки товаров</h3>
<h4>Период: <?= $filter->from; ?> - <?= $filter->to; ?> </h4>
<table border="1" cellpadding="5" cellspacing="0">
<thead>
<tr>
<th></th>
<th>Товар </th>
<th>Поступило</th>
<th>Расход</th>
<th>На конец</th>
<th>Цена зак</th>
<th>Цена про</th>
</tr>
</thead>
<tbody>
<?php
// $sum = 0;
$i = 0;
foreach ($data as $item) {
$i++;
?>
<tr>
<td>
<?= $i; ?>
</td>
<td>
<?= $item->goods_name; ?>
</td>
<td>
<?= $item->plus + $item->invent; ?>
</td>
<td>
<?= $item->minus + $item->spisanie + $item->perem; ?>
</td>
<td>
<?= $item->to_balance; ?>
</td>
<td>
<?= $item->end_cost_z; ?>
</td>
<td>
<?= $item->end_cost_p; ?>
</td>
</tr>
<?php } ?>
</tbody>
</table> |
|
в шаблон angular вывожу
| HTML5 |
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
| <dialog ng-controller="report_calculationCtrl">
<div class="static-filter">
<form ng-submit='getReport(period)'>
<input ng-model="search" type='text' placeholder="Найти по имени">
<input ng-model="period.from" type="text" datepicker="" placeholder="Период с">
<input ng-model="period.to" type="text" datepicker="" placeholder="Период по">
<select ng-model="period.storage_idstorage" ng-options="s.idstorage as s.storage_name for s in data.storage">
<option value="" disabled="" selected="">Склад</option>
</select>
<button class="btn btn-default" type="button" ng-click="period.storage_idstorage = undefined">x</button>
<select ng-model="goods_cat" ng-options="g.idgoods_cat as g.goods_cat_name for g in data.goods_cat">
<option value="" disabled="" selected="">Категория</option>
</select>
<button class="btn btn-default" type="button" ng-click="goods_cat = undefined">x</button>
<button type="submit" class="btn btn-default">Сформировать</button>
</form>
<hr>
<form ng-submit='print(reports)' ng-if="reports" class="animated fadeIn">
<button class="btn btn-default" type="button" ng-click="printReport('report_calculation_1', reports, period)"><i class="fa fa-print"></i> Печать</button>
<button class="btn btn-default" type="button" ng-click="excelReport('report_calculation_1', reports, period)"><i class="fa fa-table"></i> Сохранить в exel</button>
</form>
</div>
<div pagination ng-from="from" ng-to="to" ng-length="(reports| filter:search|filter:{goods_cat_idgoods_cat:goods_cat}).length" ng-limit="500" class="text-center">
</div>
<div class="static-view">
<table class="dataTable">
<thead>
<tr>
<th></th>
<th ng-click="predicate = 'goods_name';
reverse = !reverse">Товар </th>
<th>Поступило</th>
<th>Расход</th>
<th ng-click="predicate = 'to_balance';
reverse = !reverse">Остаток</th>
<th>Цена зак</th>
<th>Цена про</th>
</tr>
</thead>
<tbody class="undertable">
<tr ng-repeat="tr in reports| filter:search|filter:{goods_cat_idgoods_cat:goods_cat}|limitTo:500:from|orderBy:pridicate:reverse track by $index" ng-if="tr.from_balance != 0 || tr.invent != 0 || tr.plus != 0 || tr.minus != 0 || tr.to_balance != 0"
ng-click="get('vmin_documents_goods', 'get_documents_goods', {period: period, id: tr.idgoods})" >
<td>
{{$index + 1}}
</td>
<td>{{tr.goods_name}}</td>
<td >{{((tr.plus * 1) + (tr.invent * 1))}}</td>
<td >{{((tr.minus * 1) + (tr.perem * 1) + (tr.spisanie * 1))}}</td>
<td ng-class="{negative:tr.to_balance < 0,positive:tr.to_balance > 0}">
{{tr.to_balance}}
</td>
<td>{{tr.end_cost_z}}</td>
<td>{{tr.end_cost_p}}</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3"><b> Всего на начало периода по закупке:</b></td>
<td colspan="3"><b> {{get_begin_cost_zSum()}}</b></td>
</tr>
<tr>
<td colspan="3"><b> Всего на конец периода по закупке:</b></td>
<td colspan="3"><b> {{get_end_cost_zSum()}}</b></td>
</tr>
<tr>
<td colspan="3"><b> Баланс по закупке:</b></td>
<td colspan="3">
<b> {{(get_begin_cost_zSum() - get_end_cost_zSum()).toFixed(2)}}</b>
</td>
</tr>
<tr>
<td colspan="3"><b> Всего на начало периода по продаже:</b>
</td>
<td colspan="3"><b> {{get_begin_cost_pSum()}}</b></td>
</tr>
<tr>
<td colspan="3">
<b> Всего на конец периода по продаже:</b>
</td>
<td colspan="3">
<b> {{get_end_cost_pSum()}}</b>
</td>
</tr>
<tr>
<td colspan="3">
<b> Баланс по продаже:</b>
</td>
<td colspan="3">
<b> {{(get_begin_cost_pSum() - get_end_cost_pSum()).toFixed(2)}}</b>
</td>
</tr>
<tr>
<td colspan="3">
<b> Продано:</b>
</td>
<td colspan="3">
<b> {{get_fact_minus()}}</b>
</td>
</tr>
<tr>
<td colspan="3">
<b> Прибыльность:</b>
</td>
<td colspan="3">
<b> {{get_fact_plus()}}</b>
</td>
</tr>
<tr>
<td colspan="3">
<b> Средняя наценка:</b>
</td>
<td colspan="3">
<b> {{get_fact_procent()}} %</b>
</td>
</tr>
</tfoot>
</table>
</div>
<div class="clearfix"></div>
</dialog> |
|
Добавлено через 58 секунд
проще говоря - выводятся в excel и на печать данные
без учета формы сортировки