Forráskód Böngészése

PokazOferty - opcje zależne od rewiru budynku

Piotr Labudda 10 éve
szülő
commit
7ad235e410
1 módosított fájl, 21 hozzáadás és 6 törlés
  1. 21 6
      SE/superedit-POKAZ_OFERTY_AKTUALNE_FUNC.php

+ 21 - 6
SE/superedit-POKAZ_OFERTY_AKTUALNE_FUNC.php

@@ -3309,7 +3309,7 @@ jQuery(document).ready(function(){
 		<?php
 		//}
 
-		$oferty_opcje_all = PokazOfertyHelper::get_oferty_opcje_all();
+		$oferty_opcje_all = PokazOfertyHelper::get_oferty_opcje_all($building);
 		$oferty_opcje_cols = PokazOfertyHelper::get_oferty_opcje_visible_cols();
 		//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">$oferty_opcje: ';print_r($oferty_opcje);echo'</pre>';
 		//echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;">';print_r($oferty_group_add_info ['labels']);echo'</pre>';
@@ -4747,6 +4747,7 @@ class PokazOfertyHelper {
 	}
 
 	public static function get_oferty_opcje() {
+		$db = DB::getDB();
 		$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
@@ -4778,8 +4779,8 @@ class PokazOfertyHelper {
 				and o.`P_SERVICE_COMPANY`='BN'
 			order by o.`ID_PRODUKT` desc, o.`P_CONTRACT_PRICE` desc
 		";
-		$res = DB::query($sql);
-		while ($r = DB::fetch($res)) {
+		$res = $db->query($sql);
+		while ($r = $db->fetch($res)) {
 			$r->srednia = '';
 			if (array_key_exists($r->ID, $oferty_costs)) {
 				$r->koszt = $oferty_costs[ $r->ID ];
@@ -4789,13 +4790,22 @@ class PokazOfertyHelper {
 		return $oferty_opcje;
 	}
 
-	public static function get_oferty_opcje_all() {
+	public static function get_oferty_opcje_all($building) {
+		$db = DB::getDB();
 		$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
 		$sqlStatus = array('NORMAL');
 		if (V::get('TEST_MONITOR', '', $_GET)) $sqlStatus[] = 'MONITOR';
 		$sqlStatus = "and o.`A_STATUS` in('" . implode("','", $sqlStatus) . "')";
+		$sqlRewir = "";
+		if ($building) {
+			$sqlRewir = "
+				and (o.`M_REWIR`=''
+					or ('{$building->M_REWIR}' like o.`M_REWIR`)
+				)
+			";
+		}
 		$sql = "select
 				o.`ID`
 				, o.`P_SERVICE`
@@ -4818,14 +4828,19 @@ class PokazOfertyHelper {
 				, o.`P_MULTIROOM_ADD_DEKODER_SD`
 				, o.`P_MULTIROOM_ADD_DEKODER_HD`
 				, o.`P_MULTIROOM_ADD_MODUL_CAM`
+				, o.`M_REWIR`
+				, IF (''=o.`M_REWIR`, 1, 0) as rewir_empty
+				, IF ('{$building->M_REWIR}' like o.`M_REWIR`, 1, 0) as rewir_ok
 			from `USERS2_OFFERS` as o
 			where o.`P_SERVICE` in('OPCJE', 'OPCJA_TVC', 'OPCJA_TEL')
 				{$sqlStatus}
 				and o.`P_SERVICE_COMPANY`='BN'
+				{$sqlRewir}
 			order by o.`ID_PRODUKT` desc, o.`P_CONTRACT_PRICE` desc
 		";
-		$res = DB::query($sql);
-		while ($r = DB::fetch($res)) {
+		DBG::_('DBG', '>1', "sql oferty opcje", $sql, __CLASS__, __FUNCTION__, __LINE__);
+		$res = $db->query($sql);
+		while ($r = $db->fetch($res)) {
 			$r->srednia = '';
 			if (array_key_exists($r->ID, $oferty_costs)) {
 				$r->koszt = $oferty_costs[ $r->ID ];