public function store() { // validate // read more on validation at http://laravel.com/docs/validation $rules = array('full_name' => 'required', 'name' => 'required', 'inn' => 'required', 'kpp' => 'required|size:9', 'ogrn' => 'required|unique:clients|size:13'); $validator = Validator::make(Input::all(), $rules); // process the login if ($validator->fails()) { return redirect()->back()->with('danger', 'Данные клиента введены неверно')->withInput(); } else { if (count(Client::where('inn', '=', Input::get('inn'))->get()) > 0) { return redirect()->back()->with('danger', 'Клиент с данным ИНН уже имеется в базе')->withInput(); } else { var_dump($this->is_valid_inn((int) Input::get('inn'))); if ($this->is_valid_inn((int) Input::get('inn'))) { //Проверка инн $client = new Client(); $client->full_name = Input::get('full_name'); $client->name = Input::get('name'); $client->inn = Input::get('inn'); $client->kpp = Input::get('kpp'); $client->ogrn = Input::get('ogrn'); $client->save(); // redirect //*Request::flashOnly('message', 'Клиент добавлен');*/ Session::flash('success', 'Клиент добавлен'); return Redirect::to('client/' . $client->id . '/agreement'); } else { return redirect()->back()->with('danger', 'ИНН введен не верно')->withInput(); } } } }
/** * Bootstrap any application services. * * @return void */ public function boot() { Validator::extend('check_auth_user_password', function ($attribute, $value, $parameters, $validator) { return Hash::check($value, Auth::user()->password); }); // Make sure client email is not used by another client of current user Validator::extend('email_not_used_by_another_user_client', function ($attribute, $value, $parameters, $validator) { if (Client::where('user_id', Auth::user()->id)->where('email', $value)->count()) { return false; } return true; }); // Make sure client phone number is not user by another client of current user Validator::extend('phone_number_not_used_by_another_user_client', function ($attribute, $value, $parameters, $validator) { if (Client::where('user_id', Auth::user()->id)->where('phone_number', $value)->count()) { return false; } return true; }); Validator::extend('not_exists', function ($attribute, $value, $parameters, $validator) { return !DB::table($parameters[0])->where($parameters[1], $value)->count(); }); Validator::extend('is_not_in_auth_user_products', function ($attribute, $value, $parameters, $validator) { return !DB::table('products')->where('user_id', \Auth::user()->id)->where('code', $value)->count(); }); }
public function clientsForUser($user = null) { if ($user != null) { return \App\Client::where('user_id', $user->id)->get(); } return \App\Client::where('user_id', $this->user()->id)->get(); }
public function handleAction(Request $request) { $action = $request->input('_action'); if ($action == 'createClient') { //Creation : Client::create($request->all()); // FLash messaging : flash()->success('Opération réussie!', 'Client créé avec succès.'); } else { if ($_POST['_action'] == 'getClientByID') { $id = $_POST['_uid']; $client = Client::where('id', $id)->with('files')->first(); return response(['status' => 'success', 'client' => $client], 200); } else { if ($_POST['_action'] == 'editClient') { $id = $_POST['id']; $client = Client::find($id); $client->lastname = $_POST['lastname']; $client->firstname = $_POST['firstname']; $client->email = $_POST['email']; $client->street = $_POST['street']; $client->postal_code = $_POST['postal_code']; $client->city = $_POST['city']; $client->vat = $_POST['tva']; $client->mobile = $_POST['mobile']; $client->office = $_POST['office']; $client->fax = $_POST['fax']; $client->save(); flash()->success('Opération réussie!', 'Client modifé avec succès.'); } else { } } } return redirect('/clients'); }
function create() { $id = Input::get('id'); if (Input::get('muayneDurumu') != 'ertelendi') { $hour = Input::get('saat'); $app_date = Input::get('tarih'); } else { $hour = Input::get('ysaat'); $app_date = Input::get('yTarih'); } $client = array('name' => Input::get('ad'), 'last_name' => Input::get('soyad'), 'email' => Input::get('email'), 'tel' => Input::get('tel'), 'app_date' => $app_date, 'hour_id' => $hour, 'doctor_id' => Input::get('doktor'), 'confirmation' => 1, 'message' => Input::get('mesaj')); $update = Client::where('id', Input::get('id'))->update($client); if ($update || Input::get('muayneDurumu') != null) { $client_detail = array('client_id' => Input::get('id'), 'app_date' => $app_date, 'hour_id' => $hour, 'made_operation' => Input::get('yapilanIslem'), 'doctor_id' => Input::get('doktor'), 'after_operation' => Input::get('yapilacakIslem'), 'status' => Input::get('muayneDurumu')); $create = ClientDetail::create($client_detail); if ($create) { $client = Client::find($id); $_SESSION['mesaj'] = '<div class="form-signin" style="background-color:pink;"><center><p style="color:green;">İşlem başarıyla gerçekleştirildi.</p></center></div>'; return view('clients.appointment', ['client' => $client]); } } else { $client = Client::find($id); $_SESSION['mesaj'] = '<div class="form-signin" style="background-color:pink;"><center><p style="color:red;">İşelem gerçekleştirilmedi</p></center></div>'; return view('clients.appointment', ['client' => $client]); } }
public function submitOTP(Request $request) { //get mobile number from user input $mobileNum = $request->input('mobile'); //get user type from user input $userType = $request->input('userType'); //set user email $userEmail = '*****@*****.**'; //set country code $countryCode = 61; //initial authentication API // $authy_api = new AuthyApi(config('services.authy.key')); $authy_api = new AuthyApi(config('services.authy.key'), 'http://sandbox-api.authy.com'); //sandbox //register a user through email, cellphone, country_code $user = $authy_api->registerUser($userEmail, $mobileNum, $countryCode); //generate authentication token and send it to usser $sms = $authy_api->requestSms($user->id(), array("force" => "true")); if ($sms->ok()) { //check user exist or not $results = Client::where('mobile', $mobileNum)->first(); //if user does not exist, register of him if (empty($results)) { $newUser = new Client(); $newUser->mobile = $mobileNum; $newUser->save(); } return view('auth.otp')->with('userid', $user->id())->with('mobileNum', $mobileNum)->with('userType', $userType); } else { //session()->put('message','incorrect mobile number'); return redirect('login')->with('message', 'Please input correct mobile number'); } }
public function index() { \App\Gini\Gapper\Client::init(); if (\App\Gini\Gapper\Client::getUserName()) { return view('dashboard', ['products_count' => Product::count(), 'servers_count' => Server::count(), 'clients_count' => Client::where('parent_id', 0)->count(), 'projects_count' => Project::count()]); } return view('login'); }
/** * reads Project table by unique index * - if not found, emit a not found message. * - if found return the $project record to the caller. * * @param [in] $text * @return a record. */ public static function checkIfExists($text) { $client = Client::where('name', '=', $text)->first(); if (!is_null($client)) { appGlobals::existsMessage(appGlobals::getClientTableName(), $client->name, $client->id); } return $client; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $user = \Auth::user()->id; // get the id of the logged in user $clients = Client::where('user_id', $user)->get(); // only get clients belonging to logged user return view('clients.index', compact('clients')); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $clients = Client::where('status', 'active')->get(); foreach ($clients as $client) { $client->client_id = $client->id + 1000; } return $clients; return view('app.clients', ['clients' => $clients]); }
public function jsonGetNameByPhone($number) { $client = Client::where('phone', $number)->first(); if (is_null($client)) { return ""; } else { return $client->name; } }
public function run() { $client = Client::where('name', '=', 'Exhibit Partners')->first(); Contact::create(['first_name' => 'Seth Cindra', 'email' => '*****@*****.**', 'client_id' => $client->id]); Contact::create(['first_name' => 'Seth TRMS', 'email' => '*****@*****.**', 'client_id' => $client->id]); Contact::create(['first_name' => 'Seth BlackKat', 'email' => '*****@*****.**', 'client_id' => $client->id]); Contact::create(['first_name' => 'Dane Giles', 'email' => '*****@*****.**', 'client_id' => $client->id]); Contact::create(['first_name' => 'Bill Gench', 'email' => '*****@*****.**', 'client_id' => $client->id]); Contact::create(['name' => 'Debs Holloway', 'email' => '*****@*****.**', 'client_id' => $client->id]); }
public function filter() { $input = Request::all(); $filter = $input['filter']; $clients = Client::where('status', $filter)->paginate(10); if ($filter == "All") { return redirect()->action('ClientsController@index'); } $clients->appends(Request::only('filter')); return view('clients.index', compact('clients')); }
/** * Get clients of given user. * * @param bool $userId * @return mixed */ public static function getClients($userId = false) { // If an user id is not given use the id of current logged in user if (!$userId) { $userId = Auth::user()->id; } $clients = Client::where('user_id', $userId)->paginate(); foreach ($clients as &$client) { $client->orders = Bill::where('client_id', $client->id)->count(); } return response($clients)->header('Content-Type', 'application/json'); }
/** * Run a general search. * @return array of objects with the search results. */ public function search() { $q = Input::get("q"); // redirect user back if nothing was typed if (empty(trim($q))) { return Redirect::back(); } $clients = Client::where('name', 'like', '%' . $q . '%')->whereUserId(Auth::id())->get(); $projects = Project::where('name', 'like', '%' . $q . '%')->whereUserId(Auth::id())->get(); $tasks = Task::where('name', 'like', '%' . $q . '%')->whereUserId(Auth::id())->get(); $pTitle = "Search Results"; return View::make('search', compact('q', 'clients', 'projects', 'tasks', 'pTitle')); }
public function view($route, $title, $notices, $school) { $user = \Auth::user(); $admin_schools = null; $client_schools = null; $administrator = \App\Administrator::where('user_id', $user->id)->first(); $clients = \App\Client::where('user_id', $user->id)->get(); if ($administrator != null) { $admin_schools = \App\School::where('id', $administrator->school_id)->first(); } $schools = \Auth::user()->schools()->get(); //dd($school); return view($route, compact('school', 'admin_schools', 'schools', 'clients', 'title', 'notices')); }
/** * Make get request to get first page of clients. */ public function testClientsPagination() { // Number of clients to generate $numberOfClients = 45; // Generate one user $user = factory(App\User::class)->create(); // Generate clients for ($i = 0; $i < $numberOfClients; $i++) { $user->clients()->save(factory(App\Client::class)->make()); } // Get expected results $pagination = \App\Client::where('user_id', $user->id)->orderby('created_at', 'desc')->paginate(10); $this->actingAs($user)->get('/clients/get')->seeJson(['total' => $pagination->total(), 'per_page' => $pagination->perPage(), 'current_page' => $pagination->currentPage()]); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $segments = $request->segments(); if ($this->auth->guest()) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { return redirect($segments[0] . '/login'); } } else { $client = \App\Client::where('user_id', $request->user()->id)->first(); if ($client == null) { return redirect($segments[0] . '/patch/' . $request->user()->id); } } return $next($request); }
public function authenticate(Request $request) { $validator = Validator::make($request->all(), ['username' => 'required', 'password' => 'required']); if ($validator->fails()) { return redirect('login')->withErrors($validator)->withInput(); } $username = $request->username; $password = sha1($request->password); $client = Client::where('username', '=', $username)->where('password', '=', $password)->first(); if (!$client) { $validator->errors()->add('wrongDetails', "The Credentials you provided are Incorrect"); return redirect('login')->withErrors($validator)->withInput(); } Session::put('c_id', $client->id); Session::put('c_username', $client->username); return redirect('home'); }
public function getClientMessages($school, $client) { $user = \Auth::user(); $admin_schools = null; $client_schools = null; $administrator = Administrator::where('user_id', $user->id)->first(); $clients = Client::where('user_id', $user->id)->get(); if ($administrator != null) { $admin_schools = School::where('id', $administrator->school_id)->first(); } //dd($client_schools); $schools = \Auth::user()->schools()->get(); $post = "/" . $school->username . "/client/forum/" . $client->id . "/"; $messages = $this->messages($school, 0); $client_messages = $this->messages($school, 1, $client->class); $title = "School Space"; // dd($client_messages); return view('client.account.messenger', compact('title', 'client_messages', 'user', 'client', 'schools', 'admin_schools', 'school', 'clients', 'post', 'messages')); }
public function getOTP(Request $request, $mail) { if (filter_var($mail, FILTER_VALIDATE_EMAIL)) { $key = $request->headers->get('pub-key'); $app = \App\Aplication::where('public_key', $key)->get(); //return var_dump($app[0]->id); if (isset($app[0])) { $client = \App\Client::where('email', $mail)->get(); if (isset($client[0])) { $list = ['libertad', 'patria', 'soberano', 'independencia', 'avanzadora', 'chavez', 'cimarron', 'cacao']; $code = $list[rand(0, count($list) - 1)] . rand(100, 999); /* Solicitar envio de SMS */ $curl = new cURL(); $params = array('telf' => $client[0]->phone, 'texto' => 'Hemos eviado una clave de acceso temporal para la aplicación: ' . $app[0]->name . ' Su clave temporal OTP es: ' . $code, 'app_name' => 'ssas'); $url = $curl->buildUrl('http://desarrollo.ssas.gob.ve/rest/SMS', $params); $curl->get($url); /* Solicitar envio de Correo */ $email = $client[0]->email; \Mail::send('otp_mail', ['aplication' => $app[0]->name, 'otp' => $code], function ($message) use($email) { $message->from('*****@*****.**', 'Aplicaciones SIAS'); $message->to($email); $message->subject('Clave de Acceso Temporal'); }); /* Encriptamos el otp con clave privada */ $encrypt = crypt($code, $app[0]->private_key); /* Almacenamos OTP */ $otp = new Otp(); $otp->code = $encrypt; $otp->status = 'D'; $otp->clients_id = $client[0]->id; $otp->aplication_id = $app[0]->id; $otp->save(); return array('crypt' => $encrypt); } else { return response()->json(['error' => 'no autorizado'], 401); } } else { return response()->json(['error' => 'no autorizado'], 401); } } else { return response()->json(['error' => 'no autorizado'], 401); } }
/** * Display a listing of the resource. * * @return Response */ public function index() { $title = 'CLIENT'; if (Input::has('cid')) { $id = Input::get('cid'); $clients = Client::where('cid', $id)->paginate(10); } elseif (Input::has('name')) { $name = Input::get('name'); $clients = Client::where('name', 'like', '%' . $name . '%')->paginate(10); } elseif (Input::has('contact_person')) { $contact_person = Input::get('contact_person'); $clients = Client::where('contact_person', 'like', '%' . $contact_person . '%')->paginate(10); } elseif (Input::has('city')) { $city = Input::get('city'); $clients = Client::where('city', 'like', '%' . $city . '%')->paginate(10); } elseif (Input::has('state')) { $state = Input::get('state'); $clients = Client::where('state', 'like', '%' . $state . '%')->paginate(10); } else { $clients = Client::paginate(10); } $repository = $this->repository; return view('client/index', compact('title', 'clients', 'repository')); }
public function store() { //Session::start(); //dd(Input::file('report')); if (Input::file('report')) { $result = Excel::load(Input::file('report'), function ($reader) { $reader->setDateFormat('Y-m-d'); $reader->toObject(); }, 'UTF-8')->get(); $resultNotJson = $result->each(function ($sheet) { $sheet->each(function ($row) { }); }); $resultArrayNull = json_decode($resultNotJson); $resultArrayVar = []; $resultArray = []; $deliveryCheck = 0; $invoicesCheck = 0; for ($i = 0; $i < count($resultArrayNull); $i++) { for ($j = 0; $j < count($resultArrayNull[$i]); $j++) { if (!empty($resultArrayNull[$i][$j])) { if ($resultArrayNull[$i][$j] == 'Накладная' || $resultArrayNull[$i][$j] == 'накладная') { $deliveryCheck++; } if ($resultArrayNull[$i][$j] == 'Счет-фактура' || $resultArrayNull[$i][$j] == 'счет-фактура') { $invoicesCheck++; } array_push($resultArrayVar, $resultArrayNull[$i][$j]); } } if (count($resultArrayVar) > 0) { array_push($resultArray, $resultArrayVar); } $resultArrayVar = []; } //dd($invoicesCheck); if ($deliveryCheck > 0 && $invoicesCheck > 0 && $deliveryCheck == $invoicesCheck) { if (count($resultArray[0] === 4) && count($resultArray[1] === 4) && count($resultArray[2] === 4) && count($resultArray[3] === 2) && count($resultArray[4] === 4)) { $clientInn = $resultArray[1][3]; $clientName = $resultArray[1][1]; $debtorInn = $resultArray[2][3]; $debtorName = $resultArray[2][1]; $contractCode = strval($resultArray[3][1]); $contractDate = new Carbon($resultArray[4][2]); $registryVar = $resultArray[0][3]; $registryDate = new Carbon($resultArray[0][1]); $client = Client::where('inn', '=', $clientInn)->first(); $debtor = Debtor::where('inn', '=', $debtorInn)->first(); $registryDelivery = Delivery::where('registry', '=', $registryVar)->where('client_id', '=', $client->id)->first(); if ($registryDelivery === null) { if ($client) { if ($debtor) { $clientId = $client->id; $debtorId = $debtor->id; $relation = Relation::where('client_id', $client->id)->where('debtor_id', $debtor->id)->whereHas('contract', function ($q) use($contractCode, $contractDate) { $q->where('code', '=', $contractCode); $q->whereDate('created_at', '=', $contractDate); })->first(); if ($relation) { $row = 0; $stop = 0; $i = 7; //dd($resultArray); while ($stop === 0) { if (isset($resultArray[$i][1]) && ($resultArray[$i][1] == 'Накладная' || $resultArray[$i][1] == 'накладная')) { $waybillDateVar = new Carbon($resultArray[$i][3]); //Дата накладной $waybillVar = strval($resultArray[$i][2]); //Накладная if (count($resultArray[$i + 1]) == 3) { $invoiceDateVar = new Carbon($resultArray[$i + 1][2]); //Дата счет фактуры $invoiceVar = $resultArray[$i + 1][1]; } elseif (count($resultArray[$i + 1]) == 2) { if (strtotime($resultArray[$i + 1][1])) { $invoiceDateVar = new Carbon($resultArray[$i + 1][1]); //Дата счет фактуры $invoiceVar = null; } else { $invoiceDateVar = null; //Дата счет фактуры $invoiceVar = $resultArray[$i + 1][1]; } } else { $invoiceVar = null; $invoiceDateVar = null; } $sum = $resultArray[$i][5]; $debtDate = $resultArray[$i][4]; //не используется if (isset($resultArray[$i][6])) { $notes = $resultArray[$i][6]; } else { $notes = null; } $waybillExist = $relation->deliveries->where('waybill', $waybillVar)->where('date_of_waybill', $waybillDateVar->format('Y-m-d'))->first(); if ($waybillExist === null) { $dateOfRecourse = clone $waybillDateVar; $dateOfRecourse->addDays($relation->deferment); //Срок оплаты $dateNowVar = new Carbon(date('Y-m-d')); //Сегодняшнее число $actualDeferment = clone $dateNowVar; $dateOfRecourseClone = clone $dateOfRecourse; $actualDeferment = $dateOfRecourseClone->diffInDays($actualDeferment, false); //Фактическая просрочка $dateOfRegress = clone $dateOfRecourse; $dateOfRegress->addDays($relation->waiting_period); //Дата регресса $theDateOfTerminationOfThePeriodOfRegression = clone $dateOfRegress; $theDateOfTerminationOfThePeriodOfRegression->addDays($relation->regress_period); //Дата окончания регресса $delivery = new Delivery(); $delivery->client_id = $relation->client_id; $delivery->debtor_id = $relation->debtor_id; $delivery->relation_id = $relation->id; $delivery->waybill = $waybillVar; $delivery->waybill_amount = $sum; $rpp = $relation->rpp; $delivery->first_payment_amount = $sum / 100.0 * $rpp; $delivery->date_of_waybill = $waybillDateVar; $delivery->due_date = $relation->deferment; $delivery->date_of_recourse = $dateOfRecourse; //срок оплаты //$delivery->date_of_payment = $dateNowVar->format('Y-m-d');//дата оплаты(ложь) $delivery->date_of_regress = $dateOfRegress; $delivery->the_date_of_termination_of_the_period_of_regression = $theDateOfTerminationOfThePeriodOfRegression; $delivery->the_date_of_a_registration_supply = $dateNowVar->format('Y-m-d'); $delivery->the_actual_deferment = $actualDeferment; $delivery->invoice = $invoiceVar; $delivery->date_of_invoice = $invoiceDateVar; $delivery->registry = $registryVar; $delivery->date_of_registry = $registryDate; //$delivery->date_of_funding = ; //$delivery->end_date_of_funding = $dateNowVar->format('Y-m-d');;//(ложь) $delivery->notes = $notes; $delivery->return = ""; $delivery->status = 'Зарегистрирована'; $delivery->state = false; $delivery->the_presence_of_the_original_document = Input::get('the_presence_of_the_original_document'); if ($relation->confedential_factoring) { $delivery->type_of_factoring = $relation->confedential_factoring; } else { $delivery->type_of_factoring = false; } if (!$delivery->save()) { Session::flash('success', 'Реестр успешно загружен'); } } else { //накладная с таким номером существует } $i = $i + 2; } else { $stop = 1; } } } else { Session::flash('danger', 'Связь между клиентом и дебитором, либо договор не найдены'); } } else { Session::flash('danger', 'Дебитор с таким ИНН не найден'); } } else { Session::flash('danger', 'Клиент с таким ИНН не найден'); } } else { Session::flash('danger', 'Реестр с таким номером уже существует'); } } else { Session::flash('danger', 'Заполните все поля реестра'); } } else { Session::flash('danger', 'Проверьте наличие ключей \'Накладная\' и \'Счет-фактура\''); } } else { Session::flash('danger', 'Файл не был загружен'); } return Redirect::to('delivery'); }
/** * User create new bill with client name used by another user and does not use current campaign. */ public function test_create_bill_with_client_name_used_by_another_user_using_other_campaign() { $secondUser = factory(\App\User::class)->create(); $clientOfSecondUser = factory(\App\Client::class)->create(['user_id' => $secondUser->id]); $this->postData['client'] = $clientOfSecondUser->name; unset($this->postData['use_current_campaign']); $this->postData['campaign_year'] = date('Y'); $this->postData['campaign_number'] = rand(1, 17); $this->actingAs($this->user)->post('/bills/create', $this->postData)->seeJson(['success' => true, 'message' => trans('bills.bill_created')])->seeInDatabase('bills', ['user_id' => $this->user->id, 'client_id' => \App\Client::where('user_id', $this->user->id)->where('name', $this->postData['client'])->first()->id, 'campaign_id' => \App\Campaign::where('year', $this->postData['campaign_year'])->where('number', $this->postData['campaign_number'])->first()->id, 'campaign_order' => 1]); }
public function getStatsClient($userid, $range) { return Client::where([['created_at', '>=', $range], ['user_id', '=', $userid]])->groupBy('date')->orderBy('date', 'DESC')->get([DB::raw('Date(created_at) as date'), DB::raw('COUNT(*) as value')]); }
public function statistics($dateString = null) { // echo('<pre>'); Carbon::setLocale('nl'); //check if valid date $isRightFormat = preg_match('(^[0-9]{4}-[0-9]{2}-[0-9]{2}$)', $dateString); if ($dateString && $isRightFormat && Carbon::createFromFormat('Y-m-d', $dateString) !== false) { $date = Carbon::createFromFormat('Y-m-d h:i:s', $dateString . ' 00:00:00', 'Europe/Brussels'); } else { $date = Carbon::today('Europe/Brussels'); } $clients = Client::where('entertime', '>', $date)->where('entertime', '<', $date->copy()->addDay()); //get number of booked tables $clientSum = $clients->count(); //get total amount of clients $clientAmount = $clients->sum('amount'); //get number of orders $orders = Order::where('starttime', '>', $date)->where('starttime', '<', $date->copy()->addDay()); $ordersCount = $orders->count('id'); $longestTime = $shortestTime = null; $ordersGet = $orders->get(); //get total number of staff members working today $staff = WaiterArea::groupBy('FK_waiter_id')->where('start_time', '>', $date)->where('end_time', '<', $date->copy()->addDay())->get()->count(); //check all orders to set longest and shortest wait time foreach ($ordersGet as $order) { $starttime = Carbon::createFromFormat('Y-m-d H:i:s', $order->starttime); if ($order->endtime) { $endtime = Carbon::createFromFormat('Y-m-d H:i:s', $order->endtime); } else { $endtime = Carbon::now('Europe/Brussels'); } $wait_time = $endtime->diffInSeconds($starttime); //if longesTime or shortestTime is null, set equal to first wait time if ($longestTime == null || $shortestTime == null) { $longestTime = $shortestTime = []; $longestTime['time'] = $shortestTime['time'] = $wait_time; $longestTime['start'] = $shortestTime['start'] = $starttime; $longestTime['end'] = $shortestTime['end'] = $endtime; $longestTime['table'] = $shortestTime['table'] = $order->client->table->number; } //if wait time is longer than old longest time, change longest time if ($wait_time > $longestTime['time']) { $longestTime['time'] = $wait_time; $longestTime['start'] = $starttime; $longestTime['end'] = $endtime; $longestTime['table'] = $order->client->table->number; } //if wait time is shorter than old shortest time, change shortest time if ($wait_time < $shortestTime['time']) { $shortestTime['time'] = $wait_time; $shortestTime['start'] = $starttime; $shortestTime['end'] = $endtime; $shortestTime['table'] = $order->client->table->number; } } //set times readable for humans if (isset($longestTime) && isset($shortestTime)) { $longestTime['time'] = $longestTime['end']->diffForHumans($longestTime['start'], true); $shortestTime['time'] = $shortestTime['end']->diffForHumans($shortestTime['start'], true); } $clientsHour = []; //make graph $clientsHour = $this->dayGraph($date, $clients->get()); $data = []; $data['date'] = $date->toDateString(); $data['clientSum'] = $clientSum; $data['clientAmount'] = $clientAmount; $data['orders'] = $ordersCount; $data['shortestTime'] = $shortestTime; $data['longestTime'] = $longestTime; $data['clientsHour'] = $clientsHour; $data['staff'] = $staff; return View('statistic')->with($data); }
/** * User tries to create new client with invalid phone number. */ public function test_create_new_client_with_invalid_phone_number() { $this->postData['client_phone_number'] = 'phone_nr14'; $clientsBeforeRequest = Client::where('user_id', $this->user->id)->count(); $this->actingAs($this->user)->post('/clients/create', $this->postData)->seeJson(['success' => false, 'errors' => ['client_phone_number' => trans('validation.digits', ['attribute' => trans('validation.attributes.client_phone_number'), 'digits' => 10])]]); $this->assertEquals($clientsBeforeRequest, Client::where('user_id', $this->user->id)->count()); }
/** * Function that saves a client. * * @return Response */ public function saveClient() { // Validate Input. $validator = Validator::make(Input::all(), array('name' => 'required', 'id' => 'required', 'phone' => 'required', 'address' => 'required', 'lat' => 'required', 'lon' => 'required', 'creditLimit' => 'required', 'clientId' => 'required')); if ($validator->fails()) { return response()->json(['error' => 'No se envio la informacion completa!']); } // Check that user is part of authorized staff. if (Auth::user()->Type != 1) { // If they are unauthorized no point in returning anything. return response()->json(['state' => 'Unauthorized']); } // Get the credit value. $credit = Input::get('credit') ? true : false; $creditLimit = Input::get('creditLimit'); // Reset creditLimit just in case. if (!$credit) { $creditLimit = 0; } // Get the Client. $client = Client::where('Cedula', '=', Input::get('clientId'))->first(); if (!$client) { $response['state'] = 'Error'; $response['error'] = 'No existe un cliente con esta identifiacion!'; return response()->json($response); } // Now get the Location. $location = Location::find($client->LocationId); // Update the Client. $client->Name = Input::get('name'); $client->Cedula = Input::get('id'); $client->Phone = Input::get('phone'); $client->Email = Input::get('email'); $client->Address = Input::get('address'); $client->InstitutionId = Input::get('institutionId'); $client->Credit = $credit; $client->CreditLimit = $creditLimit; // Save the Client. $client->save(); // Update the location. $location->Name = 'Direccion de ' . Input::get('name'); $location->Latitude = Input::get('lat'); $location->Longitude = Input::get('lon'); // Save the location. $location->save(); return response()->json(['state' => 'Success']); }
static function showTodayDoctorClients($date, $id) { $clients = Client::where('app_date', $date)->where('doctor_id', $id)->whereRaw('CURDATE() <= app_date')->get(); return $clients; }
public function filter() { $input = Request::all(); $filter = $input['filter']; if ($filter == 'All') { return redirect()->action('CollectiblesController@index'); } $clients = Client::where('status', $filter)->paginate(10); $overdue = new SalesInvoice(); $delivered = new SalesInvoice(); $check = new SalesInvoice(); $salesinvoice = new SalesInvoice(); $salesinvoice2 = new SalesInvoice(); $salesinvoice3 = new SalesInvoice(); $salesinvoiceTotal; foreach ($clients as $client) { $overdue[$client->id] = SalesInvoice::where('client_id', $client->id)->where('status', 'Overdue')->count(); $delivered[$client->id] = SalesInvoice::where('client_id', $client->id)->where('status', 'Delivered')->count(); $check[$client->id] = SalesInvoice::where('client_id', $client->id)->where('status', 'Check on Hand')->count(); // $salesinvoice[$client->id] = DB::SELECT("SELECT sum(total_amount) as total FROM sales_invoices // WHERE (status = 'Overdue' or status = 'Delivered') and client_id = '$client->id'"); $salesinvoice = SalesInvoice::where('status', '=', 'Overdue')->where('client_id', '=', $client->id)->sum('total_amount'); $salesinvoice2 = SalesInvoice::where('status', 'Delivered')->where('client_id', $client->id)->sum('total_amount'); $salesinvoice3 = SalesInvoice::where('status', 'Check on Hand')->where('client_id', $client->id)->sum('total_amount'); $salesinvoiceTotal[$client->id] = $salesinvoice + $salesinvoice2 + $salesinvoice3; } // for ($x = $clients[0]; $x < count($clients)+1; $x++) // { // $overdue[$x] = SalesInvoice::where('client_id', $x)->where('status', 'Overdue')->count(); // $delivered[$x] = SalesInvoice::where('client_id', $x)->where('status', 'Delivered')->count(); // $pending[$x] = SalesInvoice::where('client_id', $x)->where('status', 'Pending')->count(); // } if ($clients == "[]") { return redirect()->action('CollectiblesController@index'); } $clients->appends(Request::only('filter')); return view('collectibles.index', compact('clients', 'overdue', 'delivered', 'check', 'salesinvoiceTotal')); }