/** * Генерация rss для bicotender.ru * @param $date datetime в Y-m-d H:i:s */ public static function bicotenderGenerateRss($date) { if (!preg_match("#^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}\\s[0-9]{2}:[0-9]{2}:[0-9]{2}\$#", $date, $m)) { $date = date("Y-m-d 00:00:00"); } global $DB; $cache_expire = 900; $sql = "SELECT p.kind, p.name, p.descr, p.id, p.post_date, p.end_date, p.cost, p.currency, p.edit_date, p.exec_id,\n e.login, e.uname, e.usurname, e.compname, e.phone_1 AS phis_phone, e.second_email AS phis_email, e.site,\n fin.form_type, fin._1_inn, fin._2_inn, fin._2_address_fct, fin._1_address, fin._2_phone AS jur_phone, fin._2_email AS jur_email, fin._2_bossname AS boss, fin._2_full_name,\n country.country_name, city.city_name, groups.name AS category, professions.name AS prof\n FROM projects p\n INNER JOIN\n employer e\n ON e.uid = p.user_id\n AND e.is_banned = '0'\n LEFT JOIN projects_blocked pb ON pb.project_id = p.id\n LEFT JOIN sbr_reqv AS fin ON fin.user_id = e.uid\n LEFT JOIN country ON country.id = e.country \n LEFT JOIN city ON city.id = e.city\n LEFT JOIN project_to_spec AS pts ON pts.project_id = p.id\n LEFT JOIN prof_group AS groups ON pts.category_id = groups.id\n LEFT JOIN professions ON pts.subcategory_id = professions.id\n WHERE pb.project_id IS NULL\n /*AND (p.moderator_status > 0 OR e.is_pro = TRUE)*/\n AND p.post_date >= '{$date}'\n AND p.closed = false \n AND p.kind = 7\n ORDER BY p.kind, p.post_date DESC"; $nodes = array(); $project_exRates = project_exrates::GetAll(); $translate_exRates = array(0 => 2, 1 => 3, 2 => 4, 3 => 1); $rows = $DB->cache($cache_expire)->rows($sql); foreach ($rows as $row) { $rubprice = preg_replace('/.00$/', '', sprintf("%.2f", round($row['cost'] * $project_exRates[trim($translate_exRates[$row['currency']]) . '4'], 2))); $boss = $compname = $row['uname'] . " " . $row['usurname']; $inn = $row['_1_inn']; $address = $row['_1_address']; $phone = $row['phis_phone']; $email = $row['phis_email']; $url = $row['site']; $postPosition = ''; $editDate = $row["edit_date"]; if (!$editDate) { $editDate = $row["post_date"]; } if ($row['form_type'] == 2) { $compname = $row['_2_full_name'] ? $row['_2_full_name'] : $row['compname']; $inn = $row['_2_inn']; $address = $row['_2_address_fct']; $phone = $row['jur_phone']; $email = $row['jur_email']; $url = $row['site']; $boss = $row['boss']; $postPosition = 'Генеральный директор'; } $filesData = self::getAllAttach($row['id']); $files = ''; if (count($filesData)) { $files = array(); foreach ($filesData as $file) { $files[] = "<file ID=\"{$file['file_id']}\">\n\t <url>{$file_url}</url>\n\t <name>{$file['name']}</name>\n\t <type>Документация</type>\n\t <lastUpdate>{$row['modified']}</lastUpdate>\n\t </file>"; } $files = "<files>" . join("\n", $files) . "</files>"; } $offers = ''; if (count($filesData)) { $offersData = projects_offers::GetPrjOffers($c, $row['id'], 'ALL'); $offers = array(); foreach ($offersData as $offer) { $winner = "isWinner='1"; $status = "Исполнитель"; if ($row['exec_id'] != $offer['uid']) { $winner = ""; if ($offer['refused'] == 't') { $status = "Отказано"; } elseif ($offer['selected'] == 't') { $status = "Кандидат"; } } $cost = preg_replace('/.00$/', '', sprintf("%.2f", round($offer['cost_from'] * $project_exRates[trim($translate_exRates[$offer['cost_type']]) . '4'], 2))); $lancer = $offer['uname'] . " " . $offer['usurname']; $offers[] = "<competitor ID=\"1\" {$winner}>\n\t <name>{$lancer}</name>\n\t <cost>{$cost}</cost> \n\t <rating>{$offer['rating']}</rating>\n\t <status>{$status}</status>\n\t </competitor>"; } $offers = "<competitors>" . join("\n", $offers) . "</competitors>"; } $nodes[] = " <tender ID=\"{$row['id']}\" editDate = '{$editDate}'>\n <name>{$row['name']}</name>\n <type>Открытый конкурс</type>\n <dateStart>{$row['post_date']}</dateStart>\n <dateStop>{$row['end_date']}</dateStop>\n <text>{$row['descr']}</text>\n <cost>{$rubprice}</cost>\n <country>{$row['country_name']}</country>\n <address>Адрес проведения тендера</address>\n <field name='{$row['category']}'>\n <subfield>{$row['prof']}</subfield>\n </field>\n <company>\n <name>{$compname}</name>\n <inn>{$inn}</inn>\n <address>{$address}</address>\n <phone>{$phone}</phone>\n <email>{$email}</email>\n <url>{$url}</url>\n </company>\n\n <contact>\n <name>{$boss}</name>\n <position>{$postPosition}</position>\n </contact>\n {$files}\n {$offers}\n </tender>"; } $tenders = "<?xml version=\"1.0\" encoding=\"utf-8\"?> \n<tenders>" . join("\n", $nodes) . "</tenders>"; return iconv("WINDOWS-1251", "UTF-8//IGNORE", $tenders); }
header('Location: /404.php'); exit; } else { if (!$obj_project->CheckBlocked($prj_id) || hasPermissions('projects')) { $error .= $obj_project->SwitchStatusPrj($uid, $prj_id); header('Location: ' . getFriendlyURL('project', $project['id'])); exit; } } } break; } //Персональный проект //показываем одно единственное предложение if ($project['kind'] == 9) { $offers = $obj_offer->GetPrjOffers($num_offers, $prj_id, MAX_OFFERS_AT_PAGE, MAX_OFFERS_AT_PAGE * ($item_page - 1), $uid, TRUE, 'date', 'a'); $real_offers_count = current($obj_offer->CountPrjOffers($prj_id, 'all')); } else { switch ($_GET['sort']) { default: case 'date': $po_sort = 'date'; break; case 'time': $po_sort = 'time'; break; case 'cost': $po_sort = 'cost'; break; case 'rating': $po_sort = 'rating';
/** * Возврат ответов в случае блокировки проекта. * * @param int $project_id - ID проекта * * @return mixed - сообщение об ошибке или 0 в случае успеха */ public function ReturnAnswers($project_id) { global $DB; $descr = 'Возврат ответа на проект в связи с блокировкой проекта'; $op_code = $this->return_op_code; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects_offers.php'; $of = new projects_offers(); $offers = $of->GetPrjOffers($count, $project_id, 'ALL', 0, 0, true); if (!$count) { return; } require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/account.php'; $account = new account(); foreach ($offers as $offer) { $uid = $offer['user_id']; if ($offer['type'] == 0) { continue; } $transaction_id = $account->start_transaction($uid); $error = $account->Buy($billing_id, $transaction_id, $op_code, $uid, $descr, $descr, 0, 0); if ($error) { return $error; } if ($offer['type'] == 2) { $DB->query('UPDATE projects_offers_answers SET pay_offers = pay_offers + 1 WHERE uid = ?', $uid); } else { $free_cnt = self::FREE_ANSWERS_CNT; $DB->query("UPDATE projects_offers_answers \n SET free_offers = free_offers + (CASE WHEN free_offers < {$free_cnt} THEN 1 ELSE 0 END) WHERE uid = ?", $uid); } $account->commit_transaction($transaction_id, $uid, $billing_id); } }
/** * Получение одного проекта * * @param array $aParams массив входящих данных * @return array $aResult ответ */ protected function x____projects_get($aParams = array()) { $this->_validDevice($aParams); $sId = __paramValue('int', $aParams['id'], null, true); if (!empty($sId)) { require_once ABS_PATH . '/classes/projects.php'; $oPrj = new new_projects(); $aProject = $oPrj->GetPrjCust($sId); $aAttaches = $oPrj->getAllAttach($sId); if (!empty($aProject)) { if ($aProject['is_banned'] || $aProject['is_blocked']) { // работодатель или проест заблокированы $this->error(EXTERNAL_ERR_PROJECT_NOT_FOUND); } $aResult = array('item' => $this->_getProjectData($aProject)); $nUid = get_uid(false); $aSpecs = new_projects::getSpecs($sId); if (is_array($aSpecs) && $aSpecs) { $aResult['item']['category_id'] = $aSpecs[0]['category_id']; $aResult['item']['subcategory_id'] = $aSpecs[0]['subcategory_id']; } $aResult['item']['attaches'] = array(); if ($aAttaches) { foreach ($aAttaches as $attach) { $aResult['item']['attaches'][] = array("url" => WDCPREFIX . '/' . $attach['path'], "file" => $attach['name']); } } $aResult['item']['responses'] = array(); if ($aProject['kind'] == 7) { // конкурс require_once ABS_PATH . '/classes/contest.php'; $oContest = new contest($sId, $nUid, is_emp(), $aProject['user_id'] == $nUid, false, is_pro()); $oContest->GetOffers(); if (is_array($oContest->offers) && $oContest->offers) { foreach ($oContest->offers as $aOne) { $aResult['item']['responses'][] = $this->_getContestOfferData($aOne); } } } else { // проект require_once ABS_PATH . '/classes/projects_offers.php'; require_once ABS_PATH . '/classes/projects_offers_dialogue.php'; $oPrjOffers = new projects_offers(); $obj_dialogue = new projects_offers_dialogue(); $nOffersCnt = 0; if (is_emp()) { // залогинен работодатель $aOffers = $oPrjOffers->GetPrjOffers($nOffersCnt, $sId, 'ALL', 0, $nUid, $aProject['user_id'] == $nUid, 'date', $aProject['user_id'] == $nUid ? 'a' : 'nor'); } else { $aOffers = $oPrjOffers->GetPrjOffers($nOffersCnt, $sId, 'ALL', 0, $nUid, false, null, 'nor'); } // Диалоги по предложениям к данному проекту и все остальное if (is_array($aOffers) && $aOffers) { foreach ($aOffers as $key => $value) { $aOffers[$key]['exec_id'] = $aProject['exec_id']; $aOffers[$key]['emp_uid'] = $aProject['user_id']; $aOffers[$key]['dialogue'] = $obj_dialogue->GetDialogueForOffer($value['id']); $aResult['item']['responses'][] = $this->_getProjectOfferData($aOffers[$key]); } } $aResult['item']['responses_count'] = $nOffersCnt; $aResult['item']['is_responses_exists'] = $oPrjOffers->OfferExist($sId, $nUid) ? 1 : 2; // Наличие предложения данного юзера по данному проекту if ($aResult['item']['is_responses_exists'] == 1) { // Предложение данного пользователя по данному проекту $user_offer = $oPrjOffers->GetPrjOffer($sId, $nUid); $user_offer['exec_id'] = $aProject['exec_id']; $user_offer['emp_uid'] = $aProject['user_id']; // Диалог по предложению данного пользователя $user_offer['dialogue'] = $obj_dialogue->GetDialogueForOffer($user_offer['id']); $aResult['item']['responses'][] = $this->_getProjectOfferData($user_offer); } } } else { $this->error(EXTERNAL_ERR_PROJECT_NOT_FOUND); } } else { $this->error(EXTERNAL_ERR_EMPTY_PROJECT_ID); } return $aResult; }