/** * Download task list as attachment * * @access public * @param void * @return null */ function download_list() { $task_list = ProjectTaskLists::findById(get_id()); if (!$task_list instanceof ProjectTaskList) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if $this->canGoOn(); if (!$task_list->canView(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('task')); } // if $output = array_var($_GET, 'output', 'csv'); $project_name = active_project()->getName(); $task_list_name = $task_list->getName(); $task_count = 0; if ($output == 'pdf') { Env::useLibrary('fpdf'); $download_name = "{$project_name}-{$task_list_name}-tasks.pdf"; $download_type = 'application/pdf'; $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetTitle($task_list_name); $pdf->SetCompression(true); $pdf->SetCreator('ProjectPier'); $pdf->SetDisplayMode(fullpage, single); $pdf->SetSubject(active_project()->getObjectName()); $pdf->SetFont('Arial', 'B', 16); $task_lists = active_project()->getOpenTaskLists(); $pdf->Cell(0, 10, lang('project') . ': ' . active_project()->getObjectName(), 'C'); $pdf->Ln(); foreach ($task_lists as $task_list) { $pdf->SetFont('Arial', 'B', 14); $pdf->Write(10, lang('task list') . ': ' . $task_list->getObjectName()); $pdf->Ln(); $tasks = $task_list->getTasks(); $line = 0; // Column widths $w = array(10, 0, 0); // Header //for($i=0;$i<count($header);$i++) // $this->Cell($w[$i],7,$header[$i],1,0,'C'); //$this->Ln(); $pdf->SetFont('Arial', 'I', 14); foreach ($tasks as $task) { $line++; if ($task->isCompleted()) { $task_status = lang('completed'); $pdf->SetTextColor(100, 200, 100); $task_completion_info = lang('completed task') . ' : ' . format_date($task->getCompletedOn()); } else { $task_status = lang('open'); $pdf->SetTextColor(255, 0, 0); $task_completion_info = lang('due date') . ' : ' . lang('not assigned'); if ($task->getDueDate()) { $task_completion_info = lang('due date') . ' : ' . format_date($task->getDueDate()); } } if ($task->getAssignedTo()) { $task_assignee = $task->getAssignedTo()->getObjectName(); } else { $task_assignee = lang('not assigned'); } $pdf->Cell($w[0], 6, $line); $pdf->Cell($w[2], 6, $task_status, "TLRB"); $pdf->Ln(); $pdf->Cell($w[0], 6, ''); $pdf->SetTextColor(0, 0, 0); $pdf->Cell($w[2], 6, $task_completion_info, "TLRB"); $pdf->Ln(); $pdf->Cell($w[0], 6, ''); $pdf->SetTextColor(0, 0, 0); $pdf->Cell($w[2], 6, $task_assignee, "TLRB"); $pdf->Ln(); $pdf->Cell($w[0], 6, ''); $pdf->SetTextColor(0, 0, 0); $pdf->MultiCell($w[2], 6, $task->getText(), "TLRB"); $pdf->Ln(); } } $pdf->Output($download_name, 'D'); } else { $download_name = "{$project_name}-{$task_list_name}-tasks.txt"; $download_type = 'text/csv'; $download_contents = $task_list->getDownloadText($task_count, "\t", true); download_contents($download_contents, $download_type, $download_name, strlen($download_contents)); } die; }
if (isset($_GET['sonuc'])) { $readerUTime = $_GET['readerUTime']; $pdf = new FPDF('L', 'mm', 'A4'); $tabanhesabi = null; AddPage($readerUTime); $pdf->SetXY(15, 120); $pdf->Cell(200, 5, "Genel baþarý seviyesi deðerlendirmesidir.", 0, 0, 'L'); $tabanhesabi = 0; AddPage($readerUTime); $pdf->SetXY(15, 120); $pdf->Cell(200, 5, "Sadece \" {$tabanhesabi} \" baþarý seviyesinden büyük olanlarýn deðerlendirmesidir.", 0, 0, 'L'); $tabanhesabi = 50; AddPage($readerUTime); $pdf->SetXY(15, 120); $pdf->Cell(200, 5, "Sadece \" {$tabanhesabi} \" baþarý seviyesinden büyük olanlarýn deðerlendirmesidir.", 0, 0, 'L'); $pdf->SetCompression(true); $pdf->Output(); } else { ?> <html> <head><title>OMR</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" /></head> <body> <form id="form1" name="form1" method="get" action=""> <table border="1" cellspacing="0" cellpadding="5"> <tr><td colspan="2">Rapor PDF Çiktisi</td></tr> <tr><td colspan="2">Optik Form Kayit Tarihi</td> </tr><tr><td><label for="readerUTime"></label> <select name="readerUTime" id="readerUTime"> <?php $result = mysql_query("SELECT `utime` FROM `d_reader` GROUP BY `utime` ORDER BY `utime` DESC");
} // création du document $pdf->SetCreator($gepiSchoolName); // auteur du document $pdf->SetAuthor($gepiSchoolName); // mots clé $pdf->SetKeywords(''); // sujet du document $pdf->SetSubject('Bilan journalier des absences'); // titre du document $pdf->SetTitle('Bilan journalier des absences'); // méthode d'affichage du document à son ouverture $pdf->SetDisplayMode('fullwidth', 'single'); // compression du document $pdf->SetCompression(TRUE); // change automatiquement de page à 5mm du bas $pdf->SetAutoPageBreak(TRUE, 5); /* **************************** */ /* début de la boucle des pages */ // comptage du nombre de page traité $nb_page_traite = 0; // initialiser la variable compteur de ligne passé pour le tableau $nb_ligne_passe = 0; // initialiser un compteur temporaire autre que i // il serviras pour savoir à quelle endroit de la liste nous somme rendus
function parse_pdf_content($content, $member_id) { // parse text content from Smarty to pdf content global $db, $config, $t; $pdf_content = ''; $margins = array(mm_to_pt(20), mm_to_pt(20), mm_to_pt(20), mm_to_pt(20)); //left, top, right, bottom (in points) 56pt ~= 20mm $font_size = 14; //points $pdf = new FPDF('P', 'pt', 'A4'); // portrait, A4 $pdf->SetCompression(false); $pdf->SetMargins($margins[0], $margins[1], $margins[2]); //only left, top, right margins. bottom margin equals to 20mm by default. $pdf->SetTitle('Your Invoice'); $pdf->SetSubject('*** Your Payment'); $pdf->SetAuthor('aMember'); $pdf->AddPage(); $pdf->SetFont('Arial', '', $font_size); $current_x = $pdf->GetX(); $current_y = $pdf->GetY(); $width = mm_to_pt(210); $height = mm_to_pt(270); $width = $width - $margins[0] - $margins[2]; // target width $height = $height - $margins[1] - $margins[3]; // target height $image = $config['root_dir'] . "/logo.jpg"; // logo path to include in pdf at top-right corner if (is_file($image)) { $size = getimagesize($image); $x = $width - $size[0] + $margins[0]; $y = $current_y; $pdf->Image($image, $x, $y, $size[0], $size[1]); // use original size $current_y += $size[1]; } $current_y += $font_size; //pt $contacts = explode("\n", $config['invoice_contacts']); // output contact information right-aligned $max_length = 0; foreach ($contacts as $row) { $row = trim($row); $length = $pdf->GetStringWidth($row); if ($length > $max_length) { $max_length = $length; } } $x = $width - $max_length + $margins[0]; $y = $current_y; foreach ($contacts as $row) { $row = trim($row); $attr = get_font_styles($row); $pdf->SetFont('Arial', $attr, $font_size); $pdf->Text($x, $y, strip_tags($row)); $y += $font_size; } $current_y = $y; $pdf->SetFont('Arial', '', $font_size); //return font settings // customer contacts $u = $db->get_user($member_id); if (!$t) { $t =& new_smarty(); } $t->assign('u', $u); $cust_contacts = $t->fetch('mail_receipt_contact.pdf.txt'); $cust_contacts = explode("\n", $cust_contacts); // output contact information left-aligned $num_rows = count($contacts); $x = $margins[0]; $y = $current_y - $font_size * $num_rows; // $num_rows rows up from contact information and output customer data foreach ($cust_contacts as $row) { $row = trim($row); $attr = get_font_styles($row); $pdf->SetFont('Arial', $attr, $font_size); $pdf->Text($x, $y, strip_tags($row)); $y += $font_size; } $current_y = $y; /* $y = $current_y - $font_size * 4; // 4 rows up from contact information and output customer data $string = $u['name_f'] . ' ' . $u['name_l']; $pdf->Text ($x, $y, $string); $y += $font_size; $string = $u['street']; $pdf->Text ($x, $y, $string); $y += $font_size; $string = $u['zip'] . ' ' . $u['city']; $pdf->Text ($x, $y, $string); $y += $font_size; $state = db_getStateByCode($u['country'], $u['state']); $country = db_getCountryByCode($u['country']); $string = $state . ' ' . $country; $pdf->Text ($x, $y, $string); $y += $font_size; */ $current_y = $y + $font_size * 2; //2 rows down $pdf->SetFont('Arial', '', $font_size); //return font settings // remove new lines $content = str_replace("\n", "", $content); $content = str_replace("\r", "", $content); $content = str_replace("£", chr(163), $content); // split text by <br /> $content = explode("<br />", $content); $y = $current_y; // count maximum columns widths $widths = array(); foreach ($content as $text) { $text = trim($text); if (preg_match('/\\|/i', $text, $regs)) { $column = 0; $items = explode("|", $text); foreach ($items as $item) { $length = $pdf->GetStringWidth(trim(strip_tags($item))) + 10; if ($widths[$column] < $length) { $widths[$column] = $length; } $column++; } } } $length = 0; for ($i = 1; $i < count($widths); $i++) { $length += $widths[$i]; } // width of column 0 is * $widths[0] = $width - $length; foreach ($content as $hr_content) { $hr_content = trim($hr_content); // split text by <hr> $hr_content = explode("<hr>", $hr_content); $hr_count = count($hr_content) - 1; //<br /> add new line if ($hr_count < 1 && strip_tags($hr_content[0]) == '') { $y += $font_size; } foreach ($hr_content as $text) { $line_feeds = 1; // how much rows feed if (strip_tags($text) != '') { // if there is a text if (!preg_match('/\\|/i', $text, $regs)) { // simple text $y += $font_size * $line_feeds; $attr = get_font_styles($text); $text = trim(strip_tags($text)); $pdf->SetFont('Arial', $attr, $font_size); $pdf->Text($x, $y, $text); // simple textout. no line feeds allowed. /* $length = $pdf->GetStringWidth ($text); while ($length > $width) $line_feeds++; */ } else { //table content (splitted by "|") $border = 0; $fill = 0; $pdf->SetFillColor(192, 192, 192); // Silver if (preg_match('/<fill>(.*)<\\/fill>/i', $text, $regs)) { $text = $regs[1]; $fill = 1; } $text = strip_tags($text); $items = explode("|", $text); $column = 0; $x = $margins[0]; foreach ($items as $item) { $attr = get_font_styles($item); $item = trim(strip_tags($item)); $pdf->SetFont('Arial', $attr, $font_size); if ($column > 0) { $align = 'R'; } else { $align = 'L'; } $pdf->SetXY($x, $y); $pdf->MultiCell($widths[$column], $font_size, $item, $border, $align, $fill); // multi rows output for ($i = 1; $i < $line_feeds; $i++) { $_y = $y + $i * $font_size; $pdf->SetXY($x, $_y); $pdf->MultiCell($widths[$column], $font_size, '', $border, $align, $fill); // empty rows } if ($column == 0) { // count line feeds only for 0 column $length = $pdf->GetStringWidth($item); while ($length > $widths[$column]) { $line_feeds++; $length -= $widths[$column]; } } $x += $widths[$column]; $column++; } $y += $font_size * $line_feeds; $pdf->SetXY($margins[0], $y); } } // (strip_tags($text) != '') if ($hr_count > 0) { // check count of <hr> (do not draw last <hr>) $y += 2; $pdf->Line($margins[0], $y, $margins[0] + $width, $y); $y += 2; $hr_count--; } $x = $margins[0]; } //foreach hr_content } //foreach content $current_y = $y; $pdf_content = $pdf->Output('', 'S'); //get pdf content return $pdf_content; }
/** * Download task list as attachment * * @access public * @param void * @return null */ function download_list() { $task_list = ProjectTaskLists::findById(get_id()); if (!$task_list instanceof ProjectTaskList) { flash_error(lang('task list dnx')); $this->redirectTo('task'); } // if $this->canGoOn(); if (!$task_list->canView(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('task')); } // if $output = array_var($_GET, 'output', 'csv'); $project_name = active_project()->getName(); $task_list_name = $task_list->getName(); $task_count = 0; if ($output == 'pdf') { Env::useLibrary('fpdf'); $download_name = "{$project_name}-tasks.pdf"; $download_type = 'application/pdf'; $pdf = new FPDF("P", "mm"); $pdf->AddPage(); $pdf->SetTitle($project_name); $pdf->SetCompression(true); $pdf->SetCreator('ProjectPier'); $pdf->SetDisplayMode('fullpage', 'single'); $pdf->SetSubject(active_project()->getObjectName()); $pdf->SetFont('Arial', 'B', 16); $task_lists = active_project()->getOpenTaskLists(); $pdf->Cell(0, 10, lang('project') . ': ' . active_project()->getObjectName(), 'B', 0, 'C'); $pdf->Ln(14); $w = array(0 => 12, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140); foreach ($task_lists as $task_list) { $pdf->SetFont('Arial', 'B', 14); $pdf->Write(10, lang('task list') . ': ' . $task_list->getObjectName()); $pdf->Ln(14); $tasks = $task_list->getTasks(); $pdf->SetFont('Arial', 'I', 14); $pdf->SetFillColor(230, 230, 230); $pdf->Cell($w[1], 6, '#', 1, 0, 'C', true); $pdf->Cell($w[3], 6, lang('status'), 1, 0, 'C', true); $pdf->Cell($w[10], 6, lang('info'), 1, 0, 'C', true); $pdf->Cell(0, 6, lang(user), 1, 0, 'C', true); $pdf->Ln(); foreach ($tasks as $task) { $line++; if ($task->isCompleted()) { $task_status = lang('completed'); $task_status_color_R = 0; $task_status_color_G = 150; $task_status_color_B = 0; $task_completion_info = lang('completed task') . ' : ' . format_date($task->getCompletedOn()) . ' @ ' . format_time($task->getCompletedOn()); } else { $task_status = lang('open'); $task_status_color_R = 200; $task_status_color_G = 0; $task_status_color_B = 0; $task_completion_info = lang('due date') . ' : ' . lang('not assigned'); $task_completion_info_color_R = 200; $task_completion_info_color_G = 0; $task_completion_info_color_B = 0; if ($task->getDueDate()) { $task_completion_info = lang('due date') . ' : ' . format_date($task->getDueDate()) . ' @ ' . format_time($task->getDueDate()); $task_completion_info_color_R = 0; $task_completion_info_color_G = 0; $task_completion_info_color_B = 0; } } if ($task->getAssignedTo()) { $task_assignee = $task->getAssignedTo()->getObjectName(); $task_assignee_color_R = 0; $task_assignee_color_G = 0; $task_assignee_color_B = 0; } else { $task_assignee = lang('not assigned'); $task_assignee_color_R = 200; $task_assignee_color_G = 0; $task_assignee_color_B = 0; } $pdf->SetFillColor(245, 245, 245); $pdf->Cell($w[1], 6, $line, 1, 0, 'C', true); $pdf->SetTextColor($task_status_color_R, $task_status_color_G, $task_status_color_B); $pdf->Cell($w[3], 6, $task_status, 1, 0, 'C', true); $pdf->SetTextColor($task_completion_info_color_R, $task_completion_info_color_G, $task_completion_info_color_B); $pdf->Cell($w[10], 6, $task_completion_info, 1, 0, 'C', true); $pdf->SetTextColor($task_assignee_color_R, $task_assignee_color_G, $task_assignee_color_B); $pdf->Cell(0, 6, $task_assignee, 1, 0, 'C', true); $pdf->SetTextColor(0, 0, 0); $pdf->Ln(); $pdf->MultiCell(0, 6, $task->getText(), 1); //$pdf->Ln(); } } $pdf->Output($download_name, 'I'); } if ($output == 'txt') { $download_name = "{$project_name}-tasks.txt"; $download_type = 'text/csv'; $txt_lang_1 = lang('project'); $txt_lang_2 = lang('milestone'); $txt_lang_3 = lang('task list'); $txt_lang_4 = lang('status'); $txt_lang_5 = lang('description'); $txt_lang_6 = lang('id'); $txt_lang_7 = lang('status'); $txt_lang_8 = lang('completion info'); $txt_lang_9 = lang('assigned to'); $s .= "{$txt_lang_1}\t{$txt_lang_2}\t{$txt_lang_3}\t{$txt_lang_4}\t{$txt_lang_5}\t{$txt_lang_6}\t{$txt_lang_7}\t{$txt_lang_8}\t{$txt_lang_9}"; $s .= "\n"; $task_lists = active_project()->getOpenTaskLists(); foreach ($task_lists as $task_list) { /*$s .= $task_list->getObjectName(); $s .= "\n"; $task_list_desc = $task_list->getDescription(); $task_list_desc = strtr($task_list_desc,"\r\n\t"," "); $task_list_desc_100 = substr($task_list_desc,0,100); $s .= $task_list_desc_100; $s .= "\n";*/ $milestone = $task_list->getMilestone(); $tasks = $task_list->getTasks(); foreach ($tasks as $task) { $s .= $project_name; $s .= "\t"; $milestone_name = lang(none); if ($milestone instanceof ProjectMilestone) { $milestone_name = $milestone->getName(); } $s .= $milestone_name; $s .= "\t"; $s .= $task_list->getObjectName(); $s .= "\t"; $task_list_name = $task_list->getName(); if ($task_list->isCompleted()) { $task_list_status = lang('completed'); } else { $task_list_status = lang('open'); } $s .= $task_list_status; $s .= "\t"; $task_list_desc2 = $task_list->getDescription(); $task_list_desc2 = strtr($task_list_desc2, "\r\n\t", " "); $task_list_desc2_100 = substr($task_list_desc2, 0, 50); $s .= $task_list_desc2_100; $s .= "\t"; $s .= $task->getId(); $s .= "\t"; if ($task->isCompleted()) { $task_status = lang('completed'); $task_completion_info = format_date($task->getCompletedOn()) . " @ " . format_time($task->getCompletedOn()); } else { $task_status = lang('open'); $task_completion_info = format_date($task->getDueDate()) . " @ " . format_time($task->getDueDate()); } $s .= $task_status; $s .= "\t"; $s .= $task_completion_info; $s .= "\t"; if ($task->getAssignedTo()) { $task_assignee = $task->getAssignedTo()->getObjectName(); } else { $task_assignee = lang('not assigned'); } $s .= $task_assignee; $s .= "\n"; } } $download_contents = $s; download_headers($download_name, $download_type, strlen($download_contents), true); echo $download_contents; } else { $download_name = "{$project_name}-{$task_list_name}-tasks.csv"; $download_type = 'text/csv'; $download_contents = $task_list->getDownloadText($task_count, "\t", true); download_contents($download_contents, $download_type, $download_name, strlen($download_contents)); } die; }