* SPDX-License-Identifier: AGPL-3.0-only ************************************/ require_once('include/utils/utils.php'); global $app_strings,$current_user,$theme,$adb,$current_language,$table_prefix; $image_path = 'themes/'.$theme.'/images/'; $language = VteSession::get('authenticated_user_language'); $pdf_strings = return_module_language($language, "PDFMaker"); $smarty=new VteSmarty(); $smarty->assign("MOD",$mod_strings); $smarty->assign("APP",$app_strings); $smarty->assign("PDF",$pdf_strings); $smarty->assign("THEME", $theme); $smarty->assign("IMAGE_PATH",$image_path); //crmv@26396 $status_sql="SELECT ".$table_prefix."_pdfmaker.templateid FROM ".$table_prefix."_pdfmaker_userstatus INNER JOIN ".$table_prefix."_pdfmaker ON ".$table_prefix."_pdfmaker.templateid = ".$table_prefix."_pdfmaker_userstatus.templateid WHERE userid=? AND is_active=0"; $status_res=$adb->pquery($status_sql,array($current_user->id)); while($status_row = $adb->fetchByAssoc($status_res)) { $inactive_arr[$status_row["templateid"]] = $status_row["templateid"]; } $default_sql="SELECT ".$table_prefix."_pdfmaker.templateid FROM ".$table_prefix."_pdfmaker_userstatus INNER JOIN ".$table_prefix."_pdfmaker ON ".$table_prefix."_pdfmaker.templateid = ".$table_prefix."_pdfmaker_userstatus.templateid WHERE userid=? AND is_default=1"; //crmv@26396e $default_res=$adb->pquery($default_sql,array($current_user->id)); while($default_row = $adb->fetchByAssoc($default_res)) { $default_template = $default_row["templateid"]; } $temp_sql = "SELECT templateid, filename AS templatename FROM ".$table_prefix."_pdfmaker WHERE module = '".$_REQUEST['return_module']."'"; if(isset($inactive_arr)){ $temp_sql.=" AND templateid NOT IN (".implode($inactive_arr,",").")"; } $temp_result = $adb->query($temp_sql); //TEMPLATES BLOCK $options=""; while($temp_row = $adb->fetchByAssoc($temp_result)){ if(isset($default_template) AND $default_template == $temp_row['templateid']){ $selected=' selected="selected" '; } else { $selected=""; } $options.=''; } $language_output=""; $generate_pdf=""; if($adb->num_rows($temp_result)>0) { $template_output=' '; $temp_res = $adb->query("SELECT label, prefix FROM ".$table_prefix."_language WHERE active=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.=''; else $options.=''; } $language_output=' '; } else { foreach($template_languages as $prefix=>$label) $language_output.=''; } //GENERATE PDF ACTION BLOCK //crmv@27096 $generate_pdf=' '; //crmv@27096e } else { $template_output=' '.$pdf_strings["CRM_TEMPLATES_DONT_EXIST"]; if(isPermitted("PDFMaker","EditView") == 'yes') { $template_output.='
'.$pdf_strings["CRM_TEMPLATES_ADMIN"].' '.$pdf_strings["TEMPLATE_CREATE_HERE"].''; } $template_output.=''; //GENERATE PDF ACTION BLOCK IN CASE NO TEMPLATES EXIST $generate_pdf=' '; } // TODO: move all the html in the tpl! $smarty->assign('POPUP_HTML', $template_output.$language_output.$generate_pdf); $smarty->display('modules/PDFMaker/ListViewSelect.tpl');