public function downloadError() { $file_id = (int) $this->input->get_post('file_id'); $file = $this->file_upload_model->getFile($file_id); $file_dir = './upload/excel/' . date('Ym', strtotime($file['created_at'])) . '/'; $tempName = explode('.', $file['file_save_name']); $err_file = FCPATH . $file_dir . $tempName[0] . '_error.csv'; downloadCSV($err_file); }
while ($res_f = $res->fetch()) { $listeServices[$res_f['id']] = getServiceInfo($res_f['id']); } /* Téléchargement de la liste des services au format CSV */ if ($action == 'dl') { /* Création de l'array à retourner */ $servicesCSV = array(array('id', LANG_ADMIN_SERVICES_LISTE_TABLE_TITLE_HOPITAL, LANG_ADMIN_SERVICES_LISTE_TABLE_TITLE_SPECIALITE, LANG_ADMIN_SERVICES_LISTE_TABLE_TITLE_CHEF, LANG_ADMIN_SERVICES_LISTE_TABLE_TITLE_CHEF, LANG_ADMIN_SERVICES_NOM)); foreach (getServiceList() as $service) { $servicesCSV[] = array($service['id'], $service['hopital']['nom'], $service['specialite']['nom'], $service['chef']['nom'], $service['chef']['prenom'], $service['nom']); } // Téléchargement du CSV downloadCSV($servicesCSV, 'services.csv'); } if ($action == 'list') { /** 2. Création de la pagination **/ $pagination = creerPagination(8, 4, $pageActuelle, $nbTotalPages); /** Affichage des résultats **/ /* Liste des services */ /* Filtres de sélection */
1. Récupération des données **/ $allowedAction = array('menu', 'importCSVFile'); if (isset($_GET['action']) && in_array($_GET['action'], $allowedAction)) { $action = $_GET['action']; } else { $action = 'menu'; } /** 2. Traitement des donnés **/ if ($action == 'importCSVFile') { // Téléchargement du CSV vide if (isset($_GET['downloadCSV'])) { $arrayCSV[] = array(LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_NOM, LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_PRENOM, LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_MAIL, LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_NBETU, LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_PROMOTION, LANG_ADMIN_UTILISATEURS_MENU_BATCH_TABLE_RANG); downloadCSV($arrayCSV, 'import.csv'); } // Traitement des CSV importés // Si fichier CSV envoyé if (isset($_POST['upload']) && isset($_FILES['csv']) && $_POST['upload'] == 'ok') { $fileName = explode('.', $_FILES['csv']['name']); if (is_file($_FILES['csv']['tmp_name']) && ($csv = fopen($_FILES['csv']['tmp_name'], 'r') && $fileName[count($fileName) - 1] == 'csv')) { // Récupération de la liste à partir du CSV $users = readCSV($_FILES['csv']['tmp_name'], ';', FALSE); // Corresponsance CSV -> Valeur $correspondance = array('nom' => 0, 'prenom' => 1, 'mail' => 2, 'nbEtu' => 3, 'promotion' => 4, 'rang' => 5); /* On parcours le fichier $users et : * - On enregistre dans l'array $userOK['insert'] les valeurs prêtes à être insérées * - On enregistre dans l'array $userOK['update'] les valeurs prêtes à être mises à jours * - On enregistre dans l'array $userOK['erreur'] les valeurs qui posent probleme et qui ne doivent pas être insérées */
function downloadText($text, $filename, $description, $inline = false, $length = true) { downloadCSV($text, false, preg_replace('/\\.txt\\z/', "", $filename), $description, array("inline" => $inline, "nolength" => !$length, "type" => "txt")); }
} else { header('Location: ' . ROOT . CURRENT_FILE . '?page=' . $_GET['page']); } } } // On retourne la liste au format CSV si $action == 'dl' if ($action == 'dl') { /* Création de l'array à retourner */ $promotionsCSV = array(array('id', LANG_ADMIN_PROMOTION_NOM_TITRE)); foreach ($listePromotions as $promotion) { $promotionsCSV[] = array($promotion['id'], $promotion['nom']); } // Téléchargement du CSV downloadCSV($promotionsCSV, 'promotions.csv'); } /** 2. Traitement des formulaires **/ if (isset($_POST) && count($_POST)) { /* Préparation des données : on crée un array contenant toutes les données, ce dernier sera ensuite parcouru pour créer la requête SQL qui sera préparée */ if ($action == 'add') { if (isset($_POST['nom']) && $_POST['nom'] != '') { $sql = 'INSERT INTO promotion (nom) VALUE (?)'; } } if ($action == 'edit' || $action == 'delete') { $sqlData['id'] = $promotionData['id'];
foreach (ReviewForm::all_fields() as $f) { if ($f->has_options) { $scoreselector["+" . $f->id] = "high {$f->name_html} scores"; $scoreselector["-" . $f->id] = "low {$f->name_html} scores"; } } if ($scoreselector["+overAllMerit"] === "") { unset($scoreselector["+overAllMerit"], $scoreselector["-overAllMerit"]); } $scoreselector["x"] = "(no score preference)"; // download proposed assignment if (isset($Qreq->saveassignment) && isset($Qreq->download) && isset($Qreq->assignment)) { $assignset = new AssignmentSet($Me, true); $assignset->parse($Qreq->assignment); $x = $assignset->unparse_csv(); downloadCSV($x->data, $x->header, "assignments", ["selection" => true, "sort" => SORT_NATURAL]); } $Error = array(); $Conf->header("Assignments ∕ <strong>Automatic</strong>", "autoassign", actionBar()); echo '<div class="psmode">', '<div class="papmodex"><a href="', hoturl("autoassign"), '">Automatic</a></div>', '<div class="papmode"><a href="', hoturl("manualassign"), '">Manual</a></div>', '<div class="papmode"><a href="', hoturl("bulkassign"), '">Bulk update</a></div>', '</div><hr class="c" />'; class AutoassignerInterface { private $atype; private $atype_review; private $reviewtype; private $discordertag; private $autoassigner; private $start_at; private $live; public $ok = false; public function check()
$header[] = "roles"; if (@$has->tags) { $header[] = "tags"; } array_push($header, "affiliation", "collaborators", "follow"); if (@$has->phone) { $header[] = "phone"; } $selection = $header; foreach ($topics as $id => $tn) { if (isset($has->topics[$id])) { $header[] = "topic: " . $tn; $selection[] = "ti{$id}"; } } downloadCSV($people, $header, "pcinfo", array("selection" => $selection)); } // modifications function modify_confirm($j, $ok_message, $ok_message_optional) { global $Conf; if (@$j->ok && @$j->warnings) { $Conf->warnMsg("<div>" . join("</div><div style='margin-top:0.5em'>", $j->warnings) . "</div>"); } if (@$j->ok && $ok_message && (!$ok_message_optional || !@$j->warnings)) { $Conf->confirmMsg($ok_message); } } if ($Me->privChair && @$_REQUEST["modifygo"] && check_post() && isset($papersel)) { if (@$_REQUEST["modifytype"] == "disableaccount") { modify_confirm(UserActions::disable($papersel, $Me), "Accounts disabled.", true);
foreach ($user['mail'] as $mail) { if ($mailText != '') { $mailText .= ';'; } $mailText .= $mail; } // Etat de l'évaluation if ($user['statut'] == 0) { $state = LANG_ADMIN_EVALUATION_CSV_NOT_COMPLETE; } else { $state = LANG_ADMIN_EVALUATION_CSV_COMPLETE; } $userCSVList[] = array($user['nom'], $user['prenom'], $user['nbEtudiant'], $user['promotion']['nom'], $mailText, $state); } // Téléchargement du CSV downloadCSV($userCSVList, LANG_ADMIN_EVALUATION_CSV_STATE . ' ' . $evaluation['nom'] . '.csv'); } if (isset($_SESSION['evaluationAdd']) && $action != 'settings' && $action != 'userList' && $action != 'add') { unset($_SESSION['evaluationAdd']); // Suppression automatique du traceur d'ajout d'évaluation } /** 3. Affichage **/ // 3.1 : On affiche les erreurs if (isset($erreur) && count($erreur) > 0) { displayErreur($erreur); } // 3.2 : Si $action = liste : on affiche la liste des évaluations if ($action == 'liste') { if (isset($evaluations) && count($evaluations) > 0) {
function run(Contact $user, $qreq, $ssel) { global $Conf; $result = Dbl::qe_raw($Conf->paperQuery($user, array("paperId" => $ssel->selection(), "topics" => 1))); $texts = array(); $tmap = $Conf->topic_map(); while ($row = PaperInfo::fetch($result, $user)) { if ($user->can_view_paper($row)) { $out = array(); foreach ($row->topics() as $t) { $out[] = [$row->paperId, $row->title, $tmap[$t]]; } if (!count($out)) { $out[] = [$row->paperId, $row->title, "<none>"]; } arrayappend($texts[$row->paperId], $out); } } downloadCSV($ssel->reorder($texts), array("paper", "title", "topic"), "topics"); }
function run(Contact $user, $qreq, $ssel) { global $Conf; $type = $this->islead ? "lead" : "shepherd"; $result = Dbl::qe_raw($Conf->paperQuery($user, array("paperId" => $ssel->selection(), "reviewerName" => $type))); $texts = array(); while ($row = PaperInfo::fetch($result, $user)) { if ($row->reviewEmail && ($this->islead ? $user->can_view_lead($row, true) : $user->can_view_shepherd($row, true))) { arrayappend($texts[$row->paperId], [$row->paperId, $row->title, $row->reviewFirstName, $row->reviewLastName, $row->reviewEmail]); } } downloadCSV($ssel->reorder($texts), array("paper", "title", "first", "last", "{$type}email"), "{$type}s"); }
<?php require 'getAllSensorData.php'; function outputCSV($data) { $outputBuffer = fopen("php://output", 'w'); ob_start(); // set csv header array_slice($data,1)) // fputcsv($outputBuffer, array_keys(array_slice($data,1))); //echo var_dump($data); foreach ($data as $val) { fputcsv($outputBuffer, $val); } fclose($outputBuffer); $csv = ob_get_clean(); return $csv; } function downloadCSV() { $filename = "LandfillGasMonitoringData"; header("Content-type: text/csv"); header("Content-Disposition: attachment; filename={$filename}.csv"); header("Pragma: no-cache"); header("Expires: 0"); $data = getAllSensorData(); return outputCSV($data); } $csv = downloadCSV(); echo $csv; //echo "okies";
function run(Contact $user, $qreq, $ssel) { global $Conf, $Opt; $q = $Conf->paperQuery($user, array("paperId" => $ssel->selection(), "allReviewerPreference" => 1, "allConflictType" => 1, "topics" => 1)); $result = Dbl::qe_raw($q); $texts = array(); $pcm = pcMembers(); $has_conflict = $has_expertise = $has_topic_score = false; while ($prow = PaperInfo::fetch($result, $user)) { if (!$user->can_administer($prow, true)) { continue; } $conflicts = $prow->conflicts(); foreach ($pcm as $cid => $p) { $pref = $prow->reviewer_preference($p); $conf = get($conflicts, $cid); $tv = $prow->topicIds ? $prow->topic_interest_score($p) : 0; if ($pref || $conf || $tv) { $texts[$prow->paperId][] = array("paper" => $prow->paperId, "title" => $prow->title, "first" => $p->firstName, "last" => $p->lastName, "email" => $p->email, "preference" => $pref[0] ?: "", "expertise" => unparse_expertise($pref[1]), "topic_score" => $tv ?: "", "conflict" => $conf ? "conflict" : ""); $has_conflict = $has_conflict || $conf; $has_expertise = $has_expertise || $pref[1] !== null; $has_topic_score = $has_topic_score || $tv; } } } $headers = array("paper", "title", "first", "last", "email", "preference"); if ($has_expertise) { $headers[] = "expertise"; } if ($has_topic_score) { $headers[] = "topic_score"; } if ($has_conflict) { $headers[] = "conflict"; } downloadCSV($ssel->reorder($texts), $headers, "allprefs", ["selection" => true]); }