public function activity($option = 'summary', $action = 'view') { // quitamos el stepped para que no nos lo coja para el siguiente proyecto que editemos if (isset($_SESSION['stepped'])) { unset($_SESSION['stepped']); } $user = $_SESSION['user']; $viewData = array('menu' => self::menu(), 'section' => __FUNCTION__, 'option' => $option, 'action' => $action); // portada if ($option == 'summary') { $page = Page::get('dashboard'); $viewData['message'] = \str_replace('%USER_NAME%', $_SESSION['user']->name, $page->content); $viewData['lists'] = Dashboard\Activity::projList($user); $viewData['status'] = Model\Project::status(); } //@TODO: if ($option == 'wall') Dashboard\Activity::wall($user); // si es un salto a otro panel if (in_array($option, array('admin', 'review', 'translate'))) { if (ACL::check('/' . $option)) { throw new Redirection('/' . $option, Redirection::TEMPORARY); } else { throw new Redirection('/dashboard', Redirection::TEMPORARY); } } return new View('view/dashboard/index.html.php', $viewData); }
public static function getAll($activeonly = false, $node = \GOTEO_NODE) { // estados $status = Project::status(); $promos = array(); $sqlFilter = $activeonly ? " AND promote.active = 1" : ''; $query = static::query("\n SELECT\n promote.id as id,\n promote.project as project,\n project.name as name,\n project.status as status,\n IFNULL(promote_lang.title, promote.title) as title,\n IFNULL(promote_lang.description, promote.description) as description,\n promote.order as `order`,\n promote.active as `active`\n FROM promote\n LEFT JOIN promote_lang\n ON promote_lang.id = promote.id\n AND promote_lang.lang = :lang\n INNER JOIN project\n ON project.id = promote.project\n WHERE promote.node = :node\n {$sqlFilter}\n ORDER BY `order` ASC, title ASC\n ", array(':node' => $node, ':lang' => \LANG)); foreach ($query->fetchAll(\PDO::FETCH_CLASS, __CLASS__) as $promo) { $promo->description = Text::recorta($promo->description, 100, false); $promo->status = $status[$promo->status]; $promos[] = $promo; } return $promos; }
public static function getAll($activeonly = false, $node = \GOTEO_NODE) { // estados $status = Project::status(); $banners = array(); $sqlFilter = $activeonly ? " AND banner.active = 1" : ''; $query = static::query("\n SELECT\n banner.id as id,\n banner.node as node,\n banner.project as project,\n project.name as name,\n IFNULL(banner_lang.title, banner.title) as title,\n IFNULL(banner_lang.description, banner.description) as description,\n banner.url as url,\n project.status as status,\n banner.image as image,\n banner.order as `order`,\n banner.active as `active`\n FROM banner\n LEFT JOIN project\n ON project.id = banner.project\n LEFT JOIN banner_lang\n ON banner_lang.id = banner.id\n AND banner_lang.lang = :lang\n WHERE banner.node = :node\n {$sqlFilter}\n ORDER BY `order` ASC\n ", array(':node' => $node, ':lang' => \LANG)); foreach ($query->fetchAll(\PDO::FETCH_CLASS, __CLASS__) as $banner) { $banner->image = !empty($banner->image) ? Image::get($banner->image) : null; $banner->status = $status[$banner->status]; $banners[] = $banner; } return $banners; }
public static function process($action = 'list', $id = null, $filters = array()) { $node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE; // métodos de pago $methods = Model\Invest::methods(); // estados del proyecto $status = Model\Project::status(); // estados de aporte $investStatus = Model\Invest::status(); // listado de proyectos $projects = Model\Invest::projects(false, $node); // usuarios cofinanciadores $users = Model\Invest::users(true); // campañas que tienen aportes $calls = Model\Invest::calls(); // extras $types = array('donative' => 'Solo los donativos', 'anonymous' => 'Solo los anónimos', 'manual' => 'Solo los manuales', 'campaign' => 'Solo con riego'); // detalles del aporte if ($action == 'details') { $invest = Model\Invest::get($id); $project = Model\Project::get($invest->project); $userData = Model\User::get($invest->user); if (!empty($invest->droped)) { $droped = Model\Invest::get($invest->droped); } else { $droped = null; } if ($project->node != $node) { throw new Redirection('/admin/invests'); } return new View('view/admin/index.html.php', array('folder' => 'invests', 'file' => 'details', 'invest' => $invest, 'project' => $project, 'user' => $userData, 'status' => $status, 'investStatus' => $investStatus, 'droped' => $droped, 'calls' => $calls)); } // listado de aportes if ($filters['filtered'] == 'yes') { if (!empty($filters['calls'])) { $filters['types'] = ''; } $list = Model\Invest::getList($filters, $node, 999); } else { $list = array(); } $viewData = array('folder' => 'invests', 'file' => 'list', 'list' => $list, 'filters' => $filters, 'projects' => $projects, 'users' => $users, 'calls' => $calls, 'methods' => $methods, 'types' => $types, 'investStatus' => $investStatus); return new View('view/admin/index.html.php', $viewData); }
public static function process($action = 'list', $id = null, $filters = array()) { switch ($action) { case 'fulfill': $sql = "UPDATE invest_reward SET fulfilled = 1 WHERE invest = ?"; if (Model\Invest::query($sql, array($id))) { Message::Info(Text::get('admin-rewards-info-status-completed')); } else { Message::Error(Text::get('admin-rewards-error-statuschage-fail')); } throw new Redirection('/admin/rewards'); break; case 'unfill': $sql = "UPDATE invest_reward SET fulfilled = 0 WHERE invest = ?"; if (Model\Invest::query($sql, array($id))) { Message::Info(Text::get('admin-rewards-info-status-completed-pending')); } else { message::Error('Ha fallado al desmarcar'); } throw new Redirection('/admin/rewards'); break; } // edicion if ($action == 'edit' && !empty($id)) { $invest = Model\Invest::get($id); $projectData = Model\Project::get($invest->project); $userData = Model\User::getMini($invest->user); $status = Model\Project::status(); // si tratando post if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update'])) { $errors = array(); // la recompensa: $chosen = $_POST['selected_reward']; if (empty($chosen)) { // renuncia a las recompensas, bien por el/ella! $invest->rewards = array(); } else { $invest->rewards = array($chosen); } $invest->anonymous = $_POST['anonymous']; // dirección de envio para la recompensa // y datos fiscales por si fuera donativo $invest->address = (object) array('name' => $_POST['name'], 'nif' => $_POST['nif'], 'address' => $_POST['address'], 'zipcode' => $_POST['zipcode'], 'location' => $_POST['location'], 'country' => $_POST['country']); if ($invest->update($errors)) { Message::Info(Text::get('admin-rewards-info-update')); throw new Redirection('/admin/rewards'); } else { Message::Error('No se han actualizado correctamente los datos del aporte. ERROR: ' . implode(', ', $errors)); } } return new View('view/admin/index.html.php', array('folder' => 'rewards', 'file' => 'edit', 'invest' => $invest, 'project' => $projectData, 'user' => $userData, 'status' => $status)); } // listado de proyectos $projects = Model\Invest::projects(); $status = array('nok' => Text::_("Pendiente"), 'ok' => Text::_("Cumplida")); // listado de aportes if ($filters['filtered'] == 'yes') { $list = Model\Project\Reward::getChossen($filters); } else { $list = array(); } return new View('view/admin/index.html.php', array('folder' => 'rewards', 'file' => 'list', 'list' => $list, 'filters' => $filters, 'projects' => $projects, 'status' => $status)); }
public static function process($action = 'list', $id = null, $filters = array()) { $errors = array(); // reubicando aporte, if ($action == 'move') { // el aporte original $original = Model\Invest::get($id); $userData = Model\User::getMini($original->user); $projectData = Model\Project::getMini($original->project); //el original tiene que ser de tpv o cash y estar como 'cargo ejecutado' if ($original->method == 'paypal' || $original->status != 1) { Message::Error('No se puede reubicar este aporte!'); throw new Redirection('/admin/accounts'); } // generar aporte manual y caducar el original if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['move'])) { // si falta proyecto, error $projectNew = $_POST['project']; // @TODO a saber si le toca dinero de alguna convocatoria $campaign = null; $invest = new Model\Invest(array('amount' => $original->amount, 'user' => $original->user, 'project' => $projectNew, 'account' => $userData->email, 'method' => 'cash', 'status' => '1', 'invested' => date('Y-m-d'), 'charged' => $original->charged, 'anonymous' => $original->anonymous, 'resign' => $original->resign, 'admin' => $_SESSION['user']->id, 'campaign' => $campaign)); //@TODO si el proyecto seleccionado if ($invest->save($errors)) { //recompensas que le tocan (si no era resign) if (!$original->resign) { // sacar recompensas $rewards = Model\Project\Reward::getAll($projectNew, 'individual'); foreach ($rewards as $rewId => $rewData) { $invest->setReward($rewId); //asignar } } // cambio estado del aporte original a 'Reubicado' (no aparece en cofinanciadores) // si tuviera que aparecer lo marcaríamos como caducado if ($original->setStatus('5')) { // Evento Feed $log = new Feed(); $log->setTarget($projectData->id); $log->populate('Aporte reubicado', '/admin/accounts', \vsprintf("%s ha aportado %s al proyecto %s en nombre de %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('money', $_POST['amount'] . ' €'), Feed::item('project', $projectData->name, $projectData->id), Feed::item('user', $userData->name, $userData->id)))); $log->doAdmin('money'); unset($log); Message::Info('Aporte reubicado correctamente'); throw new Redirection('/admin/accounts'); } else { $errors[] = 'A fallado al cambiar el estado del aporte original (' . $original->id . ')'; } } else { $errors[] = 'Ha fallado algo al reubicar el aporte'; } } $viewData = array('folder' => 'accounts', 'file' => 'move', 'original' => $original, 'user' => $userData, 'project' => $projectData); return new View('view/admin/index.html.php', $viewData); // fin de la historia dereubicar } // cambiando estado del aporte aporte, if ($action == 'update') { // el aporte original $invest = Model\Invest::get($id); if (!$invest instanceof Model\Invest) { Message::Error('No tenemos registro del aporte ' . $id); throw new Redirection('/admin/accounts'); } $status = Model\Invest::status(); $new = isset($_POST['status']) ? $_POST['status'] : null; if ($invest->issue && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update']) && $_POST['resolve'] == 1) { Model\Invest::unsetIssue($id); Model\Invest::setDetail($id, 'issue-solved', 'La incidencia se ha dado por resuelta por el usuario ' . $_SESSION['user']->name); Message::Info('La incidencia se ha dado por resuelta'); } if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['update']) && isset($new) && isset($status[$new])) { if ($new != $invest->status) { if (Model\Invest::query("UPDATE invest SET status=:status WHERE id=:id", array(':id' => $id, ':status' => $new))) { Model\Invest::setDetail($id, 'status-change' . rand(0, 9999), 'El admin ' . $_SESSION['user']->name . ' ha cambiado el estado del apote a ' . $status[$new]); Message::Info('Se ha actualizado el estado del aporte'); } else { Message::Error('Ha fallado al actualizar el estado del aporte'); } } else { Message::Error('No se ha cambiado el estado'); } throw new Redirection('/admin/accounts/details/' . $id); } return new View('view/admin/index.html.php', array('folder' => 'accounts', 'file' => 'update', 'invest' => $invest, 'status' => $status)); // fin de la historia actualizar estado } // resolviendo incidencias if ($action == 'solve') { // el aporte original $invest = Model\Invest::get($id); if (!$invest instanceof Model\Invest) { Message::Error('No tenemos registro del aporte ' . $id); throw new Redirection('/admin/accounts'); } $projectData = Model\Project::getMini($invest->project); $errors = array(); // primero cancelar switch ($invest->method) { case 'paypal': $err = array(); if (Paypal::cancelPreapproval($invest, $err)) { $errors[] = 'Preaproval paypal cancelado.'; $log_text = "El admin %s ha cancelado aporte y preapproval de %s de %s mediante PayPal (id: %s) al proyecto %s del dia %s"; } else { $txt_errors = implode('; ', $err); $errors[] = 'Fallo al cancelar el preapproval en paypal: ' . $txt_errors; $log_text = "El admin %s ha fallado al cancelar el aporte de %s de %s mediante PayPal (id: %s) al proyecto %s del dia %s. <br />Se han dado los siguientes errores: {$txt_errors}"; if ($invest->cancel()) { $errors[] = 'Aporte cancelado'; } else { $errors[] = 'Fallo al cancelar el aporte'; } } break; case 'tpv': $err = array(); if (Tpv::cancelPreapproval($invest, $err)) { $txt_errors = implode('; ', $err); $errors[] = 'Aporte cancelado correctamente. ' . $txt_errors; $log_text = "El admin %s ha anulado el cargo tpv de %s de %s mediante TPV (id: %s) al proyecto %s del dia %s"; } else { $txt_errors = implode('; ', $err); $errors[] = 'Fallo en la operación. ' . $txt_errors; $log_text = "El admin %s ha fallado al solicitar la cancelación del cargo tpv de %s de %s mediante TPV (id: %s) al proyecto %s del dia %s. <br />Se han dado los siguientes errores: {$txt_errors}"; } break; case 'cash': if ($invest->cancel()) { $log_text = "El admin %s ha cancelado aporte manual de %s de %s (id: %s) al proyecto %s del dia %s"; $errors[] = 'Aporte cancelado'; } else { $log_text = "El admin %s ha fallado al cancelar el aporte manual de %s de %s (id: %s) al proyecto %s del dia %s. "; $errors[] = 'Fallo al cancelar el aporte'; } break; } // Evento Feed $log = new Feed(); $log->setTarget($projectData->id); $log->populate('Cargo cancelado manualmente (admin)', '/admin/accounts', \vsprintf($log_text, array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('user', $userData->name, $userData->id), Feed::item('money', $invest->amount . ' €'), Feed::item('system', $invest->id), Feed::item('project', $projectData->name, $projectData->id), Feed::item('system', date('d/m/Y', strtotime($invest->invested)))))); $log->doAdmin(); unset($log); // luego resolver if ($invest->solve($errors)) { // Evento Feed $log = new Feed(); $log->setTarget($projectData->id); $log->populate('Incidencia resuelta (admin)', '/admin/accounts', \vsprintf("El admin %s ha dado por resuelta la incidencia con el botón \"Nos han hecho la transferencia\" para el aporte %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('system', $id, 'accounts/details/' . $id)))); $log->doAdmin('admin'); unset($log); Message::Info('La incidencia se ha dado por resuelta, el aporte se ha pasado a manual y cobrado'); throw new Redirection('/admin/accounts'); } else { // Evento Feed $log = new Feed(); $log->setTarget($projectData->id); $log->populate('Fallo al resolver incidencia (admin)', '/admin/accounts', \vsprintf("Al admin %s le ha fallado el botón \"Nos han hecho la transferencia\" para el aporte %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('system', $id, 'accounts/details/' . $id)))); $log->doAdmin('admin'); unset($log); Message::Error('Ha fallado al resolver la incidencia: ' . implode(',', $errors)); throw new Redirection('/admin/accounts/details/' . $id); } } // aportes manuales, cargamos la lista completa de usuarios, proyectos y campañas if ($action == 'add') { // listado de proyectos en campaña $projects = Model\Project::active(false, true); // usuarios $users = Model\User::getAllMini(); // campañas //@CALLSYS $calls = array(); // generar aporte manual if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['add'])) { $userData = Model\User::getMini($_POST['user']); $projectData = Model\Project::getMini($_POST['project']); $invest = new Model\Invest(array('amount' => $_POST['amount'], 'user' => $userData->id, 'project' => $projectData->id, 'account' => $userData->email, 'method' => 'cash', 'status' => '1', 'invested' => date('Y-m-d'), 'charged' => date('Y-m-d'), 'anonymous' => $_POST['anonymous'], 'resign' => 1, 'admin' => $_SESSION['user']->id)); //@CALLSYS if ($invest->save($errors)) { // Evento Feed $log = new Feed(); $log->setTarget($projectData->id); $log->populate('Aporte manual (admin)', '/admin/accounts', \vsprintf("%s ha aportado %s al proyecto %s en nombre de %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('money', $_POST['amount'] . ' €'), Feed::item('project', $projectData->name, $projectData->id), Feed::item('user', $userData->name, $userData->id)))); $log->doAdmin('money'); unset($log); Model\Invest::setDetail($invest->id, 'admin-created', 'Este aporte ha sido creado manualmente por el admin ' . $_SESSION['user']->name); Message::Info('Aporte manual creado correctamente, seleccionar recompensa y dirección de entrega.'); throw new Redirection('/admin/rewards/edit/' . $invest->id); } else { $errors[] = 'Ha fallado algo al crear el aporte manual'; } } $viewData = array('folder' => 'accounts', 'file' => 'add', 'autocomplete' => true, 'users' => $users, 'projects' => $projects, 'calls' => $calls); return new View('view/admin/index.html.php', $viewData); // fin de la historia } // Informe de la financiación de un proyecto if ($action == 'report') { // estados de aporte $project = Model\Project::get($id); if (!$project instanceof Model\Project) { Message::Error('Instancia de proyecto no valida'); throw new Redirection('/admin/accounts'); } $invests = Model\Invest::getAll($id); $project->investors = Model\Invest::investors($id, false, true); $users = $project->agregateInvestors(); $investStatus = Model\Invest::status(); // Datos para el informe de transacciones correctas $Data = Model\Invest::getReportData($project->id, $project->status, $project->round, $project->passed); return new View('view/admin/index.html.php', array('folder' => 'accounts', 'file' => 'report', 'invests' => $invests, 'project' => $project, 'status' => $status, 'users' => $users, 'investStatus' => $investStatus, 'Data' => $Data)); } // cancelar aporte antes de ejecución, solo aportes no cargados if ($action == 'cancel') { $invest = Model\Invest::get($id); if (!$invest instanceof Model\Invest) { Message::Error('No tenemos objeto para el aporte ' . $id); throw new Redirection('/admin/accounts'); } $project = Model\Project::get($invest->project); $userData = Model\User::get($invest->user); if ($project->status > 3 && $project->status < 6) { $errors[] = 'No debería poderse cancelar un aporte cuando el proyecto ya está financiado. Si es imprescindible, hacerlo desde el panel de paypal o tpv'; break; } switch ($invest->method) { case 'paypal': $err = array(); if (Paypal::cancelPreapproval($invest, $err)) { $errors[] = 'Preaproval paypal cancelado.'; $log_text = "El admin %s ha cancelado aporte y preapproval de %s de %s mediante PayPal (id: %s) al proyecto %s del dia %s"; } else { $txt_errors = implode('; ', $err); $errors[] = 'Fallo al cancelar el preapproval en paypal: ' . $txt_errors; $log_text = "El admin %s ha fallado al cancelar el aporte de %s de %s mediante PayPal (id: %s) al proyecto %s del dia %s. <br />Se han dado los siguientes errores: {$txt_errors}"; if ($invest->cancel()) { $errors[] = 'Aporte cancelado'; } else { $errors[] = 'Fallo al cancelar el aporte'; } } break; case 'tpv': $err = array(); if (Tpv::cancelPreapproval($invest, $err)) { $txt_errors = implode('; ', $err); $errors[] = 'Aporte cancelado correctamente. ' . $txt_errors; $log_text = "El admin %s ha anulado el cargo tpv de %s de %s mediante TPV (id: %s) al proyecto %s del dia %s"; } else { $txt_errors = implode('; ', $err); $errors[] = 'Fallo en la operación. ' . $txt_errors; $log_text = "El admin %s ha fallado al solicitar la cancelación del cargo tpv de %s de %s mediante TPV (id: %s) al proyecto %s del dia %s. <br />Se han dado los siguientes errores: {$txt_errors}"; } break; case 'cash': if ($invest->cancel()) { $log_text = "El admin %s ha cancelado aporte manual de %s de %s (id: %s) al proyecto %s del dia %s"; $errors[] = 'Aporte cancelado'; } else { $log_text = "El admin %s ha fallado al cancelar el aporte manual de %s de %s (id: %s) al proyecto %s del dia %s. "; $errors[] = 'Fallo al cancelar el aporte'; } break; } // Evento Feed $log = new Feed(); $log->setTarget($project->id); $log->populate('Cargo cancelado manualmente (admin)', '/admin/accounts', \vsprintf($log_text, array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('user', $userData->name, $userData->id), Feed::item('money', $invest->amount . ' €'), Feed::item('system', $invest->id), Feed::item('project', $project->name, $project->id), Feed::item('system', date('d/m/Y', strtotime($invest->invested)))))); $log->doAdmin(); Model\Invest::setDetail($invest->id, 'manually-canceled', $log->html); unset($log); } // ejecutar cargo ahora!!, solo aportes no ejecutados // si esta pendiente, ejecutar el cargo ahora (como si fuera final de ronda), deja pendiente el pago secundario if ($action == 'execute' && $invest->status == 0) { $invest = Model\Invest::get($id); if (!$invest instanceof Model\Invest) { Message::Error('No tenemos objeto para el aporte ' . $id); throw new Redirection('/admin/accounts'); } $project = Model\Project::get($invest->project); $userData = Model\User::get($invest->user); switch ($invest->method) { case 'paypal': // a ver si tiene cuenta paypal $projectAccount = Model\Project\Account::get($invest->project); if (empty($projectAccount->paypal)) { // Erroraco! $errors[] = 'El proyecto no tiene cuenta paypal!!, ponersela en la seccion Contrato del dashboard del autor'; $log_text = null; // Evento Feed $log = new Feed(); $log->setTarget($project->id); $log->populate('proyecto sin cuenta paypal (admin)', '/admin/projects', \vsprintf('El proyecto %s aun no ha puesto su %s !!!', array(Feed::item('project', $project->name, $project->id), Feed::item('relevant', 'cuenta PayPal')))); $log->doAdmin('project'); unset($log); break; } $invest->account = $projectAccount->paypal; if (Paypal::pay($invest, $errors)) { $errors[] = 'Cargo paypal correcto'; $log_text = "El admin %s ha ejecutado el cargo a %s por su aporte de %s mediante PayPal (id: %s) al proyecto %s del dia %s"; $invest->status = 1; // si era incidencia la desmarcamos if ($invest->issue) { Model\Invest::unsetIssue($invest->id); Model\Invest::setDetail($invest->id, 'issue-solved', 'La incidencia se ha dado por resuelta al ejecutar el aporte manualmente por el admin ' . $_SESSION['user']->name); } } else { $txt_errors = implode('; ', $errors); $errors[] = 'Fallo al ejecutar cargo paypal: ' . $txt_errors . '<strong>POSIBLE INCIDENCIA NO COMUNICADA Y APORTE NO CANCELADO, HAY QUE TRATARLA MANUALMENTE</strong>'; $log_text = "El admin %s ha fallado al ejecutar el cargo a %s por su aporte de %s mediante PayPal (id: %s) al proyecto %s del dia %s. <br />Se han dado los siguientes errores: {$txt_errors}"; } break; case 'tpv': if (Tpv::pay($invest, $errors)) { $errors[] = 'Cargo sermepa correcto'; $log_text = "El admin %s ha ejecutado el cargo a %s por su aporte de %s mediante TPV (id: %s) al proyecto %s del dia %s"; $invest->status = 1; } else { $txt_errors = implode('; ', $errors); $errors[] = 'Fallo al ejecutar cargo sermepa: ' . $txt_errors; $log_text = "El admin %s ha fallado al ejecutar el cargo a %s por su aporte de %s mediante TPV (id: %s) al proyecto %s del dia %s <br />Se han dado los siguientes errores: {$txt_errors}"; } break; case 'cash': $invest->setStatus('1'); $errors[] = 'Aporte al contado, nada que ejecutar.'; $log_text = "El admin %s ha dado por ejecutado el aporte manual a nombre de %s por la cantidad de %s (id: %s) al proyecto %s del dia %s"; $invest->status = 1; break; } if (!empty($log_text)) { // Evento Feed $log = new Feed(); $log->setTarget($project->id); $log->populate('Cargo ejecutado manualmente (admin)', '/admin/accounts', \vsprintf($log_text, array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('user', $userData->name, $userData->id), Feed::item('money', $invest->amount . ' €'), Feed::item('system', $invest->id), Feed::item('project', $project->name, $project->id), Feed::item('system', date('d/m/Y', strtotime($invest->invested)))))); $log->doAdmin(); Model\Invest::setDetail($invest->id, 'manually-executed', $log->html); unset($log); } } // visor de logs if ($action == 'viewer') { return new View('view/admin/index.html.php', array('folder' => 'accounts', 'file' => 'viewer')); } if ($action == 'resign' && !empty($id) && $_GET['token'] == md5('resign')) { if ($invest->setResign(true)) { Model\Invest::setDetail($invest->id, 'manually-resigned', 'Se ha marcado como donativo independientemente de las recompensas'); throw new Redirection('/admin/accounts/detail/' . $invest->id); } else { $errors[] = 'Ha fallado al marcar donativo'; } } if (!empty($errors)) { Message::Error(implode('<br />', $errors)); } // tipos de aporte $methods = Model\Invest::methods(); // estados del proyecto $status = Model\Project::status(); $procStatus = Model\Project::procStatus(); // estados de aporte $investStatus = Model\Invest::status(); // listado de proyectos $projects = Model\Invest::projects(); // usuarios cofinanciadores $users = Model\Invest::users(true); // campañas que tienen aportes $calls = Model\Invest::calls(); // extras $types = array('donative' => 'Solo los donativos', 'anonymous' => 'Solo los anónimos', 'manual' => 'Solo los manuales', 'campaign' => 'Solo con riego'); // filtros de revisión de proyecto $review = array('collect' => 'Recaudado', 'paypal' => 'Rev. PayPal', 'tpv' => 'Rev. TPV', 'online' => 'Pagos Online'); $issue = array('show' => 'Solamente las incidencias', 'hide' => 'Ocultar las incidencias'); /// detalles de una transaccion if ($action == 'details') { $invest = Model\Invest::get($id); $project = Model\Project::get($invest->project); $userData = Model\User::get($invest->user); return new View('view/admin/index.html.php', array('folder' => 'accounts', 'file' => 'details', 'invest' => $invest, 'project' => $project, 'user' => $userData, 'details' => $details, 'status' => $status, 'investStatus' => $investStatus)); } // listado de aportes if ($filters['filtered'] == 'yes') { $list = Model\Invest::getList($filters, null, 999); } else { $list = array(); } $viewData = array('folder' => 'accounts', 'file' => 'list', 'list' => $list, 'filters' => $filters, 'users' => $users, 'projects' => $projects, 'calls' => $calls, 'review' => $review, 'methods' => $methods, 'types' => $types, 'status' => $status, 'procStatus' => $procStatus, 'issue' => $issue, 'investStatus' => $investStatus); return new View('view/admin/index.html.php', $viewData); }
* 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\Library\Text, Goteo\Model; $promo = $this['promo']; $node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE; // proyectos disponibles // si tenemos ya proyecto seleccionado lo incluimos $projects = Model\Promote::available($promo->project, $node); $status = Model\Project::status(); ?> <form method="post" action="/admin/promote"> <input type="hidden" name="action" value="<?php echo $this['action']; ?> " /> <input type="hidden" name="order" value="<?php echo $promo->order; ?> " /> <input type="hidden" name="id" value="<?php echo $promo->id; ?> " />
public static function process($action = 'list', $id = null, $filters = array()) { $log_text = null; $errors = array(); // multiples usos $nodes = array(); if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['id'])) { $projData = Model\Project::get($_POST['id']); if (empty($projData->id)) { Message::Error('El proyecto ' . $_POST['id'] . ' no existe'); throw new Redirection('/admin/projects/images/' . $id); } if (isset($_POST['save-dates'])) { $fields = array('created', 'updated', 'published', 'success', 'closed', 'passed'); $set = ''; $values = array(':id' => $projData->id); foreach ($fields as $field) { if ($set != '') { $set .= ", "; } $set .= "`{$field}` = :{$field} "; if (empty($_POST[$field]) || $_POST[$field] == '0000-00-00') { $_POST[$field] = null; } $values[":{$field}"] = $_POST[$field]; } try { $sql = "UPDATE project SET " . $set . " WHERE id = :id"; if (Model\Project::query($sql, $values)) { $log_text = 'El admin %s ha <span class="red">tocado las fechas</span> del proyecto ' . $projData->name . ' %s'; } else { $log_text = 'Al admin %s le ha <span class="red">fallado al tocar las fechas</span> del proyecto ' . $projData->name . ' %s'; } } catch (\PDOException $e) { Message::Error(Text::_("No se ha guardado correctamente. ") . $e->getMessage()); } } elseif (isset($_POST['save-accounts'])) { $accounts = Model\Project\Account::get($projData->id); $accounts->bank = $_POST['bank']; $accounts->bank_owner = $_POST['bank_owner']; $accounts->paypal = $_POST['paypal']; $accounts->paypal_owner = $_POST['paypal_owner']; if ($accounts->save($errors)) { Message::Info(Text::_('Se han actualizado las cuentas del proyecto ') . $projData->name); } else { Message::Error(implode('<br />', $errors)); } } elseif ($action == 'images') { $todook = true; if (!empty($_POST['move'])) { $direction = $_POST['action']; Model\Project\Image::$direction($id, $_POST['move'], $_POST['section']); } foreach ($_POST as $key => $value) { $parts = explode('_', $key); if ($parts[1] == 'image' && in_array($parts[0], array('section', 'url'))) { if (Model\Project\Image::update($id, $parts[2], $parts[0], $value)) { // OK } else { $todook = false; Message::Error(Text::_('No se ha podido actualizar campo') . " {$parts[0]} -> {$value}"); } } } if ($todook) { Message::Info(Text::_('Se han actualizado los datos')); } throw new Redirection('/admin/projects/images/' . $id); } elseif ($action == 'rebase') { $todook = true; if ($_POST['proceed'] == 'rebase' && !empty($_POST['newid'])) { $newid = $_POST['newid']; // pimero miramos que no hay otro proyecto con esa id $test = Model\Project::getMini($newid); if ($test->id == $newid) { Message::Error(Text::_('Ya hay un proyecto con ese Id.')); throw new Redirection('/admin/projects/rebase/' . $id); } if ($projData->status >= 3 && $_POST['force'] != 1) { Message::Error(Text::_('El proyecto no está ni en Edición ni en Revisión, no se modifica nada.')); throw new Redirection('/admin/projects/rebase/' . $id); } if ($projData->rebase($newid)) { Message::Info(Text::_('Verificar el proyecto') . ' -> <a href="' . SITE_URL . '/project/' . $newid . '" target="_blank">' . $projData->name . '</a>'); throw new Redirection('/admin/projects'); } else { Message::Info(Text::_('Ha fallado algo en el rebase, verificar el proyecto') . ' -> <a href="' . SITE_URL . '/project/' . $projData->id . '" target="_blank">' . $projData->name . ' (' . $id . ')</a>'); throw new Redirection('/admin/projects/rebase/' . $id); } } } } /* * switch action, * proceso que sea, * redirect * */ if (isset($id)) { $project = Model\Project::get($id); } switch ($action) { case 'review': // pasar un proyecto a revision if ($project->ready($errors)) { $redir = '/admin/reviews/add/' . $project->id; $log_text = 'El admin %s ha pasado el proyecto %s al estado <span class="red">Revision</span>'; } else { $log_text = 'Al admin %s le ha fallado al pasar el proyecto %s al estado <span class="red">Revision</span>'; } break; case 'publish': // poner un proyecto en campa�a if ($project->publish($errors)) { $log_text = 'El admin %s ha pasado el proyecto %s al estado <span class="red">en Campa�a</span>'; } else { $log_text = 'Al admin %s le ha fallado al pasar el proyecto %s al estado <span class="red">en Campa�a</span>'; } break; case 'cancel': // descartar un proyecto por malo if ($project->cancel($errors)) { $log_text = 'El admin %s ha pasado el proyecto %s al estado <span class="red">Descartado</span>'; } else { $log_text = 'Al admin %s le ha fallado al pasar el proyecto %s al estado <span class="red">Descartado</span>'; } break; case 'enable': // si no esta en edicion, recuperarlo if ($project->enable($errors)) { $log_text = 'El admin %s ha pasado el proyecto %s al estado <span class="red">Edicion</span>'; } else { $log_text = 'Al admin %s le ha fallado al pasar el proyecto %s al estado <span class="red">Edicion</span>'; } break; case 'fulfill': // marcar que el proyecto ha cumplido con los retornos colectivos if ($project->satisfied($errors)) { $log_text = 'El admin %s ha pasado el proyecto %s al estado <span class="red">Retorno cumplido</span>'; } else { $log_text = 'Al admin %s le ha fallado al pasar el proyecto %s al estado <span class="red">Retorno cumplido</span>'; } break; case 'unfulfill': // dar un proyecto por financiado manualmente if ($project->rollback($errors)) { $log_text = 'El admin %s ha pasado el proyecto %s al estado <span class="red">Financiado</span>'; } else { $log_text = 'Al admin %s le ha fallado al pasar el proyecto %s al estado <span class="red">Financiado</span>'; } break; } if (isset($log_text)) { // Evento Feed $log = new Feed(); $log->setTarget($project->id); $log->populate(Text::_('Cambio estado/fechas/cuentas/nodo de un proyecto desde el admin'), '/admin/projects', \vsprintf($log_text, array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('project', $project->name, $project->id)))); $log->doAdmin('admin'); Message::Info($log->html); if (!empty($errors)) { Message::Error(implode('<br />', $errors)); } if ($action == 'publish') { // si es publicado, hay un evento publico $log->populate($project->name, '/project/' . $project->id, Text::html('feed-new_project'), $project->gallery[0]->id); $log->doPublic('projects'); } unset($log); if (empty($redir)) { throw new Redirection('/admin/projects/list'); } else { throw new Redirection($redir); } } if ($action == 'report') { // informe financiero // Datos para el informe de transacciones correctas $Data = Model\Invest::getReportData($project->id, $project->status, $project->round, $project->passed); return new View('view/admin/index.html.php', array('folder' => 'projects', 'file' => 'report', 'project' => $project, 'Data' => $Data)); } if ($action == 'dates') { // cambiar fechas return new View('view/admin/index.html.php', array('folder' => 'projects', 'file' => 'dates', 'project' => $project)); } if ($action == 'accounts') { $accounts = Model\Project\Account::get($project->id); // cambiar fechas return new View('view/admin/index.html.php', array('folder' => 'projects', 'file' => 'accounts', 'project' => $project, 'accounts' => $accounts)); } if ($action == 'images') { // imagenes $images = array(); // secciones $sections = Model\Project\Image::sections(); foreach ($sections as $sec => $secName) { $secImages = Model\Project\Image::get($project->id, $sec); foreach ($secImages as $img) { $images[$sec][] = $img; } } return new View('view/admin/index.html.php', array('folder' => 'projects', 'file' => 'images', 'project' => $project, 'images' => $images, 'sections' => $sections)); } if ($action == 'move') { // cambiar el nodo return new View('view/admin/index.html.php', array('folder' => 'projects', 'file' => 'move', 'project' => $project, 'nodes' => $nodes)); } if ($action == 'rebase') { // cambiar la id return new View('view/admin/index.html.php', array('folder' => 'projects', 'file' => 'rebase', 'project' => $project)); } // Rechazo express if ($action == 'reject') { if (empty($project)) { Message::Error(Text::_('No hay proyecto sobre el que operar')); } else { // Obtenemos la plantilla para asunto y contenido $template = Template::get(40); // Sustituimos los datos $subject = str_replace('%PROJECTNAME%', $project->name, $template->title); $search = array('%USERNAME%', '%PROJECTNAME%'); $replace = array($project->user->name, $project->name); $content = \str_replace($search, $replace, $template->text); // iniciamos mail $mailHandler = new Mail(); $mailHandler->to = $project->user->email; $mailHandler->toName = $project->user->name; $mailHandler->subject = $subject; $mailHandler->content = $content; $mailHandler->html = true; $mailHandler->template = $template->id; if ($mailHandler->send()) { Message::Info('Se ha enviado un email a <strong>' . $project->user->name . '</strong> a la dirección <strong>' . $project->user->email . '</strong>'); } else { Message::Error('Ha fallado al enviar el mail a <strong>' . $project->user->name . '</strong> a la dirección <strong>' . $project->user->email . '</strong>'); } unset($mailHandler); } throw new Redirection('/admin/projects/list'); } if (!empty($filters['filtered'])) { $projects = Model\Project::getList($filters, $_SESSION['admin_node']); } else { $projects = array(); } $status = Model\Project::status(); $categories = Model\Project\Category::getAll(); //@CONTRACTSYS $calls = array(); // la lista de nodos la hemos cargado arriba $orders = array('name' => Text::_('Nombre'), 'updated' => Text::_('Enviado a revision')); return new View('view/admin/index.html.php', array('folder' => 'projects', 'file' => 'list', 'projects' => $projects, 'filters' => $filters, 'status' => $status, 'categories' => $categories, 'calls' => $calls, 'nodes' => $nodes, 'orders' => $orders)); }
} ?> <div class="widget"> <p><strong><?php echo $project->name ?></strong></p> <a class="button red" href="/project/edit/<?php echo $project->id ?>"><?php echo Text::get('regular-edit') ?></a> <a class="button" href="/project/<?php echo $project->id ?>" target="_blank"><?php echo Text::get('dashboard-menu-projects-preview') ?></a> <?php if ($project->status == 1) : ?> <a class="button weak" href="/project/delete/<?php echo $project->id ?>" onclick="return confirm('<?php echo Text::get('dashboard-project-delete_alert') ?>')"><?php echo Text::get('regular-delete') ?></a> <?php endif ?> </div> <div class="status"> <div id="project-status"> <h3><?php echo Text::get('form-project-status-title'); ?></h3> <ul> <?php foreach (Project::status() as $i => $s): ?> <li><?php if ($i == $project->status) echo '<strong>' ?><?php echo htmlspecialchars($s) ?><?php if ($i == $project->status) echo '</strong>' ?></li> <?php endforeach ?> </ul> </div> </div> <div id="meter-big" class="widget collapsable"> <?php echo new View('view/m/project/meter_hor_big.html.php', $this) ?> </div>
public static function process($action = 'list', $id = null, $filters = array()) { // año fiscal $year = Model\User\Donor::$currYear; $year0 = $year; $year1 = $year - 1; $errors = array(); $node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE; // Valores de filtro $interests = Model\User\Interest::getAll(); $status = Model\Project::status(); $methods = Model\Invest::methods(); $types = array('investor' => 'Cofinanciadores', 'owner' => 'Autores', 'user' => 'Usuarios'); $roles = array('admin' => 'Administrador', 'checker' => 'Revisor', 'translator' => 'Traductor'); // una variable de sesion para mantener los datos de todo esto if (!isset($_SESSION['mailing'])) { $_SESSION['mailing'] = array(); } switch ($action) { case 'edit': $_SESSION['mailing']['receivers'] = array(); $values = array(); $sqlFields = ''; $sqlInner = ''; $sqlFilter = ''; // cargamos los destiantarios //---------------------------- // por tipo de usuario switch ($filters['type']) { case 'investor': $sqlInner .= "INNER JOIN invest\n ON invest.user = user.id\n AND (invest.status = 0 OR invest.status = 1 OR invest.status = 3 OR invest.status = 4)\n INNER JOIN project\n ON project.id = invest.project\n "; $sqlFields .= ", project.name as project"; $sqlFields .= ", project.id as projectId"; break; case 'owner': $sqlInner .= "INNER JOIN project\n ON project.owner = user.id\n "; $sqlFields .= ", project.name as project"; $sqlFields .= ", project.id as projectId"; break; default: break; } $_SESSION['mailing']['filters_txt'] = 'los <strong>' . $types[$filters['type']] . '</strong> '; if (!empty($filters['project']) && !empty($sqlInner)) { $sqlFilter .= " AND project.name LIKE (:project) "; $values[':project'] = '%' . $filters['project'] . '%'; $_SESSION['mailing']['filters_txt'] .= 'de proyectos que su nombre contenga <strong>\'' . $filters['project'] . '\'</strong> '; } elseif (empty($filters['project']) && !empty($sqlInner)) { $_SESSION['mailing']['filters_txt'] .= 'de cualquier proyecto '; } if (isset($filters['status']) && $filters['status'] > -1 && !empty($sqlInner)) { $sqlFilter .= "AND project.status = :status "; $values[':status'] = $filters['status']; $_SESSION['mailing']['filters_txt'] .= 'en estado <strong>' . $status[$filters['status']] . '</strong> '; } elseif ($filters['status'] < 0 && !empty($sqlInner)) { $_SESSION['mailing']['filters_txt'] .= 'en cualquier estado '; } if ($filters['type'] == 'investor') { if (!empty($filters['method']) && !empty($sqlInner)) { $sqlFilter .= "AND invest.method = :method "; $values[':method'] = $filters['method']; $_SESSION['mailing']['filters_txt'] .= 'mediante <strong>' . $methods[$filters['method']] . '</strong> '; } elseif (empty($filters['method']) && !empty($sqlInner)) { $_SESSION['mailing']['filters_txt'] .= 'mediante cualquier metodo '; } } if (!empty($filters['interest'])) { $sqlInner .= "INNER JOIN user_interest\n ON user_interest.user = user.id\n AND user_interest.interest = :interest\n "; $values[':interest'] = $filters['interest']; if ($filters['interest'] == 15) { $_SESSION['mailing']['filters_txt'] .= 'del grupo de testeo '; } else { $_SESSION['mailing']['filters_txt'] .= 'interesados en fin <strong>' . $interests[$filters['interest']] . '</strong> '; } } if (!empty($filters['role'])) { $sqlInner .= "INNER JOIN user_role\n ON user_role.user_id = user.id\n AND user_role.role_id = :role\n "; $values[':role'] = $filters['role']; $_SESSION['mailing']['filters_txt'] .= 'que sean <strong>' . $roles[$filters['role']] . '</strong> '; } if (!empty($filters['name'])) { $sqlFilter .= " AND ( user.name LIKE (:name) OR user.email LIKE (:name) ) "; $values[':name'] = '%' . $filters['name'] . '%'; $_SESSION['mailing']['filters_txt'] .= 'que su nombre o email contenga <strong>\'' . $filters['name'] . '\'</strong> '; } if (!empty($filters['donant'])) { if ($filters['type'] == 'investor') { $sqlFilter .= " AND invest.resign = 1\n AND invest.status IN (1, 3)\n AND invest.charged >= '{$year0}-01-01'\n AND invest.charged < '{$year1}-01-01'\n AND (project.passed IS NOT NULL AND project.passed != '0000-00-00')\n "; $_SESSION['mailing']['filters_txt'] .= 'que haya hecho algun donativo '; } else { Message::Error('Solo se filtran donantes si se envia "A los: Cofinanciadores"'); } } if ($node != \GOTEO_NODE) { $sqlFilter .= " AND user.node = :node"; $values[':node'] = $node; if (!empty($sqlInner)) { $sqlFilter .= " AND project.node = :node"; } } $sql = "SELECT\n user.id as id,\n user.id as user,\n user.name as name,\n user.email as email\n {$sqlFields}\n FROM user\n {$sqlInner}\n WHERE user.active = 1\n {$sqlFilter}\n GROUP BY user.id\n ORDER BY user.name ASC\n "; // die('<pre>'.$sql . '<br />'.print_r($values, 1).'</pre>'); if ($query = Model\User::query($sql, $values)) { foreach ($query->fetchAll(\PDO::FETCH_OBJ) as $receiver) { $_SESSION['mailing']['receivers'][$receiver->id] = $receiver; } } else { Message::Error('Fallo el SQL!!!!! <br />' . $sql . '<pre>' . print_r($values, 1) . '</pre>'); } // si no hay destinatarios, salta a la lista con mensaje de error if (empty($_SESSION['mailing']['receivers'])) { Message::Error('No se han encontrado destinatarios para ' . $_SESSION['mailing']['filters_txt']); throw new Redirection('/admin/mailing/list'); } // si hay, mostramos el formulario de envio return new View('view/admin/index.html.php', array('folder' => 'mailing', 'file' => 'edit', 'filters' => $filters, 'interests' => $interests, 'status' => $status, 'types' => $types, 'roles' => $roles)); break; case 'send': // die(\trace($_POST)); $URL = NODE_ID != GOTEO_NODE ? NODE_URL : SITE_URL; // Enviando contenido recibido a destinatarios recibidos $receivers = array(); $subject = $_POST['subject']; $templateId = !empty($_POST['template']) ? $_POST['template'] : 11; $content = \str_replace('%SITEURL%', $URL, $_POST['content']); // quito usuarios desmarcados foreach ($_SESSION['mailing']['receivers'] as $usr => $userData) { $errors = array(); $campo = 'receiver_' . $usr; if (!isset($_POST[$campo])) { $_SESSION['mailing']['receivers'][$usr]->ok = null; } else { $receivers[] = $userData; } } // montamos el mailing // - se crea un registro de tabla mail $sql = "INSERT INTO mail (id, email, html, template, node) VALUES ('', :email, :html, :template, :node)"; $values = array(':email' => 'any', ':html' => $content, ':template' => $templateId, ':node' => $node); $query = \Goteo\Core\Model::query($sql, $values); $mailId = \Goteo\Core\Model::insertId(); // - se usa el metodo initializeSending para grabar el envío (parametro para autoactivar) // - initiateSending ($mailId, $subject, $receivers, $autoactive = 0) if (\Goteo\Library\Sender::initiateSending($mailId, $subject, $receivers, 1)) { $ok = true; // Evento Feed $log = new Feed(); $log->populate('comunicación masiva a usuarios (admin)', '/admin/mailing', \vsprintf("El admin %s ha iniciado una %s a %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'Comunicacion masiva'), $_SESSION['mailing']['filters_txt']))); $log->doAdmin('admin'); unset($log); } else { $ok = false; // Evento Feed $log = new Feed(); $log->populate('comunicación masiva a usuarios (admin)', '/admin/mailing', \vsprintf("El admin %s le ha %s una %s a %s", array(Feed::item('user', $_SESSION['user']->name, $_SESSION['user']->id), Feed::item('relevant', 'fallado'), Feed::item('relevant', 'Comunicacion masiva'), $_SESSION['mailing']['filters_txt']))); $log->doAdmin('admin'); unset($log); } return new View('view/admin/index.html.php', array('folder' => 'mailing', 'file' => 'send', 'subject' => $subject, 'interests' => $interests, 'status' => $status, 'methods' => $methods, 'types' => $types, 'roles' => $roles, 'users' => $receivers, 'ok' => $ok)); break; } return new View('view/admin/index.html.php', array('folder' => 'mailing', 'file' => 'list', 'interests' => $interests, 'status' => $status, 'methods' => $methods, 'types' => $types, 'roles' => $roles, 'filters' => $filters)); }
public static function process($action = 'list', $id = null, $filters = array()) { $node = isset($_SESSION['admin_node']) ? $_SESSION['admin_node'] : \GOTEO_NODE; // métodos de pago $methods = Model\Invest::methods(); // estados del proyecto $status = Model\Project::status(); // estados de aporte $investStatus = Model\Invest::status(); // listado de proyectos $projects = Model\Invest::projects(false, $node); // usuarios cofinanciadores $users = Model\Invest::users(true); // campañas que tienen aportes $calls = Model\Invest::calls(); // extras $types = array('donative' => 'Solo los donativos', 'anonymous' => 'Solo los anónimos', 'manual' => 'Solo los manuales', 'campaign' => 'Solo con riego'); if ($action == 'csv') { $invest = Model\Invest::getPreapproval($id); foreach ($invest as $value) { $csv[] = array($value->id, $value->amount); } $fileName = "axes_" . date("YmdHis") . ".csv"; header("Content-Disposition: attachment; filename=\"{$filename}\""); header("Content-type: application/octet-stream"); header("Pragma: no-cache"); header("Expires: 0"); $fp = fopen('php://output', 'w'); foreach ($csv as $fields) { fputcsv($fp, $fields); } fclose($fp); exit; } if ($action == 'dopay') { $query = \Goteo\Core\Model::query("\n SELECT *\n FROM invest\n WHERE invest.project = ?\n AND (invest.status = 0\n OR (invest.method = 'tpv'\n AND invest.status = 1\n )\n OR (invest.method = 'cash'\n AND invest.status = 1\n )\n )\n AND (invest.campaign IS NULL OR invest.campaign = 0)\n ", array($id)); $invests = $query->fetchAll(\PDO::FETCH_CLASS, '\\Goteo\\Model\\Invest'); foreach ($invests as $key => $invest) { if ($invest->setPayment(date("YmdHis"))) { $invest->setStatus(1); Model\Invest::setDetail($invest->id, 'executed', 'Preapproval has been executed, has initiated the chained payment. Process cron / execute'); if ($invest->issue) { Model\Invest::unsetIssue($invest->id); Model\Invest::setDetail($invest->id, 'issue-solved', 'The incidence has been resolved upon success by the automatic process'); } } } Message::Info("処理しました"); throw new Redirection('/admin/projects/list'); exit; } // detalles del aporte if ($action == 'details') { $invest = Model\Invest::get($id); $project = Model\Project::get($invest->project); $userData = Model\User::get($invest->user); if (!empty($invest->droped)) { $droped = Model\Invest::get($invest->droped); } else { $droped = null; } if ($project->node != $node) { throw new Redirection('/admin/invests'); } return new View('view/admin/index.html.php', array('folder' => 'invests', 'file' => 'details', 'invest' => $invest, 'project' => $project, 'user' => $userData, 'status' => $status, 'investStatus' => $investStatus, 'droped' => $droped, 'calls' => $calls)); } // listado de aportes if ($filters['filtered'] == 'yes') { if (!empty($filters['calls'])) { $filters['types'] = ''; } $list = Model\Invest::getList($filters, $node, 999); } else { $list = array(); } $viewData = array('folder' => 'invests', 'file' => 'list', 'list' => $list, 'filters' => $filters, 'projects' => $projects, 'users' => $users, 'calls' => $calls, 'methods' => $methods, 'types' => $types, 'investStatus' => $investStatus); return new View('view/admin/index.html.php', $viewData); }
</a> <?php } ?> </div> <div class="status"> <div id="project-status"> <h3><?php echo Text::get('form-project-status-title'); ?> </h3> <ul> <?php foreach (Project::status() as $i => $s) { ?> <li><?php if ($i == $project->status) { echo '<strong>'; } echo htmlspecialchars($s); if ($i == $project->status) { echo '</strong>'; } ?> </li> <?php } ?> </ul>