예제 #1
0
function getProfileRegistrantsList($showEditButtons = false)
{
    global $urlRequestRoot, $cmsFolder, $moduleFolder, $templateFolder, $sourceFolder;
    require_once "{$sourceFolder}/{$moduleFolder}/form/viewregistrants.php";
    $sortField = 'useremail';
    $sortOrder = 'asc';
    if (isset($_GET['sortfield'])) {
        $sortField = escape($_GET['sortfield']);
    }
    if (isset($_GET['sortorder']) && ($_GET['sortorder'] == 'asc' || $_GET['sortorder'] == 'desc')) {
        $sortOrder = escape($_GET['sortorder']);
    }
    $action = './+admin&subaction=' . escape($_GET['subaction']);
    $columnList['useremail'] = 'User Email';
    $columnList['username'] = '******';
    $columnList['userfullname'] = 'User Full Name';
    $columnList['registrationdate'] = 'Registration Date';
    $columnList['lastupdated'] = 'Last Updated';
    $columnList = array_merge($columnList, getColumnList(0, false, false, false, false));
    $normalImage = "<img alt=\"Sort by this field\" height=\"12\" width=\"12\" style=\"padding:0px\" src=\"{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/icons/16x16/actions/view-refresh.png\" />";
    $orderedImage = "<img alt=\"Sort by this field\" height=\"12\" width=\"12\" style=\"padding:0px\" src=\"{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/icons/16x16/actions/go-" . ($sortOrder == 'asc' ? 'up' : 'down') . ".png\" />";
    $tableCaptions = "<tr>\n<th nowrap=\"nowrap\">S. No.</th>\n";
    if ($showEditButtons) {
        $tableCaptions .= '<th nowrap="nowrap">Edit</th><th nowrap="nowrap">Delete</th>';
    }
    foreach ($columnList as $columnName => $columnTitle) {
        $tableCaptions .= "<th nowrap=\"nowrap\">{$columnTitle}<a href=\"{$action}&sortfield={$columnName}";
        if ($sortField == $columnName) {
            $tableCaptions .= '&sortorder=' . ($sortOrder == 'asc' ? 'desc' : 'asc') . '">' . $orderedImage . '</a>';
        } else {
            $tableCaptions .= '">' . $normalImage . '</a>';
        }
        $tableCaptions .= "</th>\n";
        $columnNames[] = $columnName;
    }
    $tableCaptions .= "</tr>\n";
    $userIds = getDistinctRegistrants(0, $sortField, $sortOrder);
    $userCount = count($userIds);
    $editImage = "<img style=\"padding:0px\" src=\"{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/icons/16x16/apps/accessories-text-editor.png\" alt=\"Edit\" />";
    $deleteImage = "<img style=\"padding:0px\" src=\"{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/icons/16x16/actions/edit-delete.png\" alt=\"Delete\" />";
    $tableBody = '';
    for ($i = 0; $i < $userCount; $i++) {
        $tableBody .= '<tr><td>' . ($i + 1) . '</td>';
        if ($showEditButtons) {
            $tableBody .= '<td align="center"><a href="./+admin&subaction=editsiteregistrants&subsubaction=editregistrant&useremail=' . getUserEmail($userIds[$i]) . '" />' . $editImage . '</a></td>';
            $tableBody .= '<td align="center"><a href="./+admin&subaction=editsiteregistrants&subsubaction=deleteregistrant&useremail=' . getUserEmail($userIds[$i]) . '" />' . $deleteImage . '</a></td>';
        }
        $tableBody .= '<td>' . join(generateFormDataRow(0, $userIds[$i], $columnNames), '</td><td>') . "</td></tr>\n";
    }
    return '<br /><br /><br /><table border="1">' . $tableCaptions . $tableBody . '</table>';
}
예제 #2
0
/**
 * @uses generateFormDataRow($moduleCompId,$userId)
 * @uses getFormElementInfo($moduleCompId) (once it is made in formelementdescclass.php)
 *
 * @param $rowSortOrder "asc" or "desc"
 * @param $rowSortField "registrationdate" or "lastupdated" or "useremail" or "userfullname" or "elementid_".$i
 * @param $showEditButtons Whether to show edit and delete buttons or not: helps with editregistrants
 */
function generateFormDataTable($moduleComponentId, $sortField, $sortOrder, $action = 'viewregistrants')
{
    global $sourceFolder, $templateFolder, $urlRequestRoot, $cmsFolder, $moduleFolder;
    $formDescQuery = 'SELECT  `form_showuseremail`, `form_showuserfullname`, `form_showregistrationdate`, `form_showlastupdatedate`, `form_showuserprofiledata`,`form_heading` FROM `form_desc` ' . 'WHERE `page_modulecomponentid` = \'' . $moduleComponentId . "'";
    $formDescResult = mysql_query($formDescQuery);
    $showUserEmail = $showUserFullName = false;
    $showRegistrationDate = $showLastUpdateDate = true;
    $showUserProfileData = false;
    $formName = '';
    if ($formDescRow = mysql_fetch_row($formDescResult)) {
        $showUserEmail = $formDescRow[0] == 1;
        $showUserFullName = $formDescRow[1] == 1;
        $showRegistrationDate = $formDescRow[2] == 1;
        $showLastUpdateDate = $formDescRow[3] == 1;
        $showUserProfileData = $formDescRow[4] == 1;
        $formName = $formDescRow[5];
    }
    $showEditButtons = $action == 'editregistrants';
    $columnList = getColumnList($moduleComponentId, $showUserEmail, $showUserFullName, $showRegistrationDate, $showLastUpdateDate, $showUserProfileData);
    $columnNames = array();
    /*$normalImage = "<img alt=\"Sort by this field\" height=\"12\" width=\"12\" style=\"padding:0px\" src=\"$urlRequestRoot/$cmsFolder/$templateFolder/common/icons/16x16/actions/view-refresh.png\" />";
    	$orderedImage = "<img alt=\"Sort by this field\" height=\"12\" width=\"12\" style=\"padding:0px\" src=\"$urlRequestRoot/$cmsFolder/$templateFolder/common/icons/16x16/actions/go-" . ($sortOrder == 'asc' ? 'up' : 'down') . ".png\" />";
    
    	$tableCaptions = "<thead><tr>\n<th nowrap=\"nowrap\" class=\"sortable-numeric\">S. No.</th>\n";
    	if($showEditButtons) {
    		$tableCaptions .= '<th nowrap="nowrap">Edit</th><th nowrap="nowrap">Delete</th>';
    	}
    	foreach($columnList as $columnName => $columnTitle) {
    		$tableCaptions .= "<th nowrap=\"nowrap\" class=\"sortable-text\">$columnTitle</th>\n";
    		$columnNames[] = $columnName;
    	}
    	$tableCaptions .= "</tr></thead>\n";*/
    $tableCaptions = "<thead><tr>\n<th>S. No.</th>\n";
    $toggleColumns = "<fieldset><legend>Select Columns</legend><table><tr>";
    $tableJqueryStuff = "";
    $c = 0;
    $d = 0;
    if ($showEditButtons) {
        $tableCaptions .= '<th>Actions</th>';
        $tableJqueryStuff = "null,";
        $c++;
    }
    foreach ($columnList as $columnName => $columnTitle) {
        $tableCaptions .= "<th>{$columnTitle}</th>\n";
        $columnNames[] = $columnName;
        $c = $c + 1;
        $checked = "checked";
        if (!($columnName == "useremail" || $columnName == "registrationdate" || $columnName == "lastupdated")) {
            $tableJqueryStuff .= "/* {$columnTitle} */ { \"bVisible\": false },";
            $checked = "";
        } else {
            $tableJqueryStuff .= "null,";
        }
        if ($d != 0 && $d % 5 == 0) {
            $toggleColumns .= "</tr><tr>";
        }
        $d = $d + 1;
        $toggleColumns .= "<td><input type='checkbox' onclick='fnShowHide({$c});' {$checked} />{$columnTitle} <br/></td>";
    }
    $tableCaptions .= "</tr></thead>\n";
    $toggleColumns .= "</tr></table></fieldset>";
    $userIds = getDistinctRegistrants($moduleComponentId, $sortField, $sortOrder);
    $userCount = count($userIds);
    global $ICONS;
    $editImage = $ICONS['Edit']['small'];
    $deleteImage = $ICONS['Delete']['small'];
    $tableBody = '<tbody>';
    for ($i = 0; $i < $userCount; $i++) {
        $tableBody .= '<tr><td>' . ($i + 1) . '</td>';
        if ($showEditButtons) {
            if ($userIds[$i] <= 0) {
                $tableBody .= '<td align="center">&nbsp;</td>';
            } else {
                $tableBody .= '<td align="center"><a title="Edit" href="./+editregistrants&subaction=edit&useremail=' . getUserEmail($userIds[$i]) . '" />' . $editImage . '</a>&nbsp;';
            }
            if ($userIds[$i] <= 0) {
                $tableBody .= '<a style="cursor:pointer" title="Delete" onclick="return gotopage(\'./+editregistrants&subaction=delete&&useremail=' . getUserEmail($userIds[$i]) . '&registrantid=' . $userIds[$i] . '\',\'' . getUserEmail($userIds[$i]) . '\')" />' . $deleteImage . '</a></td>';
            } else {
                $tableBody .= '<a style="cursor:pointer" title="Delete" onclick="return gotopage(\'./+editregistrants&subaction=delete&useremail=' . getUserEmail($userIds[$i]) . '\',\'' . getUserEmail($userIds[$i]) . '\')" />' . $deleteImage . '</a></td>';
            }
        }
        $tableBody .= '<td>' . join(generateFormDataRow($moduleComponentId, $userIds[$i], $columnNames, $showUserProfileData), '</td><td>') . "</td></tr>\n";
    }
    $tableBody .= "</tbody>";
    $tableJqueryStuff = "/* S. No. */ null, {$tableJqueryStuff}";
    $smarttable = smarttable::render(array('registrantstable'), array('registrantstable' => array('aoColumns' => "{$tableJqueryStuff}")));
    global $STARTSCRIPTS;
    $STARTSCRIPTS .= "initSmartTable();";
    $javascriptBody = <<<JAVASCRIPTBODY
\t\t{$smarttable}
\t\t<script>
\t\t\tfunction fnShowHide( iCol )
\t\t\t{
\t\t\t\tvar bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
\t\t\t\toTable.fnSetColumnVis( iCol, bVis ? false : true );
\t\t\t}

\t\t</script>
\t\t<script language="javascript">
\t\t\tfunction gotopage(pagepath,useremail) {
\t\t\t\tif(confirm("Are you sure you want to remove "+useremail+" from this form?"))
\t\t\t\t\twindow.location = pagepath;
\t\t\t}
\t    </script>
JAVASCRIPTBODY;
    $imagesFolder = $urlRequestRoot . "/" . $cmsFolder . "/templates/common/images";
    $editRegistrantsView = '<br />';
    if ($action == 'editregistrants') {
        $editRegistrantsView .= <<<EDITREGISTRANTSVIEW
\t\t\t<form name="addusertoformform" method="POST" action="./+editregistrants" style="float:left">
\t\t\t\t<script type="text/javascript" language="javascript" src="{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/scripts/ajaxsuggestionbox.js">
\t\t\t\t</script>

\t\t\t\t<input type="text" name="useremail" id="userEmail" autocomplete="off" style="width: 256px" />
\t\t\t\t<div id="suggestionsBox" class="suggestionbox"></div>

\t\t\t\t
\t\t\t\t<input type="submit" name="btnAddUserToForm" value="Add User to Form" />
\t\t\t\t<script language="javascript" type="text/javascript">
\t\t\t\t<!--
\t\t\t\t\tvar userBox = new SuggestionBox(document.getElementById('userEmail'), document.getElementById('suggestionsBox'), "./+editregistrants&subaction=getsuggestions&forwhat=%pattern%");
\t\t\t\t\tuserBox.loadingImageUrl = '{$imagesFolder}/ajaxloading.gif';
\t\t\t\t-->
\t\t\t\t</script>
\t\t\t</form>
\t\t\t<br /><br />
EDITREGISTRANTSVIEW;
    }
    //$editRegistrantsView .= $javascriptBody.'<table border="1" id="registrantstable" class="paginate-20 max-pages-5 no-arrow rowstyle-alt colstyle-alt sortable display">' . $tableCaptions . $tableBody . '</table><br />';
    $editRegistrantsView .= $javascriptBody . $toggleColumns . '<table border="1" id="registrantstable" class="display">' . $tableCaptions . $tableBody . '</table><br />';
    if (!$showEditButtons && isset($_POST['save_as_excel'])) {
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false);
        header("Content-Type: application/vnd.ms-excel");
        header("Content-Disposition: attachment; filename=\"{$formName}.xls\";");
        header("Content-Transfer-Encoding: binary");
        echo '<table>' . $tableCaptions . $tableBody . '</table>';
        exit(1);
    }
    if ($action == 'editregistrants') {
        $editRegistrantsView .= '<form name="emptyregistrants" method="POST" action="./+editregistrants" onsubmit="return confirm(\'Are you sure you wish to remove all registrants from this form? This will also remove the users from any groups associated with this form.\')">' . '<input type="submit" name="btnEmptyRegistrants" value="Delete All Registrants" title="Deletes all registrations to this form" />' . '</form>';
    }
    return $editRegistrantsView;
}