function getProfileForm($userId, $userName, $userFullname, $forEditRegistrant = false) { global $urlRequestRoot, $moduleFolder, $cmsFolder, $sourceFolder, $templateFolder; require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformsubmit.php"; require_once "{$sourceFolder}/{$moduleFolder}/form/registrationformgenerate.php"; require_once "{$sourceFolder}/upload.lib.php"; $fakeModuleComponentId = $userId; $profileimgname = getUploadedFiles($fakeModuleComponentId, 'profile'); if ($profileimgname == NULL) { $profileimgname = "{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/images/no-img.jpg"; } else { $profileimgname = "./+profile&fileget={$profileimgname[0]['upload_filename']}"; } $profileimg = "<img id=profileimg src='{$profileimgname}' alt='Profile Image' title='Profile Image' height=120 width=100><br/>"; $profileimgupload = getFileUploadField('profileimage', 'profile', 512 * 1024); $jsValidationFunctions = array(); $containsFileUploadFields = false; $dynamicFields = getFormElementsHtmlAsArray(0, $userId, $jsValidationFunctions, $containsFileUploadFields); $dynamicFields = join($dynamicFields, "</tr>\n<tr>"); if ($dynamicFields != '') { $dynamicFields = "<tr>{$dynamicFields}</tr>"; } $jsValidationFunctions = join($jsValidationFunctions, ' && '); $captchaValidation = ''; if (!$forEditRegistrant) { $captchaQuery = 'SELECT `form_usecaptcha` FROM `form_desc` WHERE `page_modulecomponentid` = 0'; $captchaResult = mysql_query($captchaQuery); $captchaRow = mysql_fetch_row($captchaResult); if (isset($captchaRow[0]) && $captchaRow[0] == 1) { $captchaValidation = getCaptchaHtml(); } } $fValidatorPath = "{$urlRequestRoot}/{$cmsFolder}/{$templateFolder}/common/scripts/formValidator.js"; $ValidatorPath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}/form/validation.js"; $calpath = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}"; $formAction = './+profile'; if ($forEditRegistrant) { $formAction = './+admin&subaction=editsiteregistrants&subsubaction=editregistrant'; } global $ICONS; global $STARTSCRIPTS; $STARTSCRIPTS .= "document.getElementsByName('profileimage[]')[0].disabled=true;"; $profileForm = <<<PREF <script language="javscript" type="text/javascript" src="{$ValidatorPath}"></script> <script language="javascript" type="text/javascript" src="{$fValidatorPath}"></script> <link rel="stylesheet" type="text/css" media="all" href="{$calpath}/form/calendar/calendar.css" title="Aqua" /> <script language="javascript" type="text/javascript" src="{$calpath}/form/calendar/calendar.js"></script> <script language="javascript" type="text/javascript"> \twindow.addEvent("domready", function() { \t\tvar exValidatorA = new fValidator("registrationform"); \t}); \tfunction checkPassword(inputhandler) { \t\tinputhandler2=document.getElementById("user_newpassword"); \t\tif(inputhandler.value!=inputhandler2.value)\t{ \t\t\talert("The password you typed in the New Password field does not match the one in the Confirmation Box."); \t\t\tinputhandler.value=""; \t\t\tinputhandler2.value=""; \t\t\tinputhandler2.focus(); \t\t\treturn false; \t\t} \t\treturn true; \t} \tfunction checkProfileForm(inputhandler) { \t\tif(inputhandler.user_newpassword.value.length!=0) { \t\t\tif(inputhandler.user_password.value.length==0) { \t\t\t\talert("Please enter your current password in order to change to a new one."); \t\t\t\treturn false; \t\t\t} \t\t} \t\tif(checkPassword(inputhandler.user_newrepassword)==false) \t\t\treturn false; \t\treturn {$jsValidationFunctions}; \t} \t \tfunction toggle_img_upform() \t{ \t\tvar obj1=document.getElementsByName('profileimage[]')[0]; \t\tvar obj2=document.getElementById('upnewradio'); \t\tobj1.disabled=(obj2.checked==true?false:true); \t} \t </script> <div class="cms-registrationform"> \t<form id="cms-registrationform" class="fValidator-form" method="POST" name="user_profile_usrFrm" onsubmit="return checkProfileForm(this)" action="{$formAction}" enctype="multipart/form-data"> \t\t<fieldset style="width:80%"> \t\t\t<legend>{$ICONS['User Profile']['small']}Profile Preferences</legend> \t\t\t<table> \t\t\t\t<tr> \t\t\t\t<td colspan=2 style="text-align:center">{$profileimg}</td> \t\t\t\t</tr> \t\t\t\t<tr> \t\t\t\t\t<td><label for="user_name" class="labelrequired">Name</label></td> \t\t\t\t\t<td><input name="user_name" id="user_name" class="fValidate['required']" type="text" value="{$userName}"></td> \t\t\t\t</tr> \t\t\t\t<tr> \t\t\t\t\t<td><label for="user_fullname" class="labelrequired">Full Name</label></td> \t\t\t\t\t<td><input name="user_fullname" id="user_fullname" class="fValidate['required']" type="text" value="{$userFullname}"></td> \t\t\t\t</tr> \t\t\t\t<tr> \t\t\t\t\t<td>Profile image</td> \t\t\t\t\t<td> \t\t\t\t\t<input type="radio" name="profileimgaction" value="usecurrent" checked onclick="toggle_img_upform()"> Use existing image<br/> \t\t\t\t\t<input id='upnewradio' type="radio" name="profileimgaction" value="uploadnew" onclick="toggle_img_upform()"> Upload new image<br/> \t\t\t\t\t<input type="radio" name="profileimgaction" value="noimage" onclick="toggle_img_upform()"> Remove your image \t\t\t\t\t</td> \t\t\t\t<tr> \t\t\t\t\t<td><label for="profileimage">Upload new profile image (maximum size is 512 KB)</td> \t\t\t\t\t<td>{$profileimgupload}</td> \t\t\t\t</tr> PREF; if (!$forEditRegistrant) { $profileForm .= <<<PREF \t\t\t\t<tr> \t\t\t\t\t<td><label for="user_password" class="labelrequired">Current Password (Only for changing password)</label></td> \t\t\t\t\t<td><input name="user_password" id="user_password" class="" type="password"></td> \t\t\t\t</tr> \t\t\t\t<tr> \t\t\t\t\t<td><label for="user_newpassword" class="labelrequired">New Password</label></td> \t\t\t\t\t<td> <input name="user_newpassword" id="user_newpassword" class="fValidate['']" type="password"></td> \t\t\t\t</tr> \t\t\t\t<tr> <td><label for="user_newrepassword" class="labelrequired">Re-enter New Password</label></td> \t\t\t\t\t<td> <input name="user_newrepassword" id="user_newrepassword" class="fValidate['=user_newpassword']" type="password"></td> \t\t\t\t</tr> PREF; } $profileForm .= <<<PREF \t\t\t\t\t{$dynamicFields} \t\t\t\t\t{$captchaValidation} \t\t\t\t<tr> \t\t\t\t\t<td colspan="2"> </td> \t\t\t\t</tr> \t\t\t\t<tr> \t\t\t\t\t<td><input type="submit" name="btnSubmitProfile" id="submitbutton" value="Save Profile"></td> \t\t\t\t\t<td></td> \t\t\t\t</tr> \t\t\t</table> PREF; if ($forEditRegistrant) { $profileForm .= '<input type="hidden" name="useremail" value="' . getUserEmail($userId) . '" />'; } $profileForm .= <<<PREF \t\t</fieldset> \t</form> </div> PREF; // TODO: implement getProfileNewsletterList completely. return $profileForm . getProfileGroupsAndFormsList($userId) . getProfileNewsletterList($userId); return $profileForm . getProfileForms($userId) . getProfileGroupsAndFormsList($userId) . getFormDeadlines($userId); }
/** * Formulates a file upload form which can be used in modules. * @param $moduleComponentId page_modulecomponentid. * @param $moduleName The module which is calling this function. * @param $uploadFormAction The action that must be processed in submitting the form. * @param $maxFileSizeInBytes the maximum permissible size of the files that can be uploaded. * @param $uploadFieldCount The maximum number of that that can be submitted in one form. * @param $uploadFieldName The name of the variable used in forms to upload the file * * @return $uploadFormString The file upload form HTML in a string */ function getFileUploadForm($moduleComponentId, $moduleName, $uploadFormAction = './+edit', $maxFileSizeInBytes = false, $uploadFieldCount = 5, $uploadFieldName = 'fileUploadField') { $uploadFormString = <<<UPLOAD \t\t<form action="{$uploadFormAction}" method="post" enctype="multipart/form-data"> \t\t\t<style type="text/css"> \t\t\t\t.upload { display : none; } \t\t\t\t.show { display : block; } \t\t\t</style> \t\t\t<script language="javascript" type="text/javascript"> \t\t\t\tfunction toggleuploadfiles(gett) { \t\t\t\t\tif(gett.nextSibling.nextSibling.className != "show") \t\t\t\t\t{ \t\t\t\t\t\tgett.nextSibling.nextSibling.className = "show"; \t\t\t\t\t\tgett = gett.nextSibling.nextSibling; \t\t\t\t\t} \t\t\t\t\telse \t\t\t\t\t{ \t\t\t\t\t\tgett.nextSibling.nextSibling.className = "upload"; \t\t\t\t\t\tgett = gett.nextSibling.nextSibling; \t\t\t\t\t} \t\t\t\t} \t\t\t</script> UPLOAD; $uploadFormString .= getFileUploadField($uploadFieldName, $moduleName, $maxFileSizeInBytes); if ($uploadFieldCount >= 2) { $uploadFormString .= '<input type="button" value="Upload more files" onclick="javascript:toggleuploadfiles(this);" /> <span class="upload">'; for ($i = 2; $i <= $uploadFieldCount; $i++) { $uploadFormString .= "<input name=\"" . $uploadFieldName . "[]\" type=\"file\" />"; if ($i != $uploadFieldCount) { $uploadFormString .= '<br />'; } } $uploadFormString .= '</span>'; } $uploadFormString .= '<input value="Upload" type="submit" /> </form>'; return $uploadFormString; }
public function actionQahead() { global $urlRequestRoot, $sourceFolder, $templateFolder, $cmsFolder, $moduleFolder; $moduleComponentId = $this->moduleComponentId; $userId = $this->userId; require_once "{$sourceFolder}/{$moduleFolder}/events/events_common.php"; require_once "{$sourceFolder}/{$moduleFolder}/events/events_forms.php"; require_once "{$sourceFolder}/{$moduleFolder}/events/events.config.php"; require_once $sourceFolder . "/" . $moduleFolder . "/qaos1/excel.php"; require_once $sourceFolder . "/upload.lib.php"; if (isset($_GET['subaction'])) { if ($_GET['subaction'] == "viewEvent") { if (isset($_POST['eventId'])) { $eventId = escape($_POST['eventId']); return displayEventOptions('qahead', $moduleComponentId, $eventId); } } else { if ($_GET['subaction'] == 'getParticipant') { if (isset($_POST['eventId'])) { $eventId = escape($_POST['eventId']); $userId = escape($_POST['userId']); $eventAdd = "<p>SEARCH RESULTS </p>"; if ($userId[0] == 'F' || $userId[1] == 'f') { $bookletId = $userId; $userId = getUserIdFromBookletId($moduleComponentId, $userId); } else { if ($userId > 200000 && $userId < 30000) { $userId -= 180000; } $bookletId = getBookletIdFromUserId($userId, $moduleComponentId); } $eventAdd .= searchParticipant('qahead', $pmcId, 1); $eventAdd .= "<h2>Profile</h2>"; $eventAdd .= returnUserProfileDetails($userId); $eventAdd .= "<h2>PR & Hospi Details</h2>"; $eventAdd .= "<table><tr style='font-size:10px'>"; $eventAdd .= "<th>PR CHECK IN TIME</th>"; $eventAdd .= "<th>PR CHECK OUT TIME</th>"; $eventAdd .= "<th>AMOUNT RECIEVED AT PR</th>"; $eventAdd .= "<th>AMOUNT REFUNDED AT PR</th>"; $eventAdd .= "<th>HOSPI CHECK IN TIME</th>"; $eventAdd .= "<th>HOSPI CHECK OUT TIME</th>"; $eventAdd .= "<th>AMOUNT RECIEVED AT HOSPI</th>"; $eventAdd .= "<th>AMOUNT REFUNDED AT HOSPI</th>"; $eventAdd .= "<th>No. of days of stay</th></tr>"; $prStatus = "SELECT * FROM `prhospi_pr_status` WHERE `user_id`='{$userId}' and `page_moduleComponentId`={$moduleComponentId}"; $prQuery = mysql_query($prStatus) or displayerror(mysql_error()); $prRows = mysql_fetch_array($prQuery); $checkintime_pr = $prRows['hospi_checkin_time']; $checkoutime_pr = $prRows['hospi_checkpout_time']; $amount_recieved_pr = $prRows['amount_recieved']; $amount_refunded_pr = $prRows['amount_refunded']; $HospiStatus = "SELECT * FROM `prhospi_accomodation_status` WHERE `user_id`='{$userId}' and `page_modulecomponentid`={$moduleComponentId}"; $HospiQuery = mysql_query($HospiStatus) or displayerror(mysql_error()); $HospiRows = mysql_fetch_array($HospiQuery); $checkintime_hospi = $HospiRows['hospi_actual_checkin']; $checkoutime_hospi = $HospiRows['hospi_actual_checkout']; $amount_recieved_hospi = $HospiRows['hospi_cash_recieved']; $amount_refunded_hospi = $HospiRows['hospi_cash_refunded']; $no_of_days = $HospiRows['no_of_days']; $hospi_room_id = $HospiRows['hospi_room_id']; $eventAdd .= "<td>" . $checkintime_pr . "</td>"; $eventAdd .= "<td>" . $checkoutime_pr . "</td>"; $eventAdd .= "<td>" . $amount_recieved_pr . "</td>"; $eventAdd .= "<td>" . $amount_refunded_pr . "</td>"; $eventAdd .= "<td>" . $checkintime_hospi . "</td>"; $eventAdd .= "<td>" . $checkoutime_hospi . "</td>"; $eventAdd .= "<td>" . $amount_recieved_hospi . "</td>"; $eventAdd .= "<td>" . $amount_refunded_hospi . "</td>"; $eventAdd .= "<td>{$no_of_days}</td>"; $eventAdd .= "</tr></table>"; $hostelQuery = "SELECT * FROM `prhospi_hostel` WHERE `hospi_room_id`={$hospi_room_id} and `page_modulecomponentid`={$moduleComponentId}"; $hostelQueryResult = mysql_query($hostelQuery) or displayerror(mysql_error()); $hostelDetails = mysql_fetch_array($hostelQueryResult); $eventAdd .= "<h2>Hostel Details</h2>"; $eventAdd .= "<table>"; $eventAdd .= "<th>HOSTEL</th>"; $eventAdd .= "<th>FLOOR</th>"; $eventAdd .= "<th>ROOM</th>"; $eventAdd .= "<tr>"; $eventAdd .= "<td>{$hostelDetails['hospi_hostel_name']}</td>"; $eventAdd .= "<td>{$hostelDetails['hospi_floor']}</td>"; $eventAdd .= "<td>{$hostelDetails['hospi_room_no']}</td>"; $eventAdd .= "</tr>"; $eventAdd .= "</table>"; $eventAdd .= "<h2>Event Details</h2>"; $eventAdd .= "<table><tr>"; $eventAdd .= "<th>EVENT</th>"; $eventAdd .= "<th>EVENT RANK</th>"; $eventAdd .= "<th>PRIZE MONEY</th>"; $eventAdd .= "<th>TEAMMATES </th>"; $userDetails = "SELECT * FROM `events_result` WHERE `user_id`='{$userId}' and `page_moduleComponentId`={$moduleComponentId}"; $userDetailsRows = mysql_query($userDetails) or displayerror(mysql_error()); while ($row = mysql_fetch_array($userDetailsRows)) { $eventAdd .= "<tr>"; $eventDetails = "SELECT * FROM `events_details` WHERE `event_id`='{$row['event_id']}'"; $eventResults = mysql_query($eventDetails) or displayerror(mysql_error()); $eventsResults = mysql_fetch_array($eventResults); $eventAdd .= "<td>" . $eventsResults['event_name'] . "</td>"; $eventAdd .= "<td>" . $row['user_rank'] . "</td>"; $userPrizeDetails = "SELECT * FROM `events_participants` WHERE `user_pid`='{$userId}' "; $userPrizeQuery = mysql_query($userPrizeDetails) or displayerror(mysql_error()); $userPrizeRows = mysql_fetch_array($userPrizeQuery); $eventAdd .= "<td>" . $userPrizeRows['prize_money'] . "</td>"; $teamMateDetails = "SELECT * FROM `events_participants` WHERE `user_pid`='{$userId}' and `event_id` ='{$row['event_id']}'"; displayerror($teamMateDetails); $teamMateQuery = mysql_query($teamMateDetails) or displayerror(mysql_error); $teamMateDetails = mysql_fetch_assoc($teamMateQuery); $teamMates = $teamMateDetails['user_team_id']; $teamMateDetails = "SELECT * FROM `events_participants` WHERE `user_team_id`={$teamMates} and `event_id` ='{$row['event_id']}'"; $teamMateQuery = mysql_query($teamMateDetails) or displayerror(mysql_error); $eventAdd .= "<td>"; while ($newRow = mysql_fetch_array($teamMateQuery)) { $eventAdd .= $newRow['user_pid'] . " "; } $eventAdd .= "</td>"; } $eventAdd .= "</table>"; return $eventAdd; } } else { if ($_GET['subaction'] == 'addParticipant') { if (isset($_POST['eventId'])) { $eventId = escape($_POST['eventId']); $fileUploadableField = getFileUploadField('fileUploadFieldPart', "events"); $eventAdd = <<<FORM <p>Upload Event Excel File:</p> <form action="./+qahead&subaction=viewEvent" method="post" enctype='multipart/form-data'> {$fileUploadableField} <input type='hidden' name='eventId' value='{$eventId}'> <input type='submit' name='submit' value='Upload'> </form> FORM; return $eventAdd; } } else { if ($_GET['subaction'] == "editParticipant") { $editFormId = escape($_POST['formId']); $editUserId = escape($_POST['userId']); $teamId = escape($_POST['teamId']); $rowValue = escape($_POST['rowValue']); $rowId = escape($_POST['rowId']); $eventId = escape($_POST['eventId']); if (!empty($userId)) { //return $rowId; echo editParticipant('qahead', $moduleComponentId, $eventId, $editFormId, $editUserId, $teamId, $rowValue, $rowId); die; } } else { if ($_GET['subaction'] == "lockEvent") { $eventId = trim(escape($_POST['eventId'])); if (!empty($eventId)) { return lockEvent($moduleComponentId, $eventId); } } else { if ($_GET['subaction'] == 'unlockEvent') { $eventId = trim(escape($_POST['eventId'])); if (!empty($eventId)) { return unlockEvent($moduleComponentId, $eventId); } } else { if ($_GET['subaction'] == "downloadExcel") { //$eventId = escape($_POST['eventId']); //error_log($eventId); //getUserDetailsTable($moduleComponentId,$eventId); getUserDetailsTable('qahead', $moduleComponentId, escape($_GET['event_id'])); } else { if ($_GET['subaction'] == "deleteParticipant") { $userId = escape($_POST['userId']); $eventId = escape($_POST['eventId']); return deleteParticipant($moduleComponentId, $userId, $eventId); } else { if ($_GET['subaction'] == "deleteEvent") { $eventId = escape($_POST['eventId']); return deleteEventQa($moduleComponentId, $eventId); } } } } } } } } } /*else if($_GET['subaction'] == "getDetails"){ if(isset($_POST['eventId'])){ $eventId = escape($_POST['eventId']); return } }*/ } else { //return displayQa($moduleComponentId); return qaHeadOptions($moduleComponentId); } }
function getFormElementFile($elementName, $value, $isRequired, $elementHelpName, $elementTooltip, $elementSize, $elementTypeOptions, $elementMoreThan, $elementLessThan, $elementCheckInt, &$jsOutput, &$htmlOutput) { if ($isRequired && $value == '') { /// Check $value == '', because if it isn't, there's no point making the user upload the same file again $validCheck = " class=\"required\""; } else { $validCheck = ""; } global $sourceFolder; require_once "{$sourceFolder}/upload.lib.php"; $htmlOutput .= getFileUploadField($elementName, "form", 2 * 1024 * 1024, $validCheck); global $uploadFolder; if ($value != '') { $htmlOutput .= '<br />(Leave blank to keep current file : <a href="./' . $value . '">' . $value . '</a>)'; } return true; }
/** * Renders the File type element * @param $elementName The name of the field * @param $value The current value * @param $options The extra options related to this field type * @param $htmlOutput Will contain the actual HTML Output * @see getFileUploadField * @return true if succesful, or false if rendering failed. */ function renderFileTypeField($elementName, $value, $options, &$htmlOutput) { global $sourceFolder; require_once "{$sourceFolder}/upload.lib.php"; ///Used to maintain uniformity in upload fields in the CMS $htmlOutput .= getFileUploadField($elementName, "", 2 * 1024 * 1024, ""); if ($value != '') { $htmlOutput .= '<br />(Leave blank to keep current file : <a href="./' . $value . '">' . $value . '</a>)'; } return true; }
function viewWorkshopDetails($workshopId, $pmcId) { global $cmsFolder, $moduleFolder, $urlRequestRoot, $sourceFolder; $scriptFolder = "{$urlRequestRoot}/{$cmsFolder}/{$moduleFolder}/events"; $workshopDetails = <<<SCRIPT \t\t<script src="{$scriptFolder}/events.js"></script> <script src="{$scriptFolder}/jquery.js"></script> SCRIPT; $workshopDetails .= getWorkshopsList($pmcId); if (isset($_FILES['fileUploadField']['name'])) { syncExcelFileWorkshop($pmcId, $workshopId, $_FILES['fileUploadField']['tmp_name'][0]); } $checkParticipantsQuery = "SELECT `user_id` FROM `events_workshop_participants` WHERE `page_moduleComponentId`='{$pmcId}' AND `workshop_id`='{$workshopId}' LIMIT 1"; $checkParticipantsRes = mysql_query($checkParticipantsQuery) or displayerror(mysql_error()); if (mysql_num_rows($checkParticipantsRes) == 0) { //Show FileUpload Details $fileUploadableField = getFileUploadField('fileUploadField', "events"); $workshopDetails .= <<<ADDROOMFORM <br/><br/> <form action="./+prhead&subaction=viewWorkshopDetails" method="post"> \t<input type="submit" name="downloadSampleFormat" value="Download Sample Form"><br/> </form> <form action="./+prhead&subaction=viewWorkshopDetails" method="post" enctype='multipart/form-data'> \t {$fileUploadableField} \t <input type='hidden' name='workshopId' value='{$workshopId}'> \t <input type='submit' name='submit' value='Upload'> \t </form> ADDROOMFORM; } else { $workshopDetails .= <<<PRINTTABLE \t\t<table><tr><td> \t\t<a href='./+prhead&subaction=downloadExcel&workshop_id={$workshopId}'>Download Details</a> \t\t</td><td> \t\t<form method='POST' action='./+prhead&subaction=printCerti'> \t\t<input type='hidden' name='workshopId' value='{$workshopId}'> \t\t<input type='submit' value='Print Certificates PDF'> \t\t</form></td></tr></table> \t PRINTTABLE; //$downloadTable = getUserDetailsTable($pmcId,$eventId); //$eventDetails.=displayExcelForTable($downloadTable); $workshopParticipants = displayWorkshopParticipants($pmcId, $workshopId); //displayExcelForTable($eventParticipants); $workshopDetails .= $workshopParticipants; } return $workshopDetails; }