فهرست منبع

fix windykacja functions

Piotr Labudda 6 سال پیش
والد
کامیت
54ab88dedd
3فایلهای تغییر یافته به همراه26 افزوده شده و 23 حذف شده
  1. 17 14
      SE/se-lib/Windykacja/StatsHelper.php
  2. 2 2
      SE/se-lib/Windykacja/StatsModel.php
  3. 7 7
      SE/se-lib/Windykacja/View.php

+ 17 - 14
SE/se-lib/Windykacja/StatsHelper.php

@@ -815,33 +815,36 @@ class Windykacja_StatsHelper {
 		", [ ':id' => $user->WINDYKACJA_ID ]));
 	}
 
-	public static function get_user_hist_status_events(&$user) {
+	public static function getUserHistStatusEvents($idUser) { // TODO: convert to idUser. Sql join USERS2_WINDYKACJA_STATUS w where w.ID_BILLING_USERS = :id_user
 		return array_map(function ($item) { return (object)$item; }, DB::getPDO()->fetchAll("
 			select wh.*, kor.`K_ZAWARTOS`
-			from `USERS2_WINDYKACJA_STATUS_HIST` as wh
-				left join `IN7_DZIENNIK_KORESP` as kor on(wh.`ID_KORESP`!='N/S;' and kor.`ID`=wh.`ID_KORESP`)
-			where wh.`ID_USERS2` = :id
-				and wh.`A_STATUS_UPDATE_DATE`!='N/S;'
-		", [ ':id' => $user->WINDYKACJA_ID ]));
+			from `USERS2_WINDYKACJA_STATUS` as w
+				join `USERS2_WINDYKACJA_STATUS_HIST` as wh on ( wh.`ID_USERS2` = w.ID )
+				left join `IN7_DZIENNIK_KORESP` as kor on ( wh.`ID_KORESP` != 'N/S;' and kor.`ID` = wh.`ID_KORESP` )
+			where w.`ID_BILLING_USERS` = :id
+				and wh.`A_STATUS_UPDATE_DATE` != 'N/S;'
+		", [ ':id' => $idUser ]));
 	}
 
-	public static function get_user_hist_phone_events(&$user) {
+	public static function getUserHistPhoneEvents($idUser) {
 		return array_map(function ($item) { return (object)$item; }, DB::getPDO()->fetchAll("
 			select wh.*
-			from `USERS2_WINDYKACJA_STATUS_HIST` as wh
-			where wh.`ID_USERS2` = :id
+			from `USERS2_WINDYKACJA_STATUS` as w
+				join `USERS2_WINDYKACJA_STATUS_HIST` as wh on ( wh.`ID_USERS2` = w.ID )
+			where w.`ID_BILLING_USERS` = :id
 				and wh.`LAST_PHONE_STATUS_DATE` != 'N/S;'
-		", [ ':id' => $user->WINDYKACJA_ID ]));
+		", [ ':id' => $idUser ]));
 	}
 
-	public static function get_user_bad_address_events(&$user) {
+	public static function getUserBadAddressEvents($idUser) {
 		return array_map(function ($item) { return (object)$item; }, DB::getPDO()->fetchAll("
 			select wh.*
-			from `USERS2_WINDYKACJA_STATUS_HIST` as wh
-			where wh.`ID_USERS2` = :id
+			from `USERS2_WINDYKACJA_STATUS` as w
+				join `USERS2_WINDYKACJA_STATUS_HIST` as wh on ( wh.`ID_USERS2` = w.ID )
+			where w.`ID_BILLING_USERS` = :id
 				and wh.`BAD_ADDRESS` != 'N/S;'
 			order by wh.`ID` ASC
-		", [ ':id' => $user->WINDYKACJA_ID ]));
+		", [ ':id' => $idUser ]));
 	}
 
 	public static function get_status_count() {

+ 2 - 2
SE/se-lib/Windykacja/StatsModel.php

@@ -429,14 +429,14 @@ class Windykacja_StatsModel {
 		return (!empty($streets))? implode(',', array_keys($streets)) : '';
 	}
 
-	public static function get_umowy_from_l2($user) {
+	public static function getClientUmowy($idUser) {
 		return DB::getPDO()->fetchAllByKey("
 			select
 				d.`ID`, d.`P_DEALPREFIX`, d.`P_DEALNUMBER`, d.`P_DEALNUMBER_OLD`, d.`P_DEALDATE`, d.`P_DEALDATE_TERM`, d.`DEALDESC`, d.`ANEX_NEEDED`, d.`ANEX_CONFIRM_DATE`
 			from `DEALS_TABLE` as d
 			where d.`ID_BILLING_USERS` = :id_user
 			order by d.`ID` DESC
-		", $key = 'ID', [ ':id_user' => $user->ID ]);
+		", $key = 'ID', [ ':id_user' => $idUser ]);
 	}
 
 	public static function get_uslugi_from_l2(&$user) {

+ 7 - 7
SE/se-lib/Windykacja/View.php

@@ -1412,7 +1412,7 @@ class Windykacja_View {
 		}
 
 		$uslugi_l2 = Windykacja_StatsModel::get_uslugi_from_l2($user);
-		$umowy_l2 = Windykacja_StatsModel::get_umowy_from_l2($user);
+		$umowy_l2 = Windykacja_StatsModel::getClientUmowy($user->ID);
 
 		$uslugi_l2_nieprzypisane = array();
 		foreach ($uslugi_l2 as $k_id => $h) {
@@ -1659,7 +1659,7 @@ class Windykacja_View {
 		$billing_docs = Windykacja_StatsModel::getBillDocsByDate($user->ID);
 
 		// add events
-		$umowy_l2 = Windykacja_StatsModel::get_umowy_from_l2($user);
+		$umowy_l2 = Windykacja_StatsModel::getClientUmowy($user->ID);
 		//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">billing_docs ';print_r($billing_docs);echo'</pre>';
 		//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">billing_docs ';print_r(reset($billing_docs));echo'</pre>';
 		//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">umowy_l2 ';print_r($umowy_l2);echo'</pre>';
@@ -1673,7 +1673,7 @@ class Windykacja_View {
 			}
 		}
 
-		$user_hist_events = Windykacja_StatsHelper::get_user_hist_status_events($user);
+		$user_hist_events = Windykacja_StatsHelper::getUserHistStatusEvents($user->ID);
 		if (!empty($user_hist_events)) {
 			foreach ($user_hist_events as $v_hist) {
 				$bill_doc = (array)$v_hist;
@@ -1681,7 +1681,7 @@ class Windykacja_View {
 			}
 		}
 
-		$user_hist_events = Windykacja_StatsHelper::get_user_hist_phone_events($user);
+		$user_hist_events = Windykacja_StatsHelper::getUserHistPhoneEvents($user->ID);
 		if (!empty($user_hist_events)) {
 			foreach ($user_hist_events as $v_hist) {
 				$bill_doc = (array)$v_hist;
@@ -1689,7 +1689,7 @@ class Windykacja_View {
 			}
 		}
 
-		$user_hist_events = Windykacja_StatsHelper::get_user_bad_address_events($user);
+		$user_hist_events = Windykacja_StatsHelper::getUserBadAddressEvents($user->ID);
 		if (!empty($user_hist_events)) {
 			foreach ($user_hist_events as $v_hist) {
 				$bill_doc = (array)$v_hist;
@@ -2792,7 +2792,7 @@ class Windykacja_View {
 	 * @params $id_koresp
 	 */
 	public static function task_bok_rozwiazanie_umowy_print($user, $id_koresp) {
-		$user_hist_events = Windykacja_StatsHelper::get_user_hist_status_events($user);
+		$user_hist_events = Windykacja_StatsHelper::getUserHistStatusEvents($user->ID);
 		if (empty($user_hist_events)) {
 			echo '<p style="color:red">' . "Brak danych HIST" . '</p>';
 			return;
@@ -2927,7 +2927,7 @@ class Windykacja_View {
             }
 		".'</script>';
 
-		$umowy_l2 = Windykacja_StatsModel::get_umowy_from_l2($user);
+		$umowy_l2 = Windykacja_StatsModel::getClientUmowy($user->ID);
 		if (empty($umowy_l2)) {
 			echo '<p style="color:red">' . "Brak aktualnych umów z klientem" . '</p>';
 			return;