function reservationName($reservation)
{
    if ($reservation->CreditorType == 2) {
        return Institution::find($reservation->CreditorId)->Name;
    } else {
        if ($reservation->CreditorId != 0) {
            return Client::find($reservation->CreditorId)->Name;
        } else {
            return 'No declarado';
        }
    }
}
 public static function delete($id)
 {
     if (self::get_user_admin() == null) {
         Redirect::to('/home');
     }
     $degrees = Degree::findByInstitution($id);
     if (!empty($degrees)) {
         Redirect::to('/institutions', array('error' => 'Institution could not be deleted, because it is linked to one or more degrees. First delete related degrees under Manage->Degrees.'));
     }
     $institution = Institution::find($id);
     $institution->delete();
     Redirect::to('/institutions', array('message' => 'Institution deleted!'));
 }
 /**
  * Show the form for editing the specified institution.
  *
  * @param  int $id
  * @return Response
  */
 public function edit($id)
 {
     $institution = Institution::find($id);
     $fileids = json_decode($institution->logo);
     $files = array();
     foreach ($fileids as $fileid) {
         $upload = Upload::find($fileid);
         if (isset($upload)) {
             $newurl = URL::asset($upload->publicpath() . $upload->filename);
             $success = new stdClass();
             $success->name = $upload->filename;
             $success->size = $upload->size;
             $success->url = $newurl;
             $success->thumbnailUrl = $newurl;
             $success->deleteUrl = action('UploadController@delete', $upload->id);
             $success->deleteType = 'DELETE';
             $success->fileID = $upload->id;
             $files[] = $success;
         }
     }
     $json = json_encode(array('files' => $files));
     return View::make('institutions.edit', compact('institution', 'json'));
 }
Exemple #4
0
 private static function makeDegreeObjectsFromQueryRows($rows)
 {
     $degrees = array();
     foreach ($rows as $row) {
         $query = DB::connection()->prepare('SELECT * FROM Degree_Institution WHERE degree_id = :id');
         $query->execute(array('id' => $row['id']));
         $degree_institutions = $query->fetchAll();
         $institutions = array();
         foreach ($degree_institutions as $degree_institution) {
             $institutions[] = Institution::find($degree_institution['institution_id']);
         }
         $degrees[] = new Degree(array('id' => $row['id'], 'name' => $row['name'], 'deadline' => $row['deadline'], 'description' => $row['description'], 'accepted' => $row['accepted'], 'acceptancerate' => $row['acceptancerate'], 'city' => $row['city'], 'extent' => $row['extent'], 'institutions' => $institutions));
     }
     return $degrees;
 }
Exemple #5
0
 private static function createDegree($params, $id)
 {
     $degree = new Degree(array('id' => $id, 'name' => $params['name'], 'extent' => $params['extent'], 'city' => $params['city'], 'accepted' => $params['accepted'], 'acceptancerate' => $params['acceptancerate'], 'deadline' => $params['deadline'], 'description' => $params['description'], 'institutions' => null));
     $institutions = array();
     if (isset($params['institutions'])) {
         foreach ($params['institutions'] as $institutionId) {
             $institutions[] = Institution::find($institutionId);
         }
     }
     $degree->institutions = $institutions;
     return $degree;
 }