Всем привет.
Работаю с webasyst.
Ссылка на видео с проблемой:
https://yadi.sk/i/wF2deCMhEyfjsQ
Содержимое файла .html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$wa->appName()} — {$wa->accountName()}</title>
{$wa->css()}
<link type="text/css" rel="stylesheet" href="{$wa_app_static_url}css/reports.css?v{$wa->version()}">
<link rel="stylesheet" type="text/css" href="/wa-content/js/DataTables/datatables.min.css"/>
<script type="text/javascript" src="{$wa_url}wa-content/js/jquery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="{$wa_url}wa-content/js/jquery-wa/wa.core.js?v{$wa->version(true)}"></script>
<script type="text/javascript" src="/wa-content/js/jquery-ui/jquery-ui.custom.min.js?v1.9.7.287"></script>
<script src="/wa-content/js/jquery-ui/i18n/jquery.ui.datepicker-ru_RU.js"></script>
<script type="text/javascript" src="{$wa_app_static_url}js/reports.js?v{$wa->version()}"></script>
<script type="text/javascript" src="/wa-content/js/DataTables/datatables.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#s-product-stocks').dataTable({
"bPaginate": false,
"bLengthChange": false,
"bFilter": true,
"bInfo": false,
"bAutoWidth": false
});
$( '.from' ).datepicker({
dateFormat: "yy-mm-dd",
});
$( '.before' ).datepicker({
dateFormat: "yy-mm-dd",
});
});
</script>
</head>
<body>
<div id="wa">
{$wa->header()}
<div id="wa-app">
<div class="sidebar left200px">
<div class="block">
<ul class="menu-v with-icons">
<li class="">
<a href="/webasyst/reports/" class="bold"><i class="icon16 smiley"></i>Отчет по продажам</a>
</li>
<li class="">
<a href="#" class="bold"><i class="icon16 smiley"></i>Отчеты по монтажу</a>
</li>
<li class="">
<a href="/webasyst/reports/?action=DDS" class="bold"><i class="icon16 smiley"></i>ДДС</a>
</li>
<li class="">
<a href="/webasyst/reports/?action=cashbox" class="bold"><i class="icon16 smiley"></i>Манибоксы</a>
</li>
<li class="">
<a href="/webasyst/reports/?action=consumption" class="bold"><i class="icon16 smiley"></i>Справочник расходов</a>
</li>
<li class="selected">
<a href="/webasyst/reports/templates/?action=pay" class="bold"><i class="icon16 smiley"></i>Зарплатный отчет</a>
</li>
</ul>
</div>
<div class="pay_form">
<h2>Отчет в указанном интервале</h2>
<form class="pay_period">
<input type="text" class="from" name="pay_update_datetime_from" placeholder="От">
<input type="text" class="before" name="pay_update_datetime_before" placeholder="До">
<button type="submit">Поиск</button>
</form>
</div>
</div>
<div class="content left200px">
<div id="content">
<div style="display: flex; flex-direction: column;" class="block">
<h1>Зарплатный отчет</h1>
<table class="zebra" id="s-product-stocks">
<thead>
<tr>
<td>№</td>
<td>Менеджер</td>
<td>Создан</td>
<td>Сумма</td>
<td>ФИО</td>
<td>Статус</td>
<td>Дата оплаты</td>
<td>Себестоимость</td>
<td>Маржинальность %</td>
<td>ПР/МН/ДС</td>
<td>Прибыль</td>
<td>Сумма для расчета з/п</td>
<td>4%</td>
</tr>
</thead>
<tbody>
{foreach $orders as $i}
<tr>
<td><a target="_blank" href="/webasyst/shop/#/orders/state_id=new|processing|paid&id={$i.order_id}/">{$i.order_id}</a></td>
<td>{$i.manager}</td>
<td>{$i.create_datetime}</td>
<td>{$i.total}</td>
<td></td>
<td>{$i.state_id}</td>
<td class="complete_date">{$i.complete_date}</td>
<td>{$i.all_purchase}</td>
<td>{$i.marginality}</td>
<td>{$i.shipping}</td>
<td>{$i.profit}</td>
<td>{$i.temp_pay}</td>
<td class="pay">{$i.pay}</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<style>table {
border-collapse: collapse;
}
table, th, td {
border: 1px solid black;
padding:5px;
}</style>
</body>
</html>
Содержимое файла .action.php
<?php
class reportsBackendPayAction extends waViewAction
{
public function execute()
{
$update_datetime_from = waRequest::get('pay_update_datetime_from');
$update_datetime_before = waRequest::get('pay_update_datetime_before');
if (!$update_datetime_from) {
$update_datetime_from = date('Y-m-01');
}
if (!$update_datetime_before) {
$day_count = date('t', time());
$update_datetime_before = date('Y-m-'.$day_count.'');
}
wa('shop');
$hash = 'search/update_datetime>='.$update_datetime_from.'%2000:00:00%26update_datetime<='.$update_datetime_before.'%2023:59:59%26state_id=completed';
$collection = new shopOrdersCollection($hash);
$orders = $collection->getOrders('id', '999');
$order_model = new shopOrderModel();
$orderItems_model = new shopOrderItemsModel();
$orders_out = array();
foreach ($orders as $o) {
$order = $order_model->getById($o['id']);
$items = $orderItems_model->getByField('order_id', $o['id'], true);
$items_count = $orderItems_model->countByField('order_id', $o['id']);
$all_purchase = 0;
$profit = 0;
$temp_pay = 0;
$pay = 0;
$marginality = 0;
foreach ($items as $item) {
$purchase_price = $item['purchase_price'] * $item['quantity'];
$all_purchase += $purchase_price;
}
$profit = $order['total'] - $order['shipping'];
$profit -= $all_purchase;
$temp_pay = $order['total'] - $order['shipping'];
$pay = $temp_pay * 0.04;
$marginality = (($order['total'] - $all_purchase)/$all_purchase)*100;
$marginality = round ($marginality,2);
if ($all_purchase == 0.0000) {
$all_purchase = 'Не указана себестоимость!';
$marginality = 'Не указана себестоимость!';
$profit = 'Не указана себестоимость!';
$markup = 'Не указана себестоимость!';
}
$orders_out[] = array(
'order_id' => $order['id'],
'manager' => $order ['manager'],
'create_datetime' => $order['create_datetime'],
'total' => $order['total'],
'state_id' => $order['state_id'],
'complete_date' => $order['update_datetime'],
'all_purchase' => $all_purchase,
'marginality' => $marginality,
'shipping' => $order['shipping'],
'profit' => $profit,
'temp_pay' => $temp_pay,
'pay' => $pay,
);
}
$this->view->assign('orders', $orders_out);
}
}
Содержимое файла .js
$( document ).ready(function() {
$('.period').submit(function() {
data = $(this).serialize();
$.ajax({
type: "POST",
url: "/webasyst/reports/",
data: data
});
});
$('.pay_period').submit(function(){
form_data = $(this).serialize();
$.ajax({
type: "POST",
url: "/webasyst/reports/templates/?action=pay",
data: form_data
});``
});
});