$oPagerLink->setCustom("elemperpage", $_REQUEST["elemperpage"]);
$oPagerLink->setCustom("filter", $_REQUEST["filter"]);
$oPagerLink->setCustom("restrictgroup", $_REQUEST["restrictgroup"]);
$oPagerLink->setCustom("sortby", $_REQUEST["sortby"]);
$oPagerLink->setCustom("sortorder", $_REQUEST["sortorder"]);
$oPagerLink->setCustom("searchin", $_REQUEST["searchin"]);
$oPagerLink->setCustom("frame", $frame);
$oPagerLink->setCustom("area", $area);
$oPagerLink->enableAutomaticParameterAppend();
$oPagerLink->setCustom("contenido", $sess->id);
// Note, that after the "page" parameter no "pagerlink" parameter is specified -
// it is not used, as the JS below only uses the INNER html and the "pagerlink" parameter is
// set by ...left_top.html for the foldingrow itself
$oPager = new cObjectPager($sPagerId, $iItemCount, $_REQUEST["elemperpage"], $_REQUEST["page"], $oPagerLink, "page");
// Add slashes, to insert in javascript
$sPagerContent = $oPager->render(1);
$sPagerContent = str_replace('\\', '\\\\', $sPagerContent);
$sPagerContent = str_replace('\'', '\\\'', $sPagerContent);
// Send new object pager to left_top
$oPage->addScript('setpager', '<script type="text/javascript" src="scripts/setPager.js"></script>');
$sRefreshPager = '
	<script type="text/javascript">
		var sNavigation = \'' . $sPagerContent . '\';

		// Activate time to refresh pager folding row in left top
		var oTimer = window.setInterval("fncSetPager(\'' . $sPagerId . '\',\'' . $_REQUEST["page"] . '\')", 200);
	</script>';
$oPage->addScript('refreshpager', $sRefreshPager);
//$oPage->setContent(array('<table border="0" cellspacing="0" cellpadding="0" width="100%">', $oListOptionRow, '</table>', $oMenu->render(false)));
$oPage->setContent($oMenu->render(false));
$oPage->render();
    $oAssocGroups = new RecipientGroupMemberCollection();
    $oAssocGroups->link("RecipientGroupCollection");
    $oAssocGroups->setWhere("recipientgroupmembercollection.idnewsrcp", $recipient->get("idnewsrcp"));
    $oAssocGroups->setOrder("recipientgroupcollection.groupname");
    $oAssocGroups->query();
    if ($oAssocGroups->count() == 0) {
        $oGroupList->setCell(0, 1, i18n("Recipient is not member of any group", $plugin_name));
    } else {
        // Headline
        $oGroupList->setCell(0, 1, "<strong>" . i18n("Groupname", $plugin_name) . "</strong>");
        $oImgDel = new cHTMLImage("images/delete.gif");
        $oGroupList->setCell(0, 2, $oImgDel->render());
        $oGroupList->setCellAlignment(0, 2, "right");
        // Data
        while ($oAssocGroup = $oAssocGroups->next()) {
            $oGroup = $oAssocGroups->fetchObject("RecipientGroupCollection");
            $oCkbRemove = new cHTMLCheckbox("ckbRemove[]", $oAssocGroup->get("idnewsgroupmember"));
            echo $oGroup->get("idnewsgroupmember");
            $oGroupList->setCell($oAssocGroup->get("idnewsgroupmember"), 1, $oGroup->get("groupname"));
            $oGroupList->setCell($oAssocGroup->get("idnewsgroupmember"), 2, $oCkbRemove->toHTML(false));
            $oGroupList->setCellAlignment($oAssocGroup->get("idnewsgroupmember"), 2, "right");
        }
    }
    $oForm->add(i18n("Associated Groups", $plugin_name), $oGroupList->render());
    $oForm->add(i18n("Author", $plugin_name), $classuser->getUserName($recipient->get("author")) . " (" . $recipient->get("created") . ")");
    $oForm->add(i18n("Last modified by", $plugin_name), $classuser->getUserName($recipient->get("modifiedby")) . " (" . $recipient->get("lastmodified") . ")");
    $oPage->setContent($sNotis . $oForm->render(true));
} else {
    $oPage->setContent($sNotis . "");
}
$oPage->render();
    $result = $notification->returnNotification("warning", i18n('There is no Content Allocation tree.', 'content_allocation'));
} else {
    if (!is_object($tpl)) {
        $tpl = new Template();
    }
    $hiddenfields = '<input type="hidden" name="action" value="storeallocation">
		<input type="hidden" name="idart" value="' . $idart . '">
		<input type="hidden" name="contenido" value="' . $sess->id . '">
		<input type="hidden" name="area" value="' . $area . '">
		<input type="hidden" name="frame" value="' . $frame . '">
		<input type="hidden" name="idcat" value="' . $idcat . '">';
    $tpl->set('s', 'HIDDENFIELDS', $hiddenfields);
    if (sizeof($loadedAllocations) > 0) {
        $tpl->set('s', 'ARRAY_CHECKED_BOXES', 'var checkedBoxes = [' . implode(',', $loadedAllocations) . '];');
    } else {
        $tpl->set('s', 'ARRAY_CHECKED_BOXES', 'var checkedBoxes = [];');
    }
    $oDiv = new cHTMLDiv();
    $oDiv->updateAttributes(array('style' => 'text-align: right; padding: 5px; width: 730px; border: 1px #B3B3B3 solid; background-color: #FFFFFF;'));
    $oDiv->setContent('<input type="image" src="images/but_ok.gif" />');
    $tpl->set('s', 'DIV', '<br>' . $oDiv->render());
    $tpl->set('s', 'TREE', $result);
    $tpl->set('s', 'REMOVE_ALL', i18n("Remove all", 'content_allocation'));
    $tpl->set('s', 'REMOVE', i18n("Remove", 'content_allocation'));
    $result = $tpl->generate($cfg['pica']['treetemplate_complexlist'], true);
    $script = '<link rel="stylesheet" type="text/css" href="' . $cfg['pica']['style_complexlist'] . '"/>
	<script language="javascript" src="' . $cfg['pica']['script_complexlist'] . '"></script>';
    $oPage->addScript('style', $script);
}
$oPage->setContent($sLocationString . $result . markSubMenuItem(5, true));
$oPage->render();
            $oForm->addHeader(i18n("Report:", $plugin_name));
            $oForm->add("", "");
            $oForm->add("", sprintf(i18n("Sending newsletter ... (chunk %s of %s, recipients: %s, sent: %s)", $plugin_name), $iChunk, $iChunks, $oJob->get("rcpcount"), $oJob->get("sendcount")));
            $oPage->addScript("Refresh", '<meta http-equiv="refresh" content="' . $oJob->get("dispatch_delay") . '; URL=' . $sPathNext . '">');
            $oForm->unsetActionButton("submit");
            $oForm->setActionButton("cancel", $cfg['path']['contenido_fullhtml'] . "images/but_cancel.gif", i18n("Stop sending", $plugin_name), "c");
        }
    } else {
        // All newsletters should have been sent
        $oForm = new UI_Table_Form("properties");
        $oForm->addHeader(i18n("Report:", $plugin_name));
        $oForm->add("", "");
        $oForm->add("", sprintf(i18n("The newsletter has been sent to %s recipients", $plugin_name), $oJob->get("sendcount")));
        $oPage->setReload();
    }
    $oPage->setContent($notis . $oForm->render(true));
} else {
    if ($action == "news_job_delete" && $perm->have_perm_area_action($area, $action) && is_numeric($_REQUEST["idnewsjob"])) {
        $oJobs = new cNewsletterJobCollection();
        $oJobs->delete($_REQUEST["idnewsjob"]);
        $oPage->setSubnav("blank", "news_jobs");
        $oPage->setReload();
        $oPage->setContent($notis);
    } else {
        if ($action == "news_job_details" || $action == "news_job_detail_delete") {
            // Show job details (recipients)
            $oLogs = new cNewsletterLogCollection();
            // Remove recipient from a job
            if ($action == "news_job_detail_delete" && is_numeric($_REQUEST["idnewslog"]) && $perm->have_perm_area_action($area, "news_job_detail_delete")) {
                $oLogs->delete($_REQUEST["idnewslog"]);
            }
			controller = document.getElementById("itemname");
			controller.focus();
			function fieldCheck() {
				if (controller.value == "") {
					alert("' . i18n("Please enter a category name.", 'content_allocation') . '");
					controller.focus();
					return false;
				}
                return true;
			}
		</script>';
    $oDiv->setContent($form);
    $sTemp = $oDiv->render();
} else {
    $newTree = '<a href="main.php?action=' . $action . '&step=createRoot&frame=' . $frame . '&area=' . $area . '&contenido=' . $sess->id . '"><img  src="images/folder_new.gif" border="0" style="vertical-align: middle; margin-right: 5px;">' . i18n("Create new tree", 'content_allocation') . '</a><div style="height:10px"></div>';
}
$result = $oTree->renderTree(true);
if ($result === false) {
    $result = '&nbsp;';
}
$js = '
<script language="javascript">
/* Function for deleting categories*/
function deleteCategory(idpica_alloc) {
    var url = "main.php?area=' . $area . '&action=' . $action . '&step=deleteItem&idpica_alloc=" + idpica_alloc + "&frame=' . $frame . '&contenido=' . $sess->id . '";
    window.location.href = url;
}
</script>';
$oPage->addScript('deleteCategory', $js);
$oPage->setContent($pNotify . $newTree . $sTemp . '<br/>' . $result);
$oPage->render();
$oForm->setVar("frame", $frame);
$oForm->setVar("area", $area);
$oForm->setVar("action", "recipients_import_exec");
$oForm->addHeader(i18n("Import recipients", $plugin_name));
$oSelDelimiter = new cHTMLSelectElement("selDelimiter");
$aItems = array();
$aItems[] = array("semicolon", i18n("Semicolon", $plugin_name));
$aItems[] = array("tab", i18n("Tab", $plugin_name));
$oSelDelimiter->autoFill($aItems);
$oSelDelimiter->setDefault($_REQUEST["selDelimiter"]);
$oForm->add(i18n("Delimiter", $plugin_name), $oSelDelimiter->render());
$oAreaData = new cHTMLTextarea("txtData", $_REQUEST["txtData"], 80, 20);
$sInfo = '<a href="javascript:fncShowHide(\'idInfoText\');"><strong>' . i18n("Import information", $plugin_name) . '</strong></a>' . '<div id="idInfoText" style="display: none">' . '<br /><br /><strong>' . i18n("Specify colum types:", $plugin_name) . '</strong>' . i18n("<br />The first line must contain the column names; this specifies the column order.<br />&lt;column name&gt;[delimiter]&lt;column name&gt;...", $plugin_name) . '<br /><br /><strong>' . i18n("Data structure:", $plugin_name) . '</strong><br />' . i18n("The recipients have to be entered using the following format:<br />&lt;data&gt;[Delimiter]&lt;data&gt;... - each recipient in a new line.", $plugin_name) . '<br /><br /><strong>' . i18n("Example:", $plugin_name) . '</strong>' . i18n("<br />name;mail;confirmed<br />Smith;jon.smith@example.org;1", $plugin_name) . '<br /><br /><strong>' . i18n("The following column names will be recognized:", $plugin_name) . '</strong><br />' . implode("<br />\n", $aFields) . '</div>';
$oForm->add(i18n("Recipients", $plugin_name), $oAreaData->render() . "<br />" . $sInfo);
unset($sInfo);
$sExecScript = '
<script type="text/javascript">
    /* Enabled/Disable group box */
    function fncShowHide(strItemID) {
        objItem = document.getElementById(strItemID);

        if (objItem.style.display == "none") {
           objItem.style.display = "inline";
        } else {
           objItem.style.display = "none";
        }
    }
	</script>';
$oPage->addScript('execscript', $sExecScript);
$oPage->setContent($sMessage . $oForm->render(true));
$oPage->render();