get($_SESSION['id']); if ($obj['operation_type'] == 1) { $dealType = 'SELL'; $sqlPriceTypePart = "1"; } else { $dealType = 'RENT'; $priceType = 'MONTH'; if ($obj['srok'] == 1) { $priceType = 'DAY'; } $sqlPriceTypePart = " advertising_package_price_type_id in (SELECT id FROM advertising_package_price_type where code = '$priceType') "; } $hasPhotos = 0; $isRoom = 0; $sqlPhotoInfo = "SELECT id FROM objects_object_photo oop WHERE oop.object_id = $obj[id] LIMIT 1"; $rezPhotoInfo = mysql_query($sqlPhotoInfo); if (mysql_num_rows($rezPhotoInfo) > 0) { $hasPhotos = 1; } $objectType = 'FLAT'; switch ($obj['type']) { case 1: $objectType = 'FLAT'; break; case 2: $objectType = 'FLAT'; $isRoom = 1; break; case 3: $objectType = 'HOUSE'; break; case 4: case 6: if ($obj['type_category']) { if ($obj['type_category'] == 1) { $objectType = 'BUSINESS'; } if ($obj['type_category'] == 2) { $objectType = 'WAREHOUSE'; } if ($obj['type_category'] >= 3) { $objectType = 'BUSINESS'; } } else { $objectType = 'BUSINESS'; } break; case 5: $objectType = 'HOUSE'; break; case 7: $objectType = 'LAND'; break; } if($obj['id_rf_region']){ $region = $obj['id_rf_region']; }else{ $region = 78; } $sqlPackageList = "SELECT * FROM advertising_package WHERE is_room=$isRoom AND has_photo = $hasPhotos AND advertising_package_deal_type_id in (SELECT id FROM advertising_package_deal_type where code = '$dealType') AND advertising_package_object_type_id in (SELECT id FROM advertising_package_object_type where code = '$objectType') AND $sqlPriceTypePart AND deleted = 0 and agency_id = $curUser->agencyId and (region_rf_id = $region or region_rf_id in (select parent from rf_regions where id = $region))"; if ($_SESSION['id'] == 93) { echo $sqlPackageList; echo '
'; } $rezPackageList = mysql_query($sqlPackageList); $num = 1; if (mysql_num_rows($rezPackageList) > 0) { echo '
'; while ($package = mysql_fetch_assoc($rezPackageList)) { $checked = false; $sqlActivePacks = "SELECT * FROM advertising_package_object_publish WHERE object_id = $get[objectId] and advertising_package_id = $package[id]"; $rezActivePacks = mysql_query($sqlActivePacks); $publishObj = null; if (mysql_num_rows($rezActivePacks) > 0) { $publishObj = mysql_fetch_assoc($rezActivePacks); if ($publishObj['active'] == 1) { $checked = true; } } if ($checked) { $daysResult = zipalPackageCountText($obj['id'], $package['id']); } else { $daysResult = array('html' => '', 'zipal_active' => 0); } $checked = $daysResult['zipal_active'] == 0 ? false : true; echo ' 0) { echo 'style="background-color: #f9f9f9;"'; } echo '>'; echo ''; echo ''; echo ''; echo ''; $num++; } echo '
'; echo $package['name']; echo '
'; echo '(' . declOfNum($package['days_count'], array('%d день', '%d дня', '%d дней')) . ')'; echo '
'; $sqlDestinations = "select * from advertising_package_destinations where advertising_package_id = $package[id] and deleted = 0"; $rezDestinations = mysql_query($sqlDestinations); while ($dest = mysql_fetch_assoc($rezDestinations)) { $targetName = $ZIPAL_TARGETS[$dest['destination']]; if (!$targetName) { $targetName = $dest['destination']; } echo $targetName . '; '; } echo ''; echo '
'; echo $daysResult['html']; echo '
'; echo '
'; $errStyle = ''; $errTitle = ''; if ($publishObj != null && $publishObj['error_text']) { $errStyle = 'border: 1px solid red;'; $errTitle = htmlentities($publishObj['error_text']); } ?>
" onclick="publishAdvPack(this);" data-package-id="" title="">
'; echo '
'; } else { echo 'Подходящих по параметрам пакетов не найдено.'; } } }