public static function adjudicateProject($projectId, $offerId) { $userFields = array(User::PROFILE_DIRECTION, User::PROFILE_MOVIL, User::PROFILE_CITY); //Load proyect and offer $project = Project::loadById($projectId); $projectOwner = User::getUserInfo($project->user_id, $userFields); if (Project::canBeAdjudicated($project)) { $offer = Offer::getOffer($offerId); $winner = User::getUserInfo($offer->user_id, $userFields); //Set project as adjudicated $data = array('pro_status' => Project::PROJECT_STATUS_ADJUDICATED, 'pro_date_end' => date('Y-m-d H:i:s', time())); Project::updateProject($project->pro_id, $data); //Set offer as winner $data = array('awarded' => Offer::STATUS_AWARDED); Offer::updateOffer($offer->id, $data); //Send notificacions and emails self::notifyWinner($project, $projectOwner, $winner); // Send email to winner self::emailWinner($offer, $winner, $project, $projectOwner); // Send email to project owner self::emailProjectOwner($offer, $winner, $project, $projectOwner); // Notifiy other photographers about denied offers. Losers :D self::notifyLosers($project); //Track event in analytics // Event = Proyectos adjudicados $eventData = new \stdClass(); $eventData->user_id = $projectOwner['id']; $eventData->photograph_id = $winner['id']; $eventData->project_name = $project->pro_tit; $events = FAnalytics::getInstance(); $events->trackEvent('Proyecto', 'Proyectos adjudicados', json_encode($eventData)); } else { //TODO Oh oh... strong notification here about this fail return false; } return true; }
// endif; //valida que el usuario que visita no haya hecho una oferta antes al proyecto $oferta_user = listAll("ofertas", "WHERE pro_id = '{$id_pro}' AND user_id = '{$current_user->id}'"); $rows_oferta = mysql_num_rows($oferta_user); if ($rows_oferta > 0) { $ofertas = "S"; } else { $ofertas = "N"; } //busca la oferta bas baja $oferta_baja = listAll("ofertas", "WHERE pro_id = '{$id_pro}' ORDER BY bid ASC LIMIT 0,1"); $rows_ob = mysql_fetch_object($oferta_baja); $winnerOffer = null; $winnerOfferOwner = null; if ($rs_pro->oferta_adjudicada_id) { $winnerOffer = Offer::getOffer($rs_pro->oferta_adjudicada_id); $winnerOfferOwner = getUserInfo($rs_pro->oferta_user_id); } $currentUserOffer = listAll("ofertas", "WHERE pro_id = '{$id_pro}' AND user_id = '{$current_user->id}'"); $currentUserOffer = mysql_fetch_object($currentUserOffer); ?> <script src="<?php echo FConfig::getUrl('js/popModal.js'); ?> "></script> <div class="project-info clearfix"> <h2 class="main-title"> <?php