Пример #1
0
                $organisations = Organisations::getInstance()->getOrganisationById($org_id);
                $jTableResult['TotalRecordCount'] = count($organisations);
                $jTableResult['Records'] = $organisations;
            } else {
                $jTableResult['TotalRecordCount'] = Organisations::getInstance()->getOrganisationsRowCountBySearchCriteria($orgName);
                $jTableResult['Records'] = Organisations::getInstance()->getOrganisationsBySearchCriteria($orgName, $_GET["jtSorting"], $_GET["jtStartIndex"], $_GET["jtPageSize"]);
            }
            print json_encode($jTableResult);
        } catch (Exception $ex) {
            //Return error message
            $jTableResult = array();
            $jTableResult['Result'] = "ERROR";
            $jTableResult['Message'] = $ex->getMessage();
            print json_encode($jTableResult);
        }
        break;
    case 'organisation_detail':
        if (isset($_GET['orgid'])) {
            try {
                $organisations = Organisations::getInstance()->getOrganisationById($_GET['orgid']);
                echo $organisations ? jsonGoodResult($organisations[0]) : jsonBadResult(t('Could not find the organisation'));
            } catch (Exception $e) {
                echo jsonBadResult($e->getMessage());
            }
        } else {
            echo jsonBadResult(t("No organisation identifier submitted!"));
        }
        break;
    default:
        echo "No such action: " . $_GET['action'];
}
Пример #2
0
function initBrowseProjectLayout($pid = '')
{
    $org_id = 0;
    if (isset($_GET['organisation'])) {
        $org_id = $_GET['organisation'];
    }
    $state = null;
    if (isset($_GET['state'])) {
        $state = $_GET['state'];
    }
    $apply_projects = vals_soc_access_check('dashboard/projects/apply') ? 1 : 0;
    $rate_projects = Users::isSuperVisor();
    $is_student = Users::isStudent();
    ?>
	<div class="filtering" id="browse_projects">
		<span id="infotext" style="margin-left: 34px"></span>
		<form id="project_filter">
		<?php 
    echo t('Tags');
    ?>
: <input type="text" name="tags" id="tags" />
		<?php 
    echo t('Organisations');
    ?>
:
			<select id="organisation" name="organisation">
			<option <?php 
    echo !$org_id ? 'selected="selected"' : '';
    ?>
 value="0"><?php 
    echo t('All Organisations');
    ?>
</option><?php 
    $result = Organisations::getInstance()->getOrganisationsLite();
    foreach ($result as $record) {
        $selected = $record->org_id == $org_id ? 'selected="selected" ' : '';
        echo '<option ' . $selected . 'value="' . $record->org_id . '">' . $record->name . '</option>';
    }
    ?>
			</select>
			<?php 
    if ($is_student) {
        ?>
			<input type='button' value='<?php 
        echo t('Filter on Favourites');
        ?>
' id='favourite_filter'/>
			<?php 
    }
    ?>
			
			<?php 
    echo "<BR/>";
    echo t('Status');
    ?>
:
			<select id="state" name="state">
				<option <?php 
    echo !$state ? 'selected="selected"' : '';
    ?>
 value="0"><?php 
    echo t('NA');
    ?>
</option><?php 
    $states = array('draft' => 'draft', 'pending' => 'pending', 'open' => 'open', 'preselected' => 'preselected', 'active' => 'active', 'ended' => 'ended', 'archived' => 'archived');
    if (!Users::isAdmin()) {
        if (Users::isMentor()) {
            unset($states['archived']);
        } else {
            unset($states['draft']);
            if ($is_student) {
                unset($states['pending'], $states['archived']);
            } elseif (Users::isUser()) {
                unset($states['archived']);
            } else {
                $states = array();
            }
        }
    }
    foreach ($states as $key => $stat) {
        $selected = $key == $state ? 'selected="selected" ' : '';
        echo "<option {$selected} value='{$key}'>{$stat}</option>";
    }
    ?>
			</select>
			
		</form>
	</div>
	<div id="ProjectTableContainer" style="width: 700px;"></div>

<script type="text/javascript">
	jQuery(document).ready(function($){

		window.view_settings = {};
		window.view_settings.apply_projects = <?php 
    echo $apply_projects ? 1 : 0;
    ?>
;
		window.view_settings.rate_projects  = <?php 
    echo $rate_projects ? 1 : 0;
    ?>
;
	
		//Prepare jTable
		$("#ProjectTableContainer").jtable({
			//title: "Table of projects",
			paging: true,
			pageSize: 10,
			sorting: true,
			defaultSorting: "title ASC",
			actions: {
				listAction: moduleUrl + "actions/project_actions.php?action=list_search"
			},
			fields: {
				pid: {
					key: true,
					create: false,
					edit: false,
					list: false
				},
				title: {
					title: "Project title",
					width: "40%",
					display: function (data) {
						return "<a title=\"View project details\" href=\"javascript:void(0);\" onclick=\"getProjectDetail("+
							data.record.pid+")\">" + data.record.title + "</a>";
						},
						create: false,
						edit: false
				},
				name: {
					title: "Organisation",
					width: "20%"
				},
				tags: {
					title: "Tags",
					width: "26%",
					create: false,
					edit: false
				},
				proposal_count: {
					title: "Proposals",
					width: "12%",
					create: false,
					edit: false
				},
				state: {
					title: "Status",
					//width: "12%",
					create: false,
					edit: false
				}
				/*
				,
				Detail: {
					width: "2%",
					title: "",
					sorting: false,
					display: function (data) {
						return "<a title=\"View project details\" href=\"#\" onclick=\"getProjectDetail("+
							data.record.pid+")\"><span class=\"ui-icon ui-icon-info\"></span></a>";
						},
					create: false,
					edit: false
				}
				*/
				<?php 
    if ($apply_projects) {
        ?>
					,
					Propose: {
						width: "2%",
						title: "",
						sorting: false,
						display: function (data) {
							return "<a title=\"Propose a project for this idea\" href=\"#\" onclick=\"getProposalFormForProject("+data.record.pid+")\">"+
							"<span class=\"ui-icon ui-icon-script\"></span></a>";
							},
						create: false,
						edit: false
					}<?php 
    }
    ?>
			}
			/*
//this makes of each row a filter for that project
			,recordsLoaded: function(event, data) {
				var browse_url = baseUrl + "dashboard/projects/browse?pid=";
				
				$(".jtable-data-row").each(function(){
					var $parent = $(this);
					
					var row_id = $parent.attr("data-record-key");
					$parent.children('td:first-child').click(function() {
						document.location.href=browse_url + row_id;
					});
				});
			}
			*/
		});
	
	//Load project list from server on initial page load
	$("#ProjectTableContainer").jtable("load", {
		tags: $("#tags").val(),
		state: $("#state").val(),
		organisation: $("#organisation").val()<?php 
    if ($pid) {
        echo ", pid: {$pid}";
    }
    ?>
	});
		
	$("#tags").keyup(function(e) {
		e.preventDefault();
		// only auto clear when there is no tag info
		if(testTagInput() && $("#tags").val()==""){
			$("#ProjectTableContainer").jtable("load", {
			tags: $("#tags").val(),
			state: $("#state").val(),
			organisation: $("#organisation").val()
			});
		}
	});
		
	$("#organisation").change(function(e) {
		e.preventDefault();
		if(testTagInput()){
			$("#ProjectTableContainer").jtable("load", {
				tags: $("#tags").val(),
				state: $("#state").val(),
				organisation: $("#organisation").val()
			});
		}
	});
	$("#state").change(function(e) {
		e.preventDefault();
		if(testTagInput()){
			$("#ProjectTableContainer").jtable("load", {
				tags: $("#tags").val(),
				state: $("#state").val(),
				organisation: $("#organisation").val()
			});
		}
	});
	<?php 
    if ($is_student) {
        ?>
	$("#favourite_filter").click(function(e) {
		e.preventDefault();
		//if(testTagInput()){
			$("#ProjectTableContainer").jtable("load", {favourites :true});
		//}
	});
	<?php 
    }
    ?>
	$("#project_filter").submit(function(e){
		e.preventDefault();
		if(testTagInput()){
			$("#ProjectTableContainer").jtable("load", {
				tags: $("#tags").val(),
				state: $("#state").val(),
				organisation: $("#organisation").val()
			});
		}
	});

	
	
					
	// define these at the window level so that they can still be called once loaded
	window.getProposalFormForProject = getProposalFormForProject;
	window.getProjectDetail = getProjectDetail;
	
	});
	</script>
<?php 
}
Пример #3
0
function initBrowseProposalsByTypeLayout($owner_only = false)
{
    $only_mine_query = (bool) $owner_only ? '&mine_only=true' : '';
    $only_mine_js = (bool) $owner_only ? 'true' : 'false';
    // ORG ADMIN & MENTOR VIEWS
    if (hasRole(array(_ORGADMIN_TYPE)) || hasRole(array(_MENTOR_TYPE))) {
        $org_id = 0;
        if (isset($_GET['organisation'])) {
            $org_id = $_GET['organisation'];
        }
        echo "<a href='" . _WEB_URL . "/dashboard/proposals/browsebytype'>" . t('Show all proposals for my organisation') . "</a>";
        echo " | ";
        echo "<a href='" . _WEB_URL . "/dashboard/proposals/browsebytype/mine'>" . t('Show only mine') . "</a>";
        ?>
		<div class="filtering" style="width: 800px;">
			<span id="infotext" style="margin-left: 34px"></span>
			<form id="proposal_filter">
		        <?php 
        echo t('Filter by Organisation');
        ?>
:
		        <?php 
        // echo t('Organisations');
        ?>
		        <select id="organisation" name="organisation">
					<option <?php 
        echo !$org_id ? 'selected="selected"' : '';
        ?>
					value="0"><?php 
        echo t('All My Organisations');
        ?>
</option><?php 
        $result = Organisations::getInstance()->getMyOrganisations(TRUE);
        foreach ($result as $record) {
            $selected = $record->org_id == $org_id ? 'selected="selected" ' : '';
            echo '<option ' . $selected . 'value="' . $record->org_id . '">' . $record->name . '</option>';
        }
        ?>
				</select>
			</form>
		</div>
		<div id="TableContainer" style="width: 800px;"></div>
		<script type="text/javascript">

				jQuery(document).ready(function($){
					window.view_settings = {};

					function loadFilteredProposals(){
						$("#TableContainer").jtable("load", {
							organisation: $("#organisation").val(),
						});
					}

				    //Prepare jTable
					$("#TableContainer").jtable({
						paging: true,
						pageSize: 10,
						sorting: true,
						defaultSorting: "pid ASC",
						actions: {
							listAction: moduleUrl + "actions/project_actions.php?action=list_search_proposal_count<?php 
        echo $only_mine_query;
        ?>
"
						},
						fields: {
							pid: {
								key: true,
		    					create: false,
		    					edit: false,
		    					list: false
							},
							title: {
								title: "Project",
								width: "49%",
								display: function (data) {
									return "<a title=\"View project details\" href=\"javascript:void(0);\" onclick=\"getProjectDetail("+data.record.pid+")\">"
											+ data.record.title+"</a>";
									},
							},
							org_name: {
								title: "Organisation",
								width: "35%",
								display: function (data){return data.record.org_name;}
							},
							proposal_count : {
								title: "Proposals",
								width: "10%",
								display: function (data){return data.record.proposal_count;}
							},

							proposal_view : {
								width: "6%",
		    					title: "View",
								sorting: false,
		    					display: function (data) {
			    					if(data.record.proposal_count > 0){
									return "<a title=\"View Proposals\" href=\"javascript:void(0);\" "+
										"onclick=\"getProposalsForProject("+data.record.pid+",<?php 
        echo $only_mine_js;
        ?>
)\">"+
											"<span class=\"ui-icon ui-icon-info\">See detail</span></a>";
			    					}
		    					},

		    					create: false,
		    					edit: false
							},

						},
					});

					//Load proposal list from server on initial page load
					loadFilteredProposals();

					$("#organisation").change(function(e) {
		           		e.preventDefault();
		           		loadFilteredProposals();
		        	});

					$("#proposal_filter").submit(function(e){
						e.preventDefault();
						loadFilteredProposals()
					});

				});
			</script><?php 
    } else {
        if (hasRole(array(_INSTADMIN_TYPE)) || hasRole(array(_SUPERVISOR_TYPE))) {
            $studentgroup_id = 0;
            if (isset($_GET['group'])) {
                $studentgroup_id = $_GET['group'];
            }
            echo "<a href='" . _WEB_URL . "/dashboard/proposals/browsebytype'>" . t('Show all proposals from my Institution') . "</a>";
            echo " | ";
            echo "<a href='" . _WEB_URL . "/dashboard/proposals/browsebytype/mine'>" . t('Show only mine') . "</a>";
            ?>
		 	<div class="filtering" style="width: 800px;">
				<span id="infotext" style="margin-left: 34px"></span>
				<form id="proposal_filter">
			        <?php 
            echo t('Filter by Group');
            ?>
:
			        <?php 
            // echo t('Organisations');
            $option_text = (bool) $owner_only ? t('All My Groups') : t('All Groups from my Institution');
            if ($owner_only) {
                $result = Groups::getGroups(_STUDENT_GROUP, $GLOBALS['user']->uid);
            } else {
                $institutes = Users::getInstituteForUser($GLOBALS['user']->uid);
                if ($institutes->rowCount() > 0) {
                    $result = Groups::getGroups(_STUDENT_GROUP, 'all', $institutes->fetchObject()->inst_id);
                } else {
                    // give up, just get their own
                    $result = Groups::getGroups(_STUDENT_GROUP, $GLOBALS['user']->uid);
                }
            }
            ?>
			        <select id="group" name="group">
			<option
				<?php 
            echo !$studentgroup_id ? 'selected="selected"' : '';
            ?>
				value="0"><?php 
            echo $option_text;
            ?>
</option><?php 
            foreach ($result as $record) {
                $selected = $record->studentgroup_id == $studentgroup_id ? 'selected="selected" ' : '';
                echo '<option ' . $selected . 'value="' . $record->studentgroup_id . '">' . $record->name . '</option>';
            }
            ?>
					</select>
				</form>
			</div>
			<div id="TableContainer" style="width: 800px;"></div>
			<script type="text/javascript">

		 			jQuery(document).ready(function($){
		 				window.view_settings = {};

		 				function loadFilteredProposals(){
		 					$("#TableContainer").jtable("load", {
		 						group: $("#group").val(),
		 					});
		 				}

		 			    //Prepare jTable
		 				$("#TableContainer").jtable({
		 					paging: true,
		 					pageSize: 10,
		 					sorting: true,
		 					defaultSorting: "pid ASC",
		 					actions: {
		 						listAction: moduleUrl + "actions/institute_actions.php?action=list_search_proposal_count_student<?php 
            echo $only_mine_query;
            ?>
"
		 					},
		 					fields: {
		 						uid: {
		 							key: true,
		 	    					create: false,
		 	    					edit: false,
		 	    					list: false
		 						},
		 						username: {
		 							title: "Student",
		 							width: "42%",
		 							display: function (data) {
		 								return  data.record.username;
		 								},
		 						},
		 						groupname: {
		 							title: "Group name",
		 							width: "42%",
		 							display: function (data){return data.record.groupname;}
		 						},
		 						proposal_count : {
		 							title: "Proposals",
		 							width: "10%",
		 							display: function (data){return data.record.proposal_count;}
		 						},

		 						proposal_view : {
		 							width: "6%",
		 	    					title: "View",
		 							sorting: false,
		 	    					display: function (data) {
		 		    					if(data.record.proposal_count > 0){
		 								return "<a title=\"View Proposals\" href=\"javascript:void(0);\" "+
		 									"onclick=\"getProposalsForStudent("+data.record.uid+",<?php 
            echo $only_mine_js;
            ?>
)\">"+
		 										"<span class=\"ui-icon ui-icon-info\">See detail</span></a>";
		 		    					}
		 	    					},

		 	    					create: false,
		 	    					edit: false
		 						},

		 					},
		 				});

		 				//Load proposal list from server on initial page load
		 				loadFilteredProposals();

		 				$("#group").change(function(e) {
		 	           		e.preventDefault();
		 	           		loadFilteredProposals();
		 	        	});

		 				$("#proposal_filter").submit(function(e){
		 					e.preventDefault();
		 					loadFilteredProposals()
		 				});

		 			});
		 		</script><?php 
        } else {
        }
    }
}
Пример #4
0
 public static function getProjectsAndProposalCountByCriteria($organisation, $owner_id = '', $sorting = 'p.pid', $startIndex = 1, $pageSize = 10)
 {
     if (!$organisation) {
         $organisation = array();
         $result = Organisations::getInstance()->getMyOrganisations(TRUE);
         foreach ($result as $record) {
             array_push($organisation, $record->org_id);
         }
     }
     $query = " \n    \t\tSELECT p.pid, p.title, o.name AS org_name, COUNT(v.proposal_id) AS proposal_count\n\t\t\tFROM soc_projects AS p\n\t\t\tLEFT JOIN soc_proposals AS v ON ( v.pid = p.pid )\n\t\t\tLEFT JOIN soc_organisations AS o ON ( p.org_id = o.org_id ) \n\t\t\tWHERE p.org_id IN (:orgs) ";
     if ($owner_id) {
         //$query .= "AND p.owner_id = " . $owner_id . " ";
         $query .= "AND p.mentor_id = " . $owner_id . " ";
     }
     $query .= "GROUP BY p.pid ";
     if (!$sorting) {
         $sorting = 'pid ASC';
     }
     $query .= " ORDER BY " . $sorting . " LIMIT " . $startIndex . "," . $pageSize . ";";
     $projects = db_query($query, array(':orgs' => $organisation))->fetchAll();
     return $projects;
 }
Пример #5
0
function showInstituteOverviewPage($institute)
{
    include_once _VALS_SOC_ROOT . '/includes/classes/Proposal.php';
    include_once _VALS_SOC_ROOT . '/includes/classes/Organisations.php';
    include_once _VALS_SOC_ROOT . '/includes/classes/Project.php';
    echo "<h2>" . t('Overview of your institute activity') . "</h2>";
    $inst_id = $institute->inst_id;
    $nr_proposals_draft = count(Proposal::getProposalsPerOrganisation('', $inst_id));
    $nr_proposals_final = count(Proposal::getProposalsPerOrganisation('', $inst_id, 'published'));
    $nr_students = Users::getUsers(_STUDENT_TYPE, _INSTITUTE_GROUP, $inst_id)->rowCount();
    $nr_groups = Groups::getGroups(_STUDENT_GROUP, 'all', $inst_id)->rowCount();
    $nr_tutors = Users::getUsers(_SUPERVISOR_TYPE, _INSTITUTE_GROUP, $inst_id)->rowCount() + Users::getUsers(_INSTADMIN_TYPE, _INSTITUTE_GROUP, $inst_id)->rowCount();
    $nr_orgs = count(Organisations::getInstance()->getOrganisations());
    $nr_projects = count(Project::getProjects());
    echo "<b>" . t("Proposals in draft:") . "</b>&nbsp; {$nr_proposals_draft}<br>";
    echo "<b>" . t("Proposals submitted:") . "</b>&nbsp; {$nr_proposals_final}<br>";
    echo "<b>" . t("Number of students subscribed:") . "</b>&nbsp; {$nr_students}<br>";
    echo "<b>" . t("Number of groups available:") . "</b>&nbsp; {$nr_groups}<br>";
    echo "<b>" . t("Number of supervisors subscribed:") . "</b>&nbsp; {$nr_tutors}<br>";
    echo "<b>" . t("Number of organisations:") . "</b>&nbsp; {$nr_orgs}<br>";
    echo "<b>" . t("Number of projects:") . "</b>&nbsp; {$nr_projects}<br>";
}
Пример #6
0
function initBrowseProjectOffersLayout()
{
    global $base_url;
    $org_id = 0;
    if (isset($_GET['organisation'])) {
        $org_id = $_GET['organisation'];
    }
    echo '<div id="baktoprops"><a href=" ' . $base_url . '/dashboard">' . t('Back to dashboard') . '</a></div>';
    echo '<h2>' . t('Here you can select which of your project offers you wish to accept') . '</h2>';
    ?>
		<div class="filtering" style="width: 800px;">
			<span id="infotext" style="margin-left: 34px"></span>
			<form id="proposal_filter">
		        <?php 
    echo t('Filter by Organisation');
    ?>
:
		        <?php 
    // echo t('Organisations');
    ?>
		        <select id="organisation" name="organisation">
					<option <?php 
    echo !$org_id ? 'selected="selected"' : '';
    ?>
					value="0"><?php 
    echo t('All Organisations');
    ?>
</option><?php 
    $result = Organisations::getInstance()->getOrganisationsLite();
    foreach ($result as $record) {
        $selected = $record->org_id == $org_id ? 'selected="selected" ' : '';
        echo '<option ' . $selected . 'value="' . $record->org_id . '">' . $record->name . '</option>';
    }
    ?>
				</select>
			</form>
		</div>

		<div id="TableContainer" style="width: 800px;"></div>
		<script type="text/javascript">
	
				jQuery(document).ready(function($){
					window.view_settings = {};
	
					function loadFilteredProposals(){
						$("#TableContainer").jtable("load", {
							organisation: $("#organisation").val(),
						});
					}
	
				    //Prepare jTable
					$("#TableContainer").jtable({
						paging: true,
						pageSize: 10,
						sorting: true,
						defaultSorting: "pid ASC",
						actions: {
							listAction: moduleUrl + "actions/proposal_actions.php?action=list_my_offers"
						},
						fields: {
							pid: {
								key: true,
		    					create: false,
		    					edit: false,
		    					list: false
							},
							pr_title: {
								title: "Project",
								width: "49%",
								display: function (data) {
									return "<a title=\"View proposal details\" href=\"javascript:void(0);\" onclick=\"getProposalDetail("+data.record.proposal_id+")\">"
											+ data.record.pr_title+"</a>";
									},
							},
							o_name: {
								title: "Organisation",
								width: "35%",
								display: function (data){return data.record.o_name;}
							},
							accept_col : {
								width: "6%",
		    					title: "Accept",
								sorting: false,
		    					display: function (data) {
									return "<a title=\"Accept this offer\" href=\"javascript:void(0);\" "+
										"onclick=\"acceptProjectOffer("+data.record.proposal_id+",'"+data.record.pr_title+"', "+data.record.pid+")\">"+
											"<span class=\"ui-icon ui-icon-star\">accept</span></a>";
		    					},
	
		    					create: false,
		    					edit: false
							},
	
						},
					});
	
					//Load proposal list from server on initial page load
					loadFilteredProposals();
	
					$("#organisation").change(function(e) {
		           		e.preventDefault();
		           		loadFilteredProposals();
		        	});
	
					$("#proposal_filter").submit(function(e){
						e.preventDefault();
						loadFilteredProposals()
					});
	
				});
			</script><?php 
}