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 htmlResponsiveRow(); $container->add(new htmlTitle(_('PDF editor')), 12); 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'])); $container->add($message, 12); } else { $message = new htmlStatusMessage('ERROR', _('Unable to delete PDF structure!'), $typeToDelete->getAlias() . ': ' . htmlspecialchars($_POST['profileDeleteName'])); $container->add($message, 12); } } $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) { $container->add($errMessage, 12); } } // 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) { $container->add($errMessage, 12); } } // upload logo file if (isset($_POST['uploadLogo']) && !empty($_FILES['logoUpload']) && !empty($_FILES['logoUpload']['size'])) { $file = $_FILES['logoUpload']['tmp_name']; $filename = $_FILES['logoUpload']['name']; $container->add(\LAM\PDF\uploadPDFLogo($file, $filename), 12); } // delete logo file if (isset($_POST['delLogo'])) { $toDel = $_POST['logo']; $container->add(\LAM\PDF\deletePDFLogo($toDel), 12); } // 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' => \LAM\PDF\getPDFStructures($type->getId())); $availableTypes[$title] = $type->getId(); } // check if a template should be edited foreach ($templateClasses as $templateClass) { if (isset($_POST['editTemplate_' . $templateClass['typeId']]) || isset($_POST['editTemplate_' . $templateClass['typeId'] . '_x'])) { metaRefresh('pdfpage.php?type=' . htmlspecialchars($templateClass['typeId']) . '&edit=' . htmlspecialchars($_POST['template_' . $templateClass['typeId']])); exit; } } include __DIR__ . '/../../lib/adminHeader.inc'; ?>