|
|
@@ -16,90 +16,99 @@ class Route_DealsSales extends RouteBase {
|
|
|
SE_Layout::menu();
|
|
|
|
|
|
?>
|
|
|
-TODO: ...
|
|
|
<?php
|
|
|
$this->legacy_DEALS_SALES();
|
|
|
|
|
|
SE_Layout::dol();
|
|
|
}
|
|
|
|
|
|
- public function legacy_DEALS_SALES() {
|
|
|
-
|
|
|
- $id_telboxes = V::get('id_telboxes', '', $_REQUEST);
|
|
|
- $id_companies = V::get('id_companies', '', $_REQUEST, 'int');
|
|
|
- $task = V::get('_task', '', $_REQUEST);
|
|
|
- switch ($task) {
|
|
|
- case 'TYPESPECIAL': {
|
|
|
- $DBG = ('1' == V::get('DBG', '', $_REQUEST));
|
|
|
- header("Content-type: application/json");
|
|
|
-
|
|
|
- $fld = V::get('fld', '', $_GET);
|
|
|
- switch ($fld) {
|
|
|
- case 'id_telboxes': {
|
|
|
- Lib::loadClass('TypespecialVariable');
|
|
|
- $typeSpecialTelboxes = TypespecialVariable::getInstance(-1, '__TELBOXES_NAME');
|
|
|
-
|
|
|
- $query = V::get('q', '', $_REQUEST);
|
|
|
- $rawRows = null;
|
|
|
- $rows = $typeSpecialTelboxes->getValuesWithExports($query);
|
|
|
- if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
|
|
|
- foreach ($rows as $kID => $vItem) {
|
|
|
- $itemJson = new stdClass();
|
|
|
- $itemJson->id = $vItem->id;
|
|
|
- $itemJson->name = $vItem->param_out;
|
|
|
- if (!empty($vItem->exports)) {
|
|
|
- $itemJson->exports = $vItem->exports;
|
|
|
- }
|
|
|
- $jsonData[] = $itemJson;
|
|
|
+ public function typespecialAction() {
|
|
|
+ $DBG = ('1' == V::get('DBG', '', $_REQUEST));
|
|
|
+ header("Content-type: application/json");
|
|
|
+
|
|
|
+ $fld = V::get('fld', '', $_GET);
|
|
|
+ switch ($fld) {
|
|
|
+ case 'id_telboxes': {
|
|
|
+ Lib::loadClass('TypespecialVariable');
|
|
|
+ $typeSpecialTelboxes = TypespecialVariable::getInstance(-1, '__DEALS_SALES_TELBOXES_NAME');
|
|
|
+
|
|
|
+ $query = V::get('q', '', $_REQUEST);
|
|
|
+ $rawRows = null;
|
|
|
+ $rows = $typeSpecialTelboxes->getValuesWithExports($query);
|
|
|
+ if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
|
|
|
+ foreach ($rows as $kID => $vItem) {
|
|
|
+ $itemJson = new stdClass();
|
|
|
+ $itemJson->id = $vItem->id;
|
|
|
+ $itemJson->name = $vItem->param_out;
|
|
|
+ if (!empty($vItem->exports)) {
|
|
|
+ $itemJson->exports = $vItem->exports;
|
|
|
}
|
|
|
- echo json_encode($jsonData);
|
|
|
+ $jsonData[] = $itemJson;
|
|
|
}
|
|
|
- break;
|
|
|
- case 'id_companies': {
|
|
|
- Lib::loadClass('TypespecialVariable');
|
|
|
- $typeSpecialCompanies = TypespecialVariable::getInstance(-1, '__COMPANIES');
|
|
|
-
|
|
|
- $query = V::get('q', '', $_REQUEST);
|
|
|
- $rawRows = null;
|
|
|
- $rows = $typeSpecialCompanies->getValuesWithExports($query);
|
|
|
- if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
|
|
|
- foreach ($rows as $kID => $vItem) {
|
|
|
- $itemJson = new stdClass();
|
|
|
- $itemJson->id = $vItem->id;
|
|
|
- $itemJson->name = $vItem->param_out;
|
|
|
- if (!empty($vItem->exports)) {
|
|
|
- $itemJson->exports = $vItem->exports;
|
|
|
- }
|
|
|
- $jsonData[] = $itemJson;
|
|
|
+ echo json_encode($jsonData);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'id_companies': {
|
|
|
+ Lib::loadClass('TypespecialVariable');
|
|
|
+ $typeSpecialCompanies = TypespecialVariable::getInstance(-1, '__COMPANIES');
|
|
|
+
|
|
|
+ $query = V::get('q', '', $_REQUEST);
|
|
|
+ $rawRows = null;
|
|
|
+ $rows = $typeSpecialCompanies->getValuesWithExports($query);
|
|
|
+ if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
|
|
|
+ foreach ($rows as $kID => $vItem) {
|
|
|
+ $itemJson = new stdClass();
|
|
|
+ $itemJson->id = $vItem->id;
|
|
|
+ $itemJson->name = $vItem->param_out;
|
|
|
+ if (!empty($vItem->exports)) {
|
|
|
+ $itemJson->exports = $vItem->exports;
|
|
|
}
|
|
|
- echo json_encode($jsonData);
|
|
|
+ $jsonData[] = $itemJson;
|
|
|
}
|
|
|
- break;
|
|
|
- }
|
|
|
- exit;
|
|
|
+ echo json_encode($jsonData);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public function legacy_DEALS_SALES() {
|
|
|
+
|
|
|
+ $id_telboxes = V::get('id_telboxes', '', $_REQUEST);
|
|
|
+ $id_companies = V::get('id_companies', '', $_REQUEST, 'int');
|
|
|
+
|
|
|
SE_Layout::menu();
|
|
|
|
|
|
Lib::loadClass('TypespecialVariable');
|
|
|
- $typeSpecialTelboxes = TypespecialVariable::getInstance(-1, '__TELBOXES_NAME');
|
|
|
+ $typeSpecialTelboxes = TypespecialVariable::getInstance(-1, '__DEALS_SALES_TELBOXES_NAME');
|
|
|
$typeSpecialCompanies = null;// TypespecialVariable::getInstance(-1, '__COMPANIES');
|
|
|
|
|
|
$obroty = array();
|
|
|
+ $marki = array();
|
|
|
+ $obrotyToMarki = array();
|
|
|
if (!empty($id_telboxes) || $id_companies > 0) {
|
|
|
$db = DB::getDB();
|
|
|
$sqlWhere = array();
|
|
|
//if (!empty($id_telboxes)) $sqlWhere[] = " d.`T_TELBOX_NEIGHBOUR_IN`='{$id_telboxes}' ";
|
|
|
- if (!empty($id_telboxes)) $sqlWhere[] = " o.`T_TELBOX_NEIGHBOUR_IN`='{$id_telboxes}' ";
|
|
|
+ if (!empty($id_telboxes)) {
|
|
|
+ if (false !== strpos($id_telboxes, ': ')) {
|
|
|
+ $parts = explode(': ', $id_telboxes, 2);
|
|
|
+ $sqlWhere[] = " o.`T_TELBOX_NEIGHBOUR_IN`='{$parts[0]}' ";
|
|
|
+ // $sqlWhere[] = " o.`marka`='{$parts[1]}' ";
|
|
|
+ } else {
|
|
|
+ $sqlWhere[] = " o.`T_TELBOX_NEIGHBOUR_IN`='{$id_telboxes}' ";
|
|
|
+ }
|
|
|
+ }
|
|
|
//if ($id_companies > 0) $sqlWhere[] = " d.`ID_BILLING_USERS`='{$id_companies}' ";
|
|
|
$sqlWhere = (!empty($sqlWhere))? implode(" or ", $sqlWhere) : '';
|
|
|
$sql = "select o.`ID`
|
|
|
-- , d.`T_TELBOX_NEIGHBOUR_IN`
|
|
|
, o.`T_TELBOX_NEIGHBOUR_IN`
|
|
|
, o.`ID_DEALS_TABLE`
|
|
|
- , o.`SALES_DATE`
|
|
|
+ -- , o.`SALES_DATE`
|
|
|
+ , o.`SALES_YEAR`
|
|
|
+ , o.`SALES_MONTH`
|
|
|
, o.`SALES_VALUE`
|
|
|
+ , o.`marka`
|
|
|
from `DEALS_SALES` as o
|
|
|
-- join `DEALS_TABLE` as d on (d.`ID`=o.`ID_DEALS_TABLE`)
|
|
|
where
|
|
|
@@ -108,27 +117,53 @@ TODO: ...
|
|
|
if(V::get('DBG','',$_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;"> (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'</pre>';}
|
|
|
$res = $db->query($sql);
|
|
|
while ($r = $db->fetch($res)) {
|
|
|
- $year = substr($r->SALES_DATE, 0, 4);
|
|
|
- $month = substr($r->SALES_DATE, 5, 2);
|
|
|
+ $year = $r->SALES_YEAR;
|
|
|
+ $month = sprintf("%02d", $r->SALES_MONTH);
|
|
|
$obroty[$r->ID_DEALS_TABLE][$year][$month] = $r->SALES_VALUE;
|
|
|
+ $marki[$r->marka] = true;
|
|
|
+ $obrotyToMarki[$year][$month] = $r->marka;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ DBG::_('DBG', '>0', "marki", $marki, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ DBG::_('DBG', '>0', "obrotyToMarki", $obrotyToMarki, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+
|
|
|
+ $markiOut = array();
|
|
|
+ {
|
|
|
+ $markiLabels = array('primary', 'success', 'warning', 'danger', 'default');
|
|
|
+ // <span class="label label-default">Default</span>
|
|
|
+ reset($markiLabels);
|
|
|
+ foreach ($marki as $marka => $vBool) {
|
|
|
+ $markiOut[$marka] = current($markiLabels);
|
|
|
+ if (!next($markiLabels)) reset($markiLabels);
|
|
|
+ }
|
|
|
+ }// Default Primary Success Info Warning Danger
|
|
|
+
|
|
|
$monthsOut = array();
|
|
|
for ($i = 0; $i < 12; $i++) $monthsOut[] = sprintf("%02d", $i + 1);
|
|
|
|
|
|
?>
|
|
|
+<style type="text/css">
|
|
|
+ .cell_marka_primary { background-color: #d9edf7; }
|
|
|
+ .cell_marka_success { background-color: #dff0d8; }
|
|
|
+ .cell_marka_warning { background-color: #fcf8e3; }
|
|
|
+ .cell_marka_danger { background-color: #f2dede; }
|
|
|
+ .cell_marka_default { background-color: #f5f5f5; }
|
|
|
+</style>
|
|
|
|
|
|
<div class="container-fluid">
|
|
|
|
|
|
+ <p></p>
|
|
|
+
|
|
|
<form action="" method="GET" class="form-inline">
|
|
|
+ <input type="hidden" name="_route" value="DealsSales">
|
|
|
<table>
|
|
|
<!--
|
|
|
<summary>Wybierz lokal i/lub firmę w celu przeglądania obrotów </summary>
|
|
|
-->
|
|
|
<thead>
|
|
|
<tr>
|
|
|
- <th style="text-align:left">Lokal</th>
|
|
|
+ <th style="text-align:left">Wyszukaj lokal lub markę</th>
|
|
|
<th style="text-align:left">
|
|
|
<?php if ($typeSpecialCompanies) : ?>
|
|
|
Firma
|
|
|
@@ -144,7 +179,7 @@ TODO: ...
|
|
|
$fName = 'id_telboxes';
|
|
|
$fldParams = array();
|
|
|
$fldParams['allowCreate'] = false;
|
|
|
- $fldParams['ajaxDataUrlBase'] = "index.php?FUNCTION_INIT=" . __FUNCTION__ . "&HEADER_NOT_INIT=YES&_task=TYPESPECIAL&fld={$fName}";
|
|
|
+ $fldParams['ajaxDataUrlBase'] = "index.php?_route=DealsSales&_task=typespecial&fld={$fName}";
|
|
|
//$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
|
|
|
echo $typeSpecialTelboxes->showFormItem($tblID = -1, $fName, $selValue = $id_telboxes, $fldParams);
|
|
|
?>
|
|
|
@@ -156,7 +191,7 @@ TODO: ...
|
|
|
$fName = 'id_companies';
|
|
|
$fldParams = array();
|
|
|
$fldParams['allowCreate'] = false;
|
|
|
- $fldParams['ajaxDataUrlBase'] = "index.php?FUNCTION_INIT=" . __FUNCTION__ . "&HEADER_NOT_INIT=YES&_task=TYPESPECIAL&fld={$fName}";
|
|
|
+ $fldParams['ajaxDataUrlBase'] = "index.php?_route=DealsSales&_task=typespecial&fld={$fName}";
|
|
|
//$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
|
|
|
echo $typeSpecialCompanies->showFormItem($tblID = -1, $fName, $selValue = $id_companies, $fldParams);
|
|
|
?>
|
|
|
@@ -175,6 +210,18 @@ TODO: ...
|
|
|
<?php if (empty($obroty)) : ?>
|
|
|
|
|
|
<?php else : ?>
|
|
|
+
|
|
|
+ <hr>
|
|
|
+
|
|
|
+ <table class="table table-bordered" style="width:auto">
|
|
|
+ <tr>
|
|
|
+ <th>Marki:</th>
|
|
|
+ <?php foreach ($markiOut as $markaLabel => $labelType) : ?>
|
|
|
+ <td class="cell_marka_<?php echo $labelType; ?>"><b><?php echo $markaLabel; ?></b></td>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
+
|
|
|
<table class="table table-bordered table-hover">
|
|
|
<thead>
|
|
|
<th></th>
|
|
|
@@ -188,7 +235,15 @@ TODO: ...
|
|
|
<tr>
|
|
|
<th><?php echo $kYearId; ?></th>
|
|
|
<?php $sumaYear = 0; foreach ($monthsOut as $vMonth) : ?>
|
|
|
- <td>
|
|
|
+ <?php
|
|
|
+ $clsName = '';
|
|
|
+ if (!empty($obrotyToMarki[$kYearId][$vMonth])) {
|
|
|
+ $vMarka = $obrotyToMarki[$kYearId][$vMonth];
|
|
|
+ $vMarkaLabel = $markiOut[$vMarka];
|
|
|
+ $clsName = "cell_marka_{$vMarkaLabel}";
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ <td class="<?php echo $clsName; ?>">
|
|
|
<?php if (isset($vSalesByMonth[$vMonth])) : ?>
|
|
|
<?php $sumaYear += $vSalesByMonth[$vMonth]; ?>
|
|
|
<nobr><?php echo number_format($vSalesByMonth[$vMonth], 2, ',', ' '); ?></nobr>
|