Example #1
0
 public function getSourceClaimer()
 {
     if ($this->match_army_update) {
         return ArmyUpdates::find($this->match_table_id)->getClaimer();
     }
     if ($this->match_found_person) {
         return FoundPeople::find($this->match_table_id)->getClaimer();
     }
 }
 private function doClaim($is_duplicate)
 {
     $claim_match_id = Input::get('match-id');
     Log::info("======[claim_match_id]======");
     Log::info($claim_match_id);
     Log::info(Input::all());
     $match = Match::find($claim_match_id);
     $fip = FindPeople::find($match->fip_id);
     // MARK match as claimed and FIP as found
     $match->claimed = true;
     $match->save();
     $fip->found = true;
     $fip->duplicate = $is_duplicate;
     if ($match->match_army_update) {
         $fip->found_in_army_updates = true;
         $au = ArmyUpdates::find($match->match_table_id);
         $au->claimed = true;
         $au->save();
         // not deleting. allowing duplicate claims instead
         //Match::where('match_table_id', '=', $au->id)->delete();
     }
     if ($match->match_found_person) {
         $fip->found_in_found_people = true;
         $fop = FoundPeople::find($match->match_table_id);
         $fop->claimed = true;
         $fop->save();
         //Match::where('match_table_id', '=', $fop->id)->delete();
     }
     $fip->found_table_id = $match->match_table_id;
     $fip->save();
     Match::deleteMatchesForFip($fip->id);
     // TODO : also send back the id in the table it was matched to
     // Turn into Found
     $response = array('status' => 'success', 'fip-id' => $fip->id);
     return Response::json($response);
 }
 public function edit()
 {
     $fop_id = Input::get('fop-id');
     Log::info("===========================in FoundPeopleController EDIT [fop_id] is =>");
     Log::info($fop_id);
     $fop = FoundPeople::find($fop_id);
     // Storing the image
     $image_file = Input::file('fop-photo-file');
     if ($image_file) {
         $image_file_name = 'FOP_id_' . $fop_id . '.' . $image_file->guessClientExtension();
         $image_file_location = 'images/FOP_photos/';
         $image_file->move($image_file_location, $image_file_name);
         if ($fop->photo_url) {
             // delete old upload
             unlink(app_path() . '/../public' . $fop->photo_url);
         }
         $fop->photo_url = '/' . $image_file_location . $image_file_name;
     }
     $fop->description = Input::get('fop-desc');
     $fop->save();
     return Redirect::route('found.person.show', $fop_id);
 }
Example #4
0
    return View::make('find_person/edit', ['fip' => $fip]);
}))->before('auth');
Route::post('findperson/edit/{id}', array('as' => 'find.person.edit', 'uses' => 'FindPeopleController@edit'))->before('auth');
Route::get('findperson/show/{id}', array('as' => 'find.person.show', 'uses' => function ($id) {
    $fip = FindPeople::find($id);
    $looker = $fip->getLooker();
    return View::make('find_person/show', ['fip' => $fip, 'looker' => $looker]);
}));
Route::post('/found', array('as' => 'found.people.create', 'uses' => 'FoundPeopleController@create'));
Route::get('foundperson/show/{id}', array('as' => 'found.person.show', 'uses' => function ($id) {
    $fop = FoundPeople::find($id);
    $finder = $fop->getFinder();
    return View::make('found_person/show', ['fop' => $fop, 'finder' => $finder]);
}));
Route::get('foundperson/edit/{id}', array('as' => 'found.person.edit', 'uses' => function ($id) {
    $fop = FoundPeople::find($id);
    return View::make('found_person/edit', ['fop' => $fop]);
}))->before('auth');
Route::post('foundperson/edit/{id}', array('as' => 'found.person.edit', 'uses' => 'FoundPeopleController@edit'))->before('auth');
Route::post('deletefop', array('as' => 'found.people.delete', 'uses' => 'FoundPeopleController@delete'))->before('auth');
Route::get('AUdata', array('as' => 'au.data', 'uses' => function () {
    return Response::json(ArmyUpdates::all(array('first_name', 'age')));
}));
Route::get('/updates', array('as' => 'updates', 'uses' => function () {
    $army_updates_pag = ArmyUpdates::orderBy('s_no', 'asc')->paginate(ArmyUpdates::SHOW_PER_PAGE);
    return View::make('armyupdates', ['army_updates_pag' => $army_updates_pag]);
}));
Route::post('/updates', array('as' => 'army.updates.search', 'uses' => 'ArmyUpdatesController@search'));
Route::get('/contributors', array('as' => 'contributors', 'uses' => function () {
    $cu_list = User::where('contributor', true)->get()->sortByDesc('contributed');
    return View::make('contributors', ['contributor_users_list' => $cu_list]);
Example #5
0
 private static function getBuilderWithParam($find_name, $find_age)
 {
     $name = false;
     $age = false;
     if ($find_name) {
         $name = true;
     }
     if ($find_age) {
         $age = true;
     }
     $results = array();
     $explanation = "";
     if ($name && !$age) {
         // Only Name Specified
         // First-name and Last-name search
         // $results = DB::table('FoundPeople')
         //                     ->where('first-name', '=', $updates_name)
         //                     ->orWhere('last-name', '=', $updates_name)
         //                     ->get();
         // Substr match
         // $results = FoundPeople::whereRaw('first_name LIKE ? and last_name LIKE ?', array(
         //                                     '%'.$find_first_name.'%', '%'.$find_last_name.'%'
         //                                 ));
         $results = Helper::searchTableForName(FoundPeople::TABLE_NAME, $find_name);
         // TODO : separate out exact matches and substr matches and disp them separately
     } elseif ($age && !$name) {
         // Only Age Specified
         $results = FoundPeople::where('age', '=', $find_age);
     } elseif ($name && $age) {
         // Name, Age Specified
         // $results = FoundPeople::whereRaw('( first_name LIKE ? and last_name LIKE ? ) and age = ?', array(
         //                             '%'.$find_first_name.'%', '%'.$find_last_name.'%', $find_age
         //                         ));
         $results = Helper::searchTableForNameAndAge(FoundPeople::TABLE_NAME, $find_name, $find_age);
         // TODO : separate out exact matches and substr matches and disp them separately
     }
     return $results;
 }
 public function create()
 {
     //check if its our form
     // TODO #7
     // if ( Session::token() !== Input::get( '_token' ) ) {
     //     return Response::json( array(
     //         'msg' => 'Unauthorized attempt to create option'
     //     ) );
     // }
     $find_name = Input::get('find-name');
     $find_age = Input::get('find-age');
     Log::info("===========================in FindPeopleController create [start]");
     Log::info($find_name);
     Log::info($find_age);
     // find_age is str
     // If not logged in, it could be New User or Returning User
     if (Auth::guest()) {
         /////// Create User of type Looker
         $looker_first_name = Input::get('looker-first-name');
         $looker_last_name = Input::get('looker-last-name');
         $looker_mobile = Input::get('looker-mobile');
         $returning_user = User::where('mobile', '=', $looker_mobile)->get()->first();
         if ($returning_user) {
             Auth::login($returning_user, true);
         } else {
             // New user
             $looker_obj = User::createLookerAndSave($looker_first_name, $looker_last_name, $looker_mobile);
             // Manually logging in user and 'Remember me' = true.
             // So no need to use Auth::attempt
             Auth::login($looker_obj, true);
         }
     }
     if (!Auth::user()->looker) {
         Auth::user()->makeLooker();
     }
     // TODO: check for duplicates before creating another record
     $fip = FindPeople::createNewForLooker($find_name, $find_age, Auth::user()->id);
     // If we wanted to print the findPeople per user.
     // $fp = User::find($looker_id)->findPeople()->get();
     // Log::info($fp);
     // Now that 'Looker' has created a new 'Fip', we should try to match this Fip against AU and FOP
     // TODO This code might need to move somewhere else
     // Doing only AU for now. TODO do FOP
     $au_search_results = ArmyUpdates::searchWithNameAndAge($find_name, $find_age);
     Log::info("==[AU search results]==");
     Log::info($au_search_results);
     // If the number of search_results > 0, i.e. matches found, create matches on FIP. (Alerts to FIP->Looker fired automatically)
     // FIP->hasMany(Matches)
     if (count($au_search_results)) {
         $fip->createNewMatches(ArmyUpdates::TABLE_NAME, $au_search_results);
     }
     $fop_search_results = FoundPeople::searchWithNameAndAge($find_name, $find_age);
     if (count($fop_search_results)) {
         $fip->createNewMatches(FoundPeople::TABLE_NAME, $fop_search_results);
     }
     Log::info("========[in FindPeopleController -> fop__search_result is]==========");
     Log::info($fop_search_results);
     $num_matches = count($au_search_results) + count($fop_search_results);
     $response = array('status' => 'success', 'username' => Auth::user()->fname, 'notificationCount' => $num_matches, 'fname' => Helper::getDisplayFirstNameFrom($find_name), 'lname' => Helper::getDisplayLastNameFrom($find_name), 'age' => $find_age, 'msgCount' => Auth::user()->messages()->count(), 'msg' => 'Person inserted in Find-People Table successfully');
     Log::info("===========================in FindPeopleController create [end]");
     return Response::json($response);
 }