Ejemplo n.º 1
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         School::create([]);
     }
 }
Ejemplo n.º 2
0
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($id = 1; $id < 19; $id++) {
         School::create(['user_id' => $id, 'primary_name' => $faker->randomElement(['Jose Rizal University', 'Rizal Techonological University', 'La Salle', 'Ateneo de Manila', 'San Sebastian College', 'University of the Philippines', 'University of Santo Tomas']), 'primary_address' => $faker->streetAddress, 'primary_years' => '', 'secondary_name' => $faker->randomElement(['Jose Rizal University', 'Rizal Techonological University', 'La Salle', 'Ateneo de Manila', 'San Sebastian College', 'University of the Philippines', 'University of Santo Tomas']), 'secondary_address' => $faker->streetAddress, 'secondary_years' => '', 'tertiary_name' => $faker->randomElement(['Jose Rizal University', 'Rizal Techonological University', 'La Salle', 'Ateneo de Manila', 'San Sebastian College', 'University of the Philippines', 'University of Santo Tomas']), 'tertiary_address' => $faker->streetAddress, 'tertiary_years' => '']);
     }
 }
Ejemplo n.º 3
0
function _ops_update()
{
    $OID = max(0, intval($_POST['OID']));
    $CID = max(0, intval($_POST['CID']));
    $msg = "";
    loginRequireMgmt();
    if (!loginCheckPermission(USER::MGMT_SCHOOL)) {
        redirect("errors/401");
    }
    $itemName = "School";
    $urlPrefix = "mgmt_school";
    $object = new School();
    if ($OID) {
        $object->retrieve($OID, $CID);
        if (!$object->exists()) {
            $msg = "{$itemName} not found!";
        } else {
            transactionBegin();
            $object->merge($_POST);
            if ($object->update()) {
                transactionCommit();
                $msg = "{$itemName} updated!";
            } else {
                transactionRollback();
                $msg = "{$itemName} update failed";
            }
        }
    } else {
        $object->merge($_POST);
        transactionBegin();
        if ($object->create()) {
            transactionCommit();
            $msg = "{$itemName} created!";
        } else {
            transactionRollback();
            $msg = "{$itemName} Create failed";
        }
    }
    redirect("{$urlPrefix}/manage", $msg);
}
Ejemplo n.º 4
0
 public function postRegister()
 {
     $validator = Validator::make(Input::all(), User::$rules);
     if ($validator->fails()) {
         return Redirect::route('register')->withErrors($validator)->withInput();
     }
     $user = User::create(['firstname' => Input::get('firstname'), 'middlename' => Input::get('middlename'), 'lastname' => Input::get('lastname'), 'email' => Input::get('email'), 'username' => Input::get('username'), 'password' => Hash::make(Input::get('password')), 'department_id' => Input::get('department_id'), 'birthday' => Input::get('birthday'), 'birthplace' => Input::get('birthplace'), 'gender' => Input::get('gender'), 'civilstatus' => Input::get('civilstatus'), 'citizenship' => Input::get('citizenship'), 'height' => Input::get('height'), 'weight' => Input::get('weight'), 'bloodtype' => Input::get('bloodtype'), 'datehired' => Input::get('datehired'), 'pos_id' => Input::get('pos_id'), 'status' => Input::get('status')]);
     // $user->department()->attach(Input::get('department_id'));
     $lastid = User::orderBy('id', 'desc')->first();
     $contacts = ContactInfo::create(['user_id' => $lastid->id, 'homenum' => Input::get('homenum'), 'officenum' => Input::get('officenum'), 'mobilenum' => Input::get('mobilenum'), 'street' => Input::get('street'), 'city' => Input::get('city')]);
     $commonid = CommonId::create(['user_id' => $lastid->id, 'tin' => input::get('taxid'), 'philhealth' => input::get('philhealth'), 'pagibig' => input::get('pagibig'), 'sss' => input::get('sss'), 'gsisbp' => input::get('gsisbp'), 'gsispolicy' => input::get('gsispol'), 'gsisoptional' => input::get('gsisopt'), 'educplan' => input::get('educplan')]);
     $father = Parents::create(['user_id' => $lastid->id, 'parent_id' => Input::get('fatherid'), 'firstname' => Input::get('fatherfirstname'), 'middlename' => Input::get('fathermiddlename'), 'lastname' => Input::get('fatherlastname'), 'address' => Input::get('fatheraddress')]);
     $mother = Parents::create(['user_id' => $lastid->id, 'parent_id' => Input::get('motherid'), 'firstname' => Input::get('motherfirstname'), 'middlename' => Input::get('mothermiddlename'), 'lastname' => Input::get('motherlastname'), 'address' => Input::get('motheraddress')]);
     $vacleave = LeaveBalance::create(['user_id' => $lastid->id, 'balance' => 1.25, 'leavetype_id' => 1]);
     $sickleave = LeaveBalance::create(['user_id' => $lastid->id, 'balance' => 1.25, 'leavetype_id' => 2]);
     $patleave = LeaveBalance::create(['user_id' => $lastid->id, 'leavetype_id' => 3]);
     $patleave = LeaveBalance::create(['user_id' => $lastid->id, 'leavetype_id' => 4]);
     $birthleave = LeaveBalance::create(['user_id' => $lastid->id, 'leavetype_id' => 5]);
     $school = School::create(['user_id' => $lastid->id]);
     $evalpoints = EvaluatePoints::create(['user_id' => $lastid->id]);
     $audit = AuditTrail::create(['user_id' => Auth::id(), 'role' => 'Employee Management Admin', 'action' => 'registered a new EMPLOYEE "' . $lastid->firstname . ' ' . $lastid->lastname . '".']);
     return Redirect::route('register')->with('alert', 'success|' . $user->formatName(':fn :mi :ln') . ' has been registered successfully.');
 }
Ejemplo n.º 5
0
function doInsert()
{
    if (isset($_POST['save'])) {
        $NAME = $_POST['name'];
        $SHORTNAME = $_POST['shortname'];
        $ADDRESS = $_POST['address'];
        $TELEPHONE = $_POST['telephone'];
        $FAX = $_POST['fax'];
        $DIRECTLINE = $_POST['directline'];
        $EMAIL = $_POST['email'];
        $WEBSITE = $_POST['website'];
        $FACEBOOK = $_POST['facebook'];
        $TWEETER = $_POST['tweeter'];
        $GPLUS = $_POST['gplus'];
        $YOUTUBE = $_POST['youtube'];
        $LINKEDIN = $_POST['linkedin'];
        $SKYPE = $_POST['skype'];
        $BUREAU = $_POST['bureau'];
        $EXTENSION = $_POST['extension'];
        $school = new School();
        $school->extension = $EXTENSION;
        $school->name = $NAME;
        $school->shortname = $SHORTNAME;
        $school->address = $ADDRESS;
        $school->telephone = $TELEPHONE;
        $school->fax = $FAX;
        $school->directline = $DIRECTLINE;
        $school->email = $EMAIL;
        $school->website = $WEBSITE;
        $school->tweeter = $TWEETER;
        $school->facebook = $FACEBOOK;
        $school->gplus = $GPLUS;
        $school->youtube = $YOUTUBE;
        $school->linkedin = $LINKEDIN;
        $school->skype = $SKYPE;
        $school->bureau_id = $BUREAU;
    }
    if ($NAME == "") {
        message('Name is required!', "error");
        redirect('index.php?view=add');
    } elseif ($SHORTNAME == "") {
        message('Short Name is required!', "error");
        redirect('index.php?view=add');
    } elseif ($ADDRESS == "") {
        message('Short Name is required!', "error");
        redirect('index.php?view=add');
    } elseif ($EXTENSION == "") {
        message('Extension is required!', "error");
        redirect('index.php?view=add');
    } elseif ($TELEPHONE == "") {
        message('Telephone is required!', "error");
        redirect('index.php?view=add');
    } elseif ($FAX == "") {
        message('Fax is required!', "error");
        redirect('index.php?view=add');
    } elseif ($DIRECTLINE == "") {
        message('Directline is required!', "error");
        redirect('index.php?view=add');
    } elseif ($EMAIL == "") {
        message('Email is required!', "error");
        redirect('index.php?view=add');
    } elseif ($WEBSITE == "") {
        message('Website is required!', "error");
        redirect('index.php?view=add');
    } elseif ($TWEETER == "") {
        message('Tweeter is required!', "error");
        redirect('index.php?view=add');
    } elseif ($FACEBOOK == "") {
        message('Facebook ID is required!', "error");
        redirect('index.php?view=add');
    } elseif ($GPLUS == "") {
        message('Gplus is required!', "error");
        redirect('index.php?view=add');
    } elseif ($YOUTUBE == "") {
        message('Youtube is required!', "error");
        redirect('index.php?view=add');
    } elseif ($LINKEDIN == "") {
        message('Linkedin is required!', "error");
        redirect('index.php?view=add');
    } elseif ($SKYPE == "") {
        message('Skype is required!', "error");
        redirect('index.php?view=add');
    } elseif ($BUREAU == "") {
        message('Bureau is required!', "error");
        redirect('index.php?view=add');
    } else {
        $school->create();
        message('New school addedd successfully!', "success");
        redirect('index.php?view=list');
    }
}
Ejemplo n.º 6
0
 $object->about = $_POST['about'];
 $object->address = $_POST['address'];
 $object->comments = $_POST['comments'];
 $object->fbcomments = $_POST['fbcomments'];
 $object->history = $_POST['history'];
 $object->visionmission = $_POST['visionmission'];
 $object->corevalues = $_POST['corevalues'];
 $file = new File($_FILES['logo']);
 if ($file->valid) {
     $object->logo = $file->data;
 }
 $file = new File($_FILES['cover']);
 if ($file->valid) {
     $object->picture = $file->data;
 }
 $object->create();
 $schooluser = new SchoolUser();
 $schooluser->schoolid = $object->id;
 $schooluser->userid = $session->user_id;
 $schooluser->level = 1;
 $schooluser->role = "admin";
 $schooluser->enabled = 1;
 $schooluser->pending = 0;
 $schooluser->create();
 $folder_path = "../../public/schools/";
 mkdir($folder_path . $object->id . "/", 0700);
 // schoolid folder
 mkdir($folder_path . $object->id . "/yearbooks/", 0700);
 // yearbook folder
 $log = new Log($session->user_id, $clientip, "WEB", "CREATED SCHOOL: " . $object->id);
 $log->create();
Ejemplo n.º 7
0
require_once "../../includes/initialize.php";
global $session;
if (!$session->is_logged_in()) {
    redirect_to("../../index.php");
}
if ($_POST['oper'] == 'add') {
    $school = new School();
    $school->comments = $_POST['comments'];
    $school->pending = $_POST['pending'];
    $school->enabled = $_POST['enabled'];
    $school->name = $_POST['name'];
    $school->address = $_POST['address'];
    $school->email = $_POST['email'];
    $school->number = $_POST['number'];
    $school->about = $_POST['about'];
    $school->create();
    $schooluser = new SchoolUser();
    $schooluser->pending = 0;
    $schooluser->enabled = 1;
    $schooluser->schoolid = $school->id;
    $schooluser->userid = $session->user_id;
    $schooluser->level = 1;
    $schooluser->create();
    $folder_path = "../../public/schools/";
    mkdir($folder_path . $school->id . "/", 0700);
    // schoolid folder
    mkdir($folder_path . $school->id . "/yearbooks/", 0700);
    // yearbook folder
    $log = new Log($session->user_id, $clientip, "WEB", "CREATED SCHOOL: " . $_POST['id']);
    $log->create();
} else {
Ejemplo n.º 8
0
function _resetdb()
{
    if (!isset($_POST['dataOption'])) {
        echo "error";
        exit;
    }
    $dataOption = $_POST['dataOption'];
    try {
        $dbh = getdbh();
        $list = explode(",", "v_leaderboard_main,v_ext_ranks,v_leaderboard_ext");
        foreach ($list as $view) {
            dropView($dbh, $view);
        }
        //
        //  rPI challenge data
        //
        $list = explode(",", "t_cts_data,t_fsl_data,t_hmb_data,t_cpa_data,t_ext_data");
        foreach ($list as $table) {
            dropTable($dbh, $table);
        }
        $list = explode(",", "t_event,t_user,t_rpi,t_station,t_stationtype,t_team,t_school");
        foreach ($list as $table) {
            dropTable($dbh, $table);
        }
        create_t_user($dbh);
        create_t_stationtype($dbh);
        create_t_station($dbh);
        create_t_school($dbh);
        create_t_team($dbh);
        create_t_event($dbh);
        create_t_rpi($dbh);
        create_v_leaderboard_main($dbh);
        create_v_ext_ranks($dbh);
        create_v_leaderboard_ext($dbh);
        //
        //  rPI challenge data
        //
        create_t_cts_data($dbh);
        create_t_fsl_data($dbh);
        create_t_hmb_data($dbh);
        create_t_cpa_data($dbh);
        create_t_ext_data($dbh);
        $admin = new User();
        $admin->set('username', "admin");
        $admin->setPassword('pass');
        $admin->set('email', "*****@*****.**");
        $admin->set('fullname', "administrator");
        $admin->setRoll(USER::ROLL_ADMIN);
        $admin->create();
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_REG, "Register", false, 60, "Hello! You have been successfully registered and may start the competition. Good luck!", "If you see this message there was an internal error 1", "If you see this message there was an internal error 2", "If you see this message there was an internal error 3");
        if ($stationType === false) {
            echo "Create StationType REG failed";
        } else {
            createStations(1, "reg", $stationType->get('OID'));
        }
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_CTS, "Crack The Safe", true, 60, "Welcome, Team! Your first assignment is to break into Professor Aardvark's safe where you will find the first clue to his Secret Laboratory. Measure the interior angles and pick the three correct angles for the safe combination. Good luck! [clue=[clue]]", "Success! Go quickly to the next team queue.", "You have failed the challenge. Go quickly to the next team queue.", "No luck, better try again!");
        $numStations = $dataOption == 1 ? 1 : 6;
        if ($stationType === false) {
            echo "Create StationType CTS failed";
        } else {
            createStations($numStations, "cts", $stationType->get('OID'));
        }
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_FSL, "Find Secret Lab", false, 60, "Find and scan the [ordinal] at [waypoint-lat=[lat]] [waypoint-lon=[lng]].", "Success! Find and scan the [ordinal] marker at [waypoint-lat=[lat]] [waypoint-lon=[lng]].", "Too bad, you failed. Find and scan the [ordinal] marker at [waypoint-lat=[lat]] [waypoint-lon=[lng]].", "Wrong marker, try again!");
        if ($stationType === false) {
            echo "Create StationType FSL failed";
        } else {
            createStations(1, "fsl", $stationType->get('OID'));
        }
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_HMB, "Defuse Hypermutation Bomb", true, 60, "The HMB has been triggered! Send the Energy Pulsator cycle time quickly!", "Success! Go quickly to the next team queue.", "Oops. Enough said. Go quickly to the next team queue.", "Nope, better try again!");
        $numStations = $dataOption == 1 ? 1 : 6;
        if ($stationType === false) {
            echo "Create StationType HMB failed";
        } else {
            createStations($numStations, "hmb", $stationType->get('OID'));
        }
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_CPA, "Catch Provessor Aardvark", true, 2000, "PA is trying to escape. Quickly measure the [fence=label] [building=[label]] and scan Start QR Code.", "Watch now as the professor attempts to escape. Get him!", "Success! Go quickly to the team finish area.", "Professor Aardvark has escaped. Oh well. Go quickly to the team finish area.", "Miss! Try again!");
        $numStations = $dataOption == 1 ? 1 : 6;
        if ($stationType === false) {
            echo "Create StationType CPA failed";
        } else {
            createStations($numStations, "cpa", $stationType->get('OID'));
        }
        $stationType = StationType::makeStationType(StationType::STATION_TYPE_EXT, "Extra", false, 60, "You have 20 (TBR) minutes to provide the tower location and height. Good luck." . " [waypoint1-lat=[a_lat]] [waypoint1-lon=[a_lng]]" . " [waypoint2-lat=[b_lat]] [waypoint2-lon=[b_lng]]" . " [waypoint3-lat=[c_lat]] [waypoint3-lon=[c_lng]]", "Message received, return to base", "M didn't understand your message", "If you see this message there was an internal error 5");
        if ($stationType === false) {
            echo "Create StationType EXT failed";
        } else {
            createStations(1, "ext", $stationType->get('OID'));
        }
        if ($dataOption == 0) {
            redirect('mgmt_main', 'Database Initialized without test data!');
            return;
        }
        // generate test data
        // for ($i=1;$i < 21; $i++) {
        //  $user = new User();
        //  $user->set('username','user'.$i);
        //  $user->setPassword('pass'.$i);
        //  $user->set('email','email'.$i."@harris.com");
        //  $user->set('fullname','User #'.$i);
        //  if ($user->create()===false) echo "Create user $i failed";
        // }
        // keep an equal number of each of these items.
        $mascots = explode(",", "Unencoded,Encoded,Unencoded,Encoded,Unencoded,Encoded,Unencoded,Encoded,Unencoded,Encoded,Unencoded,Encoded,Unencoded,Encoded");
        $schools = explode(",", "Titusville HS,Edgewood Jr/Sr HS,Holy Trinity,West Shore Jr/Sr HS,Melbourne HS,Palm Bay Magnet HS,Bayside HS");
        // keep twice as many name&pins we will populate 2 teams / school
        $names = explode(",", "team1,team2,team3,team4,team5,team6,team7,team8,team9,team10,team11,team12,team13,team14");
        $pins = explode(",", "00001,00002,00003,00004,00005,00006,00007,00008,00009,00010,00011,00012,00013,00014");
        // always make the schools
        $numSchools = count($schools);
        for ($i = 0; $i < $numSchools; $i++) {
            $school = new School();
            $school->set("name", $schools[$i]);
            $school->set("mascot", $mascots[$i]);
            if ($school->create() === false) {
                echo "Create School {$i} failed";
            }
            $schools[$i] = $school->get('OID');
            // replace school name with OID for next part
        }
        // TODO always make the teams with random ids
        $numTeams = $dataOption == 1 ? 2 : count($names);
        for ($i = 0; $i < $numTeams; $i++) {
            $team = new Team();
            $team->set("name", $names[$i]);
            $team->set("schoolId", $schools[$i / 2]);
            /*use OID from previous step two teams / school */
            $team->set("pin", $pins[$i]);
            // to test ext we need special test data
            $team->set('extDuration', $i * 100);
            $team->set('towerH', $i);
            $team->set('towerD', $i);
            if ($team->create() === false) {
                echo "Create team {$i} failed";
            }
        }
        for ($i = 1; $i <= ($dataOption == 1 ? 1 : 5); $i++) {
            $cts = new CTSData();
            $station = Station::getFromTag("cts0" . $i);
            if ($station === false) {
                break;
            }
            $cts->set('stationId', $station->get('OID'));
            // hack assume get works
            if (isStudentServer() && $i == 1) {
                $cts->set('_1st', 39);
                $cts->set('_2nd', 57);
                $cts->set('_3rd', 13);
                $cts->set('_4th', 23);
                $cts->set('_5th', 48);
            } else {
                $cts->set('_1st', 10 + $i);
                $cts->set('_2nd', 20 + $i);
                $cts->set('_3rd', 30 + $i);
                $cts->set('_4th', 40 + $i);
                $cts->set('_5th', 50 + $i);
            }
            $cts->set('tolerance', 5.0);
            if ($cts->create() === false) {
                echo "Create CTS {$i} failed";
            }
        }
        for ($i = 1; $i <= ($dataOption == 1 ? 1 : 5); $i++) {
            $cpa = new CPAData();
            $station = Station::getFromTag("cpa0" . $i);
            if ($station === false) {
                break;
            }
            $cpa->set('stationId', $station->get('OID'));
            // hack assume get works
            if ($i == 1) {
                $cpa->set('label', $i);
                $cpa->set('fence', 240);
                $cpa->set('building', 127);
                $cpa->set('sum', 367);
            } else {
                $cpa->set('label', $i);
                $cpa->set('fence', 240 + $i);
                $cpa->set('building', 127 - $i);
                $cpa->set('sum', 367);
            }
            if ($cpa->create() === false) {
                echo "Create CTA {$i} failed";
            }
        }
        $hmb = new HMBData();
        $hmb->set('_1st_on', 1);
        $hmb->set('_1st_off', 1);
        $hmb->set('_2nd_on', 1);
        $hmb->set('_2nd_off', 10);
        $hmb->set('_3rd_on', 1);
        $hmb->set('_3rd_off', 22);
        $hmb->set('cycle', 506);
        if ($hmb->create() === false) {
            echo "Create HMB {$i} failed";
        }
        $fsl_data = array(array("1", +28.030924, -80.601834, "1", +28.032708, -80.600032, "1", +28.03167, -80.59855899999999, "1", +28.031062, -80.600013, 665.8, 600.1, 574.6), array("1", +28.030924, -80.601834, "1", +28.032708, -80.600032, "1", +28.03167, -80.59855899999999, "2", +28.030975, -80.60010699999999, 629.9, 632.4, 618.6), array("1", +28.030924, -80.601834, "1", +28.032708, -80.600032, "1", +28.03167, -80.59855899999999, "3", +28.030859, -80.60001800000001, 662.5, 674.1, 608.6));
        for ($i = 0; $i < count($fsl_data); $i++) {
            $fsl = new FSLData();
            $fsl->set('a_tag', $fsl_data[$i][0]);
            $fsl->set('a_lat', $fsl_data[$i][1]);
            $fsl->set('a_lng', $fsl_data[$i][2]);
            $fsl->set('b_tag', $fsl_data[$i][3]);
            $fsl->set('b_lat', $fsl_data[$i][4]);
            $fsl->set('b_lng', $fsl_data[$i][5]);
            $fsl->set('c_tag', $fsl_data[$i][6]);
            $fsl->set('c_lat', $fsl_data[$i][7]);
            $fsl->set('c_lng', $fsl_data[$i][8]);
            $fsl->set('l_tag', $fsl_data[$i][9]);
            $fsl->set('l_lat', $fsl_data[$i][10]);
            $fsl->set('l_lng', $fsl_data[$i][11]);
            $fsl->set('a_rad', $fsl_data[$i][12]);
            $fsl->set('b_rad', $fsl_data[$i][13]);
            $fsl->set('c_rad', $fsl_data[$i][14]);
            if ($fsl->create() === false) {
                echo "Create FSLData {$i} failed";
            }
        }
        $ext = new EXTData();
        $ext->set('a_lat', +28.031848);
        $ext->set('a_lng', -80.600938);
        $ext->set('b_lat', +28.031695);
        $ext->set('b_lng', -80.600413);
        $ext->set('c_lat', +28.031579);
        $ext->set('c_lng', -80.60087300000001);
        $ext->set('t_lat', +28.031698);
        $ext->set('t_lng', -80.60075500000001);
        $ext->set('height', 102);
        if ($ext->create() === false) {
            echo "Create EXTData {$i} failed";
        }
        redirect('mgmt_main', 'Database Initialized test data!');
    } catch (ErrorInfo $e) {
        echo $e->getMessage();
        die;
    }
}
Ejemplo n.º 9
0
 /**
  * Store a newly created school in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), School::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     School::create($data);
     return Redirect::route('schools.index');
 }