server()) { metaRefresh("../login.php"); exit; } // check if new template should be created if(isset($_POST['createNewTemplate'])) { metaRefresh('pdfpage.php?type=' . htmlspecialchars($_POST['typeId'])); exit(); } $typeManager = new TypeManager(); $types = $typeManager->getConfiguredTypes(); $sortedTypes = array(); foreach ($types as $type) { if ($type->isHidden() || !checkIfWriteAccessIsAllowed($type->getId())) { continue; } $sortedTypes[$type->getId()] = $type->getAlias(); } natcasesort($sortedTypes); $container = new htmlTable(); $container->addElement(new htmlTitle(_('PDF editor')), true); if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) { $typeToDelete = $typeManager->getConfiguredType($_POST['profileDeleteType']); // delete structure if (\LAM\PDF\deletePDFStructure($_POST['profileDeleteType'], $_POST['profileDeleteName'])) { $message = new htmlStatusMessage('INFO', _('Deleted PDF structure.'), $typeToDelete->getAlias() . ': ' . htmlspecialchars($_POST['profileDeleteName'])); $message->colspan = 10; $container->addElement($message, true); } else { $message = new htmlStatusMessage('ERROR', _('Unable to delete PDF structure!'), $typeToDelete->getAlias() . ': ' . htmlspecialchars($_POST['profileDeleteName'])); $message->colspan = 10; $container->addElement($message, true); } } $configProfiles = getConfigProfiles(); $serverProfiles = array(); foreach ($configProfiles as $profileName) { $serverProfiles[$profileName] = new \LAMConfig($profileName); } // import structures if (!empty($_POST['import'])) { $cfg = new LAMCfgMain(); $typeId = $_POST['typeId']; // check master password $errMessage = null; if (!$cfg->checkPassword($_POST['passwd_i_' . $_POST['typeId']])) { $errMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!')); } elseif (!empty($_POST['importProfiles_' . $typeId])) { $options = array(); foreach ($_POST['importProfiles_' . $typeId] as $importProfiles) { $parts = explode('##', $importProfiles); $options[] = array('conf' => $parts[0], 'typeId' => $parts[1], 'name' => $parts[2]); } $errMessage = importStructures($_POST['typeId'], $options, $serverProfiles, $typeManager); } if ($errMessage != null) { $errMessage->colspan = 10; $container->addElement($errMessage, true); } } // export structures if (!empty($_POST['export'])) { $cfg = new LAMCfgMain(); $typeId = $_POST['typeId']; // check master password $errMessage = null; if (!$cfg->checkPassword($_POST['passwd_e_' . $_POST['typeId']])) { $errMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!')); } elseif (!empty($_POST['exportProfiles_' . $typeId])) { $options = array(); foreach ($_POST['exportProfiles_' . $typeId] as $importProfiles) { $parts = explode('##', $importProfiles); $options[] = array('conf' => $parts[0], 'typeId' => $parts[1]); } $typeId = $_POST['typeId']; $name = $_POST['name_' . $typeId]; $errMessage = exportStructures($typeId, $name, $options, $serverProfiles, $typeManager); } if ($errMessage != null) { $errMessage->colspan = 10; $container->addElement($errMessage, true); } } // upload logo file if (isset($_POST['uploadLogo']) && !empty($_FILES['logoUpload']) && !empty($_FILES['logoUpload']['size'])) { $file = $_FILES['logoUpload']['tmp_name']; $filename = $_FILES['logoUpload']['name']; $container->addElement(\LAM\PDF\uploadPDFLogo($file, $filename), true); } // delete logo file if (isset($_POST['delLogo'])) { $toDel = $_POST['logo']; $container->addElement(\LAM\PDF\deletePDFLogo($toDel), true); } // get list of account types $availableTypes = array(); $templateClasses = array(); foreach ($sortedTypes as $typeId => $title) { $type = $typeManager->getConfiguredType($typeId); $templateClasses[] = array( 'typeId' => $type->getId(), 'scope' => $type->getScope(), 'title' => $title, 'icon' => $type->getIcon(), 'templates' => ""); $availableTypes[$title] = $type->getId(); } // get list of templates for each account type for ($i = 0; $i < sizeof($templateClasses); $i++) { $templateClasses[$i]['templates'] = \LAM\PDF\getPDFStructures($templateClasses[$i]['typeId']); } // check if a template should be edited for ($i = 0; $i < sizeof($templateClasses); $i++) { if (isset($_POST['editTemplate_' . $templateClasses[$i]['typeId']]) || isset($_POST['editTemplate_' . $templateClasses[$i]['typeId'] . '_x'])) { metaRefresh('pdfpage.php?type=' . htmlspecialchars($templateClasses[$i]['typeId']) . '&edit=' . htmlspecialchars($_POST['template_' . $templateClasses[$i]['typeId']])); exit; } } include '../main_header.php'; ?>