Browse Source

change recount bills f-vat

Piotr Labudda 11 years ago
parent
commit
ec480b90dc
1 changed files with 20 additions and 21 deletions
  1. 20 21
      SE/superedit-RECOUNT_STATS_BILLS_FVAT_POS.php

+ 20 - 21
SE/superedit-RECOUNT_STATS_BILLS_FVAT_POS.php

@@ -116,23 +116,24 @@ jQuery(document).ready(function () {
 				and f.`ID_BILLS_FVAT`=fv.`ID`
 		";
 
-		$sqlList[] = "update `stats_BILLS_FVAT_POS` as f, `SERVICES` as s
+		$sqlList[] = "update `stats_BILLS_FVAT_POS` as f
+				join `SERVICES` as s on(s.`ID`=f.`ID_SERVICES` and f.`ID_SERVICES`>0)
 			set
 				f.`S_ADDRESS_STREET`=s.`S_ADDRESS_STREET`
 				, f.`NAME_LIST_SERVICES`=s.`NAME_LIST_SERVICES`
 				, f.`ID_DEALS_TABLE`=s.`ID_DEALS_TABLE`
-			where s.`ID`=f.`ID_SERVICES`
-				and f.`ID_SERVICES`>0
+				, f.`ID_OFFERS`=s.`ID_OFFERS`
 		";
 
-		$sqlList[] = "update `stats_BILLS_FVAT_POS` as f, `DEALS_TABLE` as d
+		$sqlList[] = "update `stats_BILLS_FVAT_POS` as f
+				join `DEALS_TABLE` as d on(d.`ID`=f.`ID_DEALS_TABLE` and f.`S_ADDRESS_STREET`='')
 			set
 				f.`S_ADDRESS_STREET`=d.`S_ADDRESS_STREET`
-			where d.`ID`=f.`ID_DEALS_TABLE`
-				and f.`S_ADDRESS_STREET`=''
 		";
 
-		$sqlList[] = "update `stats_BILLS_FVAT_POS` as f, `USERS2_MARKETING` as m, `BUILDINGS` as b
+		$sqlList[] = "update `stats_BILLS_FVAT_POS` f
+				join `USERS2_MARKETING` m on(m.`S_ADDRESS_STREET`=f.`S_ADDRESS_STREET`)
+				join `BUILDINGS` b on(b.`S_ADDRESS_STREET`=m.`T_TELBOX_BUILDING_IN`)
 			set
 				f.`T_TELBOX_BUILDING_IN`=m.`T_TELBOX_BUILDING_IN`
 				, f.`M_REWIR`=b.`M_REWIR`
@@ -140,12 +141,12 @@ jQuery(document).ready(function () {
 					, CONCAT(b.`S_ADDRESS_CITY`, ' - ', b.`P_OSIEDLE`)
 					, b.`S_ADDRESS_CITY`
 				)
-			where m.`S_ADDRESS_STREET`=f.`S_ADDRESS_STREET`
-				and b.`S_ADDRESS_STREET`=m.`T_TELBOX_BUILDING_IN`
-				and f.`S_ADDRESS_STREET`!=''
+			where f.`S_ADDRESS_STREET`!=''
 		";
 
-		$sqlList[] = "update `stats_BILLS_FVAT_POS` as f, `USERS2_OFFERS` as o, `USERS2_OFFERS_COSTS_GROUPS` as c
+		$sqlList[] = "update `stats_BILLS_FVAT_POS` f
+				join `USERS2_OFFERS` o on(o.`ID`=f.`ID_OFFERS`)
+				join `USERS2_OFFERS_COSTS_GROUPS` c on(c.`ID`=o.`ID_COSTS_GROUPS`)
 			set
 				f.`P_SERVICE`=IF(o.`P_SERVICE`='OPCJE'
 					, concat(o.`P_SERVICE`, '_', o.`P_SERVICE_PARENT`)
@@ -154,31 +155,29 @@ jQuery(document).ready(function () {
 				, f.`P_NET_SPEED`=IF(o.`P_SERVICE` in('NET')
 					, o.`P_S_PARAM1`
 					, '')
-				, f.`P_TV_NAME`=IF(o.`P_SERVICE` in('TV','TVC','TVCP')
+				, f.`P_TV_NAME`=IF(o.`P_SERVICE` in('TV','TVC','TVCP','OPCJA_TVC')
 					, o.`P_SERVICE_NAME`
 					, '')
-				, f.`P_TEL_NAME`=IF(o.`P_SERVICE` in('TEL')
+				, f.`P_TEL_NAME`=IF(o.`P_SERVICE` in('TEL','OPCJA_TEL')
 					, o.`P_SERVICE_NAME`
 					, '')
 				, f.`P_OFFER_COSTS`=c.`P_OFFER_COSTS`
-			where o.`ID`=f.`ID_OFFERS`
-				and c.`ID`=o.`ID_COSTS_GROUPS`
-				and f.`ID_OFFERS`>0
+			where f.`ID_OFFERS`>0
 		";
 
-		$sqlList[] = "update `stats_BILLS_FVAT_POS` as f, `USERS2_OFFERS` as o, `USERS2_PRODUKT` as p
+		$sqlList[] = "update `stats_BILLS_FVAT_POS` f
+				join `USERS2_OFFERS` o on(o.`ID`=f.`ID_OFFERS`)
+				join `USERS2_PRODUKT` p on(p.`ID`=o.`ID_PRODUKT`)
 			set
 				f.`P_NET_GROUP`=p.`P_NAME`
-			where o.`ID`=f.`ID_OFFERS`
-				and p.`ID`=o.`ID_PRODUKT`
-				and f.`ID_OFFERS`>0
+			where f.`ID_OFFERS`>0
 				and o.`ID_PRODUKT`>0
 				and o.`P_SERVICE`='NET'
 		";
 
 		$sqlList[] = "update `stats_BILLS_FVAT_POS` as f
 			set
-				f.`P_OFFER_ZYSK`=f.`INCOME` - f.`P_OFFER_COSTS`
+				f.`P_OFFER_ZYSK`=(f.`INCOME` - f.`P_OFFER_COSTS`)
 		";
 
 		$sqlList[] = "update `stats_BILLS_FVAT_POS` as f