コード例 #1
1
 function generate(Vtiger_Request $xxx0b)
 {
     global $xxx22, $xxx23, $xxx24, $xxx25, $xxx26, $xxx27, $xxx28, $xxx29;
     $xxx0c = new PDFMaker_PDFMaker_Model();
     $xxx0d = $xxx0b->getAll();
     $xxx0e = PearDatabase::getInstance();
     $xxx0f = "site_URL";
     $xxx10 = "vtiger_current_version";
     $xxx11 = vglobal($xxx10);
     $xxx12 = vglobal($xxx0f);
     $xxx13 = $xxx0b->get('relmodule');
     $xxx14 = CRMEntity::getInstance($xxx13);
     $xxx15 = $xxx0b->get('record');
     $xxx16 = $xxx0b->get('mode');
     $xxx17 = $xxx0b->get('language');
     $xxx18 = $xxx0b->get('type');
     $xxx19 = "";
     $xxx1a = $xxx0c->GetPreparedMPDF($xxx19, $xxx15, $xxx13, $xxx17);
     $xxx19->Output('cache/' . $xxx1a . '.pdf');
     @$xxx27();
     $xxx25('Content-Type: application/pdf');
     $xxx25("Content-length: " . $xxx22("./cache/{$xxx1a}.pdf"));
     $xxx25("Cache-Control: private");
     $xxx25("Content-Disposition: attachment; filename={$xxx1a}.pdf");
     $xxx25("Content-Description: PHP Generated Data");
     echo $xxx23($xxx24("./cache/{$xxx1a}.pdf", "r"), $xxx22("./cache/{$xxx1a}.pdf"));
     @$xxx29("cache/{$xxx1a}.pdf");
 }
コード例 #2
0
ファイル: Pdfmaker.inc.php プロジェクト: cin-system/cinrepo
 protected function _getFile($id, $moduleName, $crmid)
 {
     $current_user = \Users_Record_Model::getCurrentUserModel();
     $useUser = \Users::getActiveAdminUser();
     $oldUser = vglobal('current_user');
     vglobal('current_user', $useUser);
     $tmpFilename = $this->_getTmpFilename();
     $mpdf = "";
     $language = $current_user->language;
     if (empty($language)) {
         $language = \Vtiger_Language_Handler::getLanguage();
     }
     $Records = array($crmid);
     // $request = $_REQUEST;
     // $_REQUEST['search'] = true;
     //$_REQUEST['submode'] = true;
     \Vtiger_Loader::autoLoad('PDFMaker_PDFMaker_Model');
     $PDFMaker = new \PDFMaker_PDFMaker_Model();
     $name = $PDFMaker->GetPreparedMPDF($mpdf, $Records, array($id), $moduleName, $language);
     $name = $PDFMaker->generate_cool_uri($name);
     if ($name != "") {
         $name = $name . ".pdf";
     }
     $mpdf->Output($tmpFilename);
     vglobal('current_user', $oldUser);
     $filetype = "application/pdf";
     //$_REQUEST = $request;
     return array('path' => $tmpFilename, 'name' => $name, 'type' => $filetype);
 }
コード例 #3
0
ファイル: SendEmail.php プロジェクト: cin-system/cinrepo
 /**
  * Function which will construct the compose email
  * This will handle the case of attaching the invoice pdf as attachment
  * @param Vtiger_Request $request 
  */
 public function composeMailData(Vtiger_Request $request)
 {
     parent::composeMailData($request);
     $viewer = $this->getViewer($request);
     $inventoryRecordId = $request->get('record');
     $mpdf = "";
     $Records = array($inventoryRecordId);
     $language = $request->get('language');
     $moduleName = $request->get('formodule');
     //$pdftemplateid = rtrim($request->get('pdftemplateid'),';');
     $pdftemplateid = rtrim($request->get('pdftemplateid'), ';');
     $Templateids = explode(";", $pdftemplateid);
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     $name = $PDFMaker->GetPreparedMPDF($mpdf, $Records, $Templateids, $moduleName, $language);
     $name = $PDFMaker->generate_cool_uri($name);
     if ($name != "") {
         $fileName = $name . ".pdf";
     } else {
         $fileName = $moduleName . "_" . $inventoryRecordId . '.pdf';
     }
     $current_user = $cu_model = Users_Record_Model::getCurrentUserModel();
     if (!is_dir("storage/PDFMaker/")) {
         mkdir("storage/PDFMaker/");
     }
     if (!is_dir("storage/PDFMaker/" . $current_user->id)) {
         mkdir("storage/PDFMaker/" . $current_user->id);
     }
     $path = 'storage/PDFMaker/' . $current_user->id;
     $pdfFilePath = $path . '/' . $fileName;
     $mpdf->Output($pdfFilePath);
     $attachmentDetails = array(array('attachment' => $fileName, 'path' => $path, 'size' => filesize($pdfFilePath), 'type' => 'pdf', 'nondeletable' => true));
     $viewer->assign('ATTACHMENTS', $attachmentDetails);
     echo $viewer->view('ComposeEmailForm.tpl', 'Emails', true);
 }
コード例 #4
0
ファイル: WfTaskPDFMaker.php プロジェクト: cin-system/cinrepo
 public function handleTask(&$context)
 {
     $adb = \PearDatabase::getInstance();
     if (!getTabid('PDFMaker') || !vtlib_isModuleActive('PDFMaker')) {
         throw new \Exception('PDFMaker Extension not found!');
     }
     /* Insert here source code to execute the task */
     $recordChooser = $this->get('recordChooser');
     if (empty($recordChooser) || $recordChooser == -1) {
         throw new \Exception('You need to configure the PDFMaker Integraion.');
     }
     $recordIds = array();
     if ($recordChooser === 'current') {
         $recordIds = array($context->getId());
         $moduleName = $this->getModuleName();
     } else {
         $currentTime = microtime(true);
         $benchmark = array();
         $parts = explode("#~#", $this->get("search_module"));
         $related_module = VtUtils::getModuleName($parts[1]);
         $moduleName = $related_module;
         $logger = new \Workflow\ConditionLogger();
         $objMySQL = new \Workflow\ConditionMysql($related_module, $context);
         $objMySQL->setLogger($logger);
         $main_module = \CRMEntity::getInstance($related_module);
         $sqlCondition = $objMySQL->parse($this->get("condition"));
         $newTime = microtime(true);
         $benchmark[] = round($newTime - $currentTime, 3);
         $currentTime = $newTime;
         $sqlTables = $objMySQL->generateTables();
         if (strlen($sqlCondition) > 3) {
             $sqlCondition .= " AND vtiger_crmentity.deleted = 0";
         } else {
             $sqlCondition .= " vtiger_crmentity.deleted = 0";
         }
         $logs = $logger->getLogs();
         $this->setStat($logs);
         $sqlCondition .= " GROUP BY vtiger_crmentity.crmid ";
         $idColumn = $main_module->table_name . "." . $main_module->table_index;
         $sqlQuery = "SELECT {$idColumn} as `idCol` " . $sqlTables . " WHERE " . (strlen($sqlCondition) > 3 ? $sqlCondition : "");
         $sortField = $this->get("sort_field");
         if (!empty($sortField) && $sortField != -1) {
             $sortField = VtUtils::getColumnName($sortField);
             $sortDirection = $this->get("sortDirection");
             $sqlQuery .= " ORDER BY " . $sortField . " " . $sortDirection;
         }
         $this->addStat("MySQL Query: " . $sqlQuery);
         $result = $adb->query($sqlQuery, true);
         $newTime = microtime(true);
         $benchmark[] = round($newTime - $currentTime, 3);
         $this->addStat("num Rows: " . $adb->num_rows($result));
         # If no records are found, fo other way
         if ($adb->num_rows($result) == 0) {
             return "yes";
         }
         $this->addStat("Benchmark: " . implode("/", $benchmark));
         while ($row = $adb->fetchByAssoc($result)) {
             $recordIds[] = $row['idcol'];
         }
     }
     $context->save();
     $useUser = Users::getActiveAdminUser();
     $oldUser = vglobal('current_user');
     vglobal('current_user', $useUser);
     $PDFMaker = new PDFMaker_PDFMaker_Model();
     $dl = Vtiger_Language_Handler::getLanguage();
     $mpdf = "";
     $copies = $this->get('copies');
     if ($copies == -1 || empty($copies)) {
         $copies = 1;
     }
     $templateids = array();
     for ($i = 0; $i < $copies; $i++) {
         $templateids = array_merge($templateids, $this->get("template"));
     }
     $filename = $PDFMaker->GetPreparedMPDF($mpdf, $recordIds, $templateids, $moduleName, $dl, '');
     if (strpos($filename, '.pdf') === false) {
         $filename .= '.pdf';
     }
     //        $filename = $PDFMaker->generate_cool_uri($filename);
     $tmpfile = tempnam(sys_get_temp_dir(), 'WfTmp');
     @unlink($tmpfile);
     $mpdf->Output($tmpfile);
     $overwriteFilename = $this->get("filename", $context);
     if ($overwriteFilename != -1 && !empty($overwriteFilename)) {
         $filename = $overwriteFilename;
     }
     \Workflow\FileAction::doActions($this->get('resultaction'), $tmpfile, $filename, $context, $recordIds, $this->getWorkflow());
     vglobal('current_user', $oldUser);
     return "yes";
 }