Example #1
0
 private function x2f($x0c, $x0e, $x94 = false)
 {
     global $x15d, $x15e, $x15f, $x160, $x161, $x162, $x163, $x164, $x165, $x166, $x167, $x168, $x169, $x16a, $x16b, $x16c, $x16d, $x16e, $x16f, $x170, $x171, $x172, $x173, $x174, $x175, $x176, $x177, $x178;
     if (!isset(self::$x22[$x0c])) {
         $this->x2e($x0c, $x0e);
     }
     if (!isset(self::$x22[$x0c])) {
         return array();
     }
     $x13e = "";
     if ($x94 !== false) {
         $x13e = "R_" . $x175($x94) . "_";
     }
     self::$x21["\$" . $x13e . "SUBTOTAL\$"] = $this->x23($x0e->column_fields["hdnSubTotal"]);
     self::$x21["\$" . $x13e . "TOTAL\$"] = $this->x23($x0e->column_fields["hdnGrandTotal"]);
     $xf9 = $this->x21($x0c, $x0e);
     $xf9["currency_symbol"] = $x172("тя┐╜м", "€", $xf9["currency_symbol"]);
     $xf9["currency_symbol"] = $x172("┬┬г", "£", $xf9["currency_symbol"]);
     self::$x21["\$" . $x13e . "CURRENCYNAME\$"] = getTranslatedCurrencyString($xf9["currency_name"]);
     self::$x21["\$" . $x13e . "CURRENCYSYMBOL\$"] = $xf9["currency_symbol"];
     self::$x21["\$" . $x13e . "CURRENCYCODE\$"] = $xf9["currency_code"];
     self::$x21["\$" . $x13e . "ADJUSTMENT\$"] = $this->x23($x0e->column_fields["txtAdjustment"]);
     $x6f = $this->x18($x0c, $x0e);
     self::$x21["\$" . $x13e . "TOTALWITHOUTVAT\$"] = $x6f["TOTAL"]["TOTALWITHOUTVAT"];
     self::$x21["\$" . $x13e . "VAT\$"] = $x6f["TOTAL"]["TAXTOTAL"];
     self::$x21["\$" . $x13e . "VATPERCENT\$"] = $x6f["TOTAL"]["TAXTOTALPERCENT"];
     self::$x21["\$" . $x13e . "TOTALWITHVAT\$"] = $x6f["TOTAL"]["TOTALWITHVAT"];
     self::$x21["\$" . $x13e . "SHTAXAMOUNT\$"] = $x6f["TOTAL"]["SHTAXAMOUNT"];
     self::$x21["\$" . $x13e . "SHTAXTOTAL\$"] = $x6f["TOTAL"]["SHTAXTOTAL"];
     self::$x21["\$" . $x13e . "TOTALDISCOUNT\$"] = $x6f["TOTAL"]["FINALDISCOUNT"];
     self::$x21["\$" . $x13e . "TOTALDISCOUNTPERCENT\$"] = $x6f["TOTAL"]["FINALDISCOUNTPERCENT"];
     self::$x21["\$" . $x13e . "TOTALAFTERDISCOUNT\$"] = $x6f["TOTAL"]["TOTALAFTERDISCOUNT"];
     $this->x15();
     if ($x94 === false) {
         if ($x161($x6f["TOTAL"]["VATBLOCK"]) > 0) {
             $x14d = "<table border='1' style='border-collapse:collapse;' cellpadding='3'>";
             $x14d .= "<tr>\r\n                                <td nowrap align='center'>" . vtranslate("Name") . "</td>\n\n                                <td nowrap align='center'>" . self::$x10["LBL_VATBLOCK_VAT_PERCENT"] . "</td>\r\n                                <td nowrap align='center'>" . self::$x10["LBL_VATBLOCK_SUM"] . " (" . $xf9["currency_symbol"] . ")" . "</td>\r\n                                <td nowrap align='center'>" . self::$x10["LBL_VATBLOCK_VAT_VALUE"] . " (" . $xf9["currency_symbol"] . ")" . "</td>\r\n                              </tr>";
             foreach ($x6f["TOTAL"]["VATBLOCK"] as $x14e => $x14f) {
                 if ($x14f["netto"] != 0) {
                     $x14d .= "<tr>\n                                        <td nowrap align='left' width='20%'>" . $x14f["label"] . "</td>\n\n                        \t\t\t\t<td nowrap align='right' width='25%'>" . $this->x23($x14f["value"]) . " %</td>\r\n                                        <td nowrap align='right' width='30%'>" . $this->x23($x14f["netto"]) . "</td>\r\n                                        <td nowrap align='right' width='25%'>" . $this->x23($x14f["vat"]) . "</td>\r\n                                      </tr>";
                 }
             }
             $x14d .= "</table>";
         } else {
             $x14d = "";
         }
         self::$x21["\$" . "VATBLOCK\$"] = $x14d;
         $this->x15();
         if ($x176(self::$x1c, "#VATBLOCK_START#") !== false && $x176(self::$x1c, "#VATBLOCK_END#") !== false) {
             $this->x29();
             $x150 = array();
             $x151 = $x163("#VATBLOCK_START#", self::$x1c);
             $x150[] = $x151[0];
             for ($x79 = 1; $x79 < $x161($x151); $x79++) {
                 $x152 = $x163("#VATBLOCK_END#", $x151[$x79]);
                 foreach ($x152 as $x153) {
                     $x150[] = $x153;
                 }
                 $x154 = $x79 * 2 - 1;
                 $x155[$x154] = $x150[$x154];
                 $x150[$x154] = '';
             }
             if ($x161($x6f["TOTAL"]["VATBLOCK"]) > 0) {
                 foreach ($x6f["TOTAL"]["VATBLOCK"] as $x14e => $x14f) {
                     foreach ($x155 as $x7f => $x80) {
                         if ($x14f["netto"] != 0) {
                             foreach ($x14f as $x156 => $x157) {
                                 if ($x16a($x157)) {
                                     $x157 = $this->x23($x157);
                                 }
                                 $x80 = $x172("\$" . "VATBLOCK_" . $x175($x156) . "\$", $x157, $x80);
                             }
                             $x150[$x7f] .= $x80;
                         }
                     }
                 }
             }
             self::$x1c = $x167('', $x150);
         }
     }
     return $x6f;
 }
Example #2
0
    public function process(Vtiger_Request $request)
    {
        PDFMaker_Debugger_Model::GetInstance()->Init();
        $simple_html_dom_file = $this->getSimpleHtmlDomFile();
        require_once $simple_html_dom_file;
        $default_charset = vglobal('default_charset');
        $adb = PearDatabase::getInstance();
        $relmodule = $request->get("formodule");
        $viewer = $this->getViewer($request);
        // get ids
        if ($request->get("idslist") != "") {
            //generating from listview
            $Records = explode(";", rtrim($request->get("idslist"), ";"));
        } elseif ($request->get('record') != '') {
            $Records = array($request->get("record"));
        } elseif ($request->get('return_id') != '') {
            $Records = array($request->get("return_id"));
        }
        $viewer->assign("RECORDS", implode(';', $Records));
        // get selected templates id array
        $commontemplateids = trim($request->get("commontemplateid"), ";");
        $Templateids = explode(";", $commontemplateids);
        $viewer->assign("COMMONTEMPLATEIDS", $commontemplateids);
        // get selected templates array
        $sql = "SELECT * FROM vtiger_pdfmaker WHERE templateid IN (" . generateQuestionMarks($Templateids) . ")";
        $result = $adb->pquery($sql, $Templateids);
        $num_rows = $adb->num_rows($result);
        $template_select = '';
        if ($num_rows > 1) {
            $template_select .= "<select onChange='changeTemplate(this.value);'>";
            while ($row = $adb->fetchByAssoc($result)) {
                if ($st == "") {
                    $st = $row['templateid'];
                }
                $template_select .= "<option value='" . $row['templateid'] . "'>" . $row['filename'] . "</option>";
            }
            $template_select .= "</select>";
        } else {
            $st = $adb->query_result($result, 0, "templateid");
            $template_select .= $adb->query_result($result, 0, "filename");
        }
        $viewer->assign("TEMPLATE_SELECT", $template_select);
        $viewer->assign("ST", $st);
        // get content of templates
        $PDFMaker = new PDFMaker_PDFMaker_Model('PDFMaker');
        $PDFContents = array();
        //require_once("modules/PDFMaker/InventoryPDF.php");
        foreach ($Records as $record) {
            $record_model = Vtiger_Record_Model::getInstanceById($record);
            $focus = $record_model->entity;
            foreach ($Templateids as $templateid) {
                $PDFContent = new PDFMaker_PDFContent_Model($templateid, $relmodule, $focus, $request->get("language"));
                $pdf_content = $PDFContent->getContent();
                $body_html = $pdf_content["body"];
                $body_html = str_replace("#LISTVIEWBLOCK_START#", "", $body_html);
                $body_html = str_replace("#LISTVIEWBLOCK_END#", "", $body_html);
                $PDFContents[$templateid]["header"] = $pdf_content["header"];
                $PDFContents[$templateid]["body"] = $body_html;
                $PDFContents[$templateid]["footer"] = $pdf_content["footer"];
            }
        }
        $pdf_divs = '';
        foreach ($PDFContents as $templateid => $templatedata) {
            $sections = array("body", "header", "footer");
            foreach ($sections as $val) {
                if ($templatedata[$val] != "") {
                    /*
                    $html = str_get_html($templatedata[$val]);
                    
                    $textTags = $html->find('text');
                    foreach ($textTags as $text) {
                        $text->outertext = str_replace("  ", "&nbsp;&nbsp;", $text->outertext);
                        $text->outertext = str_replace("&nbsp; ", "&nbsp;&nbsp;", $text->outertext);
                    }
                    $templatedata[$val] = htmlentities($html->save(), ENT_QUOTES, $default_charset);
                    */
                    $templatedata[$val] = htmlentities($templatedata[$val], ENT_QUOTES, $default_charset);
                }
            }
            $pdf_divs .= '<div style="display:none;" id="body_div' . $templateid . '"> 
		         <textarea name="body' . $templateid . '" id="body' . $templateid . '" style="width:90%;height:700px" class=small tabindex="5">' . $templatedata["body"] . '</textarea>
		       </div>
		
		       <div style="display:none;" id="header_div' . $templateid . '"> 
		         <textarea name="header' . $templateid . '" id="header' . $templateid . '" style="width:90%;height:700px" class=small tabindex="5">' . $templatedata["header"] . '</textarea>
		       </div>
		 
		       <div style="display:none;" id="footer_div' . $templateid . '"> 
		         <textarea name="footer' . $templateid . '" id="footer' . $templateid . '" style="width:90%;height:700px" class=small tabindex="5">' . $templatedata["footer"] . '</textarea>
		       </div>';
            $pdf_divs .= '<script type="text/javascript">
                            jQuery(document).ready(function(){
		          	CKEDITOR.replace( \'body' . $templateid . '\', {height: \'300\'});
                                CKEDITOR.replace( \'header' . $templateid . '\', {height: \'300\'});
                                CKEDITOR.replace( \'footer' . $templateid . '\', {height: \'300\'});
                                })
		         </script>';
        }
        $viewer->assign("PDF_DIVS", $pdf_divs);
        $language = Vtiger_Language_Handler::getLanguage();
        $mod_strings = Vtiger_Language_Handler::getModuleStringsFromFile($language, "Documents");
        $pdf_strings = Vtiger_Language_Handler::getModuleStringsFromFile($language, "PDFMaker");
        $sql = "select foldername,folderid from vtiger_attachmentsfolder order by foldername";
        $res = $adb->pquery($sql, array());
        $options = "";
        for ($i = 0; $i < $adb->num_rows($res); $i++) {
            $fid = $adb->query_result($res, $i, "folderid");
            $fldr_name = $adb->query_result($res, $i, "foldername");
            $options .= '<option value="' . $fid . '">' . $fldr_name . '</option>';
        }
        $viewer->assign("FOLDER_OPTIONS", $options);
        $viewer->view('EditAndExport.tpl', 'PDFMaker');
    }