コード例 #1
0
ファイル: Requests.php プロジェクト: amcfarlane1251/lcnsMgmt
 public static function retrieve($roleId = null, $reqCode, $type)
 {
     if ($roleId) {
         return Requests::where('role_id', $roleId)->where('type', $type)->orderBy('created_at', 'desc')->get();
     } else {
         return Requests::where('type', $type)->orderBy('created_at', 'desc')->get();
     }
 }
コード例 #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Working');
     $date1 = date('Y-m-d h:i:s');
     $this->info($date1);
     $date = date_create($date1);
     $msgtime = $date->add(new DateInterval('P0Y0M0DT0H30M0S'))->format('Y-m-d H:i:s');
     $requests = Requests::where('later', 1)->where('is_started', 0)->where('request_start_time', '<=', $msgtime)->get();
     if ($requests->count() > 0) {
         $this->info('hola');
         foreach ($requests as $request) {
             $provider = Walker::where('id', $request->confirmed_walker)->first();
             $owner = Owner::where('id', $request->owner_id)->first();
             $message = "You have a ride scheduled in 30 mins from now. Client name is {$owner->first_name} {$owner->last_name} and phone no. is {$owner->phone}";
             $this->info($request->id);
             $this->info($message);
             send_notifications($provider->id, 'provider', 'Ride in 30 min', $message);
             $request->later = 0;
             $request->save();
         }
     }
 }
コード例 #3
0
 public function indexRequests($roleId)
 {
     //get user role
     $user = Sentry::getUser();
     $role = $user->role;
     Input::get('reqCode') ? $reqCode = Input::get('reqCode') : ($reqCode = '');
     if ($role->role != 'All' && $role->id != $roleId) {
         return Redirect::to('/')->with('error', 'Cannot access that EC');
     }
     if ($role->role == 'All' && $role->id == $roleId) {
         $requests = Request::where('request_code', $reqCode)->orderBy('created_at', 'desc')->get();
     } else {
         $requests = Request::where('request_code', $reqCode)->where('role_id', $roleId)->orderBy('created_at', 'desc')->get();
     }
     if ($this->httpRequest->ajax()) {
         //ajax request so return json
         foreach ($requests as $key => $request) {
             $requests[$key]->requester = $request->owner->first_name . " " . $request->owner->last_name;
             $requests[$key]->role = $request->roles->role;
             $requests[$key]->lcnsTypes = $request->licenseTypes;
             if ($requests[$key]->request_code != 'closed') {
                 if ($user->hasAccess('admin') || $user->role->id == $requests[$key]->role_id) {
                     $requests[$key]->actions = "<a href=" . URL::to('request/' . $requests[$key]->id . '/edit') . "><i class='fa fa-pencil icon-white'></i></a>";
                 }
                 if ($user->hasAccess('admin')) {
                     $requests[$key]->actions .= "<a href=" . URL::to('request/' . $request->id . '/approve') . "><i class='fa fa-check icon-white'></i></a>";
                 }
             }
         }
         header('Content-type: application/json');
         return Response::json(array('requests' => $requests, 'isAdmin' => $user->hasAccess('admin'), 'roleId' => $user->role->id), 200);
     } else {
         //html request
         return View::make('backend.requests.index')->with('requests', $requests)->with('user', $user)->with('roleId', $roleId);
     }
 }
コード例 #4
0
                    <td><?php 
    echo $referred;
    ?>
</td>
                    <td>
                        <div class="dropdown">
                            <button class="btn btn-flat btn-info dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
                                Actions
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                                <li role="presentation"><a role="menuitem" tabindex="-1" id="edit" href="{{ URL::Route('AdminUserEdit', $owner->id) }}">Edit {{ trans('customize.User'); }}</a></li>
                                <li role="presentation"><a role="menuitem" tabindex="-1" id="history" href="{{ URL::Route('AdminUserHistory',$owner->id) }}">View History</a></li>
                                <li role="presentation"><a role="menuitem" tabindex="-1" id="coupon" href="{{ URL::Route('AdminUserReferral', $owner->id) }}">Coupon Details</a></li>
                                <?php 
    $check = Requests::where('owner_id', '=', $owner->id)->where('is_cancelled', '<>', '1')->get()->count();
    //print_r($check);
    if ($check == 0) {
        ?>
                                    <li role="presentation"><a role="menuitem" tabindex="-1" id="add_req" href="{{ URL::Route('AdminAddRequest', $owner->id) }}">Add Request</a></li>
    <?php 
    }
    ?>
                                <li role="presentation"><a role="menuitem" tabindex="-1" id="add_req" href="{{ URL::Route('AdminDeleteUser', $owner->id) }}">Delete</a></li>
                            </ul>
                        </div>
                    </td>
                </tr>
<?php 
}
?>
コード例 #5
0
 public function userTrips()
 {
     $owner_id = Session::get('user_id');
     $requests = Requests::where('owner_id', $owner_id)->where('is_completed', 1)->leftJoin('walker', 'walker.id', '=', 'request.confirmed_walker')->leftJoin('walker_type', 'walker_type.id', '=', 'walker.type')->orderBy('request_start_time', 'desc')->select('request.id', 'request_start_time', 'walker.first_name', 'walker.last_name', 'request.total as total', 'walker_type.name as type')->get();
     return View::make('web.userTrips')->with('title', 'My Trips')->with('requests', $requests);
 }
コード例 #6
0
 public function create_manual_request()
 {
     $latitude = Input::get('latitude');
     $longitude = Input::get('longitude');
     $d_latitude = Input::get('d_latitude');
     $d_longitude = Input::get('d_longitude');
     $type = Input::get('type');
     $provider = Input::get('provider');
     $user_id = Session::get('user_id');
     $time = date("Y-m-d H:i:s");
     $provider_details = Walker::where('id', '=', $provider)->first();
     $user = Owner::where('id', '=', $user_id)->first();
     $request = new Requests();
     $request->owner_id = $user_id;
     $request->request_start_time = $time;
     $request->confirmed_walker = $provider;
     if ($d_longitude != '' && $d_latitude != '') {
         $request->D_latitude = $d_latitude;
         $request->D_longitude = $d_longitude;
     }
     $request->current_walker = $provider;
     $request->status = 1;
     $request->save();
     $reqid = $request->id;
     $request_service = new RequestServices();
     $request_service->type = $type;
     $request_service->request_id = $request->id;
     $request_service->save();
     $owner = Owner::find($user_id);
     $owner->latitude = $latitude;
     $owner->longitude = $longitude;
     $owner->save();
     $walkerlocation = new WalkLocation();
     $walkerlocation->request_id = $request->id;
     $walkerlocation->distance = 0.0;
     $walkerlocation->latitude = $latitude;
     $walkerlocation->longitude = $longitude;
     $walkerlocation->save();
     if ($request->save()) {
         $current_request = Requests::where('id', '=', $reqid)->first();
         return Redirect::to('/user/request-trip');
     }
 }
コード例 #7
0
 public function request_in_progress()
 {
     $token = Input::get('token');
     $owner_id = Input::get('id');
     $validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id), array('token' => 'required', 'owner_id' => 'required|integer'));
     if ($validator->fails()) {
         $error_messages = $validator->messages()->all();
         $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
         $response_code = 200;
     } else {
         $is_admin = $this->isAdmin($token);
         if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) {
             // check for token validity
             if (is_token_active($owner_data->token_expiry) || $is_admin) {
                 $request = Requests::where('status', '=', 1)->where('is_completed', '=', 0)->where('is_cancelled', '=', 0)->where('owner_id', '=', $owner_id)->orderBy('created_at', 'desc')->first();
                 if ($request) {
                     $request_id = $request->id;
                 } else {
                     $request_id = -1;
                 }
                 $response_array = array('request_id' => $request_id, 'success' => true);
                 $response_code = 200;
             } else {
                 $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
                 $response_code = 200;
             }
         } else {
             if ($is_admin) {
                 $response_array = array('success' => false, 'error' => 'Owner ID not Found', 'error_code' => 410);
             } else {
                 $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406);
             }
             $response_code = 200;
         }
     }
     $response = Response::json($response_array, $response_code);
     return $response;
 }
コード例 #8
0
 public function send_eta()
 {
     $token = Input::get('token');
     $owner_id = Input::get('id');
     $phones = Input::get('phone');
     $request_id = Input::get('request_id');
     $eta = Input::get('eta');
     $validator = Validator::make(array('token' => $token, 'owner_id' => $owner_id, 'phones' => $phones, 'eta' => $eta), array('token' => 'required', 'phones' => 'required', 'owner_id' => 'required|integer', 'eta' => 'required'));
     if ($validator->fails()) {
         $error_messages = $validator->messages()->all();
         $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
         $response_code = 200;
     } else {
         $is_admin = $this->isAdmin($token);
         if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) {
             // check for token validity
             if (is_token_active($owner_data->token_expiry) || $is_admin) {
                 // If phones is not an array
                 if (!is_array($phones)) {
                     $phones = explode(',', $phones);
                 }
                 Log::info('phones = ' . print_r($phones, true));
                 foreach ($phones as $key) {
                     $owner = Owner::where('id', $owner_id)->first();
                     $secret = str_random(6);
                     $request = Requests::where('id', $request_id)->first();
                     $request->security_key = $secret;
                     $request->save();
                     $msg = $owner->first_name . ' ' . $owner->last_name . ' ETA : ' . $eta;
                     send_eta($key, $msg);
                     Log::info('Send ETA MSG  = ' . print_r($msg, true));
                 }
                 $response_array = array('success' => true);
                 $response_code = 200;
             } else {
                 $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
                 $response_code = 200;
             }
         } else {
             if ($is_admin) {
                 /* $var = Keywords::where('id', 2)->first();
                    $response_array = array('success' => false, 'error' => '' . $var->keyword . ' ID not Found', 'error_code' => 410); */
                 $response_array = array('success' => false, 'error' => '' . Config::get('app.generic_keywords.User') . ' ID not Found', 'error_code' => 410);
             } else {
                 $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406);
             }
             $response_code = 200;
         }
     }
     $response = Response::json($response_array, $response_code);
     return $response;
 }
コード例 #9
0
 public function get_track_loc($id)
 {
     $request = Requests::where('security_key', $id)->where('is_started', 1)->where('is_completed', 0)->first();
     if ($request) {
         $owner = Owner::where('id', $request->owner_id)->first();
         $user_name = $owner->first_name . " " . $owner->last_name;
         $theme = Theme::all();
         $logo = '/image/logo.png';
         $favicon = '/image/favicon.ico';
         foreach ($theme as $themes) {
             $favicon = '/uploads/' . $themes->favicon;
             $logo = '/uploads/' . $themes->logo;
         }
         if ($logo == '/uploads/') {
             $logo = '/image/logo.png';
         }
         if ($favicon == '/uploads/') {
             $favicon = '/image/favicon.ico';
         }
         $app_name = Config::get('app.website_title');
         // walk location
         $start_loc = WalkLocation::where('request_id', $request->id)->first();
         $reqloc = WalkLocation::where('request_id', $request->id)->orderBy('id', 'desc')->first();
         $title = 'Track ' . $user_name;
         return Response::json(array('success' => true, 'titl' => $title, 'logo' => $logo, 'favicon' => $favicon, 'app_name' => $app_name, 'cur_lat' => $reqloc->latitude, 'cur_lon' => $reqloc->longitude, 'prev_lat' => $start_loc->latitude, 'prev_lon' => $start_loc->longitude, 'track_id' => $id));
     } else {
         return Redirect::to('/');
     }
 }
コード例 #10
0
 public function request_in_progress()
 {
     $token = Input::get('token');
     $walker_id = Input::get('id');
     $validator = Validator::make(array('token' => $token, 'walker_id' => $walker_id), array('token' => 'required', 'walker_id' => 'required|integer'));
     if ($validator->fails()) {
         $error_messages = $validator->messages()->all();
         $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
         $response_code = 200;
     } else {
         $is_admin = $this->isAdmin($token);
         if ($walker_data = $this->getWalkerData($walker_id, $token, $is_admin)) {
             // check for token validity
             if (is_token_active($walker_data->token_expiry) || $is_admin) {
                 $request = Requests::where('status', '=', 1)->where('is_cancelled', '=', 0)->where('is_completed', '=', 0)->where('confirmed_walker', '=', $walker_id)->first();
                 if ($request) {
                     $request_id = $request->id;
                 } else {
                     $request_id = -1;
                 }
                 $txt_approve = "Decline";
                 if ($walker_data->is_approved) {
                     $txt_approve = "Approved";
                 }
                 $response_array = array('request_id' => $request_id, 'is_approved' => $walker_data->is_approved, 'is_available' => $walker_data->is_active, 'is_approved_txt' => $txt_approve, 'success' => true);
                 $response_code = 200;
             } else {
                 $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
                 $response_code = 200;
             }
         } else {
             if ($is_admin) {
                 /* $driver = Keywords::where('id', 1)->first();
                    $response_array = array('success' => false, 'error' => '' . $driver->keyword . ' ID not Found', 'error_code' => 410); */
                 $response_array = array('success' => false, 'error' => '' . Config::get('app.generic_keywords.Provider') . ' ID not Found', 'error_code' => 410);
             } else {
                 $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406);
             }
             $response_code = 200;
         }
     }
     $response = Response::json($response_array, $response_code);
     return $response;
 }
コード例 #11
0
 public function user_set_destination()
 {
     $request_id = Input::get('request_id');
     $token = Input::get('token');
     $owner_id = Input::get('id');
     $dest_lat = Input::get('dest_lat');
     $dest_long = Input::get('dest_long');
     $validator = Validator::make(array('request_id' => $request_id, 'token' => $token, 'owner_id' => $owner_id, 'dest_lat' => $dest_lat, 'dest_long' => $dest_long), array('request_id' => 'required|integer', 'token' => 'required', 'owner_id' => 'required|integer', 'dest_lat' => 'required', 'dest_long' => 'required'));
     if ($validator->fails()) {
         $error_messages = $validator->messages()->all();
         $response_array = array('success' => false, 'error' => 'Invalid Input', 'error_code' => 401, 'error_messages' => $error_messages);
         $response_code = 200;
     } else {
         $is_admin = $this->isAdmin($token);
         if ($owner_data = $this->getOwnerData($owner_id, $token, $is_admin)) {
             // check for token validity
             if (is_token_active($owner_data->token_expiry) || $is_admin) {
                 // Do necessary operations
                 if ($request = Requests::find($request_id)) {
                     if ($request->owner_id == $owner_data->id) {
                         Requests::where('id', $request_id)->update(array('D_latitude' => $dest_lat, 'D_longitude' => $dest_long));
                         if ($request->current_walker) {
                             $msg_array = array();
                             $msg_array['request_id'] = $request_id;
                             $msg_array['unique_id'] = 4;
                             $last_destination = Requests::find($request_id);
                             $owner = Owner::find($owner_id);
                             $request_data = array();
                             $request_data['owner'] = array();
                             $request_data['owner']['name'] = $owner->first_name . " " . $owner->last_name;
                             $request_data['owner']['picture'] = $owner->picture;
                             $request_data['owner']['phone'] = $owner->phone;
                             $request_data['owner']['address'] = $owner->address;
                             $request_data['owner']['latitude'] = $owner->latitude;
                             $request_data['owner']['longitude'] = $owner->longitude;
                             $request_data['owner']['dest_latitude'] = $last_destination->D_latitude;
                             $request_data['owner']['dest_longitude'] = $last_destination->D_longitude;
                             $request_data['owner']['rating'] = $owner->rate;
                             $request_data['owner']['num_rating'] = $owner->rate_count;
                             $request_data['dog'] = array();
                             if ($dog = Dog::find($owner->dog_id)) {
                                 $request_data['dog']['name'] = $dog->name;
                                 $request_data['dog']['age'] = $dog->age;
                                 $request_data['dog']['breed'] = $dog->breed;
                                 $request_data['dog']['likes'] = $dog->likes;
                                 $request_data['dog']['picture'] = $dog->image_url;
                             }
                             $msg_array['request_data'] = $request_data;
                             $title = "Set Destination";
                             $message = $msg_array;
                             if ($request->confirmed_walker == $request->current_walker) {
                                 send_notifications($request->confirmed_walker, "walker", $title, $message);
                             }
                         }
                         $response_array = array('success' => true, 'error' => "Destination Set Successfully");
                         $response_code = 200;
                     } else {
                         $response_array = array('success' => false, 'error' => 'Request ID doesnot matches with Owner ID', 'error_code' => 407);
                         $response_code = 200;
                     }
                 } else {
                     $response_array = array('success' => false, 'error' => 'Request ID Not Found', 'error_code' => 408);
                     $response_code = 200;
                 }
             } else {
                 $response_array = array('success' => false, 'error' => 'Token Expired', 'error_code' => 405);
                 $response_code = 200;
             }
         } else {
             if ($is_admin) {
                 $response_array = array('success' => false, 'error' => 'Owner ID not Found', 'error_code' => 410);
             } else {
                 $response_array = array('success' => false, 'error' => 'Not a valid token', 'error_code' => 406);
             }
             $response_code = 200;
         }
     }
     $response = Response::json($response_array, $response_code);
     return $response;
 }
コード例 #12
0
 public function send_eta_web()
 {
     if ($_POST) {
         $request_id = Input::get('request_id');
         $mail_ids = Input::get('mail_ids');
         $duration = Input::get('duration');
         $destination = Input::get('destination');
         $source = Input::get('source');
         $request = Requests::where('id', $request_id)->first();
         $splits = explode(',', $mail_ids);
         $user_name = Session::get('user_name');
         foreach ($splits as $key) {
             // send email
             $link = "https://maps.google.com/maps?f=d&hl=en&saddr=" . $source . "&daddr=" . $destination . "&ie=UTF8&om=0&output=kml";
             $pattern = "Hello,<br> " . $user_name . " will Reached the Destination in " . $duration . " (Estimated Time) <br><br><br>For More Information---<br>" . $link . "<br>";
             $subject = "ETA from " . $user_name;
             send_eta_email($key, $pattern, $subject);
         }
         return Redirect::to('/user/request-trip')->with('message', "Your ETA Shared Successfully.");
     }
 }
コード例 #13
0
 public function providerTrips()
 {
     $start_date = Input::get('start_date');
     $end_date = Input::get('end_date');
     $submit = Input::get('submit');
     $start_time = date("Y-m-d H:i:s", strtotime($start_date));
     $end_time = date("Y-m-d H:i:s", strtotime($end_date));
     $start_date = date("Y-m-d", strtotime($start_date));
     $end_date = date("Y-m-d", strtotime($end_date));
     if (!Input::get('start_date') && !Input::get('end_date')) {
         $walker_id = Session::get('walker_id');
         $requests = Requests::where('confirmed_walker', $walker_id)->where('is_completed', 1)->leftJoin('walker', 'walker.id', '=', 'request.confirmed_walker')->leftJoin('walker_type', 'walker_type.id', '=', 'walker.type')->leftJoin('owner', 'owner.id', '=', 'request.owner_id')->orderBy('request_start_time', 'desc')->select('request.id', 'request_start_time', 'owner.first_name', 'owner.last_name', 'request.total as total', 'walker_type.name as type', 'request.distance', 'request.time')->get();
         $total_rides = Requests::where('confirmed_walker', $walker_id)->where('is_completed', 1)->count();
         $total_distance = Requests::where('confirmed_walker', $walker_id)->where('is_completed', 1)->sum('distance');
         $settings = Settings::where('key', 'default_distance_unit')->first();
         $unit = $settings->value;
         $total_earnings = Requests::where('confirmed_walker', $walker_id)->where('is_completed', 1)->sum('total');
         $average_rating = DogReview::where('walker_id', $walker_id)->avg('rating');
     } else {
         $walker_id = Session::get('walker_id');
         $requests = Requests::where('confirmed_walker', $walker_id)->where('is_completed', 1)->where('request_start_time', '>=', $start_time)->where('request_start_time', '<=', $end_time)->leftJoin('walker', 'walker.id', '=', 'request.confirmed_walker')->leftJoin('walker_type', 'walker_type.id', '=', 'walker.type')->leftJoin('owner', 'owner.id', '=', 'request.owner_id')->orderBy('request_start_time', 'desc')->select('request.id', 'request_start_time', 'owner.first_name', 'owner.last_name', 'request.total as total', 'walker_type.name as type', 'request.distance', 'request.time')->get();
         $total_rides = Requests::where('confirmed_walker', $walker_id)->where('is_completed', 1)->where('request_start_time', '>=', $start_time)->where('request_start_time', '<=', $end_time)->count();
         $total_distance = Requests::where('confirmed_walker', $walker_id)->where('is_completed', 1)->where('request_start_time', '>=', $start_time)->where('request_start_time', '<=', $end_time)->sum('distance');
         $total_earnings = Requests::where('confirmed_walker', $walker_id)->where('is_completed', 1)->where('request_start_time', '>=', $start_time)->where('request_start_time', '<=', $end_time)->sum('total');
         $average_rating = DogReview::where('walker_id', $walker_id)->where('created_at', '>=', $start_time)->where('created_at', '<=', $end_time)->avg('rating');
     }
     if (!Input::get('submit') || Input::get('submit') == 'filter') {
         return View::make('web.providerTrips')->with('title', 'My Trips')->with('requests', $requests)->with('total_rides', $total_rides)->with('total_distance', $total_distance)->with('total_earnings', $total_earnings)->with('average_rating', $average_rating);
     } else {
         header('Content-Type: text/csv; charset=utf-8');
         header('Content-Disposition: attachment; filename=data.csv');
         $handle = fopen('php://output', 'w');
         fputcsv($handle, array('Date', 'Customer name', 'Type of Service', 'Distance (Miles)', 'Time (Minutes)', 'Earning'));
         foreach ($requests as $request) {
             fputcsv($handle, array(date('l, F d Y h:i A', strtotime($request->request_start_time)), $request->first_name . " " . $request->last_name, $request->type, $request->distance, $request->time, $request->total));
         }
         fputcsv($handle, array());
         fputcsv($handle, array());
         fputcsv($handle, array('Total Rides', $total_rides));
         fputcsv($handle, array('Total Distance Covered (Miles)', $total_distance));
         fputcsv($handle, array('Average Rating', $average_rating));
         fputcsv($handle, array('Total Earning', $total_earnings));
         fclose($handle);
     }
 }