示例#1
0
 public function testProjectUpdate()
 {
     $this->assertTrue(Project::updateProject(1, array('pro_descripcion' => 'nueva_desc')));
     $this->assertTrue(Project::updateProject(1, array('pro_tit' => 'nuevo titulo 2')));
     $this->assertTrue(Project::updateProject(1, array('pro_country' => 'MK')));
     $this->assertTrue(Project::updateProject(1, array('pro_country' => 'MK', 'pro_tit' => 'nuevo titulo 3')));
     $this->assertTrue(Project::updateProject(1, array('pro_date' => '2015-06-02 00:00:00', 'pro_date_end' => '2015-09-02 00:00:00')));
     $this->assertTrue(Project::updateProject(1, array('pro_cant' => '52', 'pro_cp' => '99999')));
     $this->assertTrue(Project::updateProject(1, array('pro_type' => '2', 'pro_category' => '2')));
     $this->assertTrue(Project::updateProject(1, array('pro_status' => 'E', 'pro_address' => 'mi casa', 'pro_state' => 'el estei', 'pro_city' => 'la citiman')));
     $this->assertTrue(Project::updateProject(1, array('user_id' => '5', 'pro_address' => 'mi casa', 'pro_state' => 'el estei', 'pro_city' => 'la citiman')));
 }
示例#2
0
 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;
 }
示例#3
0
    $data['pro_environment'] = $app->getRequest()->post('pro_environment');
    $data['pro_moment'] = $app->getRequest()->post('pro_moment');
    $proDeadline = str_replace('/', '-', $app->getRequest()->post('pro_deadline'));
    if (!empty($proDeadline)) {
        $projectDeadline = date('Y-m-d H:i:s', strtotime($proDeadline));
    }
    $data['pro_deadline'] = $projectDeadline;
    if ($error) {
        $app->addError("La información suministrada para la creación del proyecto es inválida.");
        $app->getInput()->save();
        //flash form data
        $app->redirect($app->getHelper('UrlHelper')->getUrl('agregarProyecto?id=' . $proId));
        return;
    }
    // END - Server side validations
    $result = Project::updateProject($proId, $data);
    if (!$result) {
        $app->addError("La información suministrada para la creación del proyecto es inválida.");
        $app->getInput()->save();
        //flash form data
        $app->redirect($app->getHelper('UrlHelper')->getUrl('agregarProyecto?id=' . $proId));
        return;
    }
    //Success
    $projectUrl = $app->getHelper('UrlHelper')->getProjectUrl($proId);
    $app->addMessage('Tu proyecto se ha guardo con éxito. <a href="{0}">Ir al proyecto</a>', $projectUrl);
    $app->redirect($app->getHelper('UrlHelper')->getUrl("perfil"));
    return;
}
//oferta
if ($act == "oferta") {