示例#1
0
 function delete($id)
 {
     $agency = new Agency($id);
     $agency->delete();
     set_notify('success', lang('delete_data_complete'));
     redirect('agenies/admin/agenies');
 }
 public static function getRoutes(Agency $agency, $version = 0)
 {
     /**
      * @var DB
      */
     $dbObj = DBPool::getInstance();
     $version = $version == 0 ? TableUpdate::getVersion() : $version;
     $dbObj->bindParams(array($agency->getId(), $version));
     $routes = $dbObj->get_results("SELECT * FROM route WHERE agency_id=?\n            AND version = ? ORDER BY position");
     if ($dbObj->num_rows > 0) {
         $routeArray = array();
         foreach ($routes as $r) {
             $routeObj = new Route();
             $routeObj->setId($r->id);
             $routeObj->setAgency($agency);
             $routeObj->setTag($r->tag);
             $routeObj->setColor($r->color);
             $routeObj->setTitle($r->title);
             $routeObj->setShortTitle($r->short_title);
             $routeObj->setLatMin($r->lat_min);
             $routeObj->setLatMax($r->lat_max);
             $routeObj->setLonMin($r->lon_min);
             $routeObj->setLonMax($r->lon_max);
             $routeObj->setVehicleType($r->vehicle_type);
             $routeObj->setPosition($r->position);
             $routeArray[$r->tag] = $routeObj;
         }
         return $routeArray;
     } else {
         //TODO: Don't use a generic exception
         throw new Exception("No data available - Route::getRoutes");
     }
 }
 public static function getStops(Agency $agency, $version = 0)
 {
     /**
      * @var DB
      */
     $dbObj = DBPool::getInstance();
     $version = $version == 0 ? TableUpdate::getVersion() : $version;
     $dbObj->bindParams(array($agency->getId(), TableUpdate::getVersion()));
     $stops = $dbObj->get_results("SELECT * FROM stop WHERE agency_id=?\n            AND version = ?");
     if ($dbObj->num_rows > 0) {
         $stopArray = array();
         foreach ($stops as $s) {
             $stopObj = new Stop();
             $stopObj->setId($s->id);
             $stopObj->setAgency($agency);
             $stopObj->setFlipStopTag($s->flip_stop_tag);
             $stopObj->setTag($s->tag);
             $stopObj->setTitle($s->title);
             $stopObj->setPrettyTitle($s->pretty_title);
             $stopObj->setLatitude($s->latitude);
             $stopObj->setLongitude($s->longitude);
             $stopArray[$s->tag] = $stopObj;
         }
         return $stopArray;
     } else {
         //TODO: Don't use a generic exception
         throw new Exception("No data available - Stop::getStops");
     }
 }
示例#4
0
 public function getDataByAgencyId($agencycode)
 {
     $agency_obj = new Agency();
     $rs_agency_info = $agency_obj->getAgecyInfoByCode($agencycode);
     $agencydata_obj = new DataPrivacy();
     $rs = $agencydata_obj->getDataByAgencyId($rs_agency_info[0]->id);
     return View::make('requestdata.ajax_databyagency')->with('all_data', $rs);
 }
示例#5
0
 public function checkAgency($code)
 {
     $rs = Agency::where('code', '=', $code)->count();
     if (isset($rs)) {
         return $rs >= 1 ? false : true;
     }
 }
示例#6
0
 public function delete()
 {
     $id = Input::get('id');
     $agency = Agency::find($id);
     $agency->delete();
     return "Agency Deleted.";
 }
 /**
  * Add the routes to the database
  * @param array $routes - Array of Route objects
  */
 protected function add(array $routes)
 {
     $insertCnt = 0;
     $version = TableUpdate::getVersion();
     foreach ($routes as $r) {
         //Add the mandatory columns
         $columns = array('agency_id', 'tag', 'color', 'title', 'short_title', 'vehicle_type', 'version', 'position');
         $boundParams = array($this->agency->getId(), $r->getTag(), $r->getColor(), $r->getTitle(), $r->getShortTitle(), $r->getVehicleType(), $version, $r->getPosition());
         $columnCnt = count($columns);
         //Check and add the optional columns
         if ($r->getLatMin()) {
             $columns[] = 'lat_min';
             $boundParams[] = $r->getLatMin();
             $columnCnt++;
         }
         if ($r->getLatMax()) {
             $columns[] = 'lat_max';
             $boundParams[] = $r->getLatMax();
             $columnCnt++;
         }
         if ($r->getLonMin()) {
             $columns[] = 'lon_min';
             $boundParams[] = $r->getLonMin();
             $columnCnt++;
         }
         if ($r->getLonMax()) {
             $columns[] = 'lon_max';
             $boundParams[] = $r->getLonMax();
             $columnCnt++;
         }
         $this->dbObj->bindParams($boundParams);
         //var_dump($boundParams);
         $query = "INSERT INTO route (" . implode(",", $columns) . ", created_date)\n                VALUES (" . implode(",", array_fill(0, $columnCnt, "?")) . ", NOW())";
         $this->dbObj->query($query);
         if ($this->dbObj->rows_affected != 1) {
             //$this->dbObj->debug();exit;
             throw new DBException("Addition of route failed [agency:" . $this->agency->getId() . "] [route tag:" . $r->getTag() . "] [route title:" . $r->getTitle() . "]");
         }
         $insertCnt++;
     }
     //TODO: Add a log for the total number of rows added
     //Write the changes to the change log
     $this->saveChangesToFile();
 }
 private function getVehicleTypeOverride()
 {
     $agencyShortTitle = $this->agency->getShortTitle();
     $config = $this->appConfig;
     $filePath = $config['sfmuni_vehicle_override'];
     //TODO: Check for exception
     $xmlObjBuilder = new XmlObjBuilder($filePath);
     $xml = $xmlObjBuilder->getXmlObj();
     $vehicleOverrides = array();
     //We only support SF-Muni for now
     if ($agencyShortTitle == "sf-muni") {
         foreach ($xml->route as $r) {
             $routeTag = (string) $r['tag'];
             $vehicleType = (string) $r['vehicle'];
             $vehicleOverrides[$routeTag] = $vehicleType;
         }
     }
     return $vehicleOverrides;
 }
 public static function getAgencies()
 {
     $dbObj = DBPool::getInstance();
     $agencies = $dbObj->get_results("SELECT * FROM agency");
     if ($dbObj->num_rows > 0) {
         $agencyArray = array();
         foreach ($agencies as $a) {
             $agencyObj = new Agency();
             $agencyObj->setId($a->id);
             $agencyObj->setTitle($a->title);
             $agencyObj->setShortTitle($a->short_title);
             $agencyObj->setDefaultVehicleType($a->default_vehicle);
             $agencyArray[$a->short_title] = $agencyObj;
         }
         return $agencyArray;
     } else {
         throw new Exception("There are no agencies in the database");
     }
 }
 protected function add(array $stops)
 {
     //var_dump($stops);exit;
     $insertCnt = 0;
     $version = TableUpdate::getVersion();
     foreach ($stops as $s) {
         $boundParams = array($this->agency->getId(), $s->getTag(), $s->getLatitude(), $s->getLongitude(), $s->getTitle(), $this->getPrettyTitle($s->getTitle()), $s->getFlipStopTag(), $version);
         $this->dbObj->bindParams($boundParams);
         $query = "INSERT INTO stop (agency_id, tag, latitude, longitude, \n                title, pretty_title, flip_stop_tag, version, created_date)\n                VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW())";
         $this->dbObj->query($query);
         if ($this->dbObj->rows_affected != 1) {
             //$this->dbObj->debug();exit;
             throw new DBException("Addition of stop failed [agency:" . $this->agency->getId() . "] [stop tag:" . $s->getTag() . "]");
         }
         $insertCnt++;
     }
     //TODO: Add a log for the total number of stops added
     //Write the changes to the change log
     $this->saveChangesToFile();
 }
function getRoutes(Agency $agency, $version)
{
    $dbObj = DBPool::getInstance();
    $routeArray = array();
    $finalRouteArray = array();
    //Get the routes
    $dbObj->bindParams(array($version, $agency->getId()));
    $routes = $dbObj->get_results("SELECT b.tag AS routetag, a.tag AS dirtag\n                                    FROM direction as a, route as b\n                                    WHERE a.route_id=b.id\n                                        AND a.use_for_ui=true\n                                        AND a.version=?\n                                        AND b.agency_id=?\n                                    ORDER BY b.tag;");
    if ($dbObj->num_rows > 0) {
        foreach ($routes as $r) {
            $routeTag = (string) $r->routetag;
            $routeArray[$routeTag][] = (string) $r->dirtag;
        }
        //Pick only the ones with more than 2 directions
        foreach ($routeArray as $routeTag => $dirs) {
            if (count($dirs) > 2) {
                $finalRouteArray[$routeTag] = $dirs;
            }
        }
    }
    return $finalRouteArray;
}
示例#12
0
 public function postUpdateagency()
 {
     $id = Input::get('id');
     $agency = Agency::find($id);
     $agency->name = Input::get('name');
     $agency->email = Input::get('email');
     $agency->mobile = Input::get('mobile');
     $agency->city = Input::get('city');
     $agency->address1 = Input::get('address1');
     $agency->address2 = Input::get('address2');
     $agency->commission = Input::get('commission');
     $agency->save();
     return Response::json($agency);
 }
 public function populate()
 {
     $id = Input::get('id');
     $user = User::find($id);
     $accountType = DB::table('accounttype')->select('accountTypeName')->where('accountTypeId', '=', $user->accountType)->pluck('accountTypeName');
     $user->accountType = $accountType;
     if ($user->agencyId == null) {
         $user->agencyId = "No Agency";
     } else {
         $agencyName = Agency::find($user->agencyId);
         $user->agencyId = $agencyName->agencyName;
     }
     return $user->toJson();
 }
示例#14
0
 public function run()
 {
     $faker = Faker::create();
     $accType = Accounts::all()->lists('accountTypeId');
     $agency = Agency::all()->lists('agencyId');
     foreach (range(1, 20) as $index) {
         $atype = $faker->randomElement($accType);
         Log::info($atype);
         if ($atype == 3) {
             $agen = $faker->randomElement($agency);
             User::create(array('username' => str_replace('.', '_', $faker->unique()->username), 'password' => Hash::make('admin'), 'email' => $faker->email, 'accountType' => $atype, 'updated_at' => new DateTime(), 'created_at' => new DateTime(), 'agencyId' => $agen));
         } else {
             User::create(array('username' => str_replace('.', '_', $faker->unique()->username), 'password' => Hash::make('admin'), 'email' => $faker->email, 'accountType' => $atype, 'updated_at' => new DateTime(), 'created_at' => new DateTime()));
         }
     }
 }
 public function getReply()
 {
     $id = Request::segment(3);
     $inbox_id = Request::segment(4);
     $profiles = Agency::where('staff_id', '=', $id)->get();
     $allTeamsMember = array();
     foreach ($profiles as $profile) {
         if ($profile->user_id != Sentry::getUser()->id) {
             $allTeamsMember[$profile->user_id] = $profile->name;
         }
     }
     // DB::table('inbox')
     //           ->where('to_user', Sentry::getUser()->id)
     //           ->where('id', $inbox_id)
     //           ->update(array('notification' => 0));
     return View::make('message.reply')->with('teams', $allTeamsMember);
 }
 private function getDirectionOverrides()
 {
     $config = $this->appConfig;
     $filePath = $config['location_override'];
     //TODO: Check for exception
     $xmlObjBuilder = new XmlObjBuilder($filePath);
     $xml = $xmlObjBuilder->getXmlObj();
     $routeArray = array();
     foreach ($xml->agency as $a) {
         $shortTitle = $a['shortTitle'];
         //We only want the overrides for the current agency
         if ($this->agency->getShortTitle() == $shortTitle) {
             foreach ($a->route as $r) {
                 $routeTag = (string) $r['tag'];
                 foreach ($r->direction as $d) {
                     $routeArray[$routeTag][] = (string) $d['tag'];
                 }
             }
         }
     }
     return $routeArray;
 }
 /**
  * Read flip stop overrides from a file and return them as an array.
  * NOTE: This method returns the flip stops only for the agency being processed
  *
  * @return Array - stopTag => flipStopTag
  */
 private function getFlipStopOverrides()
 {
     $agencyShortTitle = $this->agency->getShortTitle();
     $config = $this->appConfig;
     $filePath = $config['flip_stop_override'];
     //TODO: Check for exception
     $xmlObjBuilder = new XmlObjBuilder($filePath);
     $xml = $xmlObjBuilder->getXmlObj();
     $flipStopMap = array();
     foreach ($xml->agency as $tempAgency) {
         if ((string) $tempAgency["shortTitle"] != $agencyShortTitle) {
             continue;
         }
         foreach ($tempAgency->stop as $tempStop) {
             $stopTag = (string) $tempStop["tag"];
             $flipStopTag = (string) $tempStop["reverseStopTag"];
             $flipStopMap[$stopTag] = $flipStopTag;
             if (!empty($flipStopTag)) {
                 $flipStopMap[$flipStopTag] = $stopTag;
             }
         }
     }
     return $flipStopMap;
 }
<?php

use App\Utils\Hash;
use Illuminate\Support\Str;
if (\User::check()) {
    $user = \User::getUser();
    $agency = \Agency::getAgency();
}
$_hash = new Hash();
$_hash = $_hash->getHasher();
?>

@extends('front.app')

@section('title')
{{ $job->title }}| Programme Chameleon
@stop

@section('content')
<div id="wrapper">
	@include('front.include.header')
	<div class="container">
		<h1 class="page-header"> {{ $job->title }} - <small class="lighten"> Contractors Applied</small> </h1>

		<div class="row">
			<div class="col-md-8">
				<div class="panel panel-default">
					<div class="panel-heading">Contractors Applied</div>
					<div class="panel-body">
						<?php 
$contractors = $job->contractors();
示例#19
0
	<?php 
echo $form->textFieldRow($model, 'ord_no', array('class' => 'span2', 'value' => '', 'placeholder' => '000 - 0000'));
?>
    
  <?php 
echo $form->textAreaRow($model, 'subj_matter', array('class' => 'span6', 'rows' => 5, 'value' => ''));
?>
 

	<?php 
echo $form->select2Row($model, 'author', array('asDropDownList' => true, 'data' => CHtml::listData(Officials::model()->findAll(array('condition' => 'now() >= start_date')), 'off_id', 'Fullname'), 'multiple' => 'multiple', 'options' => array('width' => '63%', 'placeholder' => '        ------------ Choose Author ------------', 'tokenSeparators' => array(',', ' '))));
?>

    <?php 
echo $form->select2Row($model, 'imp_agency', array('asDropDownList' => true, 'data' => CHtml::listData(Agency::model()->findAll(), 'agency_id', 'agency_name'), 'multiple' => 'multiple', 'options' => array('width' => '63%', 'placeholder' => '        ------------ Choose Agency ------------', 'tokenSeparators' => array(',', ' '))));
?>
  <?php 
echo $form->textFieldRow($model, 'amend', array('class' => 'span2', 'value' => ''));
?>
  <?php 
echo $form->datepickerRow($model, 'firstreading', array('prepend' => '<i class="icon-calendar"></i>', 'options' => array('format' => 'yyyy-mm-dd')));
?>
	<?php 
echo $form->datepickerRow($model, 'secondreading', array('prepend' => '<i class="icon-calendar"></i>', 'options' => array('format' => 'yyyy-mm-dd')));
?>
  <?php 
echo $form->datepickerRow($model, 'thirdreading', array('prepend' => '<i class="icon-calendar"></i>', 'options' => array('format' => 'yyyy-mm-dd')));
?>
  <?php 
echo $form->datepickerRow($model, 'date_passed', array('prepend' => '<i class="icon-calendar"></i>', 'options' => array('format' => 'yyyy-mm-dd')));
<?php

define("ROOT", "../");
set_time_limit(0);
require ROOT . 'www/common.php';
require ROOT . 'nextbus/Require.php';
require ROOT . 'bart/Require.php';
require ROOT . 'www/generate_xml.php';
$mailMessage = "";
$zipFileContents = array();
$logger = Logger::getInstance();
$agencyArray = Agency::getAgencies();
try {
    foreach ($agencyArray as $agencyTitle => $agencyObj) {
        //print "<br /><b>$agencyTitle</b><br />";
        file_put_contents(Util::getChangeLogFile(), "\n" . strtoupper($agencyTitle) . "\n\n", FILE_APPEND);
        if ("actransit" == $agencyTitle || "sf-muni" == $agencyTitle || "emery" == $agencyTitle) {
            /*
            if ("sf-muni" == $agencyTitle) {
                $agencyObj->setDataUrl("./files/sf-muni.xml");
            } else if ("actransit" == $agencyTitle) {
                $agencyObj->setDataUrl("./files/actransit.xml");
            }
            */
            //Get the XML object
            $xmlObjBuilder = new NxtbusXmlObjBuilder($agencyObj);
            $xmlObj = $xmlObjBuilder->getXmlObj(true);
            //Update the routes
            $nxtbusRoute = new NxtbusRoute($agencyObj, $xmlObj);
            $nxtbusRoute->updateRoutes();
            //print "Routes updated | ";
示例#21
0
        <td><strong><?php 
echo join(', ', $location_list);
?>
</strong></td>
    </tr>
    <tr>
        <td><i class="flag icon"></i><strong>Theme</strong></td>
        <td><strong><?php 
echo join(', ', $theme_list);
?>
</strong></td>
    </tr>
    <tr>
        <th colspan="2">
            <?php 
$mailto = Agency::get_email();
$mailto .= '?subject=Offre:' . get_the_title();
$mailto .= '&body=' . __('I\'m interested in this this offert', 'sage');
?>
            <a href="mailto: <?php 
echo $mailto;
?>
" class="fluid ui inverted button">
                <i class="shop icon"></i>
                <?php 
_e('Contact us', 'sage');
?>
            </a>
        </th>
    </tr>
</table>
示例#22
0
 /**
  * Declares an association between this object and a Agency object.
  *
  * @param      Agency $v
  * @return     Camp The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setAgency(Agency $v = null)
 {
     if ($v === null) {
         $this->setAgencyId(NULL);
     } else {
         $this->setAgencyId($v->getId());
     }
     $this->aAgency = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Agency object, it will not be re-added.
     if ($v !== null) {
         $v->addCamp($this);
     }
     return $this;
 }
示例#23
0
} else {
    $pdf->SetFont('helvetica', 'B', 17);
    $pdf->Ln(25);
    $pdf->Write(0, 'Ordinance No. ' . $model->ord_no, '', 0, 'C', true, 0, false, false, 0);
    $pdf->Ln(15);
    $pdf->SetFont('helvetica', 'B', 14);
    $pdf->Write(0, $model->subj_matter, '', 0, 'C', true, 0, false, false, 0);
    $pdf->SetFont('helvetica', '', 10);
    $pdf->Ln(10);
    // -----------------------------------------------------------------------------
    $timezone = new DateTimeZone('Asia/Manila');
    $agenda = !empty($model->meeting_ordi_id) ? $model->getAgendaDate($model->meeting_ordi_id) : '0000-00-00';
    $origin = !empty($model->meeting_ordi_id) ? $model->getOrigin($model->meeting_ordi_id) : 'Unknown Origin';
    $referral = !empty($model->meeting_ordi_id) ? $model->getReferralDate($model->meeting_ordi_id) : '0000-00-00';
    $date_report = !empty($model->meeting_ordi_id) ? $model->getReportDate($model->meeting_ordi_id) : '0000-00-00';
    $agency = Agency::model()->FindByPK($model->imp_agency)->agency_name;
    $first = $model->firstreading;
    $second = $model->secondreading;
    $third = $model->thirdreading;
    $datepassed = $model->date_passed;
    $agenda1 = new DateTime($agenda, $timezone);
    $refer1 = new DateTime($referral, $timezone);
    $daterport = new DateTime($date_report, $timezone);
    $firstread = new DateTime($first, $timezone);
    $secondread = new DateTime($second, $timezone);
    $thirdread = new DateTime($third, $timezone);
    $datepassed1 = new DateTime($datepassed, $timezone);
    $tbl = '<table style="padding:10; font-size:16px; width:100%; border-bottom-style: 1px solid black;">';
    if ($agenda == '0000-00-00') {
        $tbl .= '<tr nobr="true">
                 <td style="border-top-style: 1px solid black; font-size:16px; font-weight:bold;">A) Date Agenda</td>
示例#24
0
 /**
  * [getDataList list of agency by each type of data]
  * @param  [integer] $type [type id riainfall, water level ,dam ect.]
  * @return [type]       [description]
  */
 public function getDataList($type)
 {
     $agency_id = Data::getAgencyByDataType($type);
     $rs = Agency::getAgency($agency_id);
     return View::make('rbac.ajax_datalist')->with('result', $rs);
 }
 public function execute()
 {
     PHPWS_Core::initModClass('intern', 'Internship.php');
     PHPWS_Core::initModClass('intern', 'Agency.php');
     PHPWS_Core::initModClass('intern', 'Department.php');
     PHPWS_Core::initModClass('intern', 'Faculty.php');
     /**************
      * Sanity Checks
      */
     // Required fields check
     $missing = self::checkRequest();
     if (!is_null($missing) && !empty($missing)) {
         // checkRequest returned some missing fields.
         $url = 'index.php?module=intern&action=edit_internship';
         $url .= '&missing=' . implode('+', $missing);
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, 'Please fill in the highlighted fields.');
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check the Banner ID
     if (!preg_match('/^\\d{9}$/', $_REQUEST['banner'])) {
         $url = 'index.php?module=intern&action=edit_internship&missing=banner';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The Banner ID you entered is not valid. No changes were saved. The student's Banner ID should be nine digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check student email
     if (isset($_REQUEST['student_email']) && preg_match("/@/", $_REQUEST['student_email'])) {
         $url = 'index.php?module=intern&action=edit_internship&missing=student_email';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The student's email address is invalid. No changes were saved. Enter only the username portion of the student's email address. The '@appstate.edu' portion is not necessary.");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check student zip
     if (isset($_REQUEST['student_zip']) && $_REQUEST['student_zip'] != "" && (strlen($_REQUEST['student_zip']) != 5 || !is_numeric($_REQUEST['student_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=student_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The student's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Course start date must be before end date
     if (!empty($_REQUEST['start_date']) && !empty($_REQUEST['end_date'])) {
         $start = strtotime($_REQUEST['start_date']);
         $end = strtotime($_REQUEST['end_date']);
         if ($start > $end) {
             $url = 'index.php?module=intern&action=edit_internship&missing=start_date+end_date';
             // Restore the values in the fields the user already entered
             unset($_POST['start_date']);
             unset($_POST['end_date']);
             foreach ($_POST as $key => $val) {
                 $url .= "&{$key}={$val}";
             }
             NQ::simple('intern', INTERN_WARNING, 'The internship start date must be before the end date.');
             NQ::close();
             return PHPWS_Core::reroute($url);
         }
     }
     // Sanity check internship location zip
     if (isset($_REQUEST['loc_zip']) && $_REQUEST['loc_zip'] != "" && (strlen($_REQUEST['loc_zip']) != 5 || !is_numeric($_REQUEST['loc_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=loc_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The internship location's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check agency zip
     if (isset($_REQUEST['agency_zip']) && $_REQUEST['agency_zip'] != "" && (strlen($_REQUEST['agency_zip']) != 5 || !is_numeric($_REQUEST['agency_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=agency_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The agency's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check supervisor's zip
     if (isset($_REQUEST['agency_sup_zip']) && $_REQUEST['agency_sup_zip'] != "" && (strlen($_REQUEST['agency_sup_zip']) != 5 || !is_numeric($_REQUEST['agency_sup_zip']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=agency_sup_zip';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The agency supervisor's zip code is invalid. No changes were saved. Zip codes should be 5 digits only (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Sanity check course number
     if (isset($_REQUEST['course_no']) && $_REQUEST['course_no'] != '' && (strlen($_REQUEST['course_no']) > 20 || !is_numeric($_REQUEST['course_no']))) {
         $url = 'index.php?module=intern&action=edit_internship&missing=course_no';
         // Restore the values in the fields the user already entered
         foreach ($_POST as $key => $val) {
             $url .= "&{$key}={$val}";
         }
         NQ::simple('intern', INTERN_ERROR, "The course number provided is invalid. No changes were saved. Course numbers should be less than 20 digits (no letters, spaces, or punctuation).");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     PHPWS_DB::begin();
     // Create/Save agency
     $agency = new Agency();
     if (isset($_REQUEST['agency_id'])) {
         // User is editing internship
         try {
             $agency = new Agency($_REQUEST['agency_id']);
         } catch (Exception $e) {
             // Rollback and re-throw the exception so that admins gets an email
             PHPWS_DB::rollback();
             throw $e;
         }
     }
     $agency->name = $_REQUEST['agency_name'];
     $agency->address = $_REQUEST['agency_address'];
     $agency->city = $_REQUEST['agency_city'];
     $agency->zip = $_REQUEST['agency_zip'];
     $agency->phone = $_REQUEST['agency_phone'];
     if ($_REQUEST['location'] == 'internat') {
         /* Location is INTERNATIONAL. Country is required. Province was typed in. */
         $agency->state = $_REQUEST['agency_state'];
         $agency->province = $_REQUEST['agency_province'];
         $agency->country = $_REQUEST['agency_country'];
         $agency->supervisor_state = $_REQUEST['agency_sup_state'];
         $agency->supervisor_province = $_REQUEST['agency_sup_province'];
         $agency->supervisor_country = $_REQUEST['agency_sup_country'];
     } else {
         /* Location is DOMESTIC. Country is U.S. State was chosen from drop down */
         $agency->state = $_REQUEST['agency_state'] == -1 ? null : $_REQUEST['agency_state'];
         $agency->country = 'United States';
         $agency->supervisor_state = $_REQUEST['agency_sup_state'] == -1 ? null : $_REQUEST['agency_sup_state'];
         $agency->supervisor_country = 'United States';
     }
     $agency->supervisor_first_name = $_REQUEST['agency_sup_first_name'];
     $agency->supervisor_last_name = $_REQUEST['agency_sup_last_name'];
     $agency->supervisor_title = $_REQUEST['agency_sup_title'];
     $agency->supervisor_phone = $_REQUEST['agency_sup_phone'];
     $agency->supervisor_email = $_REQUEST['agency_sup_email'];
     $agency->supervisor_fax = $_REQUEST['agency_sup_fax'];
     $agency->supervisor_address = $_REQUEST['agency_sup_address'];
     $agency->supervisor_city = $_REQUEST['agency_sup_city'];
     $agency->supervisor_zip = $_REQUEST['agency_sup_zip'];
     $agency->address_same_flag = isset($_REQUEST['copy_address']) ? 't' : 'f';
     try {
         $agencyId = $agency->save();
     } catch (Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         PHPWS_DB::rollback();
         throw $e;
     }
     /**********************************
      * Create and/or save the Internship
      */
     if (isset($_REQUEST['internship_id']) && $_REQUEST['internship_id'] != '') {
         // User is editing internship
         try {
             PHPWS_Core::initModClass('intern', 'InternshipFactory.php');
             $i = InternshipFactory::getInternshipById($_REQUEST['internship_id']);
         } catch (Exception $e) {
             // Rollback and re-throw the exception so that admins gets an email
             PHPWS_DB::rollback();
             throw $e;
         }
     } else {
         $i = new Internship();
     }
     $i->term = $_REQUEST['term'];
     $i->agency_id = $agencyId;
     $i->faculty_id = $_REQUEST['faculty_id'] > 0 ? $_REQUEST['faculty_id'] : null;
     $i->department_id = $_REQUEST['department'];
     $i->start_date = !empty($_REQUEST['start_date']) ? strtotime($_REQUEST['start_date']) : 0;
     $i->end_date = !empty($_REQUEST['end_date']) ? strtotime($_REQUEST['end_date']) : 0;
     // Credit hours must be an integer (because of database column type),
     // so round the credit hours to nearest int
     if (isset($_REQUEST['credits'])) {
         $i->credits = round($_REQUEST['credits']);
     }
     $avg_hours_week = (int) $_REQUEST['avg_hours_week'];
     $i->avg_hours_week = $avg_hours_week ? $avg_hours_week : null;
     $i->paid = $_REQUEST['payment'] == 'paid';
     $i->stipend = isset($_REQUEST['stipend']) && $i->paid;
     $i->unpaid = $_REQUEST['payment'] == 'unpaid';
     $i->pay_rate = $_REQUEST['pay_rate'];
     // Internship experience type
     if (isset($_REQUEST['experience_type'])) {
         $i->setExperienceType($_REQUEST['experience_type']);
     }
     // Set fields depending on domestic/international
     if ($_REQUEST['location'] == 'domestic') {
         // Set Flags
         $i->domestic = 1;
         $i->international = 0;
         // Set state
         if ($_POST['loc_state'] != '-1') {
             $i->loc_state = strip_tags($_POST['loc_state']);
         } else {
             $i->loc_state = null;
         }
         // Clear province, country
         $i->loc_province = '';
         $i->loc_country = '';
     } else {
         if ($_REQUEST['location'] == 'internat') {
             // Set flags
             $i->domestic = 0;
             $i->international = 1;
             // Set province, country
             $i->loc_province = $_POST['loc_province'];
             $i->loc_country = strip_tags($_POST['loc_country']);
             // Clear state
             $i->loc_state = null;
         }
     }
     // Address, city, zip are always set (no matter domestic or international)
     $i->loc_address = strip_tags($_POST['loc_address']);
     $i->loc_city = strip_tags($_POST['loc_city']);
     $i->loc_zip = strip_tags($_POST['loc_zip']);
     if (isset($_POST['course_subj']) && $_POST['course_subj'] != '-1') {
         $i->course_subj = strip_tags($_POST['course_subj']);
     } else {
         $i->course_subj = null;
     }
     // Course info
     $i->course_no = strip_tags($_POST['course_no']);
     $i->course_sect = strip_tags($_POST['course_sect']);
     $i->course_title = strip_tags($_POST['course_title']);
     // Multipart course
     if (isset($_POST['multipart'])) {
         $i->multi_part = 1;
     } else {
         $i->multi_part = 0;
     }
     if (isset($_POST['multipart']) && isset($_POST['secondary_part'])) {
         $i->secondary_part = 1;
     } else {
         $i->secondary_part = 0;
     }
     // Corequisite Course Info
     if (isset($_POST['corequisite_course_num'])) {
         $i->corequisite_number = $_POST['corequisite_course_num'];
     }
     if (isset($_POST['corequisite_course_sect'])) {
         $i->corequisite_section = $_POST['corequisite_course_sect'];
     }
     // Student Information
     $i->first_name = $_REQUEST['student_first_name'];
     $i->middle_name = $_REQUEST['student_middle_name'];
     $i->last_name = $_REQUEST['student_last_name'];
     $i->setFirstNameMetaphone($_REQUEST['student_first_name']);
     $i->setLastNameMetaphone($_REQUEST['student_last_name']);
     $i->banner = $_REQUEST['banner'];
     $i->phone = $_REQUEST['student_phone'];
     $i->email = $_REQUEST['student_email'];
     $i->level = $_REQUEST['student_level'];
     // Check the level and record the major/program for this level.
     // Be sure to set/clear the other leve's major/program to null
     // in case the user is switching levels.
     if ($i->getLevel() == 'ugrad') {
         $i->ugrad_major = $_REQUEST['ugrad_major'];
         $i->grad_prog = null;
     } else {
         if ($i->getLevel() == 'grad') {
             $i->grad_prog = $_REQUEST['grad_prog'];
             $i->ugrad_major = null;
         }
     }
     $i->gpa = $_REQUEST['student_gpa'];
     $i->campus = $_REQUEST['campus'];
     $i->student_address = $_REQUEST['student_address'];
     $i->student_city = $_REQUEST['student_city'];
     if ($_REQUEST['student_state'] != '-1') {
         $i->student_state = $_REQUEST['student_state'];
     } else {
         $i->student_state = "";
     }
     $i->student_zip = $_REQUEST['student_zip'];
     /*
     $i->emergency_contact_name = $_REQUEST['emergency_contact_name'];
     $i->emergency_contact_relation = $_REQUEST['emergency_contact_relation'];
     $i->emergency_contact_phone = $_REQUEST['emergency_contact_phone'];
     */
     /************
      * OIED Certification
      */
     // If OIED certification has changed, then double check permissions
     $cert = $i->oied_certified == 1 ? true : false;
     $certSubmitted = $_POST['oied_certified_hidden'] == 'true' ? true : false;
     $certChanged = $cert != $certSubmitted;
     if ($certChanged && !Current_User::allow('intern', 'oied_certify')) {
         $url = "index.php?module=intern&action=edit_internship&internship_id={$i->getId()}";
         NQ::simple('intern', INTERN_ERROR, "You do not have permission to change the OIED certification checkbox. No changes were saved.");
         NQ::close();
         return PHPWS_Core::reroute($url);
     }
     // Check if this has changed from non-certified->certified so we can log it later
     if ($i->oied_certified == 0 && $_POST['oied_certified_hidden'] == 'true') {
         // note the change for later
         $oiedCertified = true;
     } else {
         $oiedCertified = false;
     }
     if ($_POST['oied_certified_hidden'] == 'true') {
         $i->oied_certified = 1;
     } else {
         if ($_POST['oied_certified_hidden'] == 'false') {
             $i->oied_certified = 0;
         } else {
             $i->oied_certified = 0;
         }
     }
     // If we don't have a state and this is a new internship,
     // the set an initial state
     if ($i->id == 0 && is_null($i->state)) {
         PHPWS_Core::initModClass('intern', 'WorkflowStateFactory.php');
         $state = WorkflowStateFactory::getState('CreationState');
         $i->setState($state);
         // Set this initial value
     }
     try {
         $i->save();
     } catch (Exception $e) {
         // Rollback and re-throw the exception so that admins gets an email
         PHPWS_DB::rollback();
         throw $e;
     }
     PHPWS_DB::commit();
     /***************************
      * State/Workflow Handling *
      ***************************/
     PHPWS_Core::initModClass('intern', 'WorkflowController.php');
     PHPWS_Core::initModClass('intern', 'WorkflowTransitionFactory.php');
     $t = WorkflowTransitionFactory::getTransitionByName($_POST['workflow_action']);
     $workflow = new WorkflowController($i, $t);
     try {
         $workflow->doTransition(isset($_POST['notes']) ? $_POST['notes'] : null);
     } catch (MissingDataException $e) {
         NQ::simple('intern', INTERN_ERROR, $e->getMessage());
         NQ::close();
         return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
     }
     // Create a ChangeHisotry for the OIED certification.
     if ($oiedCertified) {
         $currState = WorkflowStateFactory::getState($i->getStateName());
         $ch = new ChangeHistory($i, Current_User::getUserObj(), time(), $currState, $currState, 'Certified by OIED');
         $ch->save();
     }
     $workflow->doNotification(isset($_POST['notes']) ? $_POST['notes'] : null);
     if (isset($_REQUEST['internship_id'])) {
         // Show message if user edited internship
         NQ::simple('intern', INTERN_SUCCESS, 'Saved internship for ' . $i->getFullName());
         NQ::close();
         return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
     } else {
         NQ::simple('intern', INTERN_SUCCESS, 'Added internship for ' . $i->getFullName());
         NQ::close();
         return PHPWS_Core::reroute('index.php?module=intern&action=edit_internship&internship_id=' . $i->id);
     }
 }
示例#26
0
 /**
  * [agencyDel description]
  * @param  [type] $agency_id [description]
  * @return [type]            [description]
  */
 public function agencyDel($agency_id)
 {
     Agency::where('id', '=', $agency_id)->delete();
     return Redirect::to('agency')->with('success', 'ชื่อข้อมูลหน่วยงานรหัส = ' . $agency_id . ' ลบทิ้งสำเร็จ');
 }
 public function applyForJob($contractor, $job)
 {
     if (!($company = $job->company)) {
         throw new \Exception("Company for this job not found.", 1);
         return;
     }
     // not efficient, need to change
     if (!($contractor = $this->findById($contractor->id))) {
         throw new \Exception("Contractor not found.", 1);
         return;
     }
     if ($contractor->jobs->contains($job->id)) {
         throw new \Exception("You have already applied for this job.", 1);
         return;
     }
     $contractor->jobs()->sync([$job->id => ['status' => 'request', 'created_at' => Carbon::now(), 'updated_at' => Carbon::now()]], false);
     // TODO: Move to background worker
     $cUser = $contractor->user;
     $_hash = new Hash();
     $_hash = $_hash->getHasher();
     $notificationData = ['company_id' => $company->id, 'title' => 'New Job Application', 'alert_from' => $cUser->first_name . ' ' . $cUser->last_name, 'has_read' => false, 'url' => route('company.job.application') . '?i=' . $_hash->encode($job->id)];
     $notification = \Company::addNotification($company, $notificationData);
     if (!is_null($job->agency_id)) {
         if ($agency = $job->agency) {
             $notificationData = ['agency_id' => $job->agency_id, 'title' => 'New Job Application', 'alert_from' => $cUser->first_name . ' ' . $cUser->last_name, 'has_read' => false, 'url' => route('agency.job.application') . '?i=' . $_hash->encode($job->id)];
             $notification = \Agency::addNotification($agency, $notificationData);
         }
     }
     // END TODO
     return $contractor;
 }
 public function postRemoveAffiliate()
 {
     $_hash = new Hash();
     $_hash = $_hash->getHasher();
     $id = $_hash->decode(trim(\Input::get('id')));
     if (!($agency = \Agency::findAgencyById($id))) {
         return \Response::json(['type' => 'danger', 'message' => 'Agency not found.']);
     }
     try {
         $affiliate = \Company::removeAffiliate($agency);
         return \Response::json(['type' => 'success', 'message' => 'Affiliate "' . $agency->name . '" removed.']);
     } catch (\Exception $e) {
         return \Response::json(['type' => 'danger', 'message' => $e->getMessage()]);
     }
 }
示例#29
0
 private function assertEqualAgency(Agency $a, Agency $b)
 {
     $this->assertTrue($a->getBank()->getBankID() === $b->getBank()->getBankID());
     $this->assertTrue($a->getID() === $b->getID());
     $this->assertTrue($a->getPostcode() === $b->getPostcode());
     $this->assertTrue($a->getCity() === $b->getCity());
     $this->assertTrue($a->getName() === $b->getName());
     $this->assertTrue($a->getShortTerm() === $b->getShortTerm());
     $this->assertTrue($a->hasPAN() === $b->hasPAN());
     $this->assertTrue($a->hasBIC() === $b->hasBIC());
     if ($a->hasPAN()) {
         $this->assertTrue($a->getPAN() === $b->getPAN());
     }
     if ($a->hasBIC()) {
         $this->assertTrue($a->getBIC() === $b->getBIC());
     }
 }
示例#30
0
 /**
  * [peerAgencyFrm description]
  * @return [type] [description]
  */
 public function peerAgencyFrm()
 {
     $agency = Agency::all();
     return View::make('peer.agencylist')->with('all_agency', $agency);
 }