public function process(Vtiger_Request $request) { PDFMaker_Debugger_Model::GetInstance()->Init(); $PDFMaker = new PDFMaker_PDFMaker_Model(); if ($PDFMaker->CheckPermissions("DETAIL") == false) { $PDFMaker->DieDuePermission(); } $viewer = $this->getViewer($request); if ($request->has('templateid') && !$request->isEmpty('templateid')) { $pdftemplateResult = $PDFMaker->GetDetailViewData($_REQUEST['templateid']); $viewer->assign("TEMPLATEID", $pdftemplateResult["templateid"]); $viewer->assign("MODULENAME", getTranslatedString($pdftemplateResult["module"])); $viewer->assign("BODY", decode_html($pdftemplateResult["body"])); $viewer->assign("HEADER", decode_html($pdftemplateResult["header"])); $viewer->assign("FOOTER", decode_html($pdftemplateResult["footer"])); } $version_type = $PDFMaker->GetVersionType(); $viewer->assign("VERSION", $version_type . " " . PDFMaker_Version_Helper::$version); if ($PDFMaker->CheckPermissions("EDIT") && $PDFMaker->GetVersionType() != "deactivate") { $viewer->assign("EDIT", "permitted"); } $category = getParentTab(); $viewer->assign("CATEGORY", $category); $viewer->view('Detail.tpl', 'PDFMaker'); }
public function process(Vtiger_Request $request) { PDFMaker_Debugger_Model::GetInstance()->Init(); $PDFMaker = new PDFMaker_PDFMaker_Model(); if ($PDFMaker->CheckPermissions("DELETE") == false) { $PDFMaker->DieDuePermission(); } $adb = PearDatabase::getInstance(); $id_array = array(); if ($request->has('templateid') && !$request->isEmpty('templateid')) { $templateid = $request->get('templateid'); $checkSql = "select module from vtiger_pdfmaker where templateid=?"; $checkRes = $adb->pquery($checkSql, array($templateid)); $checkRow = $adb->fetchByAssoc($checkRes); //if we are trying to delete template that is not allowed for current user then die because user should not be able to see the template //$PDFMaker->CheckTemplatePermissions($checkRow["module"], $templateid); $Template_Permissions_Data = $PDFMaker->returnTemplatePermissionsData($checkRow["module"], $templateid); if ($Template_Permissions_Data["delete"] === false) { $this->DieDuePermission(); } $sql = "delete from vtiger_pdfmaker where templateid=?"; $adb->pquery($sql, array($templateid)); $sql = "delete from vtiger_pdfmaker_settings where templateid=?"; $adb->pquery($sql, array($templateid)); } else { $idlist = $request->get('idlist'); $id_array = explode(';', $idlist); $checkSql = "select templateid, module from vtiger_pdfmaker where templateid IN (" . generateQuestionMarks($id_array) . ")"; $checkRes = $adb->pquery($checkSql, $id_array); $checkArr = array(); while ($checkRow = $adb->fetchByAssoc($checkRes)) { $checkArr[$checkRow["templateid"]] = $checkRow["module"]; } for ($i = 0; $i < count($id_array) - 1; $i++) { //if we are trying to delete template that is not allowed for current user then die because user should not be able to see the template //$PDFMaker->CheckTemplatePermissions($checkArr[$id_array[$i]], $id_array[$i]); $Template_Permissions_Data = $PDFMaker->returnTemplatePermissionsData($checkArr[$id_array[$i]], $id_array[$i]); if ($Template_Permissions_Data["delete"] === false) { $this->DieDuePermission(); } $sql = "delete from vtiger_pdfmaker where templateid=?"; $adb->pquery($sql, array($id_array[$i])); $sql = "delete from vtiger_pdfmaker_settings where templateid=?"; $adb->pquery($sql, array($id_array[$i])); } } $ajaxDelete = $request->get('ajaxDelete'); $listViewUrl = "index.php?module=PDFMaker&view=List"; if ($ajaxDelete) { $response = new Vtiger_Response(); $response->setResult($listViewUrl); return $response; } else { header("Location: {$listViewUrl}"); } }
public function process(Vtiger_Request $request) { PDFMaker_Debugger_Model::GetInstance()->Init(); $PDFMaker = new PDFMaker_PDFMaker_Model(); if ($PDFMaker->CheckPermissions("DETAIL") == false) { $PDFMaker->DieDuePermission(); } $viewer = $this->getViewer($request); if ($request->has('templateid') && !$request->isEmpty('templateid')) { $pdftemplateResult = $PDFMaker->GetDetailViewData($_REQUEST['templateid']); $viewer->assign("FILENAME", $pdftemplateResult["filename"]); $viewer->assign("DESCRIPTION", $pdftemplateResult["description"]); $viewer->assign("TEMPLATEID", $pdftemplateResult["templateid"]); $viewer->assign("MODULENAME", getTranslatedString($pdftemplateResult["module"])); $viewer->assign("BODY", decode_html($pdftemplateResult["body"])); $viewer->assign("HEADER", decode_html($pdftemplateResult["header"])); $viewer->assign("FOOTER", decode_html($pdftemplateResult["footer"])); $viewer->assign("IS_ACTIVE", $pdftemplateResult["is_active"]); $viewer->assign("IS_DEFAULT", $pdftemplateResult["is_default"]); $viewer->assign("ACTIVATE_BUTTON", $pdftemplateResult["activateButton"]); $viewer->assign("DEFAULT_BUTTON", $pdftemplateResult["defaultButton"]); } $version_type = $PDFMaker->GetVersionType(); $viewer->assign("VERSION", $version_type . " " . PDFMaker_Version_Helper::$version); if ($pdftemplateResult["permissions"]["edit"]) { //if ($PDFMaker->CheckPermissions("EDIT")) { $viewer->assign("EXPORT", "yes"); } if ($PDFMaker->GetVersionType() != "deactivate") { if ($pdftemplateResult["permissions"]["edit"]) { //if ($PDFMaker->CheckPermissions("EDIT") && $PDFMaker->GetVersionType() != "deactivate") { $viewer->assign("EDIT", "permitted"); $viewer->assign("IMPORT", "yes"); } if ($pdftemplateResult["permissions"]["delete"]) { $viewer->assign("DELETE", "permitted"); } } //$tool_buttons = Button_Check('PDFMaker'); //$viewer->assign('CHECK', $tool_buttons); $category = getParentTab(); $viewer->assign("CATEGORY", $category); $viewer->view('Detail.tpl', 'PDFMaker'); }
public function getTemplates($selected_module) { $PDFMaker = new PDFMaker_PDFMaker_Model(); $templates = $PDFMaker->GetAvailableTemplates($selected_module); $def_template = array(); $fieldvalue = array(); if ($PDFMaker->CheckPermissions("DETAIL") !== false) { foreach ($templates as $templateid => $valArr) { if ($valArr["is_default"] == "1" || $valArr["is_default"] == "3") { $def_template[$templateid] = $valArr["templatename"]; } else { $fieldvalue[$templateid] = $valArr["templatename"]; } } if (count($def_template) > 0) { $fieldvalue = (array) $def_template + (array) $fieldvalue; } } if (count($fieldvalue) == 0) { $fieldvalue[] = "none"; } return $fieldvalue; }
function process(Vtiger_Request $request) { PDFMaker_Debugger_Model::GetInstance()->Init(); //parent::process($request); $viewer = $this->getViewer($request); $PDFMaker = new PDFMaker_PDFMaker_Model(); if ($PDFMaker->CheckPermissions("EDIT")) { $viewer->assign("EXPORT", "yes"); if ($PDFMaker->GetVersionType() != "deactivate") { $viewer->assign("IMPORT", "yes"); } } if ($request->get('from_view') == 'Detail' && !$request->isEmpty('from_templateid')) { $viewer->assign('ALLOW_SET_AS', 'yes'); $pdftemplateResult = $PDFMaker->GetDetailViewData($request->get('from_templateid')); $viewer->assign("IS_ACTIVE", $pdftemplateResult["is_active"]); $viewer->assign("IS_DEFAULT", $pdftemplateResult["is_default"]); $viewer->assign("ACTIVATE_BUTTON", $pdftemplateResult["activateButton"]); $viewer->assign("DEFAULT_BUTTON", $pdftemplateResult["defaultButton"]); $viewer->assign("TEMPLATEID", $request->get('from_templateid')); } //print_r($_REQUEST); $viewer->view('TemplateTools.tpl', 'PDFMaker'); }
public function process(Vtiger_Request $request) { PDFMaker_Debugger_Model::GetInstance()->Init(); $PDFMaker = new PDFMaker_PDFMaker_Model(); if ($PDFMaker->CheckPermissions("EDIT") == false) { $PDFMaker->DieDuePermission(); } $viewer = $this->getViewer($request); if ($request->has('templateid') && !$request->isEmpty('templateid')) { $templateid = $request->get('templateid'); $pdftemplateResult = $PDFMaker->GetEditViewData($templateid); $select_module = $pdftemplateResult["module"]; $select_format = $pdftemplateResult["format"]; $select_orientation = $pdftemplateResult["orientation"]; } else { $templateid = ""; if ($request->has("return_module") && !$request->isEmpty("return_module")) { $select_module = $request->get("return_module"); } else { $select_module = ""; } $select_format = "A4"; $select_orientation = "portrait"; } $PDFMaker->CheckTemplatePermissions($select_module, $templateid); $viewer->assign("EMODE", "edit"); $viewer->assign("TEMPLATEID", $templateid); $viewer->assign("MODULENAME", vtranslate($select_module, $select_module)); $viewer->assign("SELECTMODULE", $select_module); $viewer->assign("BODY", $pdftemplateResult["body"]); $cu_model = Users_Record_Model::getCurrentUserModel(); $this->cu_language = $cu_model->get('language'); $viewer->assign("THEME", $theme); $viewer->assign("IMAGE_PATH", $image_path); $app_strings_big = Vtiger_Language_Handler::getModuleStringsFromFile($this->cu_language); $app_strings = $app_strings_big['languageStrings']; $viewer->assign("APP", $app_strings); $viewer->assign("PARENTTAB", getParentTab()); $modArr = $PDFMaker->GetAllModules(); $Modulenames = $modArr[0]; $ModuleIDS = $modArr[1]; // ****************************************** Company and User information: ********************************** $CUI_BLOCKS["Account"] = vtranslate("LBL_COMPANY_INFO", 'PDFMaker'); $CUI_BLOCKS["Assigned"] = vtranslate("LBL_USER_INFO", 'PDFMaker'); $CUI_BLOCKS["Logged"] = vtranslate("LBL_LOGGED_USER_INFO", 'PDFMaker'); $viewer->assign("CUI_BLOCKS", $CUI_BLOCKS); $adb = PearDatabase::getInstance(); $sql = "SELECT * FROM vtiger_organizationdetails"; $result = $adb->pquery($sql, array()); $organization_logoname = decode_html($adb->query_result($result, 0, 'logoname')); $organization_header = decode_html($adb->query_result($result, 0, 'headername')); $organization_stamp_signature = $adb->query_result($result, 0, 'stamp_signature'); global $site_URL; $path = $site_URL . "/test/logo/"; if (isset($organization_logoname)) { $organization_logo_img = "<img src=\"" . $path . $organization_logoname . "\">"; $viewer->assign("COMPANYLOGO", $organization_logo_img); } if (isset($organization_stamp_signature)) { $organization_stamp_signature_img = "<img src=\"" . $path . $organization_stamp_signature . "\">"; $viewer->assign("COMPANY_STAMP_SIGNATURE", $organization_stamp_signature_img); } if (isset($organization_header)) { $organization_header_img = "<img src=\"" . $path . $organization_header . "\">"; $viewer->assign("COMPANY_HEADER_SIGNATURE", $organization_header_img); } $Acc_Info = array('' => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "COMPANY_NAME" => vtranslate("LBL_COMPANY_NAME", 'PDFMaker'), "COMPANY_LOGO" => vtranslate("LBL_COMPANY_LOGO", 'PDFMaker'), "COMPANY_ADDRESS" => vtranslate("LBL_COMPANY_ADDRESS", 'PDFMaker'), "COMPANY_CITY" => vtranslate("LBL_COMPANY_CITY", 'PDFMaker'), "COMPANY_STATE" => vtranslate("LBL_COMPANY_STATE", 'PDFMaker'), "COMPANY_ZIP" => vtranslate("LBL_COMPANY_ZIP", 'PDFMaker'), "COMPANY_COUNTRY" => vtranslate("LBL_COMPANY_COUNTRY", 'PDFMaker'), "COMPANY_PHONE" => vtranslate("LBL_COMPANY_PHONE", "PDFMaker"), "COMPANY_FAX" => vtranslate("LBL_COMPANY_FAX", 'PDFMaker'), "COMPANY_WEBSITE" => vtranslate("LBL_COMPANY_WEBSITE", 'PDFMaker')); $viewer->assign("ACCOUNTINFORMATIONS", $Acc_Info); $sql_user_block = "SELECT blockid, blocklabel FROM vtiger_blocks WHERE tabid=29 ORDER BY sequence ASC"; $res_user_block = $adb->query($sql_user_block); $user_block_info_arr = array(); while ($row_user_block = $adb->fetch_array($res_user_block)) { $sql_user_field = "SELECT fieldid, uitype FROM vtiger_field WHERE block=" . $row_user_block['blockid'] . " and (displaytype != 3 OR uitype = 55) ORDER BY sequence ASC"; $res_user_field = $adb->query($sql_user_field); $num_user_field = $adb->num_rows($res_user_field); if ($num_user_field > 0) { $user_field_id_array = array(); while ($row_user_field = $adb->fetch_array($res_user_field)) { $user_field_id_array[] = $row_user_field['fieldid']; // print_r($user_field_id_array); } $user_block_info_arr[$row_user_block['blocklabel']] = $user_field_id_array; } } $user_mod_strings = $this->getModuleLanguageArray("Users"); $b = 0; foreach ($user_block_info_arr as $block_label => $block_fields) { $b++; if (isset($user_mod_strings[$block_label]) and $user_mod_strings[$block_label] != "") { $optgroup_value = $user_mod_strings[$block_label]; } else { $optgroup_value = vtranslate($block_label, 'PDFMaker'); } if (count($block_fields) > 0) { $field_ids = implode(",", $block_fields); $sql1 = "SELECT * FROM vtiger_field WHERE fieldid IN (" . $field_ids . ")"; $result1 = $adb->query($sql1); while ($row1 = $adb->fetchByAssoc($result1)) { $fieldname = $row1['fieldname']; $fieldlabel = $row1['fieldlabel']; $option_key = strtoupper("Users" . "_" . $fieldname); if (isset($current_mod_strings[$fieldlabel]) and $current_mod_strings[$fieldlabel] != "") { $option_value = $current_mod_strings[$fieldlabel]; } elseif (isset($app_strings[$fieldlabel]) and $app_strings[$fieldlabel] != "") { $option_value = $app_strings[$fieldlabel]; } else { $option_value = $fieldlabel; } $User_Info[$optgroup_value][$option_key] = $option_value; $Logged_User_Info[$optgroup_value]["R_" . $option_key] = $option_value; } } //variable RECORD ID added if ($b == 1) { $option_value = "Record ID"; $option_key = strtoupper("USERS_CRMID"); $User_Info[$optgroup_value][$option_key] = $option_value; $Logged_User_Info[$optgroup_value]["R_" . $option_key] = $option_value; } //end } // ****************************************** END: Company and User information ********************************** $viewer->assign("USERINFORMATIONS", $User_Info); $viewer->assign("LOGGEDUSERINFORMATION", $Logged_User_Info); $Invterandcon = array("" => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "TERMS_AND_CONDITIONS" => vtranslate("LBL_TERMS_AND_CONDITIONS", 'PDFMaker')); $viewer->assign("INVENTORYTERMSANDCONDITIONS", $Invterandcon); //labels $global_lang_labels = @array_flip($app_strings); $global_lang_labels = @array_flip($global_lang_labels); asort($global_lang_labels); $viewer->assign("GLOBAL_LANG_LABELS", $global_lang_labels); $module_lang_labels = array(); if ($select_module != "") { $mod_lang = $this->getModuleLanguageArray($select_module); $module_lang_labels = @array_flip($mod_lang); $module_lang_labels = @array_flip($module_lang_labels); asort($module_lang_labels); } else { $module_lang_labels[""] = vtranslate("LBL_SELECT_MODULE_FIELD", 'PDFMaker'); } $viewer->assign("MODULE_LANG_LABELS", $module_lang_labels); $Header_Footer_Strings = array("" => vtranslate("LBL_PLS_SELECT", 'PDFMaker'), "PAGE" => $app_strings["Page"], "PAGES" => $app_strings["Pages"]); $viewer->assign("HEADER_FOOTER_STRINGS", $Header_Footer_Strings); //PDF FORMAT SETTINGS $Formats = array("A3" => "A3", "A4" => "A4", "A5" => "A5", "A6" => "A6", "Letter" => "Letter", "Legal" => "Legal", "Custom" => "Custom"); // ITS4YOU VlZa $viewer->assign("FORMATS", $Formats); if (strpos($select_format, ";") > 0) { $tmpArr = explode(";", $select_format); $select_format = "Custom"; $custom_format["width"] = $tmpArr[0]; $custom_format["height"] = $tmpArr[1]; $viewer->assign("CUSTOM_FORMAT", $custom_format); } $viewer->assign("SELECT_FORMAT", $select_format); //PDF ORIENTATION SETTINGS $Orientations = array("portrait" => vtranslate("portrait", 'PDFMaker'), "landscape" => vtranslate("landscape", 'PDFMaker')); $viewer->assign("ORIENTATIONS", $Orientations); $viewer->assign("SELECT_ORIENTATION", $select_orientation); //PDF MARGIN SETTINGS if ($request->has("templateid") && !$request->isEmpty("templateid")) { $Margins = array("top" => $pdftemplateResult["margin_top"], "bottom" => $pdftemplateResult["margin_bottom"], "left" => $pdftemplateResult["margin_left"], "right" => $pdftemplateResult["margin_right"]); $Decimals = array("point" => $pdftemplateResult["decimal_point"], "decimals" => $pdftemplateResult["decimals"], "thousands" => $pdftemplateResult["thousands_separator"] != "sp" ? $pdftemplateResult["thousands_separator"] : " "); } else { $Margins = array("top" => "2", "bottom" => "2", "left" => "2", "right" => "2"); $Decimals = array("point" => ",", "decimals" => "2", "thousands" => " "); } $viewer->assign("MARGINS", $Margins); $viewer->assign("DECIMALS", $Decimals); //PDF HEADER / FOOTER $header = ""; $footer = ""; if ($request->has("templateid") && !$request->isEmpty("templateid")) { $header = $pdftemplateResult["header"]; $footer = $pdftemplateResult["footer"]; } $viewer->assign("HEADER", $header); $viewer->assign("FOOTER", $footer); $hfVariables = array("##PAGE##" => vtranslate("LBL_CURRENT_PAGE", 'PDFMaker'), "##PAGES##" => vtranslate("LBL_ALL_PAGES", 'PDFMaker'), "##PAGE##/##PAGES##" => vtranslate("LBL_PAGE_PAGES", 'PDFMaker')); $viewer->assign("HEAD_FOOT_VARS", $hfVariables); $dateVariables = array("##DD.MM.YYYY##" => vtranslate("LBL_DATE_DD.MM.YYYY", 'PDFMaker'), "##DD-MM-YYYY##" => vtranslate("LBL_DATE_DD-MM-YYYY", 'PDFMaker'), "##MM-DD-YYYY##" => vtranslate("LBL_DATE_MM-DD-YYYY", 'PDFMaker'), "##YYYY-MM-DD##" => vtranslate("LBL_DATE_YYYY-MM-DD", 'PDFMaker')); $viewer->assign("DATE_VARS", $dateVariables); $cmod = $this->getModuleLanguageArray("Settings"); //$cmod = return_specified_module_language($current_language, "Settings"); $viewer->assign("CMOD", $cmod); //Ignored picklist values $pvsql = "SELECT value FROM vtiger_pdfmaker_ignorepicklistvalues"; $pvresult = $adb->query($pvsql); $pvvalues = ""; while ($pvrow = $adb->fetchByAssoc($pvresult)) { $pvvalues .= $pvrow["value"] . ", "; } $viewer->assign("IGNORE_PICKLIST_VALUES", rtrim($pvvalues, ", ")); $More_Fields = array("CURRENCYNAME" => vtranslate("LBL_CURRENCY_NAME", 'PDFMaker'), "CURRENCYSYMBOL" => vtranslate("LBL_CURRENCY_SYMBOL", 'PDFMaker'), "CURRENCYCODE" => vtranslate("LBL_CURRENCY_CODE", 'PDFMaker'), "TOTALWITHOUTVAT" => vtranslate("LBL_VARIABLE_SUMWITHOUTVAT", 'PDFMaker'), "TOTALDISCOUNT" => vtranslate("LBL_VARIABLE_TOTALDISCOUNT", 'PDFMaker'), "TOTALDISCOUNTPERCENT" => vtranslate("LBL_VARIABLE_TOTALDISCOUNT_PERCENT", 'PDFMaker'), "TOTALAFTERDISCOUNT" => vtranslate("LBL_VARIABLE_TOTALAFTERDISCOUNT", 'PDFMaker'), "VAT" => vtranslate("LBL_VARIABLE_VAT", 'PDFMaker'), "VATPERCENT" => vtranslate("LBL_VARIABLE_VAT_PERCENT", 'PDFMaker'), "VATBLOCK" => vtranslate("LBL_VARIABLE_VAT_BLOCK", 'PDFMaker'), "TOTALWITHVAT" => vtranslate("LBL_VARIABLE_SUMWITHVAT", 'PDFMaker'), "SHTAXTOTAL" => vtranslate("LBL_SHTAXTOTAL", 'PDFMaker'), "SHTAXAMOUNT" => vtranslate("LBL_SHTAXAMOUNT", 'PDFMaker'), "ADJUSTMENT" => vtranslate("LBL_ADJUSTMENT", 'PDFMaker'), "TOTAL" => vtranslate("LBL_VARIABLE_TOTALSUM", 'PDFMaker')); //formatable VATBLOCK content $vatblock_table = '<table border="1" cellpadding="3" cellspacing="0" style="border-collapse:collapse;"> <tr> <td>' . $app_strings["Name"] . '</td> <td>' . vtranslate("LBL_VATBLOCK_VAT_PERCENT", 'PDFMaker') . '</td> <td>' . vtranslate("LBL_VATBLOCK_SUM", 'PDFMaker') . '</td> <td>' . vtranslate("LBL_VATBLOCK_VAT_VALUE", 'PDFMaker') . '</td> </tr> <tr> <td colspan="4">#VATBLOCK_START#</td> </tr> <tr> <td>$VATBLOCK_LABEL$</td> <td>$VATBLOCK_VALUE$</td> <td>$VATBLOCK_NETTO$</td> <td>$VATBLOCK_VAT$</td> </tr> <tr> <td colspan="4">#VATBLOCK_END#</td> </tr> </table>'; $vatblock_table = str_replace(array("\r\n", "\r", "\n", "\t"), "", $vatblock_table); $vatblock_table = ereg_replace(" {2,}", ' ', $vatblock_table); $viewer->assign("VATBLOCK_TABLE", $vatblock_table); $ModCommentsModules = array(); foreach ($ModuleIDS as $module => $IDS) { if ($module == 'Calendar') { $sql1 = "SELECT blockid, blocklabel FROM vtiger_blocks WHERE tabid IN (9,16) ORDER BY sequence ASC"; } elseif ($module == "Quotes" || $module == "Invoice" || $module == "SalesOrder" || $module == "PurchaseOrder" || $module == "Issuecards" || $module == "Receiptcards" || $module == "Creditnote" || $module == "StornoInvoice") { $sql1 = "SELECT blockid, blocklabel FROM vtiger_blocks WHERE tabid=" . $IDS . " AND blocklabel != 'LBL_DETAILS_BLOCK' AND blocklabel != 'LBL_ITEM_DETAILS' ORDER BY sequence ASC"; } else { $sql1 = "SELECT blockid, blocklabel FROM vtiger_blocks WHERE tabid=" . $IDS . " ORDER BY sequence ASC"; } $res1 = $adb->query($sql1); $block_info_arr = array(); while ($row = $adb->fetch_array($res1)) { if ($row['blockid'] == '41' && $row['blocklabel'] == '') { $row['blocklabel'] = 'LBL_EVENT_INFORMATION'; } $sql2 = "SELECT fieldid, uitype, columnname, fieldlabel\n FROM vtiger_field\n WHERE block=" . $row['blockid'] . "\n AND (displaytype != 3 OR uitype = 55)\n ORDER BY sequence ASC"; $res2 = $adb->query($sql2); $num_rows2 = $adb->num_rows($res2); if ($num_rows2 > 0) { $field_id_array = array(); while ($row2 = $adb->fetch_array($res2)) { $field_id_array[] = $row2['fieldid']; $tmpArr = array($row2["columnname"], $row2["fieldlabel"]); switch ($row2['uitype']) { case "51": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Accounts"); break; case "57": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Contacts"); break; case "58": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Campaigns"); break; case "59": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Products"); break; case "73": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Accounts"); break; case "75": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Vendors"); break; case "81": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Vendors"); break; case "76": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Potentials"); break; case "78": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Quotes"); break; case "80": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "SalesOrder"); break; case "68": $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Accounts"); $All_Related_Modules[$module][] = array_merge($tmpArr, (array) "Contacts"); break; case "10": $fmrs = $adb->query('SELECT relmodule FROM vtiger_fieldmodulerel WHERE fieldid=' . $row2['fieldid']); while ($rm = $adb->fetch_array($fmrs)) { $All_Related_Modules[$module][] = array_merge($tmpArr, (array) $rm['relmodule']); } break; } } // ITS4YOU MaJu //$block_info_arr[$row['blocklabel']] = $field_id_array; if (!empty($block_info_arr[$row['blocklabel']])) { foreach ($field_id_array as $field_id_array_value) { $block_info_arr[$row['blocklabel']][] = $field_id_array_value; } } else { $block_info_arr[$row['blocklabel']] = $field_id_array; } // ITS4YOU-END } } if ($module == "Quotes" || $module == "Invoice" || $module == "SalesOrder" || $module == "PurchaseOrder") { $block_info_arr["LBL_DETAILS_BLOCK"] = array(); } //ModComments support //if (in_array($module, $ModCommentsModules)) { // $block_info_arr["TEMP_MODCOMMENTS_BLOCK"] = array(); //} $ModuleFields[$module] = $block_info_arr; } //Permissions are taken into consideration when dealing with realted modules $AllowedRelMods = array(); if (count($All_Related_Modules) > 0) { foreach ($All_Related_Modules as $Mod => $RelMods) { foreach ($RelMods as $RelModKey => $RelMod) { $RelModName = $RelMod[2]; if (isPermitted($RelModName, '') == "yes") { $AllowedRelMods[$Mod][$RelModKey] = $RelMod; } } } } $All_Related_Modules = $AllowedRelMods; // Fix of emtpy selectbox in case of selected module does not have any related modules foreach ($Modulenames as $key => $value) { if (!isset($All_Related_Modules[$key])) { $All_Related_Modules[$key] = array(); } } $viewer->assign("ALL_RELATED_MODULES", $All_Related_Modules); if ($select_module != "" && count($All_Related_Modules[$select_module]) > 0) { foreach ($All_Related_Modules[$select_module] as $RelModArr) { $Related_Modules[$RelModArr[2] . "|" . $RelModArr[0]] = vtranslate($RelModArr[2]) . " (" . $RelModArr[1] . ")"; } } $viewer->assign("RELATED_MODULES", $Related_Modules); $tacModules = array(); $tac4you = is_numeric(getTabId("Tac4you")); if ($tac4you == true) { $sql = "SELECT tac4you_module FROM vtiger_tac4you_module WHERE presence = 1"; $result = $adb->query($sql); while ($row = $adb->fetchByAssoc($result)) { $tacModules[$row["tac4you_module"]] = $row["tac4you_module"]; } } $desc4youModules = array(); $desc4you = is_numeric(getTabId("Descriptions4you")); if ($desc4you == true) { $sql = "SELECT b.name FROM vtiger_links AS a\n INNER JOIN vtiger_tab AS b USING (tabid)\n WHERE linktype = 'DETAILVIEWWIDGET'\n AND linkurl = 'block://ModDescriptions4you:modules/Descriptions4you/ModDescriptions4you.php'"; $result = $adb->query($sql); while ($row = $adb->fetchByAssoc($result)) { $desc4youModules[$row["name"]] = $row["name"]; } } $Settings_Profiles_Record_Model = new Settings_Profiles_Record_Model(); foreach ($ModuleFields as $module => $Blocks) { $Optgroupts = array(); $current_mod_strings = $this->getModuleLanguageArray($module); $moduleModel = Vtiger_Module_Model::getInstance($module); $b = 0; if ($module == 'Calendar') { $b++; $Optgroupts[] = '"' . vtranslate('Calendar') . '","' . $b . '"'; $Convert_ModuleFields['Calendar|1'] .= ',"Record ID","CALENDAR_CRMID"'; $SelectModuleFields['Calendar'][vtranslate('Calendar')]["CALENDAR_CRMID"] = "Record ID"; $EventModel = Vtiger_Module_Model::getInstance('Events'); } foreach ($Blocks as $block_label => $block_fields) { $b++; $Options = array(); if ($block_label != "TEMP_MODCOMMENTS_BLOCK") { $optgroup_value = vtranslate($block_label, $module); if ($optgroup_value == $block_label) { $optgroup_value = vtranslate($block_label, 'PDFMaker'); } } else { $optgroup_value = vtranslate("LBL_MODCOMMENTS_INFORMATION", 'PDFMaker'); } $Optgroupts[] = '"' . $optgroup_value . '","' . $b . '"'; if (count($block_fields) > 0) { $field_ids = implode(",", $block_fields); $sql1 = "SELECT * FROM vtiger_field WHERE fieldid IN (" . $field_ids . ")"; $result1 = $adb->query($sql1); while ($row1 = $adb->fetchByAssoc($result1)) { $fieldname = $row1['fieldname']; $fieldlabel = $row1['fieldlabel']; $fieldModel = Vtiger_Field_Model::getInstance($fieldname, $moduleModel); if (!$fieldModel || !$fieldModel->getPermissions('readonly')) { if ($module == 'Calendar') { $eventFieldModel = Vtiger_Field_Model::getInstance($fieldname, $EventModel); if (!$eventFieldModel || !$eventFieldModel->getPermissions('readonly')) { continue; } } else { continue; } } $option_key = strtoupper($module . "_" . $fieldname); if (isset($current_mod_strings[$fieldlabel]) and $current_mod_strings[$fieldlabel] != "") { $option_value = $current_mod_strings[$fieldlabel]; } elseif (isset($app_strings[$fieldlabel]) and $app_strings[$fieldlabel] != "") { $option_value = $app_strings[$fieldlabel]; } else { $option_value = $fieldlabel; } if ($module == 'Calendar') { if ($option_key == 'CALENDAR_ACTIVITYTYPE' || $option_key == 'CALENDAR_DUE_DATE') { $Convert_ModuleFields['Calendar|1'] .= ',"' . $option_value . '","' . $option_key . '"'; $SelectModuleFields['Calendar'][vtranslate('Calendar')][$option_key] = $option_value; continue; } elseif (!isset($Existing_ModuleFields[$option_key])) { $Existing_ModuleFields[$option_key] = $optgroup_value; } else { $Convert_ModuleFields['Calendar|1'] .= ',"' . $option_value . '","' . $option_key . '"'; $SelectModuleFields['Calendar'][vtranslate('Calendar')][$option_key] = $option_value; $Unset_Module_Fields[] = '"' . $option_value . '","' . $option_key . '"'; unset($SelectModuleFields['Calendar'][$Existing_ModuleFields[$option_key]][$option_key]); continue; } } $Options[] = '"' . $option_value . '","' . $option_key . '"'; $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value; } } //variable RECORD ID added if ($b == 1) { $option_value = "Record ID"; $option_key = strtoupper($module . "_CRMID"); $Options[] = '"' . $option_value . '","' . $option_key . '"'; $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value; $option_value = vtranslate('Created Time') . ' (' . vtranslate('Due Date & Time') . ')'; $option_key = strtoupper($module . "_CREATEDTIME_DATETIME"); $Options[] = '"' . $option_value . '","' . $option_key . '"'; $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value; $option_value = vtranslate('Modified Time') . ' (' . vtranslate('Due Date & Time') . ')'; $option_key = strtoupper($module . "_MODIFIEDTIME_DATETIME"); $Options[] = '"' . $option_value . '","' . $option_key . '"'; $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value; } //end if ($block_label == "LBL_TERMS_INFORMATION" && isset($tacModules[$module])) { $option_value = vtranslate("LBL_TAC4YOU", 'PDFMaker'); $option_key = strtoupper($module . "_TAC4YOU"); $Options[] = '"' . $option_value . '","' . $option_key . '"'; $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value; } if ($block_label == "LBL_DESCRIPTION_INFORMATION" && isset($desc4youModules[$module])) { $option_value = vtranslate("LBL_DESC4YOU", 'PDFMaker'); $option_key = strtoupper($module . "_DESC4YOU"); $Options[] = '"' . $option_value . '","' . $option_key . '"'; $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value; } //ModComments support if ($block_label == "TEMP_MODCOMMENTS_BLOCK" && in_array($module, $ModCommentsModules) == true) { $option_value = vtranslate("LBL_MODCOMMENTS", 'PDFMaker'); $option_key = strtoupper($module . "_MODCOMMENTS"); $Options[] = '"' . $option_value . '","' . $option_key . '"'; $SelectModuleFields[$module][$optgroup_value][$option_key] = $option_value; } $Convert_RelatedModuleFields[$module . "|" . $b] = implode(",", $Options); $OptionsRelMod = array(); if (($block_label == "LBL_DETAILS_BLOCK" || $block_label == "LBL_ITEM_DETAILS") && ($module == "Quotes" || $module == "Invoice" || $module == "SalesOrder" || $module == "PurchaseOrder" || $module == "Issuecards" || $module == "Receiptcards" || $module == "Creditnote" || $module == "StornoInvoice")) { foreach ($More_Fields as $variable => $variable_name) { $variable_key = strtoupper($variable); $Options[] = '"' . $variable_name . '","' . $variable_key . '"'; $SelectModuleFields[$module][$optgroup_value][$variable_key] = $variable_name; if ($variable_key != "VATBLOCK") { $OptionsRelMod[] = '"' . $variable_name . '","' . strtoupper($module) . '_' . $variable_key . '"'; } } } //this concatenation is because of need to have extra Details block in Inventory modules which are as related modules $Convert_RelatedModuleFields[$module . "|" . $b] .= implode(',', $OptionsRelMod); $Convert_ModuleFields[$module . "|" . $b] = implode(",", $Options); } if ($module == 'Calendar') { $Convert_ModuleFields['Calendar|1'] = str_replace(',"Record ID","CALENDAR_CRMID",', "", $Convert_ModuleFields['Calendar|1']); $Convert_ModuleFields['Calendar|1'] .= ',"Record ID","CALENDAR_CRMID"'; unset($SelectModuleFields['Calendar'][vtranslate('Calendar')]["CALENDAR_CRMID"]); $SelectModuleFields['Calendar'][vtranslate('Calendar')]["CALENDAR_CRMID"] = "Record ID"; } $Convert_ModuleBlocks[$module] = implode(",", $Optgroupts); } foreach ($Convert_ModuleFields as $cmf_key => $cmf_value) { if (substr($cmf_key, 0, 9) == 'Calendar|' && $cmf_key != 'Calendar|1') { foreach ($Unset_Module_Fields as $to_unset) { $cmf_value = str_replace($to_unset, '', $cmf_value); $cmf_value = str_replace(",,", ',', $cmf_value); $Convert_ModuleFields[$cmf_key] = trim($cmf_value, ','); } } } $viewer->assign("MODULE_BLOCKS", $Convert_ModuleBlocks); $viewer->assign("RELATED_MODULE_FIELDS", $Convert_RelatedModuleFields); $viewer->assign("MODULE_FIELDS", $Convert_ModuleFields); //Product block fields start // Product bloc templates $sql = "SELECT * FROM vtiger_pdfmaker_productbloc_tpl"; $result = $adb->query($sql); $Productbloc_tpl[""] = vtranslate("LBL_PLS_SELECT", 'PDFMaker'); while ($row = $adb->fetchByAssoc($result)) { $Productbloc_tpl[$row["body"]] = $row["name"]; } $viewer->assign("PRODUCT_BLOC_TPL", $Productbloc_tpl); $ProductBlockFields = $PDFMaker->GetProductBlockFields(); foreach ($ProductBlockFields as $viewer_key => $pbFields) { $viewer->assign($viewer_key, $pbFields); } //Product block fields end $viewer->assign("SELECT_MODULE_FIELD", $SelectModuleFields[$select_module]); $smf_filename = $SelectModuleFields[$select_module]; unset($smf_filename["Details"]); $viewer->assign("SELECT_MODULE_FIELD_FILENAME", $smf_filename); $version_type = ucfirst($PDFMaker->GetVersionType()); $viewer->assign("VERSION", $version_type . " " . PDFMaker_Version_Helper::$version); $category = getParentTab(); $viewer->assign("CATEGORY", $category); $viewer->view('Edit.tpl', 'PDFMaker'); }
public function process(Vtiger_Request $request) { PDFMaker_Debugger_Model::GetInstance()->Init(); $PDFMaker = new PDFMaker_PDFMaker_Model(); if ($PDFMaker->CheckPermissions("EDIT") == false) { $PDFMaker->DieDuePermission(); } $viewer = $this->getViewer($request); $emode = ""; $template = array(); $tplid = $request->get('tplid'); $mode = $request->get('mode'); if (isset($tplid) && $tplid != "") { $adb = PearDatabase::getInstance(); $sql = "SELECT * FROM vtiger_pdfmaker_productbloc_tpl WHERE id=?"; $result = $adb->pquery($sql, array($tplid)); $row = $adb->fetchByAssoc($result); if ($mode != "duplicate") { $template["id"] = $row["id"]; } $template["name"] = $row["name"]; $template["body"] = $row["body"]; $emode = "edit"; } //if no ID is specified then it is create view $viewer->assign("EDIT_TEMPLATE", $template); //PROPERTIES tab $ProductBlockFields = $PDFMaker->GetProductBlockFields(); foreach ($ProductBlockFields as $smarty_key => $pbFields) { $viewer->assign($smarty_key, $pbFields); } //LABELS //global lang $cu_model = Users_Record_Model::getCurrentUserModel(); $this->cu_language = $cu_model->get('language'); $app_strings_big = Vtiger_Language_Handler::getModuleStringsFromFile($this->cu_language); $app_strings = $app_strings_big['languageStrings']; $global_lang_labels = array_flip($app_strings); $global_lang_labels = array_flip($global_lang_labels); asort($global_lang_labels); $viewer->assign("GLOBAL_LANG_LABELS", $global_lang_labels); //custom lang list($custom_labels, $languages) = $PDFMaker->GetCustomLabels(); $currLangId = ""; foreach ($languages as $langId => $langVal) { if ($langVal["prefix"] == $current_language) { $currLangId = $langId; break; } } $vcustom_labels = array(); if (count($custom_labels) > 0) { foreach ($custom_labels as $oLbl) { $currLangVal = $oLbl->GetLangValue($currLangId); if ($currLangVal == "") { $currLangVal = $oLbl->GetFirstNonEmptyValue(); } $vcustom_labels[$oLbl->GetKey()] = $currLangVal; } asort($vcustom_labels); } else { $vcustom_labels = $mod_strings["LBL_SELECT_MODULE_FIELD"]; } $viewer->assign("CUSTOM_LANG_LABELS", $vcustom_labels); //VIEW HELPERS if ($PDFMaker->GetVersionType() == "professional") { $type = "professional"; } else { $type = "basic"; } $viewer->assign("TYPE", $type); $viewer->assign("EMODE", $emode); $viewer->assign("MODE", $mode); $viewer->view('EditProductBlock.tpl', 'PDFMaker'); }
public function process(Vtiger_Request $request) { //Debugger::GetInstance()->Init(); $AvailableRelModules = array("Accounts", "Contacts", "Leads", "Vendors"); $current_user = $cu_model = Users_Record_Model::getCurrentUserModel(); $currentLanguage = Vtiger_Language_Handler::getLanguage(); $adb = PearDatabase::getInstance(); $viewer = $this->getViewer($request); $PDFMaker = new PDFMaker_PDFMaker_Model(); if ($PDFMaker->CheckPermissions("DETAIL") == false) { $output = '<table border=0 cellspacing=0 cellpadding=5 width=100% align=center bgcolor=white> <tr> <td class="dvtCellInfo" style="width:100%;border-top:1px solid #DEDEDE;text-align:center;"> <strong>' . vtranslate("LBL_PERMISSION") . '</strong> </td> </tr> </table>'; die($output); } $record = $request->get('record'); $module = getSalesEntityType($record); $viewer->assign('MODULE', $module); $viewer->assign('ID', $record); $relfocus = CRMEntity::getInstance($module); $relfocus->id = $record; $relfocus->retrieve_entity_info($relfocus->id, $module); $relmodule = ""; $relmodule_selid = ""; if (in_array($module, $AvailableRelModules)) { $relmodule = $module; $relmodule_selid = $relfocus->id; } else { if (isset($relfocus->column_fields['account_id']) && $relfocus->column_fields['account_id'] != "" && $relfocus->column_fields['account_id'] != "0") { $relmodule = 'Accounts'; $relmodule_selid = $relfocus->column_fields['account_id']; } if ($relmodule == "" && isset($relfocus->column_fields['related_to']) && $relfocus->column_fields['related_to'] != "" && $relfocus->column_fields['related_to'] != "0") { $relmodule_selid = $relfocus->column_fields['related_to']; $relmodule = getSalesEntityType($relmodule_selid); if (!in_array($relmodule, $AvailableRelModules)) { $relmodule = $relmodule_selid = ""; } } if ($relmodule == "" && isset($relfocus->column_fields['parent_id']) && $relfocus->column_fields['parent_id'] != "" && $relfocus->column_fields['parent_id'] != "0") { $relmodule_selid = $relfocus->column_fields['parent_id']; $relmodule = getSalesEntityType($relmodule_selid); if (!in_array($relmodule, $AvailableRelModules)) { $relmodule = $relmodule_selid = ""; } } if ($relmodule == "" && isset($relfocus->column_fields['contact_id']) && $relfocus->column_fields['contact_id'] != "" && $relfocus->column_fields['contact_id'] != "0") { $relmodule = 'Contacts'; $relmodule_selid = $relfocus->column_fields['contact_id']; } } $viewer->assign('RELMODULE', $relmodule); $viewer->assign('RELMODULE_SELID', $relmodule_selid); require 'user_privileges/user_privileges_' . $current_user->id . '.php'; if (is_dir("modules/PDFMaker/resources/mpdf") && $PDFMaker->CheckPermissions("DETAIL")) { $viewer->assign("ENABLE_PDFMAKER", 'true'); } else { $viewer->assign("ENABLE_PDFMAKER", "false"); } if (is_dir("modules/EMAILMaker") && vtlib_isModuleActive('EMAILMaker')) { $module_tabid = getTabId($module); $res = $adb->pquery("SELECT * FROM vtiger_links WHERE tabid = ? AND linktype = ? AND linkurl LIKE ?", array($module_tabid, 'DETAILVIEWSIDEBARWIDGET', 'module=EMAILMaker&view=GetEMAILActions&record=%')); if ($adb->num_rows($res) > 0) { $viewer->assign("ENABLE_EMAILMAKER", 'true'); } } $viewer->assign('PDFMAKER_MOD', return_module_language($currentLanguage, "PDFMaker")); if (!isset($_SESSION["template_languages"]) || $_SESSION["template_languages"] == "") { $temp_res = $adb->pquery("SELECT label, prefix FROM vtiger_language WHERE active = ?", array('1')); while ($temp_row = $adb->fetchByAssoc($temp_res)) { $template_languages[$temp_row["prefix"]] = $temp_row["label"]; } $_SESSION["template_languages"] = $template_languages; } $viewer->assign('TEMPLATE_LANGUAGES', $_SESSION["template_languages"]); $viewer->assign('CURRENT_LANGUAGE', $currentLanguage); $viewer->assign('IS_ADMIN', is_admin($current_user)); $templates = $PDFMaker->GetAvailableTemplates($module); if (count($templates) > 0) { $no_templates_exist = 0; } else { $no_templates_exist = 1; } $viewer->assign('CRM_TEMPLATES', $templates); $viewer->assign('CRM_TEMPLATES_EXIST', $no_templates_exist); //Action permission handling //edit and export $editAndExportAction = "1"; if (isPermitted($module, "EditView", $record) == "no") { $editAndExportAction = "0"; } //save as doc $saveDocAction = "1"; if (isPermitted("Documents", "EditView") == "no") { $saveDocAction = "0"; } //send email with pdf $sendEmailPDF = "1"; if (isPermitted("Emails", "") == "no" && isPermitted("MailManager", "") == "no") { $sendEmailPDF = "0"; } if (is_dir("modules/EMAILMaker") && vtlib_isModuleActive('EMAILMaker')) { if (isPermitted("EMAILMaker", "") == "no" && ($sendEmailPDF = "0")) { $sendEmailPDF = "0"; } else { $sendEmailPDF = "1"; } } $viewer->assign("EDIT_AND_EXPORT_ACTION", $editAndExportAction); $viewer->assign("SAVE_AS_DOC_ACTION", $saveDocAction); $viewer->assign("SEND_EMAIL_PDF_ACTION", $sendEmailPDF); $viewer->view("GetPDFActions.tpl", 'PDFMaker'); }
public function getList(Vtiger_Request $request) { PDFMaker_Debugger_Model::GetInstance()->Init(); $PDFMaker = new PDFMaker_PDFMaker_Model(); if ($PDFMaker->CheckPermissions("DETAIL") == false) $PDFMaker->DieDuePermission(); $viewer = $this->getViewer($request); $orderby = "templateid"; $dir = "asc"; if (isset($_REQUEST["dir"]) && $_REQUEST["dir"] == "desc") $dir = "desc"; if (isset($_REQUEST["orderby"])) { switch ($_REQUEST["orderby"]) { case "name": $orderby = "filename"; break; case "module": $orderby = "module"; break; case "description": $orderby = "description"; break; case "order": $orderby = "order"; break; default: $orderby = $_REQUEST["orderby"]; break; } } $version_type = $PDFMaker->GetVersionType(); $license_key = $PDFMaker->GetLicenseKey(); $viewer->assign("VERSION_TYPE", $version_type); $viewer->assign("VERSION", ucfirst($version_type) . " " . PDFMaker_Version_Helper::$version); if ($PDFMaker->CheckPermissions("EDIT")) { $viewer->assign("EDIT", "permitted"); } $notif = $PDFMaker->GetReleasesNotif(); $viewer->assign("RELEASE_NOTIF", $notif); $php_version = phpversion(); $notif = false; $max_in_vars = ini_get("max_input_vars"); if ($max_in_vars <= 1000 && $php_version >= "5.3.9") $notif = true; $test = ini_set("memory_limit", "256M"); $memory_limit = ini_get("memory_limit"); if (substr($memory_limit, 0, -1) <= 128) $notif = true; $max_exec_time = ini_get("max_execution_time"); if ($max_exec_time <= 60) $notif = true; if (extension_loaded('suhosin')) { $request_max_vars = ini_get("suhosin.request.max_vars"); $post_max_vars = ini_get("suhosin.post.max_vars"); if ($request_max_vars <= 1000) $notif = true; if ($post_max_vars <= 1000) $notif = true; } $viewer->assign("MOD", $mod_strings); $viewer->assign("APP", $app_strings); $viewer->assign("THEME", $theme); $viewer->assign("PARENTTAB", getParentTab()); $viewer->assign("IMAGE_PATH", $image_path); $return_data = $PDFMaker->GetListviewData($orderby, $dir); $viewer->assign("PDFTEMPLATES", $return_data); $category = getParentTab(); $viewer->assign("CATEGORY", $category); if (is_admin($current_user)) { $viewer->assign('IS_ADMIN', '1'); } $linkModels = $PDFMaker->getListViewLinks($linkParams); $viewer->assign('LISTVIEW_LINKS', $linkModels); $tpl = "ListPDFTemplates"; if ($request->get('ajax') == "true") $tpl .= "Contents"; $viewer->view($tpl.".tpl", 'PDFMaker'); }
public function process(Vtiger_Request $request) { $moduleName = $request->getModule(); $moduleModel = Vtiger_Module_Model::getInstance($moduleName); $for_module = $request->get('return_module'); $recordIds = $this->getRecordsListFromRequest($request); $adb = PearDatabase::getInstance(); PDFMaker_Debugger_Model::GetInstance()->Init(); $PDFMaker = new PDFMaker_PDFMaker_Model(); if ($PDFMaker->CheckPermissions("DETAIL") == false) { $close_img = vimage_path('close.gif'); $output = ' <table border=0 cellspacing=0 cellpadding=5 width=100% class=layerHeadingULine> <tr> <td width="90%" align="left" class="genHeaderSmall" id="PDFListViewDivHandle" style="cursor:move;">' . vtranslate("LBL_PDF_ACTIONS", "PDFMaker") . ' </td> <td width="10%" align="right"> <a href="javascript:fninvsh(\'PDFListViewDiv\');"><img title="' . vtranslate("LBL_CLOSE") . '" alt="' . vtranslate("LBL_CLOSE") . '" src="' . $close_img . '" border="0" align="absmiddle" /></a> </td> </tr> </table> <table border=0 cellspacing=0 cellpadding=5 width=100% align=center> <tr><td class="small"> <table border=0 cellspacing=0 cellpadding=5 width=100% align=center bgcolor=white> <tr> <td class="dvtCellInfo" style="width:100%;border-top:1px solid #DEDEDE;text-align:center;"> <strong>' . vtranslate("LBL_PERMISSION_DENIED") . '</strong> </td> </tr> <tr> <td class="dvtCellInfo" style="width:100%;" align="center"> <input type="button" class="crmbutton small cancel" value="' . vtranslate("LBL_CANCEL") . '" onclick="fninvsh(\'PDFListViewDiv\');" /> </td> </tr> </table> </td></tr> </table> '; die($output); } $_REQUEST['idslist'] = implode(";", $recordIds); $request->set('idlist', $_REQUEST['idslist']); //$language = $_SESSION['authenticated_user_language']; $current_language = Vtiger_Language_Handler::getLanguage(); $templates = $PDFMaker->GetAvailableTemplates($for_module, true); $options = ""; foreach ($templates as $templateid => $valArr) { if ($valArr["is_default"] == "2" || $valArr["is_default"] == "3") { $selected = ' selected="selected" '; } else { $selected = ""; } $options .= '<option value="' . $templateid . '"' . $selected . '>' . $valArr['templatename'] . '</option>'; } $template_output = ""; $language_output = ""; $generate_pdf = ""; if ($options != "") { $template_output = ' <tr> <td class="dvtCellInfo" style="width:100%;border-top:1px solid #DEDEDE;"> <select name="use_common_template" id="use_common_template" class="detailedViewTextBox" multiple style="width:90%;" size="5"> ' . $options . ' </select> </td> </tr> '; $templates_select = '<select name="use_common_template" id="use_common_template" style="display: none;" id="fieldList" class="select2 row-fluid" multiple="true" size="5" data-validation-engine="validate[required]"> ' . $options . ' </select>'; $temp_res = $adb->pquery("SELECT label, prefix FROM vtiger_language WHERE active=?", array("1")); while ($temp_row = $adb->fetchByAssoc($temp_res)) { $template_languages[$temp_row["prefix"]] = $temp_row["label"]; } //LANGUAGES BLOCK if (count($template_languages) > 1) { $options = ""; foreach ($template_languages as $prefix => $label) { if ($current_language != $prefix) { $options .= '<option value="' . $prefix . '">' . $label . '</option>'; } else { $options .= '<option value="' . $prefix . '" selected="selected">' . $label . '</option>'; } } $language_output = ' <tr> <td class="dvtCellInfo" style="width:100%;"> <select name="template_language" id="template_language" class="detailedViewTextBox" style="width:90%;" size="1"> ' . $options . ' </select> </td> </tr>'; $languages_select = '<select name="template_language" id="template_language" class="select2 row-fluid" style="display: none;"> ' . $options . ' </select>'; } else { foreach ($template_languages as $prefix => $label) { $languages_select .= '<input type="hidden" name="template_language" id="template_language" value="' . $prefix . '"/>'; } } } else { $template_output = '<tr> <td class="dvtCellInfo" style="width:100%;border-top:1px solid #DEDEDE;"> ' . vtranslate("CRM_TEMPLATES_DONT_EXIST", "PDFMaker"); // if(isPermitted("PDFMaker","EditView") == 'yes') if ($PDFMaker->CheckPermissions("EDIT")) { $template_output .= '<br />' . vtranslate("CRM_TEMPLATES_ADMIN", "PDFMaker") . ' <a href="index.php?module=PDFMaker&action=EditPDFTemplate&return_module=' . $request->get("return_module") . '&parenttab=Tools" class="webMnu">' . vtranslate("TEMPLATE_CREATE_HERE", "PDFMaker") . '</a>'; } $template_output .= '</td></tr>'; } $viewer = $this->getViewer($request); //$viewer->assign('MODULE', $relmodule); //$viewer->assign('ID', $record); $viewer->assign('templates_select', $templates_select); $viewer->assign('languages_select', $languages_select); $viewer->assign('idslist', $_REQUEST['idslist']); $viewer->assign('relmodule', $request->get('return_module')); $viewer->view("ListViewSelect.tpl", 'PDFMaker'); }
public function getList(Vtiger_Request $request) { PDFMaker_Debugger_Model::GetInstance()->Init(); $PDFMaker = new PDFMaker_PDFMaker_Model(); if ($PDFMaker->CheckPermissions("DETAIL") == false) { $PDFMaker->DieDuePermission(); } $viewer = $this->getViewer($request); $orderby = "templateid"; $dir = "asc"; if (isset($_REQUEST["dir"]) && $_REQUEST["dir"] == "desc") { $dir = "desc"; } if (isset($_REQUEST["orderby"])) { switch ($_REQUEST["orderby"]) { case "name": $orderby = "filename"; break; case "module": $orderby = "module"; break; case "description": $orderby = "description"; break; case "order": $orderby = "order"; break; default: $orderby = $_REQUEST["orderby"]; break; } } $version_type = $PDFMaker->GetVersionType(); $license_key = $PDFMaker->GetLicenseKey(); $viewer->assign("VERSION_TYPE", $version_type); $viewer->assign("VERSION", ucfirst($version_type) . " " . PDFMaker_Version_Helper::$version); $viewer->assign("LICENSE_KEY", $license_key); // $to_update = "false"; // $smarty->assign("TO_UPDATE",$to_update); if ($PDFMaker->CheckPermissions("EDIT")) { $viewer->assign("EXPORT", "yes"); } if ($PDFMaker->CheckPermissions("EDIT") && $PDFMaker->GetVersionType() != "deactivate") { $viewer->assign("EDIT", "permitted"); $viewer->assign("IMPORT", "yes"); } if ($PDFMaker->CheckPermissions("DELETE") && $PDFMaker->GetVersionType() != "deactivate") { $viewer->assign("DELETE", "permitted"); } $notif = $PDFMaker->GetReleasesNotif(); $viewer->assign("RELEASE_NOTIF", $notif); $php_version = phpversion(); $notif = false; $max_in_vars = ini_get("max_input_vars"); if ($max_in_vars <= 1000 && $php_version >= "5.3.9") { $notif = true; } $test = ini_set("memory_limit", "256M"); $memory_limit = ini_get("memory_limit"); if (substr($memory_limit, 0, -1) <= 128) { $notif = true; } $max_exec_time = ini_get("max_execution_time"); if ($max_exec_time <= 60) { $notif = true; } if (extension_loaded('suhosin')) { $request_max_vars = ini_get("suhosin.request.max_vars"); $post_max_vars = ini_get("suhosin.post.max_vars"); if ($request_max_vars <= 1000) { $notif = true; } if ($post_max_vars <= 1000) { $notif = true; } } if ($notif === true) { //$notif = '<a href="index.php?module=PDFMaker&action=Debugging&parenttab=Settings" title="' . vtranslate("LBL_GOTO_DEBUG","PDFMaker") . '" style="color:red;">' . vtranslate("LBL_DBG_NOTIF","PDFMaker") . '</a>'; //$viewer->assign("DEBUG_NOTIF", $notif); } $viewer->assign("MOD", $mod_strings); $viewer->assign("APP", $app_strings); $viewer->assign("THEME", $theme); $viewer->assign("PARENTTAB", getParentTab()); $viewer->assign("IMAGE_PATH", $image_path); $viewer->assign("ORDERBY", $orderby); $viewer->assign("DIR", $dir); $return_data = $PDFMaker->GetListviewData($orderby, $dir); $viewer->assign("PDFTEMPLATES", $return_data); $category = getParentTab(); $viewer->assign("CATEGORY", $category); if (is_admin($current_user)) { $viewer->assign('IS_ADMIN', '1'); } //$tool_buttons = Button_Check($currentModule); //$viewer->assign('CHECK', $tool_buttons); $linkParams = array('MODULE' => $moduleName, 'ACTION' => $request->get('view')); $linkModels = $PDFMaker->getListViewLinks($linkParams); $viewer->assign('LISTVIEW_MASSACTIONS', $linkModels['LISTVIEWMASSACTION']); $viewer->assign('LISTVIEW_LINKS', $linkModels); $tpl = "ListPDFTemplates"; if ($request->get('ajax') == "true") { $tpl .= "Contents"; } $viewer->view($tpl . ".tpl", 'PDFMaker'); }