public function postEditUser(Request $request, User $user, Client $client, CommonCode $cCode) { // $bool_include_password = $cCode->setCheckboxVar($request->include_password); // $bool_include_email = $cCode->setCheckboxVar($request->include_email); $validation_rules = $client->getValidationRulesEditUser(); // $validation_messages = $client->getValidationMessagesEditUser(); $this->validate($request, $validation_rules); $arr_request = $client->getRequestArrayEditUser($request); $user = $user->find(Auth::user()->id); // $user = $cCode->getObject($arr_request, $user); // $user->first_name = $arr_request->first_name; // $user->last_name = $arr_request->last_name; // $user->company = $arr_request->company; // $arr_request = array(); // // transfer to new array, so as not to propagate teh password // $arr_request['first_name'] = $request->first_name; // $arr_request['last_name'] = $request->last_name; // $arr_request['company'] = $request->company; // $user->email = $arr_request['email']; // $user->password = $arr_request['password']; // $user->name = ''; // $user->save(); $client = $user->client; // $client->cloaked_client_id = $client->getNewCloakedClientId($user->id); // $client->user_id = $user->id; $client->first_name = $arr_request['first_name']; $client->last_name = $arr_request['last_name']; $client->company = $arr_request['company']; $client->client_url = $arr_request['client_url']; $client->save(); // $user_id = $user->id; $data = $client->getDataArrayPostEditUser($arr_request, $user->id, $this->cloakedClientId, $this->arr_logged_in_user); return view('client/edit_user_results')->with('data', $data); }
protected function fakeClient() { $fakeClient = new Client(); $fakeClient->serial_number = "C241874"; $fakeClient->primary_name = "Fake Client"; $fakeClient->client_type_id = $this->fakeClientType()->client_type_id; $fakeClient->save(); return $fakeClient; }
public function __construct(Role_user $role_user, User $user, Client $client, RoleHelper $roleHelper) { //next lines are temp code, until roles and auth implemented // $this->arr_logged_in_user = array(); // $this->middleware('three_step:admin'); $this->middleware('auth'); if (Auth::check()) { // $this->client_id = $user->find($user->id)->cloakedClientId(); $this->middleware('role:client'); $this->obj_logged_in_user = Auth::user(); $this->arr_logged_in_user = $client->getClientInfo(Auth::user()->id, Auth::user()->email); // $this->arr_logged_in_client_info = $client->getClientInfo(Auth::user()->id); } // end if Auth::check() }
public function save($publicId, $data) { if ($publicId) { $task = Task::scope($publicId)->firstOrFail(); } else { $task = Task::createNew(); } if (isset($data['client']) && $data['client']) { $task->client_id = Client::getPrivateId($data['client']); } if (isset($data['description'])) { $task->description = trim($data['description']); } //$timeLog = $task->time_log ? json_decode($task->time_log, true) : []; $timeLog = isset($data['time_log']) ? json_decode($data['time_log']) : []; if ($data['action'] == 'start') { $task->is_running = true; $timeLog[] = [strtotime('now'), false]; } else { if ($data['action'] == 'resume') { $task->is_running = true; $timeLog[] = [strtotime('now'), false]; } else { if ($data['action'] == 'stop' && $task->is_running) { $timeLog[count($timeLog) - 1][1] = time(); $task->is_running = false; } } } $task->time_log = json_encode($timeLog); $task->save(); return $task; }
private function getData($request) { $account = Auth::user()->account; $data = ['account' => $account, 'title' => 'Invoice Ninja v' . NINJA_VERSION . ' - ' . $account->formatDateTime($account->getDateTime()), 'multiUser' => $account->users->count() > 1]; if ($request->input(ENTITY_CLIENT)) { $data['clients'] = Client::scope()->with('user', 'contacts', 'country')->withArchived()->get(); $data['contacts'] = Contact::scope()->with('user', 'client.contacts')->withTrashed()->get(); $data['credits'] = Credit::scope()->with('user', 'client.contacts')->get(); } if ($request->input(ENTITY_TASK)) { $data['tasks'] = Task::scope()->with('user', 'client.contacts')->withArchived()->get(); } if ($request->input(ENTITY_INVOICE)) { $data['invoices'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status')->withArchived()->where('is_quote', '=', false)->where('is_recurring', '=', false)->get(); $data['quotes'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status')->withArchived()->where('is_quote', '=', true)->where('is_recurring', '=', false)->get(); $data['recurringInvoices'] = Invoice::scope()->with('user', 'client.contacts', 'invoice_status', 'frequency')->withArchived()->where('is_quote', '=', false)->where('is_recurring', '=', true)->get(); } if ($request->input(ENTITY_PAYMENT)) { $data['payments'] = Payment::scope()->withArchived()->with('user', 'client.contacts', 'payment_type', 'invoice', 'account_gateway.gateway')->get(); } if ($request->input(ENTITY_VENDOR)) { $data['clients'] = Vendor::scope()->with('user', 'vendorcontacts', 'country')->withArchived()->get(); $data['vendor_contacts'] = VendorContact::scope()->with('user', 'vendor.contacts')->withTrashed()->get(); /* $data['expenses'] = Credit::scope() ->with('user', 'client.contacts') ->get(); */ } return $data; }
public function save($publicId = null, $input) { if ($publicId) { $payment = Payment::scope($publicId)->firstOrFail(); } else { $payment = Payment::createNew(); } $paymentTypeId = $input['payment_type_id'] ? $input['payment_type_id'] : null; $payment->payment_type_id = $paymentTypeId; $payment->payment_date = Utils::toSqlDate($input['payment_date']); $payment->transaction_reference = trim($input['transaction_reference']); if (!$publicId) { $clientId = Client::getPrivateId($input['client']); $amount = Utils::parseFloat($input['amount']); if ($paymentTypeId == PAYMENT_TYPE_CREDIT) { $credits = Credit::scope()->where('client_id', '=', $clientId)->where('balance', '>', 0)->orderBy('created_at')->get(); $applied = 0; foreach ($credits as $credit) { $applied += $credit->apply($amount); if ($applied >= $amount) { break; } } } $payment->client_id = $clientId; $payment->invoice_id = isset($input['invoice']) && $input['invoice'] != "-1" ? Invoice::getPrivateId($input['invoice']) : null; $payment->amount = $amount; } $payment->save(); return $payment; }
public function edit($publicId) { $payment = Payment::scope($publicId)->firstOrFail(); $payment->payment_date = Utils::fromSqlDate($payment->payment_date); $data = array('client' => null, 'invoice' => null, 'invoices' => Invoice::scope()->where('is_recurring', '=', false)->where('is_quote', '=', false)->with('client', 'invoice_status')->orderBy('invoice_number')->get(), 'payment' => $payment, 'method' => 'PUT', 'url' => 'payments/' . $publicId, 'title' => trans('texts.edit_payment'), 'paymentTypes' => Cache::get('paymentTypes'), 'clients' => Client::scope()->with('contacts')->orderBy('name')->get()); return View::make('payments.edit', $data); }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function getDetail($id) { $client = Client::find($id); $data_clients = DataClient::with("client")->where("client_id", "=", $id)->get(); return view("clients.detail")->with(array('client' => $client, 'data_client' => $data_clients)); return redirect()->back(); }
public function save($data) { $publicId = isset($data['public_id']) ? $data['public_id'] : false; if (!$publicId || $publicId == '-1') { $client = Client::createNew(); } else { $client = Client::scope($publicId)->with('contacts')->firstOrFail(); } $client->fill($data); $client->save(); /* if ( ! isset($data['contact']) && ! isset($data['contacts'])) { return $client; } */ $first = true; $contacts = isset($data['contact']) ? [$data['contact']] : $data['contacts']; $contactIds = []; foreach ($contacts as $contact) { $contact = $client->addContact($contact, $first); $contactIds[] = $contact->public_id; $first = false; } foreach ($client->contacts as $contact) { if (!in_array($contact->public_id, $contactIds)) { $contact->delete(); } } return $client; }
public function edit($publicId) { $credit = Credit::scope($publicId)->firstOrFail(); $credit->credit_date = Utils::fromSqlDate($credit->credit_date); $data = array('client' => null, 'credit' => $credit, 'method' => 'PUT', 'url' => 'credits/' . $publicId, 'title' => 'Edit Credit', 'clients' => Client::scope()->with('contacts')->orderBy('name')->get()); return View::make('credit.edit', $data); }
public function __construct(Request $request) { /* This checks the client list for the CID. If a matching CID is found, all caching will be ignored for this request */ if (Cache::has('clients')) { $clients = Cache::get('clients'); } else { $clients = Client::all(); Cache::put('clients', $clients, 1); } if (Cache::has('keys')) { $keys = Cache::get('keys'); } else { $keys = Key::all(); Cache::put('keys', $keys, 1); } $input_cid = $request->input('cid'); if (!empty($input_cid)) { foreach ($clients as $client) { if ($client->uuid == $input_cid) { $this->client = $client; } } } $input_key = $request->input('k'); if (!empty($input_key)) { foreach ($keys as $key) { if ($key->api_key == $input_key) { $this->key = $key; } } } }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); // $this->call(UserTableSeeder::class); \App\Models\Client::truncate(); factory(\App\Models\Client::class, 10)->create(); Model::reguard(); }
public function index() { $clients = Client::scope()->with('contacts')->orderBy('created_at', 'desc')->get(); $clients = Utils::remapPublicIds($clients->toArray()); $response = json_encode($clients, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(count($clients)); return Response::make($response, 200, $headers); }
public function getPedidos($id) { $client = Client::find($id); $pedido = Pedido::with('client')->where('client_id', '=', $id)->get(); //dd($pedido->toArray()); return view("data_clients.pedidos")->with(array('client' => $client, 'pedido' => $pedido)); return redirect()->back(); }
/** * Handle the command. * * @param CreateClientCommand $command * @return void */ public function handle(CreateClientCommand $command) { $client = Client::create(['name' => $command->name, 'pay' => $command->pay, 'due' => $command->due]); if (!empty($client)) { return $client; } return false; }
/** * @SWG\Post( * path="/clients", * tags={"client"}, * summary="Create a client", * @SWG\Parameter( * in="body", * name="body", * @SWG\Schema(ref="#/definitions/Client") * ), * @SWG\Response( * response=200, * description="New client", * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Client")) * ), * @SWG\Response( * response="default", * description="an ""unexpected"" error" * ) * ) */ public function store(CreateClientRequest $request) { $client = $this->clientRepo->save($request->input()); $client = Client::scope($client->public_id)->with('country', 'contacts', 'industry', 'size', 'currency')->first(); $transformer = new ClientTransformer(Auth::user()->account, Input::get('serializer')); $data = $this->createItem($client, $transformer, ENTITY_CLIENT); return $this->response($data); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $client = Client::whereId($id)->first(); if (empty($client)) { return $this->saveResponse(false); } return $this->saveResponse($client->delete()); }
public function getClients($id) { $vendedor = Vendedor::find($id); $client = Client::select('name', 'telephone')->with('vendedor')->where('vendedor_id', '=', $id)->get(); //dd($clients->toArray()); return view("vendedores.clients")->with(array('vendedor' => $vendedor, 'client' => $client)); return redirect()->back(); }
/** * @establish a relationship with client or website model */ public function getCow() { if ($this->belong_to == 1) { return $this->hasOne(Client::className(), ['id' => 'clients_or_webs_id']); } elseif ($this->belong_to == 2) { return $this->hasOne(Website::className(), ['id' => 'clients_or_webs_id']); } }
/** * Finds the Client model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Client the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Client::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if ($this->auth->check() && Client::scope()->count() > 0) { Session::reflash(); return new RedirectResponse(url('/dashboard')); } return $next($request); }
/** * @SWG\Post( * path="/clients", * tags={"client"}, * summary="Create a client", * @SWG\Parameter( * in="body", * name="body", * @SWG\Schema(ref="#/definitions/Client") * ), * @SWG\Response( * response=200, * description="New client", * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Client")) * ), * @SWG\Response( * response="default", * description="an ""unexpected"" error" * ) * ) */ public function store(CreateClientRequest $request) { $client = $this->clientRepo->save($request->input()); $client = Client::scope($client->public_id)->with('country', 'contacts', 'industry', 'size', 'currency')->first(); $client = Utils::remapPublicIds([$client]); $response = json_encode($client, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); return Response::make($response, 200, $headers); }
/** * Update the specified resource in storage. * * @return \Illuminate\Http\Response */ public function update(ClientRequest $request, $slug) { $client = Client::where(compact('slug'))->firstOrFail(); $client_request = $request->except('tabs'); $client->update($client_request); Toastr::success("Saved changes"); $tabs = explode(':', $request->get('tabs')); return redirect('/client/' . $client->slug . '/' . $tabs[0] . '/' . $tabs[1]); }
/** * Create a new controller instance. * * @return void */ public function index(Request $request) { $email = Option::where('key', 'contact.email')->first()->value; $phone = Option::where('key', 'contact.phone')->first()->value; $slogan = Option::where('key', 'site.slogan')->first()->value; $social_links = array('facebook' => Option::where('key', 'facebook.link')->first()->value, 'twitter' => Option::where('key', 'twitter.link')->first()->value, 'youtube' => Option::where('key', 'youtube.link')->first()->value, 'linkedin' => Option::where('key', 'linkedin.link')->first()->value, 'instagram' => Option::where('key', 'instagram.link')->first()->value); $data = array('services' => Service::orderBy('sort_order')->get(), 'clients' => Client::orderBy('sort_order')->get(), 'photos' => Photo::orderBy('sort_order')->get(), 'email' => $email, 'phone' => $phone, 'slogan' => $slogan, 'social_links' => $social_links); return view('home', $data); }
/** * Updates an existing Event model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'zal' => Zal::find()->asArray()->all(), 'client' => Client::find()->asArray()->orderBy('name_client')->all(), 'users' => Users::find()->asArray()->where(['status' => 10])->orderBy('username')->all()]); } }
public function anyAdd() { $data = Request::all(); if (count($data) > 0) { $UserDetails = new Client(); $UserDetails->fullname = $data['fullname']; $UserDetails->email = $data['email']; $UserDetails->order_number = $data['order_number']; $UserDetails->product_id = $data['product_id']; $UserDetails->note = $data['note']; if ($UserDetails->save()) { $email = $data['email']; $subject = 'Demo mail'; // subject you want for you email Session::flash('flash_message', 'successfully saved.'); return redirect('/warranty'); } } }
public function destroy($id) { try { $client = Client::findorFail($id); $client->delete(); Session()->flash('flash_message', 'Client successfully deleted'); } catch (\Illuminate\Database\QueryException $e) { Session()->flash('flash_message_warning', 'Client can NOT have, leads, or tasks assigned when deleted'); } }
public function save($data) { if (isset($data['client_id']) && $data['client_id']) { $data['client_id'] = Client::getPrivateId($data['client_id']); } if (isset($data['vendor_id']) && $data['vendor_id']) { $data['vendor_id'] = Vendor::getPrivateId($data['vendor_id']); } return $this->expenseRepo->save($data); }
public function clientData($id) { $clients = Client::select(['id', 'name', 'company_name', 'primary_number', 'email'])->where('fk_user_id', $id); return Datatables::of($clients)->addColumn('clientlink', function ($clients) { return '<a href="' . route('clients.show', $clients->id) . '">' . $clients->name . '</a>'; })->editColumn('created_at', function ($clients) { return $clients->created_at ? with(new Carbon($clients->created_at))->format('d/m/Y') : ''; })->editColumn('deadline', function ($clients) { return $clients->created_at ? with(new Carbon($clients->created_at))->format('d/m/Y') : ''; })->make(true); }
public function actionIndex() { $keywords = Yii::$app->request->get('k'); if ($keywords) { $sql_c = 'SELECT * FROM clients WHERE company LIKE "%' . $keywords . '%" OR firstname LIKE "%' . $keywords . '%" OR lastname LIKE "%' . $keywords . '%"'; $clients = new ActiveDataProvider(['query' => Client::findBySql($sql_c, [':key' => $keywords]), 'pagination' => ['pageSize' => 10]]); $sql_w = 'SELECT * FROM websites WHERE domain LIKE "%' . $keywords . '%"'; $websites = new ActiveDataProvider(['query' => Website::findBySql($sql_w, [':key' => $keywords]), 'pagination' => ['pageSize' => 10]]); return $this->render('index', ['clients' => $clients, 'websites' => $websites]); } }