Joywork/ajax/getGridTableSalesPlan.php

181 lines
8.2 KiB
PHP
Raw Normal View History

2026-05-22 20:21:54 +02:00
<?php
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
$period = 'all';
$whereTasks = "";
$bd_period = '';
$bd_do_period = '';
if(isset($_POST['period'])){
$period = $_POST['period'];
}
$onDate = null;
$offDate = null;
if(isset($_POST['onDate'])){
$onDate = $_POST['onDate'];
}
if(isset($_POST['offDate'])){
$offDate = $_POST['offDate'];
}
$dates = getPeriod($period, $onDate, $offDate);
$mounthArrray = ["", "Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь" ];
//var_dump($dates);
?>
<div class="">
<div id="export_sales_plan" style="margin-left: 20px; " class="crm__new-client">
<a style="padding: 3px 15px 6px; background: -moz-linear-gradient(top, #fff, #f5f5f5);
background: -webkit-linear-gradient(top, #fff, #f5f5f5);
background: -o-linear-gradient(top, #fff, #f5f5f5);
background: -ms-linear-gradient(top, #fff, #f5f5f5);
background: linear-gradient(top, #fff, #f5f5f5);
cursor: pointer;
position: absolute;
margin-top: 17px;
border: 1px solid #d0d0d0; border-bottom: 1px solid #d0d0d0;" href="javascript:{}" class="jw__g-button">Экспорт в Excel</a>
</div>
<div class="buttons-toolbar" style="padding-top: 15px">
</div>
<!-- <div id="table-sales_plan_list-selection-fixed" class="bootstrap-table bootstrap4" style="display:none; position:absolute;z-index: 999;">
<div class="fixed-table-container fixed-height" style="border-bottom: 0;">
<table style="border-bottom: 0px;" class="table table-bordered table-hover">
<thead style="border-bottom: 0px;"></thead>
</table>
</div>
<div class="fixed-table-body">
<table class="table table-bordered table-hover">
<tbody>
</tbody>
</table>
</div>
</div> -->
<table class="table"
id="table-sales_plan_list-selection"
data-locale="ru-RU"
data-height="650"
data-show-refresh="true"
data-show-columns="true"
data-buttons-toolbar=".buttons-toolbar"
data-show-columns-toggle-all="true"
data-ajax="ajaxRequestSalesPlan"
data-loading-template="loadingTemplate"
data-show-footer="true"
>
<thead>
<tr>
<th data-field="fio" data-formatter="sourceFormatter" data-cell-style="cellStyle" data-class="table_white" data-switchable="false" data-footer-formatter="itogFormatter" rowspan="4">Сотрудник</th>
<th data-field="expenditure" colspan="7" data-cell-style="cellStyle" data-class="table_white">План на период</th>
<?php
foreach($dates['months'] as $month){
?>
<th data-field="months_<?=$month?>" colspan="7" data-cell-style="cellStyle" data-class="table_white"><?=$mounthArrray[$month]?></th>
<?php
}
?>
</tr>
<tr>
<th data-field="plan" colspan="2" data-cell-style="cellStyle" data-class="table_white">План</th>
<th data-field="fact" colspan="5" data-cell-style="cellStyle" data-class="table_white">Фактическое выполнение</th>
<?php
foreach($dates['months'] as $month){
?>
<th data-field="plan_<?=$month?>" colspan="2" data-cell-style="cellStyle" data-class="table_white">План</th>
<th data-field="fact_<?=$month?>" colspan="5" data-cell-style="cellStyle" data-class="table_white">Фактическое выполнение</th>
<?php
}
?>
</tr>
<tr>
<th data-cell-style="cellStyle" data-class="table_white" rowspan="2" data-field="summa_commission" data-sortable="true" data-sorter="salesPlanSorter" data-footer-formatter="priceFormatter">Сумма комиссии</th>
<th data-cell-style="cellStyle" data-class="table_white" rowspan="2" data-footer-formatter="priceFormatter" data-field="deals_quantity" data-sortable="true" data-sorter="salesPlanSorter">Количество сделок</th>
<th data-field="real_summa_commission" data-sortable="true" data-sorter="salesPlanSorter" rowspan="2" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="priceFormatter">Сумма комиссии</th>
<th data-field="real_deals_quantity" data-sortable="true" data-sorter="salesPlanSorter" rowspan="2" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="priceFormatter">Количество сделок</th>
<th data-field="real_pr" data-sortable="true" data-sorter="salesPlanSorter" rowspan="2" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="procentFormated">% выполнения</th>
<th data-field="making" colspan="2" data-cell-style="cellStyle" data-class="table_white">Задатки</th>
<?php
foreach($dates['months'] as $month){
?>
<th data-field="summa_commission_<?=$month?>" data-sortable="true" data-sorter="salesPlanSorter" rowspan="2" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="priceFormatter">Сумма комиссии</th>
<th data-field="deals_quantity_<?=$month?>" data-sortable="true" data-sorter="salesPlanSorter" rowspan="2" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="priceFormatter">Количество сделок</th>
<th data-field="real_summa_commission_<?=$month?>" data-sortable="true" data-sorter="salesPlanSorter" rowspan="2" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="priceFormatter">Сумма комиссии</th>
<th data-field="real_deals_quantity_<?=$month?>" data-sortable="true" data-sorter="salesPlanSorter" rowspan="2" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="priceFormatter">Количество сделок</th>
<th data-field="real_pr_<?=$month?>" data-sortable="true" data-sorter="salesPlanSorter" rowspan="2" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="procentFormated">% выполнения</th>
<th data-field="making_<?=$month?>" data-cell-style="cellStyle" data-class="table_white" colspan="2">Задатки</th>
<?php
}
?>
</tr>
<tr>
<th data-field="makings" data-sortable="true" data-sorter="salesPlanSorter" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="priceFormatter">Сумма</th>
<th data-field="makings_total" data-sortable="true" data-sorter="salesPlanSorter" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="priceFormatter">Количество</th>
<?php
foreach($dates['months'] as $month){
?>
<th data-field="makings_<?=$month?>" data-sortable="true" data-sorter="salesPlanSorter" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="priceFormatter">Сумма</th>
<th data-field="makings_total_<?=$month?>" data-sortable="true" data-sorter="salesPlanSorter" data-cell-style="cellStyle" data-class="table_white" data-footer-formatter="priceFormatter">Количество</th>
<?php
}
?>
</tr>
</thead>
</table>
</div>
<?php
$sql = 'SELECT item_list FROM `reclame_table` WHERE id_user='.$_SESSION['id']. ' AND id_table=9';
$reSql = mysql_query($sql);
$res = mysql_fetch_assoc($reSql);
$resList = $res['item_list'];
?>
<script>
function resList() {
let res = '<?=$resList?>';
return res;
}
// resList('<?=$resList?>');
function saveTableColumn(_this) {
let arr = [];
let idUser = <?= $_SESSION['id'];?>;
_this.closest('.dropdown-menu').find('input').each(function(){
$(this).is(':checked') ? arr.push($(this).attr('data-field')) : '';
})
console.log(arr);
console.log(_this.closest('.dropdown-menu').find('input'));
$.ajax({
url:"/ajax/getReclameTable.php",
method: 'get',
dataType: 'html',
data: {arrPunkt: arr, idTable: 9, idUser: idUser},
success: function(data) {
console.log(data);
}
});
}
</script>