Ejemplo n.º 1
0
 /** The constructor
  * @access public
  * @param array $options
  * @return void
  */
 public function __construct(array $options = null)
 {
     $users = new Users();
     $users_options = $users->getOptions();
     $countries = new Countries();
     $countries_options = $countries->getOptions();
     $counties = new OsCounties();
     $county_options = $counties->getCountiesID();
     $activities = new PrimaryActivities();
     $activities_options = $activities->getTerms();
     $organisations = new Organisations();
     $organisations_options = $organisations->getOrgs();
     parent::__construct($options);
     $this->setName('people');
     $title = new Zend_Form_Element_Select('title');
     $title->setLabel('Title: ')->addFilters(array('StripTags', 'StringTrim'))->setValue('Mr')->addErrorMessage('Choose title of person')->setAttrib('class', 'span2 selectpicker show-menu-arrow')->addMultiOptions(array('Mr' => 'Mr', 'Mrs' => 'Mrs', 'Miss' => 'Miss', 'Ms' => 'Ms', 'Dr' => 'Dr.', 'Prof' => 'Prof.', 'Sir' => 'Sir', 'Lord' => 'Lord', 'Lady' => 'Lady', 'Other' => 'Other', 'Captain' => 'Captain', 'Master' => 'Master', 'Dame' => 'Dame', 'Duke' => 'Duke', 'Admiral' => 'Admiral', 'Baron' => 'Baron', 'Baroness' => 'Baroness', 'Brigadier' => 'Brigadier', 'Captain' => 'Captain', 'Colonel' => 'Colonel', 'Colonel Sir' => 'Colonel Sir', 'Commander' => 'Commander', 'Commodore' => 'Commodore', 'Countess' => 'Countess', 'Earl' => 'Earl', 'Field Marshal Lord' => 'Field Marshal Lord', 'General' => 'General', 'Group Captain' => 'Group Captain', 'Lieutenant' => 'Lieutenant', 'Lieutenant Commander' => 'Lieutenant Commander', 'Lt-Col' => 'Lt-Col', 'Lt-Gen Sir' => 'Lt-Gen Sir', 'Maj-Gen' => 'Maj-Gen', 'Major' => 'Major', 'Prince' => 'Prince', 'Princesss' => 'Princess', 'Rear Admiral' => 'Rear Admiral', 'Squadron Leader' => 'Squadron Leader', 'The Baroness' => 'The Baroness', 'The Countess' => 'The Countess', 'The Countess of' => 'The Countess of', 'The Duchess of' => 'The Duchess of', 'The Duke of' => 'The Duke of', 'The Earl of' => 'The Earl of', 'The Hon' => 'The Hon', 'His Honour Judge' => 'His Honour Judge', 'The Hon Mrs' => 'The Hon Mrs', 'The Marchioness of' => 'The Marchioness of', 'The Marquess of' => 'The Marquess of', 'The Viscount' => 'The Viscount', 'The Viscountess' => 'The Viscountess', 'Wing Commander' => 'Wing Commander', 'The Reverend' => 'The Reverend', 'Archbishop' => 'Archbishop', 'Canon' => 'Canon', 'Bishop' => 'Bishop'));
     $forename = new Zend_Form_Element_Text('forename');
     $forename->setLabel('Forename: ')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter person\'s forename')->addFilter(new Zend_Filter_Callback(array('callback' => 'ucfirst')));
     $surname = new Zend_Form_Element_Text('surname');
     $surname->setLabel('Surname: ')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addFilter(new Zend_Filter_Callback(array('callback' => 'ucfirst')))->addErrorMessage('Please enter person\'s surname');
     $fullname = new Zend_Form_Element_Text('fullname');
     $fullname->setLabel('Fullname: ')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter person\'s fullname');
     $email = new Zend_Form_Element_Text('email');
     $email->SetLabel('Email address: ')->addFilters(array('StringTrim', 'StringToLower', 'StripTags'))->addValidator('StringLength', false, array(1, 200))->addValidator('EmailAddress', false, array('mx' => true))->setAttrib('size', '60');
     $dbaseID = new Zend_Form_Element_Select('dbaseID');
     $dbaseID->setLabel('User account: ')->addFilters(array('StripTags', 'StringTrim'))->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addValidator('Int')->addValidator('InArray', false, array(array_keys($users_options), null))->addMultiOptions(array(null => 'Choose a user account', 'Existing accounts' => $users_options))->addErrorMessage('You must enter a database account.');
     $canRecord = $this->addElement('checkbox', 'canRecord', array('label' => 'Allowed to record: '))->canRecord;
     $address = new Zend_Form_Element_Text('address');
     $address->SetLabel('Address: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addValidator('StringLength', false, array(1, 500));
     $town_city = new Zend_Form_Element_Text('town_city');
     $town_city->SetLabel('Town: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addValidator('StringLength', false, array(1, 200));
     $countyID = new Zend_Form_Element_Select('countyID');
     $countyID->setLabel('County: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addMultiOptions(array(null => 'Please choose a county', 'Valid counties' => $county_options));
     $postcode = new Zend_Form_Element_Text('postcode');
     $postcode->SetLabel('Postcode: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim', 'StringToUpper', 'Purifier'))->addValidator('StringLength', false, array(1, 200))->addValidator('ValidPostCode');
     $country = new Zend_Form_Element_Select('country');
     $country->SetLabel('Country: ')->addFilters(array('StripTags', 'StringTrim'))->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addValidator('StringLength', false, array(1, 4))->addValidator('InArray', false, array(array_keys($countries_options)))->addMultiOptions(array(null => 'Please choose a country of residence', 'Valid countries' => $countries_options))->setValue('GB');
     $hometel = new Zend_Form_Element_Text('hometel');
     $hometel->SetLabel('Home telephone number: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addValidator('StringLength', false, array(1, 30));
     $worktel = new Zend_Form_Element_Text('worktel');
     $worktel->SetLabel('Work telephone number: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addValidator('StringLength', false, array(1, 30));
     $fax = new Zend_Form_Element_Text('faxno');
     $fax->SetLabel('Fax number: ')->addFilters(array('StripTags', 'StringTrim', 'Purifier'))->addValidator('StringLength', false, array(1, 30));
     $comments = new Pas_Form_Element_CKEditor('comments');
     $comments->SetLabel('Comments: ')->setAttrib('rows', 10)->setAttrib('cols', 40)->setAttrib('Height', 400)->setAttrib('ToolbarSet', 'Finds')->addFilters(array('StringTrim', 'BasicHtml', 'EmptyParagraph', 'WordChars'));
     $organisationID = new Zend_Form_Element_Select('organisationID');
     $organisationID->SetLabel('Organisation attached to: ')->addFilters(array('StripTags', 'StringTrim'))->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addMultiOptions(array(null => 'Please choose an organisation', 'Valid organisations' => $organisations_options))->addValidator('InArray', false, array(array_keys($organisations_options)));
     $primary_activity = new Zend_Form_Element_Select('primary_activity');
     $primary_activity->SetLabel('Person\'s primary activity: ')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->setAttrib('class', 'input-xxlarge selectpicker show-menu-arrow')->addValidator('Int')->addValidator('InArray', false, array(array_keys($activities_options)))->addMultiOptions(array(null => 'Choose a primary activity', 'Valid activities' => $activities_options))->addErrorMessage('You must enter an activity for this person.');
     $submit = new Zend_Form_Element_Submit('submit');
     $this->addElements(array($title, $forename, $surname, $fullname, $email, $address, $town_city, $countyID, $postcode, $country, $dbaseID, $canRecord, $hometel, $worktel, $fax, $comments, $organisationID, $primary_activity, $submit));
     $this->addDisplayGroup(array('title', 'forename', 'surname', 'fullname', 'email', 'address', 'town_city', 'countyID', 'postcode', 'country', 'dbaseID', 'canRecord', 'hometel', 'worktel', 'faxno', 'comments', 'organisationID', 'primary_activity'), 'details');
     $this->details->setLegend('Person details: ');
     $this->addDisplayGroup(array('submit'), 'buttons');
     parent::init();
 }
Ejemplo n.º 2
0
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Ejemplo n.º 3
0
 public function __construct($options = null)
 {
     $users = new Users();
     $users_options = $users->getOptions();
     $countries = new Countries();
     $countries_options = $countries->getOptions();
     $counties = new Counties();
     $counties_options = $counties->getCountyname2();
     $activities = new PrimaryActivities();
     $activities_options = $activities->getTerms();
     $organisations = new Organisations();
     $organisations_options = $organisations->getOrgs();
     parent::__construct($options);
     $this->addElementPrefixPath('Pas_Validate', 'Pas/Validate/', 'validate');
     $this->setName('people');
     $decorators = array(array('ViewHelper'), array('Description', array('placement' => 'append', 'class' => 'info')), array('Errors', array('placement' => 'append', 'class' => 'error', 'tag' => 'li')), array('Label'), array('HtmlTag', array('tag' => 'li')));
     $title = new Zend_Form_Element_Select('title');
     $title->setLabel('Title: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->setValue('Mr')->addErrorMessage('Choose title of person')->addMultiOptions(array('Mr' => 'Mr', 'Mrs' => 'Mrs', 'Miss' => 'Miss', 'Ms' => 'Ms', 'Dr' => 'Dr.', 'Prof' => 'Prof.', 'Sir' => 'Sir', 'Lady' => 'Lady', 'Other' => 'Other', 'Captain' => 'Captain', 'Master' => 'Master', 'Dame' => 'Dame', 'Duke' => 'Duke'))->setDecorators($decorators);
     $forename = new Zend_Form_Element_Text('forename');
     $forename->setLabel('Forename: ')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter person\'s forename')->setDecorators($decorators)->addFilter(new Zend_Filter_Callback(array('callback' => 'ucfirst')));
     $surname = new Zend_Form_Element_Text('surname');
     $surname->setLabel('Surname: ')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addFilter(new Zend_Filter_Callback(array('callback' => 'ucfirst')))->addErrorMessage('Please enter person\'s surname')->setDecorators($decorators);
     $fullname = new Zend_Form_Element_Text('fullname');
     $fullname->setLabel('Fullname: ')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addErrorMessage('Please enter person\'s fullname')->setDecorators($decorators);
     $email = new Zend_Form_Element_Text('email');
     $email->SetLabel('Email address: ')->setRequired(false)->addFilters(array('StringTrim', 'StringToLower', 'StripTags'))->addValidator('StringLength', false, array(1, 200))->addValidator('EmailAddress', false, array('mx' => true))->setAttrib('size', '60')->setDecorators($decorators);
     $dbaseID = new Zend_Form_Element_Select('dbaseID');
     $dbaseID->setLabel('User account: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Int')->addValidator('InArray', false, array(array_keys($users_options), null))->addMultiOptions(array(NULL => 'Choose a user account', 'Existing accounts' => $users_options))->addErrorMessage('You must enter a database account.')->setDecorators($decorators);
     $address = new Zend_Form_Element_Text('address');
     $address->SetLabel('Address: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addValidator('StringLength', false, array(1, 200))->setDecorators($decorators)->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     $town_city = new Zend_Form_Element_Text('town_city');
     $town_city->SetLabel('Town: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addValidator('StringLength', false, array(1, 200))->setDecorators($decorators)->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     $county = new Zend_Form_Element_Select('county');
     $county->setLabel('County: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Please choose a county', 'Valid counties' => $counties_options))->setDecorators($decorators)->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     $postcode = new Zend_Form_Element_Text('postcode');
     $postcode->SetLabel('Postcode: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim', 'StringToUpper'))->addValidator('StringLength', false, array(1, 200))->addValidator('ValidPostCode')->setDecorators($decorators)->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     $country = new Zend_Form_Element_Select('country');
     $country->SetLabel('Country: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addValidator('StringLength', false, array(1, 4))->addValidator('InArray', false, array(array_keys($countries_options)))->addMultiOptions(array(NULL => 'Please choose a country of residence', 'Valid countries' => $countries_options))->setValue('GB')->setDecorators($decorators);
     $hometel = new Zend_Form_Element_Text('hometel');
     $hometel->SetLabel('Home telephone number: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addValidator('StringLength', false, array(1, 30))->setDecorators($decorators)->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     $worktel = new Zend_Form_Element_Text('worktel');
     $worktel->SetLabel('Work telephone number: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addValidator('StringLength', false, array(1, 30))->setDecorators($decorators)->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     $fax = new Zend_Form_Element_Text('faxno');
     $fax->SetLabel('Fax number: ')->addFilters(array('StripTags', 'StringTrim'))->addValidator('StringLength', false, array(1, 30))->setDecorators($decorators)->addValidator('Alnum', false, array('allowWhiteSpace' => true));
     $comments = new Pas_Form_Element_RTE('comments');
     $comments->SetLabel('Comments: ')->setRequired(false)->setAttrib('rows', 10)->setAttrib('cols', 40)->setAttrib('Height', 400)->setAttrib('ToolbarSet', 'Finds')->addFilters(array('StringTrim', 'BasicHtml', 'EmptyParagraph', 'WordChars'));
     $organisationID = new Zend_Form_Element_Select('organisationID');
     $organisationID->SetLabel('Organisation attached to: ')->setRequired(false)->addFilters(array('StripTags', 'StringTrim'))->addMultiOptions(array(NULL => 'Please choose an organisation', 'Valid organisations' => $organisations_options))->addValidator('InArray', false, array(array_keys($organisations_options)))->setDecorators($decorators);
     $primary_activity = new Zend_Form_Element_Select('primary_activity');
     $primary_activity->SetLabel('Person\'s primary activity: ')->setRequired(true)->addFilters(array('StripTags', 'StringTrim'))->addValidator('Int')->addValidator('InArray', false, array(array_keys($activities_options)))->addMultiOptions(array(NULL => 'Choose a primary activity', 'Valid activities' => $activities_options))->addErrorMessage('You must enter an activity for this person.')->setDecorators($decorators);
     $submit = new Zend_Form_Element_Submit('submit');
     $submit->setAttrib('id', 'submitbutton')->removeDecorator('label')->removeDecorator('HtmlTag')->removeDecorator('DtDdWrapper')->setAttrib('class', 'large');
     $this->addElements(array($title, $forename, $surname, $fullname, $email, $address, $town_city, $county, $postcode, $country, $dbaseID, $hometel, $worktel, $fax, $comments, $organisationID, $primary_activity, $submit));
     $hash = new Zend_Form_Element_Hash('csrf');
     $hash->setValue($this->_config->form->salt)->removeDecorator('DtDdWrapper')->removeDecorator('HtmlTag')->removeDecorator('label')->setTimeout(4800);
     $this->addElement($hash);
     $this->addDisplayGroup(array('title', 'forename', 'surname', 'fullname', 'email', 'address', 'town_city', 'county', 'postcode', 'country', 'dbaseID', 'hometel', 'worktel', 'faxno', 'comments', 'organisationID', 'primary_activity'), 'details');
     $this->details->setLegend('Person details: ');
     $this->addDisplayGroup(array('submit'), 'submit');
     $this->details->removeDecorator('DtDdWrapper');
     $this->details->addDecorators(array('FormElements', array('HtmlTag', array('tag' => 'ul'))));
 }
Ejemplo n.º 4
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'];
}
Ejemplo n.º 5
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 
}
Ejemplo n.º 6
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 {
        }
    }
}
Ejemplo n.º 7
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;
 }
Ejemplo n.º 8
0
 public function organisationAction()
 {
     $orgs = new Organisations();
     $orgsjson = $orgs->getOrgNames($this->_getParam('q'));
     echo Zend_Json::encode($orgsjson);
 }
Ejemplo n.º 9
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>";
}
 /** Delete an organisation
  */
 public function deleteAction()
 {
     if ($this->_getParam('id', false)) {
         if ($this->_request->isPost()) {
             $id = (int) $this->_request->getPost('id');
             $del = $this->_request->getPost('del');
             if ($del == 'Yes' && $id > 0) {
                 $organisations = new Organisations();
                 $where = 'id = ' . $id;
                 $organisations->delete($where);
             }
             $this->_flashMessenger->addMessage('Record deleted!');
             $this->_redirect(self::REDIRECT);
         } else {
             $id = (int) $this->_request->getParam('id');
             if ($id > 0) {
                 $this->view->organisation = $this->_organisations->fetchRow('id=' . $id);
             }
         }
     } else {
         throw new Pas_Exception_Param($this->_missingParameter);
     }
 }
Ejemplo n.º 11
0
		<tfoot>
			<tr>
				<td style="padding-top: 25px;" colspan="3"><input class="btn" type="submit" name="show_table" id="show_table_btn" value="Show Table"/></td>
			</tr>
		</tfoot>
		<tbody>
		<tr>
			<td>&nbsp;</td>
			<td><label for="associated_organisation_id" class="form-required"><?php 
    echo $translate->translate("Organisation");
    ?>
</label></td>
			<td>
				<select id="associated_organisation_id" name="associated_organisation_id" style="width: 203px">
					<?php 
    $organisations = Organisations::get();
    if ($organisations) {
        foreach ($organisations as $organisation) {
            $organisation_id = $organisation->getID();
            if ($ENTRADA_ACL->amIAllowed('resourceorganisation' . $organisation_id, 'create')) {
                $organisation_title = $organisation->getTitle();
                echo build_option($organisation_id, html_encode($organisation_title), $ORGANISATION_ID == $organisation_id);
            }
        }
    }
    ?>
				</select>
			</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
Ejemplo n.º 12
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 
}