|
|
@@ -85,6 +85,10 @@ switch ($_GET['task']) {
|
|
|
POKAZ_OFERTY_AKTUALNE_FUNC__activate_services_voip();
|
|
|
return;
|
|
|
break;
|
|
|
+ case 'ajaxUmowaZysk':
|
|
|
+ POKAZ_OFERTY_AKTUALNE_FUNC__ajaxUmowaZysk();
|
|
|
+ return;
|
|
|
+ break;
|
|
|
default:
|
|
|
|
|
|
}
|
|
|
@@ -1070,7 +1074,6 @@ if ($DBG) {echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;
|
|
|
|
|
|
$pokaz_oferty_view = new PokazOfertyView();
|
|
|
echo $pokaz_oferty_view->print_css();
|
|
|
-echo '<script type="text/javascript" src="stuff/jquery.js"></script>';
|
|
|
echo '<script type="text/javascript">' . "
|
|
|
jQuery(document).ready(function(){
|
|
|
jQuery('#tbl-oferty').on('click', '.tbl-row', function(event){
|
|
|
@@ -1446,7 +1449,7 @@ foreach ($oferty as $row) {
|
|
|
echo '</thead>';
|
|
|
echo '<tfoot>';
|
|
|
echo '<tr>';
|
|
|
- echo '<th colspan="'.(count($oferty_group_add_info['labels']) + 1).'" style="text-align:left">';
|
|
|
+ echo '<th colspan="'.(count($oferty_group_add_info['labels']) + 2).'" style="text-align:left">';
|
|
|
$link_href = "?MENU_INIT=POKAZ_OFERTY_AKTUALNE_FUNC";
|
|
|
//"S_ADDRESS_STREET=&ADD=SZUKAJ";
|
|
|
$link_href .= "&task=dodaj_aneks";
|
|
|
@@ -1455,6 +1458,11 @@ foreach ($oferty as $row) {
|
|
|
$link_href .= "&user_id=" . $_GET['user_id'];
|
|
|
$js = "return print_umowa(this);";
|
|
|
echo '<a href="' . $link_href . '" href_base="' . $link_href . '" title="' . "Dodaj aneks lub nową umowę" . '" onclick="' . $js . '">' . '<img src="icon/add.gif" alt="+" />' . " Dodaj aneks lub nową umowę" . '</a>';
|
|
|
+
|
|
|
+ $js = "return umowaZysk_click(this); return false;";
|
|
|
+ ?>
|
|
|
+ <a class="btn btn-mini pull-right" href="#" data-id_group="<?php echo $row['0_1380']; ?>" title="Oblicz zysk" onclick="<?php echo $js; ?>">Oblicz zysk</a>
|
|
|
+ <?php
|
|
|
echo '</th>';
|
|
|
echo '</tr>';
|
|
|
echo '</tfoot>';
|
|
|
@@ -1464,7 +1472,8 @@ foreach ($oferty as $row) {
|
|
|
echo '<tbody id="' . $html_cell_id . '">';
|
|
|
echo '<tr>';
|
|
|
echo '<td>';
|
|
|
- echo reset(explode('_', $v_p_service));
|
|
|
+ $outPService = explode('_', $v_p_service);
|
|
|
+ echo reset($outPService);
|
|
|
echo '<br />';
|
|
|
$js = "return show_opcje('" . $html_cell_id . "', '" . $v_p_service . "');";
|
|
|
echo '<a href="' . "#" . '" onclick="' . $js . '">' . "opcje" . '</a>';
|
|
|
@@ -2341,7 +2350,7 @@ class PokazOfertyHelper {
|
|
|
* @return array or null
|
|
|
* [ID_BILLING_USERS => array of object deal]
|
|
|
*/
|
|
|
- function get_deals_active_by_street($S_ADDRESS_STREET) {
|
|
|
+ public static function get_deals_active_by_street($S_ADDRESS_STREET) {
|
|
|
return self::get_deals_active(array('S_ADDRESS_STREET'=>$S_ADDRESS_STREET));
|
|
|
}
|
|
|
|
|
|
@@ -2351,19 +2360,19 @@ class PokazOfertyHelper {
|
|
|
* @return array or null
|
|
|
* [ID_DEALS => deal]
|
|
|
*/
|
|
|
- function get_deals_active_with_info($S_ADDRESS_STREET, $ID_BILLING_USERS, $only_active = true) {
|
|
|
+ public static function get_deals_active_with_info($S_ADDRESS_STREET, $ID_BILLING_USERS, $only_active = true) {
|
|
|
$active_deals_by_id = self::get_deals_active(array('S_ADDRESS_STREET'=>$S_ADDRESS_STREET, 'ID_BILLING_USERS'=>$ID_BILLING_USERS, 'return_by'=>'ID', 'P_DEALNUMBER'=>true));
|
|
|
self::deals_active_add_info($active_deals_by_id, $ID_BILLING_USERS, $only_active);
|
|
|
return $active_deals_by_id;
|
|
|
}
|
|
|
|
|
|
- function get_deals_active_by_user($ID_BILLING_USERS, $only_active = true) {
|
|
|
+ public static function get_deals_active_by_user($ID_BILLING_USERS, $only_active = true) {
|
|
|
$active_deals_by_id = self::get_deals_active(array('ID_BILLING_USERS'=>$ID_BILLING_USERS, 'return_by'=>'ID', 'P_DEALNUMBER'=>true));
|
|
|
self::deals_active_add_info($active_deals_by_id, $ID_BILLING_USERS, $only_active);
|
|
|
return $active_deals_by_id;
|
|
|
}
|
|
|
|
|
|
- function deals_active_add_info(&$active_deals_by_id, $ID_BILLING_USERS, $only_active = false) {
|
|
|
+ public static function deals_active_add_info(&$active_deals_by_id, $ID_BILLING_USERS, $only_active = false) {
|
|
|
if (empty($active_deals_by_id)) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -2419,7 +2428,7 @@ class PokazOfertyHelper {
|
|
|
* @return array or null
|
|
|
* [ID_BILLING_USERS => array of object deal]
|
|
|
*/
|
|
|
- function get_deals_active($params = array()) {
|
|
|
+ public static function get_deals_active($params = array()) {
|
|
|
|
|
|
$forceUpdate = false;
|
|
|
Lib::loadClass('ColumnDealsStatus');
|
|
|
@@ -2472,7 +2481,7 @@ class PokazOfertyHelper {
|
|
|
return $active_deals;
|
|
|
}
|
|
|
|
|
|
- function get_l2_list_status_name($status) {
|
|
|
+ public static function get_l2_list_status_name($status) {
|
|
|
static $l2_list_status;
|
|
|
if (!is_array($l2_list_status)) {
|
|
|
$l2_list_status = array();
|
|
|
@@ -2492,7 +2501,7 @@ class PokazOfertyHelper {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- function get_services_by_user_deals($user_id, $deals_ids = array(), $only_active = false) {
|
|
|
+ public static function get_services_by_user_deals($user_id, $deals_ids = array(), $only_active = false) {
|
|
|
$deals = array();
|
|
|
if (empty($deals_ids)) {
|
|
|
return $deals;
|
|
|
@@ -2566,7 +2575,7 @@ class PokazOfertyHelper {
|
|
|
return $deals;
|
|
|
}
|
|
|
|
|
|
- function get_services_params($uslugi) {
|
|
|
+ public static function get_services_params($uslugi) {
|
|
|
$ses_x_a = array();
|
|
|
if (empty($uslugi)) return $ses_x_a;
|
|
|
|
|
|
@@ -2594,7 +2603,7 @@ class PokazOfertyHelper {
|
|
|
return $ses_x_a;
|
|
|
}
|
|
|
|
|
|
- function get_users_by_query($q) {
|
|
|
+ public static function get_users_by_query($q) {
|
|
|
$users_rows = array();
|
|
|
$db = DB::getDB();
|
|
|
$sql_order_by = 'order by a.`P_NAME` asc';
|
|
|
@@ -2683,7 +2692,7 @@ class PokazOfertyHelper {
|
|
|
return $users_rows;
|
|
|
}
|
|
|
|
|
|
- function get_user_info($user_id) {
|
|
|
+ public static function get_user_info($user_id) {
|
|
|
$user = null;
|
|
|
$user_id = (int)$user_id;
|
|
|
if ($user_id <= 0) {
|
|
|
@@ -2717,15 +2726,15 @@ class PokazOfertyHelper {
|
|
|
return $user;
|
|
|
}
|
|
|
|
|
|
- function get_users2_deals_empty_object() {
|
|
|
+ public static function get_users2_deals_empty_object() {
|
|
|
return new Column_users2_deals();
|
|
|
}
|
|
|
|
|
|
- function get_deals_table_empty_object() {
|
|
|
+ public static function get_deals_table_empty_object() {
|
|
|
return new Column_deals_table();
|
|
|
}
|
|
|
|
|
|
- function get_buildings_cols() {
|
|
|
+ public static function get_buildings_cols() {
|
|
|
$buildings_sql_cols = array();
|
|
|
$buildings_sql_cols ['ID']= "ID";
|
|
|
$buildings_sql_cols ['S_ADDRESS_STREET']= "S ADDRESS STREET";
|
|
|
@@ -2740,7 +2749,7 @@ class PokazOfertyHelper {
|
|
|
return $buildings_sql_cols;
|
|
|
}
|
|
|
|
|
|
- function get_marketing_cols() {
|
|
|
+ public static function get_marketing_cols() {
|
|
|
$marketing_sql_cols = array();
|
|
|
$marketing_sql_cols ['ID']= "ID";
|
|
|
$marketing_sql_cols ['S_ADDRESS_STREET']= "S ADDRESS STREET";
|
|
|
@@ -2752,7 +2761,7 @@ class PokazOfertyHelper {
|
|
|
return $marketing_sql_cols;
|
|
|
}
|
|
|
|
|
|
- function get_buildings_by_mieszk($street) {
|
|
|
+ public static function get_buildings_by_mieszk($street) {
|
|
|
$buildings = array();
|
|
|
if (empty($street)) {
|
|
|
//return self::get_buildings($street);
|
|
|
@@ -2791,7 +2800,7 @@ class PokazOfertyHelper {
|
|
|
return $buildings;
|
|
|
}
|
|
|
|
|
|
- function get_buildings($street) {
|
|
|
+ public static function get_buildings($street) {
|
|
|
$buildings = array();
|
|
|
$db = DB::getDB();
|
|
|
$buildings_sql_cols = self::get_buildings_cols();
|
|
|
@@ -2821,7 +2830,7 @@ class PokazOfertyHelper {
|
|
|
return $buildings;
|
|
|
}
|
|
|
|
|
|
- function get_deal($id_deal) {
|
|
|
+ public static function get_deal($id_deal) {
|
|
|
$deal = null;
|
|
|
if ($id_deal <= 0) {
|
|
|
return $deal;
|
|
|
@@ -2963,7 +2972,7 @@ class PokazOfertyHelper {
|
|
|
return $offers;
|
|
|
}
|
|
|
|
|
|
- function get_users2_deals_by_deal_id($deal_id, $params = array()) {
|
|
|
+ public static function get_users2_deals_by_deal_id($deal_id, $params = array()) {
|
|
|
$users2_deals = array();
|
|
|
$db = DB::getDB();
|
|
|
$sql_status = "";
|
|
|
@@ -3045,7 +3054,7 @@ class PokazOfertyHelper {
|
|
|
return $oferty_costs_start;
|
|
|
}
|
|
|
|
|
|
- function get_oferty_opcje_visible_cols() {
|
|
|
+ public static function get_oferty_opcje_visible_cols() {
|
|
|
$cols = array();
|
|
|
$cols ['ID'] = 'ID oferty';
|
|
|
//$cols ['ID_PROCES' ] = '';
|
|
|
@@ -3063,7 +3072,7 @@ class PokazOfertyHelper {
|
|
|
return $cols;
|
|
|
}
|
|
|
|
|
|
- function get_oferty_opcje() {
|
|
|
+ public static function get_oferty_opcje() {
|
|
|
$oferty_opcje = array();// [ service ] => array(ID => {oferta})
|
|
|
$oferty_costs = self::get_offers_costs_by_offer_ids();
|
|
|
// TODO: use [P_OFFER_TERM_BEGIN] => 0000-00-00, [P_OFFER_TERM] => 2011-12-31, [M_REWIR] => gd
|
|
|
@@ -3106,7 +3115,7 @@ class PokazOfertyHelper {
|
|
|
return $oferty_opcje;
|
|
|
}
|
|
|
|
|
|
- function get_oferty_opcje_all() {
|
|
|
+ public static function get_oferty_opcje_all() {
|
|
|
$oferty_opcje = array();// [ service ] => array(ID => {oferta})
|
|
|
$oferty_costs = self::get_offers_costs_by_offer_ids();
|
|
|
// TODO: use [P_OFFER_TERM_BEGIN] => 0000-00-00, [P_OFFER_TERM] => 2011-12-31, [M_REWIR] => gd
|
|
|
@@ -3156,7 +3165,7 @@ class PokazOfertyHelper {
|
|
|
return $oferty_opcje;
|
|
|
}
|
|
|
|
|
|
- function find_groups_by_offers($oferty, $todo_test_deal_id = 0) {
|
|
|
+ public static function find_groups_by_offers($oferty, $todo_test_deal_id = 0) {
|
|
|
$db = DB::getDB();
|
|
|
$groups = array();
|
|
|
$sql_where_arr = array();
|
|
|
@@ -3191,7 +3200,7 @@ class PokazOfertyHelper {
|
|
|
return $groups;
|
|
|
}
|
|
|
|
|
|
- function date_diff_days($d1, $d2) {
|
|
|
+ public static function date_diff_days($d1, $d2) {
|
|
|
$d1_sec = strtotime($d1);
|
|
|
$d2_sec = strtotime($d2);
|
|
|
$diff_sec = $d1_sec - $d2_sec;
|
|
|
@@ -3199,7 +3208,7 @@ class PokazOfertyHelper {
|
|
|
return $diff_days;
|
|
|
}
|
|
|
|
|
|
- function date_diff_months($d1, $d2) {
|
|
|
+ public static function date_diff_months($d1, $d2) {
|
|
|
$d1_sec = strtotime($d1);
|
|
|
$d2_sec = strtotime($d2);
|
|
|
$diff_sec = $d1_sec - $d2_sec;
|
|
|
@@ -3207,7 +3216,7 @@ class PokazOfertyHelper {
|
|
|
return $diff_months;
|
|
|
}
|
|
|
|
|
|
- function get_aneks_loss($offers_ids, $diff_months, $deal_month, &$loss_log) {
|
|
|
+ public static function get_aneks_loss($offers_ids, $diff_months, $deal_month, &$loss_log) {
|
|
|
if (empty($offers_ids) || $diff_months <= 0) {
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -3227,7 +3236,7 @@ class PokazOfertyHelper {
|
|
|
return $loss;
|
|
|
}
|
|
|
|
|
|
- function get_aneks_loss_abonament_netto($offers_ids, $diff_months, $deal_month, &$loss_log) {
|
|
|
+ public static function get_aneks_loss_abonament_netto($offers_ids, $diff_months, $deal_month, &$loss_log) {
|
|
|
if (empty($offers_ids) || $diff_months <= 0) {
|
|
|
return 0;
|
|
|
}
|
|
|
@@ -3241,7 +3250,7 @@ class PokazOfertyHelper {
|
|
|
return $loss;
|
|
|
}
|
|
|
|
|
|
- function get_deals_by_month($month, $params = array()) {
|
|
|
+ public static function get_deals_by_month($month, $params = array()) {
|
|
|
$deals = array();
|
|
|
|
|
|
$sql_status = "";
|
|
|
@@ -3276,7 +3285,7 @@ class PokazOfertyHelper {
|
|
|
return $deals;
|
|
|
}
|
|
|
|
|
|
- function get_deals_created_in_month($month, $params = array()) {
|
|
|
+ public static function get_deals_created_in_month($month, $params = array()) {
|
|
|
$deals = array();
|
|
|
|
|
|
$sql_status = "";
|
|
|
@@ -8846,3 +8855,59 @@ function POKAZ_OFERTY_AKTUALNE_FUNC__activate_services_save($tblAcl, $fieldsList
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+function POKAZ_OFERTY_AKTUALNE_FUNC__ajaxUmowaZysk() {
|
|
|
+ $jsonData = new stdClass();
|
|
|
+
|
|
|
+ try {
|
|
|
+ $jsonData = POKAZ_OFERTY_AKTUALNE_FUNC__ajaxUmowaZysk_createJson();
|
|
|
+ }
|
|
|
+ catch (Exception $e) {
|
|
|
+ $jsonData->type = 'error';
|
|
|
+ $jsonData->msg = $e->getMessage();
|
|
|
+ }
|
|
|
+ echo json_encode($jsonData);
|
|
|
+ exit;
|
|
|
+}
|
|
|
+
|
|
|
+function POKAZ_OFERTY_AKTUALNE_FUNC__ajaxUmowaZysk_createJson() {
|
|
|
+ $jsonData = new stdClass();
|
|
|
+ $con = new PokazOfertyController();
|
|
|
+ $con->set_params_from_request();
|
|
|
+
|
|
|
+ if ($con->hasOptionsToServices()) {
|
|
|
+ if (!$con->convertOptionsToSrv()) {
|
|
|
+ throw new Exception("Nie udało się utworzyć nowej grupy na podstawie wybranych parametrów.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $jsonData->con = $con;
|
|
|
+
|
|
|
+ $group = $con->get_group();
|
|
|
+ if (!$group) {
|
|
|
+ throw new Exception("Brak grupy");
|
|
|
+ }
|
|
|
+
|
|
|
+ $group->fetch_offers();
|
|
|
+ $jsonData->zysk = $group->get_zysk_netto();
|
|
|
+ $jsonData->zyskabonament_srednia_netto = $group->get_srednia_netto();
|
|
|
+
|
|
|
+ $procenty = array();
|
|
|
+ $procenty[]= 2;
|
|
|
+ $procenty[]= 5;
|
|
|
+ $procenty[]= 10;
|
|
|
+ $procenty[]= 15;
|
|
|
+ $procenty[]= 30;
|
|
|
+
|
|
|
+ ob_start();
|
|
|
+ ?>
|
|
|
+Zysk: <?php echo number_format($jsonData->zysk, 2, ',', ''); ?>
|
|
|
+<?php foreach ($procenty as $procent) : ?>
|
|
|
+ <br><?php echo $procent; ?>%: <?php echo number_format($jsonData->zysk * $procent / 100, 2, ',', ''); ?>
|
|
|
+<?php endforeach; ?>
|
|
|
+ <?php
|
|
|
+ $jsonData->html = ob_get_contents();
|
|
|
+ ob_clean();
|
|
|
+
|
|
|
+ return $jsonData;
|
|
|
+}
|