Esempio n. 1
0
 public function process(Vtiger_Request $request)
 {
     if ($_FILES['import_file']['error'] == 0) {
         $tmp_file_name = $_FILES['import_file']['tmp_name'];
         $fh = fopen($tmp_file_name, "r");
         $xml_content = fread($fh, filesize($tmp_file_name));
         fclose($fh);
         $PDFMaker = new PDFMaker_PDFMaker_Model();
         $adb = PearDatabase::getInstance();
         $xml = new SimpleXMLElement($xml_content);
         foreach ($xml->template as $data) {
             $filename = $this->cdataDecode($data->templatename);
             $nameOfFile = $this->cdataDecode($data->filename);
             $description = $this->cdataDecode($data->description);
             $modulename = $this->cdataDecode($data->module);
             $pdf_format = $this->cdataDecode($data->settings->format);
             $pdf_orientation = $this->cdataDecode($data->settings->orientation);
             $tabid = getTabId($modulename);
             if ($PDFMaker->GetVersionType() == "professional" || in_array($tabid, $PDFMaker->GetBasicModules())) {
                 if ($data->settings->margins->top > 0) {
                     $margin_top = $data->settings->margins->top;
                 } else {
                     $margin_top = 0;
                 }
                 if ($data->settings->margins->bottom > 0) {
                     $margin_bottom = $data->settings->margins->bottom;
                 } else {
                     $margin_bottom = 0;
                 }
                 if ($data->settings->margins->left > 0) {
                     $margin_left = $data->settings->margins->left;
                 } else {
                     $margin_left = 0;
                 }
                 if ($data->settings->margins->right > 0) {
                     $margin_right = $data->settings->margins->right;
                 } else {
                     $margin_right = 0;
                 }
                 $dec_point = $this->cdataDecode($data->settings->decimals->point);
                 $dec_decimals = $this->cdataDecode($data->settings->decimals->decimals);
                 $dec_thousands = $this->cdataDecode($data->settings->decimals->thousands);
                 $header = $this->cdataDecode($data->header);
                 $body = $this->cdataDecode($data->body);
                 $footer = $this->cdataDecode($data->footer);
                 $templateid = $adb->getUniqueID('vtiger_pdfmaker');
                 $sql1 = "insert into vtiger_pdfmaker (filename,module,description,body,deleted,templateid) values (?,?,?,?,?,?)";
                 $params1 = array($filename, $modulename, $description, $body, 0, $templateid);
                 $adb->pquery($sql1, $params1);
                 $sql2 = "INSERT INTO vtiger_pdfmaker_settings (templateid, margin_top, margin_bottom, margin_left, margin_right, format, orientation, decimals, decimal_point, thousands_separator, header, footer, encoding, file_name) \n             VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
                 $params2 = array($templateid, $margin_top, $margin_bottom, $margin_left, $margin_right, $pdf_format, $pdf_orientation, $dec_decimals, $dec_point, $dec_thousands, $header, $footer, "auto", $nameOfFile);
                 $adb->pquery($sql2, $params2);
                 $PDFMaker->AddLinks($modulename);
             }
         }
     }
     header('Location: index.php?module=PDFMaker&view=List');
 }