$text = substr($text, 0, $tcount);
        $tcount = strpos($parts[1], "</tr>") + 5;
        $parts[1] = substr($parts[1], $tcount);
    }
    $text .= $parts[1];
}
$converted = templateParser::parse_template($text, $object_arr);
$header = templateParser::parse_template($header, $object_arr);
$footer = templateParser::parse_template($footer, $object_arr);
$printable = str_replace("\n", "<br />", $converted);
if ($task == 'pdf' || $task == 'emailpdf') {
    $file_name = $mod_strings['LBL_PDF_NAME'] . "_" . str_replace(" ", "_", $module->name) . ".pdf";
    ob_clean();
    try {
        $pdf = new mPDF('en', 'A4', '', 'DejaVuSansCondensed', 15, 15, 16, 16, 8, 8);
        $pdf->setAutoFont();
        $pdf->SetHTMLHeader($header);
        $pdf->SetHTMLFooter($footer);
        $pdf->writeHTML($printable);
        if ($task == 'pdf') {
            $pdf->Output($file_name, "D");
        } else {
            $fp = fopen($sugar_config['upload_dir'] . 'attachfile.pdf', 'wb');
            fclose($fp);
            $pdf->Output($sugar_config['upload_dir'] . 'attachfile.pdf', 'F');
            sendEmail::send_email($module, $module_type, '', $file_name, true);
        }
    } catch (mPDF_exception $e) {
        echo $e;
    }
} else {
Beispiel #2
0
        $note->modified_user_id = $current_user->id;
        $note->created_by = $current_user->id;
        $note->name = $file_name;
        $note->parent_type = $module_type;
        $note->parent_id = $module->id;
        $note->file_mime_type = 'application/pdf';
        $note->filename = $file_name;
        if ($module_type == 'Contacts') {
            $note->contact_id = $module->id;
            $note->parent_type = 'Accounts';
            $note->parent_id = $module->account_id;
        }
        $note->save();
        $fp = fopen('cache/upload/nfile.pdf', 'wb');
        fclose($fp);
        $pdf_history->setAutoFont();
        $pdf_history->SetHTMLHeader($header);
        $pdf_history->SetHTMLFooter($footer);
        $pdf_history->writeHTML($printable);
        $pdf_history->Output('cache/upload/nfile.pdf', 'F');
        $pdf->AddPage();
        $pdf->setAutoFont();
        $pdf->SetHTMLHeader($header);
        $pdf->SetHTMLFooter($footer);
        $pdf->writeHTML($printable);
        rename('cache/upload/nfile.pdf', 'cache/upload/' . $note->id);
    } catch (mPDF_exception $e) {
        echo $e;
    }
}
$pdf->Output($file_name, "D");
Beispiel #3
0
 protected function action_downloadPDF()
 {
     error_reporting(0);
     require_once 'modules/AOS_PDF_Templates/PDF_Lib/mpdf.php';
     $d_image = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png'));
     $head = '<table style="width: 100%; font-family: Arial; text-align: center;" border="0" cellpadding="2" cellspacing="2">
             <tbody style="text-align: left;">
             <tr style="text-align: left;">
             <td style="text-align: left;">
             <p><img src="' . $d_image[0] . '" style="float: left;"/>&nbsp;</p>
             </td>
             <tr style="text-align: left;">
             <td style="text-align: left;"></td>
             </tr>
              <tr style="text-align: left;">
             <td style="text-align: left;">
             </td>
             <tr style="text-align: left;">
             <td style="text-align: left;"></td>
             </tr>
             <tr style="text-align: left;">
             <td style="text-align: left;">
             <b>' . strtoupper($this->bean->name) . '</b>
             </td>
             </tr>
             </tbody>
             </table><br />';
     $printable = $this->bean->build_group_report(-1, false);
     $stylesheet = file_get_contents('themes/Suite7/css/style.css');
     ob_clean();
     try {
         $pdf = new mPDF('en', 'A4', '', 'DejaVuSansCondensed');
         $pdf->setAutoFont();
         $pdf->WriteHTML($stylesheet, 1);
         $pdf->WriteHTML($head, 2);
         $pdf->WriteHTML($printable, 3);
         $pdf->Output($this->bean->name . '.pdf', "D");
     } catch (mPDF_exception $e) {
         echo $e;
     }
     die;
 }
Beispiel #4
0
 protected function action_downloadPDF()
 {
     error_reporting(0);
     require_once 'modules/AOS_PDF_Templates/PDF_Lib/mpdf.php';
     $d_image = explode('?', SugarThemeRegistry::current()->getImageURL('company_logo.png'));
     $graphs = $_POST["graphsForPDF"];
     $graphHtml = "<div class='reportGraphs' style='width:100%; text-align:center;'>";
     $chartsPerRow = $this->bean->graphs_per_row;
     $countOfCharts = count($graphs);
     if ($countOfCharts > 0) {
         $width = (int) 100 / $chartsPerRow;
         $modulusRemainder = $countOfCharts % $chartsPerRow;
         if ($modulusRemainder > 0) {
             $modulusWidth = (int) 100 / $modulusRemainder;
             $itemsWithModulus = $countOfCharts - $modulusRemainder;
         }
         for ($x = 0; $x < $countOfCharts; $x++) {
             if (is_null($itemsWithModulus) || $x < $itemsWithModulus) {
                 $graphHtml .= "<img src='.{$graphs[$x]}.' style='width:{$width}%;' />";
             } else {
                 $graphHtml .= "<img src='.{$graphs[$x]}.' style='width:{$modulusWidth}%;' />";
             }
         }
         /*            foreach($graphs as $g)
                     {
                         $graphHtml.="<img src='.$g.' style='width:$width%;' />";
                     }*/
         $graphHtml .= "</div>";
     }
     $head = '<table style="width: 100%; font-family: Arial; text-align: center;" border="0" cellpadding="2" cellspacing="2">
             <tbody style="text-align: left;">
             <tr style="text-align: left;">
             <td style="text-align: left;">
             <p><img src="' . $d_image[0] . '" style="float: left;"/>&nbsp;</p>
             </td>
             <tr style="text-align: left;">
             <td style="text-align: left;"></td>
             </tr>
              <tr style="text-align: left;">
             <td style="text-align: left;">
             </td>
             <tr style="text-align: left;">
             <td style="text-align: left;"></td>
             </tr>
             <tr style="text-align: left;">
             <td style="text-align: left;">
             <b>' . strtoupper($this->bean->name) . '</b>
             </td>
             </tr>
             </tbody>
             </table><br />' . $graphHtml;
     $this->bean->user_parameters = requestToUserParameters();
     $printable = $this->bean->build_group_report(-1, false);
     $stylesheet = file_get_contents('themes/Suite7/css/style.css');
     ob_clean();
     try {
         $pdf = new mPDF('en', 'A4', '', 'DejaVuSansCondensed');
         $pdf->setAutoFont();
         $pdf->WriteHTML($stylesheet, 1);
         $pdf->WriteHTML($head, 2);
         $pdf->WriteHTML($printable, 3);
         $pdf->Output($this->bean->name . '.pdf', "D");
     } catch (mPDF_exception $e) {
         echo $e;
     }
     die;
 }