Ejemplo n.º 1
0
 *  Goteo is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Goteo is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with Goteo.  If not, see <http://www.gnu.org/licenses/agpl.txt>.
 *
 */
use Goteo\Core\View, Goteo\Library\Text, Goteo\Model\Project\Reward, Goteo\Model\Invest;
$icons = Reward::icons('individual');
$project = $this['project'];
$rewards = $this['rewards'];
// recompensas ordenadas por importe
uasort($rewards, function ($a, $b) {
    if ($a->amount == $b->amount) {
        return 0;
    }
    return $a->amount > $b->amount ? 1 : -1;
});
$invests = $this['invests'];
$filter = $this['filter'];
// al ir mostrando, quitamos los que no cumplan
// pending = solo los que tienen alguna recompensa pendientes
// fulfilled = solo los que tienen todas las recompensas cumplidas
// resign = solo los que hicieron renuncia a recompensa
Ejemplo n.º 2
0
 private function process_rewards(&$project, &$errors)
 {
     if (!isset($_POST['process_rewards'])) {
         return false;
     }
     $types = Model\Project\Reward::icons('');
     //tratar retornos sociales
     foreach ($project->social_rewards as $k => $reward) {
         if (!empty($_POST["social_reward-{$reward->id}-remove"])) {
             unset($project->social_rewards[$k]);
             continue;
         }
         if (isset($_POST['social_reward-' . $reward->id . '-reward'])) {
             $reward->reward = $_POST['social_reward-' . $reward->id . '-reward'];
             $reward->description = $_POST['social_reward-' . $reward->id . '-description'];
             $reward->icon = $_POST['social_reward-' . $reward->id . '-icon'];
             if ($reward->icon == 'other') {
                 $reward->other = $_POST['social_reward-' . $reward->id . '-other'];
             }
             $reward->license = $_POST['social_reward-' . $reward->id . '-' . $reward->icon . '-license'];
             $reward->icon_name = $types[$reward->icon]->name;
         }
     }
     // retornos individuales
     foreach ($project->individual_rewards as $k => $reward) {
         if (!empty($_POST["individual_reward-{$reward->id}-remove"])) {
             unset($project->individual_rewards[$k]);
             continue;
         }
         if (isset($_POST['individual_reward-' . $reward->id . '-reward'])) {
             $reward->reward = $_POST['individual_reward-' . $reward->id . '-reward'];
             $reward->description = $_POST['individual_reward-' . $reward->id . '-description'];
             $reward->icon = $_POST['individual_reward-' . $reward->id . '-icon'];
             if ($reward->icon == 'other') {
                 $reward->other = $_POST['individual_reward-' . $reward->id . '-other'];
             }
             $reward->amount = $_POST['individual_reward-' . $reward->id . '-amount'];
             $reward->units = $_POST['individual_reward-' . $reward->id . '-units'];
             $reward->icon_name = $types[$reward->icon]->name;
         }
     }
     // tratar nuevos retornos
     if (!empty($_POST['social_reward-add'])) {
         $project->social_rewards[] = new Model\Project\Reward(array('type' => 'social', 'project' => $project->id, 'reward' => 'Nuevo retorno colectivo', 'icon' => '', 'license' => ''));
     }
     if (!empty($_POST['individual_reward-add'])) {
         $project->individual_rewards[] = new Model\Project\Reward(array('type' => 'individual', 'project' => $project->id, 'reward' => 'Nueva recompensa individual', 'icon' => '', 'amount' => '', 'units' => ''));
     }
     return true;
 }