PK4Z_` Providers/AppServiceProvider.phpnu[configureRateLimiting(); $this->routes(function () { Route::middleware('api') ->prefix('api') ->group(base_path('routes/api.php')); Route::middleware('web') ->group(base_path('routes/web.php')); }); } /** * Configure the rate limiters for the application. * * @return void */ protected function configureRateLimiting() { RateLimiter::for('api', function (Request $request) { return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip()); }); } } PK4Z||&Providers/BroadcastServiceProvider.phpnu[ */ protected $policies = [ // 'App\Models\Model' => 'App\Policies\ModelPolicy', ]; /** * Register any authentication / authorization services. * * @return void */ public function boot() { $this->registerPolicies(); } } PK4Z)("Providers/EventServiceProvider.phpnu[> */ protected $listen = [ Registered::class => [ SendEmailVerificationNotification::class, ], ]; /** * Register any events for your application. * * @return void */ public function boot() { // } /** * Determine if events and listeners should be automatically discovered. * * @return bool */ public function shouldDiscoverEvents() { return false; } } PK4ZvConsole/Commands/SendSMS.phpnu[subDay(1)->startOfDay()->toDateTimeString(); $date_to = Carbon::now()->subDay(1)->endOfDay()->toDateTimeString(); $customer = Customer::whereBetween('created_at',[$date_from,$date_to])->distinct()->get(); foreach($customer as $info){ // Log::info($info); // return; $links = Link::select('link')->where('links_custId',$info['id'])->get(); $comp = explode("/",$links[0]->link); $comp_name = (new User())::select('comp_name')->where('token',$comp[5])->get(); $tinyURL = (new SMSController)->tinyUrl($links[0]->link); $subject = "Security Deposit"; $headers = "From: info@autohubgroup.com\r\n"; $headers .= "Content-Type: text/html\r\n"; $message = view('layouts.email.email',['comp_name'=>$comp_name[0]->comp_name,'customer'=>$info['fname']." ".$info['lname'],'url'=>$tinyURL])->render(); mail($info['email'],$subject,$message,$headers); if(empty($info['mobile'])){ } else { $array_data = [ "method" => "POST", "uri" => "https://api.autohub.ph/v1/sms/default", "key" => "b0d4111b7fff11edab53fa163e06960f", "mobile" => $info['mobile'], "message" => "Thank you for visiting ". $comp_name[0]->comp_name .". We are glad to assist you on your next vehicle purchase. To further serve you better, kindly visit the link below. Thank you. \nLink: ".$tinyURL, ]; $result = (new SMSController)->sendSMS($array_data); $status = json_decode($result,true); $db = DB::table('sms_response'); if($status['status'] == 0){ $db->insert([ 'cust_Id' => $info['id'], 'token' => $comp[5], 'url' => $tinyURL, 'mobile' => $info['mobile'], 'status' => $status['status'], 'message' => ucfirst(strtolower($status['message'])), 'created_at' => NOW() ]); } else { $statusResponse = json_decode($status['response'],true); $db->insert([ 'cust_Id' => $info['id'], 'token' => $comp[5], 'url' => $tinyURL, 'mobile' => $info['mobile'], 'status' => $status['status'], 'message' => "success", 'type' => $statusResponse['type'], 'transid' => $statusResponse['transid'], 'sms_length' => $statusResponse['sms_length'], 'sms_parts' => $statusResponse['sms_parts'], 'transaction_amount' => $statusResponse['transaction_amount'], 'telco' => $statusResponse['telco'], 'created_at' => NOW() ]); } } } } }PK4ZڐConsole/Kernel.phpnu[command('inspire')->hourly(); // $schedule->command('send:sms')->timezone('Asia/Manila')->at('9:00'); /* Run this command below **/ // $schedule->command('send:sms')->timezone('Asia/Manila')->at('9:00'); $schedule->command('send:sms')->everyMinute(); } /** * Register the commands for the application. * * @return void */ protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } } PK4Zj Http/Middleware/TrustProxies.phpnu[|string|null */ protected $proxies; /** * The headers that should be used to detect proxies. * * @var int */ protected $headers = Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO | Request::HEADER_X_FORWARDED_AWS_ELB; } PK4Z# Http/Middleware/Authenticate.phpnu[expectsJson()) { return route('/'); } } } PK4Zgh@@#Http/Middleware/VerifyCsrfToken.phpnu[ */ protected $except = [ // ]; } PK4Z~}}Http/Middleware/TrimStrings.phpnu[ */ protected $except = [ 'current_password', 'password', 'password_confirmation', ]; } PK4Z7mm+Http/Middleware/RedirectIfAuthenticated.phpnu[check()) { return redirect(RouteServiceProvider::HOME); } } return $next($request); } } PK4Z{{nn4Http/Middleware/PreventRequestsDuringMaintenance.phpnu[ */ protected $except = [ // ]; } PK4ZL{ ttHttp/Middleware/TrustHosts.phpnu[ */ public function hosts() { return [ $this->allSubdomainsOfApplicationUrl(), ]; } } PK4Z"q33"Http/Middleware/EncryptCookies.phpnu[ */ protected $except = [ // ]; } PK4ZGf%Http/Middleware/ValidateSignature.phpnu[ */ protected $except = [ // 'fbclid', // 'utm_campaign', // 'utm_content', // 'utm_medium', // 'utm_source', // 'utm_term', ]; } PK4Zs! ! Http/Kernel.phpnu[ */ protected $middleware = [ // \App\Http\Middleware\TrustHosts::class, \App\Http\Middleware\TrustProxies::class, \Illuminate\Http\Middleware\HandleCors::class, \App\Http\Middleware\PreventRequestsDuringMaintenance::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, ]; /** * The application's route middleware groups. * * @var array> */ protected $middlewareGroups = [ 'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, ], 'api' => [ // \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class, 'throttle:api', \Illuminate\Routing\Middleware\SubstituteBindings::class, ], ]; /** * The application's route middleware. * * These middleware may be assigned to groups or used individually. * * @var array */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'auth.session' => \Illuminate\Session\Middleware\AuthenticateSession::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'password.confirm' => \Illuminate\Auth\Middleware\RequirePassword::class, 'signed' => \App\Http\Middleware\ValidateSignature::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class, ]; } PK4Z&O)Http/Controllers/ValidationController.phpnu[timezone('Asia/Manila'); $header = $request->getRequestUri(); $params = explode('/',$header); $param['token'] = $params[3]; $param['comp_token'] = $params[5]; $true = Link::where('token',$param['token'])->get(); if(!empty($true[0]->id)){ if(!empty($true[0]->flag) && !empty($true[0]->verified)){ if(($true[0]->flag == 1) && ($true[0]->verified == 1)){ abort(403, 'You responded already'); // return view('errors.400'); } elseif (($true[0]->flag == 2) && ($true[0]->verified == 2)){ abort(403, 'You responded already'); // return view('errors.401'); } else { abort(403, 'You responded already'); // return view('errors.400'); } } else { $date_diff = date_diff($now, $true[0]->created_at); if($date_diff->days >= 365){ abort(500); // return view('errors.500'); } else { $img = User::where('token',"=",$param['comp_token'])->get(); $image = "/".$img[0]->receipt; $transaction = $true; $comptoken = $param['comp_token']; return view('verify.verify',compact('image','transaction','comptoken')); } } } else { abort(404); // return view('errors.404'); } } // this function verifies the link on the http request and return the view if the link is valid or has not been used. public function fetchImage(Request $request){ $header = url()->previous(); $params = explode('/',$header); dd($params); } public function validateTop(Request $request){ $header = $request->header('referer'); $params = explode('/',$header); $customer_token = $params[5]; $custId = Link::select('links_custId') ->where('token',"=",$customer_token)->get(); // dd($request->all()); $request->validate([ 'amount' => 'required|integer', 'sc_fname' => 'required|regex:/^[a-zA-Z\s]+$/', 'sc_lname' => 'required|regex:/^[a-zA-Z\s]+$/', 'orNo' => 'required', ],[ 'sc_fname.regex' => 'SC Name is invalid', 'sc_lname.regex' => 'SC Surname is invalid', ]); $transaction = new Transaction; $transaction->transactions_custId = $custId[0]->links_custId; $transaction->orNo = $request->orNo; $transaction->amount = $request->amount; $transaction->assisting_sc_fName = $request->sc_fname; $transaction->assisting_sc_lName = $request->sc_lname; if($request->payment_type === "cashier"){ $transaction->cashier_payment = 1; } else { $transaction->sc_payment = 1; } $transaction->save(); Link::where('token',$customer_token) ->where('links_custId',$custId[0]->links_custId) ->update(['flag'=>1,'verified'=>1]); return response()->json(["message"=>"success"]); } //this function gets the information if the customer secures a deposit. public function validateTransaction(Request $request){ $id = $request->id; $custId = $request->custId; $token = $request->token; $type = $request->type; $conditions = [['links_custId',"=",$custId],['id',"=",$id],['token',"=",$token]]; $transaction = Link::where($conditions)->get(); if($transaction[0]['flag'] == null && $transaction[0]['verified'] == null){ if($type == "deny"){ $transaction = Link::where($conditions)->update(['flag'=>2,'verified'=>2]); return response()->json(["message"=>"verified"]); } } else { abort(403,'You responded already'); // return response()->json(["message"=>'You already responded'],401); } } } PK4Z "Http/Controllers/SMSController.phpnu[ $array_data['key'], 'mobile' => $array_data['mobile'], 'message' => $message, ); $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_URL => $array_data['uri'], CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $postData //,CURLOPT_FOLLOWLOCATION => true )); //Ignore SSL certificate verification curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //get response $output = curl_exec($ch); //Print error if any if(curl_errno($ch)) { echo 'error:' . curl_error($ch); } return $output; } public function tinyUrl($url){ $api_url = 'https://tinyurl.com/api-create.php?url=' . "https://guest.autohub.ph".$url; $curl = curl_init(); $timeout = 10; curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_URL, $api_url); $new_url = curl_exec($curl); curl_close($curl); return $new_url; } // this function returns the long url as tiny url using the api of tinyUrl }PK4Z/n***Http/Controllers/InformationController.phpnu[authCheck($view); if(Auth::user()->access === 0){ return view('forms.first_page'); } else { abort(403, 'Access Denied. If you happen to see this upon registering, Please contact admin to activate your account otherwise manually visit ' . url('/') . '.'); } } public function import(){ return view('auth.import'); } public function adminRegister(){ return view('auth.admin-reg'); } public function create(Request $request){ $subscribe = $request->subscribe; $parsedUrl = parse_url($subscribe); $query = $parsedUrl['query']; $sub = ""; if($query == "subscribe=on"){ $sub = 1; } else { $sub = NULL; } $file_name = ""; $image_type = ""; $comp_token = Auth::user()->token; $request->validate([ 'fname' => 'required', 'lname' => 'required', 'mobile' => 'nullable|required_without:email', 'email' => [ 'nullable', 'required_without:mobile', 'email', ], ],[ 'fname.required' => 'First Name is required', 'lname.required' => 'Last Name is required', 'email.email' => 'Email should be in valid email format' ]); $firstName = $request->input('fname'); $mname = $request->input('mname'); $lastName = $request->input('lname'); $count = DB::table('customers') ->where('fname', $firstName) ->where('mname', $mname) ->where('lname', $lastName) ->where('token',$comp_token) ->whereDate('created_at', '=', date('Y-m-d')) ->count(); if ($count > 0) { //check if user registered on this same day on the same dealer throw ValidationException::withMessages([ 'fname' => 'You already registered for today', ]); } if($request->image != "undefined"){ //check if photo has been taken $file_name = $request->fname . "_" . $request->lname; $img = $request->image; $folderPath = "files/img/"; $image_parts = explode(";base64,", $img); $image_type_aux = explode("image/", $image_parts[0]); $image_type = $image_type_aux[1]; $image_base64 = base64_decode($image_parts[1]); $file = $folderPath . $file_name . '.'.$image_type; file_put_contents($file, $image_base64); } $customer = new Customer; //Create new instance of Customer model $customer->fname = $request->fname; $customer->mname = $request->mname; $customer->lname = $request->lname; $customer->nickname = $request->nickname; $customer->mobile = $request->mobile; $customer->messenger = $request->messenger; $customer->email = $request->email; $customer->image = $file_name .'.' .$image_type; $customer->token = $comp_token; $customer->subscribe = $sub; $customer->save(); $token = Str::random(16); $token = uniqid().$token; $link = new Link; $link->links_custId = $customer->id; $link->link = "/verify/token/".$token."/q/".$comp_token; $link->token = $token; $link->save(); return response()->json(["message"=>"success"], 200); } // this is the function that handles the reques when a client registers on the kiosk public function customerSelect2(){ $start = Carbon::now()->startOfDay(); $end = Carbon::now()->endOfDay(); $customer = Customer::select('fname','lname','id') ->whereBetween('created_at',[$start,$end]) ->get(); $customers['results'] = []; foreach($customer as $cust){ $customers['results'][] = [ "id" => $cust['id'], "text" => $cust['fname'] . " " . $cust['lname'], ]; } return response()->json($customers,200); } public function importDetails(Request $request){ // dd($request->all()); $access = null; $request->validate([ 'f_name' => 'nullable|string|required_without_all:dealer_name,dealer_code', 'l_name' => 'nullable|string|required_without_all:dealer_name,dealer_code', 'email' => 'nullable|string|required_without_all:dealer_name,dealer_code', 'official_receipt' => 'required_without_all:f_name,l_name|image|mimes:jpg,png,jpeg,gif,svg|max:2048', 'official_logo' => 'required_without_all:f_name,l_name|image|mimes:jpg,png,jpeg,gif,svg|max:2048', 'comp_name' => 'required', 'dealer_name' => 'required_without_all:f_name,l_name|unique:users,deal_name', 'dealer_code' => 'required_without_all:f_name,l_name|unique:users,deal_code', 'password' => 'required' ],[ 'official_receipt.required_without_all' => 'OR is required', 'official_logo.required_without_all' => 'Logo is required', 'f_name.required_without_all' => 'Name is required', 'l_name.required_without_all' => 'Surname is required', 'email.required_without_all' => 'Email is required', 'comp_name.required' => "Company Name is required", 'dealer_name.required_without_all' => 'Dealer Name is required', 'dealer_code.required_without_all' => 'Dealer Code is required', 'dealer_name.unique' => 'Dealer Name is already taken', 'dealer_code.unique' => 'Dealer Code is already taken', 'password.required' => 'Password is required' ]); if(!empty($request->dealer_name) && !empty($request->dealer_code)){ $check = User::select('id') ->where('deal_name',"=",$request->dealer_name) ->where('deal_code',"=",$request->dealer_code) ->get(); if(!empty($check[0])){ return response()->json(["message"=>"Duplicate Entry"],422); } } $token = Str::random(32); $token = uniqid().$token; if($request->official_receipt){ $file['image'] = uniqid().$request->dealer_code.'.'.$request->official_receipt->extension(); $request->official_receipt->move('files/img/', $file['image']); $path = 'files/img/'.$file['image']; } if($request->official_logo){ $file['image'] = uniqid().$request->dealer_code.'_logo.'.$request->official_logo->extension(); $request->official_logo->move('files/img/logo/', $file['image']); $path2 = 'files/img/logo/'.$file['image']; } // dd($request->all()); $company = new User; if($request->official_receipt || $request->official_logo){ $company->user_name = $request->dealer_code; $company->comp_name = $request->comp_name; $company->deal_name = $request->dealer_name; $company->deal_code = $request->dealer_code; $company->receipt = $path; $company->logo = $path2; $access = 0; } $company->f_name = $request->f_name; $company->l_name = $request->l_name; $company->email = $request->email; $company->password = bcrypt($request->password); $company->token = $token; $company->access = $access; $company->save(); // Auth::login($company); return response()->json(['success'=>'done'],200); } // this is the function that handles the logic when importing details of dealers public function login(Request $request){ $data = []; if(Str::endsWith($request->user_name,'@autohubgroup.com')){ $data = [ 'email' => $request->user_name, 'password' => $request->password ]; } else { $data = [ 'user_name' => $request->user_name, 'password' => $request->password ]; } if (auth()->attempt($data)){ $user = Auth::user(); Auth::login($user); return response()->json('success'); } else { return response()->json(['error'=>'Unauthorized'], 401); } } // this function handles the login logic of the users public function thankyou(){ return view('verify.thankyou'); } // returns the thank you blade file public function feedback(Request $request){ if(!($request->star)){ return response()->json(['message'=>"Please provide a rating"],403); } $header = $request->header('referer'); $params = explode('/',$header); $custId = $params[5]; // $custId = Link::select('links_custId') // ->where('token',"=",$customer_token)->get(); // dd($custId); $feedback = DB::table('ratings') ->insert([ 'cust_id'=>$custId, 'rating'=>$request->star, 'comment'=>$request->feedback, 'created_at'=>NOW(), 'updated_at'=>NOW() ]); if($feedback){ return response()->json(['message'=>"Success"],201); } else { return response()->json(['message'=>"Error"],400); } } // customer feedback page when answering the link sent from sms public function adminLogin(){ return view('admin.login'); } public function adminSignin(Request $request){ $adminCredentials = $request->only('email','password'); if(Auth::guard('admin')->attempt($adminCredentials)){ dd("true"); } else { dd("cannot connect"); } } public function logout(){ Auth::guard('web')->logout(); return redirect('/'); } // logout function } PK4Z_ _ 1Http/Controllers/CustomerProjectionController.phpnu[select(DB::raw('DATE(created_at) as date'), DB::raw('count(*) as count')) ->groupBy('date') ->get(); // Fetch data from the database $customerArray = $customers->toArray(); // Create arrays of input features (dates) and output labels (customer counts) $dates = []; $counts = []; foreach ($customerArray as $row) { $dates[] = strtotime($row->date); $counts[] = $row->count; } // Split the input features and output labels into training and testing sets $splitIndex = (int) (count($dates) * 0.8); $trainingDates = array_slice($dates, 0, $splitIndex); $trainingCounts = array_slice($counts, 0, $splitIndex); $testingDates = array_slice($dates, $splitIndex); $testingCounts = array_slice($counts, $splitIndex); if (!is_array($trainingDates)) { $trainingDates = [$trainingDates]; } if (!is_array($trainingCounts)) { $trainingCounts = [$trainingCounts]; } // Create a linear regression model and train it using the training data $model = new LeastSquares(); $model->train(array_map(function ($date) { return [$date]; }, array_values($trainingDates)), array_values($trainingCounts)); // Use the model to predict the future customer counts $futureDates = [ strtotime('tomorrow'), strtotime('+1 week'), strtotime('+1 month'), strtotime('+3 months'), strtotime('+6 months'), strtotime('+1 year'), strtotime('+2 years'), strtotime('+3 years'), ]; $predictedCounts = array_map(function ($date) use ($model) { return $model->predict([$date]); }, $futureDates); return response()->json(['dates' => $futureDates, 'counts' => $predictedCounts]); } } PK4ZD籍iiHttp/Controllers/Controller.phpnu[cust = new Customer; $this->user = new User; $this->sms = new SmsResponse; $this->transaction = new Transaction; /** * This is the construct wherein a model is stored inside a variable * The model should be instantiated to be able to be assigned in a variable */ } public function dashboard(){ return view('admin.management.dashboard'); } public function storePolicy(Request $request){ // dd($request->all()); $result = DB::table('policy')->update([ 'content' => $request->disclaimer, 'editor' => Auth::user()->id, ]); return response()->json(['message'=>"success"]); } //update the policy public function fetchPolicy(){ $result = DB::table('policy')->select('content') ->first(); return response()->json(['policy'=>$result]); } //fetch the policy and render on the view file public function getCustomerFrequency(Request $request){ $array_data['type'] = $request->type; $array_data['where'] = ""; $dailyStart = Carbon::now()->startOfDay()->toDateTimeString(); $dailyEnd = Carbon::now()->endOfDay()->toDateTimeString(); $weeklyStart = Carbon::now()->startOfWeek()->toDateString(); $weeklyEnd = Carbon::now()->endOfWeek()->toDateString(); $monthlyStart = Carbon::now()->startOfMonth()->toDateString(); $monthlyEnd = Carbon::now()->endOfMonth()->toDateString(); $quarterlyStart = Carbon::now()->startOfQuarter(); $quarterlyEnd = Carbon::now()->endOfQuarter(); $yearlyStart = Carbon::now()->startOfYear(); $yearlyEnd = Carbon::now()->endOfYear(); $results = array( $this->generateReport('daily', $dailyStart, $dailyEnd, $request->dealer), $this->generateReport('weekly', $weeklyStart, $weeklyEnd, $request->dealer), $this->generateReport('monthly', $monthlyStart, $monthlyEnd, $request->dealer), $this->generateReport('quarterly', $quarterlyStart, $quarterlyEnd, $request->dealer), $this->generateReport('yearly', $yearlyStart, $yearlyEnd, $request->dealer) ); return response()->json($results); } //used for generating charts in the dashboard function generateReport($type, $start, $end, $dealer) { $array_data['where'] = ""; if(!empty($dealer)){ $array_data['where'] .= " AND `links`.`link` LIKE '%".$dealer."%'"; } $array_data['where'] .= " AND DATE(`cst`.`created_at`) BETWEEN '$start' AND '$end' "; $results['count'] = count( $results[$type] = $this->cust->reports($array_data)); return $results; } public function authCheck($view){ if(Auth::user()->access === 0){ return view($view); }elseif(Auth::user()->access === 1) { return view($view); } else { abort(403); } } public function adminDashboard(){ $today_start = Carbon::now()->startOfDay()->setTimezone('Asia/Manila')->toDateTimeString(); $today_end = Carbon::now()->endOfDay()->setTimezone('Asia/Manila')->toDateTimeString(); $week_start = Carbon::now()->startOfWeek()->setTimezone('Asia/Manila')->toDateTimeString(); $week_end = Carbon::now()->endOfWeek()->setTimezone('Asia/Manila')->toDateTimeString(); $month_start = Carbon::now()->startOfMonth()->setTimezone('Asia/Manila')->toDateTimeString(); $month_end = Carbon::now()->endOfMonth()->setTimezone('Asia/Manila')->toDateTimeString(); $year_start = Carbon::now()->startOfYear()->setTimezone('Asia/Manila')->toDateTimeString(); $year_end = Carbon::now()->endOfYear()->setTimezone('Asia/Manila')->toDateTimeString(); $daily = Customer::whereBetween('created_at',[$today_start,$today_end])->get(); $weekly = Customer::whereBetween('created_at',[$week_start,$week_end])->get(); $monthly = Customer::whereBetween('created_at',[$month_start,$month_end])->get(); $yearly = Customer::whereBetween('created_at',[$year_start,$year_end])->get(); return view('admin.dashboard',compact('daily','weekly', 'monthly', 'yearly')); } //dashboard public function reports(){ if(auth()->user()->access == 1){ return view('admin.report'); } else { abort(403, 'Access Denied. If you happen to see this upon registering, Please contact admin to activate your account otherwise manually visit ' . url('/') . '.'); } } //reports public function reportIndex(){ if(Auth::user()->access == 1){ return view('admin.blank'); } else { abort(403, 'Access Denied. Please go back to the home page or manually visit ' . url('/') . '.'); } } public function customerDashboard(){ return view('admin.report.customer'); } public function dealerDashboard(){ return view('admin.report.dealer'); } public function smsDashboard(){ return view('admin.report.sms'); } public function transactionDashboard(){ return view('admin.report.transaction'); } public function orDashboard(){ return view('admin.report.or_compliance'); } // ############### REPORTS QUERY ############# // public function customerReport(Request $request){ $array_data['type'] = $request->type; $array_data['where'] = ""; if(!empty($request->from_date) && !empty($request->to_date)){ $from = Carbon::parse($request->from_date); $to = Carbon::parse($request->to_date); $fromdate = $from->toDateString(); $todate = $to->toDateString(); $array_data['where'] .= " AND DATE(`cst`.`created_at`) BETWEEN '$fromdate' AND '$todate' "; } if(!empty($request->dealer)){ $array_data['where'] .= " AND `links`.`link` LIKE '%".$request->dealer."%'"; } $results = $this->cust->reports($array_data); $response = $this->cust->pdf($results, $request->dealer); $pdf = App::make('dompdf.wrapper'); $pdf->loadView('layouts.reports.customer',$response); switch($array_data['type']){ case('view'): return $pdf->stream(); break; case('pdf'): return $pdf->download("customers-masterfile.pdf"); break; case('csv'): $this->cust->csv($results); break; } } public function dealerReport(Request $request){ $array_data['type'] = $request->type; $array_data['where'] = ""; if(!empty($request->from_date) && !empty($request->to_date)){ $from = Carbon::parse($request->from_date); $to = Carbon::parse($request->to_date); $fromdate = $from->toDateString(); $todate = $to->toDateString(); $array_data['where'] .= " AND DATE(`created_at`) BETWEEN '$fromdate' AND '$todate' "; } $results = $this->user->reports($array_data); $response = $this->user->pdf($results); $pdf = App::make('dompdf.wrapper'); $pdf->loadView('layouts.reports.dealer',$response); switch($array_data['type']){ case('view'): return $pdf->stream(); break; case('pdf'): return $pdf->download("dealers-masterfile.pdf"); break; case('csv'): $this->user->csv($results); break; } } public function smsReport(Request $request){ $array_data['type'] = $request->type; $array_data['where'] = ""; $fromdate = null; $todate = null; if(!empty($request->from_date) && !empty($request->to_date)){ $from = Carbon::parse($request->from_date); $to = Carbon::parse($request->to_date); $fromdate = $from->toDateString(); $todate = $to->toDateString(); $array_data['where'] .= " AND DATE(`sms`.`created_at`) BETWEEN '$fromdate' AND '$todate' "; } if(!empty($request->dealer)){ $array_data['where'] .= " AND `sms`.`token` LIKE '%".$request->dealer."%'"; } $results = $this->sms->reports($array_data); $response = $this->sms->pdf($results, $request->dealer, $fromdate, $todate); $pdf = App::make('dompdf.wrapper'); $pdf->loadView('layouts.reports.sms',$response); switch($array_data['type']){ case('view'): return $pdf->stream(); break; case('pdf'): return $pdf->download("sms-masterfile.pdf"); break; case('csv'): $this->sms->csv($results); break; } } public function transactionReport(Request $request){ // dd($request->all()); $array_data['type'] = $request->type; $array_data['where'] = ""; if(!empty($request->from_date) && !empty($request->to_date)){ $from = Carbon::parse($request->from_date); $to = Carbon::parse($request->to_date); $fromdate = $from->toDateString(); $todate = $to->toDateString(); $array_data['where'] .= " AND DATE(`trs`.`created_at`) BETWEEN '$fromdate' AND '$todate' "; } if(!empty($request->dealer)){ $array_data['where'] .= " AND `cst`.`token` LIKE '%".$request->dealer."%' "; // $array_data['where'] .= " AND `sms`.`token` LIKE '%".$request->dealer."%'"; } $results = $this->transaction->reports($array_data); $response = $this->transaction->pdf($results, $request->dealer); $pdf = App::make('dompdf.wrapper'); $pdf->loadView('layouts.reports.transaction',$response); switch($array_data['type']){ case('view'): return $pdf->stream(); break; case('pdf'): return $pdf->download("transaction-masterfile.pdf"); break; case('csv'): $this->transaction->csv($results,$request->dealer); break; } } public function orReport(Request $request){ $array_data['type'] = $request->type; $array_data['where'] = ""; if(!empty($request->from_date) && !empty($request->to_date)){ $from = Carbon::parse($request->from_date); $to = Carbon::parse($request->to_date); $fromdate = $from->toDateString(); $todate = $to->toDateString(); $array_data['where'] .= " AND DATE(`trs`.`created_at`) BETWEEN '$fromdate' AND '$todate' "; } if(!empty($request->dealer)){ $array_data['where'] .= " AND `cst`.`token` LIKE '%".$request->dealer."%' "; } if(!empty($request->or_status)){ $array_data['where'] .= " AND `links`.`flag` = {$request->or_status} "; $array_data['where'] .= " AND `links`.`verified` = {$request->or_status} "; } else if ($request->or_status == 4){ $array_data['where'] .= " AND(`links`.`flag` = 1 OR `links`.`flag` = 2 OR `links`.`flag` IS NULL) "; $array_data['where'] .= " AND (`links`.`verified` = 1 OR `links`.`verified` = 2 OR `links`.`verified` IS NULL) "; } else { $array_data['where'] .= " AND `links`.`flag` IS NULL "; $array_data['where'] .= " AND `links`.`verified` IS NULL "; } $results = $this->transaction->orReports($array_data); // dd($results); $response = $this->transaction->ORpdf($results, $request->dealer); $pdf = App::make('dompdf.wrapper'); $pdf->loadView('layouts.reports.or_compliance',$response) ->setPaper('a4','landscape'); switch($array_data['type']){ case('view'): return $pdf->stream(); break; case('pdf'): return $pdf->download("OR-Compliance-masterfile.pdf"); break; case('csv'): $this->transaction->ORcsv($results,$request->dealer); break; } } public function customerReportDaily(Request $request){ } public function dealerList(Request $request){ $data = []; $term = $request->search; $response = DB::table('users') ->where(function($query) use ($term){ $query->orWhere('deal_name','like','%'.$term.'%') ->orWhere('deal_code','like','%'.$term.'%'); }) ->get(); foreach($response as $item){ $data['results'][] = [ 'id' => $item->token, 'text' => $item->deal_name . " (" .$item->deal_code. ")" ]; } return response()->json($data); } //fetching of dealer list for select2 function public function userMgmnt(){ if(Auth::user()->access == 1){ return view('admin.management.user_management'); } else { abort(403); } } //user management index public function getSMS(Request $request){ $array_data['search_keyword'] = $request->search['value']; if(empty($request->search_type)){ $array_data['search_type'] = ""; } else { $array_data['search_type'] = json_decode($request->search_type,true)[0]; } $array_data['sort'] = $request->order[0]['dir']; $array_data['order'] = $request->columns[$request->order[0]['column']]['data']; $array_data['offset'] = $request->start; $array_data['limit'] = $request->length; $array_data['offset_limit'] = " LIMIT {$array_data['offset']},{$array_data['limit']}"; $array_data['sort'] = " ORDER BY {$array_data['order']} {$array_data['sort']} "; $array_data['search'] = ""; $array_data['where'] = ""; $data = $request->data; if($data['dealer']){ $array_data['where'] .= " AND `sms`.`token` = '{$data['dealer']}' "; } $results = $this->sms->getSMS($array_data); $result['data'] = array(); foreach($results as $row){ $result['data'][] = array( "id" => $row->id, "customer" => $row->name, "company"=> $row->company, "dealer"=> $row->dealer, "mobile" => $row->mobile, "url" => $row->url, "telco" => $row->telco, "message" => $row->message, "status" => $row->status, "date" => $row->created_at, ); } $result['draw'] = $request->draw; $result['recordsTotal'] = $this->sms->getSMSCount($array_data)[0]->Count ; $result['recordsFiltered'] = $this->sms->getSMSFilteredCount($array_data)[0]->FilteredCount ; return response()->json($result); } //get sms query function for datatable public function getUserAll(Request $request){ $array_data['search_keyword'] = $request->search['value']; if(empty($request->search_type)){ $array_data['search_type'] = ""; } else { $array_data['search_type'] = $request->search_type; ; } $array_data['sort'] = $request->order[0]['dir']; $array_data['order'] = $request->columns[$request->order[0]['column']]['data']; $array_data['offset'] = $request->start; $array_data['limit'] = $request->length; $array_data['offset_limit'] = " LIMIT {$array_data['offset']},{$array_data['limit']}"; $array_data['sort'] = " ORDER BY {$array_data['order']} {$array_data['sort']} "; $array_data['search'] = ""; $array_data['where'] = ""; $data = $request->data; $user_id = auth()->user()->id; $fields = " id, f_name, l_name, email, created_at, access"; $array_data['where'] .= " AND comp_name IS NULL AND deal_name IS NULL AND deal_code IS NULL "; $array_data['where'] .= " AND id <> {$user_id} "; if(!empty($array_data['search_keyword'])){ $array_data['search'] =" AND (f_name LIKE '%{$array_data['search_keyword']}%' OR l_name LIKE '%{$array_data['search_keyword']}%' OR email LIKE '%{$array_data['search_keyword']}%' ) "; } $results = $this->user->getUsers($array_data,$fields); $result = array(); foreach($results as $row){ $result['data'][] = array( 'id' => $row->id, 'name' => $row->f_name . " " . $row->l_name, 'email' => $row->email, 'date' => $row->created_at, 'access' => $row->access ); } $result['draw'] = $request->draw; $result['recordsTotal'] = $this->user->getUsersCount($array_data)[0]->Count; $result['recordsFiltered'] = $this->user->getUsersFilteredCount($array_data)[0]->FilteredCount; return response()->json($result); } //get users query function for datatable public function getDealerAll(Request $request){ $array_data['search_keyword'] = $request->search['value']; if(empty($request->search_type)){ $array_data['search_type'] = ""; } else { // $array_data['search_type'] = json_decode($request->search_type,true)[0]; $array_data['search_type'] = $request->search_type; } $array_data['sort'] = $request->order[0]['dir']; $array_data['order'] = $request->columns[$request->order[0]['column']]['data']; $array_data['offset'] = $request->start; $array_data['limit'] = $request->length; $array_data['offset_limit'] = " LIMIT {$array_data['offset']},{$array_data['limit']}"; $array_data['sort'] = " ORDER BY {$array_data['order']} {$array_data['sort']} "; $array_data['search'] = ""; $array_data['where'] = ""; $fields = " id, deal_name, deal_code, comp_name, created_at, access"; $array_data['where'] .= " AND f_name IS NULL AND l_name IS NULL AND email IS NULL AND status IS NOT NULL "; if(!empty($array_data['search_keyword'])){ $array_data['search'] =" AND (deal_name LIKE '%{$array_data['search_keyword']}%' OR deal_code LIKE '%{$array_data['search_keyword']}%' OR comp_name LIKE '%{$array_data['search_keyword']}%' ) "; } $results = $this->user->getUsers($array_data,$fields); foreach($results as $row){ $result['data'][] = array( 'id' => $row->id, 'comp_name' => $row->comp_name, 'deal_name' => $row->deal_name, 'deal_code' => $row->deal_code, 'date' => $row->created_at, 'access' => $row->access ); } $result['draw'] = $request->draw; $result['recordsTotal'] = $this->user->getDealersCount($array_data)[0]->Count; $result['recordsFiltered'] = $this->user->getDealersFilteredCount($array_data)[0]->FilteredCount; return response()->json($result); } //get dealer query function for datatable public function getDealer($id){ $user = User::findOrFail($id); return view('admin.management.edit_dealer')->with(['user'=>$user]); } //get the dealer details public function updateDealer(Request $request, $id){ $dealer = User::findOrFail($id); if(empty($dealer)){ return response()->json(["message"=>"Invalid Action"],403); } $request->validate([ 'comp_name' => 'required', 'deal_name' => 'required', 'deal_code' => 'required', 'password' => 'confirmed', ],[ 'comp_name.required' => 'Company is Required', 'deal_name.required' => 'Dealer is Required', 'deal_code.required' => 'Dealer Code is Required' ]); if($request->official_receipt){ $file['image'] = uniqid().$request->deal_code.'.'.$request->official_receipt->extension(); $request->official_receipt->move('files/img/', $file['image']); $path = 'files/img/'.$file['image']; $dealer->receipt = $path; } if($request->official_logo){ $file['image'] = uniqid().$request->deal_code.'_logo.'.$request->official_logo->extension(); $request->official_logo->move('files/img/logo/', $file['image']); $path2 = 'files/img/logo/'.$file['image']; $dealer->logo = $path2; } $dealer->comp_name = $request->comp_name; $dealer->deal_name = $request->deal_name; $dealer->deal_code = $request->deal_code; $dealer->user_name = $request->deal_code; // if($request->official_receipt || $request->official_logo){ // } if($request->password){ $dealer->password = bcrypt($request->password); } $dealer->save(); return response()->json(['success'=>'success'],200); } //update the dealer details public function deleteDealer(Request $request, $id){ $dealer = User::findOrFail($id); if(empty($dealer)){ return response()->json(["message"=>"Invalid Action"],403); } $dealer->status = null; $dealer->save(); return response()->json(['message'=>"Success"]); } //delete/deactivate the dealer public function getTransactionsAll(Request $request){ $array_data['search_keyword'] = $request->search['value']; if(empty($request->search_type)){ $array_data['search_type'] = ""; } else { $array_data['search_type'] = json_decode($request->search_type,true)[0]; } $array_data['sort'] = $request->order[0]['dir']; $array_data['order'] = $request->columns[$request->order[0]['column']]['data']; $array_data['offset'] = $request->start; $array_data['limit'] = $request->length; $array_data['offset_limit'] = " LIMIT {$array_data['offset']},{$array_data['limit']}"; $array_data['sort'] = " ORDER BY {$array_data['order']} {$array_data['sort']} "; $array_data['search'] = ""; $array_data['where'] = ""; $data = $request->data; if($data['dealer']){ $array_data['where'] .= " AND `cst`.`token` = '{$data['dealer']}' "; } $results = $this->transaction->getTransaction($array_data); $result['data'] = array(); foreach($results as $row){ $result['data'][] = array( "id" => $row->id, "customer" => $row->name, "paid_to" => ($row->cashier_payment == 1) ? "Cashier" : (($row->sc_payment == 1) ? "SC" : " "), "date" => $row->created_at ); } $result['draw'] = $request->draw; $result['recordsTotal'] = $this->transaction->getTransactionCount($array_data)[0]->Count; $result['recordsFiltered'] = $this->transaction->getTransactionFilteredCount($array_data)[0]->FilteredCount; return response()->json($result); } //get the transactions query function public function getTransactionDetails($id){ $result = DB::table('transactions as trs') ->join('customers as cst', 'trs.transactions_custId', "=", 'cst.id') ->join('users as comp', 'cst.token', "=", 'comp.token') ->select(DB::raw('CONCAT(cst.fname, " ", cst.lname) as customer'), 'cst.mobile','cst.email','cst.created_at as visit_date', 'trs.orNo','trs.amount',DB::raw('CONCAT(trs.assisting_sc_fName, " ", trs.assisting_sc_lName) as SC'), 'trs.cashier_payment','trs.sc_payment','trs.created_at as transaction_date', 'comp.comp_name') ->where('trs.id',"=",$id) ->get() ; return response()->json($result); } //get specific transaction query function public function updateUserRole(Request $request, $id){ $user = User::findOrFail($id); $user->access = $request->type; $user->save(); return response()->json(['message'=>"success"],200); } //update the user role query function public function update(Request $request){ $user = User::findOrFail(auth()->user()->id); if(empty($request->password)){ $user->f_name = $request->name; $user->l_name = $request->surname; $user->email = $request->email; $user->save(); return response()->json(['message'=>"updated without password"]); } else { $validate = $request->validate([ 'password' => 'confirmed', ]); $user->f_name = $request->name; $user->l_name = $request->surname; $user->email = $request->email; $user->password = bcrypt($request->password); $user->save(); return response()->json(['message'=>"updated with password"]); } } //update the user profile query function } PK4Z B %Http/Controllers/RatingController.phpnu[ratingResponsiveness; $var2 = $request->ratingPortability; $var3 = $request->ratingUsability; $var4 = $request->ratingDesign; $var5 = $request->ratingSpeed; $rating = new Rating; $rating->responsiveness = $request->ratingResponsiveness; $rating->portability = $request->ratingPortability; $rating->usability = $request->ratingUsability; $rating->design = $request->ratingDesign; $rating->speed = $request->ratingSpeed; $rating->review = $request->review; $rating->average = (($var1 + $var2 + $var3 + $var4 + $var5)/5); $rating->save(); return response()->json(['message'=>'success'],200); } // this function holds the logic after the user successfully answered the link provided /** * Display the specified resource. * * @param \App\Models\Rating $rating * @return \Illuminate\Http\Response */ public function show(Rating $rating) { // } /** * Show the form for editing the specified resource. * * @param \App\Models\Rating $rating * @return \Illuminate\Http\Response */ public function edit(Rating $rating) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\Models\Rating $rating * @return \Illuminate\Http\Response */ public function update(Request $request, Rating $rating) { // } /** * Remove the specified resource from storage. * * @param \App\Models\Rating $rating * @return \Illuminate\Http\Response */ public function destroy(Rating $rating) { // } } PK4Z mExceptions/Handler.phpnu[, \Psr\Log\LogLevel::*> */ protected $levels = [ // ]; /** * A list of the exception types that are not reported. * * @var array> */ protected $dontReport = [ // ]; /** * A list of the inputs that are never flashed to the session on validation exceptions. * * @var array */ protected $dontFlash = [ 'current_password', 'password', 'password_confirmation', ]; /** * Register the exception handling callbacks for the application. * * @return void */ public function register() { $this->reportable(function (Throwable $e) { // }); } } PK4Z:}}Models/Customer.phpnu[getCustomersReportQuery(), $fields, $array_data['where'] ); // dd($query); return DB::select($query); } // public function pdf($results, $type){ // $data = []; // $grpData = new \stdClass(); // $grpData->list = $results; // $grpData->total = sizeOf($results); // array_push($data, $grpData); // $report_title = "Customers Masterfile"; // $reportData = [ // 'data' => $data, // 'webpage_title' => "Customers Report", // 'report_title' => $report_title, // 'table_headers' => ['No.','Customer','Mobile', 'Date of Visit'], // 'table_body' => ['name','mobile', 'created_at'] // ]; // return $reportData; // } public function pdf($results, $dealer) { $dealer = User::select('deal_name')->where('token',$dealer)->first(); // Create an associative array to group the customers by date $groupedData = []; // foreach ($results as $result) { // $date = $result->created_at; // if (!array_key_exists($date, $groupedData)) { // $groupedData[$date] = []; // } // $groupedData[$date][] = $result; // } // Create an array of grouped data objects $data = []; // foreach ($groupedData as $date => $results) { $grpData = new \stdClass(); $grpData->list = $results; $grpData->total = sizeOf($results); // $grpData->date = $date; // $data[] = $grpData; // } array_push($data, $grpData); // Sort the grouped data objects by date // usort($data, function ($a, $b) { // return strtotime($a->date) - strtotime($b->date); // }); $title = $dealer->deal_name ?? ' Autohub Wide'; $report_title = "Customers Masterfile ".$title; // $start_date = isset($data[0]) ? $data[0]->date : ''; // $end_date = isset($data[count($data) - 1]) ? $data[count($data) - 1]->date : ''; // if(empty($start_date)){ // $dateRange = "Date Range: "; // } else { // $dateRange = "Date Range: " . date('F j, Y', strtotime($start_date)) . " - " . date('F j, Y', strtotime($end_date)); // } $reportData = [ 'data' => $data, 'webpage_title' => "Customers Report", 'report_title' => $report_title, // 'date_range' => $dateRange, 'table_headers' => ['#','Customer','Mobile','Email', 'Date of Visit'], 'table_body' => ['name','mobile','email', 'created_at'] ]; return $reportData; } public function csv($results){ // dd($results); $customer = []; $customer[] = ['No.', 'Name', 'Mobile', 'Email', 'Created At']; $inc = 0; foreach($results as $row){ $customer[] = [ $inc+=1, $row->name, $row->mobile, $row->email, $row->created_at ]; } $filename = "Customers_Masterfile"."-". date('Y-m-d').'.csv'; // dd($customer); header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); $f = fopen('php://output', 'wb'); if ($f === false) { die('Error opening the file ' .$filename); } if(empty($customer[1])){ $arr = [ "No data to show" ]; fputcsv($f, $arr); } else { foreach ($customer as $row) { fputcsv($f, $row, ','); } } fclose($f); } } PK4Z(ʉModels/Admin.phpnu[ */ protected $fillable = [ 'user_name', 'comp_name', 'comp_code', 'password', 'token', ]; /** * The attributes that should be hidden for serialization. * * @var array */ protected $hidden = [ 'password', // 'remember_token', ]; /** * The attributes that should be cast. * * @var array */ // protected $casts = [ // 'email_verified_at' => 'datetime', // ]; public function getDealerReportQuery(){ return " SELECT %s FROM users WHERE 1 AND `comp_name` IS NOT NULL AND `deal_code` IS NOT NULL AND `deal_name` IS NOT NULL %s "; } public function reports($array_data){ // dd($array_data); $fields = " comp_name, deal_name, deal_code, DATE_FORMAT(created_at,'%b. %d, %Y') as created_at "; $query = sprintf( $this->getDealerReportQuery(), $fields, $array_data['where'] ); return DB::select($query); } public function pdf($results){ $data = []; $grpData = new \stdClass(); $grpData->list = $results; $grpData->total = sizeOf($results); array_push($data, $grpData); $report_title = "Company Masterfile"; $reportData = [ 'data' => $data, 'webpage_title' => "Company Report", 'report_title' => $report_title, 'table_headers' => ['No.','Company','Dealer Name','Date Created'], 'table_body' => ['comp_name','deal_name','created_at'], // 'img' => $base64 ]; return $reportData; } public function csv($results){ $companies = []; $companies[] = ['No.', 'Company Code', 'Company Name', 'Created At']; $inc = 0; foreach($results as $row){ $companies[] = [ $inc+=1, $row->comp_code, $row->comp_name, $row->created_at ]; } $filename = "Companies_Masterfile"."-". date('Y-m-d').'.csv'; // dd($customer); header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); $f = fopen('php://output', 'wb'); if ($f === false) { die('Error opening the file ' .$filename); } if(empty($companies[1])){ $arr = [ "No data to show" ]; fputcsv($f, $arr); } else { foreach ($companies as $row) { fputcsv($f, $row, ','); } } fclose($f); } public function getUsersQuery(){ return "SELECT %s FROM users WHERE 1 %s %s %s %s "; } public function getUsers($array_data,$fields){ // $fields = " * "; $query = sprintf( $this->getUsersQuery(), $fields, $array_data['search'], $array_data['where'], $array_data['sort'], $array_data['offset_limit'] ); return DB::select($query); } public function getUsersCount($array_data){ $fields = " COUNT(1) as Count "; $query = sprintf( $this->getUsersQuery(), $fields, '', $array_data['where'], '', '' ); return DB::select($query); } public function getUsersFilteredCount($array_data){ $fields = " COUNT(1) as FilteredCount "; $query = sprintf( $this->getUsersQuery(), $fields, $array_data['search'], $array_data['where'], '', '' ); return DB::select($query); } public function getDealersCount($array_data){ $fields = " COUNT(1) as Count "; $query = sprintf( $this->getUsersQuery(), $fields, '', $array_data['where'], '', '' ); return DB::select($query); } public function getDealersFilteredCount($array_data){ $fields = " COUNT(1) as FilteredCount "; $query = sprintf( $this->getUsersQuery(), $fields, $array_data['search'], $array_data['where'], '', '' ); return DB::select($query); } } PK4Z͛kModels/Transaction.phpnu[getTransactionQuery(), $fields, $array_data['search'], $array_data['where'], $array_data['sort'], $array_data['offset_limit'] ); return DB::select($query); } public function getTransactionCount($array_data){ $fields = " COUNT(1) as Count "; $query = sprintf( $this->getTransactionQuery(), $fields, '', $array_data['where'], '', '' ); return DB::select($query); } public function getTransactionFilteredCount($array_data){ $fields = " COUNT(1) as FilteredCount "; $query = sprintf( $this->getTransactionQuery(), $fields, $array_data['search'], $array_data['where'], '', '' ); return DB::select($query); } public function getTransactionReportQuery(){ return "SELECT %s FROM `transactions` `trs` INNER JOIN `customers` `cst` ON `trs`.`transactions_custId` = `cst`.`id` WHERE 1 %s "; } public function reports($array_data){ $fields = " `trs`.`id`,`trs`.`orNo` ,CONCAT(`cst`.`fname`, ' ', `cst`.`lname`) as name, CONCAT(`trs`.`assisting_sc_fName`,'',`trs`.`assisting_sc_lName`) as SCName ,IF(`trs`.`cashier_payment` = 1, 'Cashier', 'SC') AS payment_to, `trs`.`amount`, DATE_FORMAT(`trs`.`created_at`, '%b %d, %Y') as created_at "; $query = sprintf( $this->getTransactionReportQuery(), $fields, $array_data['where'] ); return DB::select($query); } public function pdf($results, $dealer){ // dd($results); $dealer = User::select('deal_name')->where('token',$dealer)->first(); $data = []; $grpData = new \stdClass(); $grpData->list = $results; $grpData->total = sizeOf($results); array_push($data, $grpData); $report_title = $dealer->deal_name . " Transactions Masterfile"; $reportData = [ 'data' => $data, 'webpage_title' => "Transaction Report", 'report_title' => $report_title, 'dealer' => $dealer, 'table_headers' => ['No.','OR No.','Customer', 'Assisting SC', 'Payment To', 'Amount', 'Filing Date'], 'table_body' => ['orNo','name','SCName','payment_to','amount','created_at'], ]; return $reportData; } public function csv($results, $dealer){ $dealer = User::select('deal_name')->where('token',$dealer)->first(); $transaction = []; $transaction[] = ['No.','SC Name', 'Payment To','Amount','Date']; $inc = 0; foreach($results as $row){ $transaction[] = [ $inc+=1, $row->name, $row->payment_to, $row->amount, $row->created_at ]; } $filename = "Transaction_Masterfile"."-".date('Y-m-d').'.csv'; header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); $f = fopen('php://output', 'wb'); if ($f === false) { die('Error opening the file ' .$filename); } if(empty($transaction[1])){ $arr = [ "No data to show" ]; fputcsv($f, $arr); } else { fputcsv($f,[$dealer->deal_name]); foreach ($transaction as $row) { fputcsv($f, $row, ','); } } fclose($f); } public function getOrReportQuery(){ return "SELECT %s FROM `links` `links` INNER JOIN `customers` `cst` ON `links`.`links_custId` = `cst`.`id` WHERE 1 %s "; } public function orReports($array_data){ $fields = " `links`.`id`, CONCAT('https://kiosk.autohub.ph',`links`.`link`) as link, CONCAT(`cst`.`fname`, ' ', `cst`.`lname`) as name "; $query = sprintf( $this->getOrReportQuery(), $fields, $array_data['where'] ); // dd($query); return DB::select($query); } public function ORpdf($results, $dealer){ // dd($results); $dealer = User::select('deal_name')->where('token',$dealer)->first(); $data = []; $grpData = new \stdClass(); $grpData->list = $results; $grpData->total = sizeOf($results); array_push($data, $grpData); $report_title = $dealer->deal_name ?? 'Autohub Wide' . " Transactions Masterfile"; $reportData = [ 'data' => $data, 'webpage_title' => "Transaction Report", 'report_title' => $report_title, 'dealer' => $dealer, 'table_headers' => ['No.','Link', 'Name'], 'table_body' => ['link','name'], ]; return $reportData; } public function ORcsv($results, $dealer){ // dd($results); $dealer = User::select('deal_name')->where('token',$dealer)->first(); $filename = "OR_Compliance_Masterfile"."-".date('Y-m-d').'.csv'; // $transaction = []; // $transaction[] = ['No.','Link', 'Name']; // $inc = 0; // foreach($results as $row){ // $transaction[] = [ // $inc+=1, // $row->link, // $row->name, // ]; // } // header('Content-Type: text/csv'); // header('Content-Disposition: attachment; filename="'.$filename.'"'); // $f = fopen('php://output', 'wb'); // if ($f === false) { // die('Error opening the file ' .$filename); // } // if(empty($transaction[1])){ // $arr = [ // "No data to show" // ]; // fputcsv($f, $arr); // } else { // fputcsv($f,[$dealer->deal_name]); // foreach ($transaction as $row) { // fputcsv($f, $row, ','); // } // } // fclose($f); $generator = function () use ($results) { foreach ($results as $row) { yield [ 'link' => $row->link, 'name' => $row->name, ]; } }; $output = fopen('php://temp', 'w'); fputcsv($output, ['No.', 'Link', 'Name']); // Chunk size determines the number of rows processed at a time $chunkSize = 100; $inc = 0; foreach ($generator() as $row) { $inc++; fputcsv($output, [ $inc, $row['link'], $row['name'], ]); // Break the loop after each chunk is processed if ($inc % $chunkSize === 0) { break; } } rewind($output); $csvContent = stream_get_contents($output); fclose($output); return response($csvContent, 200, [ 'Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment; filename="' . $filename . '"', ]); } } PK4Z~Models/Link.phpnu[getSMSReportQuery(), $fields, $array_data['where'] ); return DB::select($query); } public function pdf($results, $dealer, $fromdate, $todate){ $dealer = User::select('deal_name')->where('token',$dealer)->first(); $data = []; $grpData = new \stdClass(); $date_range = ''; if(!empty($fromdate) && !empty($todate)){ $date_range = $fromdate." - ".$todate; } else { $date_range = "----/--/-- - ----/--/--"; } $grpData->list = $results; $grpData->total = sizeOf($results); array_push($data, $grpData); $report_title = $dealer->deal_name . " SMS Masterfile"; $reportData = [ 'data' => $data, 'webpage_title' => "Company Report", 'report_title' => $report_title, 'date_range' => $date_range, 'dealer' => $dealer, 'table_headers' => ['No.','Name', 'Mobile','URL','Telco','Status','Message','Date'], 'table_body' => ['name','mobile', 'url', 'telco', 'status', 'message', 'created_at'], ]; return $reportData; } public function csv($results){ $sms = []; $sms[] = ['No.','Name', 'Mobile','URL','Telco','Status','Message','Date']; $inc = 0; foreach($results as $row){ $sms[] = [ $inc+=1, $row->name, $row->mobile, $row->url, $row->telco, $row->status, $row->message, $row->created_at ]; } $filename = "SMS_Masterfile"."-". date('Y-m-d').'.csv'; // dd($customer); header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); $f = fopen('php://output', 'wb'); if ($f === false) { die('Error opening the file ' .$filename); } if(empty($sms[1])){ $arr = [ "No data to show" ]; fputcsv($f, $arr); } else { foreach ($sms as $row) { fputcsv($f, $row, ','); } } fclose($f); } public function getSMSQuery(){ return "SELECT %s FROM sms_response sms INNER JOIN `customers` `cst` ON `cst`.`id` = `sms`.`cust_Id` LEFT OUTER JOIN `users` ON `sms`.`token` = `users`.`token` WHERE 1 %s %s %s %s "; } public function getSMS($array_data){ // dd($array_data); $fields = "CONCAT(`cst`.`fname`, ' ', `cst`.`lname`) as `name`,`sms`.`id`,`sms`.`token`,`sms`.`mobile`, `sms`.`url`, `sms`.`telco`, `sms`.`status`, `sms`.`message`,`sms`.`created_at`,`users`.`comp_name` as `company`,`users`.`deal_code` as `dealer` "; $query = sprintf( $this->getSMSQuery(), $fields, $array_data['search'], $array_data['where'], $array_data['sort'], $array_data['offset_limit'] ); return DB::select($query); } public function getSMSCount($array_data){ $fields = " COUNT(1) as Count "; $query = sprintf( $this->getSMSQuery(), $fields, '', $array_data['where'], '', '' ); return DB::select($query); } public function getSMSFilteredCount($array_data){ $fields = " COUNT(1) as FilteredCount "; $query = sprintf( $this->getSMSQuery(), $fields, $array_data['search'], $array_data['where'], '', '' ); return DB::select($query); } } PKZJ .gitignorenu[* !public/ !.gitignore PKZ뚩public/.gitignorenu[* !.gitignore PK4Z_` Providers/AppServiceProvider.phpnu[PK4Z//"Providers/RouteServiceProvider.phpnu[PK4Z||&dProviders/BroadcastServiceProvider.phpnu[PK4ZVd!6 Providers/AuthServiceProvider.phpnu[PK4Z)(" Providers/EventServiceProvider.phpnu[PK4ZvConsole/Commands/SendSMS.phpnu[PK4Zڐ Console/Kernel.phpnu[PK4Zj R$Http/Middleware/TrustProxies.phpnu[PK4Z# +'Http/Middleware/Authenticate.phpnu[PK4Zgh@@#L)Http/Middleware/VerifyCsrfToken.phpnu[PK4Z~}}*Http/Middleware/TrimStrings.phpnu[PK4Z7mm+,Http/Middleware/RedirectIfAuthenticated.phpnu[PK4Z{{nn4s0Http/Middleware/PreventRequestsDuringMaintenance.phpnu[PK4ZL{ ttE2Http/Middleware/TrustHosts.phpnu[PK4Z"q33"4Http/Middleware/EncryptCookies.phpnu[PK4ZGf%5Http/Middleware/ValidateSignature.phpnu[PK4Zs! ! 7Http/Kernel.phpnu[PK4Z&O) BHttp/Controllers/ValidationController.phpnu[PK4Z "SHttp/Controllers/SMSController.phpnu[PK4Z/n***[Http/Controllers/InformationController.phpnu[PK4Z_ _ 1Http/Controllers/CustomerProjectionController.phpnu[PK4ZD籍iiӏHttp/Controllers/Controller.phpnu[PK4Zk+ee$Http/Controllers/AdminController.phpnu[PK4Z B %Http/Controllers/RatingController.phpnu[PK4Z mExceptions/Handler.phpnu[PK4Z:}}7Models/Customer.phpnu[PK4Z(ʉModels/Admin.phpnu[PK4ZxUModels/Rating.phpnu[PK4ZrcA++Models/User.phpnu[PK4Z͛k]0Models/Transaction.phpnu[PK4Z~PModels/Link.phpnu[PK4Z^QModels/Company.phpnu[PK4ZwςcRModels/SmsResponse.phpnu[PKZJ e.gitignorenu[PKZ뚩:fpublic/.gitignorenu[PK## f