Exemple #1
0
    public function definition() {
        global $USER, $CFG, $PAGE;
        $school = new school();
        $mform = $this->_form;
        $id = $this->_customdata['id'];
        $schools = $this->_customdata['tool'];
        $editoroptions = $this->_customdata['editoroptions'];
        if ($id < 0)
            $mform->addElement('header', 'settingsheader', get_string('createschool', 'local_collegestructure'));
        else
            $mform->addElement('header', 'settingsheader', get_string('editschool', 'local_collegestructure'));
        $tools = array();
        $hierarchy = new hierarchy();
        $items = $hierarchy->get_school_items(true);
        $parents = $hierarchy->get_school_parent($items, $schools->id);
        if (count($parents) <= 1) {
            $mform->addElement('hidden', 'parentid', 0);
            $mform->setType('parentid', PARAM_RAW);
        } else {
            $mform->addElement('select', 'parentid', get_string('parent', 'local_collegestructure'), $parents);
            $mform->setType('parentid', PARAM_RAW);
        }
        $mform->addHelpButton('parentid', 'parent', 'local_collegestructure');
        $mform->addElement('text', 'fullname', get_string('schoolname', 'local_collegestructure'), $tools);
        $mform->setType('fullname', PARAM_TEXT);
        $mform->addRule('fullname', get_string('missingschoolname', 'local_collegestructure'), 'required', null, 'client');

        $mform->addElement('editor', 'description', get_string('description', 'local_collegestructure'), null, $editoroptions);
        $mform->setType('description', PARAM_RAW);

        $selecttype = array();
        $selecttype['1'] = get_string('campus', 'local_collegestructure');
        $selecttype['2'] = get_string('university', 'local_collegestructure');
        $selecttype['3'] = get_string('location', 'local_collegestructure');
        $mform->addElement('select', 'type', get_string('type', 'local_collegestructure'), $selecttype);
        $mform->addHelpButton('type', 'type', 'local_collegestructure');
        $mform->setType('type', PARAM_RAW);
        $mform->addElement('hidden', 'id');
        $mform->setType('id', PARAM_INT);
        $now = date("d-m-Y");
        $now = strtotime($now);
        $mform->addElement('hidden', 'timecreated', $now);
        $mform->setType('timecreated', PARAM_RAW);
        $mform->addElement('hidden', 'usermodified', $USER->id);
        $mform->setType('usermodified', PARAM_RAW);
        $themelist = $school->cobalt_get_theme_list();
        $mform->addElement('select', 'theme', get_string('theme', 'local_collegestructure'), $themelist);
        $mform->setType('theme', PARAM_RAW);
        $mform->addRule('theme', get_string('missingtheme', 'local_collegestructure'), 'required', null, 'client');
        $submit = ($id > 0) ? get_string('update_school', 'local_collegestructure') : get_string('create', 'local_collegestructure');
        $this->add_action_buttons('false', $submit);
    }
Exemple #2
0
<?php

$page_title = 'Barangay System';
$stylesheet_link = 'style';
require 'path.php';
init_cobalt();
require 'header1.php';
require 'components/get_listview_referrer.php';
$username = $_SESSION['user'];
require_once 'subclasses/citizen.php';
$dbh_citizen1 = new citizen();
$citizen = $dbh_citizen1->execute_query("SELECT city FROM citizen WHERE username='******'")->result;
extract($citizen->fetch_assoc());
$city_citizen = $city;
require_once 'subclasses/school.php';
$dbh_school = new school();
$dbh_school->execute_query("SELECT * FROM school WHERE city = {$city_citizen}");
$result1 = $dbh_school->result;
?>
<main>
<div class="block-body">
<div class="fold-2">
	<h3 class="fold-2-head center-obj fold-head">Mga lugar sa Ating Barangay</h3>
	<hr class="hr"/>
<?php 
//echo $city_citizen;
while ($row1 = $result1->fetch_assoc()) {
    extract($row1);
    echo '<li>';
    echo $school_name;
    echo '</li>';
Exemple #3
0
<?php

include "php/user.php";
include "php/manager.php";
include "php/school.php";
include "php/security.php";
$login = new user();
$manager = new manager();
$school = new school();
$sec = new security();
$logincheck = $login->islogin();
if ($logincheck != 1) {
    header("location: index.php");
} else {
    if ($_SERVER['REQUEST_METHOD'] == "POST") {
        if (isset($_POST['schoolid'])) {
            $schoolid = $_POST['schoolid'];
            $managerid = $_POST['managerid'];
            $shift = $_POST['shift'];
            $school->addmanagertoschool($managerid, $schoolid, $shift);
            header("location: schools.php");
        }
    }
    if ($_SERVER['REQUEST_METHOD'] == "GET") {
        if (isset($_GET['schoolid']) & isset($_GET['shift'])) {
            $schoolid = $sec->escape($_GET['schoolid']);
            $shift = $sec->escape($_GET['shift']);
            $schoolresult = $school->getschoolbyid($schoolid);
            if ($schoolresult->num_rows == 1) {
                $schoolrow = $schoolresult->fetch_assoc();
                $managerresult = $manager->getmanagers();
Exemple #4
0
<?php

include "php/security.php";
include "php/school.php";
include "php/user.php";
$login = new user();
$logincheck = $login->islogin();
if ($logincheck != 1) {
    header("location: index.php");
    die;
}
$school = new school();
$sec = new security();
$name;
$address;
$telephone;
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    if (isset($_GET['id'])) {
        $result = $school->getschoolbyid($_GET['id']);
        $row = $result->fetch_assoc();
        $name = $row['Sname'];
        $address = $row['Address'];
        $telephone = $row['Telephone'];
    }
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $id = $sec->escape($_POST['schoolid']);
    $schoolname = $sec->escape($_POST["schoolname"]);
    $schoollength = $sec->checknullwithoutwhitespace($schoolname);
    $schooladdress = $sec->escape($_POST["schooladdress"]);
    $schooltel = $sec->escape($_POST["schooltel"]);
Exemple #5
0
    /**
     * @method update_plan
     * @todo Update the details of the existing plans
     * @param  $plan(array)
     * */
    function update_plan($planid, $newplan) {
        global $DB, $CFG;
        $hierarchy = new hierarchy();
        $planupdate = new school();
        $oldplan = $DB->get_record('local_curriculum_plan', array('id' => $planid));
        $currenturl = "{$CFG->wwwroot}/local/curriculum/index.php";
        //check if the parentid is the same as that of new parentid
        if ($newplan->parentid != $oldplan->parentid) {
            $newparentid = $newplan->parentid;
            $newplan->parentid = $oldplan->parentid;
        }
        $now = date("d-m-Y");
        $now = strtotime($now);
        $newplan->timemodified = $now;

        $updated = $DB->update_record('local_curriculum_plan', $newplan);

        if (isset($newparentid)) {
            $updatedplan = $DB->get_record('local_curriculum_plan', array('id' => $planid));
            $newparentid = isset($newparentid) ? $newparentid : 0;
            //if the new parentid is different then update 
            $updated = $planupdate->update_school($updatedplan, $newparentid, 'local_curriculum_plan');
        }
        return $updated;
      
    }
Exemple #6
0
/**
 * List the tool provided in a course
 *
 * @package    local
 * @subpackage collegestructure
 * @copyright  2012 Niranjan <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once(dirname(__FILE__) . '/../../config.php');
global $CFG, $USER, $PAGE;
require_once($CFG->dirroot . '/local/lib.php');
require_once($CFG->dirroot . '/local/collegestructure/lib.php');
$systemcontext = context_system::instance();
require_login();
$school = new school();
if (!has_capability('local/collegestructure:manage', $systemcontext)) {
    $returnurl = new moodle_url('/local/error.php');

    redirect($returnurl);
}
/* ---get the admin layout--- */
$PAGE->set_pagelayout('admin');
/* ---check the context level of the user and check weather the user is login to the system or not--- */
$PAGE->set_context($systemcontext);
$PAGE->set_url('/local/collegestructure/info.php');
/* ---Header and the navigation bar--- */
$PAGE->set_title(get_string('manageschools', 'local_collegestructure'));
$PAGE->navbar->add(get_string('manageschools', 'local_collegestructure'), new moodle_url('/local/collegestructure/index.php'));
$PAGE->navbar->add(get_string('info', 'local_collegestructure'));
echo $OUTPUT->header();
Exemple #7
0
//****************************************************************************************
//Generated by Cobalt, a rapid application development framework. http://cobalt.jvroig.com
//Cobalt developed by JV Roig (jvroig@jvroig.com)
//****************************************************************************************
require 'path.php';
init_cobalt('Edit school');
if (isset($_GET['school_id'])) {
    $school_id = urldecode($_GET['school_id']);
    require 'form_data_school.php';
}
if (xsrf_guard()) {
    init_var($_POST['btn_cancel']);
    init_var($_POST['btn_submit']);
    require 'components/query_string_standard.php';
    require 'subclasses/school.php';
    $dbh_school = new school();
    $object_name = 'dbh_school';
    require 'components/create_form_data.php';
    extract($arr_form_data);
    if ($_POST['btn_cancel']) {
        log_action('Pressed cancel button');
        redirect("listview_school.php?{$query_string}");
    }
    if ($_POST['btn_submit']) {
        log_action('Pressed submit button');
        $message .= $dbh_school->sanitize($arr_form_data)->lst_error;
        extract($arr_form_data);
        if ($dbh_school->check_uniqueness_for_editing($arr_form_data)->is_unique) {
            //Good, no duplicate in database
        } else {
            $message = "Record already exists with the same primary identifiers!";
require 'path.php';
init_cobalt('Delete school');
if (isset($_GET['school_id'])) {
    $school_id = urldecode($_GET['school_id']);
    require_once 'form_data_school.php';
}
if (xsrf_guard()) {
    init_var($_POST['btn_cancel']);
    init_var($_POST['btn_delete']);
    require 'components/query_string_standard.php';
    if ($_POST['btn_cancel']) {
        log_action('Pressed cancel button');
        redirect("listview_school.php?{$query_string}");
    } elseif ($_POST['btn_delete']) {
        log_action('Pressed delete button');
        require_once 'subclasses/school.php';
        $dbh_school = new school();
        $object_name = 'dbh_school';
        require 'components/create_form_data.php';
        $dbh_school->delete($arr_form_data);
        redirect("listview_school.php?{$query_string}");
    }
}
require 'subclasses/school_html.php';
$html = new school_html();
$html->draw_header('Delete School', $message, $message_type);
$html->draw_listview_referrer_info($filter_field_used, $filter_used, $page_from, $filter_sort_asc, $filter_sort_desc);
$html->draw_hidden('school_id');
$html->detail_view = TRUE;
$html->draw_controls('delete');
$html->draw_footer();
Exemple #9
0
<?php

//****************************************************************************************
//Generated by Cobalt, a rapid application development framework. http://cobalt.jvroig.com
//Cobalt developed by JV Roig (jvroig@jvroig.com)
//****************************************************************************************
require 'path.php';
init_cobalt('Add school');
require 'components/get_listview_referrer.php';
if (xsrf_guard()) {
    init_var($_POST['btn_cancel']);
    init_var($_POST['btn_submit']);
    require 'components/query_string_standard.php';
    require 'subclasses/school.php';
    $dbh_school = new school();
    $object_name = 'dbh_school';
    require 'components/create_form_data.php';
    extract($arr_form_data);
    if ($_POST['btn_cancel']) {
        log_action('Pressed cancel button');
        redirect("listview_school.php?{$query_string}");
    }
    if ($_POST['btn_submit']) {
        log_action('Pressed submit button');
        $message .= $dbh_school->sanitize($arr_form_data)->lst_error;
        extract($arr_form_data);
        if ($dbh_school->check_uniqueness($arr_form_data)->is_unique) {
            //Good, no duplicate in database
        } else {
            $message = "Record already exists with the same primary identifiers!";
        }
Exemple #10
0
//Generated by Cobalt, a rapid application development framework. http://cobalt.jvroig.com
//Cobalt developed by JV Roig (jvroig@jvroig.com)
//****************************************************************************************
require 'path.php';
init_cobalt('View school');
if (xsrf_guard()) {
    init_var($_POST['btn_cancel']);
    init_var($_POST['btn_submit']);
    if ($_POST['btn_cancel']) {
        log_action('Pressed cancel button');
        redirect("listview_school.php");
    }
    if ($_POST['btn_submit']) {
        log_action('Pressed submit button');
        require 'subclasses/school.php';
        $dbh_school = new school();
        if ($message == "") {
            log_action('Exported table data to CSV');
            $timestamp = date('Y-m-d');
            $token = generate_token(0, 'fs');
            $csv_name = $token . $_SESSION['user'] . '_school_' . $timestamp . '.csv';
            $filename = TMP_DIRECTORY . '/' . $csv_name;
            $csv_contents = $dbh_school->export_to_csv();
            $csv_file = fopen($filename, "wb");
            fwrite($csv_file, $csv_contents);
            fclose($csv_file);
            chmod($filename, 0755);
            $csv_name = urlencode($csv_name);
            $message = 'CSV file successfully generated: <a href="/' . BASE_DIRECTORY . '/download_generic.php?filename=' . $csv_name . '">Download the CSV file.</a>';
            $message_type = 'system';
        }
Exemple #11
0
<?php

include "php/school.php";
include "php/user.php";
include "php/security.php";
include "php/manager.php";
$login = new user();
$school = new school();
$sec = new security();
$manager = new manager();
$logincheck = $login->islogin();
if ($logincheck != 1) {
    header("location: index.php");
}
if (isset($_GET['id'])) {
    $school->removeschool($_GET['id']);
    $error = "مدرسه با موفقیت حذف شد";
}
if (isset($_GET['error'])) {
    $error = $_GET['error'];
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $schoolname = $sec->escape($_POST["schoolname"]);
    $schoollength = $sec->checknullwithoutwhitespace($schoolname);
    $schooladdress = $sec->escape($_POST["schooladdress"]);
    $schooltel = $sec->escape($_POST["schooltel"]);
    if ($schoollength != 0) {
        $ans = $school->addschool($schoolname, $schooladdress, $schooltel);
        if ($ans == 0) {
            $error = "نام مدرسه نباید تکراری باشد";
        } else {
Exemple #12
0
    redirect($returnurl);
}
/* ---check the context level of the user and check weather the user is login to the system or not--- */
$PAGE->set_context($systemcontext);
$PAGE->set_title(get_string('assignregistrar_title', 'local_collegestructure'));
$PAGE->set_heading($SITE->fullname);
$PAGE->navbar->add(get_string('manageschools', 'local_collegestructure'), "/local/collegestructure/index.php", get_string('viewusers', 'local_collegestructure'));
$PAGE->navbar->add(get_string('assignusers', 'local_collegestructure'));
$PAGE->set_url(new moodle_url('/local/collegestructure/assignusers.php', array('id' => $schoolids)));
$PAGE->set_pagelayout('admin');
echo $OUTPUT->header();

$returnurl = new moodle_url('/local/collegestructure/assignusers.php', array('id' => $schoolids));
$hierarche = new hierarchy();
$school = new school();
/* ---Adding the users to the school --- */
/* ---when Registrar select the users to the school and submits to assign users--- */
if (!empty($moveto) and $data = data_submitted()) {

    if (!$destschool = $DB->get_record('local_school', array('id' => $data->moveto))) {
        print_error('cannotfindschool', '', '', $data->moveto);
    }
    /*
     * ###Bugreport #189-Assign Regsitrar
     * @author Naveen Kumar<*****@*****.**>
     * (Resolved) Removed success message from the loop, So that it won't redirect
     */
    $currenturl = "{$CFG->wwwroot}/local/collegestructure/assignusers.php";
    if (empty($data)) {
        $hierarche->set_confirmation(get_string('pleaseselectschool', 'local_collegestructure'), $currenturl);
 public static function getSchoolByEmail($email)
 {
     $db = Connection::getInstance();
     $mysqli = $db->getConnection();
     $query = "select * from school where email='{$email}';";
     $result = $mysqli->query($query);
     $school = new school();
     if ($result->num_rows > 0) {
         if ($row = $result->fetch_assoc()) {
             $school->setSchool_id($row["schoolId"]);
             $school->setSchool_name($row["name"]);
             $school->setMale_percentage($row["malePercentage"]);
             $school->setCategory($row["category"]);
             $school->setSinhala_percentage($row["sinhalaPercentage"]);
             $school->setContact_no($row["contactNumber"]);
             $school->setNo_of_classes($row["noofClasses"]);
             $school->setEmail($row["email"]);
             $school->setPassword($row["password"]);
             $schools[] = $school;
         }
     }
     return $school;
 }
Exemple #14
0
<?php

$page_title = 'Barangay System';
$stylesheet_link = 'style';
require 'path.php';
init_cobalt();
require 'header1.php';
require 'components/get_listview_referrer.php';
$username = $_SESSION['user'];
require_once 'subclasses/citizen.php';
$dbh_citizen1 = new citizen();
$citizen = $dbh_citizen1->execute_query("SELECT city FROM citizen WHERE username='******'")->result;
extract($citizen->fetch_assoc());
$city_citizen = $city;
require_once 'subclasses/school.php';
$dbh_school = new school();
$dbh_school->execute_query("SELECT * FROM school WHERE city = {$city_citizen} && is_evacuation = 'Yes'");
$result1 = $dbh_school->result;
?>
<main>
<div class="block-body">
<div class="fold-2">
	<h3 class="fold-2-head center-obj fold-head">Mga lugar sa Ating Barangay</h3>
	<hr class="hr"/>
<?php 
//echo $city_citizen;
while ($row1 = $result1->fetch_assoc()) {
    extract($row1);
    echo '<li>';
    echo $school_name;
    echo '</li>';
Exemple #15
0
require_once($CFG->dirroot . '/local/collegestructure/school_form.php');

$id = optional_param('id', -1, PARAM_INT);    // user id; -1 if creating new tool
$userid = optional_param('userid', 0, PARAM_INT);
$delete = optional_param('delete', 0, PARAM_BOOL);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
$hide = optional_param('hide', 0, PARAM_INT);
$show = optional_param('show', 0, PARAM_INT);
$visible = optional_param('visible', -1, PARAM_INT);
$unassign = optional_param('unassign', 0, PARAM_BOOL);
$hierarchy = new hierarchy();
$conf = new object();
/* ---First level of checking--- */
require_login();
$school = new school();

/* ---checking the course exists or not--- */
if ($id > 0) {

    if (!($tool = $DB->get_record('local_school', array('id' => $id)))) {
        print_error('invalidtoolid1122', 'local_collegestructure');
    }
} else {
    $tool = new stdClass();
    $tool->id = -1;
}


$PAGE->set_url('/local/collegestructure/school.php', array('id' => $id));
$systemcontext = context_system::instance();
Exemple #16
0
 *
 * @package    local
 * @subpackage collegestructure
 * @copyright  2012 Niranjan <*****@*****.**>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once(dirname(__FILE__) . '/../../config.php');
global $CFG, $USER, $PAGE;
require_once($CFG->dirroot . '/local/lib.php');
require_once($CFG->dirroot . '/local/collegestructure/lib.php');
$id = optional_param('id', 0, PARAM_INT);
$flat = optional_param('flat', 0, PARAM_INT);
$page = optional_param('page', 0, PARAM_INT);
$systemcontext = context_system::instance();
require_login();
$school = new school();
if (!has_capability('local/collegestructure:manage', $systemcontext)) {
    $returnurl = new moodle_url('/local/error.php');
    redirect($returnurl);
}
/* ---get the admin layout--- */
$PAGE->set_pagelayout('admin');
/* ---check the context level of the user and check weather the user is login to the system or not--- */
$PAGE->set_context($systemcontext);
$currentcss = '/local/collegestructure/css/styles.css';
$PAGE->requires->css($currentcss);
$PAGE->set_url('/local/collegestructure/index.php');
/* ---Header and the navigation bar--- */
$PAGE->set_heading(get_string('manageschools', 'local_collegestructure'));
$PAGE->navbar->add(get_string('manageschools', 'local_collegestructure'), new moodle_url('/local/collegestructure/index.php'));
$PAGE->navbar->add(get_string('view', 'local_collegestructure'));
Exemple #17
0
        $this->show();
        return $this;
    }
    public function go()
    {
        $this->command = 'go';
        $this->show();
        return $this;
    }
}
$car = new car();
$car->start()->go();
include_once "config.php";
include_once "school.class.php";
//echo "<pre>";print_r($array);echo "</pre>";
$school = new school();
/*Добавить книгу*/
//$school->addBook('Первое чудо');
/*Добавить автора*/
//$school->addAuthor('Герман');
/*Добавить студента*/
//$school->addStudent('Генадий');
/*Установить связь книги с автором*/
//$school->setBookOfAuthor(7,1);
/*книги 1-7, Авторы 1-5*/
// Студент взял книгу ID Студента и ID книги
// Студенты 1-6, Книги 1-7
//$school->studentGiveBook(5,4);
$school->getMostPopularAuthor();
$school->getBooks();
/*echo "<pre>";
 public static function calculateschool()
 {
     $db = Connection::getInstance();
     $mysqli = $db->getConnection();
     $query1 = "select * from school;";
     $result1 = $mysqli->query($query1);
     $schools = array();
     $calculatedschools = array();
     if ($result1->num_rows > 0) {
         while ($row = $result1->fetch_assoc()) {
             $school_no;
             $school = new school();
             $school->setSchool_id($row["schoolId"]);
             $school_no = $row["schoolId"];
             $school->setSchool_name($row["name"]);
             $school->setMale_percentage($row["malePercentage"]);
             $school->setCategory($row["category"]);
             $school->setSinhala_percentage($row["sinhalaPercentage"]);
             $school->setContact_no($row["contactNumber"]);
             $school->setNo_of_classes($row["noofClasses"]);
             $capacity;
             $capacity = $row["noofClasses"] * 40;
             $school->setEmail($row["email"]);
             $school->setPassword($row["password"]);
             $schools[] = $school;
             //get all application ids
             //$length=sizeof($Applications);
             for ($t = 1; $t < 7; $t++) {
                 for ($m = 1; $m < 7; $m++) {
                     $Applications[] = array();
                     $i = 0;
                     $query4 = "select * from Application where typeOfApplication='{$m}' and orderOfPreference='{$t}' and schoolId='{$school_no}' and isverified='1'";
                     $result4 = $mysqli->query($query4);
                     if ($result4->num_rows > 0) {
                         while ($row = $result4->fetch_assoc()) {
                             if (!in_array($row["application_id"], $calculatedschools)) {
                                 $Applications[$i] = $row["application_id"];
                                 $i++;
                             }
                         }
                     }
                     $length = sizeof($Applications);
                     //save marks in array
                     $Application_Marks[] = array();
                     //final list of scools in descenting order  of marks
                     $schoolselectids[] = array();
                     /////errrroooooooorrrrrrrrrrrrrrrr
                     if ($result4->num_rows > 0) {
                         // do one thing{
                         for ($x = 0; $x < sizeof($Applications); $x++) {
                             $id = $Applications[$x];
                             if ($t == 1) {
                                 $query = "select * from close_proximity_mark where application_id='{$id}'";
                                 $result = $mysqli->query($query);
                                 $capacityquota = $capacity * 0.5;
                             } elseif ($t == 2) {
                                 $query = "select * from pastpupil_mark where application_id='{$id}'";
                                 $result = $mysqli->query($query);
                                 $capacityquota = $capacity * 0.25;
                             } elseif ($t == 3) {
                                 $query = "select * from current_student_mark where application_id='{$id}'";
                                 $result = $mysqli->query($query);
                                 $capacityquota = $capacity * 0.15;
                             } elseif ($t == 4) {
                                 $query = "select * from educational_staff_mark where application_id='{$id}'";
                                 $result = $mysqli->query($query);
                                 $capacityquota = $capacity * 0.05;
                             } elseif ($t == 5) {
                                 $query = "select * from officer_on_transfer_mark where application_id='{$id}'";
                                 $result = $mysqli->query($query);
                                 $capacityquota = $capacity * 0.04;
                             } elseif ($t == 6) {
                                 $query = "select * from person_abroad_mark where application_id='{$id}'";
                                 $result = $mysqli->query($query);
                                 $capacityquota = $capacity * 0.01;
                             }
                             if ($result->num_rows > 0) {
                                 if ($row = $result->fetch_assoc()) {
                                     if ($t == 1) {
                                         $total = $row["no_of_years_live_35"] + $row["residence_proof_10"] + $row["res_proof_other_5"] + $row["closeness_50"];
                                     }
                                     if ($t == 2) {
                                         $total = $row["no_learnt_grades"] + $row["achievement_mark"] + $row["co_curricular_mark"] + $row["contribution_mark"];
                                     }
                                     if ($t == 3) {
                                         $total = $row["no_learnt_grades"] + $row["no_living_years"] + $row["closeness_mark"] + $row["residence_proof_mark"] + $row["contribution_mark"];
                                     }
                                     if ($t == 4) {
                                         $total = $row["no_working_years"] + $row["distance_mark"] + $row["difficult_service_mark"] + $row["unutilized_leave_mark"] + $row["if_in_same_school_mark"];
                                     }
                                     if ($t == 5) {
                                         $total = $row["distance_on_trans_mark"] + $row["closeness_mark"] + $row["no_serving_years"] + $row["no_serving_years"] + $row["unutilized_leave_mark"];
                                     }
                                     if ($t == 6) {
                                         $total = $row["time_in_abroad"] + $row["reason_of_transfer"] + $row["closeness_mark"];
                                     }
                                     $Application_Marks[$x] = $total;
                                 }
                             } else {
                                 var_dump('');
                             }
                         }
                         $length = sizeof($Application_Marks);
                         for ($x = 0; $x < $length; $x++) {
                             $max_key = -1;
                             $max_val = -1;
                             for ($y = 0; $y < $length; $y++) {
                                 if ($Application_Marks[$y] > $max_val) {
                                     $max_val = $Application_Marks[$y];
                                     $max_key = $y;
                                 }
                             }
                             $schoolselectids[$x] = $Applications[$max_key];
                             var_dump($schoolselectids[$x]);
                             $Application_Marks[$max_key] = 0;
                         }
                         if ($capacityquota > $length) {
                             $capacityquota = $length;
                         }
                         for ($x = 0; $x < $capacityquota; $x++) {
                             $id = $schoolselectids[$x];
                             $calculatedschools[] = $id;
                             $query = "select applicantId from  Application where application_id='{$id}'";
                             $result = $mysqli->query($query);
                             $applicant_no;
                             if ($result->num_rows > 0) {
                                 if ($row = $result->fetch_assoc()) {
                                     $applicant_no = $row["applicantId"];
                                 }
                             }
                             $query = "UPDATE studentApplicant SET selectedSchoolId='{$school_no}' WHERE applicantId={$applicant_no}";
                             $mysqli->query($query);
                         }
                         unset($Applications);
                         unset($Application_Marks);
                         unset($schoolselectids);
                     } else {
                         unset($Applications);
                         unset($Application_Marks);
                         unset($schoolselectids);
                     }
                 }
             }
         }
     }
 }
 public function postAddschool()
 {
     $schoolid = Input::get('schoolidtext');
     $schoolname = Input::get('schoolnametext');
     $category = Input::get('category');
     $no_of_classes = Input::get('capacitytext');
     $contact_number = Input::get('contacttext');
     $male_per = Input::get('malepertext');
     $sinhala_per = Input::get('sinhalapertext');
     $email = Input::get('emailtext');
     $password = Input::get('passwordtext');
     $school = new school();
     $school->setSchool_id($schoolid);
     $school->setSchool_name($schoolname);
     $school->setCategory($category);
     $school->setContact_no($contact_number);
     $school->setNo_of_classes($no_of_classes);
     $school->setMale_percentage($male_per);
     $school->setSinhala_percentage($sinhala_per);
     $school->setEmail($email);
     //$school->setPassword(Hash::make($password));
     $school->setPassword($password);
     $result = DBSchoolController::addSchool($school);
     if ($result) {
         return View::make('G1SAS/adminpage')->with('title', 'School added successfully');
     } else {
         return View::make('G1SAS/adminpage')->with('title', 'School was not added');
     }
 }